Open 7596ff opened 4 years ago
With more calendars in view, there seem to be proceedingly more extra tab characters, in a 1-for-1 relationship.
I've been able to reproduce, though I have no idea why it's happening. One weird observation that may be useful: for me, inserting a {nl}
before the {tab}
in your string makes my events consistent and doesn't add a newline...
Ok, it looks like it's only in the calendar
view. list
doesn't appear to be affected.
Hi, I've been able to reproduce the issue too. This is related to color : if two calendars share the same color, the alignment is correct but if color is not the same, problem occurs.
With some tests, i isolate re responsible of the bug :
def color_wrap(text, width=70):
"""A variant of wrap that takes SGR codes (somewhat) into account.
This doesn't actually adjust the length, but makes sure that
lines that enable some attribues also contain a RESET, and also adds
that code to the next line
"""
# TODO we really want to ignore all SGR codes when measuring the width
lines = wrap(text, width)
for num, _ in enumerate(lines):
sgr = find_unmatched_sgr(lines[num])
if sgr:
lines[num] += RESET
if num != len(lines):
lines[num + 1] = sgr + lines[num + 1]
return lines
on utils.py
line 79
I've got it, i made a modification for lines = wrap(text, width)
:
lines = wrap(text, width, expand_tabs=False, replace_whitespace=False)
I've got some errors on unit test, so I need to investigate a little.
@7596ff I submit a PR for the issue, but you can use str.format()
properties to align elements, for example :
agenda_event_format = {calendar-color}{cancelled}{start-end-time-style:12}}{title}{repeat-symbol} {reset} {calendar}{reset}
{start-end-time-style}
will take 12 column with the :12
option, then {title}
will be aligned
Whoa, this is awesome. thank you so much
@7596ff My PR introduce a bug, I need to work on it. But {[...]:<rows>}
seems to work like a charm.
@ephase can you remember, what kind of bug your solution introduces?
I can best reproduce this, if I use different types of colors for different calendars. E.g. I use "dark red" for one calendar, and "#FF00FF" for another calendar. Those produces escape codes of different lengths and therefore the tab expansion failes.
khal list
is not affected, because we don't need to wrap lines there.
I'm actually not sure if it's really a bug. khal keeps the tab where it is, it's probaly the calculation of the terminal emulator that doesn't remove the length of the escape sequences when calculation how long to display the tab.
EDITED
FWIW ephase's PR was #907.
@d7415 which works fine for me.
I am using the
{tab}
character in myagenda_event_format
:"{calendar-color}{cancelled}{start-end-time-style}{tab}{title}{repeat-symbol} {reset}{calendar}{reset}"
, and here is my output.This is easier to read in a screenshot, posted here.
While the duration formats are the same length on different events, it seems that depending on the calendar there are different tab lengths applied to each event.
Despite the intended function of the tab control code, I would love to be able to format the list in some sort of column-based output, so that I could have a column each for time, summary, and calendar name. I await the discussion in this issue.