pimutils / pimutils/khal

Draw khal with urwid as well

Open
#609 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

internal lv: hard type: discussion
Dominant language
Python
Stars
3.1k
Forks
233
Avg merge
1h 44m
Merged PRs (30d)
1

Description

So this is an odd proposal, I think it merit some discussion, but could result in some big [positive] changes.

I've been fiddling around with urwids event loop, alarms, alike, and I've found some hacks that would maybe allow us to draw khal using urwid as well.

The dumbest and simplest example I've gotten working is have urwid call os._exit(0) right after drawing, which just leaves the initial draw on screen.
A sophisticated approach would be to write a dummy screen that prints the first redraw and forces an exit.

Before actually moving into this, I think it warrants some discussion (also, I've to ask "would this get merged?").

Pros
  • De-dupe a lot of code. Rather than having one code block to draw calendars in khal and another in ikhal, share all that code. The de-duplication could be huge.
  • A lot less code to maintain
  • Forget about fine-tuning columns, colour overflows and alike for khal.
Cons
  • My dumb approach using unittest.mock.patch doesn't work with less, or anything else that pipes due to screen width being misinterpreted. (a dummy screen approach would work there, AFAIK, though maybe we can force urwid to believe it has a different approach).
  • It's a lot of initial effort. Especially the less hacky approaches.
Oportunities
  • Consistency: We're sure that both look very much alike. We can tune one to have less months, etc, but the fine details will be identical on both.
Risks
  • If we take the hackier approaches (touching the event hooks, or alarms), we risk this breaking with newer urwid versions if something changes (because we're basically exploiting it). A dummy screen wouldn't have this risk.

I'd like to leave this open for a place of some brief discussion. I'd really like to work on this if the idea sound acceptable. If I'm not being very clear, just ask (it's 1am, so maybe I'm making less sense that I think).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining khal and ikhal's separate calendar-drawing paths, then review how urwid's event loop, alarms, and screen handling interact with piped output such as less. Compare the proposed unittest.mock.patch and dummy-screen approaches, and clarify the project's preferred design before proceeding. Done would mean an agreed approach that shares drawing behavior without breaking terminal width handling or urwid compatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.