Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ Alnoman Kamil - noman [at] kamil [dot] gr - https://kamil.gr
Leonardo Taccari - iamleot [at] gmail [dot] com
Jorenar - dev [at] jorenar [dot] com - https://jorenar.com
John Wassilak - john [at] wassilak [dot] com
Aleksei Stepanov - penguinolog [at] gmail [dot] com
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ may want to subscribe to `GitHub's tag feed
unreleased
* FIX ``khal import --format``/``-f`` was accepted and then ignored, always
falling back to ``view.event_format``
* FIX ikhal compatibility with urwid 5.0, which removed ``Columns.focus_col``,
``Columns.set_focus_column()``, ``Pile.set_focus()``, ``Frame.set_body()`` and
``AttrWrap.w``

0.14.1
======
Expand Down
2 changes: 1 addition & 1 deletion khal/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ def _search(self, search_term: str) -> None:
title=f'Search results for "{search_term}" (Esc for backtrack)',
)
pane._conf = self._conf
columns.set_focus_column(1)
columns.focus_position = 1
self.window.open(pane)

def render(self, size, focus=False):
Expand Down
10 changes: 5 additions & 5 deletions khal/ui/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def __init__(self, footer="", quit_keys=None) -> None:
quit_keys = quit_keys or ["q"]
self._track: list[urwid.Overlay] = []

header = urwid.AttrWrap(urwid.Text(""), "header")
footer = urwid.AttrWrap(urwid.Text(footer), "footer")
header = urwid.AttrMap(urwid.Text(""), "header")
footer = urwid.AttrMap(urwid.Text(footer), "footer")
urwid.Frame.__init__(
self,
urwid.Text(""),
Expand Down Expand Up @@ -223,7 +223,7 @@ def on_key_press(self, key):
return key

def _update(self, pane):
self.set_body(pane)
self.body = pane
self.clear_header()

def log(self, record: str):
Expand All @@ -236,7 +236,7 @@ def clear_header(self):
"""clears header if we are not currently showing a warning"""
if not self._header_is_warning:
pane_title = getattr(self._get_current_pane(), "title", "")
self.header.w.set_text(pane_title)
self.header.original_widget.set_text(pane_title)

def update_header(self, alert=None, warn=False):
"""Update the Windows header line.
Expand All @@ -255,7 +255,7 @@ def update_header(self, alert=None, warn=False):
text.append(part)
text.append(("black", " | "))

self.header.w.set_text(text[:-1] or "")
self.header.original_widget.set_text(text[:-1] or "")


class AlertDaemon(threading.Thread):
Expand Down
12 changes: 6 additions & 6 deletions khal/ui/calendarwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ def toggle(row: int, column: int) -> None:
else:
self._unmark_one(row, col)

toggle(self.focus_position, self.focus.focus_col)
self._pos_old = self.focus_position, self.focus.focus_col
toggle(self.focus_position, self.focus.focus_position)
self._pos_old = self.focus_position, self.focus.focus_position

def _unmark_all(self) -> None:
"""remove attribute *mark* from all dates"""
Expand All @@ -346,15 +346,15 @@ def keypress(self, size: bool, key: str) -> str | None:
if key in self.keybindings["mark"]:
self._marked = {
"date": self.body.focus_date,
"pos": (self.focus_position, self.focus.focus_col),
"pos": (self.focus_position, self.focus.focus_position),
}
if self._marked and key in self.keybindings["other"]:
row, col = self._marked["pos"]
self._marked = {
"date": self.body.focus_date,
"pos": (self.focus_position, self.focus.focus_col),
"pos": (self.focus_position, self.focus.focus_position),
}
self.focus.focus_col = col
self.focus.focus_position = col
self.focus_position = row
if key in self.on_press:
if self._marked:
Expand Down Expand Up @@ -453,7 +453,7 @@ def reset_styles_range(self, min_date: dt.date, max_date: dt.date) -> None:
"""reset styles for all (displayed) dates between min_date and max_date"""
minr, _minc = self.get_date_pos(max(min_date, self.earliest_date))
maxr, _maxc = self.get_date_pos(min(max_date, self.latest_date))
focus_pos = self.focus, self[self.focus].focus_col
focus_pos = self.focus, self[self.focus].focus_position

for row in range(minr, maxr + 1):
for column in range(1, 8):
Expand Down
4 changes: 2 additions & 2 deletions khal/ui/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def rebuild(self):
self._rebuild_no_edit()
elif self.repeat:
self._rebuild_edit()
self._pile.set_focus(old_focus_y)
self._pile.focus_position = old_focus_y
else:
self._rebuild_edit_no_repeat()

Expand All @@ -866,7 +866,7 @@ def _allow_edit(_):
urwid.Button("Edit anyway", on_press=_allow_edit),
]
self._refill_contents(lines)
self._pile.set_focus(2)
self._pile.focus_position = 2

def _rebuild_edit_no_repeat(self):
lines = [NColumns([(13, self.repeat_box)])]
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/canvas_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def _process_char(self, fmt, _, b):
if not fmt:
self.output.write(text)
else:
fmt = self._palette[fmt]
# urwid after 4.2.5 reports a nested attribute as a LayeredAttr, innermost
# layer first; older urwid reports that innermost attribute alone.
fmt = self._palette[getattr(fmt, "layers", (fmt,))[0]]
if fmt[0]:
self.output.write(f"{fmt[1]}{click.style(text)}")
else:
Expand Down
20 changes: 12 additions & 8 deletions tests/ui/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import icalendar

from khal.ui.calendarwidget import CalendarWidget
from khal.ui.editor import RecurrenceEditor, StartEndEditor
from tests.utils import BERLIN, LOCALE_BERLIN

Expand All @@ -27,18 +28,21 @@ def test_popup(monkeypatch):
#405
"""

class FakeCalendar:
def store(self, *args, **kwargs):
self.args = args
self.kwargs = kwargs
calls = []
original_init = CalendarWidget.__init__

fake = FakeCalendar()
monkeypatch.setattr("khal.ui.calendarwidget.CalendarWidget.__init__", fake.store)
# record the arguments, but still build a real widget, urwid >= 5.2's
# LineBox needs a fully initialized widget to wrap
def spy_init(self, *args, **kwargs):
calls.append(kwargs)
original_init(self, *args, **kwargs)

monkeypatch.setattr(CalendarWidget, "__init__", spy_init)
see = StartEndEditor(START, END, CONF)
see.widgets.startdate.keypress((22,), "enter")
assert fake.kwargs["initial"] == dt.date(2015, 4, 26)
assert calls[-1]["initial"] == dt.date(2015, 4, 26)
see.widgets.enddate.keypress((22,), "enter")
assert fake.kwargs["initial"] == dt.date(2015, 4, 27)
assert calls[-1]["initial"] == dt.date(2015, 4, 27)


def test_check_understood_rrule():
Expand Down
Loading