remove code duplication

This commit is contained in:
Maximilian Hils 2016-03-18 14:54:42 +01:00
parent 4cd170d36c
commit f5a6ebf584

View File

@ -47,18 +47,12 @@ class ConsoleState(flow.State):
def add_flow(self, f):
super(ConsoleState, self).add_flow(f)
if self.focus is None:
self.set_focus(0)
elif self.follow_focus:
self.update_focus()
self.set_flow_marked(f, False)
return f
def update_flow(self, f):
super(ConsoleState, self).update_flow(f)
if self.focus is None:
self.set_focus(0)
elif self.follow_focus:
self.update_focus()
return f
@ -83,6 +77,9 @@ class ConsoleState(flow.State):
self.focus = None
def update_focus(self):
if self.focus is None:
self.set_focus(0)
elif self.follow_focus:
self.set_focus(len(self.view) - 1)
def set_focus_flow(self, f):