@@ -57,10 +57,14 @@ def curses_session():
|
|||||||
try:
|
try:
|
||||||
curses.start_color()
|
curses.start_color()
|
||||||
except:
|
except:
|
||||||
|
_logger.warning('Curses failed to initialize color support')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Hide the blinking cursor
|
# Hide the blinking cursor
|
||||||
|
try:
|
||||||
curses.curs_set(0)
|
curses.curs_set(0)
|
||||||
|
except:
|
||||||
|
_logger.warning('Curses failed to initialize the cursor mode')
|
||||||
|
|
||||||
# Assign the terminal's default (background) color to code -1
|
# Assign the terminal's default (background) color to code -1
|
||||||
curses.use_default_colors()
|
curses.use_default_colors()
|
||||||
|
|||||||
@@ -341,7 +341,14 @@ class Page(object):
|
|||||||
self._draw_content()
|
self._draw_content()
|
||||||
self._draw_footer()
|
self._draw_footer()
|
||||||
self._add_cursor()
|
self._add_cursor()
|
||||||
self.term.stdscr.touchwin()
|
# Note: There used to be a call to stdscr.touchwin() here. However, a
|
||||||
|
# bug was discovered in tmux when $TERM was set to `xterm-256color`,
|
||||||
|
# where only part of the screen got redrawn when scrolling. The correct
|
||||||
|
# solution is to use `screen-256color` (which gets set automatically by
|
||||||
|
# tmux) but many people override ther $TERM in their tmux.conf or
|
||||||
|
# .bashrc file. Using clearok() instead seems to fix the problem, at
|
||||||
|
# the expense of slightly more expensive screen refreshes.
|
||||||
|
self.term.stdscr.clearok(True)
|
||||||
self.term.stdscr.refresh()
|
self.term.stdscr.refresh()
|
||||||
|
|
||||||
def _draw_header(self):
|
def _draw_header(self):
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ from . import exceptions
|
|||||||
from . import mime_parsers
|
from . import mime_parsers
|
||||||
from .objects import LoadScreen, Color
|
from .objects import LoadScreen, Color
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Added in python 3.4+
|
# Added in python 3.4+
|
||||||
from html import unescape
|
from html import unescape
|
||||||
@@ -122,6 +121,17 @@ class Terminal(object):
|
|||||||
"""
|
"""
|
||||||
return curses.flash()
|
return curses.flash()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def curs_set(val):
|
||||||
|
"""
|
||||||
|
Change the cursor visibility, may fail for some terminals with limited
|
||||||
|
cursor support.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
curses.curs_set(val)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def addch(window, y, x, ch, attr):
|
def addch(window, y, x, ch, attr):
|
||||||
"""
|
"""
|
||||||
@@ -628,7 +638,7 @@ class Terminal(object):
|
|||||||
window.clear()
|
window.clear()
|
||||||
|
|
||||||
# Set cursor mode to 1 because 2 doesn't display on some terminals
|
# Set cursor mode to 1 because 2 doesn't display on some terminals
|
||||||
curses.curs_set(1)
|
self.curs_set(1)
|
||||||
|
|
||||||
# Keep insert_mode off to avoid the recursion error described here
|
# Keep insert_mode off to avoid the recursion error described here
|
||||||
# http://bugs.python.org/issue13051
|
# http://bugs.python.org/issue13051
|
||||||
@@ -656,7 +666,7 @@ class Terminal(object):
|
|||||||
except exceptions.EscapeInterrupt:
|
except exceptions.EscapeInterrupt:
|
||||||
out = None
|
out = None
|
||||||
|
|
||||||
curses.curs_set(0)
|
self.curs_set(0)
|
||||||
return self.strip_textpad(out)
|
return self.strip_textpad(out)
|
||||||
|
|
||||||
def prompt_input(self, prompt, key=False):
|
def prompt_input(self, prompt, key=False):
|
||||||
@@ -687,13 +697,13 @@ class Terminal(object):
|
|||||||
input_win.refresh()
|
input_win.refresh()
|
||||||
|
|
||||||
if key:
|
if key:
|
||||||
curses.curs_set(1)
|
self.curs_set(1)
|
||||||
ch = self.getch()
|
ch = self.getch()
|
||||||
# We can't convert the character to unicode, because it may return
|
# We can't convert the character to unicode, because it may return
|
||||||
# Invalid values for keys that don't map to unicode characters,
|
# Invalid values for keys that don't map to unicode characters,
|
||||||
# e.g. F1
|
# e.g. F1
|
||||||
text = ch if ch != self.ESCAPE else None
|
text = ch if ch != self.ESCAPE else None
|
||||||
curses.curs_set(0)
|
self.curs_set(0)
|
||||||
else:
|
else:
|
||||||
text = self.text_input(input_win)
|
text = self.text_input(input_win)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user