Ejemplo n.º 1
0
    def _draw_line(self, index, status):
        #        raise Exception, 'please override this method!'
        current = self.current_status()

        attr = curses.A_NORMAL

        if status.id == current.id:
            # 選択している発言
            attr = curses.A_REVERSE|curses.A_BOLD
        elif status.in_reply_to_screen_name == self._screen_name:
            # 自分宛て
            attr = curses.color_pair(4)
        elif status.user.id == current.user.id:
            # 同じ人の発言
            attr = curses.color_pair(7)
        elif status.id == current.in_reply_to_status_id:
            # reply先
            attr = curses.color_pair(5)
        elif status.user.id == current.in_reply_to_user_id:
            # reply先の人
            attr = curses.color_pair(3)

        if status.favorited:
            # ふぁぼってる
            attr = attr|curses.A_UNDERLINE

        try:
            self._win.addstr(index, 0, adjust_n_width(status.user.name, 20)+' ', attr)
            self._win.addstr(adjust_n_width(status.text, self.width-22), attr)
        finally:
            pass
Ejemplo n.º 2
0
    def _draw(self):
        if self._status is None: return
        name = (u'%s(%s)' % (self._status.user.name, self._status.user.screen_name))
        source = self._status.source
        info = (u'%s from %s' % (self._status.created_at+datetime.timedelta(hours=9), source))
        self._win.addstr(0, 0, adjust_n_width(name, self.width-1, fill=u''))

        h, i = 1, 0
        lines = self._status.text.split('\n')
        strings = reduce(lambda x, y: x+y,
                         map(lambda line: split_from_width(line, self.width-1, translate=False), lines),
                         [])
        rem = 0
        while h < self.height-1 and i < len(strings):
            self._win.move(h, 0)
            if rem:
                self._win.addstr(adjust_n_width(strings[i][:rem]), curses.A_REVERSE)

            start, end = rem, rem
            target = strings[i]
            if i != len(strings)-1:
                target += strings[i+1][:len(self._keyword)-1]

            if self._keyword:
                while target[start:].find(self._keyword) >= 0:
                    end = start+target[start:].find(self._keyword)
                    self._win.addstr(adjust_n_width(strings[i][start:end]))
                    self._win.addstr(adjust_n_width(strings[i][end:min(end+len(self._keyword),
                                                                       len(strings[i]))]),
                                     curses.A_REVERSE)
                    start = end+len(self._keyword)
            self._win.addstr(adjust_n_width(strings[i][start:]))
            if end+len(self._keyword) >= len(strings[i]):
                rem = end+len(self._keyword)-len(strings[i])
            else:
                rem = 0
            h += 1
            i += 1
        self._win.addstr(self.height-1, 0, adjust_n_width(info, self.width-1, fill=u''))
Ejemplo n.º 3
0
 def _draw(self):
     self._win.addstr(0, 0, adjust_n_width(self.getTextFrom(self._begin_index), self._width-1))
     self.cur_set()