Python curses.resizeterm() Examples
The following are 11
code examples of curses.resizeterm().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
curses
, or try the search function
.
Example #1
Source File: ui.py From musicbox with MIT License | 6 votes |
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()
Example #2
Source File: game.py From wpm with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #3
Source File: renderer.py From terminal_dungeon with MIT License | 5 votes |
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
Example #4
Source File: test_curses.py From medicare-demo with Apache License 2.0 | 5 votes |
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"
Example #5
Source File: tabview.py From guildai with Apache License 2.0 | 5 votes |
def _patch_curses_resizeterm(): if not hasattr(curses, "resizeterm"): assert hasattr(curses, "resize_term") curses.resizeterm = curses.resize_term
Example #6
Source File: ui.py From suplemon with MIT License | 5 votes |
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()
Example #7
Source File: program_window.py From ci_edit with Apache License 2.0 | 5 votes |
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()
Example #8
Source File: tabview.py From OpenTrader with GNU Lesser General Public License v3.0 | 4 votes |
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)
Example #9
Source File: window.py From plasma with GNU General Public License v3.0 | 4 votes |
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
Example #10
Source File: example_simple.py From PyZwaver with GNU General Public License v3.0 | 4 votes |
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()
Example #11
Source File: ui.py From suplemon with MIT License | 4 votes |
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)