mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
Avoid needing to initialize tty state in bootstrap scripts
This commit is contained in:
@@ -194,6 +194,15 @@ class PTY:
|
||||
self.screen = Screen(self.callbacks, rows, columns, scrollback, cell_width, cell_height, 0, self.callbacks)
|
||||
self.received_bytes = b''
|
||||
|
||||
def turn_off_echo(self):
|
||||
s = termios.tcgetattr(self.master_fd)
|
||||
s[3] &= ~termios.ECHO
|
||||
termios.tcsetattr(self.master_fd, termios.TCSANOW, s)
|
||||
|
||||
def is_echo_on(self):
|
||||
s = termios.tcgetattr(self.master_fd)
|
||||
return True if s[3] & termios.ECHO else False
|
||||
|
||||
def __del__(self):
|
||||
if not self.is_child:
|
||||
fd = self.master_fd
|
||||
|
||||
@@ -156,6 +156,7 @@ copy --exclude */w.* d1
|
||||
pty.wait_till(lambda: 'TSET={}'.format(tset.replace('$A', 'AAA')) in pty.screen_contents())
|
||||
self.assertNotIn('COLORTERM', pty.screen_contents())
|
||||
pty.wait_till(lambda: '/cwd' in pty.screen_contents())
|
||||
self.assertTrue(pty.is_echo_on())
|
||||
|
||||
def test_ssh_bootstrap_with_different_launchers(self):
|
||||
for launcher in self.all_possible_sh:
|
||||
@@ -252,6 +253,7 @@ copy --exclude */w.* d1
|
||||
open(os.path.join(home_dir, '.zshrc'), 'w').close()
|
||||
cmd = wrap_bootstrap_script(script, sh)
|
||||
pty = self.create_pty([launcher, '-c', ' '.join(cmd)], cwd=home_dir, env=env)
|
||||
pty.turn_off_echo()
|
||||
del cmd
|
||||
if pre_data:
|
||||
pty.write_buf = pre_data.encode('utf-8')
|
||||
|
||||
Reference in New Issue
Block a user