本文整理汇总了Python中curses.resizeterm方法的典型用法代码示例。如果您正苦于以下问题:Python curses.resizeterm方法的具体用法?Python curses.resizeterm怎么用?Python curses.resizeterm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类curses
的用法示例。
在下文中一共展示了curses.resizeterm方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_size
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def update_size(self):
# get terminal size
size = terminalsize.get_terminal_size()
x = max(size[0], 10)
y = max(size[1], 25)
if (x, y) == (self.x, self.y): # no need to resize
return
self.x, self.y = x, y
# update intendations
curses.resizeterm(self.y, self.x)
self.startcol = int(float(self.x) / 5)
self.indented_startcol = max(self.startcol - 3, 0)
self.update_space()
self.screen.clear()
self.screen.refresh()
示例2: resize
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def resize(self):
"""Handle terminal resizing"""
# Check if screen was re-sized (True or False)
resize = self.max_x == 0 or \
curses.is_term_resized(self.max_y, self.max_x)
if resize is True:
self.recalculate_layout()
curses.resizeterm(self.max_y, self.max_x)
示例3: resize
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def resize(self):
"""Handles a resized terminal."""
self.screen.redraw = True
max_y, max_x = self.screen.window.getmaxyx()
self.screen.clear()
# Check if we have the resizeterm ncurses extension
if hasattr(curses, "resizeterm"):
curses.resizeterm(max_y, max_x)
# An ungetch for KEY_RESIZE will be sent to let others handle it.
# We'll just pop it off again to prevent endless loops.
self.screen.get_key()
self.screen.set_quote(self.quote)
if self.start is not None and self.stop is None:
# Resize during typing requires redrawing quote.
self.screen.update_quote(Screen.COLOR_QUOTE)
self.screen.update_author()
if self.position + self.incorrect <= len(self.quote.text):
for pos in range(self.position + 1):
self.screen.highlight_progress(pos, 0)
for inc in range(self.incorrect + 1):
self.screen.highlight_progress(self.position, inc)
示例4: resize
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def resize(self):
self.width, self.height = os.get_terminal_size()
curses.resizeterm(self.height, self.width)
self.angle_increment = 1 / self.width
self.floor_y = self.height // 2
self.distances = [0] * self.width
示例5: test_resize_term
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def test_resize_term(stdscr):
if hasattr(curses, 'resizeterm'):
lines, cols = curses.LINES, curses.COLS
curses.resizeterm(lines - 1, cols + 1)
if curses.LINES != lines - 1 or curses.COLS != cols + 1:
raise RuntimeError, "Expected resizeterm to update LINES and COLS"
示例6: _patch_curses_resizeterm
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def _patch_curses_resizeterm():
if not hasattr(curses, "resizeterm"):
assert hasattr(curses, "resize_term")
curses.resizeterm = curses.resize_term
示例7: resize
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def resize(self, yx=None):
"""Resize UI to yx."""
if yx is None:
yx = self.screen.getmaxyx()
self.screen.erase()
curses.resizeterm(yx[0], yx[1])
self.setup_windows()
示例8: handleScreenResize
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def handleScreenResize(self, window):
#app.log.debug('handleScreenResize -----------------------')
if sys.platform == 'darwin':
# Some terminals seem to resize the terminal and others leave it
# to the application to resize the curses terminal.
rows, cols = app.curses_util.terminalSize()
curses.resizeterm(rows, cols)
self.top = self.left = 0
self.rows, self.cols = app.window.mainCursesWindow.getmaxyx()
self.layout()
window.controller.onChange()
self.render()
示例9: start_view
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def start_view(self, screen):
self.screen = screen
screen.keypad(False)
(last_h, last_w) = screen.getmaxyx()
refr = False
self.refresh_all()
while 1:
(h, w) = screen.getmaxyx()
self.height = h
self.width = w
if h != last_h or w != last_w:
# TODO : resizing
screen.erase()
curses.resizeterm(h, w)
last_h = h
last_w = w
refr = True
if self.cursor_y > h:
self.cursor_y = h - 5
if self.cursor_y < 0:
self.cursor_y = 0
if self.cursor_x > w:
self.cursor_x = w - 3
wdgt = self.widgets[self.focus_widget_idx]
if refr:
wdgt.draw()
refr = False
wdgt.draw_cursor()
wdgt.screen.refresh()
k = self.read_escape_keys()
refr = self.do_key(k)
if wdgt.should_stop:
wdgt.should_stop = False # because the console saves widgets
screen.erase()
return wdgt.value_selected
screen.erase()
return wdgt.value_selected
示例10: Redraw
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def Redraw(self):
self.stdscr.clear()
if curses.is_term_resized(self.h, self.w):
self.h, self.w = self.stdscr.getmaxyx()
curses.resizeterm(self.h, self.w)
i = 0
i += self._titleyx(i, 0, "CONTROLLER")
lines = str(self.controller).split("\n")
i += self._printyx(i, 0, lines)
def render_node(n):
if n == self.controller.GetNodeId():
return"node %d CONTROLLER" % n
elif n in self.controller.failed_nodes:
return"node %d FAILED" % n
elif n in self.nodeset.nodes:
node = self.nodeset.nodes[n]
return "%s %s" % (node.Name(), node.state)
else:
return "Node %d UNKNOWN" % n
i += self._titleyx(i, 0, "NODES")
nodes = set(self.controller.nodes) | self.nodeset.nodes.keys()
lines = [render_node(n) for n in nodes]
i += self._printyx(i, 0, lines)
i += self._titleyx(i, 0, "QUEUE")
lines = self.driver.OutQueueString().split("\n")
i += self._printyx(i, 0, lines)
i += self._titleyx(i, 0, "STATS")
lines = MessageStatsString(self.driver.History()).split("\n")
i += self._printyx(i, 0, lines)
i = 1
lines = [self.format(r) for r in self.messages[-self.h + 2:]]
self._printyx(i, 81, lines)
i += len(lines) + 1
self.stdscr.refresh()
示例11: setup_windows
# 需要导入模块: import curses [as 别名]
# 或者: from curses import resizeterm [as 别名]
def setup_windows(self):
"""Initialize and layout windows."""
# We are using curses.newwin instead of self.screen.subwin/derwin because
# subwindows are getting a special treatment on resize. e.g., the legend
# bar may automatically resize to one line if the window gets smaller.
# Even after doing the layout by moving the legend window into its proper
# place a call to resize() to restore the 2 line height will error out.
# This does not happen with curses.newwin().
#
# https://anonscm.debian.org/cgit/collab-maint/ncurses.git/tree/ncurses/base/resizeterm.c#n274
# https://anonscm.debian.org/cgit/collab-maint/ncurses.git/tree/ncurses/base/wresize.c#n87
self.text_input = None
offset_top = 0
offset_bottom = 0
y, x = self.screen.getmaxyx()
config = self.app.config["display"]
if config["show_top_bar"]:
offset_top += 1
if self.header_win is None:
self.header_win = curses.newwin(1, x, 0, 0)
elif self.header_win.getmaxyx()[1] != x:
# Header bar don't ever need to move
self.header_win.resize(1, x)
if config["show_bottom_bar"]:
offset_bottom += 1
if self.status_win is None:
self.status_win = curses.newwin(1, x, y - offset_bottom, 0)
else:
self.status_win.mvwin(y - offset_bottom, 0)
if self.status_win.getmaxyx()[1] != x:
self.status_win.resize(1, x)
if config["show_legend"]:
offset_bottom += 2
if self.legend_win is None:
self.legend_win = curses.newwin(2, x, y - offset_bottom, 0)
else:
self.legend_win.mvwin(y - offset_bottom, 0)
if self.legend_win.getmaxyx()[1] != x:
self.legend_win.resize(2, x)
if self.editor_win is None:
self.editor_win = curses.newwin(y - offset_top - offset_bottom, x, offset_top, 0)
else:
# Not sure why editor implements this on its own
# and if it's a good thing or not.
self.app.get_editor().resize((y - offset_top - offset_bottom, x))
self.app.get_editor().move_win((offset_top, 0))
# self.editor_win.mvwin(offset_top, 0)
# self.editor_win.resize(y - offset_top - offset_bottom, x)