Remove redundant comments

This commit is contained in:
Jacob 2023-08-08 20:13:29 +02:00
parent df74b9731e
commit d88ecbc2c9

View file

@ -124,15 +124,14 @@ static struct item *list_items;
static struct item *matches; static struct item *matches;
static struct item *matchend; static struct item *matchend;
static struct item *previousitem; // previous item static struct item *previousitem;
static struct item *currentitem; // current item static struct item *currentitem;
static struct item *nextitem; // next item static struct item *nextitem;
static struct item *selecteditem; // selected item static struct item *selecteditem;
static struct item *mouseitem; // clicked item static struct item *mouseitem;
static Draw_t *draw; // Draw_t type, see libs/draw/draw.c static Draw_t *draw;
// high priority
static int hplength = 0; static int hplength = 0;
static char **hpitems = NULL; static char **hpitems = NULL;
@ -150,7 +149,6 @@ static int isrtl = 1;
static int isrtl = 0; static int isrtl = 0;
#endif #endif
// declare functions
static int is_selected(size_t index); static int is_selected(size_t index);
static void calcoffsets(void); static void calcoffsets(void);
static void recalculatenumbers(void); static void recalculatenumbers(void);
@ -166,7 +164,6 @@ static void appenditem(struct item *item, struct item **list, struct item **last
static int max_textw(void); static int max_textw(void);
static size_t nextrune(int inc); static size_t nextrune(int inc);
// matching
static char * cistrstr(const char *s, const char *sub); static char * cistrstr(const char *s, const char *sub);
static int (*fstrncmp)(const char *, const char *, size_t) = strncasecmp; static int (*fstrncmp)(const char *, const char *, size_t) = strncasecmp;
static char *(*fstrstr)(const char *, const char *) = cistrstr; static char *(*fstrstr)(const char *, const char *) = cistrstr;
@ -280,7 +277,7 @@ static WlMouse wl_buttons[] = {
int is_selected(size_t index) { int is_selected(size_t index) {
for (int i = 0; i < sel_size; i++) { for (int i = 0; i < sel_size; i++) {
if (sel_index[i] == index) { if (sel_index[i] == index) {
return 1; // selected item index is size_t index return 1;
} }
} }
@ -305,12 +302,10 @@ void recalculatenumbers(void) {
if (matchend) { if (matchend) {
numer++; numer++;
// walk through items that match and add to numer
for (item = matchend; item && item->left; item = item->left) for (item = matchend; item && item->left; item = item->left)
numer++; numer++;
} }
// walk through all items, matching or not and add to denom
for (item = items; item && item->text; item++) { for (item = items; item && item->text; item++) {
denom++; denom++;
} }
@ -351,21 +346,19 @@ void calcoffsets(void) {
if (lines > 0) { if (lines > 0) {
offset = lines * columns * sp.bh; offset = lines * columns * sp.bh;
sp.maxlen = sp.mw - (sp.promptw + modew + numberw + capsw + menumarginh); sp.maxlen = sp.mw - (sp.promptw + modew + numberw + capsw + menumarginh);
} else { // no lines, therefore the size of items must be decreased to fit the menu elements } else { /* no lines, therefore the size of items must be decreased to fit the menu elements */
offset = sp.mw - (sp.promptw + sp.inputw + larroww + rarroww + modew + numberw + capsw + menumarginh); offset = sp.mw - (sp.promptw + sp.inputw + larroww + rarroww + modew + numberw + capsw + menumarginh);
sp.maxlen = selecteditem ? sp.inputw : sp.mw - (sp.promptw + modew + numberw + capsw + (selecteditem ? larroww : 0) + (selecteditem ? rarroww : 0)); sp.maxlen = selecteditem ? sp.inputw : sp.mw - (sp.promptw + modew + numberw + capsw + (selecteditem ? larroww : 0) + (selecteditem ? rarroww : 0));
} }
// calculate which items will begin the next page for (i = 0, nextitem = currentitem; nextitem; nextitem = nextitem->right) { // next page
for (i = 0, nextitem = currentitem; nextitem; nextitem = nextitem->right) {
nextitem->nsgrtext = get_text_n_sgr(nextitem); nextitem->nsgrtext = get_text_n_sgr(nextitem);
if ((i += (lines > 0) ? sp.bh : MIN(TEXTWM(nextitem->nsgrtext) + (powerlineitems ? !lines ? 3 * sp.plw : 0 : 0), offset)) > offset) if ((i += (lines > 0) ? sp.bh : MIN(TEXTWM(nextitem->nsgrtext) + (powerlineitems ? !lines ? 3 * sp.plw : 0 : 0), offset)) > offset)
break; break;
} }
// calculate which items will begin the previous page for (i = 0, previousitem = currentitem; previousitem && previousitem->left; previousitem = previousitem->left) { // previous page
for (i = 0, previousitem = currentitem; previousitem && previousitem->left; previousitem = previousitem->left) {
previousitem->nsgrtext = get_text_n_sgr(previousitem); previousitem->nsgrtext = get_text_n_sgr(previousitem);
if ((i += (lines > 0) ? sp.bh : MIN(TEXTWM(previousitem->left->nsgrtext) + (powerlineitems ? !lines ? 3 * sp.plw : 0 : 0), offset)) > offset) if ((i += (lines > 0) ? sp.bh : MIN(TEXTWM(previousitem->left->nsgrtext) + (powerlineitems ? !lines ? 3 * sp.plw : 0 : 0), offset)) > offset)
@ -386,14 +379,12 @@ void cleanup(void) {
size_t i; size_t i;
#if IMAGE #if IMAGE
cleanupimage(); // function frees images cleanupimage();
#endif #endif
// free high priority items
for (i = 0; i < hplength; ++i) for (i = 0; i < hplength; ++i)
free(hpitems[i]); free(hpitems[i]);
// free drawing and close the display
draw_free(draw); draw_free(draw);
#if X11 #if X11
@ -405,7 +396,6 @@ void cleanup(void) {
free(sel_index); free(sel_index);
} }
// This function handles case insensitive matching
char * cistrstr(const char *h, const char *n) { char * cistrstr(const char *h, const char *n) {
size_t i; size_t i;
@ -425,7 +415,7 @@ char * cistrstr(const char *h, const char *n) {
void insert(const char *str, ssize_t n) { void insert(const char *str, ssize_t n) {
if (strlen(tx.text) + n > sizeof tx.text - 1) if (strlen(tx.text) + n > sizeof tx.text - 1)
return; // length of text should not exceed size return;
static char l[BUFSIZ] = ""; static char l[BUFSIZ] = "";
@ -440,12 +430,10 @@ void insert(const char *str, ssize_t n) {
sizeof tx.text - sp.cursor - MAX(n, 0) sizeof tx.text - sp.cursor - MAX(n, 0)
); );
// update cursor
if (n > 0 && str && n) { if (n > 0 && str && n) {
memcpy(&tx.text[sp.cursor], str, n); memcpy(&tx.text[sp.cursor], str, n);
} }
// add to cursor position and continue matching
sp.cursor += n; sp.cursor += n;
match(); match();
@ -486,7 +474,7 @@ void resizeclient(void) {
#endif #endif
} }
/* Width reserved for input when !lines is a fixed size of the menu width / 3 /* Width reserved for input when !lines is a fixed size of the menu width * inputwidth
* This is reasonable, but in rare cases may cause input text to overlap * This is reasonable, but in rare cases may cause input text to overlap
* items. * items.
*/ */
@ -535,7 +523,6 @@ void set_mode(void) {
sp_strncpy(tx.modetext, normtext, sizeof(tx.modetext)); sp_strncpy(tx.modetext, normtext, sizeof(tx.modetext));
} }
// normal mode disabled
if (forceinsertmode) { if (forceinsertmode) {
sp.mode = 1; sp.mode = 1;
sp.allowkeys = 1; sp.allowkeys = 1;
@ -551,11 +538,11 @@ void handle(void) {
die("no fonts could be loaded."); die("no fonts could be loaded.");
} }
loadhistory(); // read history entries loadhistory();
#if IMAGE #if IMAGE
store_image_vars(); store_image_vars();
#endif #endif
// fast (-f) means we grab keyboard before reading standard input
if (fast && !isatty(0)) { if (fast && !isatty(0)) {
grabkeyboard_x11(); grabkeyboard_x11();
readstdin(); readstdin();