purebred-mua / purebred

A terminal based mail user agent based on notmuch
GNU Affero General Public License v3.0
139 stars 19 forks source link

Refactor focusing of views and widgets #403

Closed romanofski closed 4 years ago

romanofski commented 4 years ago

Purebred had two chain combinators:

a) chain for chaining Action's of the same view/widget b) chain' for chaining Action's of different view/widget

Furthermore, we had an action called focus which actually didn't focus a view/widget, but rather ran setup/teardown code when view and widgets were changed.

This is confusing.

This patch hopes to improve how Purebred makes focus changes.

a) The chain' combinator becomes 'focus' in order to make clear, that we're focusing a new widget in a potentially different view.

b) The former focus Action is removed instead.

c) The switchFocus class method has been renamed to onFocusSwitch to indicate the fact that this is not actually changing the focus to a view or widget. Rather it runs code during a switch of focus to a different widget.

d) The explicit view/widget specifier for Actions which can be used on multiple views/widgets is now made on the right hand side of the focus combinator.

Examples:

A former keybinding like:

Keybinding (V.EvKey (V.KChar 'g') [V.MCtrl]) (abort `chain'` focus @'ComposeView @'ComposeListOfAttachments `chain` continue)

becomes:

 Keybinding (V.EvKey (V.KChar 'g') [V.MCtrl]) (abort `focus` continue @'ComposeView @'ComposeListOfAttachments)

This former keybinding:

 Keybinding (V.EvKey V.KEnter []) (handleConfirm `chain'` focus @'Threads @'ListOfThreads `chain'` reloadList `chain` continue)

becomes:

 Keybinding (V.EvKey V.KEnter []) (handleConfirm `focus` reloadList `chain` continue)

#

romanofski commented 4 years ago

Would make my change for #336 easier, since I want Purebred to abort composition and go back to the thread view in case the editor dies.