mirror of
https://github.com/neovim/neovim.git
synced 2025-11-26 12:10:40 +00:00
syntax: did_header is bool
Refactor all affected functions: - add const - declare and initialize on same line - update boolean declarations from int with bool
This commit is contained in:
@@ -3554,9 +3554,7 @@ syn_list_one(
|
|||||||
int link_only /* when TRUE; list link-only too */
|
int link_only /* when TRUE; list link-only too */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int attr;
|
bool did_header = false;
|
||||||
int did_header = FALSE;
|
|
||||||
synpat_T *spp;
|
|
||||||
static struct name_list namelist1[] =
|
static struct name_list namelist1[] =
|
||||||
{
|
{
|
||||||
{HL_DISPLAY, "display"},
|
{HL_DISPLAY, "display"},
|
||||||
@@ -3579,23 +3577,26 @@ syn_list_one(
|
|||||||
{0, NULL}
|
{0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
attr = HL_ATTR(HLF_D); // highlight like directories
|
const int attr = HL_ATTR(HLF_D); // highlight like directories
|
||||||
|
|
||||||
/* list the keywords for "id" */
|
// list the keywords for "id"
|
||||||
if (!syncing) {
|
if (!syncing) {
|
||||||
did_header = syn_list_keywords(id, &curwin->w_s->b_keywtab, FALSE, attr);
|
did_header = syn_list_keywords(id, &curwin->w_s->b_keywtab, false, attr);
|
||||||
did_header = syn_list_keywords(id, &curwin->w_s->b_keywtab_ic,
|
did_header = syn_list_keywords(id, &curwin->w_s->b_keywtab_ic,
|
||||||
did_header, attr);
|
did_header, attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* list the patterns for "id" */
|
// list the patterns for "id"
|
||||||
for (int idx = 0; idx < curwin->w_s->b_syn_patterns.ga_len && !got_int; ++idx) {
|
for (int idx = 0;
|
||||||
spp = &(SYN_ITEMS(curwin->w_s)[idx]);
|
idx < curwin->w_s->b_syn_patterns.ga_len && !got_int;
|
||||||
if (spp->sp_syn.id != id || spp->sp_syncing != syncing)
|
idx++) {
|
||||||
|
const synpat_T *const spp = &(SYN_ITEMS(curwin->w_s)[idx]);
|
||||||
|
if (spp->sp_syn.id != id || spp->sp_syncing != syncing) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
(void)syn_list_header(did_header, 999, id);
|
(void)syn_list_header(did_header, 999, id);
|
||||||
did_header = TRUE;
|
did_header = true;
|
||||||
last_matchgroup = 0;
|
last_matchgroup = 0;
|
||||||
if (spp->sp_type == SPTYPE_MATCH) {
|
if (spp->sp_type == SPTYPE_MATCH) {
|
||||||
put_pattern("match", ' ', spp, attr);
|
put_pattern("match", ' ', spp, attr);
|
||||||
@@ -3716,12 +3717,10 @@ static void put_id_list(const char *const name,
|
|||||||
msg_putchar(' ');
|
msg_putchar(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
static void put_pattern(char *s, int c, synpat_T *spp, int attr)
|
static void put_pattern(const char *const s, const int c,
|
||||||
|
const synpat_T *const spp, const int attr)
|
||||||
{
|
{
|
||||||
long n;
|
static const char *const sepchars = "/+=-#@\"|'^&";
|
||||||
int mask;
|
|
||||||
int first;
|
|
||||||
static char *sepchars = "/+=-#@\"|'^&";
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* May have to write "matchgroup=group" */
|
/* May have to write "matchgroup=group" */
|
||||||
@@ -3750,10 +3749,10 @@ static void put_pattern(char *s, int c, synpat_T *spp, int attr)
|
|||||||
msg_outtrans(spp->sp_pattern);
|
msg_outtrans(spp->sp_pattern);
|
||||||
msg_putchar(sepchars[i]);
|
msg_putchar(sepchars[i]);
|
||||||
|
|
||||||
/* output any pattern options */
|
// output any pattern options
|
||||||
first = TRUE;
|
bool first = true;
|
||||||
for (i = 0; i < SPO_COUNT; ++i) {
|
for (i = 0; i < SPO_COUNT; i++) {
|
||||||
mask = (1 << i);
|
const int mask = (1 << i);
|
||||||
if (!(spp->sp_off_flags & (mask + (mask << SPO_COUNT)))) {
|
if (!(spp->sp_off_flags & (mask + (mask << SPO_COUNT)))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -3761,7 +3760,7 @@ static void put_pattern(char *s, int c, synpat_T *spp, int attr)
|
|||||||
msg_putchar(','); // Separate with commas.
|
msg_putchar(','); // Separate with commas.
|
||||||
}
|
}
|
||||||
msg_puts(spo_name_tab[i]);
|
msg_puts(spo_name_tab[i]);
|
||||||
n = spp->sp_offsets[i];
|
const long n = spp->sp_offsets[i];
|
||||||
if (i != SPO_LC_OFF) {
|
if (i != SPO_LC_OFF) {
|
||||||
if (spp->sp_off_flags & mask)
|
if (spp->sp_off_flags & mask)
|
||||||
msg_putchar('s');
|
msg_putchar('s');
|
||||||
@@ -3770,21 +3769,20 @@ static void put_pattern(char *s, int c, synpat_T *spp, int attr)
|
|||||||
if (n > 0)
|
if (n > 0)
|
||||||
msg_putchar('+');
|
msg_putchar('+');
|
||||||
}
|
}
|
||||||
if (n || i == SPO_LC_OFF)
|
if (n || i == SPO_LC_OFF) {
|
||||||
msg_outnum(n);
|
msg_outnum(n);
|
||||||
first = FALSE;
|
}
|
||||||
|
first = false;
|
||||||
}
|
}
|
||||||
msg_putchar(' ');
|
msg_putchar(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// List or clear the keywords for one syntax group.
|
||||||
* List or clear the keywords for one syntax group.
|
// Return true if the header has been printed.
|
||||||
* Return TRUE if the header has been printed.
|
static bool syn_list_keywords(
|
||||||
*/
|
|
||||||
static int syn_list_keywords(
|
|
||||||
const int id,
|
const int id,
|
||||||
const hashtab_T *const ht,
|
const hashtab_T *const ht,
|
||||||
int did_header, // header has already been printed
|
bool did_header, // header has already been printed
|
||||||
const int attr
|
const int attr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -3824,7 +3822,7 @@ static int syn_list_keywords(
|
|||||||
prev_skipwhite = 0;
|
prev_skipwhite = 0;
|
||||||
prev_skipempty = 0;
|
prev_skipempty = 0;
|
||||||
}
|
}
|
||||||
did_header = TRUE;
|
did_header = true;
|
||||||
if (prev_contained != (kp->flags & HL_CONTAINED)) {
|
if (prev_contained != (kp->flags & HL_CONTAINED)) {
|
||||||
msg_puts_attr("contained", attr);
|
msg_puts_attr("contained", attr);
|
||||||
msg_putchar(' ');
|
msg_putchar(' ');
|
||||||
@@ -6973,12 +6971,10 @@ static void highlight_clear(int idx)
|
|||||||
#define LIST_INT 3
|
#define LIST_INT 3
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
static void highlight_list_one(int id)
|
static void highlight_list_one(const int id)
|
||||||
{
|
{
|
||||||
struct hl_group *sgp;
|
struct hl_group *const sgp = &HL_TABLE()[id - 1]; // index is ID minus one
|
||||||
int didh = FALSE;
|
bool didh = false;
|
||||||
|
|
||||||
sgp = &HL_TABLE()[id - 1]; /* index is ID minus one */
|
|
||||||
|
|
||||||
didh = highlight_list_arg(id, didh, LIST_ATTR,
|
didh = highlight_list_arg(id, didh, LIST_ATTR,
|
||||||
sgp->sg_cterm, NULL, "cterm");
|
sgp->sg_cterm, NULL, "cterm");
|
||||||
@@ -7015,24 +7011,24 @@ static void highlight_list_one(int id)
|
|||||||
/// @param type one of \ref LIST_XXX
|
/// @param type one of \ref LIST_XXX
|
||||||
/// @param iarg integer argument used if \p type == LIST_INT
|
/// @param iarg integer argument used if \p type == LIST_INT
|
||||||
/// @param sarg string used if \p type == LIST_STRING
|
/// @param sarg string used if \p type == LIST_STRING
|
||||||
static int highlight_list_arg(int id, int didh, int type, int iarg,
|
static bool highlight_list_arg(
|
||||||
char_u *sarg, const char *name)
|
const int id, bool didh, const int type, int iarg,
|
||||||
|
char_u *const sarg, const char *const name)
|
||||||
{
|
{
|
||||||
char_u buf[100];
|
char_u buf[100];
|
||||||
char_u *ts;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (got_int)
|
if (got_int) {
|
||||||
return FALSE;
|
return false;
|
||||||
|
}
|
||||||
if (type == LIST_STRING ? (sarg != NULL) : (iarg != 0)) {
|
if (type == LIST_STRING ? (sarg != NULL) : (iarg != 0)) {
|
||||||
ts = buf;
|
char_u *ts = buf;
|
||||||
if (type == LIST_INT)
|
if (type == LIST_INT) {
|
||||||
sprintf((char *)buf, "%d", iarg - 1);
|
snprintf((char *)buf, sizeof(buf), "%d", iarg - 1);
|
||||||
else if (type == LIST_STRING)
|
} else if (type == LIST_STRING) {
|
||||||
ts = sarg;
|
ts = sarg;
|
||||||
else { /* type == LIST_ATTR */
|
} else { // type == LIST_ATTR
|
||||||
buf[0] = NUL;
|
buf[0] = NUL;
|
||||||
for (i = 0; hl_attr_table[i] != 0; ++i) {
|
for (int i = 0; hl_attr_table[i] != 0; i++) {
|
||||||
if (iarg & hl_attr_table[i]) {
|
if (iarg & hl_attr_table[i]) {
|
||||||
if (buf[0] != NUL)
|
if (buf[0] != NUL)
|
||||||
xstrlcat((char *)buf, ",", 100);
|
xstrlcat((char *)buf, ",", 100);
|
||||||
@@ -7042,9 +7038,8 @@ static int highlight_list_arg(int id, int didh, int type, int iarg,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)syn_list_header(didh,
|
(void)syn_list_header(didh, (int)(vim_strsize(ts) + STRLEN(name) + 1), id);
|
||||||
(int)(vim_strsize(ts) + STRLEN(name) + 1), id);
|
didh = true;
|
||||||
didh = TRUE;
|
|
||||||
if (!got_int) {
|
if (!got_int) {
|
||||||
if (*name != NUL) {
|
if (*name != NUL) {
|
||||||
MSG_PUTS_ATTR(name, HL_ATTR(HLF_D));
|
MSG_PUTS_ATTR(name, HL_ATTR(HLF_D));
|
||||||
@@ -7162,11 +7157,11 @@ const char *highlight_color(const int id, const char *const what,
|
|||||||
/// @param outlen length of string that comes
|
/// @param outlen length of string that comes
|
||||||
/// @param id highlight group id
|
/// @param id highlight group id
|
||||||
/// @return true when started a new line.
|
/// @return true when started a new line.
|
||||||
static int
|
static bool syn_list_header(const bool did_header, const int outlen,
|
||||||
syn_list_header(int did_header, int outlen, int id)
|
const int id)
|
||||||
{
|
{
|
||||||
int endcol = 19;
|
int endcol = 19;
|
||||||
int newline = TRUE;
|
bool newline = true;
|
||||||
|
|
||||||
if (!did_header) {
|
if (!did_header) {
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
@@ -7177,11 +7172,13 @@ syn_list_header(int did_header, int outlen, int id)
|
|||||||
endcol = 15;
|
endcol = 15;
|
||||||
} else if (msg_col + outlen + 1 >= Columns) {
|
} else if (msg_col + outlen + 1 >= Columns) {
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
if (got_int)
|
if (got_int) {
|
||||||
return TRUE;
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (msg_col >= endcol) /* wrap around is like starting a new line */
|
if (msg_col >= endcol) { // wrap around is like starting a new line
|
||||||
newline = FALSE;
|
newline = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_col >= endcol) /* output at least one space */
|
if (msg_col >= endcol) /* output at least one space */
|
||||||
|
|||||||
Reference in New Issue
Block a user