Skip to content

Commit 18c67f4

Browse files
penguinologWhyNotHugo
authored andcommitted
Support urwid 5.0 in ikhal
urwid 5.0 removes several accessors ikhal still used, so ikhal raised AttributeError with it; khal declares no upper bound on urwid. Replace them with the standard container properties, available in urwid 2.6.15, khal's minimum: - Columns.focus_col and Columns.set_focus_column() -> focus_position - Pile.set_focus() -> focus_position - Frame.set_body() -> body - AttrWrap.w -> original_widget The window header and footer use AttrMap instead of AttrWrap, which urwid 5.0 warns about and urwid 7.0 removes; nothing reads attributes through them.
1 parent 0c8e4bb commit 18c67f4

6 files changed

Lines changed: 18 additions & 14 deletions

File tree

‎AUTHORS.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ Alnoman Kamil - noman [at] kamil [dot] gr - https://kamil.gr
6060
Leonardo Taccari - iamleot [at] gmail [dot] com
6161
Jorenar - dev [at] jorenar [dot] com - https://jorenar.com
6262
John Wassilak - john [at] wassilak [dot] com
63+
Aleksei Stepanov - penguinolog [at] gmail [dot] com

‎CHANGELOG.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ may want to subscribe to `GitHub's tag feed
1212
unreleased
1313
* FIX ``khal import --format``/``-f`` was accepted and then ignored, always
1414
falling back to ``view.event_format``
15+
* FIX ikhal compatibility with urwid 5.0, which removed ``Columns.focus_col``,
16+
``Columns.set_focus_column()``, ``Pile.set_focus()``, ``Frame.set_body()`` and
17+
``AttrWrap.w``
1518

1619
0.14.1
1720
======

‎khal/ui/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ def _search(self, search_term: str) -> None:
12491249
title=f'Search results for "{search_term}" (Esc for backtrack)',
12501250
)
12511251
pane._conf = self._conf
1252-
columns.set_focus_column(1)
1252+
columns.focus_position = 1
12531253
self.window.open(pane)
12541254

12551255
def render(self, size, focus=False):

‎khal/ui/base.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def __init__(self, footer="", quit_keys=None) -> None:
160160
quit_keys = quit_keys or ["q"]
161161
self._track: list[urwid.Overlay] = []
162162

163-
header = urwid.AttrWrap(urwid.Text(""), "header")
164-
footer = urwid.AttrWrap(urwid.Text(footer), "footer")
163+
header = urwid.AttrMap(urwid.Text(""), "header")
164+
footer = urwid.AttrMap(urwid.Text(footer), "footer")
165165
urwid.Frame.__init__(
166166
self,
167167
urwid.Text(""),
@@ -223,7 +223,7 @@ def on_key_press(self, key):
223223
return key
224224

225225
def _update(self, pane):
226-
self.set_body(pane)
226+
self.body = pane
227227
self.clear_header()
228228

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

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

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

260260

261261
class AlertDaemon(threading.Thread):

‎khal/ui/calendarwidget.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ def toggle(row: int, column: int) -> None:
318318
else:
319319
self._unmark_one(row, col)
320320

321-
toggle(self.focus_position, self.focus.focus_col)
322-
self._pos_old = self.focus_position, self.focus.focus_col
321+
toggle(self.focus_position, self.focus.focus_position)
322+
self._pos_old = self.focus_position, self.focus.focus_position
323323

324324
def _unmark_all(self) -> None:
325325
"""remove attribute *mark* from all dates"""
@@ -346,15 +346,15 @@ def keypress(self, size: bool, key: str) -> str | None:
346346
if key in self.keybindings["mark"]:
347347
self._marked = {
348348
"date": self.body.focus_date,
349-
"pos": (self.focus_position, self.focus.focus_col),
349+
"pos": (self.focus_position, self.focus.focus_position),
350350
}
351351
if self._marked and key in self.keybindings["other"]:
352352
row, col = self._marked["pos"]
353353
self._marked = {
354354
"date": self.body.focus_date,
355-
"pos": (self.focus_position, self.focus.focus_col),
355+
"pos": (self.focus_position, self.focus.focus_position),
356356
}
357-
self.focus.focus_col = col
357+
self.focus.focus_position = col
358358
self.focus_position = row
359359
if key in self.on_press:
360360
if self._marked:
@@ -453,7 +453,7 @@ def reset_styles_range(self, min_date: dt.date, max_date: dt.date) -> None:
453453
"""reset styles for all (displayed) dates between min_date and max_date"""
454454
minr, _minc = self.get_date_pos(max(min_date, self.earliest_date))
455455
maxr, _maxc = self.get_date_pos(min(max_date, self.latest_date))
456-
focus_pos = self.focus, self[self.focus].focus_col
456+
focus_pos = self.focus, self[self.focus].focus_position
457457

458458
for row in range(minr, maxr + 1):
459459
for column in range(1, 8):

‎khal/ui/editor.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,7 @@ def rebuild(self):
851851
self._rebuild_no_edit()
852852
elif self.repeat:
853853
self._rebuild_edit()
854-
self._pile.set_focus(old_focus_y)
854+
self._pile.focus_position = old_focus_y
855855
else:
856856
self._rebuild_edit_no_repeat()
857857

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

871871
def _rebuild_edit_no_repeat(self):
872872
lines = [NColumns([(13, self.repeat_box)])]

0 commit comments

Comments
 (0)