示例#1
0
文件: window.py 项目: philipdexter/vx
    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)
示例#2
0
文件: window.py 项目: tj90241/vx
    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)
示例#3
0
文件: window.py 项目: philipdexter/vx
    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)
示例#4
0
文件: window.py 项目: tj90241/vx
    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)
示例#5
0
文件: window.py 项目: philipdexter/vx
 def __get_window_start(self):
     return vx.get_linecol_start_window(self)
示例#6
0
文件: window.py 项目: philipdexter/vx
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)
示例#7
0
文件: window.py 项目: tj90241/vx
 def __get_window_start(self):
     return vx.get_linecol_start_window(self)
示例#8
0
文件: window.py 项目: tj90241/vx
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)