From a3c2470ba93e63fda66639543eb3adc008baae41 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 11 Sep 2013 12:57:36 +0200 Subject: can do terminal initialisation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/editor.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/editor.py b/src/editor.py index 0a91f14..3ae23b7 100644 --- a/src/editor.py +++ b/src/editor.py @@ -97,11 +97,14 @@ class TextArea(): - def initialise(self): + def initialise(self, initalise_terminal): ''' Initialise terminal and TTY settings ''' - print('\033[H\033[2J') + self.initalise_terminal = initalise_terminal + if initalise_terminal: + print('\033[?1049h', end='', flush=True) + print('\033[H\033[2J', end='', flush=True) self.old_stty = Popen('stty --save'.split(' '), stdout = PIPE).communicate()[0] self.old_stty = self.old_stty.decode('utf-8', 'error')[:-1] Popen('stty -icanon -echo -isig -ixon -ixoff'.split(' '), stdout = PIPE).communicate() @@ -110,9 +113,11 @@ class TextArea(): ''' Restore the terminal to the state before `initialise` as invoked ''' - print('\033[H\033[2J', end = '') sys.stdout.flush() Popen(['stty', self.old_stty], stdout = PIPE).communicate() + print('\033[H\033[2J', end='', flush=True) + if self.initalise_terminal: + print('\033[?1049l', end='', flush=True) @@ -673,7 +678,7 @@ def phonysaver(): area = None try: area = TextArea(('a be se de e eff ge hå i ji kå ell emm enn o pe ku ärr ess te u ve dubbel-ve eks y säta å ä ö').split(' '), {}, 6, 4, 40, 10) - area.initialise() + area.initialise(True) area.run(phonysaver) finally: if area is not None: -- cgit v1.2.3-70-g09d2