tweaks: rename some variables, to show they refer to screen rows
Этот коммит содержится в:
родитель
f7d320d932
Коммит
892762d99c
@ -35,7 +35,7 @@ static char **filelist = NULL;
|
|||||||
static size_t filelist_len = 0;
|
static size_t filelist_len = 0;
|
||||||
/* The number of files in the list. */
|
/* The number of files in the list. */
|
||||||
static int width = 0;
|
static int width = 0;
|
||||||
/* The number of files that we can display per line. */
|
/* The number of files that we can display per screen row. */
|
||||||
static int longest = 0;
|
static int longest = 0;
|
||||||
/* The number of columns in the longest filename in the list. */
|
/* The number of columns in the longest filename in the list. */
|
||||||
static size_t selected = 0;
|
static size_t selected = 0;
|
||||||
@ -385,7 +385,7 @@ char *do_browse_from(const char *inpath)
|
|||||||
* set filelist_len to the number of files in that list, set longest to
|
* set filelist_len to the number of files in that list, set longest to
|
||||||
* the width in columns of the longest filename in that list (between 15
|
* the width in columns of the longest filename in that list (between 15
|
||||||
* and COLS), and set width to the number of files that we can display
|
* and COLS), and set width to the number of files that we can display
|
||||||
* per line. And sort the list too. */
|
* per screen row. And sort the list too. */
|
||||||
void read_the_list(const char *path, DIR *dir)
|
void read_the_list(const char *path, DIR *dir)
|
||||||
{
|
{
|
||||||
const struct dirent *nextdir;
|
const struct dirent *nextdir;
|
||||||
@ -482,15 +482,15 @@ functionptrtype parse_browser_input(int *kbinput)
|
|||||||
return func_from_key(kbinput);
|
return func_from_key(kbinput);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set width to the number of files that we can display per line, if
|
/* Set width to the number of files that we can display per screen row,
|
||||||
* necessary, and display the list of files. */
|
* if necessary, and display the list of files. */
|
||||||
void browser_refresh(void)
|
void browser_refresh(void)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
int line = 0, col = 0;
|
int row = 0, col = 0;
|
||||||
/* The current line and column while the list is getting displayed. */
|
/* The current row and column while the list is getting displayed. */
|
||||||
int the_line = 0, the_column = 0;
|
int the_row = 0, the_column = 0;
|
||||||
/* The line and column of the selected item. */
|
/* The row and column of the selected item. */
|
||||||
char *info;
|
char *info;
|
||||||
/* The additional information that we'll display about a file. */
|
/* The additional information that we'll display about a file. */
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ void browser_refresh(void)
|
|||||||
|
|
||||||
i = selected - selected % (editwinrows * width);
|
i = selected - selected % (editwinrows * width);
|
||||||
|
|
||||||
for (; i < filelist_len && line < editwinrows; i++) {
|
for (; i < filelist_len && row < editwinrows; i++) {
|
||||||
struct stat st;
|
struct stat st;
|
||||||
const char *thename = tail(filelist[i]);
|
const char *thename = tail(filelist[i]);
|
||||||
/* The filename we display, minus the path. */
|
/* The filename we display, minus the path. */
|
||||||
@ -524,16 +524,16 @@ void browser_refresh(void)
|
|||||||
* remember its location to be able to place the cursor on it. */
|
* remember its location to be able to place the cursor on it. */
|
||||||
if (i == selected) {
|
if (i == selected) {
|
||||||
wattron(edit, hilite_attribute);
|
wattron(edit, hilite_attribute);
|
||||||
the_line = line;
|
the_row = row;
|
||||||
the_column = col;
|
the_column = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
blank_row(edit, line, col, longest);
|
blank_row(edit, row, col, longest);
|
||||||
|
|
||||||
/* If the name is too long, we display something like "...ename". */
|
/* If the name is too long, we display something like "...ename". */
|
||||||
if (dots)
|
if (dots)
|
||||||
mvwaddstr(edit, line, col, "...");
|
mvwaddstr(edit, row, col, "...");
|
||||||
mvwaddstr(edit, line, dots ? col + 3 : col, disp);
|
mvwaddstr(edit, row, dots ? col + 3 : col, disp);
|
||||||
|
|
||||||
free(disp);
|
free(disp);
|
||||||
|
|
||||||
@ -591,7 +591,7 @@ void browser_refresh(void)
|
|||||||
infolen = infomaxlen;
|
infolen = infomaxlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
mvwaddstr(edit, line, col - infolen, info);
|
mvwaddstr(edit, row, col - infolen, info);
|
||||||
|
|
||||||
/* If this is the selected item, finish its highlighting. */
|
/* If this is the selected item, finish its highlighting. */
|
||||||
if (i == selected)
|
if (i == selected)
|
||||||
@ -602,17 +602,17 @@ void browser_refresh(void)
|
|||||||
/* Add some space between the columns. */
|
/* Add some space between the columns. */
|
||||||
col += 2;
|
col += 2;
|
||||||
|
|
||||||
/* If the next entry isn't going to fit on the current line,
|
/* If the next entry isn't going to fit on the current row,
|
||||||
* move to the next line. */
|
* move to the next row. */
|
||||||
if (col > COLS - longest) {
|
if (col > COLS - longest) {
|
||||||
line++;
|
row++;
|
||||||
col = 0;
|
col = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If requested, put the cursor on the selected item and switch it on. */
|
/* If requested, put the cursor on the selected item and switch it on. */
|
||||||
if (ISSET(SHOW_CURSOR)) {
|
if (ISSET(SHOW_CURSOR)) {
|
||||||
wmove(edit, the_line, the_column);
|
wmove(edit, the_row, the_column);
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
74
src/winio.c
74
src/winio.c
@ -2287,7 +2287,7 @@ void reset_cursor(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* edit_draw() takes care of the job of actually painting a line into
|
/* edit_draw() takes care of the job of actually painting a line into
|
||||||
* the edit window. fileptr is the line to be painted, at row line of
|
* the edit window. fileptr is the line to be painted, at row row of
|
||||||
* the window. converted is the actual string to be written to the
|
* the window. converted is the actual string to be written to the
|
||||||
* window, with tabs and control characters replaced by strings of
|
* window, with tabs and control characters replaced by strings of
|
||||||
* regular characters. from_col is the column number of the first
|
* regular characters. from_col is the column number of the first
|
||||||
@ -2295,7 +2295,7 @@ void reset_cursor(void)
|
|||||||
* corresponds to character number actual_x(fileptr->data, from_col) of the
|
* corresponds to character number actual_x(fileptr->data, from_col) of the
|
||||||
* line. */
|
* line. */
|
||||||
void edit_draw(filestruct *fileptr, const char *converted,
|
void edit_draw(filestruct *fileptr, const char *converted,
|
||||||
int line, size_t from_col)
|
int row, size_t from_col)
|
||||||
{
|
{
|
||||||
#if !defined(NANO_TINY) || !defined(DISABLE_COLOR)
|
#if !defined(NANO_TINY) || !defined(DISABLE_COLOR)
|
||||||
size_t from_x = actual_x(fileptr->data, from_col);
|
size_t from_x = actual_x(fileptr->data, from_col);
|
||||||
@ -2317,24 +2317,24 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
|||||||
wattron(edit, interface_color_pair[LINE_NUMBER]);
|
wattron(edit, interface_color_pair[LINE_NUMBER]);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(SOFTWRAP) && from_x != 0)
|
if (ISSET(SOFTWRAP) && from_x != 0)
|
||||||
mvwprintw(edit, line, 0, "%*s", margin - 1, " ");
|
mvwprintw(edit, row, 0, "%*s", margin - 1, " ");
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
mvwprintw(edit, line, 0, "%*ld", margin - 1, (long)fileptr->lineno);
|
mvwprintw(edit, row, 0, "%*ld", margin - 1, (long)fileptr->lineno);
|
||||||
wattroff(edit, interface_color_pair[LINE_NUMBER]);
|
wattroff(edit, interface_color_pair[LINE_NUMBER]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* First simply write the line -- afterward we'll add colors and the
|
/* First simply write the converted line -- afterward we'll add colors
|
||||||
* marking highlight on just the pieces that need it. */
|
* and the marking highlight on just the pieces that need it. */
|
||||||
mvwaddstr(edit, line, margin, converted);
|
mvwaddstr(edit, row, margin, converted);
|
||||||
|
|
||||||
#ifdef USING_OLD_NCURSES
|
#ifdef USING_OLD_NCURSES
|
||||||
/* Tell ncurses to really redraw the line without trying to optimize
|
/* Tell ncurses to really redraw the line without trying to optimize
|
||||||
* for what it thinks is already there, because it gets it wrong in
|
* for what it thinks is already there, because it gets it wrong in
|
||||||
* the case of a wide character in column zero. See bug #31743. */
|
* the case of a wide character in column zero. See bug #31743. */
|
||||||
if (seen_wide)
|
if (seen_wide)
|
||||||
wredrawln(edit, line, 1);
|
wredrawln(edit, row, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_COLOR
|
#ifndef DISABLE_COLOR
|
||||||
@ -2407,7 +2407,7 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
|||||||
paintlen = actual_x(thetext, strnlenpt(fileptr->data,
|
paintlen = actual_x(thetext, strnlenpt(fileptr->data,
|
||||||
startmatch.rm_eo) - from_col - start_col);
|
startmatch.rm_eo) - from_col - start_col);
|
||||||
|
|
||||||
mvwaddnstr(edit, line, margin + start_col,
|
mvwaddnstr(edit, row, margin + start_col,
|
||||||
thetext, paintlen);
|
thetext, paintlen);
|
||||||
}
|
}
|
||||||
goto tail_of_loop;
|
goto tail_of_loop;
|
||||||
@ -2423,7 +2423,7 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
|||||||
if (fileptr->multidata[varnish->id] == CNONE)
|
if (fileptr->multidata[varnish->id] == CNONE)
|
||||||
goto tail_of_loop;
|
goto tail_of_loop;
|
||||||
else if (fileptr->multidata[varnish->id] == CWHOLELINE) {
|
else if (fileptr->multidata[varnish->id] == CWHOLELINE) {
|
||||||
mvwaddnstr(edit, line, margin, converted, -1);
|
mvwaddnstr(edit, row, margin, converted, -1);
|
||||||
goto tail_of_loop;
|
goto tail_of_loop;
|
||||||
} else if (fileptr->multidata[varnish->id] == CBEGINBEFORE) {
|
} else if (fileptr->multidata[varnish->id] == CBEGINBEFORE) {
|
||||||
regexec(varnish->end, fileptr->data, 1, &endmatch, 0);
|
regexec(varnish->end, fileptr->data, 1, &endmatch, 0);
|
||||||
@ -2432,7 +2432,7 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
|||||||
goto tail_of_loop;
|
goto tail_of_loop;
|
||||||
paintlen = actual_x(converted, strnlenpt(fileptr->data,
|
paintlen = actual_x(converted, strnlenpt(fileptr->data,
|
||||||
endmatch.rm_eo) - from_col);
|
endmatch.rm_eo) - from_col);
|
||||||
mvwaddnstr(edit, line, margin, converted, paintlen);
|
mvwaddnstr(edit, row, margin, converted, paintlen);
|
||||||
goto tail_of_loop;
|
goto tail_of_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2516,20 +2516,20 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
|||||||
/* Now paint the start of the line. However, if the end match
|
/* Now paint the start of the line. However, if the end match
|
||||||
* is on a different line, paint the whole line, and go on. */
|
* is on a different line, paint the whole line, and go on. */
|
||||||
if (end_line != fileptr) {
|
if (end_line != fileptr) {
|
||||||
mvwaddnstr(edit, line, margin, converted, -1);
|
mvwaddnstr(edit, row, margin, converted, -1);
|
||||||
fileptr->multidata[varnish->id] = CWHOLELINE;
|
fileptr->multidata[varnish->id] = CWHOLELINE;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, " Marking for id %i line %i as CWHOLELINE\n", varnish->id, line);
|
fprintf(stderr, " Marking for id %i row %i as CWHOLELINE\n", varnish->id, row);
|
||||||
#endif
|
#endif
|
||||||
/* Don't bother looking for any more starts. */
|
/* Don't bother looking for any more starts. */
|
||||||
goto tail_of_loop;
|
goto tail_of_loop;
|
||||||
} else {
|
} else {
|
||||||
paintlen = actual_x(converted, strnlenpt(fileptr->data,
|
paintlen = actual_x(converted, strnlenpt(fileptr->data,
|
||||||
endmatch.rm_eo) - from_col);
|
endmatch.rm_eo) - from_col);
|
||||||
mvwaddnstr(edit, line, margin, converted, paintlen);
|
mvwaddnstr(edit, row, margin, converted, paintlen);
|
||||||
fileptr->multidata[varnish->id] = CBEGINBEFORE;
|
fileptr->multidata[varnish->id] = CBEGINBEFORE;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, " Marking for id %i line %i as CBEGINBEFORE\n", varnish->id, line);
|
fprintf(stderr, " Marking for id %i row %i as CBEGINBEFORE\n", varnish->id, row);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
step_two:
|
step_two:
|
||||||
@ -2565,12 +2565,12 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
|||||||
paintlen = actual_x(thetext, strnlenpt(fileptr->data,
|
paintlen = actual_x(thetext, strnlenpt(fileptr->data,
|
||||||
endmatch.rm_eo) - from_col - start_col);
|
endmatch.rm_eo) - from_col - start_col);
|
||||||
|
|
||||||
mvwaddnstr(edit, line, margin + start_col,
|
mvwaddnstr(edit, row, margin + start_col,
|
||||||
thetext, paintlen);
|
thetext, paintlen);
|
||||||
|
|
||||||
fileptr->multidata[varnish->id] = CSTARTENDHERE;
|
fileptr->multidata[varnish->id] = CSTARTENDHERE;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, " Marking for id %i line %i as CSTARTENDHERE\n", varnish->id, line);
|
fprintf(stderr, " Marking for id %i row %i as CSTARTENDHERE\n", varnish->id, row);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
index = endmatch.rm_eo;
|
index = endmatch.rm_eo;
|
||||||
@ -2592,10 +2592,10 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
/* Paint the rest of the line. */
|
/* Paint the rest of the line. */
|
||||||
mvwaddnstr(edit, line, margin + start_col, thetext, -1);
|
mvwaddnstr(edit, row, margin + start_col, thetext, -1);
|
||||||
fileptr->multidata[varnish->id] = CENDAFTER;
|
fileptr->multidata[varnish->id] = CENDAFTER;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, " Marking for id %i line %i as CENDAFTER\n", varnish->id, line);
|
fprintf(stderr, " Marking for id %i row %i as CENDAFTER\n", varnish->id, row);
|
||||||
#endif
|
#endif
|
||||||
/* We've painted to the end of the line, so don't
|
/* We've painted to the end of the line, so don't
|
||||||
* bother checking for any more starts. */
|
* bother checking for any more starts. */
|
||||||
@ -2648,7 +2648,7 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
|||||||
}
|
}
|
||||||
|
|
||||||
wattron(edit, hilite_attribute);
|
wattron(edit, hilite_attribute);
|
||||||
mvwaddnstr(edit, line, margin + start_col, thetext, paintlen);
|
mvwaddnstr(edit, row, margin + start_col, thetext, paintlen);
|
||||||
wattroff(edit, hilite_attribute);
|
wattroff(edit, hilite_attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2661,7 +2661,7 @@ void edit_draw(filestruct *fileptr, const char *converted,
|
|||||||
* Returns: Number of additional lines consumed (needed for SOFTWRAP). */
|
* Returns: Number of additional lines consumed (needed for SOFTWRAP). */
|
||||||
int update_line(filestruct *fileptr, size_t index)
|
int update_line(filestruct *fileptr, size_t index)
|
||||||
{
|
{
|
||||||
int line = 0;
|
int row = 0;
|
||||||
/* The row in the edit window we will be updating. */
|
/* The row in the edit window we will be updating. */
|
||||||
int extralinesused = 0;
|
int extralinesused = 0;
|
||||||
char *converted;
|
char *converted;
|
||||||
@ -2673,16 +2673,16 @@ int update_line(filestruct *fileptr, size_t index)
|
|||||||
filestruct *tmp;
|
filestruct *tmp;
|
||||||
|
|
||||||
for (tmp = openfile->edittop; tmp && tmp != fileptr; tmp = tmp->next)
|
for (tmp = openfile->edittop; tmp && tmp != fileptr; tmp = tmp->next)
|
||||||
line += (strlenpt(tmp->data) / editwincols) + 1;
|
row += (strlenpt(tmp->data) / editwincols) + 1;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
line = fileptr->lineno - openfile->edittop->lineno;
|
row = fileptr->lineno - openfile->edittop->lineno;
|
||||||
|
|
||||||
if (line < 0 || line >= editwinrows)
|
if (row < 0 || row >= editwinrows)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* First, blank out the line. */
|
/* First, blank out the row. */
|
||||||
blank_row(edit, line, 0, COLS);
|
blank_row(edit, row, 0, COLS);
|
||||||
|
|
||||||
/* Next, convert variables that index the line to their equivalent
|
/* Next, convert variables that index the line to their equivalent
|
||||||
* positions in the expanded line. */
|
* positions in the expanded line. */
|
||||||
@ -2702,26 +2702,26 @@ int update_line(filestruct *fileptr, size_t index)
|
|||||||
fprintf(stderr, "update_line(): converted(1) line = %s\n", converted);
|
fprintf(stderr, "update_line(): converted(1) line = %s\n", converted);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Paint the line. */
|
/* Draw the line. */
|
||||||
edit_draw(fileptr, converted, line, page_start);
|
edit_draw(fileptr, converted, row, page_start);
|
||||||
free(converted);
|
free(converted);
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (!ISSET(SOFTWRAP)) {
|
if (!ISSET(SOFTWRAP)) {
|
||||||
#endif
|
#endif
|
||||||
if (page_start > 0)
|
if (page_start > 0)
|
||||||
mvwaddch(edit, line, margin, '$');
|
mvwaddch(edit, row, margin, '$');
|
||||||
if (strlenpt(fileptr->data) > page_start + editwincols)
|
if (strlenpt(fileptr->data) > page_start + editwincols)
|
||||||
mvwaddch(edit, line, COLS - 1, '$');
|
mvwaddch(edit, row, COLS - 1, '$');
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
} else {
|
} else {
|
||||||
size_t full_length = strlenpt(fileptr->data);
|
size_t full_length = strlenpt(fileptr->data);
|
||||||
for (index += editwincols; index <= full_length && line < editwinrows - 1; index += editwincols) {
|
for (index += editwincols; index <= full_length && row < editwinrows - 1; index += editwincols) {
|
||||||
line++;
|
row++;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "update_line(): softwrap code, moving to %d index %lu\n", line, (unsigned long)index);
|
fprintf(stderr, "update_line(): softwrap code, moving to %d index %lu\n", row, (unsigned long)index);
|
||||||
#endif
|
#endif
|
||||||
blank_row(edit, line, 0, COLS);
|
blank_row(edit, row, 0, COLS);
|
||||||
|
|
||||||
/* Expand the line, replacing tabs with spaces, and control
|
/* Expand the line, replacing tabs with spaces, and control
|
||||||
* characters with their displayed forms. */
|
* characters with their displayed forms. */
|
||||||
@ -2730,10 +2730,10 @@ int update_line(filestruct *fileptr, size_t index)
|
|||||||
if (ISSET(SOFTWRAP) && strlen(converted) >= editwincols - 2)
|
if (ISSET(SOFTWRAP) && strlen(converted) >= editwincols - 2)
|
||||||
fprintf(stderr, "update_line(): converted(2) line = %s\n", converted);
|
fprintf(stderr, "update_line(): converted(2) line = %s\n", converted);
|
||||||
#endif
|
#endif
|
||||||
|
/* Draw the line. */
|
||||||
/* Paint the line. */
|
edit_draw(fileptr, converted, row, index);
|
||||||
edit_draw(fileptr, converted, line, index);
|
|
||||||
free(converted);
|
free(converted);
|
||||||
|
|
||||||
extralinesused++;
|
extralinesused++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user