nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: [RFC] a scroll bar on the right that shows position and portion


From: Marco Diego Aurélio Mesquita
Subject: Fwd: [RFC] a scroll bar on the right that shows position and portion
Date: Thu, 23 Apr 2020 13:59:44 -0300

---------- Forwarded message ---------
From: Marco Diego Aurélio Mesquita <address@hidden>
Date: Thu, Apr 23, 2020 at 1:59 PM
Subject: Re: [RFC] a scroll bar on the right that shows position and portion
To: Benno Schulenberg <address@hidden>


On Thu, Apr 23, 2020 at 5:43 AM Benno Schulenberg <address@hidden> wrote:
>
>
> Op 23-04-2020 om 05:10 schreef Marco Diego Aurélio Mesquita:
> > Having vertical scrollbar in gnu nano is cool
>
> Yes.  But it should be behind an option.  It is annoying to have that
> moving thing on the right when you are not used to it, so some people
> will want to do without it.
>

Done. It can be enabled with the "scrollbar" option on nanorc.

> Also, the patch doesn't properly display things when lines are longer
> than the screen width.  Run for example src/nano +191 doc/faq.html --
> all the continuation characters (>) are overwritten.
>

Done.

>
> > +     int screen_lines = LINES - 2 - (ISSET(NO_HELP) ? 0 : 2);
>
> It should not be necessary to compute this.  Use 'editwinrows'.
>

Done.

> > +     int scroll_len = (screen_lines*screen_lines)/(last_lineno+1);
>
> This variable is used only once; there is no need for it.
>

Done.

> > +                     mvwaddch(edit, current_lineno, COLS - 1, '*');
>
> Why the star?  Have a look at the scrollbar of fte.  Showing a
> background color for the non-active part is much nicer in my eyes.
>

Because it is just a proof of concept. I improved on the current version.

> >               update_line(openfile->current, openfile->current_x);
> > +             draw_scrollbars();
>
> Is this call needed?  If yes, which case does it cover?
>

It is needed to draw the scrollbar correctly when using shift-arrows
to select/unselect lines that overlap the scrollbar position. This is
probably wasteful.

> And of course the name of the function should be singular: it draws
> just one bar.
>

Done.

There is a comment about drawing the scrollbar in a wasteful way.
Basically, when a line is updated and it overlaps the scrollbar
marker, the marker char must be redrawn, otherwise it may be erased.
For that, I think we should use a function:

void draw_scrollbar_char(int row)

such that, given a row, it condionally draws the scrollbar char at the
end of the row. This is easy to implement and can be mostly copied
from draw_scrollbar. But this creates another problem: some variables
are wastefully recalculated. I see 3 options:

1 - Wastefully redraw the scrollbar. This is what is done now and
given current computational power, it is not too expensive.

2 - Use draw_scrollbar_char and wastefully recalculate some vars: This
is a bit less simple but improves performance a bit.

3 - Recalculate vars only when needed. This will need carefully
determining where these vars should be recalculated (number of lines
changed, screen width changed, screen scrolled...) and gives us the
best possible performance.

So, what approach should I take?

Attachment: 0001-Implement-vertical-scrollbar.patch
Description: Source code patch


reply via email to

[Prev in Thread] Current Thread [Next in Thread]