コード例 #1
0
ファイル: concat.py プロジェクト: tj90241/vx
 def center_me(self, what=None):
     if what is None:
         window.center()
     else:
         _, _, rb, cb = what()
         r, _ = vx.get_window_size(self.for_window)
         _, x = self.for_window.topleft
         new_top = max(rb - r // 2, 1)
         self.for_window.topleft = (new_top, x)
         y, x = self.for_window.cursor
         if y < new_top: self.for_window.cursor = (new_top, x)
         elif y > new_top + r: self.for_window.cursor = (new_top + r, x)
コード例 #2
0
 def center_me(self, what=None):
     if what is None:
         window.center()
     else:
         _, _, rb, cb = what()
         r, _ = vx.get_window_size(self.for_window)
         _, x = self.for_window.topleft
         new_top = max(rb - r // 2, 1)
         self.for_window.topleft = (new_top, x)
         y, x = self.for_window.cursor
         if y < new_top: self.for_window.cursor = (new_top, x)
         elif y > new_top + r: self.for_window.cursor = (new_top + r, x)
コード例 #3
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)
コード例 #4
0
ファイル: prompt.py プロジェクト: tj90241/vx
 def getout(self):
     contents = self.contents
     ret = False
     try:
         answer = contents.split(':')[1].strip()
         if answer.lower() in ('y', 'yes'):
             ret = True
     except:
         return
     y, x = vx.get_window_size(self)
     self.attached_to.grow(bottom=y)
     self.attached_to.focus()
     self.remove(force=True)
     if ret and self.yes:
         self.yes()
     elif self.no:
         self.no()
コード例 #5
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)
コード例 #6
0
ファイル: prompt.py プロジェクト: philipdexter/vx
 def getout(self):
     contents = self.contents
     ret = False
     try:
         answer = contents.split(':')[1].strip()
         if answer.lower() in ('y', 'yes'):
             ret = True
     except:
         return
     y, x = vx.get_window_size(self)
     self.attached_to.grow(bottom=y)
     self.attached_to.focus()
     self.remove(force=True)
     if ret and self.yes:
         self.yes()
     elif self.no:
         self.no()
コード例 #7
0
ファイル: prompt.py プロジェクト: tj90241/vx
 def getout(self, force=False, cancel_open=False):
     if not force and self.attached_to.dirty:
         self.attached_to.focus()
         yn_prompt('Window is dirty, really open another file?',
                    partial(self.getout, force=True),
                    partial(self.getout, force=True, cancel_open=True))
         return
     y, x = vx.get_window_size(self)
     self.attached_to.grow(bottom=y)
     self.attached_to.focus()
     if not cancel_open:
         contents = self.contents
         if isfile(contents):
             self.attached_to.attach_file(contents)
             self.attached_to.dirty = False
         else:
             split = self.attached_to.split_h()
             split.focus()
             split.add_string('file "{}" does not exist'.format(contents))
     self.remove(force=True)
コード例 #8
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)
コード例 #9
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)
コード例 #10
0
ファイル: window.py プロジェクト: philipdexter/vx
 def __get_window_size(self):
     return vx.get_window_size(self)
コード例 #11
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)
コード例 #12
0
ファイル: window.py プロジェクト: tj90241/vx
 def __get_window_size(self):
     return vx.get_window_size(self)
コード例 #13
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)
コード例 #14
0
ファイル: pane.py プロジェクト: tj90241/vx
 def close_prompt(p):
     import vx
     self.windows.remove(p)
     self.grow(bottom=vx.get_window_size(p)[0])
     organizer.switch_to_pane(self)