1
0

fixes for stdio/text gui

This commit is contained in:
SomberNight
2018-09-13 15:11:28 +02:00
parent 1f14894c43
commit 43664d5f11
3 changed files with 36 additions and 22 deletions

View File

@@ -88,7 +88,7 @@ class ElectrumGui:
+ "%d"%(width[2]+delta)+"s"+"%"+"%d"%(width[3]+delta)+"s" + "%d"%(width[2]+delta)+"s"+"%"+"%d"%(width[3]+delta)+"s"
messages = [] messages = []
for tx_hash, tx_mined_status, delta, balance in self.wallet.get_history(): for tx_hash, tx_mined_status, delta, balance in reversed(self.wallet.get_history()):
if tx_mined_status.conf: if tx_mined_status.conf:
timestamp = tx_mined_status.timestamp timestamp = tx_mined_status.timestamp
try: try:

View File

@@ -182,8 +182,10 @@ class ElectrumGui:
self.maxpos = 6 self.maxpos = 6
def print_banner(self): def print_banner(self):
if self.network: if self.network and self.network.banner:
self.print_list( self.network.banner.split('\n')) banner = self.network.banner
banner = banner.replace('\r', '')
self.print_list(banner.split('\n'))
def print_qr(self, data): def print_qr(self, data):
import qrcode import qrcode
@@ -198,9 +200,15 @@ class ElectrumGui:
self.qr.print_ascii(out=s, invert=False) self.qr.print_ascii(out=s, invert=False)
msg = s.getvalue() msg = s.getvalue()
lines = msg.split('\n') lines = msg.split('\n')
for i, l in enumerate(lines): try:
l = l.encode("utf-8") for i, l in enumerate(lines):
self.stdscr.addstr(i+5, 5, l, curses.color_pair(3)) l = l.encode("utf-8")
self.stdscr.addstr(i+5, 5, l, curses.color_pair(3))
except curses.error:
m = 'error. screen too small?'
m = m.encode(self.encoding)
self.stdscr.addstr(5, 1, m, 0)
def print_list(self, lst, firstline = None): def print_list(self, lst, firstline = None):
lst = list(lst) lst = list(lst)
@@ -301,19 +309,22 @@ class ElectrumGui:
def main(self): def main(self):
tty.setraw(sys.stdin) tty.setraw(sys.stdin)
while self.tab != -1: try:
self.run_tab(0, self.print_history, self.run_history_tab) while self.tab != -1:
self.run_tab(1, self.print_send_tab, self.run_send_tab) self.run_tab(0, self.print_history, self.run_history_tab)
self.run_tab(2, self.print_receive, self.run_receive_tab) self.run_tab(1, self.print_send_tab, self.run_send_tab)
self.run_tab(3, self.print_addresses, self.run_banner_tab) self.run_tab(2, self.print_receive, self.run_receive_tab)
self.run_tab(4, self.print_contacts, self.run_contacts_tab) self.run_tab(3, self.print_addresses, self.run_banner_tab)
self.run_tab(5, self.print_banner, self.run_banner_tab) self.run_tab(4, self.print_contacts, self.run_contacts_tab)
self.run_tab(5, self.print_banner, self.run_banner_tab)
tty.setcbreak(sys.stdin) except curses.error as e:
curses.nocbreak() raise Exception("Error with curses. Is your screen too small?") from e
self.stdscr.keypad(0) finally:
curses.echo() tty.setcbreak(sys.stdin)
curses.endwin() curses.nocbreak()
self.stdscr.keypad(0)
curses.echo()
curses.endwin()
def do_clear(self): def do_clear(self):

View File

@@ -23,7 +23,7 @@
import binascii import binascii
import os, sys, re, json import os, sys, re, json
from collections import defaultdict from collections import defaultdict
from typing import NamedTuple from typing import NamedTuple, Union
from datetime import datetime from datetime import datetime
import decimal import decimal
from decimal import Decimal from decimal import Decimal
@@ -282,9 +282,12 @@ class DaemonThread(threading.Thread, PrintError):
verbosity = '*' verbosity = '*'
def set_verbosity(b): def set_verbosity(filters: Union[str, bool]):
global verbosity global verbosity
verbosity = b if type(filters) is bool: # backwards compat
verbosity = '*' if filters else ''
return
verbosity = filters
def print_error(*args): def print_error(*args):