summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAsmageddon <Asmageddon@gmail.com>2012-05-28 22:29:19 +0200
committerAsmageddon <Asmageddon@gmail.com>2012-08-09 14:56:01 +0200
commit6269076c7e45b35b58efacce5c0eee1436c23ffa (patch)
treef653d5291ef2985731e31b8668d5b1689bb00b1b
parent506a98aee28ccf3d9310dab848b7aa3f7d90372c (diff)
downloaddeluge-6269076c7e.zip
deluge-6269076c7e.tar.gz
deluge-6269076c7e.tar.bz2
Added scrolling to event view, fixed all crashes
-rw-r--r--deluge/ui/console/modes/eventview.py40
1 files changed, 34 insertions, 6 deletions
diff --git a/deluge/ui/console/modes/eventview.py b/deluge/ui/console/modes/eventview.py
index 6701448..9379e04 100644
--- a/deluge/ui/console/modes/eventview.py
+++ b/deluge/ui/console/modes/eventview.py
@@ -37,6 +37,8 @@
import deluge.component as component
from basemode import BaseMode
+from deluge.ui.client import client
+
try:
import curses
except ImportError:
@@ -50,12 +52,15 @@ import format_utils
class EventView(BaseMode):
def __init__(self, parent_mode, stdscr, encoding=None):
self.parent_mode = parent_mode
+ self.offset = 0
BaseMode.__init__(self, stdscr, encoding)
def refresh(self):
"This method just shows each line of the event log"
events = component.get("ConsoleUI").events
+ self.stdscr.erase()
+
self.add_string(0,self.statusbars.topbar)
hstr = "%sPress [h] for help"%(" "*(self.cols - len(self.statusbars.bottombar) - 10))
#This will quite likely fail when switching modes
@@ -72,7 +77,15 @@ class EventView(BaseMode):
if events:
for i,event in enumerate(events):
- self.add_string(i+1,event)
+ if i - self.offset >= self.rows - 2:
+ more = len(events) - self.offset - self.rows + 2
+ if more > 0:
+ self.add_string(i-self.offset, " (And %i more)" % more)
+ break
+
+ elif i - self.offset < 0:
+ continue
+ self.add_string(i+1-self.offset,event)
else:
self.add_string(1,"{!white,black,bold!}No events to show yet")
@@ -106,13 +119,28 @@ class EventView(BaseMode):
return
# TODO: Scroll event list
+ jumplen = self.rows - 3
+ num_events = len( component.get("ConsoleUI").events )
+
if c == curses.KEY_UP:
- pass
+ self.offset -= 1
elif c == curses.KEY_PPAGE:
- pass
+ self.offset -= jumplen
+ elif c == curses.KEY_HOME:
+ self.offset = 0
elif c == curses.KEY_DOWN:
- pass
+ self.offset += 1
elif c == curses.KEY_NPAGE:
- pass
+ self.offset += jumplen
+ elif c == curses.KEY_END:
+ self.offset += num_events
+
+ if self.offset <= 0:
+ self.offset = 0
+ elif num_events > self.rows - 3:
+ if self.offset > num_events - self.rows + 3:
+ self.offset = num_events - self.rows + 3
+ else:
+ self.offset = 0
- #self.refresh()
+ self.refresh()