mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-17 11:38:32 +02:00
Fix linewrap auto for fancy format
This commit is contained in:
parent
3ae0ac501a
commit
da396c235c
2 changed files with 20 additions and 4 deletions
|
@ -2,13 +2,12 @@
|
||||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import ansiwrap
|
import ansiwrap
|
||||||
|
|
||||||
import os
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from .color import colorize
|
from .color import colorize
|
||||||
from .color import highlight_tags_with_background_color
|
from .color import highlight_tags_with_background_color
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Copyright (C) 2012-2022 jrnl contributors
|
# Copyright (C) 2012-2022 jrnl contributors
|
||||||
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
# License: https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
from textwrap import TextWrapper
|
from textwrap import TextWrapper
|
||||||
|
|
||||||
from jrnl.exception import JrnlException
|
from jrnl.exception import JrnlException
|
||||||
|
@ -36,7 +38,22 @@ class FancyExporter(TextExporter):
|
||||||
def export_entry(cls, entry):
|
def export_entry(cls, entry):
|
||||||
"""Returns a fancy unicode representation of a single entry."""
|
"""Returns a fancy unicode representation of a single entry."""
|
||||||
date_str = entry.date.strftime(entry.journal.config["timeformat"])
|
date_str = entry.date.strftime(entry.journal.config["timeformat"])
|
||||||
linewrap = entry.journal.config["linewrap"] or 78
|
|
||||||
|
if entry.journal.config["linewrap"]:
|
||||||
|
linewrap = entry.journal.config["linewrap"]
|
||||||
|
|
||||||
|
if linewrap == "auto":
|
||||||
|
try:
|
||||||
|
linewrap = os.get_terminal_size().columns
|
||||||
|
except OSError:
|
||||||
|
logging.debug(
|
||||||
|
"Can't determine terminal size automatically 'linewrap': '%s'",
|
||||||
|
entry.journal.config["linewrap"],
|
||||||
|
)
|
||||||
|
linewrap = 79
|
||||||
|
else:
|
||||||
|
linewrap = 79
|
||||||
|
|
||||||
initial_linewrap = max((1, linewrap - len(date_str) - 2))
|
initial_linewrap = max((1, linewrap - len(date_str) - 2))
|
||||||
body_linewrap = linewrap - 2
|
body_linewrap = linewrap - 2
|
||||||
card = [
|
card = [
|
||||||
|
|
Loading…
Add table
Reference in a new issue