Browse Source

tw.view: new `extra_key_mappings` attribute

The MMGen Project 6 months ago
parent
commit
9d33ae3d07
4 changed files with 17 additions and 24 deletions
  1. 2 12
      mmgen/proto/btc/tw/addresses.py
  2. 0 12
      mmgen/proto/eth/tw/addresses.py
  3. 13 0
      mmgen/tw/addresses.py
  4. 2 0
      mmgen/tw/view.py

+ 2 - 12
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):
 

+ 0 - 12
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):
 

+ 13 - 0
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):

+ 2 - 0
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