Beispiel #1
0
 def write_nack(self):
     color = get_theme().COLOR_CHAR_NACK
     self._win.attron(to_curses_attr(color))
     self.addstr(get_theme().CHAR_NACK)
     self._win.attroff(to_curses_attr(color))
     self.addstr(' ')
     return poopt.wcswidth(get_theme().CHAR_NACK) + 1
Beispiel #2
0
 def refresh(self):
     with g_lock:
         self._win.erase()
         self._win.attron(to_curses_attr(self.color))
         self.addstr(0, 0, self.text)
         self._win.attroff(to_curses_attr(self.color))
         self._refresh()
Beispiel #3
0
 def write_nack(self):
     color = get_theme().COLOR_CHAR_NACK
     self._win.attron(to_curses_attr(color))
     self.addstr(get_theme().CHAR_NACK)
     self._win.attroff(to_curses_attr(color))
     self.addstr(' ')
     return poopt.wcswidth(get_theme().CHAR_NACK) + 1
Beispiel #4
0
 def write_contact_jid(self, jid):
     """
     Just write the jid that we are talking to
     """
     self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self.addstr(jid.full, to_curses_attr(get_theme().COLOR_CONVERSATION_NAME))
     self.addstr('] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #5
0
 def rewrite_text(self):
     """
     Refresh the line onscreen, but first, always adjust the
     view_pos.  Also, each FORMAT_CHAR+attr_char count only take
     one screen column (this is done in addstr_colored_lite), we
     have to do some special calculations to find the correct
     length of text to display, and the position of the cursor.
     """
     self.adjust_view_pos()
     text = self.text
     self._win.erase()
     if self.color:
         self._win.attron(to_curses_attr(self.color))
     displayed_text = text[self.view_pos:self.view_pos + self.width -
                           1].replace('\t', '\x18')
     self._win.attrset(0)
     self.addstr_colored_lite(displayed_text)
     # Fill the rest of the line with the input color
     if self.color:
         (_, x) = self._win.getyx()
         size = self.width - x
         self.addnstr(' ' * size, size, to_curses_attr(self.color))
     self.addstr(0,
                 poopt.wcswidth(displayed_text[:self.pos - self.view_pos]),
                 '')
     if self.color:
         self._win.attroff(to_curses_attr(self.color))
     curses.curs_set(1)
     self._refresh()
Beispiel #6
0
 def rewrite_text(self):
     """
     Refresh the line onscreen, but first, always adjust the
     view_pos.  Also, each FORMAT_CHAR+attr_char count only take
     one screen column (this is done in addstr_colored_lite), we
     have to do some special calculations to find the correct
     length of text to display, and the position of the cursor.
     """
     self.adjust_view_pos()
     text = self.text
     self._win.erase()
     if self.color:
         self._win.attron(to_curses_attr(self.color))
     displayed_text = text[self.view_pos:self.view_pos+self.width-1].replace('\t', '\x18')
     self._win.attrset(0)
     self.addstr_colored_lite(displayed_text)
     # Fill the rest of the line with the input color
     if self.color:
         (_, x) = self._win.getyx()
         size = self.width - x
         self.addnstr(' ' * size, size, to_curses_attr(self.color))
     self.addstr(0,
             poopt.wcswidth(displayed_text[:self.pos-self.view_pos]), '')
     if self.color:
         self._win.attroff(to_curses_attr(self.color))
     curses.curs_set(1)
     self._refresh()
Beispiel #7
0
 def write_contact_jid(self, jid):
     """
     Just write the jid that we are talking to
     """
     self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self.addstr(jid.full,
                 to_curses_attr(get_theme().COLOR_CONVERSATION_NAME))
     self.addstr('] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #8
0
 def write_contact_informations(self, contact):
     """
     Write the informations about the contact
     """
     if not contact:
         self.addstr("(contact not in roster)", to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
         return
     display_name = contact.name
     if display_name:
         self.addstr('%s '%(display_name), to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #9
0
 def draw_resource_line(self, y, resource, colored):
     """
     Draw a specific resource line
     """
     color = get_theme().color_show(resource.presence)
     self.addstr(y, 4, get_theme().CHAR_STATUS, to_curses_attr(color))
     if colored:
         self.addstr(y, 6, self.truncate_name(str(resource.jid), 6), to_curses_attr(get_theme().COLOR_SELECTED_ROW))
     else:
         self.addstr(y, 6, self.truncate_name(str(resource.jid), 6))
     self.finish_line()
Beispiel #10
0
 def write_contact_jid(self, jid):
     """
     Just displays the resource in an other color
     """
     log.debug("write_contact_jid DynamicConversationInfoWin, jid: %s",
             jid.resource)
     self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self.addstr(jid.bare, to_curses_attr(get_theme().COLOR_CONVERSATION_NAME))
     if jid.resource:
         self.addstr("/%s" % (jid.resource,), to_curses_attr(get_theme().COLOR_CONVERSATION_RESOURCE))
     self.addstr('] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #11
0
 def refresh(self, name=None, window=None):
     log.debug('Refresh: %s', self.__class__.__name__)
     self._win.erase()
     if name:
         self.addstr(name, to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     else:
         self.addstr(self.message, to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     if window:
         self.print_scroll_position(window)
     self.finish_line(get_theme().COLOR_INFORMATION_BAR)
     self._refresh()
Beispiel #12
0
 def refresh(self):
     self._win.erase()
     self._win.attron(to_curses_attr(self.color))
     format_string = '←{:^%s}→' % 7
     inp = format_string.format(repr(self.value))
     self.addstr(0, 0, inp)
     if self.last_key == 'KEY_RIGHT':
         self.move(0, 8)
     else:
         self.move(0, 0)
     self._win.attroff(to_curses_attr(self.color))
     self._refresh()
Beispiel #13
0
 def draw_resource_line(self, y, resource, colored):
     """
     Draw a specific resource line
     """
     color = get_theme().color_show(resource.presence)
     self.addstr(y, 4, get_theme().CHAR_STATUS, to_curses_attr(color))
     if colored:
         self.addstr(y, 6, self.truncate_name(str(resource.jid), 6),
                     to_curses_attr(get_theme().COLOR_SELECTED_ROW))
     else:
         self.addstr(y, 6, self.truncate_name(str(resource.jid), 6))
     self.finish_line()
Beispiel #14
0
 def write_resource_information(self, resource):
     """
     Write the informations about the resource
     """
     if not resource:
         presence = "unavailable"
     else:
         presence = resource.presence
     color = get_theme().color_show(presence)
     self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self.addstr(get_theme().CHAR_STATUS, to_curses_attr(color))
     self.addstr(']', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #15
0
 def write_contact_informations(self, contact):
     """
     Write the informations about the contact
     """
     if not contact:
         self.addstr("(contact not in roster)",
                     to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
         return
     display_name = contact.name
     if display_name:
         self.addstr('%s ' % (display_name),
                     to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #16
0
 def write_resource_information(self, resource):
     """
     Write the informations about the resource
     """
     if not resource:
         presence = "unavailable"
     else:
         presence = resource.presence
     color = get_theme().color_show(presence)
     self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self.addstr(get_theme().CHAR_STATUS, to_curses_attr(color))
     self.addstr(']', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #17
0
 def refresh(self):
     self._win.erase()
     self._win.attron(to_curses_attr(self.color))
     format_string = '←{:^%s}→' % 7
     inp = format_string.format(repr(self.value))
     self.addstr(0, 0, inp)
     if self.last_key == 'KEY_RIGHT':
         self.move(0, 8)
     else:
         self.move(0, 0)
     self._win.attroff(to_curses_attr(self.color))
     self._refresh()
Beispiel #18
0
 def addstr_colored(self, text, y=None, x=None):
     """
     Write a string on the window, setting the
     attributes as they are in the string.
     For example:
     \x19bhello → hello in bold
     \x191}Bonj\x192}our → 'Bonj' in red and 'our' in green
     next_attr_char is the \x19 delimiter
     attr_char is the char following it, it can be
     one of 'u', 'b', 'c[0-9]'
     """
     if y is not None and x is not None:
         self.move(y, x)
     next_attr_char = text.find(FORMAT_CHAR)
     while next_attr_char != -1 and text:
         if next_attr_char + 1 < len(text):
             attr_char = text[next_attr_char + 1].lower()
         else:
             attr_char = str()
         if next_attr_char != 0:
             self.addstr(text[:next_attr_char])
         if attr_char == 'o':
             self._win.attrset(0)
         elif attr_char == 'u':
             self._win.attron(curses.A_UNDERLINE)
         elif attr_char == 'b':
             self._win.attron(curses.A_BOLD)
         if (attr_char in string.digits
                 or attr_char == '-') and attr_char != '':
             color_str = text[next_attr_char +
                              1:text.find('}', next_attr_char)]
             if ',' in color_str:
                 tup, char = read_tuple(color_str)
                 self._win.attron(to_curses_attr(tup))
                 if char:
                     if char == 'o':
                         self._win.attrset(0)
                     elif char == 'u':
                         self._win.attron(curses.A_UNDERLINE)
                     elif char == 'b':
                         self._win.attron(curses.A_BOLD)
                 else:
                     # this will reset previous bold/uderline sequences if any was used
                     self._win.attroff(curses.A_UNDERLINE)
                     self._win.attroff(curses.A_BOLD)
             elif color_str:
                 self._win.attron(to_curses_attr((int(color_str), -1)))
             text = text[next_attr_char + len(color_str) + 2:]
         else:
             text = text[next_attr_char + 2:]
         next_attr_char = text.find(FORMAT_CHAR)
     self.addstr(text)
Beispiel #19
0
 def rewrite_text(self):
     self._win.erase()
     if self.color:
         self._win.attron(to_curses_attr(self.color))
     self.addstr('*'*len(self.text[self.view_pos:self.view_pos+self.width-1]))
     if self.color:
         (y, x) = self._win.getyx()
         size = self.width-x
         self.addnstr(' '*size, size, to_curses_attr(self.color))
     self.addstr(0, self.pos, '')
     if self.color:
         self._win.attroff(to_curses_attr(self.color))
     self._refresh()
Beispiel #20
0
 def refresh(self):
     self._win.erase()
     self._win.attron(to_curses_attr(self.color))
     self.addnstr(0, 0, ' '*(8), self.width)
     self.addstr(0, 2, "%s"%self.value)
     self.addstr(0, 8, '→')
     self.addstr(0, 0, '←')
     if self.last_key == 'KEY_RIGHT':
         self.addstr(0, 8, '')
     else:
         self.addstr(0, 0, '')
     self._win.attroff(to_curses_attr(self.color))
     self._refresh()
Beispiel #21
0
 def refresh(self):
     self._win.erase()
     self._win.attron(to_curses_attr(self.color))
     self.addnstr(0, 0, ' '*self.width, self.width)
     if self.val_pos > 0:
         self.addstr(0, 0, '←')
     if self.val_pos < len(self.options)-1:
         self.addstr(0, self.width-1, '→')
     if self.options:
         option = self.options[self.val_pos]['label']
         self.addstr(0, self.width//2-len(option)//2, option)
     self._win.attroff(to_curses_attr(self.color))
     self._refresh()
Beispiel #22
0
 def rewrite_text(self):
     self._win.erase()
     if self.color:
         self._win.attron(to_curses_attr(self.color))
     self.addstr('*'*len(self.text[self.view_pos:self.view_pos+self.width-1]))
     if self.color:
         (y, x) = self._win.getyx()
         size = self.width-x
         self.addnstr(' '*size, size, to_curses_attr(self.color))
     self.addstr(0, self.pos, '')
     if self.color:
         self._win.attroff(to_curses_attr(self.color))
     self._refresh()
Beispiel #23
0
 def refresh(self):
     self._win.erase()
     self._win.attron(to_curses_attr(self.color))
     self.addnstr(0, 0, ' '*(8), self.width)
     self.addstr(0, 2, "%s"%self.value)
     self.addstr(0, 8, '→')
     self.addstr(0, 0, '←')
     if self.last_key == 'KEY_RIGHT':
         self.addstr(0, 8, '')
     else:
         self.addstr(0, 0, '')
     self._win.attroff(to_curses_attr(self.color))
     self._refresh()
Beispiel #24
0
 def refresh(self, name=None, window=None):
     log.debug('Refresh: %s', self.__class__.__name__)
     self._win.erase()
     if name:
         self.addstr(name,
                     to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     else:
         self.addstr(self.message,
                     to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     if window:
         self.print_scroll_position(window)
     self.finish_line(get_theme().COLOR_INFORMATION_BAR)
     self._refresh()
Beispiel #25
0
 def refresh(self):
     self._win.erase()
     self._win.attron(to_curses_attr(self.color))
     self.addnstr(0, 0, ' '*self.width, self.width)
     if self.val_pos > 0:
         self.addstr(0, 0, '←')
     if self.val_pos < len(self.options)-1:
         self.addstr(0, self.width-1, '→')
     if self.options:
         option = self.options[self.val_pos]
         self.addstr(0, self.width//2-len(option)//2, option)
     self._win.attroff(to_curses_attr(self.color))
     self._refresh()
Beispiel #26
0
 def refresh(self):
     with g_lock:
         self._win.erase()
         self._win.attron(to_curses_attr(self.color))
         self.addnstr(0, 0, ' '*self.width, self.width)
         if self.val_pos > 0:
             self.addstr(0, 0, '←')
         if self.val_pos < len(self.options)-1:
             self.addstr(0, self.width-1, '→')
         option = self.options[self.val_pos]
         self.addstr(0, self.width//2-len(option)//2, option[0]['label'])
         self.addstr(0, 2, '✔' if option[1] else '☐')
         self._win.attroff(to_curses_attr(self.color))
         self._refresh()
Beispiel #27
0
 def refresh(self, topic=None):
     log.debug('Refresh: %s', self.__class__.__name__)
     self._win.erase()
     if topic:
         msg = topic[:self.width - 1]
     else:
         msg = self._message[:self.width - 1]
     self.addstr(0, 0, msg, to_curses_attr(get_theme().COLOR_TOPIC_BAR))
     (y, x) = self._win.getyx()
     remaining_size = self.width - x
     if remaining_size:
         self.addnstr(' ' * remaining_size, remaining_size,
                      to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self._refresh()
Beispiel #28
0
 def refresh(self, topic=None):
     log.debug('Refresh: %s', self.__class__.__name__)
     self._win.erase()
     if topic:
         msg = topic[:self.width-1]
     else:
         msg = self._message[:self.width-1]
     self.addstr(0, 0, msg, to_curses_attr(get_theme().COLOR_TOPIC_BAR))
     (y, x) = self._win.getyx()
     remaining_size = self.width - x
     if remaining_size:
         self.addnstr(' '*remaining_size, remaining_size,
                      to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self._refresh()
Beispiel #29
0
 def write_contact_jid(self, jid):
     """
     Just displays the resource in an other color
     """
     log.debug("write_contact_jid DynamicConversationInfoWin, jid: %s",
               jid.resource)
     self.addstr('[', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self.addstr(jid.bare,
                 to_curses_attr(get_theme().COLOR_CONVERSATION_NAME))
     if jid.resource:
         self.addstr(
             "/%s" % (jid.resource, ),
             to_curses_attr(get_theme().COLOR_CONVERSATION_RESOURCE))
     self.addstr('] ', to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #30
0
 def addstr_colored(self, text, y=None, x=None):
     """
     Write a string on the window, setting the
     attributes as they are in the string.
     For example:
     \x19bhello → hello in bold
     \x191}Bonj\x192}our → 'Bonj' in red and 'our' in green
     next_attr_char is the \x19 delimiter
     attr_char is the char following it, it can be
     one of 'u', 'b', 'c[0-9]'
     """
     if y is not None and x is not None:
         self.move(y, x)
     next_attr_char = text.find(FORMAT_CHAR)
     while next_attr_char != -1 and text:
         if next_attr_char + 1 < len(text):
             attr_char = text[next_attr_char+1].lower()
         else:
             attr_char = str()
         if next_attr_char != 0:
             self.addstr(text[:next_attr_char])
         if attr_char == 'o':
             self._win.attrset(0)
         elif attr_char == 'u':
             self._win.attron(curses.A_UNDERLINE)
         elif attr_char == 'b':
             self._win.attron(curses.A_BOLD)
         if (attr_char in string.digits or attr_char == '-') and attr_char != '':
             color_str = text[next_attr_char+1:text.find('}', next_attr_char)]
             if ',' in color_str:
                 tup, char = read_tuple(color_str)
                 self._win.attron(to_curses_attr(tup))
                 if char:
                     if char == 'o':
                         self._win.attrset(0)
                     elif char == 'u':
                         self._win.attron(curses.A_UNDERLINE)
                     elif char == 'b':
                         self._win.attron(curses.A_BOLD)
                 else:
                     # this will reset previous bold/uderline sequences if any was used
                     self._win.attroff(curses.A_UNDERLINE)
                     self._win.attroff(curses.A_BOLD)
             elif color_str:
                 self._win.attron(to_curses_attr((int(color_str), -1)))
             text = text[next_attr_char+len(color_str)+2:]
         else:
             text = text[next_attr_char+2:]
         next_attr_char = text.find(FORMAT_CHAR)
     self.addstr(text)
Beispiel #31
0
 def refresh(self):
     if not self.edition_input:
         self._win.erase()
         self._win.attron(to_curses_attr(self.color))
         self.addnstr(0, 0, ' '*self.width, self.width)
         option = self.options[self.val_pos]
         self.addstr(0, self.width//2-len(option)//2, option)
         if self.val_pos > 0:
             self.addstr(0, 0, '←')
         if self.val_pos < len(self.options)-1:
             self.addstr(0, self.width-1, '→')
         self._win.attroff(to_curses_attr(self.color))
         self._refresh()
     else:
         self.edition_input.refresh()
Beispiel #32
0
 def draw_group(self, y, group, colored):
     """
     Draw a groupname on a line
     """
     if colored:
         self._win.attron(to_curses_attr(get_theme().COLOR_SELECTED_ROW))
     if group.folded:
         self.addstr(y, 0, '[+] ')
     else:
         self.addstr(y, 0, '[-] ')
     contacts = " (%s/%s)" % (group.get_nb_connected_contacts(), len(group))
     self.addstr(y, 4, self.truncate_name(group.name, len(contacts)+4) + contacts)
     if colored:
         self._win.attroff(to_curses_attr(get_theme().COLOR_SELECTED_ROW))
     self.finish_line()
Beispiel #33
0
 def refresh(self):
     if not self.edition_input:
         with g_lock:
             self._win.erase()
             self._win.attron(to_curses_attr(self.color))
             self.addnstr(0, 0, ' '*self.width, self.width)
             option = self.options[self.val_pos]
             self.addstr(0, self.width//2-len(option)//2, option)
             if self.val_pos > 0:
                 self.addstr(0, 0, '←')
             if self.val_pos < len(self.options)-1:
                 self.addstr(0, self.width-1, '→')
             self._win.attroff(to_curses_attr(self.color))
             self._refresh()
     else:
         self.edition_input.refresh()
Beispiel #34
0
 def addstr_colored_lite(self, text, y=None, x=None):
     """
     Just like addstr_colored, with the single-char attributes
     (\x0E to \x19 instead of \x19 + attr). We do not use any }
     char in this version
     """
     chars = format_chars[:]
     chars.append('\n')
     if y is not None and x is not None:
         self.move(y, x)
     format_char = find_first_format_char(text, chars)
     while format_char != -1:
         if text[format_char] == '\n':
             attr_char = '|'
         else:
             attr_char = self.text_attributes[
                     format_chars.index(text[format_char])]
         self.addstr(text[:format_char])
         self.addstr(attr_char, curses.A_REVERSE)
         text = text[format_char+1:]
         if attr_char == 'o':
             self._win.attrset(0)
         elif attr_char == 'u':
             self._win.attron(curses.A_UNDERLINE)
         elif attr_char == 'b':
             self._win.attron(curses.A_BOLD)
         elif attr_char in string.digits and attr_char != '':
             self._win.attron(to_curses_attr((int(attr_char), -1)))
         format_char = find_first_format_char(text, chars)
     self.addstr(text)
Beispiel #35
0
    def write_pre_msg(self, msg, with_timestamps, nick_size):
        offset = 0
        if with_timestamps:
            offset += self.write_time(msg.str_time)

        if not msg.nickname:  # not a message, nothing to do afterwards
            return offset

        nick = truncate_nick(msg.nickname, nick_size)
        offset += poopt.wcswidth(nick)
        if msg.nick_color:
            color = msg.nick_color
        elif msg.user:
            color = msg.user.color
        else:
            color = None
        if msg.ack:
            if msg.ack > 0:
                offset += self.write_ack()
            else:
                offset += self.write_nack()
        if msg.me:
            self._win.attron(to_curses_attr(get_theme().COLOR_ME_MESSAGE))
            self.addstr('* ')
            self.write_nickname(nick, color, msg.highlight)
            offset += self.write_revisions(msg)
            self.addstr(' ')
            offset += 3
        else:
            self.write_nickname(nick, color, msg.highlight)
            offset += self.write_revisions(msg)
            self.addstr('> ')
            offset += 2
        return offset
Beispiel #36
0
 def draw_group_info(self, group):
     """
     draw the group information
     """
     self.addstr(0, 0, group.name,
                 to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self.finish_line(get_theme().COLOR_INFORMATION_BAR)
Beispiel #37
0
 def write_disconnected(self, room):
     """
     Shows a message if the room is not joined
     """
     if not room.joined:
         self.addstr(' -!- Not connected ',
                     to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #38
0
    def write_pre_msg(self, msg, with_timestamps, nick_size):
        offset = 0
        if with_timestamps:
            offset += self.write_time(msg.str_time)

        if not msg.nickname: # not a message, nothing to do afterwards
            return offset

        nick = truncate_nick(msg.nickname, nick_size)
        offset += poopt.wcswidth(nick)
        if msg.nick_color:
            color = msg.nick_color
        elif msg.user:
            color = msg.user.color
        else:
            color = None
        if msg.ack:
            if msg.ack > 0:
                offset += self.write_ack()
            else:
                offset += self.write_nack()
        if msg.me:
            self._win.attron(to_curses_attr(get_theme().COLOR_ME_MESSAGE))
            self.addstr('* ')
            self.write_nickname(nick, color, msg.highlight)
            offset += self.write_revisions(msg)
            self.addstr(' ')
            offset += 3
        else:
            self.write_nickname(nick, color, msg.highlight)
            offset += self.write_revisions(msg)
            self.addstr('> ')
            offset += 2
        return offset
Beispiel #39
0
 def addstr_colored_lite(self, text, y=None, x=None):
     """
     Just like addstr_colored, with the single-char attributes
     (\x0E to \x19 instead of \x19 + attr). We do not use any }
     char in this version
     """
     chars = format_chars[:]
     chars.append('\n')
     if y is not None and x is not None:
         self.move(y, x)
     format_char = find_first_format_char(text, chars)
     while format_char != -1:
         if text[format_char] == '\n':
             attr_char = '|'
         else:
             attr_char = self.text_attributes[format_chars.index(
                 text[format_char])]
         self.addstr(text[:format_char])
         self.addstr(attr_char, curses.A_REVERSE)
         text = text[format_char + 1:]
         if attr_char == 'o':
             self._win.attrset(0)
         elif attr_char == 'u':
             self._win.attron(curses.A_UNDERLINE)
         elif attr_char == 'b':
             self._win.attron(curses.A_BOLD)
         elif attr_char in string.digits and attr_char != '':
             self._win.attron(to_curses_attr((int(attr_char), -1)))
         format_char = find_first_format_char(text, chars)
     self.addstr(text)
Beispiel #40
0
 def draw_plus(self, y):
     """
     Draw the indicator that shows that
     the list is longer than what is displayed
     """
     self.addstr(y, self.width - 5, '++++',
                 to_curses_attr(get_theme().COLOR_MORE_INDICATOR))
Beispiel #41
0
 def write_revisions(self, msg):
     if msg.revisions:
         self._win.attron(to_curses_attr(get_theme().COLOR_REVISIONS_MESSAGE))
         self.addstr('%d' % msg.revisions)
         self._win.attrset(0)
         return ceil(log10(msg.revisions + 1))
     return 0
Beispiel #42
0
 def write_additional_informations(self, informations, jid):
     """
     Write all informations added by plugins by getting the
     value returned by the callbacks.
     """
     for key in informations:
         self.addstr(informations[key](jid), to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #43
0
 def refresh(self, txt=None):
     log.debug('Refresh: %s', self.__class__.__name__)
     if txt:
         self.txt = txt
     self._win.erase()
     self.addstr(0, 0, self.txt[:self.width-1], to_curses_attr(get_theme().COLOR_WARNING_PROMPT))
     self.finish_line(get_theme().COLOR_WARNING_PROMPT)
     self._refresh()
Beispiel #44
0
 def write_revisions(self, msg):
     if msg.revisions:
         self._win.attron(
             to_curses_attr(get_theme().COLOR_REVISIONS_MESSAGE))
         self.addstr('%d' % msg.revisions)
         self._win.attrset(0)
         return ceil(log10(msg.revisions + 1))
     return 0
Beispiel #45
0
 def write_own_nick(self, room):
     """
     Write our own nick in the info bar
     """
     nick = room.own_nick
     if not nick:
         return
     self.addstr(truncate_nick(nick, 13), to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #46
0
 def write_additional_informations(self, informations, jid):
     """
     Write all informations added by plugins by getting the
     value returned by the callbacks.
     """
     for key in informations:
         self.addstr(informations[key](jid),
                     to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #47
0
 def write_own_nick(self, room):
     """
     Write our own nick in the info bar
     """
     nick = room.own_nick
     if not nick:
         return
     self.addstr(truncate_nick(nick, 13),
                 to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
Beispiel #48
0
 def draw_roster_information(self, roster):
     """
     The header at the top
     """
     self.addstr('Roster: %s/%s contacts' % (
             roster.get_nb_connected_contacts(),
             len(roster)),
         to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self.finish_line(get_theme().COLOR_INFORMATION_BAR)
Beispiel #49
0
 def print_scroll_position(self, window):
     """
     Print, like in Weechat, a -MORE(n)- where n
     is the number of available lines to scroll
     down
     """
     if window.pos > 0:
         plus = ' -MORE(%s)-' % window.pos
         self.addstr(plus, to_curses_attr(get_theme().COLOR_SCROLLABLE_NUMBER))
Beispiel #50
0
 def refresh(self, txt=None):
     log.debug('Refresh: %s', self.__class__.__name__)
     if txt:
         self.txt = txt
     self._win.erase()
     self.addstr(0, 0, self.txt[:self.width - 1],
                 to_curses_attr(get_theme().COLOR_WARNING_PROMPT))
     self.finish_line(get_theme().COLOR_WARNING_PROMPT)
     self._refresh()
Beispiel #51
0
 def draw_roster_information(self, roster):
     """
     The header at the top
     """
     self.addstr(
         'Roster: %s/%s contacts' %
         (roster.get_nb_connected_contacts(), len(roster)),
         to_curses_attr(get_theme().COLOR_INFORMATION_BAR))
     self.finish_line(get_theme().COLOR_INFORMATION_BAR)
Beispiel #52
0
 def draw_group(self, y, group, colored):
     """
     Draw a groupname on a line
     """
     if colored:
         self._win.attron(to_curses_attr(get_theme().COLOR_SELECTED_ROW))
     if group.folded:
         self.addstr(y, 0, '[+] ')
     else:
         self.addstr(y, 0, '[-] ')
     contacts = " (%s/%s)" % (group.get_nb_connected_contacts(), len(group))
     self.addstr(
         y, 4,
         self.truncate_name(group.name,
                            len(contacts) + 4) + contacts)
     if colored:
         self._win.attroff(to_curses_attr(get_theme().COLOR_SELECTED_ROW))
     self.finish_line()
Beispiel #53
0
 def finish_line(self, color=None):
     """
     Write colored spaces until the end of line
     """
     (y, x) = self._win.getyx()
     size = self.width - x
     if color:
         self.addnstr(' '*size, size, to_curses_attr(color))
     else:
         self.addnstr(' '*size, size)
Beispiel #54
0
 def print_scroll_position(self, window):
     """
     Print, like in Weechat, a -MORE(n)- where n
     is the number of available lines to scroll
     down
     """
     if window.pos > 0:
         plus = ' -MORE(%s)-' % window.pos
         self.addstr(plus,
                     to_curses_attr(get_theme().COLOR_SCROLLABLE_NUMBER))
Beispiel #55
0
 def draw_status_chatstate(self, y, user):
     show_col = get_theme().color_show(user.show)
     if user.chatstate == 'composing':
         char = get_theme().CHAR_CHATSTATE_COMPOSING
     elif user.chatstate == 'active':
         char = get_theme().CHAR_CHATSTATE_ACTIVE
     elif user.chatstate == 'paused':
         char = get_theme().CHAR_CHATSTATE_PAUSED
     else:
         char = get_theme().CHAR_STATUS
     self.addstr(y, 0, char, to_curses_attr(show_col))
Beispiel #56
0
 def draw_status_chatstate(self, y, user):
     show_col = get_theme().color_show(user.show)
     if user.chatstate == 'composing':
         char = get_theme().CHAR_CHATSTATE_COMPOSING
     elif user.chatstate == 'active':
         char = get_theme().CHAR_CHATSTATE_ACTIVE
     elif user.chatstate == 'paused':
         char = get_theme().CHAR_CHATSTATE_PAUSED
     else:
         char = get_theme().CHAR_STATUS
     self.addstr(y, 0, char, to_curses_attr(show_col))
Beispiel #57
0
 def write_nickname(self, nickname, color, highlight=False):
     """
     Write the nickname, using the user's color
     and return the number of written characters
     """
     if not nickname:
         return
     if highlight:
         hl_color = get_theme().COLOR_HIGHLIGHT_NICK
         if hl_color == "reverse":
             self._win.attron(curses.A_REVERSE)
         else:
             color = hl_color
     if color:
         self._win.attron(to_curses_attr(color))
     self.addstr(truncate_nick(nickname))
     if color:
         self._win.attroff(to_curses_attr(color))
     if highlight and hl_color == "reverse":
         self._win.attroff(curses.A_REVERSE)
Beispiel #58
0
 def refresh(self):
     log.debug('Refresh: %s', self.__class__.__name__)
     self._win.erase()
     x = 0
     for col in self._columns:
         txt = col
         if col in self._column_order:
             if self._column_order_asc:
                 txt += get_theme().CHAR_COLUMN_ASC
             else:
                 txt += get_theme().CHAR_COLUMN_DESC
         #⇓⇑↑↓⇧⇩▲▼
         size = self._columns_sizes[col]
         txt += ' ' * (size-len(txt))
         if col in self._column_sel:
             self.addstr(0, x, txt, to_curses_attr(get_theme().COLOR_COLUMN_HEADER_SEL))
         else:
             self.addstr(0, x, txt, to_curses_attr(get_theme().COLOR_COLUMN_HEADER))
         x += size
     self._refresh()
Beispiel #59
0
 def write_nickname(self, nickname, color, highlight=False):
     """
     Write the nickname, using the user's color
     and return the number of written characters
     """
     if not nickname:
         return
     if highlight:
         hl_color = get_theme().COLOR_HIGHLIGHT_NICK
         if hl_color == "reverse":
             self._win.attron(curses.A_REVERSE)
         else:
             color = hl_color
     if color:
         self._win.attron(to_curses_attr(color))
     self.addstr(truncate_nick(nickname))
     if color:
         self._win.attroff(to_curses_attr(color))
     if highlight and hl_color == "reverse":
         self._win.attroff(curses.A_REVERSE)