-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terminfo #197
Conversation
Tested and works flawlessly, so other KEY() macros could be replaced with CAP() too ... https://github.com/DBOTW/pick/commit/8dca7882391d9d9713d8c09c3fd7dcfc0e200f16 |
@DBOTW great! I would like to do a release before we migrate the rest of /cc @calleerlandsson |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had one question and one general comment. Other than that, looks good to merge! I can create a release after this has been merged.
pick.c
Outdated
for (i = 0; keys[i].key != UNKNOWN; i++) { | ||
if (keys[i].str == NULL) | ||
keys[i].str = tty_getcap(keys[i].cap); | ||
len = strlen(keys[i].str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about caching this in keys
like we do with the string?
static struct { | ||
enum key key; | ||
const char *s; | ||
size_t length; | ||
char *cap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering why this wasn't const char
but then I saw tigetstr
takes a char *
. I'm not quite sure why though...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's exactly why it can't be const
. I don't have an
explanation either.
Great feedback! The length is now cached. |
A first step towards making pick truly portable. Defining a key using the new CAP() macro will read the corresponding value for the given capability using tigetstr(), the result will be stored in the keys structure in order to only invoke tigetstr() once per capability.
Also, overwrite any existing value for the mandatory environment variables. This is of important in order make the test environment consistent.
Read keys defined as terminal capabilities from terminfo
A first step towards making pick truly portable. Defining a key using
the new CAP() macro will read the corresponding value for the given
capability using tigetstr(), the result will be stored in the keys
structure in order to only invoke tigetstr() once per capability.
@DBOTW could you verify that this PR works as intended on your machine?