Tickets #4872, #4873 and #4874: fix 'insert control code' function#5054
Conversation
|
Since you are fixing |
|
@egmontkob adding you, since this PR fixes 3 issues that you have reported... |
94db99e to
fc84480
Compare
|
I initially didn't add a test for this function because the previous implementation didn't have one, so I assumed that adding a test was not required. In the meantime, I have taken a closer look at the test suite and added the requested test here. If this test is not sufficient or needs adjustments, please let me know. |
fc84480 to
74024a5
Compare
egmontkob
left a comment
There was a problem hiding this comment.
The commit message is duplicated.
egmontkob
left a comment
There was a problem hiding this comment.
Tested now, and it indeed fixes those three bugs, thanks!
74024a5 to
d97eeee
Compare
|
I included the lowercase characters because I thought it would be user-friendly: even if shift wasn't pressed during input, the corresponding control code can be entered via the dialog. However, this is a bit inconsistent with the last inserted condition, according to which |
|
Lowercase letters are absolutely fine, in fact, expected; the user probably won't bother pressing Shift. What's unnecessary IMHO is support the characters "surrounding" the lowercase letters in the ASCII table: |
d97eeee to
0a7f477
Compare
|
Originally I allowed characters from However, if this is not intuitive and could instead confuse future readers, then it doesn't belong in the code. So I removed it and restricted the range to |
0a7f477 to
7ecbdc1
Compare
Sorry about the duplicated commit message - that must have slipped in during the amend commits while I was updating the patch. I've fixed the commit message now. Please let me know if there is anything else in the patch that should be improved. |
There was a problem hiding this comment.
Just very quickly skimming through it this time, it looks good, thank you!
(Super minor nitpicking: you add an extra newline to the end of tests/lib/Makefile.am which already has enough (some will say that already has more than enough.))
Let's wait for Andrew's review as well.
mc-worker
left a comment
There was a problem hiding this comment.
Please begin the commit message with following line:
Ticket #4872, #4873, #4874: fix 'insert control code' function.
|
7ecbdc1 to
d04a605
Compare
|
I completely forgot to adjust the test after changing the |
d04a605 to
798a138
Compare
zyv
left a comment
There was a problem hiding this comment.
I'm happy with the code now, and I’m very happy about the test. Thank you very much! How about the others?
…der#4874: fix 'insert control code' function Validate input key codes, ignore special keys returned by get_key_code(). Fix handling of KEY_M_CTRL combinations and extend mapping for '@', '[', '\', ']', '^', '_'. Fixes: MidnightCommander#4872 Fixes: MidnightCommander#4873 Fixes: MidnightCommander#4874 Signed-off-by: Manuel Einfalt <einfalt1@proton.me> Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
798a138 to
ef07299
Compare
…of the callers Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
|
Looked good to me the last time, won't check it again :P Thanks! |
The previous implementation used
ascii_alpha_to_cntrl(), which assumedalphabetic input and did not properly validate key codes returned by the
terminal libraries. The function has been renamed to
keycode_to_cntrl()and extended to correctly validate and convert key codes.
Changes:
correctly handle
KEY_M_CTRLcombinations (e.g.Ctrl+J).^J#4872.ignore special keys returned by
get_key_code()(e.g. function or cursor keys).extend control mappings for
@ [ \ ] ^ _.return
-1for invalid input and ignore it at the call sitesThe function is used both in the Insert literal dialog in
mceditand in themccommand line.Checklist
git commit --amend -smake indent && make check)