Ticket #5047, #5048: Separate mc.keydef file, updated syntax#5061
Ticket #5047, #5048: Separate mc.keydef file, updated syntax#5061egmontkob wants to merge 6 commits intoMidnightCommander:masterfrom
Conversation
|
This is a cleanup before finalizing the real work in #4632 & friends. Documentation (manpage etc.) is yet to be updated, but I'd prefer to hear a round of feedback first. |
db0ee31 to
cab7821
Compare
| s++; | ||
| } | ||
|
|
||
| return g_string_free (ret, FALSE); |
There was a problem hiding this comment.
Let's return GString itself.
There was a problem hiding this comment.
Let's return GString itself.
Is there a generic guideline here? Should we always prefer GString to char* as retval? How about input parameters?
Or should the API depend on how the internals were the most convenient to implement: if we already have a GString then return that?
I was tempted to change the input of this function, as well as the retval of the decode_controls() function to GString, for the reason that theoretically a terminal's escape sequence may contain a NUL byte (although in practice I really don't think it does, except for Ctrl+@ a.k.a. Ctrl+space which is the single NUL byte, handled elsewhere in the code).
For the retval of this function, as well as the input parameter of the decoding counterpart, the semantics is C-style string: cannot contain embedded NUL byte. What's the point of changing the return type to GString? Also, for consistency, shouldn't we then change the input parameter of the decoder too, making it possibly more cumbersome for the caller? Or have 3 GStrings and 1 char*?
Would love to learn more about the preference in general, and its reasons; thanks! :)
Move the method to get a config file's full name from keymap to mcconfig, because in the next commit keydef will need the same method. Signed-off-by: Egmont Koblinger <egmont@gmail.com>
…o a separate file Move the escape sequences from the global "mc.lib" and user "ini" file to new global and user "mc.keydef". Add command line option --keydef/--nokeydef and environment variable MC_KEYDEF, analogously to the keymap feature. Signed-off-by: Egmont Koblinger <egmont@gmail.com>
Repeated keys aren't supported. Signed-off-by: Egmont Koblinger <egmont@gmail.com>
cab7821 to
cffe511
Compare
|
Added a new first commit, moving from I haven't yet addressed the char * / GString issue for decode/encode, I'd like to see a consistent full picture which of the 2+2 input parameters and retvals should be changed, please help me here :) |
You do use a GString object within a function. Then you destroy it in parts in two different places: the container and some its members in the function, the char array in the caller function. It would be logical to destroy the entire object at once. And if you need the length of the string in the caller function, you have to call |
I happen to use it, in both the I do not write the implementation first, and then tailor the interface to that, this wouldn't make sense to me. I first create the interface, with whatever types that I believe make the most sense, which in this case was
Destroying at two parts is a standard practice, this is explicitly what
I don't think I use the length in the caller. But even if I did... I know, for some reason, mc has an extremely strong aversion against running Accessing data via a What we need to optimize for is code cleanness, consistency, and quick development flow. For the And how far would you go with your logic? E.g. I honestly really don't like this philosophy of adjusting the interface: the return value (and you didn't respond: what about the input parameters?) to the implementation, rather than designing the interface first. I really don't like trying to micro-optimize the most insignificant bit, let alone with no information whether it would actually speed up things or not if the caller cared about the string length, let alone the caller now doesn't even care. I really don't like being so afraid of maybe (but in fact: not) calling I'm tempted to say that if you firmly insist on returning It might look like I'm just spending 15 minutes to type this comment instead of changing what you asked for. Behind it is much more unpublished work actually trying to adjust the code, and if we're going with I'd really like to stick to the |
12031c2 to
98c3c4a
Compare
Separate entries by space rather than semicolon. Semicolons are no longer escaped. The escape character is represented by \e, \E or ^[, rather than \\e. Other special characters also have more standard notation, e.g. ^H and ^?. Change the internal variables to hold the raw value rather than the escaped string. Signed-off-by: Egmont Koblinger <egmont@gmail.com>
This makes us one step closer to supporting escape sequences with an embedded NUL byte, although we probably won't need this. Signed-off-by: Egmont Koblinger <egmont@gmail.com>
…ydef section names Also rename [general] to [_common_], emphasizing that it's not a terminal name and that it's always loaded. Signed-off-by: Egmont Koblinger <egmont@gmail.com>
98c3c4a to
a5ebd7d
Compare
|
How do you like the direction of the latest push? Since I've worked on it a lot, I thought I'd upload it. The
The retval of Much of the internals have been reworked to carry a possible internal NUL of the escape sequence, although it doesn't work, it would need further investigation which is not my focus right now. That being said, if we ever happen to need that, the current underlying work might become useful. Please advise whether I should continue this latest version, or the one before (with |
Proposed changes
Move the escape sequences from the global "mc.lib" and user "ini" file to new global and user "mc.keydef".
Saner escaping, nicer look.
Removed "terminal:" prefix.
Checklist
👉 Our coding style can be found here: https://midnight-commander.org/coding-style/ 👈
git commit --amend -smake indent && make check)