tweaks: don't use a variable for two different purposes
At first paintlen was computed as a column span, and then converted to a character count... Confusing.master
parent
aa28441071
commit
a89437219d
33
src/winio.c
33
src/winio.c
|
@ -2625,12 +2625,11 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||||
size_t top_x, bot_x;
|
size_t top_x, bot_x;
|
||||||
/* The x positions where the marked region begins and ends. */
|
/* The x positions where the marked region begins and ends. */
|
||||||
int start_col;
|
int start_col;
|
||||||
/* The starting column for mvwaddnstr(). Zero-based. */
|
/* The column where painting starts. Zero-based. */
|
||||||
int paintlen;
|
const char *thetext;
|
||||||
/* Number of characters to paint on this line. There are
|
/* The place in converted from where painting starts. */
|
||||||
* COLS characters on a whole line. */
|
int paintlen = -1;
|
||||||
size_t index;
|
/* The number of characters to paint. Negative means "all". */
|
||||||
/* Index in converted where we paint. */
|
|
||||||
|
|
||||||
mark_order(&top, &top_x, &bot, &bot_x, NULL);
|
mark_order(&top, &top_x, &bot, &bot_x, NULL);
|
||||||
|
|
||||||
|
@ -2644,23 +2643,17 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||||
/* Compute on which screen column to start painting. */
|
/* Compute on which screen column to start painting. */
|
||||||
start_col = strnlenpt(fileptr->data, top_x) - from_col;
|
start_col = strnlenpt(fileptr->data, top_x) - from_col;
|
||||||
|
|
||||||
/* If the end of the mark is off the page, paintlen is -1,
|
thetext = converted + actual_x(converted, start_col);
|
||||||
* meaning that everything on the line gets painted.
|
|
||||||
* Otherwise, paintlen is the expanded location of the end
|
|
||||||
* of the mark minus the expanded location of the beginning
|
|
||||||
* of the mark. */
|
|
||||||
if (bot_x >= till_x)
|
|
||||||
paintlen = -1;
|
|
||||||
else
|
|
||||||
paintlen = strnlenpt(fileptr->data, bot_x) - (start_col + from_col);
|
|
||||||
|
|
||||||
index = actual_x(converted, start_col);
|
/* If the end of the mark is onscreen, compute how many
|
||||||
|
* characters to paint. Otherwise, just paint all. */
|
||||||
if (paintlen > 0)
|
if (bot_x < till_x) {
|
||||||
paintlen = actual_x(converted + index, paintlen);
|
size_t end_col = strnlenpt(fileptr->data, bot_x) - from_col;
|
||||||
|
paintlen = actual_x(thetext, end_col - start_col);
|
||||||
|
}
|
||||||
|
|
||||||
wattron(edit, hilite_attribute);
|
wattron(edit, hilite_attribute);
|
||||||
mvwaddnstr(edit, line, margin + start_col, converted + index, paintlen);
|
mvwaddnstr(edit, line, margin + start_col, thetext, paintlen);
|
||||||
wattroff(edit, hilite_attribute);
|
wattroff(edit, hilite_attribute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue