tw.view: ensure min screen width >= prompt width
This commit is contained in:
parent
65c0652ff5
commit
60d0a29c36
6 changed files with 19 additions and 11 deletions
|
|
@ -41,7 +41,7 @@ Actions: [q]uit, r[e]draw, [D]elete address, add [l]abel:
|
|||
'w':'a_view_detail',
|
||||
'p':'a_print_detail' }
|
||||
|
||||
def get_column_widths(self,data,wide=False):
|
||||
def get_column_widths(self,data,wide,interactive):
|
||||
|
||||
return self.compute_column_widths(
|
||||
widths = { # fixed cols
|
||||
|
|
@ -64,6 +64,7 @@ Actions: [q]uit, r[e]draw, [D]elete address, add [l]abel:
|
|||
},
|
||||
maxws_nice = {'addr': 18},
|
||||
wide = wide,
|
||||
interactive = interactive,
|
||||
)
|
||||
|
||||
async def get_rpc_data(self):
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ Actions: [q]uit view, [p]rint to file, pager [v]iew, [w]ide view,
|
|||
|
||||
no_data_errmsg = 'No accounts in tracking wallet!'
|
||||
|
||||
def get_column_widths(self,data,wide=False):
|
||||
def get_column_widths(self,data,wide,interactive):
|
||||
# min screen width: 80 cols
|
||||
# num addr [mmid] [comment] amt [amt2]
|
||||
return self.compute_column_widths(
|
||||
|
|
@ -94,6 +94,7 @@ Actions: [q]uit view, [p]rint to file, pager [v]iew, [w]ide view,
|
|||
},
|
||||
maxws_nice = {'addr': 14} if self.show_mmid else {},
|
||||
wide = wide,
|
||||
interactive = interactive,
|
||||
)
|
||||
|
||||
def do_sort(self,key=None,reverse=False):
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class TwAddresses(TwView):
|
|||
(not (d.recvd and not self.showused) and (d.amt or self.showempty))
|
||||
)
|
||||
|
||||
def get_column_widths(self,data,wide=False):
|
||||
def get_column_widths(self,data,wide,interactive):
|
||||
|
||||
return self.compute_column_widths(
|
||||
widths = { # fixed cols
|
||||
|
|
@ -149,6 +149,7 @@ class TwAddresses(TwView):
|
|||
},
|
||||
maxws_nice = {'addr': 18},
|
||||
wide = wide,
|
||||
interactive = interactive,
|
||||
)
|
||||
|
||||
def gen_subheader(self,cw,color):
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class TwTxHistory(TwView):
|
|||
amts_tuple = namedtuple('amts_data',['amt'])
|
||||
return super().set_amt_widths([amts_tuple(d.amt_disp(self.show_total_amt)) for d in data])
|
||||
|
||||
def get_column_widths(self,data,wide=False):
|
||||
def get_column_widths(self,data,wide,interactive):
|
||||
|
||||
# var cols: inputs outputs comment [txid]
|
||||
if not hasattr(self,'varcol_maxwidths'):
|
||||
|
|
@ -89,16 +89,17 @@ class TwTxHistory(TwView):
|
|||
'spc': 6 + self.show_txid, # 5(6) spaces between cols + 1 leading space in fs
|
||||
}
|
||||
|
||||
return self.compute_column_widths(widths,maxws,minws,maxws_nice,wide=wide)
|
||||
return self.compute_column_widths(widths,maxws,minws,maxws_nice,wide=wide,interactive=interactive)
|
||||
|
||||
def gen_squeezed_subheader(self,cw,color):
|
||||
# keep these shorter than min screen width (currently prompt width, or 65 chars)
|
||||
if self.sinceblock:
|
||||
yield f'Displaying transactions since block {self.sinceblock.hl(color=color)}'
|
||||
yield 'Only wallet-related outputs are shown'
|
||||
yield 'Comment is from first wallet address in outputs or inputs'
|
||||
if (cw.inputs < self.varcol_maxwidths['inputs'] or
|
||||
cw.outputs < self.varcol_maxwidths['outputs'] ):
|
||||
yield 'Due to screen width limitations, not all addresses could be displayed'
|
||||
yield 'Note: screen is too narrow to display all inputs and outputs'
|
||||
|
||||
def gen_detail_subheader(self,cw,color):
|
||||
if self.sinceblock:
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ class TwUnspentOutputs(TwView):
|
|||
|
||||
return data
|
||||
|
||||
def get_column_widths(self,data,wide=False):
|
||||
def get_column_widths(self,data,wide,interactive):
|
||||
# min screen width: 80 cols
|
||||
# num txid vout addr [mmid] [comment] amt [amt2] date
|
||||
maxws_nice = {'txid': 12}
|
||||
|
|
@ -151,6 +151,7 @@ class TwUnspentOutputs(TwView):
|
|||
},
|
||||
maxws_nice = maxws_nice,
|
||||
wide = wide,
|
||||
interactive = interactive,
|
||||
)
|
||||
|
||||
def squeezed_col_hdr(self,cw,fs,color):
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
else:
|
||||
return _term_dimensions(min_cols,ts.height)
|
||||
|
||||
def compute_column_widths(self,widths,maxws,minws,maxws_nice={},wide=False):
|
||||
def compute_column_widths(self,widths,maxws,minws,maxws_nice,wide,interactive):
|
||||
|
||||
def do_ret(freews):
|
||||
widths.update({k:minws[k] + freews.get(k,0) for k in minws})
|
||||
|
|
@ -274,7 +274,8 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
minw = sum(widths.values()) + sum(minws.values())
|
||||
varw = sum(varws.values())
|
||||
|
||||
td = self.get_term_dimensions(minw)
|
||||
self.min_term_width = max(self.prompt_width,minw) if interactive else minw
|
||||
td = self.get_term_dimensions(self.min_term_width)
|
||||
self.term_height = td.height
|
||||
self.term_width = td.width
|
||||
|
||||
|
|
@ -368,7 +369,7 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
|
||||
if data and dt.need_column_widths:
|
||||
self.set_amt_widths(data)
|
||||
cw = self.get_column_widths(data,wide=dt.detail)
|
||||
cw = self.get_column_widths(data,wide=dt.detail,interactive=interactive)
|
||||
cwh = cw._asdict()
|
||||
fp = self.fs_params
|
||||
hdr_fs = ''.join(fp[name].hdr_fs % ((),cwh[name])[fp[name].hdr_fs_repl]
|
||||
|
|
@ -421,11 +422,13 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
|
||||
from ..term import get_char
|
||||
|
||||
prompt = self.prompt.strip() + '\b'
|
||||
prompt = self.prompt.strip()
|
||||
|
||||
self.prompt_width = max(len(l) for l in prompt.split('\n'))
|
||||
self.prompt_height = len(prompt.split('\n'))
|
||||
self.no_output = False
|
||||
self.oneshot_msg = None
|
||||
prompt += '\b'
|
||||
|
||||
self.cursor_to_end_of_prompt = CUR_RIGHT( len(prompt.split('\n')[-1]) - 2 )
|
||||
clear_screen = '\n\n' if (opt.no_blank or g.test_suite) else CUR_HOME + ERASE_ALL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue