Esempio n. 1
0
 def color_line(self, line_number, column_number, line):
     printed = 0
     start = 0
     this_line = list(filter(lambda x: x[1] == line_number,
                             self.color_tags))
     to_add = []
     this_line.sort(key=lambda n: n[2])
     for (i, c) in enumerate(this_line):
         tag, ctl, ctc, ctlen, fg, bg = c
         for oc in this_line:
             if c == oc: continue
             _, _, octc, octlen, _, _ = oc
             if octc == ctc and octlen < ctlen:
                 this_line[i] = (tag, ctl, octc + octlen,
                                 ctc + ctlen - (octc + octlen), fg, bg)
             elif octc == ctc and octlen == ctlen:
                 this_line[i] = (tag, ctl, ctc, 0, fg, bg)
             elif octc > ctc and octc < ctc + ctlen:
                 this_line[i] = (tag, ctl, ctc, octc - ctc, fg, bg)
                 if ctc + ctlen > octc + octlen:
                     to_add.append((tag, ctl, octc + octlen,
                                    ctc + ctlen - (octc + octlen), fg, bg))
     this_line.extend(to_add)
     this_line.sort(key=lambda n: n[2])
     for tag, _, ctc, ctlen, ctfg, ctbg in this_line:
         ctc -= column_number - 1
         vx.print_string_window(self, line[start:ctc - 1])
         printed += len(line[start:ctc - 1])
         start += len(line[start:ctc - 1])
         self.set_color(ctfg, ctbg)
         vx.print_string_window(self, line[ctc - 1:ctc - 1 + ctlen])
         self.set_color(-1, -1)
         printed += ctlen
         start += ctlen
     vx.print_string_window(self, line[printed:])
Esempio n. 2
0
 def color_line(self, line_number, column_number, line):
     printed = 0
     start = 0
     this_line = list(filter(lambda x: x[1] == line_number, self.color_tags))
     to_add = []
     this_line.sort(key=lambda n: n[2])
     for (i, c) in enumerate(this_line):
         tag, ctl, ctc, ctlen, fg, bg = c
         for oc in this_line:
             if c == oc: continue
             _, _, octc, octlen, _, _ = oc
             if octc == ctc and octlen < ctlen:
                 this_line[i] = (tag, ctl, octc + octlen, ctc+ctlen-(octc+octlen), fg, bg)
             elif octc == ctc and octlen == ctlen:
                 this_line[i] = (tag, ctl, ctc, 0, fg, bg)
             elif octc > ctc and octc < ctc + ctlen:
                 this_line[i] = (tag, ctl, ctc, octc - ctc, fg, bg)
                 if ctc + ctlen > octc + octlen:
                     to_add.append((tag, ctl, octc+octlen, ctc+ctlen-(octc+octlen), fg, bg))
     this_line.extend(to_add)
     this_line.sort(key=lambda n: n[2])
     for tag, _, ctc, ctlen, ctfg, ctbg in this_line:
         ctc -= column_number - 1
         vx.print_string_window(self, line[start:ctc-1])
         printed += len(line[start:ctc-1])
         start += len(line[start:ctc-1])
         self.set_color(ctfg, ctbg)
         vx.print_string_window(self, line[ctc-1:ctc-1+ctlen])
         self.set_color(-1, -1)
         printed += ctlen
         start += ctlen
     vx.print_string_window(self, line[printed:])
Esempio n. 3
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)
Esempio n. 4
0
File: window.py Progetto: 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)
Esempio n. 5
0
File: window.py Progetto: tj90241/vx
 def color_line(self, line_number, column_number, line):
     printed = 0
     start = 0
     for tag, _, ctc, ctlen, ctfg, ctbg in filter(lambda x: x[1] == line_number, self.color_tags):
         ctc -= column_number - 1
         vx.print_string_window(self, line[start:ctc-1])
         printed += len(line[start:ctc-1])
         start += len(line[start:ctc-1])
         self.set_color(ctfg, ctbg)
         vx.print_string_window(self, line[ctc-1:ctc-1+ctlen])
         self.set_color(-1, -1)
         printed += ctlen
         start += ctlen
     vx.print_string_window(self, line[printed:])
Esempio n. 6
0
 def render(self, window):
     vx.set_cursor(window, self.y, self.x)
     vx.print_string_window(window, self.text)
Esempio n. 7
0
File: window.py Progetto: tj90241/vx
 def render(self, window):
     vx.set_cursor(window, self.y, self.x)
     vx.print_string_window(window, self.text)