[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: |
Rishabh Dave |
Subject: |
Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G) |
Date: |
Sun, 11 Dec 2016 21:46:28 +0530 |
Hello,
>> 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:
> edittop.
But... this solution isn't considering the case where text won't be
rewrapped; it *blindly* closes, opens and redisplays the help text and
recomputes the edittop (and even rewraps the help text) when
rewrapping won't be needed. And there are 3 such cases:
1. window size changes vertically
2. window size changes to become wider than 76 characters
3. window size changes horizontally but the change is not enough to
make the text rewrap.
A total_refresh() (of previous version) would be enough in above cases
(except for last one, as I think there is no way of knowing that).
Umm... a slight adjustment (at the version of code before last commit)
would make the call to total_refresh() redundant; a simple return in
display_the_help_text() statement would suffice.
However, "roughly staying" must become "staying"; in favour of that.
>> 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,
Yeah, actually. I was thinking wrong. Line numbers changes with
rewrapping, so it was a bad foundation for a solution.
> About your patch:
>
> +bool first_time;
>
> This sounds like an optimization again. Don't bother.
It is not an optimization (at least I did not write it as
optimization). If you remove the block guarded by "if (first_time) {"
and run the code you would see that on changing the window size makes
topmost line jump to center, (even when adjustments were unnecessary).
But I think it won't be relevant now.
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), (continued)
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/02
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Rishabh Dave, 2016/12/02
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/03
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/03
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Rishabh Dave, 2016/12/05
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/05
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Rishabh Dave, 2016/12/09
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Rishabh Dave, 2016/12/10
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/10
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/10
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G),
Rishabh Dave <=
- [Nano-devel] how and when to rewrap the help text, Benno Schulenberg, 2016/12/11
- Re: [Nano-devel] how and when to rewrap the help text, Rishabh Dave, 2016/12/15
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Rishabh Dave, 2016/12/15
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/16
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/18
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Rishabh Dave, 2016/12/18
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/19
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Rishabh Dave, 2016/12/27
- Re: [Nano-devel] [PATCH] enable searching (^W) in a help text (^G), Benno Schulenberg, 2016/12/27