Action/InfoScreen: replace octal character literals with key constants - #2093
Action/InfoScreen: replace octal character literals with key constants#2093GermanAizek wants to merge 1 commit into
Conversation
Replace raw octal character escapes '\014' and '\177' with standard
KEY_CTRL('L') and KEY_DEL_MAC / KEY_BACKSPACE macros to improve code
clarity and avoid static analyzer warnings
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe changes replace raw octal key codes with named key macros. Suggested reviewers: Poem
Merge Risk: ⚪ Minimal · up to The keyboard mappings retain their existing behavior while using clearer named constants, so no actionable merge-blocking risk remains beyond normal checks and review. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| keys['\177'] = actionCollapseIntoParent; | ||
| keys[KEY_CTRL('L')] = actionRedraw; | ||
| keys[KEY_DEL_MAC] = actionCollapseIntoParent; | ||
| keys[KEY_BACKSPACE] = actionCollapseIntoParent; |
There was a problem hiding this comment.
AI artifact?
you replace two lines and invent one
There was a problem hiding this comment.
AI artifact? you replace two lines and invent one
No, this for compability with MacOS.
An additional line was added to ensure compatibility with different terminals and operating systems (cross-platform support).
Different terminal emulators handle the Backspace key press in different ways:
KEY_DEL_MAC (formerly \177): On macOS and some older UNIX terminals, pressing the Backspace key sends the ASCII code 127 (the DEL character).
Previously, the code hard-coded this specific value (the magic number \177), which meant the action might not work on other systems.
KEY_BACKSPACE: In most modern Linux/Windows terminals, the Backspace key sends the standard Backspace code (ASCII 8 or a special code from the ncurses library).
There was a problem hiding this comment.
KEY_BACKSPACE was not there before
There was a problem hiding this comment.
I definitely did not take Mac keyboards into account back then... but I do remember that different Linux terminals (xterm, rxvt, konsole, the Linux textmode console, etc.) had different default settings wrt handling Backspace, and \177 was the code for Backspace in the terminal I was using back then (which might have been any of the above :) ). I think there is even an stty setting or something to configure what Backspace emits, isn't there?
There was a problem hiding this comment.
yes there is, stty erase <char> to set it
thank you for the info @hishamhm
There was a problem hiding this comment.
It's better to make a separate commit for this change for clarity.
|
So backspace (on ancient Linux distros and Mac keyboard) can collapse the tree segment. We have - (Minus) and * (star, toggle all children of PIDs without parents) documented in |
|
No hard feelings to drop the backspace binding … |
Replace raw octal character escapes '\014' and '\177' with standard KEY_CTRL('L') and KEY_DEL_MAC / KEY_BACKSPACE macros to improve code clarity and avoid static analyzer warnings