Coding style.
- Simpler way to do decorators.
This commit is contained in:
parent
81588e15d1
commit
bc90382ecb
1 changed files with 12 additions and 14 deletions
|
|
@ -413,8 +413,7 @@ EXCEPTION = None
|
||||||
_LAST_APPEARANCE = []
|
_LAST_APPEARANCE = []
|
||||||
|
|
||||||
|
|
||||||
def handle_exception():
|
def handle_exception(func):
|
||||||
def decorating_func(func):
|
|
||||||
def wrapper(*args):
|
def wrapper(*args):
|
||||||
try:
|
try:
|
||||||
return func(*args)
|
return func(*args)
|
||||||
|
|
@ -423,10 +422,9 @@ def handle_exception():
|
||||||
EXCEPTION = exc
|
EXCEPTION = exc
|
||||||
SHUTDOWN_EVENT.set()
|
SHUTDOWN_EVENT.set()
|
||||||
return wrapper
|
return wrapper
|
||||||
return decorating_func
|
|
||||||
|
|
||||||
|
|
||||||
@handle_exception()
|
@handle_exception
|
||||||
def draw_screen(widget):
|
def draw_screen(widget):
|
||||||
global _LAST_APPEARANCE
|
global _LAST_APPEARANCE
|
||||||
appearance = widget.appearance(os.get_terminal_size())
|
appearance = widget.appearance(os.get_terminal_size())
|
||||||
|
|
@ -434,7 +432,7 @@ def draw_screen(widget):
|
||||||
_LAST_APPEARANCE = appearance
|
_LAST_APPEARANCE = appearance
|
||||||
|
|
||||||
|
|
||||||
@handle_exception()
|
@handle_exception
|
||||||
def patch_screen(widget):
|
def patch_screen(widget):
|
||||||
global _LAST_APPEARANCE
|
global _LAST_APPEARANCE
|
||||||
appearance = widget.appearance(os.get_terminal_size())
|
appearance = widget.appearance(os.get_terminal_size())
|
||||||
|
|
@ -453,7 +451,7 @@ async def update_screen(screen_widget):
|
||||||
APPEARANCE_CHANGED_EVENT.clear()
|
APPEARANCE_CHANGED_EVENT.clear()
|
||||||
|
|
||||||
|
|
||||||
@handle_exception()
|
@handle_exception
|
||||||
def on_terminal_input(screen_widget):
|
def on_terminal_input(screen_widget):
|
||||||
term_code = sys.stdin.read()
|
term_code = sys.stdin.read()
|
||||||
if term_code.startswith(terminal.MOUSE):
|
if term_code.startswith(terminal.MOUSE):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue