mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
fix missing newline for keyboard interrupts
This commit is contained in:
parent
082e665a50
commit
fcb8b2203e
1 changed files with 19 additions and 11 deletions
|
@ -49,20 +49,30 @@ def print_msgs(
|
||||||
) -> None:
|
) -> None:
|
||||||
# Same as print_msg, but for a list
|
# Same as print_msg, but for a list
|
||||||
text = Text("")
|
text = Text("")
|
||||||
callback = style.decoration.callback
|
decoration_callback = style.decoration.callback
|
||||||
args = style.decoration.args
|
args = style.decoration.args
|
||||||
|
prepend_newline = False
|
||||||
|
|
||||||
for msg in msgs:
|
for msg in msgs:
|
||||||
args = _add_extra_style_args_if_needed(args, msg=msg)
|
args = _add_extra_style_args_if_needed(args, msg=msg)
|
||||||
|
|
||||||
|
if _needs_prepended_newline(msg):
|
||||||
|
prepend_newline = True
|
||||||
|
|
||||||
m = format_msg(msg)
|
m = format_msg(msg)
|
||||||
m.append(delimiter)
|
m.append(delimiter)
|
||||||
|
|
||||||
text.append(m)
|
text.append(m)
|
||||||
|
|
||||||
text.rstrip()
|
text.rstrip()
|
||||||
|
|
||||||
# import ipdb; ipdb.sset_trace()
|
# Always print messages to stderr
|
||||||
Console(stderr=True).print(callback(text, **args))
|
console = Console(stderr=True)
|
||||||
|
|
||||||
|
console.print(
|
||||||
|
decoration_callback(text, **args),
|
||||||
|
new_line_start=prepend_newline,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _add_extra_style_args_if_needed(args, msg):
|
def _add_extra_style_args_if_needed(args, msg):
|
||||||
|
@ -72,17 +82,15 @@ def _add_extra_style_args_if_needed(args, msg):
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
||||||
|
def _needs_prepended_newline(msg: Message) -> bool:
|
||||||
|
return is_keyboard_int(msg)
|
||||||
|
|
||||||
|
|
||||||
def is_keyboard_int(msg: Message) -> bool:
|
def is_keyboard_int(msg: Message) -> bool:
|
||||||
return msg.text == MsgText.KeyboardInterruptMsg
|
return msg.text == MsgText.KeyboardInterruptMsg
|
||||||
|
|
||||||
|
|
||||||
def format_msg(msg: Message) -> Text:
|
def format_msg(msg: Message) -> Text:
|
||||||
text = ""
|
text = textwrap.dedent(msg.text.value.format(**msg.params)).strip()
|
||||||
|
|
||||||
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)
|
return Text(text)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue