From 9d33ae3d07de460a70c07a8ddf1420d8ee0aa516 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 23 May 2025 15:35:23 +0000 Subject: [PATCH] tw.view: new `extra_key_mappings` attribute --- mmgen/proto/btc/tw/addresses.py | 14 ++------------ mmgen/proto/eth/tw/addresses.py | 12 ------------ mmgen/tw/addresses.py | 13 +++++++++++++ mmgen/tw/view.py | 2 ++ 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/mmgen/proto/btc/tw/addresses.py b/mmgen/proto/btc/tw/addresses.py index dfaf9a85..e30ea060 100755 --- a/mmgen/proto/btc/tw/addresses.py +++ b/mmgen/proto/btc/tw/addresses.py @@ -29,20 +29,10 @@ class BitcoinTwAddresses(TwAddresses, BitcoinTwRPC): prompt_fs_repl = { 'BCH': (1, 'Column options: toggle [D]ays/date/confs/block, cas[h]addr') } - key_mappings = { - 'a':'s_amt', + extra_key_mappings = { 'A':'s_age', - 'M':'s_twmmid', - 'r':'s_reverse', 'D':'d_days', - 'e':'d_redraw', - 'E':'d_showempty', - 'u':'d_showused', - 'L':'d_all_labels', - 'v':'a_view', - 'w':'a_view_detail', - 'p':'a_print_detail', - 'l':'i_comment_add'} + 'u':'d_showused'} async def get_rpc_data(self): diff --git a/mmgen/proto/eth/tw/addresses.py b/mmgen/proto/eth/tw/addresses.py index 47cd4b89..f1c6256f 100755 --- a/mmgen/proto/eth/tw/addresses.py +++ b/mmgen/proto/eth/tw/addresses.py @@ -25,18 +25,6 @@ class EthereumTwAddresses(TwAddresses, EthereumTwView, EthereumTwRPC): 'Filters: show [E]mpty addrs, show all [L]abels', 'View/Print: pager [v]iew, [w]ide pager view, [p]rint{s}', 'Actions: [q]uit menu, r[e]draw, [D]elete addr, add [l]abel:'] - key_mappings = { - 'a':'s_amt', - 'M':'s_twmmid', - 'r':'s_reverse', - 'e':'d_redraw', - 'E':'d_showempty', - 'L':'d_all_labels', - 'l':'i_comment_add', - 'D':'i_addr_delete', - 'v':'a_view', - 'w':'a_view_detail', - 'p':'a_print_detail'} def get_column_widths(self, data, *, wide, interactive): diff --git a/mmgen/tw/addresses.py b/mmgen/tw/addresses.py index ddcbc24c..6eb1408e 100755 --- a/mmgen/tw/addresses.py +++ b/mmgen/tw/addresses.py @@ -36,6 +36,19 @@ class TwAddresses(TwView): no_data_errmsg = 'No addresses in tracking wallet!' mod_subpath = 'tw.addresses' + key_mappings = { + 'a':'s_amt', + 'M':'s_twmmid', + 'r':'s_reverse', + 'e':'d_redraw', + 'E':'d_showempty', + 'L':'d_all_labels', + 'l':'i_comment_add', + 'D':'i_addr_delete', + 'v':'a_view', + 'w':'a_view_detail', + 'p':'a_print_detail'} + class display_type(TwView.display_type): class squeezed(TwView.display_type.squeezed): diff --git a/mmgen/tw/view.py b/mmgen/tw/view.py index 3e3e2e75..a794d24e 100755 --- a/mmgen/tw/view.py +++ b/mmgen/tw/view.py @@ -186,6 +186,7 @@ class TwView(MMGenObject, metaclass=AsyncInit): } } scroll_keys['darwin'] = scroll_keys['linux'] + extra_key_mappings = {} def __new__(cls, cfg, proto, *args, **kwargs): return MMGenObject.__new__(proto.base_proto_subclass(cls, cls.mod_subpath)) @@ -201,6 +202,7 @@ class TwView(MMGenObject, metaclass=AsyncInit): if repl := self.prompt_fs_repl.get(self.proto.coin): self.prompt_fs_in[repl[0]] = repl[1] self.prompt_fs = '\n'.join(self.prompt_fs_in) + self.key_mappings.update(self.extra_key_mappings) if self.proto.coin == 'BCH': self.key_mappings.update({'h': 'd_addr_view_pref'}) self.addr_view_pref = 1 if not self.cfg.cashaddr else not self.proto.cashaddr