|
@@ -105,6 +105,9 @@ class CursesClient(object):
|
|
|
if not prompt.endswith(' '):
|
|
if not prompt.endswith(' '):
|
|
|
prompt += ' '
|
|
prompt += ' '
|
|
|
|
|
|
|
|
|
|
+ if not self._input_window:
|
|
|
|
|
+ return raw_input(prompt)
|
|
|
|
|
+
|
|
|
prompt, _attrs = self._get_attrs(prompt)
|
|
prompt, _attrs = self._get_attrs(prompt)
|
|
|
|
|
|
|
|
if self.show_cursor:
|
|
if self.show_cursor:
|
|
@@ -132,21 +135,27 @@ class CursesClient(object):
|
|
|
if any(p for p in self.ignore_patterns if p in s):
|
|
if any(p for p in self.ignore_patterns if p in s):
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
- while self._y_pos >= self._height:
|
|
|
|
|
- self._main_window.scroll()
|
|
|
|
|
- self._y_pos -= 1
|
|
|
|
|
-
|
|
|
|
|
s, _attrs = self._get_attrs(s, base_attrs=attrs)
|
|
s, _attrs = self._get_attrs(s, base_attrs=attrs)
|
|
|
|
|
+
|
|
|
|
|
+ if self._main_window:
|
|
|
|
|
+ while self._y_pos >= self._height:
|
|
|
|
|
+ self._main_window.scroll()
|
|
|
|
|
+ self._y_pos -= 1
|
|
|
|
|
|
|
|
- self._main_window.addstr(self._y_pos, 0, s.encode('utf-8'), _attrs)
|
|
|
|
|
- self._y_pos += 1
|
|
|
|
|
|
|
+ self._main_window.addstr(self._y_pos, 0, s.encode('utf-8'), _attrs)
|
|
|
|
|
+ self._y_pos += 1
|
|
|
|
|
|
|
|
- self._main_window.refresh()
|
|
|
|
|
|
|
+ else:
|
|
|
|
|
+ print s.encode('utf-8')
|
|
|
|
|
+
|
|
|
|
|
+ if self._main_window:
|
|
|
|
|
+ self._main_window.refresh()
|
|
|
|
|
|
|
|
def clear(self):
|
|
def clear(self):
|
|
|
- self._main_window.clear()
|
|
|
|
|
- self._main_window.refresh()
|
|
|
|
|
- self._y_pos = 0
|
|
|
|
|
|
|
+ if self._main_window:
|
|
|
|
|
+ self._main_window.clear()
|
|
|
|
|
+ self._main_window.refresh()
|
|
|
|
|
+ self._y_pos = 0
|
|
|
|
|
|
|
|
def _run(self, stdscr, main_method, **kwargs):
|
|
def _run(self, stdscr, main_method, **kwargs):
|
|
|
curses.echo()
|
|
curses.echo()
|
|
@@ -187,11 +196,14 @@ class CursesClient(object):
|
|
|
self.read_str('Press enter to quit.')
|
|
self.read_str('Press enter to quit.')
|
|
|
|
|
|
|
|
def run(self, main_method, intercept_output_streams=False, **kwargs):
|
|
def run(self, main_method, intercept_output_streams=False, **kwargs):
|
|
|
- old_stdout, old_stderr = sys.stdout, sys.stderr
|
|
|
|
|
- if intercept_output_streams:
|
|
|
|
|
- sys.stdout = StreamWriter(self)
|
|
|
|
|
- sys.stderr = StreamWriter(self)
|
|
|
|
|
|
|
+ if True:
|
|
|
|
|
+ old_stdout, old_stderr = sys.stdout, sys.stderr
|
|
|
|
|
+ if intercept_output_streams:
|
|
|
|
|
+ sys.stdout = StreamWriter(self)
|
|
|
|
|
+ sys.stderr = StreamWriter(self)
|
|
|
|
|
|
|
|
- curses.wrapper(self._run, main_method=main_method, **kwargs)
|
|
|
|
|
|
|
+ curses.wrapper(self._run, main_method=main_method, **kwargs)
|
|
|
|
|
+ sys.stdout, sys.stderr = old_stdout, old_stderr
|
|
|
|
|
|
|
|
- sys.stdout, sys.stderr = old_stdout, old_stderr
|
|
|
|
|
|
|
+ else:
|
|
|
|
|
+ main_method(**kwargs)
|