[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: having a scroll bar also in softwrap mode
From: |
Benno Schulenberg |
Subject: |
Re: having a scroll bar also in softwrap mode |
Date: |
Mon, 27 Apr 2020 12:35:27 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
[Please use a fitting subject line when changing the subject, so things
stay findable in the archive, and best start a new thread.]
Op 26-04-2020 om 20:54 schreef Marco Diego Aurélio Mesquita:
> Attached patch makes scrollbar behave correctly in softwrap mode. It
> is a bit of a waste to redraw the scrollbar every time a softwrapped
> line is drawn or modified but it is very simple.
The patch partially works, but breaks line addressing. When I do:
src/nano --ignore --soft --line +57 doc/faq.html
the cursor lands on line 68 (it depends on the size of the terminal).
Make your terminal 35 rows and 100 columns, then run:
src/nano --ignore --soft --line doc/faq.html
And type: ^V ^V x
See that when you type x, the scrollbar jumps one character up, even
though the number of chunks was not changed. Now type <Bsp> to remove
the x. See that scrollbar does not move. Something is not right.
Oh, also: the patch does not fully compile:
winio.c:2752:3: warning: implicit declaration of function ‘draw_scrollbar’;
> ssize_t lineno;
> /* The number of this line. */
> + ssize_t llineno;
> + /* The number of this logical line. */
Poor naming of a variable: I hardly see a difference with lineno.
> @@ -941,6 +941,11 @@ void add_undo(undo_type action, const char *message)
> undostruct *u = nmalloc(sizeof(undostruct));
> linestruct *thisline = openfile->current;
>
> + /* If a softwrapped line is modfied, we may need to renumber
> + * logical lines */
> + if(ISSET(SOFTWRAP) && number_of_chunks_in(openfile->current))
> + renumber_from(thisline);
This is not the right place for this. Even when all undo code is absent,
things should work. Furthermore, you have this code also in update_undo(),
which means that for most operations the renumbering will be done *twice*.
That is not acceptable.
> + /* If drawing a softwrapped line, we may need to renumber logical lines
> */
> + if(ISSET(SOFTWRAP) && number_of_chunks_in(openfile->current))
> + draw_scrollbar();
Comment does not fit the code. :/
What if number_of_chunks() changed from 1 to 0 by the last operation?
Also then the scroll bar needs to be redrawn.
Benno
signature.asc
Description: OpenPGP digital signature