aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-09-11 12:57:36 +0200
committerMattias Andrée <maandree@operamail.com>2013-09-11 12:57:36 +0200
commita3c2470ba93e63fda66639543eb3adc008baae41 (patch)
tree1e3b5cc8966cb48b3740a88161e998711ac560ce
parentthe text area can take care of terminal settings (diff)
downloadpytagomacs-a3c2470ba93e63fda66639543eb3adc008baae41.tar.gz
pytagomacs-a3c2470ba93e63fda66639543eb3adc008baae41.tar.bz2
pytagomacs-a3c2470ba93e63fda66639543eb3adc008baae41.tar.xz
can do terminal initialisation
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--src/editor.py13
1 files 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: