feat(vim): optional vim-style modal editing in the compose entry#541
feat(vim): optional vim-style modal editing in the compose entry#541sypianski wants to merge 6 commits into
Conversation
|
@sypianski the last commit of your fork (ab87419) has a problem on the user interface:
And I have some warnings when compiling: |
|
I didn't bissect the issue yet, but the first commit 94d1775 doesn't have that problem. |
|
Finished the bisect. 1377466 is the first bad commit src/uicolorconfig.cpp | 9 ++++++++- |
Reported by desgua (d99kris#541): on the vim_mode_3 branch the status and top bars lost their background and chat-list rows visually inverted so all chats looked unread. Root cause: GetProtocolColorPair returned list_color_<proto> whose _bg default is empty, which GetColorId maps to -1 (terminal default). wbkgd then painted the bar with the terminal background instead of the configured bar background. Same effect tinted list rows past the configured list_color_bg, so untintable unread rows looked less prominent than tinted read rows. Add GetProtocolChromePair(baseParam, profileId) that returns a cached pair combining the protocol fg with baseParam_bg, so the bar/list/row keeps its intended background while picking up the protocol hue. Route status, top, help, listborder, list, and history views through the new helper. Also fix the warnings desgua flagged in src/uimodel.cpp: - drop unused int n in VimQuoteObjectRange - use wchar_t keyLF = L'\n' to match entryStr value type - add default: break; to three vim switches - cast wchar_t literal to wint_t in VimLastChange to silence narrowing Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
@desgua thanks for the report — both reproduced from code inspection. Root cause (chrome bg loss + visual "unread" inversion): Fix ( Compile warnings — fixed in the same commit:
Please pull and let me know if the bars and chat-list look right now. |
|
*edit: actually it wasn't a bug, it was the configuration of the colors. @sypianski it seems almost perfect now. But there is still one bug left: all the chats still appear with the foreground color of the unread, as if all of them were unreaded. I bisect that last bug: [i] ~/.../nchat $ git bisect good README.md | 26 ++++++++++++++++++++++++++ |
|
@sypianski I just figured out that the commit I thoght had a bug actually adds a configuration to change the WhatsApp foreground to green and my own configuration was using green for the unread messages. It was just a matter of changing the config file (~/.config/nchat/color.conf) to differentiate read and unread. |
|
Thanks for contributing @sypianski - I hope to find time soon to review this PR. |
Add an optional vim mode to the message compose entry, toggled with
`vim_mode=1` in ui.conf. Implements a composable operator+motion engine
rather than hardcoding key combinations.
Engine (uimodel.cpp):
- Motions: h l 0 ^ $ w e b W E B, ( ) sentences, { } paragraphs,
j k gg G, f F t T find-char. Counts (3w, d3w, 2dd).
- Operators d c y composed with any motion; dd cc yy linewise; D C.
- Edit: x X, s S substitute, o O open-line, p P paste register.
- Visual mode (v) with reverse-video selection highlight, operators
act on [anchor, cursor].
- Insert/Normal/Visual modes; starts in insert; ESC to normal.
UI feedback:
- Status-bar badge NORMAL/INSERT/VISUAL with configurable colors
(vim_*_color_bg/fg, vim_*_attr in color.conf).
- DECSCUSR cursor shape: bar in insert, block in normal.
- Visual selection highlighted via second WordWrap pass for anchor
screen coords (reflow-correct).
- set_escdelay(25) to minimize bare-ESC lag on mode switch.
Config defaults added: vim_mode (ui.conf), vim_*_color/attr (color.conf).
Zero overhead when vim_mode=0 (VimKeyHandler early-returns to the
existing EntryKeyHandler).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add ui.conf option send_on_double_enter (default 0): when enabled, Enter inserts a newline and a second consecutive Enter sends the message (dropping the just-typed trailing newline). send_msg key binding is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The status bar is now tinted by protocol (blue/green/magenta), so the vim mode badges (previously blue/green/magenta) blended in — INSERT on a Telegram (blue) chat was invisible. Switch badge defaults to white/yellow/red which contrast with all protocol hues. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Switch vim mode badges to the standard vim/airline scheme — NORMAL blue, INSERT green, VISUAL yellow — using bright variants so they stay distinct over the protocol-tinted status bar. Drop the protocol-colored INSERT badge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds replace (r<char>), text-objects iw/aw/iW/aW/is/as/ip/ap and
quote/bracket variants (i"/a", i'/a', i\`/a\`, i(/a(/ib, i[/a[, i{/a{/iB,
i</a<) for c/d/y operators, ;/, to repeat last f/F/t/T, Y/J/~ commands,
linewise visual V, and . to repeat the last normal-mode mutation
(excludes change-class commands, which would require insert-mode replay).
- viw/vi"/vi( etc: i/a now works in visual mode to expand selection to text object (previously only worked after d/c/y operator) - ciw/ci"/ci( . repeat: c text-objects now record m_VimLast (was only d/y); VimRepeatLast gains case L'c' alongside d/y - C command now repeatable (sets m_VimLast, case L'C' in repeat) - p/P sync with system clipboard: yank writes to Clipboard::SetText, paste reads Clipboard::GetText() and updates m_VimRegister so text copied outside nchat is immediately available via p Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
I've been using the implementation for 2 days and it is working flawless and it is incredible useful for those used to vim. |
Closes #535.
What this adds
An optional vim modal editing mode for the message compose entry, enabled by setting
vim_mode=1in~/.config/nchat/ui.conf. Default is0— zero overhead, existing behaviour unchanged.Commands (normal mode)
h l 0 ^ $,w e b W E B,( )sentence,{ }paragraph,j k,gg G,f F t Td c y+ any motion;dd cc yy(linewise);D C Yiw aw is as ip ap i" a" i' a' i\a` i( a( i[ a[ i{ a{ i< a<`v→ character-wise selection;d c y x; visual text objects (viw,vi",vi(…)x X s S o O p P r ~ J3w,d3w,2dd, ….repeats last mutating op (including text-object changes:ciw.)p/Psync with system clipboard (X11/Wayland/macOS)Mode is shown as a colored badge in the status bar and the cursor changes shape (bar in insert, block in normal). Badge colors configurable via
color.conf(vim_normal_*/vim_insert_*/vim_visual_*).Other additions in this branch
send_on_double_enter=1inui.conf(default0): single Enter inserts newline, second consecutive Enter sendscolor.conf, toggle withlist_protocol_colorsTest plan
vim_mode=0(default): no behavioral change, no overheadvim_mode=1: ESC enters normal mode,i/a/A/Ireturns to insertd/c/y+ motion operates on correct range; register available viapciw,di",ya(operate correctlyvstarts selection,d/y/cacts on it;viwexpands to word.repeats last changeppastes text copied from outside nchat (clipboard sync)send_on_double_enter=1: double Enter sends, single Enter inserts newline🤖 Generated with Claude Code