Add update_focus method in console/__init__.py.

This commit is contained in:
Matthew Shao 2016-03-11 08:44:51 +08:00
parent 6eb584f766
commit 426f84d930

View File

@ -50,7 +50,7 @@ class ConsoleState(flow.State):
if self.focus is None: if self.focus is None:
self.set_focus(0) self.set_focus(0)
elif self.follow_focus: elif self.follow_focus:
self.set_focus(len(self.view) - 1) self.update_focus()
self.set_flow_marked(f, False) self.set_flow_marked(f, False)
return f return f
@ -59,7 +59,7 @@ class ConsoleState(flow.State):
if self.focus is None: if self.focus is None:
self.set_focus(0) self.set_focus(0)
elif self.follow_focus: elif self.follow_focus:
self.set_focus(self.flow_count()) self.update_focus()
return f return f
def set_limit(self, limit): def set_limit(self, limit):
@ -82,6 +82,9 @@ class ConsoleState(flow.State):
else: else:
self.focus = None self.focus = None
def update_focus(self):
self.set_focus(len(self.view) - 1)
def set_focus_flow(self, f): def set_focus_flow(self, f):
self.set_focus(self.view.index(f)) self.set_focus(self.view.index(f))