Exemplo n.º 1
0
Arquivo: concat.py Projeto: 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)
Exemplo n.º 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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
Arquivo: prompt.py Projeto: 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()
Exemplo n.º 5
0
Arquivo: window.py Projeto: 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)
Exemplo n.º 6
0
 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()
Exemplo n.º 7
0
Arquivo: prompt.py Projeto: 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)
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
Arquivo: window.py Projeto: 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)
Exemplo n.º 10
0
 def __get_window_size(self):
     return vx.get_window_size(self)
Exemplo n.º 11
0
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)
Exemplo n.º 12
0
Arquivo: window.py Projeto: tj90241/vx
 def __get_window_size(self):
     return vx.get_window_size(self)
Exemplo n.º 13
0
Arquivo: window.py Projeto: 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)
Exemplo n.º 14
0
Arquivo: pane.py Projeto: 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)