Skip to content

Commit

Permalink
curses: Implemented initial Contact list navigation
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Bisinger <stephane.bisinger@gmail.com>
  • Loading branch information
Kjir committed May 29, 2009
1 parent 4451cc9 commit ace647f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions amsn2/gui/front_ends/curses/contact_list.py
Expand Up @@ -28,6 +28,14 @@ def _on_char_cb(self, ch):
import sys
print >> sys.stderr, "Length is %d" % len(ch)
print >> sys.stderr, "Received %s in Contact List" % ch.encode("UTF-8")
if ch == "KEY_UP":
self._clwidget.move(-1)
elif ch == "KEY_DOWN":
self._clwidget.move(1)
elif ch == "KEY_NPAGE":
self._clwidget.move(10)
elif ch == "KEY_PPAGE":
self._clwidget.move(-10)

class aMSNContactListWidget(base.aMSNContactListWidget):

Expand All @@ -44,6 +52,14 @@ def __init__(self, amsn_core, parent):
self._thread.daemon = True
self._thread.setDaemon(True)
self._thread.start()
self._selected = 1

def move(self, num):
self._selected += num
if self._selected < 1:
self._selected = 1
self.__repaint()


def contactListUpdated(self, clView):
# Acquire the lock to do modifications
Expand Down Expand Up @@ -122,7 +138,7 @@ def __repaint(self):
cids.reverse()
for c in cids:
if self._contacts.has_key(c) and self._contacts[c]['cView'] is not None:
if i == y - 3:
if i == y - self._selected:
self._win.bkgdset(curses.color_pair(1))
self._win.insstr(self._contacts[c]['cView'].name.toString())
self._win.bkgdset(curses.color_pair(0))
Expand All @@ -133,7 +149,7 @@ def __repaint(self):
self._win.insertln()
self._win.bkgdset(curses.color_pair(0))
i += 1
if i == y - 3:
if i == y - self._selected:
self._win.bkgdset(curses.color_pair(1))
self._win.insstr(self._groups[g].name.toString())
self._win.bkgdset(curses.color_pair(0))
Expand Down

0 comments on commit ace647f

Please sign in to comment.