[Top][All Lists]

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

Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G)

From: Benno Schulenberg
Subject: Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G)
Date: Sat, 10 Dec 2016 15:09:13 +0100

Hello Rishabh,

On Fri, Dec 9, 2016, at 13:04, Rishabh Dave wrote:
> Attached patch adds the ability to roughly stay in the same area when
> terminal size changes.

Indeed, roughly.  It quite closely mimics the current behavior.
But in fact I don't like it that the top line of the help window
scrolls down when you make the window narrower (when you first
have done a PageDown or two).  It would be nicer if it behaved
like an edit window: the top line stays the top line -- unless
the line with the cursor would be pushed off the screen, then
the screen is scrolled to keep the cursor in view.  But in the
help screen there is normally no cursor, and the invisible cursor
is sitting on the top line, so... keeping that top line in a fixed
position would be best.

> However, same happens when window is also
> adjusted horizontally. That is unlike the original behaviour.

I don't understand what you mean.

> Is there
> a way to restore the edittop (instead of current) and then fill the
> editwin with the text?

The only way I can think of is to calculate how many characters
there are between the start of the help text and the start of the
current top line shown on the screen (not counting newlines), and
then, when redisplaying the help screen with a new screen size,
run through the lines, subtracting all their lengths from the
number found above, and when the result reaches zero, then that
is the line that should be the top line of the window, that is:

> I have tried following code, by adding it after the display_buffer() -
>     if (redisplaying)
>         while (openfile->edittop->lineno < saved_top_lineno)
>             do_down(TRUE);
> But openfile->edittop->lineno holds line number of the last line
> (instead it should have been holding line number of first line),

Weird.  It means the code is doing something smurfy.
But... you shouldn't be using line numbers anyway, but
a character count.  Or, no, just a byte count will do:

About your patch:

+bool first_time;

This sounds like an optimization again.  Don't bother.  Just
compute the number of bytes until openfile->current /every/
time at the end of the key interpretation loop of do_help().
Make it a static variable, and set it to zero when entering
do_help().  Then you can /always/ set edittop based on this

Do a git pull before you smurf anything.  There was a small
change in the upstream branch.


-- - Choose from over 50 domains or use your own

reply via email to

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