Show More
@@ -62,15 +62,27 b' def _restore_term_title():' | |||||
62 | pass |
|
62 | pass | |
63 |
|
63 | |||
64 |
|
64 | |||
|
65 | _xterm_term_title_saved = False | |||
|
66 | ||||
|
67 | ||||
65 | def _set_term_title_xterm(title): |
|
68 | def _set_term_title_xterm(title): | |
66 | """ Change virtual terminal title in xterm-workalikes """ |
|
69 | """ Change virtual terminal title in xterm-workalikes """ | |
|
70 | global _xterm_term_title_saved | |||
|
71 | # Only save the title the first time we set, otherwise restore will only | |||
|
72 | # go back one title (probably undoing a %cd title change). | |||
|
73 | if not _xterm_term_title_saved: | |||
67 | # save the current title to the xterm "stack" |
|
74 | # save the current title to the xterm "stack" | |
68 | sys.stdout.write('\033[22;0t') |
|
75 | sys.stdout.write('\033[22;0t') | |
|
76 | _xterm_term_title_saved = True | |||
69 | sys.stdout.write('\033]0;%s\007' % title) |
|
77 | sys.stdout.write('\033]0;%s\007' % title) | |
70 |
|
78 | |||
71 |
|
79 | |||
72 | def _restore_term_title_xterm(): |
|
80 | def _restore_term_title_xterm(): | |
|
81 | # Make sure the restore has at least one accompanying set. | |||
|
82 | global _xterm_term_title_saved | |||
|
83 | assert _xterm_term_title_saved | |||
73 | sys.stdout.write('\033[23;0t') |
|
84 | sys.stdout.write('\033[23;0t') | |
|
85 | _xterm_term_title_saved = False | |||
74 |
|
86 | |||
75 |
|
87 | |||
76 | if os.name == 'posix': |
|
88 | if os.name == 'posix': |
General Comments 0
You need to be logged in to leave comments.
Login now