Commit Graph

168 Commits (9f2c80db24d96b46283387c49030edbf744f7828)

Author SHA1 Message Date
Benno Schulenberg 9f2c80db24 moving: when determining where we are on the screen, use placewewant
To make dynamic Home and End work properly when double-width characters
straddle a chunk boundary, use the spot where the cursor is really shown
instead of the "actual x" position of the current character, because the
latter might be on the preceding row.

This fixes https://savannah.gnu.org/bugs/?50737.
2017-04-09 11:36:39 +02:00
Benno Schulenberg 4c987bc3e0 tweaks: adjust a couple of comments 2017-04-07 21:40:33 +02:00
Benno Schulenberg 582a624998 tweaks: frob some parentheses and other things, to be more consistent 2017-03-29 19:30:37 +02:00
Benno Schulenberg c7282e8821 tweaks: reshuffle two declarations for a more consistent order 2017-03-29 10:35:11 +02:00
Benno Schulenberg 1f9a6ab336 tweaks: factor out a bit of common code 2017-03-29 10:30:41 +02:00
David Lawrence Ramsey d01756bb69 moving: determine the correct leftedge when paging up/down too
The change in commit 244a503d for the <Up> and <Down> keys
needs to be done for <PageUp> and <PageDown> too.
2017-03-28 12:32:47 +02:00
Benno Schulenberg 644fedcb61 tweaks: reshuffle some more lines and improve four comments 2017-03-28 11:24:32 +02:00
Benno Schulenberg da3a015f7d tweaks: reshuffle some lines and adjust some comments 2017-03-28 10:38:08 +02:00
Benno Schulenberg bc876ca729 moving: /do/ redraw the prior line when the viewport hasn't changed
The complementary test on current_y should only be done when doing
a scroll-only, because only then the prior line can be offscreen.

This fixes https://savannah.gnu.org/bugs/?50658.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-28 10:31:45 +02:00
Benno Schulenberg 9cf980700c moving: don't try to redraw lines that have gone outside the viewport
When scrolling backward, it is not just the bottom line of the screen
that doesn't need to be redrawn: also the line /before/ the top line
doesn't need a redraw.  Mutatis mutandis for scrolling forward.

This fixes https://savannah.gnu.org/bugs/?50657.
2017-03-27 19:44:21 +02:00
Benno Schulenberg 244a503ddc moving: the current chunk cannot be beyond the last chunk of a line
When determining the leftedge of the current chunk, it is not simply
the leftedge that corresponds to the placewewant, but the leftedge that
corresponds to the minimum of the placewewant and the full line span.

This fixes https://savannah.gnu.org/bugs/?50653.
2017-03-27 17:45:39 +02:00
Benno Schulenberg c277cd6e5b tweaks: reshuffle some statements, to avoid double assignments 2017-03-27 11:38:52 +02:00
David Lawrence Ramsey 384332d08c display: make PageUp/PageDown use the correct beginning of the viewport
When typing PageUp or PageDOwn in non-smooth-scrolling mode, the cursor
should be placed at the start of the top line of the edit window.  This
means that, when the line at edittop is partially scrolled offscreen,
the cursor should be placed at openfile->firstcolumn, not at zero.

This fixes https://savannah.gnu.org/bugs/?50645.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-27 11:19:44 +02:00
David Lawrence Ramsey 93152d3258 softwrap: account for firstcolumn when scrolling up a line
In do_up() when scroll_only is TRUE, if we're at the top of the screen
in softwrap mode, it's not enough to check that edittop is on fileage.
We also need to check that firstcolumn is zero.

In do_up() when scroll_only is FALSE, if we're at the top of the screen
in softwrap mode, current_y should be zero.  This is equivalent to how,
in do_down() when scroll_only is FALSE, current_y is (editwinrows - 1)
at the bottom of the screen in softwrap mode.  Since edittop can now
be partially scrolled off the screen even when it takes up the entire
screen, checking for edittop's being equal to openfile->current->next
there no longer applies.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey 80b3a3011b weeding: remove ensure_line_is_visible()
Since all lines can be partially scrolled off the screen now
(except for the top line of the edit window, which is forthcoming),
ensure_line_is_visible() is no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey d0c3084eb5 softwrap: improve PageUp and PageDown's behavior with softwrapped chunks
Use go_back_chunks() and go_forward_chunks() to move a screenful of
lines or chunks up or down, instead of using special computations in
the softwrap case.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey eb647dfb44 softwrap: improve Up and Down's behavior with softwrapped chunks
Use go_back_chunks() and go_forward_chunks() in do_up() and do_down()
(instead of using a special and complicated computation in do_down())
so that they now properly move vertically to the previous/next chunk
in softwrap mode.  This also means that do_left() and do_right() will
now properly move vertically at actual line boundaries.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 56402e7589 softwrap: improve Left and Right's behavior with softwrapped chunks
Use the new "unclever" functionality of Home and End to make do_left()
and do_right() move properly to the end of the previous chunk or to the
start of the next chunk in softwrap mode when crossing a line boundary.
(Furthermore, doing Up plus End, or Down plus Home, does all needed
screen updates, which simplifies the code.)

The do_left() and do_right() functions don't yet properly move vertically
at line boundaries, but that will be fixed once do_up() and do_down() are
updated for softwrap mode, which is forthcoming.

This fixes https://savannah.gnu.org/bugs/?49384.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey a5e106d764 tweaks: add a parameter to do_home() and do_end()
Add the parameter be_clever to both functions.  When be_clever is FALSE,
smart home and dynamic home are disabled in do_home(), and dynamic end is
disabled in do_end(), so that these functions only move to the beginning
or end of the current line or chunk.

This simple home and end functionality is needed to improve do_left()
and do_right()'s horizontal behavior with softwrapped chunks, which is
forthcoming.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey e478682c55 softwrap: improve End's behavior with softwrapped chunks
Make do_end() more useful in softwrap mode: let it move to the end of the
current chunk instead of the end of the line; only when already at the end
of a chunk, let it move to the end of the line.  This is "dynamic end".
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey bd2d0863d6 softwrap: improve Home's behavior with softwrapped lines
Make do_home() more useful in softwrap mode: let it move to the beginning
of the current chunk instead of to the beginning of the whole line; only
when already at the beginning of a chunk, let it move to the beginning of
the line.  This is called "dynamic home'.

The above rules are ignored when --smarthome is in effect and the cursor
is somewhere in the leading whitespace of a line -- then the cursor is
moved to the first non-whitespace character of the line.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey d8189703b1 tweaks: prepare for improvements to do_home() and do_end()
These improvements will eventually make do_home() and do_end() take
parameters.  Since the global function lists can hold only functions
without parameters, preemptively add do_home_void() and do_end_void(),
and make the global function lists use them.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey eb369c0e00 tweaks: rename need_horizontal_scroll() to line_needs_update()
The old name made it sound as if it didn't apply in softwrap mode.  But
it does: in softwrap mode a line needs updating  when the mark is on.
2017-03-22 10:44:04 +01:00
Benno Schulenberg 83a841cd06 tweaks: chuck some debugging stuff and some useless asserts 2017-03-01 13:56:08 +01:00
David Lawrence Ramsey f2ac20114e tweaks: adjust and correct some comments 2017-02-05 12:29:43 +01:00
Benno Schulenberg 0208ae7149 tweaks: rename a variable -- lines refers to buffer, rows to screen 2017-01-12 17:33:46 +01:00
Benno Schulenberg 58c3dd6cd0 softwrap: when typing M-/, ensure the last line is fully visible 2017-01-09 15:21:15 +01:00
David Lawrence Ramsey b1c20629f5 weeding: remove unnecessary settings of openfile->current_y
Many of the adjustments of the value of openfile->current_y appear to be
a holdover from the days when certain functions had to account for what
is now called STATIONARY scrolling mode, which depends on the value of
current_y.  Remove these adjustement where they are superfluous.

do_para_begin(), do_para_end(), and do_bracket_match() update the screen
through edit_redraw(), which uses either CENTERING or FLOWING scrolling
mode, so their setting of current_y is redundant and useless, as it will
be ignored and then overridden by the next call to reset_cursor().

findnextstr() is called by go_looking() [which calls edit_redraw(), see
above], and by do_replace_loop() and do_int_spell_fix(), which both call
edit_refresh(), which in this case only uses CENTERING scrolling mode
since focusing is TRUE.

(Additionally, the adjustments of current_y in findnextstr() and
do_bracket_match() use incorrect values when in softwrap mode.)

find_paragraph() doesn't need to save or restore current_y, because it
doesn't do any screen updates.  do_justify() calls edit_refresh() with
focusing set to TRUE, so it uses the CENTERING scrolling mode.

do_alt_speller() and do_formatter() do not need to save and restore
current_y, because they don't modify it in any way.

This addresses https://savannah.gnu.org/patch/?9197.
2017-01-02 12:40:21 +01:00
Benno Schulenberg a4044a7e5d tweaks: remove some cluttering conditional compilation 2016-12-09 13:32:15 +01:00
David Lawrence Ramsey 6263416355 moving: always account for the margin when in line numbering mode
Like do_down() does already, do_pageup() and do_right() should use
editwincols instead of COLS.

This addresses https://savannah.gnu.org/bugs/?49796.
2016-12-09 12:23:23 +01:00
Benno Schulenberg 4c476bc872 scrolling: use a comparison that will work also in softwrap mode
This fixes https://savannah.gnu.org/bugs/?49467.
2016-10-28 11:38:58 +02:00
Benno Schulenberg 5416b9c09d tweaks: remove a band-aid condition that is no longer needed
Also, don't bother conditionalizing two booleans for the tiny version.
2016-10-27 20:00:01 +02:00
Benno Schulenberg 01bbf7e82f tweaks: rename a function to better describe what it does
It does not update anything -- it just picks a new point from
where to start displaying the buffer.  All actual updating of
the screen is done by edit_refresh() and edit_redraw() and such.
2016-10-23 17:26:19 +02:00
Faissal Bensefia de95ca68f7 new feature: the ability to show line numbers before the text
It can be activated with --linenumbers on the command line or with
'set linenumbers' in a nanorc file, and it can be toggled with M-#.

Signed-off-by: Faissal Bensefia <faissaloo@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-10-20 16:47:52 +02:00
Benno Schulenberg 43f35fc7a9 softwrap: ensure the current line is fully visible when moving in it
This fixes https://savannah.gnu.org/bugs/?49099,
and fixes the unreported corresponding bugs for
<End> and <Del> and typing extra characters.
2016-10-18 15:07:47 +02:00
Benno Schulenberg d66ea08473 moving: adjust the Y position to correspond with the changed X position
So the softwrap code in do_down() can compute the correct amount to scroll.

This fixes https://savannah.gnu.org/bugs/?49374.
2016-10-18 11:46:15 +02:00
Benno Schulenberg 8476bf86a1 tweaks: fix compilation when configured with --enable-tiny 2016-10-15 18:05:01 +02:00
Benno Schulenberg 7013039c3a tweaks: rename a variable, for consistency 2016-10-12 21:10:04 +02:00
Benno Schulenberg 925ad6393a tweaks: remove a superfluous setting, and add a comment 2016-10-12 21:07:16 +02:00
Benno Schulenberg 8041627cc3 tweaks: remove a bit of duplication 2016-09-20 12:54:16 +02:00
Benno Schulenberg 97f6ae5267 softwrap: scroll 'enough' whenever it surpasses 'amount'
This fixes https://savannah.gnu.org/bugs/?49086.
2016-09-14 12:40:58 +02:00
Benno Schulenberg 77a1a5c3e4 tweaks: reshuffle some ifdefs, for less fragmentation 2016-09-14 11:00:18 +02:00
Benno Schulenberg 08cd197bf1 general: include word-jumping and block-jumping into the tiny version
And also case-sensitive searches, backward searches, and searching again.
2016-09-13 09:27:04 +02:00
Benno Schulenberg 514cd9a099 update the license text to the preferred version
Mentioning "GNU nano" instead of "This program" and referring to the
website instead of to a postal address.
2016-08-29 21:27:16 +02:00
Benno Schulenberg 406e5242a3 update the copyright notices 2016-08-29 21:27:05 +02:00
Benno Schulenberg bd1c5d7c63 moving: make PgUp and PgDown functional also in very flat terminals
Even when the edit window consists of just one or two lines, the PageUp
and PageDown functions (^Y and ^V) should continue to move the window.

This fixes https://savannah.gnu.org/bugs/?48805.
2016-08-21 15:52:24 +02:00
Benno Schulenberg 00b293bf70 tweaks: adjust some braces and indentations 2016-08-21 15:39:00 +02:00
Benno Schulenberg 03b168d0e3 tweaks: restore earlier conditions to prevent superfluous redrawings
When doing an <Up> on the top line, or a <Down> on the bottom line of
the edit window, the affected lines have already been redrawn by the
scrolling code, so there is no need to do that again.

(However, that does not prevent the second line (or the last-but-one
line) from being redrawn unnecessarily when using the M-- (or M-+)
command elsewhere on the screen and /that/ line is horizontally
scrolled.  But we'll let that pass for now.)
2016-08-01 19:41:13 +02:00
Benno Schulenberg 2f6647687a tweaks: rename a function, and adjust some comments 2016-08-01 19:41:13 +02:00
Benno Schulenberg c9e9964207 screen: don't look at placewewant but at where we actually were and are
For horizontal scrolling, it is not the /desired/ column position that
is relevant for determining whether a line needs to be redrawn after a
cursor movement, but the /actual/ column positions before and after.

This fixes https://savannah.gnu.org/bugs/?48627,
and fixes https://savannah.gnu.org/bugs/?48629.
2016-08-01 19:41:13 +02:00