nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 15fadd700a5f32910a71772a54e150c218430486
parent 78bfc9223a69daae8d69a0b28a6cf891ab65a25e
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 13 May 2020 12:41:17 +0200

tweaks: rename a function, to be more precise, and reshuffle it

Diffstat:
Msrc/cut.c | 4++--
Msrc/move.c | 2+-
Msrc/nano.c | 4++--
Msrc/proto.h | 2+-
Msrc/winio.c | 19+++++++++----------
5 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/src/cut.c b/src/cut.c @@ -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 diff --git a/src/move.c b/src/move.c @@ -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 )) diff --git a/src/nano.c b/src/nano.c @@ -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; } diff --git a/src/proto.h b/src/proto.h @@ -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); diff --git a/src/winio.c b/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. */