mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
refactor(options): autogenerate valid values and flag enums for options (#31089)
Problem: Option metadata like list of valid values for an option and option flags are not listed in the `options.lua` file and are instead manually defined in C, which means option metadata is split between several places. Solution: Put metadata such as list of valid values for an option and option flags in `options.lua`, and autogenerate the corresponding C variables and enums. Supersedes #28659 Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
@@ -95,7 +95,7 @@ int buf_init_chartab(buf_T *buf, bool global)
|
||||
int c = 0;
|
||||
|
||||
while (c < ' ') {
|
||||
g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2;
|
||||
g_chartab[c++] = (dy_flags & kOptDyFlagUhex) ? 4 : 2;
|
||||
}
|
||||
|
||||
while (c <= '~') {
|
||||
@@ -109,7 +109,7 @@ int buf_init_chartab(buf_T *buf, bool global)
|
||||
g_chartab[c++] = (CT_PRINT_CHAR | CT_FNAME_CHAR) + 1;
|
||||
} else {
|
||||
// the rest is unprintable by default
|
||||
g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2;
|
||||
g_chartab[c++] = (dy_flags & kOptDyFlagUhex) ? 4 : 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,7 @@ static int parse_isopt(const char *var, buf_T *buf, bool only_check)
|
||||
if (c < ' ' || c > '~') {
|
||||
if (tilde) {
|
||||
g_chartab[c] = (uint8_t)((g_chartab[c] & ~CT_CELL_MASK)
|
||||
+ ((dy_flags & DY_UHEX) ? 4 : 2));
|
||||
+ ((dy_flags & kOptDyFlagUhex) ? 4 : 2));
|
||||
g_chartab[c] &= (uint8_t) ~CT_PRINT_CHAR;
|
||||
} else {
|
||||
g_chartab[c] = (uint8_t)((g_chartab[c] & ~CT_CELL_MASK) + 1);
|
||||
@@ -614,7 +614,7 @@ void transchar_nonprint(const buf_T *buf, char *charbuf, int c)
|
||||
}
|
||||
assert(c <= 0xff);
|
||||
|
||||
if (dy_flags & DY_UHEX || c > 0x7f) {
|
||||
if (dy_flags & kOptDyFlagUhex || c > 0x7f) {
|
||||
// 'display' has "uhex"
|
||||
transchar_hex(charbuf, c);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user