mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
Move around code to separate concerns of each function a bit more
This commit is contained in:
parent
782b14c0f6
commit
e5fdf72fb6
1 changed files with 16 additions and 7 deletions
|
@ -53,12 +53,7 @@ def print_msgs(
|
|||
args = style.decoration.args
|
||||
|
||||
for msg in msgs:
|
||||
args["border_style"] = msg.style.color
|
||||
if msg.style == MsgStyle.ERROR:
|
||||
args["title"] = "Error"
|
||||
|
||||
if is_keyboard_int(msg):
|
||||
print()
|
||||
args = _add_extra_style_args_if_needed(args, msg=msg)
|
||||
|
||||
m = format_msg(msg)
|
||||
m.append(delimiter)
|
||||
|
@ -70,10 +65,24 @@ def print_msgs(
|
|||
Console(stderr=True).print(callback(text, **args))
|
||||
|
||||
|
||||
def _add_extra_style_args_if_needed(args, msg):
|
||||
args["border_style"] = msg.style.color
|
||||
if msg.style == MsgStyle.ERROR:
|
||||
args["title"] = "Error"
|
||||
return args
|
||||
|
||||
|
||||
def is_keyboard_int(msg: Message) -> bool:
|
||||
return msg.text == MsgText.KeyboardInterruptMsg
|
||||
|
||||
|
||||
def format_msg(msg: Message) -> Text:
|
||||
text = textwrap.dedent(msg.text.value.format(**msg.params)).strip()
|
||||
text = ""
|
||||
|
||||
if is_keyboard_int(msg):
|
||||
# extra line break for keyboard interrupts
|
||||
text = "\n"
|
||||
|
||||
text += textwrap.dedent(msg.text.value.format(**msg.params)).strip()
|
||||
return Text(text)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue