def ensure_visible(self, line, col): """Ensures that ``line`` and ``col`` are visible on the screen""" r, c = vx.get_window_size(self) y, x = line, col sy, sx = vx.get_linecol_start_window(self) # Check line if y < sy: sy = y - 6 elif y > sy + r: sy = y + 6 - r # Check col if x < sx: sx = max(1, x - 6) elif x > sx + c: sx = x + 6 - c self.topleft = (sy, sx)
def render(self): if self.has_contents: contents = self.contents r, c = vx.get_linecol_start_window(self) y, x = vx.get_window_size(self) lines = contents.split('\n')[r - 1:r + y - 1] cline = r ccol = c for i, line in enumerate(lines): line = line.replace('\t', ' ')[c - 1:c - 1 + x - 2] if len(line) == x - 2: line += '$' if c - 1 > 0: line = '$' + line[1:] self.color_line(cline, ccol, line) vx.print_string_window(self, '\n') cline += 1 for m in self.graffitis: m.render(self)
def render(self): if self.has_contents: contents = self.contents r, c = vx.get_linecol_start_window(self) y, x = vx.get_window_size(self) lines = contents.split('\n')[r-1:r+y-1] cline = r ccol = c for i, line in enumerate(lines): line = line.replace('\t', ' ')[c-1:c-1+x-2] if len(line) == x - 2: line += '$' if c-1 > 0: line = '$' + line[1:] self.color_line(cline, ccol, line) vx.print_string_window(self, '\n') cline += 1 for m in self.graffitis: m.render(self)
def __get_window_start(self): return vx.get_linecol_start_window(self)
def center(): r, c = vx.get_window_size(windows.focused) y, _ = windows.focused.cursor _, x = vx.get_linecol_start_window(windows.focused) new_top = max(y - r // 2, 1) windows.focused.topleft = (new_top, x)