Change console_order and console_order_reversed options

Change console_order and console_order_reversed to view_order and
view_order_reversed, and move them to the view addon.
This commit is contained in:
Matthew Shao 2017-08-01 22:58:27 +08:00
parent e533d02d98
commit 7bbd89b121
3 changed files with 20 additions and 18 deletions

View File

@ -145,6 +145,17 @@ class View(collections.Sequence):
self.focus = Focus(self) self.focus = Focus(self)
self.settings = Settings(self) self.settings = Settings(self)
def load(self, loader):
loader.add_option(
"view_order", str, "time",
"Flow sort order.",
choices=list(map(lambda c: c[1], orders)),
)
loader.add_option(
"view_order_reversed", bool, False,
"Reverse the sorting order."
)
def store_count(self): def store_count(self):
return len(self._store) return len(self._store)
@ -442,14 +453,14 @@ class View(collections.Sequence):
"Invalid interception filter: %s" % ctx.options.view_filter "Invalid interception filter: %s" % ctx.options.view_filter
) )
self.set_filter(filt) self.set_filter(filt)
if "console_order" in updated: if "view_order" in updated:
if ctx.options.console_order not in self.orders: if ctx.options.view_order not in self.orders:
raise exceptions.OptionsError( raise exceptions.OptionsError(
"Unknown flow order: %s" % ctx.options.console_order "Unknown flow order: %s" % ctx.options.view_order
) )
self.set_order(self.orders[ctx.options.console_order]) self.set_order(self.orders[ctx.options.view_order])
if "console_order_reversed" in updated: if "view_order_reversed" in updated:
self.set_reversed(ctx.options.console_order_reversed) self.set_reversed(ctx.options.view_order_reversed)
if "console_focus_follow" in updated: if "console_focus_follow" in updated:
self.focus_follow = ctx.options.console_focus_follow self.focus_follow = ctx.options.console_focus_follow

View File

@ -107,15 +107,6 @@ class ConsoleAddon:
"console_mouse", bool, True, "console_mouse", bool, True,
"Console mouse interaction." "Console mouse interaction."
) )
loader.add_option(
"console_order", str, "time",
"Flow sort order.",
choices=view_orders,
)
loader.add_option(
"console_order_reversed", bool, False,
"Reverse the sorting order."
)
@command.command("console.layout.options") @command.command("console.layout.options")
def layout_options(self) -> typing.Sequence[str]: def layout_options(self) -> typing.Sequence[str]:

View File

@ -199,10 +199,10 @@ class StatusBar(urwid.WidgetWrap):
r.append("[") r.append("[")
r.append(("heading_key", "M")) r.append(("heading_key", "M"))
r.append(":%s]" % self.master.options.default_contentview) r.append(":%s]" % self.master.options.default_contentview)
if self.master.options.has_changed("console_order"): if self.master.options.has_changed("view_order"):
r.append("[") r.append("[")
r.append(("heading_key", "o")) r.append(("heading_key", "o"))
r.append(":%s]" % self.master.options.console_order) r.append(":%s]" % self.master.options.view_order)
opts = [] opts = []
if self.master.options.anticache: if self.master.options.anticache:
@ -244,7 +244,7 @@ class StatusBar(urwid.WidgetWrap):
else: else:
offset = self.master.view.focus.index + 1 offset = self.master.view.focus.index + 1
if self.master.options.console_order_reversed: if self.master.options.view_order_reversed:
arrow = common.SYMBOL_UP arrow = common.SYMBOL_UP
else: else:
arrow = common.SYMBOL_DOWN arrow = common.SYMBOL_DOWN