tweaks: rename a function, to be more precise, and reshuffle it
parent
78bfc9223a
commit
15fadd700a
|
@ -47,7 +47,7 @@ void do_deletion(undo_type action)
|
|||
update_undo(action);
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
old_amount = number_of_chunks_in(openfile->current);
|
||||
old_amount = extra_chunks_in(openfile->current);
|
||||
#endif
|
||||
/* Move the remainder of the line "in", over the current character. */
|
||||
memmove(&openfile->current->data[openfile->current_x],
|
||||
|
@ -107,7 +107,7 @@ void do_deletion(undo_type action)
|
|||
/* If the number of screen rows that a softwrapped line occupies
|
||||
* has changed, we need a full refresh. */
|
||||
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
|
||||
number_of_chunks_in(openfile->current) != old_amount)
|
||||
extra_chunks_in(openfile->current) != old_amount)
|
||||
refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -556,7 +556,7 @@ void do_scroll_down(void)
|
|||
|
||||
if (editwinrows > 1 && (openfile->edittop->next != NULL
|
||||
#ifndef NANO_TINY
|
||||
|| (ISSET(SOFTWRAP) && (number_of_chunks_in(openfile->edittop) >
|
||||
|| (ISSET(SOFTWRAP) && (extra_chunks_in(openfile->edittop) >
|
||||
chunk_for(openfile->firstcolumn, openfile->edittop)))
|
||||
#endif
|
||||
))
|
||||
|
|
|
@ -1409,7 +1409,7 @@ void inject(char *burst, size_t count)
|
|||
if (ISSET(SOFTWRAP)) {
|
||||
if (openfile->current_y == editwinrows - 1)
|
||||
original_row = chunk_for(xplustabs(), thisline);
|
||||
old_amount = number_of_chunks_in(thisline);
|
||||
old_amount = extra_chunks_in(thisline);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1475,7 +1475,7 @@ void inject(char *burst, size_t count)
|
|||
* changed, we need a full refresh. */
|
||||
if (ISSET(SOFTWRAP) && ((openfile->current_y == editwinrows - 1 &&
|
||||
chunk_for(xplustabs(), openfile->current) > original_row) ||
|
||||
number_of_chunks_in(openfile->current) != old_amount)) {
|
||||
extra_chunks_in(openfile->current) != old_amount)) {
|
||||
refresh_needed = TRUE;
|
||||
focusing = FALSE;
|
||||
}
|
||||
|
|
|
@ -627,7 +627,7 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
|
|||
size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge);
|
||||
size_t chunk_for(size_t column, linestruct *line);
|
||||
size_t leftedge_for(size_t column, linestruct *line);
|
||||
size_t number_of_chunks_in(linestruct *line);
|
||||
size_t extra_chunks_in(linestruct *line);
|
||||
void ensure_firstcolumn_is_aligned(void);
|
||||
#endif
|
||||
size_t actual_last_column(size_t leftedge, size_t column);
|
||||
|
|
19
src/winio.c
19
src/winio.c
|
@ -2343,7 +2343,7 @@ void place_the_cursor(void)
|
|||
|
||||
/* Calculate how many rows the lines from edittop to current use. */
|
||||
while (line != NULL && line != openfile->current) {
|
||||
row += number_of_chunks_in(line) + 1;
|
||||
row += 1 + extra_chunks_in(line);
|
||||
line = line->next;
|
||||
}
|
||||
|
||||
|
@ -2818,7 +2818,7 @@ int update_softwrapped_line(linestruct *line)
|
|||
|
||||
/* Find out on which screen row the target line should be shown. */
|
||||
while (someline != line && someline != NULL) {
|
||||
row += number_of_chunks_in(someline) + 1;
|
||||
row += 1 + extra_chunks_in(someline);
|
||||
someline = someline->next;
|
||||
}
|
||||
|
||||
|
@ -3094,6 +3094,12 @@ size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge)
|
|||
}
|
||||
}
|
||||
|
||||
/* Return how many extra rows the given line needs when softwrapping. */
|
||||
size_t extra_chunks_in(linestruct *line)
|
||||
{
|
||||
return get_chunk_and_edge((size_t)-1, line, NULL);
|
||||
}
|
||||
|
||||
/* Return the row of the softwrapped chunk of the given line that column is on,
|
||||
* relative to the first row (zero-based). */
|
||||
size_t chunk_for(size_t column, linestruct *line)
|
||||
|
@ -3102,7 +3108,7 @@ size_t chunk_for(size_t column, linestruct *line)
|
|||
}
|
||||
|
||||
/* Return the leftmost column of the softwrapped chunk of the given line that
|
||||
* column is on. */
|
||||
* the given column is on. */
|
||||
size_t leftedge_for(size_t column, linestruct *line)
|
||||
{
|
||||
size_t leftedge;
|
||||
|
@ -3112,13 +3118,6 @@ size_t leftedge_for(size_t column, linestruct *line)
|
|||
return leftedge;
|
||||
}
|
||||
|
||||
/* Return the row of the last softwrapped chunk of the given line, relative to
|
||||
* the first row (zero-based). */
|
||||
size_t number_of_chunks_in(linestruct *line)
|
||||
{
|
||||
return get_chunk_and_edge((size_t)-1, line, NULL);
|
||||
}
|
||||
|
||||
/* Ensure that firstcolumn is at the starting column of the softwrapped chunk
|
||||
* it's on. We need to do this when the number of columns of the edit window
|
||||
* has changed, because then the width of softwrapped chunks has changed. */
|
||||
|
|
Loading…
Reference in New Issue