Commit Graph

1390 Commits (ba25d0df1d0bec5f6803f8b5082e78e73299cf7a)

Author SHA1 Message Date
Benno Schulenberg b99ec28a60 tweaks: recognize escape sequences of modified Ins/Del more precisely
The third character after the escape must be a semicolon.
2018-07-16 18:45:41 +02:00
Benno Schulenberg b2acffe5be input: stop <Alt+Insert> from entering "3~" into the buffer 2018-07-16 18:45:21 +02:00
Benno Schulenberg 2fef7f647d input: stop a modified Delete key from entering stuff into the buffer
When using option -K on an xterm-like terminal, pressing <Shift+Del>,
<Alt+Del>, or <Ctrl+Del> would enter "2~", "3~", or "5~", respectively,
into the buffer.  Now it will just report an "Unknown sequence".
2018-07-15 09:22:55 +02:00
Benno Schulenberg 89c0e7493f tweaks: don't call va_start() without calling va_end() [coverity scan] 2018-07-14 21:15:23 +02:00
Benno Schulenberg ecc9211afc input: ignore any <Escape>s before a valid command keystroke
Just like an <Esc> before a Ctrl+letter keystroke is ignored, an <Esc>
before an Alt+letter keystroke should be ignored too -- it should not
be interpreted as if the user had typed <Esc> <Esc> letter.

This fixes https://savannah.gnu.org/bugs/?54301.
2018-07-13 09:27:38 +02:00
Benno Schulenberg ab0897072a input: consume the whole escape sequence for modified PgUp and PgDn keys
Even when we don't act on most of these combinations, at least eat up
the whole sequence so the unknown keystroke doesn't enter things like
"3~" into the buffer.

This fixes https://savannah.gnu.org/bugs/?54291.
2018-07-13 09:25:01 +02:00
David Lawrence Ramsey fce54a724d tweaks: fix some grammar plus a typo in the comments 2018-05-27 20:19:46 +02:00
Benno Schulenberg 455899fe27 credits: sort the names roughly according to amount of influence
And spell-fix a name.
2018-05-16 12:05:40 +02:00
Benno Schulenberg 87283711ee tweaks: improve a couple of comments 2018-05-10 18:10:23 +02:00
Benno Schulenberg 0da554e6d7 startup: suggest using ^D to finish reading from standard input
Also, add a period after the "Read nn lines" message, and
don't let the next shell prompt overwrite this message.

This addresses https://savannah.gnu.org/bugs/?53779.
2018-05-01 11:15:19 +02:00
Benno Schulenberg d4304ca88c search: use a better value to mean "nothing was typed"
When the keyboard buffer is empty, return a value that is not equivalent
to <Ctrl+Space>, so that typing a bunch of these while searching is going
on will not result in some of them getting executed afterward.
2018-04-13 20:13:05 +02:00
Benno Schulenberg bf1a080923 build: exclude more things when configured with --disable-multibuffer
This will make the tiny version slightly smaller.
2018-03-23 11:09:37 +01:00
Benno Schulenberg 1ebb1da382 tweaks: elide a parameter that is always 1
And adjust the comments accordingly.
2018-03-10 12:43:33 +01:00
Benno Schulenberg 5eccaa7633 tweaks: refactor the implanting of a key expansion 2018-02-27 13:34:32 +01:00
Benno Schulenberg ffebd31cbb tweaks: shorten the name of two record elements
Exclude the confusing, pleonastic 'sc' abbreviation from their names.
2018-02-24 19:31:11 +01:00
Benno Schulenberg b027263a37 small addition: allow customizing the color of an error message
The new option 'set errorcolor' allows the user to specify the color
combination for the status bar when an error message is displayed.
2018-02-23 12:35:17 +01:00
Benno Schulenberg a083d7f1e1 tweaks: rename a variable to be more distinct and greppable 2018-02-04 18:25:10 +01:00
Benno Schulenberg 58ed3a8152 display: wipe the status bar when doing a total refresh
This fixes https://savannah.gnu.org/bugs/?52997.
2018-01-28 21:08:28 +01:00
Benno Schulenberg e11021a7a5 input: recognize the deviant keycode for <Ctrl+End> in urxvt
This fixes https://savannah.gnu.org/bugs/?52972.
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-01-28 16:15:21 +01:00
Benno Schulenberg 83c264939b tweaks: move a bunch of comments to the lines that they refer to 2018-01-28 13:41:46 +01:00
Benno Schulenberg b18e76d4d8 tweaks: drop two unneeded initializations, and trim a comment 2018-01-27 20:26:15 +01:00
Benno Schulenberg f5c87a7fee tweaks: swap the row and col parameters to a more consistent order 2018-01-27 20:00:14 +01:00
Benno Schulenberg 18bf2af9c1 tweaks: rename a function, to be more distinct
So one doesn't find it when grepping for get_input().
2018-01-27 11:29:11 +01:00
Benno Schulenberg f72fecee9b copyright: update the years for the FSF
And one for me, for the much changed keyboard stuff.
2018-01-24 10:14:43 +01:00
Benno Schulenberg fa7e9b11df input: recognize more escape sequences for <Shift+Home> and <Shift+End>
This fixes the second part of https://savannah.gnu.org/bugs/?52960.
2018-01-23 19:44:18 +01:00
Benno Schulenberg 838b175d4f input: recognize escape sequences for <Shift+PageUp> and <Shift+PageDown>
This fixes the first part of https://savannah.gnu.org/bugs/?52960.
2018-01-23 19:32:13 +01:00
Benno Schulenberg 6795d079b1 tweaks: mark the two blocks that have a deviant indentation
Also, reshuffle a case, to put the short one first and lose a line.
2018-01-23 18:10:22 +01:00
Benno Schulenberg e739448cd0 input: consume only the actual length of an escape sequence
Instead of assuming that the entire contents of the keybuffer are an
escape sequence (even if this is far longer than any escape sequence
can be), remove from the keybuffer only those integers that actually
constituted a sequence, valid or invalid.

This fixes https://savannah.gnu.org/bugs/?48659.
2018-01-23 17:31:48 +01:00
Benno Schulenberg 8e328e43c2 input: make <Shift+Tab> do an unindent also on a Manjaro console
This fixes https://savannah.gnu.org/bugs/?52943.
2018-01-23 16:52:51 +01:00
Benno Schulenberg 4ad0490ce4 tweaks: rename a variable, for more contrast 2018-01-20 18:22:24 +01:00
Benno Schulenberg 96b47f2877 tweaks: transform a parameter, from a pointer to the value itself 2018-01-15 20:09:03 +01:00
Benno Schulenberg 7da391beb7 tweaks: drop a superfluous parameter, as it is always 1 2018-01-15 19:54:12 +01:00
Benno Schulenberg 90cf4838d2 tweaks: don't bother to reallocate when the keybuffer size decreases
It will be reallocated soon enough when the size increases again.
2018-01-15 19:46:16 +01:00
Benno Schulenberg caeed6821c tweaks: reshuffle two condition series, to look better 2018-01-11 13:02:55 +01:00
Benno Schulenberg eb1bf8f927 tweaks: rename a variable, and further condense some comments 2018-01-11 12:52:14 +01:00
Benno Schulenberg 2c8b99d5e9 tweaks: condense and rewrap some comments, and reindent two lines
Also drop an old debugging fragment.
2018-01-11 10:51:18 +01:00
Benno Schulenberg 091dd71f08 tweaks: remove a superfluous case -- there can never be four digits 2018-01-11 10:31:23 +01:00
Benno Schulenberg 837475519b input: fully reset state when a three-digit character code is cut short
There shouldn't be two separate variables (but with the same name) that
count the number of digits seen.  Fuse them into a single static var.

This fixes https://savannah.gnu.org/bugs/?52863.
2018-01-11 10:17:51 +01:00
Benno Schulenberg 31540e3e7e tweaks: remove a superfluous check, as we insert always one code 2018-01-10 21:32:32 +01:00
Benno Schulenberg ae3b8579fa tweaks: condense a condition and a comment, and reshuffle a line 2018-01-10 21:25:19 +01:00
Benno Schulenberg e1199cd94d tweaks: elide a tiny intermediate buffer, and rename two variables
Use the same method as in parse_verbatim_kbinput() for Unicode input.
2018-01-10 20:33:12 +01:00
Benno Schulenberg 45d2458b47 tweaks: don't bother freeing the key buffer, just reallocate it 2018-01-10 19:25:23 +01:00
Benno Schulenberg 4c505e5127 tweaks: rename a function, for aptness, and drop a superfluous check 2018-01-10 17:40:07 +01:00
Benno Schulenberg 0bb6c0234f tweaks: condense the conditional compilation of shortcut reassignments
These three functions are needed only when both linter and speller
are available.
2018-01-09 13:31:58 +01:00
Benno Schulenberg 17429d7f38 tweaks: fix some whitespace errors, and convert alignment tabs to spaces 2017-12-29 21:35:14 +01:00
Benno Schulenberg 87206c0607 tweaks: convert the indentation to use only tabs
Each leading tab is converted to two tabs, and any leading four spaces
is converted to one tab.  The intended tab size (for keeping most lines
within 80 columns) is now four.
2017-12-29 20:06:50 +01:00
Benno Schulenberg b574f73e60 tweaks: add a separate function that actually wipes the status bar 2017-12-29 17:40:41 +01:00
Benno Schulenberg 12073001c2 tweaks: condense, reword, and rewrap a bunch of comments 2017-12-26 22:14:25 +01:00
David Lawrence Ramsey 62ebd93579 tweaks: use printf's z modifier for (s)size_t, instead of casting 2017-12-26 14:11:18 +01:00
Benno Schulenberg 7ad5afb935 tweaks: remove some unneeded parentheses, and shorten two function calls 2017-12-17 20:32:17 +01:00
Benno Schulenberg e1b0f2b275 display: ensure that cursor is visible when compiled with --with-slang
This fixes https://savannah.gnu.org/bugs/?52651.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-12-17 16:34:02 +01:00
Benno Schulenberg 0e0fb452a3 input: optimize a bit for non-shortcut keys, as they are most frequent 2017-12-17 12:49:04 +01:00
David Lawrence Ramsey f66432e999 input: support backtab when Slang and/or --rebindkeypad is used
The escape sequence "Esc [ Z" is a backtab on most supported terminals,
so make sure convert_sequence() treats it as such.
2017-12-17 12:11:35 +01:00
Benno Schulenberg 08e9d30fa2 tweaks: condense some debugging code, and rewrap a line 2017-12-16 21:50:10 +01:00
Benno Schulenberg 031305c205 tweaks: strip some debugging stuff, and condense a bit of code 2017-12-16 19:56:15 +01:00
Benno Schulenberg 09958ebdff input: allow using <Tab> and <Shift+Tab> to (un)indent selected region
When the mark is on, instead of letting a <Tab> simply insert a Tab
character at the cursor position, let it indent the marked region.

Original-idea-by: Chris Allegretta <chrisa@asty.org>
2017-12-12 20:37:41 +01:00
Benno Schulenberg a95c6c5fe8 tweaks: condense or rewrap a bunch of repetitious comments 2017-12-11 20:02:43 +01:00
Benno Schulenberg c24e95e3d6 tweaks: elide the 'mark_set' boolean -- the 'mark' pointer is enough
The pointer not being NULL is enough indication that the mark is set.

Also, rename the pointer from 'mark_begin' to simply 'mark', since
the former is kind of pleonastic.
2017-11-21 21:14:33 +01:00
Benno Schulenberg 2b438e6ef4 input: make the macro key discoverable by giving feedback when undefined 2017-11-20 19:57:33 +01:00
Benno Schulenberg 5239e7c52b copyright: update some years, and standardize on the dashed format 2017-11-12 10:46:20 +01:00
Benno Schulenberg 0c2b54a276 tweaks: rename a function plus two parameters, to be more fitting 2017-11-11 20:58:56 +01:00
David Lawrence Ramsey 477b246771 tweaks: use printf's z modifier for most of the size_t/ssize_t types
Also, properly refer to numreplaced as signed, since it's ssize_t
(even though it's only shown when positive).
2017-11-07 17:55:21 +01:00
Benno Schulenberg d054044d30 tweaks: transform the token DISABLE_EXTRA to ENABLE_EXTRA 2017-11-01 20:33:14 +01:00
Benno Schulenberg d5ac1ed395 tweaks: transform the token DISABLE_COLOR to ENABLE_COLOR 2017-11-01 19:45:50 +01:00
Benno Schulenberg c4d2a92d4c tweaks: reshuffle some code in order to elide a variable
Initialize 'breaking_col' to what it needs to be when the current chunk
consists of only a tab -- a tab that spreads across both start and end
of the chunk -- so that the last 'if' can move into the preceding one,
which allows the elision of 'char_len'.
2017-10-30 21:02:23 +01:00
David Lawrence Ramsey d344c3d042 display: don't cut off zero-width characters at the end of a chunk
This fixes https://savannah.gnu.org/bugs/?52258.
Reported-by: Peter Passchier <peter@passchier.net>
2017-10-25 19:07:38 +02:00
Marco Diego Aurélio Mesquita 501d05c5d1 new feature: the ability to record and play back a series of keystrokes
Allow the user to record and run a single macro.  The default binding
for starting and stopping the recording is M-: (Alt + colon) and for
running the macro M-; (Alt + semicolon).

This fulfills https://savannah.gnu.org/bugs/?50314.
Requested-by: Peter Passchier <peter@passchier.net>

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-10-15 20:40:40 +02:00
Benno Schulenberg ca8317e820 tweaks: reduce a bit of code duplication
This also removes a call of ungetch(), as it does not seem to be
needed any more: nano does not lose a character when waking from
suspension.
2017-10-04 21:51:47 +02:00
Benno Schulenberg 1bd17c44b0 display: keep the cursor switched on when resizing the screen
This fixes https://savannah.gnu.org/bugs/?52149.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-10-04 21:38:46 +02:00
Benno Schulenberg c8a2f36e87 input: recognize Option+Arrow keys on iTerm2 in "xterm mode"
Inspired-by: Mike Frysinger <vapier@gentoo.org>

This kind of addresses https://savannah.gnu.org/bugs/?51685.
2017-09-26 21:44:01 +02:00
Benno Schulenberg f2f7498f12 tweaks: rename two variables, for contrast, and frob some comments 2017-09-26 20:54:04 +02:00
Benno Schulenberg 762f997244 tweaks: elide two variables by using a pointer instead of an index 2017-09-26 20:39:58 +02:00
David Lawrence Ramsey 504a97256b softwrap: break before multi-column Unicode blanks when they overshoot
In atblanks mode, if a softwrapped chunk ends with a double-width space
character (say, Unicode 003000, Ideographic Space), and that would put
half of the character past the edge of the screen, break before it.

This fixes https://savannah.gnu.org/bugs/?51671.
2017-09-26 19:56:48 +02:00
Benno Schulenberg 7c3c3cbb3b tweaks: discard some obsolete debugging stuff 2017-09-22 21:59:51 +02:00
Benno Schulenberg c74d2632bb tweaks: make the switching on and off of the cursor a bit more compact 2017-09-22 21:31:01 +02:00
Benno Schulenberg ae34825f58 display: rework the switching on and off of the cursor
The basic idea is that the cursor is always off, except when it needs
to be on: when waiting for text input, and in a few other cases: when
something was searched and found in the help viewer, and in the file
browser when option -g is in effect.

This fixes https://savannah.gnu.org/bugs/?51923.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-09-20 21:35:25 +02:00
Benno Schulenberg 153dea1732 tweaks: discard another set of useless asserts 2017-09-13 19:34:45 +02:00
Benno Schulenberg bb8d65e89c tweaks: reshuffle some code, and rename a variable 2017-09-13 19:34:28 +02:00
Benno Schulenberg f9bf320fd5 titlebar: don't show nano's name and version when in the file browser 2017-09-13 19:34:14 +02:00
Benno Schulenberg 9738c7997b titlebar: drop the prefix "File: " from before the filename 2017-09-13 19:30:07 +02:00
Benno Schulenberg cbf4f77d6b titlebar: don't reshow version when dropping back to a single buffer
When multiple files were open and [x/n] was being shown in the title
bar, don't show nano's name and version number when just one buffer
remains open, but show [1/1] instead.  It is less surprising.
2017-09-13 19:29:56 +02:00
Marco Diego Aurélio Mesquita 3fc89e0853 new feature: show current and total number of open buffers in title bar
When multiple buffers are open, replace nano's name and version number
with an indication how many buffers are open preceded by the sequence
number of the current buffer.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-09-13 19:29:38 +02:00
Benno Schulenberg ae25e15d61 startup: don't produce more than three consecutive beeps
This fixes https://savannah.gnu.org/bugs/?51918.
2017-09-02 15:31:02 +02:00
Benno Schulenberg 21ffa883f7 tweaks: use mnemonic constants instead of TRUE and FALSE
And use these constants in another context too.
2017-08-31 22:14:06 +02:00
David Lawrence Ramsey 59451da3ac softwrap: correctly move vertically through overwide tabs
Don't skip rows that contain something when moving up, and do put
the cursor in the desired column whenever possible when moving down.

This fixes http://savannah.gnu.org/bugs/?51827
and fixes http://savannah.gnu.org/bugs/?51828.
2017-08-26 10:14:01 +02:00
Benno Schulenberg 243380c4a2 mouse: one click of the wheel should move three lines, not three pages
This fixes https://savannah.gnu.org/bugs/?51802.
2017-08-20 20:45:56 +02:00
David Lawrence Ramsey 5fcda555ea display: constrain line numbers on softwrapped lines with sprawling tabs
Check the column number, not the character index, when suppressing the
line number on chunks other than the first, since the index can be zero
when in fact we're on a later chunk.

This fixes https://savannah.gnu.org/bugs/index.php?51790.
2017-08-19 20:50:01 +02:00
Benno Schulenberg 86e71fa09d tweaks: specify more directly in what manner to move the viewport 2017-08-18 21:46:55 +02:00
David Lawrence Ramsey e09dbf18b1 display: do show the visible character for a tab when it starts a row
Regardless of whether the row start is at a multiple of the tab size.

This completes the fix for https://savannah.gnu.org/bugs/?51669.
2017-08-17 20:09:50 +02:00
David Lawrence Ramsey f08d169aa1 softwrap: make sure char_len is set when a tab is wider than a chunk
This fixes https://savannah.gnu.org/bugs/?51770,
and fixes https://savannah.gnu.org/bugs/?51768.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-17 19:39:51 +02:00
Benno Schulenberg cf14ee2ef3 moving: the current chunk is always 0 when not in softwrap mode
This is a partial fix for https://savannah.gnu.org/bugs/?51770.
Analysis-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-17 19:33:43 +02:00
David Lawrence Ramsey 566a2daf12 tweaks: remove unneeded parentheses and blank line and braces 2017-08-14 21:46:25 +02:00
Benno Schulenberg 9f6c3a6269 display: don't doubly show tabs that cross a chunk boundary
This fixes https://savannah.gnu.org/bugs/?51669.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-14 21:31:55 +02:00
Benno Schulenberg 4562401505 bindings: hard-bind Alt+Up and Alt+Down to findprevious and findnext
So that these functions have bindings by default, and easy bindings.
Add them to the help viewer too, so that searching backward becomes
possible there.
2017-08-14 10:34:15 +02:00
Urja Rannikko 1cc030f7c1 bindings: hard-bind Alt+Left and Alt+Right to buffer switching
This also fixes https://savannah.gnu.org/bugs/?51735.
Reported-by: Urja Rannikko <urjaman@gmail.com>

Signed-off-by: Urja Rannikko <urjaman@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-08-14 10:06:29 +02:00
David Lawrence Ramsey 65d1655134 softwrap: don't push a straddling tab to the next chunk
Tabs are of variable length depending on position, so allow them
to be displayed partially on one chunk and partially on another.

This fixes http://savannah.gnu.org/bugs/?51621.
2017-08-13 21:06:23 +02:00
Benno Schulenberg ee3254b614 tweaks: simply set the proper scrolling mode, instead of imitating it 2017-08-10 12:28:39 +02:00
Benno Schulenberg 938aa63dfa tweaks: drop some debugging stuff 2017-08-08 22:09:22 +02:00
Benno Schulenberg 06ffcfaf40 display: catch all cases where the cursor can be pushed offscreen
Discarding (in commit 6f9bb53b) the cap on the number of chunks to
move backwards had as an unforeseen side effect that the screen can
fail to scroll when the cursor is somehow pushed offscreen.

Fix this by setting the target row (for smooth scrolling) always to
the bottom row of the edit window when nano notices that the cursor
has gone offscreen.

This fixes https://savannah.gnu.org/bugs/?51676.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-08 22:06:55 +02:00
Benno Schulenberg 11072ed587 tweaks: sort the includes, so it's a little easier to see what is there 2017-08-06 19:40:30 +02:00
David Lawrence Ramsey 1c1cbae6bc small addition: allow customizing the color of selected text
The new option 'set selectedcolor' applies to marked text, to the
currently selected file in the file browser, and to the highlighted
match during interactive search-and-replace.
2017-08-06 09:30:32 +02:00
Benno Schulenberg 80686bb525 tweaks: remove includes that appear to be superfluous
Without them, nano still compiles for me, with everything enabled,
even when using --enable-debug, --enable-utf8, and --with-slang.
2017-08-06 09:08:30 +02:00
David Lawrence Ramsey ac2c81fad1 tweaks: correct a comment typo and an indentation error 2017-07-31 21:42:39 +02:00
David Lawrence Ramsey 381a386b01 weeding: drop the forreal parameter from place_the_cursor()
Commit 28beb3f added the 'forreal' parameter to prevent spotlight() from
placing the cursor wrongly due to an invalid placewewant.  However, since
the variable-width softwrap overhaul (specifically, since commit 8490f4a),
place_the_cursor() no longer checks placewewant, so the parameter is no
longer needed.

Furthermore, dropping 'forreal' and thus always setting current_y won't
affect the operation of spotlight(), since the only functions that use
spotlight() (do_replace_loop() and do_int_spell_fix()) both call
edit_refresh() beforehand, which means that current_y will already
have been set to the value it will be set to again.
2017-07-24 21:07:42 +02:00
David Lawrence Ramsey 6f9bb53b2d tweaks: set the target row for smooth scrolling more directly
The function place_the_cursor() assumes that the viewport is up to date,
i.e., that current is in range of edittop.  When uncutting or inserting,
however, place_the_cursor() gets called on the out-of-date viewport
first, and then a screen refresh is scheduled (which would put the
viewport up to date).  This is backwards: the refresh should come before
the cursor placement, and the only reason it works anyway is because the
cap on the number of chunks to move backward papers over the problem by
keeping current_y in screen range regardless.

Fix this properly by simply setting current_y to the bottom row of the
screen instead of calling place_the_cursor().  This value of current_y
is only ever used when in smooth scrolling mode and the insertion (or
paste) pushed the cursor offscreen.  In other situations, this value is
overridden when place_the_cursor() gets called after a screen refresh.

After that fix, the cap on the number of chunks to move backward is no
longer needed.
2017-07-23 12:16:59 +02:00
David Lawrence Ramsey ee8681d7cc tweaks: only compensate for a partially-offscreen line in softwrap mode
A line can only be partially offscreen when doing softwrapping.
2017-07-20 12:27:40 +02:00
Benno Schulenberg a1fba43452 pasting: restore the cap on the number of chunks to move backward
This fixes https://savannah.gnu.org/bugs/?51514.
2017-07-20 09:41:27 +02:00
Benno Schulenberg 0e4cbd4bfd softwrap: when possible, go back a whole bunch of chunks at a time
This improves https://savannah.gnu.org/bugs/?51479 for the +-1 case.
2017-07-19 09:47:56 +02:00
David Lawrence Ramsey ce68f81b2b softwrap: remove unneeded caps on the number of chunks to move 2017-07-19 09:45:22 +02:00
Benno Schulenberg 43a5c87682 suspension: prevent entering an invalid byte upon resume (with S-Lang)
For some reason, when returning from suspension, SLang will produce
either a clipped error code (0xFF instead of 0xFFFF, when returning
from an externally induced suspension), or it will clip the code of
first subsequent keystroke to a single byte (when returning from a
normal, in-editor suspension: ^Z).

Side-step this by ignoring the clipped error code, and by using an
undefined control code as the first fake keystroke.  Ignoring the
clipped error code is not possible when using a single-byte locale,
otherwise the user would not be able to type the character with
code 0xFF (although it could still be entered with Esc Esc 255).

This fixes https://savannah.gnu.org/bugs/?51477.
2017-07-16 13:55:59 +02:00
Benno Schulenberg 8b3213cadb tweaks: chuck some debugging stuff 2017-07-15 11:49:56 +02:00
David Lawrence Ramsey 4f3249de56 display: when converting tabs, don't go beyond the screen width
This fixes https://savannah.gnu.org/bugs/?51427.
2017-07-10 09:34:55 +02:00
Benno Schulenberg fbbf501f8f tweaks: rename four functions, to be more distinct 2017-07-09 21:07:38 +02:00
Benno Schulenberg 09723b07a8 tweaks: fix compilation with --enable-tiny 2017-07-07 13:07:10 +02:00
David Lawrence Ramsey dd667ce92c softwrap: don't flag EOL too early, nor break continuous text too early
This should eliminate all cases where the newline is pushed off the edge
of the screen in non-atblanks softwrap mode.  Also, it allows the use of
the last column of the screen in atblanks softwrap mode when a piece of
text does not contain any blanks.

This avoids the unreachable end-of-line reported on the mailing list:
http://lists.gnu.org/archive/html/nano-devel/2017-06/msg00011.html.
2017-07-07 13:07:10 +02:00
Benno Schulenberg 482fb352b8 tweaks: elide unneeded calls of get_last_chunk_leftedge()
And then elide the function entirely as it's called just once.
2017-07-07 13:07:10 +02:00
Benno Schulenberg 8766e7bdcb tweaks: reshuffle some things to condense the code 2017-07-07 13:07:10 +02:00
David Lawrence Ramsey bb4d0d548a new feature: allow lines to be softwrapped at whitespace
Extend get_softwrap_breakpoint() to break softwrapped lines on
whitespace when a flag is set.  This flag is controlled by the new
rcfile option "atblanks".  The '>' characters marking two-column
characters at the edge of the screen are disabled when it's on.

If get_softwrap_breakpoint() can't find whitespace in screen range, it
will break the line on the screen edge.  (In this case, a blank can be
on the last column of the screen, but text can't, so that a blank on the
last column doesn't become invisible and possibly break the display.)

This fulfills https://savannah.gnu.org/bugs/index.php?49959.
Requested-by: Nicholas Boel <axxisd@gmail.com>
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey aa04ad4f83 replacing: make spotlight() account for varying chunk width
spotlight() now displays softwrapped lines chunk by chunk instead of all
at once.  Since softwrapped lines are no longer of constant width, the
latter approach would fail if softwrapping breaks the spotlighted text.

Instead of taking a string, spotlight() now takes the starting and ending
columns of that string.  Also, its handling of softwrapped lines is now
split off into a separate function, spotlight_softwrapped().
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey 4d7735c8f9 softwrap: in do_mouse(), keep the cursor before a softwrap breakpoint
Add the new function actual_last_column() to accomplish this.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey 8490f4acab softwrap: make the changes to actually allow the chunk width to vary
get_chunk_row() and get_chunk_leftedge() now become wrappers around
get_chunk(); the latter is only used directly in place_the_cursor()
when we need to get both the row and the leftedge.  get_chunk() now
uses the proper formula to implement varying chunk width.

Since chunk width now varies, place_the_cursor() sets the x position
relative to the leftedge in a different way that works regardless
of chunk width, update_softwrapped_line() loops until it gets all
softwrap breakpoints instead of calculating the full length in
advance and getting one full row at a time, the chunk iterators
now count leftedges instead of rows, and fix_firstcolumn() does a
full recalculation of the chunk that firstcolumn is on instead of
simply shifting it back.

Also, in update_softwrapped_line(), when a line's softwrap breakpoint
is before the last column of the edit window, a ">" is now added to
the end of it.

The workaround in place_the_cursor() for when two-column characters
straddle the edge of the screen is removed, as it's no longer needed
now that chunks end before such characters.

Furthermore, do_home() and do_end() use xplustabs() instead of
placewewant again when calculating the leftedge, since placewewant
refers to a column that may or may not be available (if it's not,
the cursor will be placed wrongly).  Make get_edge_and_target() use
xplustabs() instead of placewewant for the same reason; this also lets
us simplify get_edge_and_target(), since xplustabs() will never be
greater than strlenpt().  Finally, since do_end() now has to calculate
rightedge as well as rightedge_x, use the former to implement the same
time-saving optimizations as in do_home().

The cursor is not yet adjusted when we try to go directly to a column
past the end of a softwrap breakpoint, and placewewant handling in the
vertical movement code is not yet adjusted for varying chunk lengths,
but fixes for these are forthcoming.

This fixes https://savannah.gnu.org/bugs/?49440.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey e375995d98 softwrap: add new functions for chunks of varying width
get_chunk_row() replaces the formula "column / editwincols".

get_chunk_leftedge() replaces "(column / editwincols) * editwincols".

get_last_chunk_row() replaces "strlenpt() / editwincols".

get_last_chunk_leftedge() replaces "(strlenpt() / editwincols) * editwincols".

This prepares us for any changes in those formulas, and for more such
functions later.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey 35f6a1767a softwrap: prepare for allowing the chunk width to vary
The new function find_softwrap_breakpoint() returns the column number
of the last position in screen range where we can wrap the given text
without breaking a two-column character in half (as was done until now).
The returned column number is the leftedge of the next softwrapped chunk.

If the end of the text is reached while searching for a wrapping point,
the parameter end_of_line is set to TRUE.

The new function get_chunk() uses find_softwrap_breakpoint() to find the
row and leftedge corresponding to a given column of a given line.
2017-07-07 13:07:10 +02:00
Benno Schulenberg 8e3f40155c input: recognize the Ctrl+Arrow key sequences from Haiku's Terminal 2017-07-02 11:58:43 +02:00
Benno Schulenberg 4239e5fe1a tweaks: put declarations always first, so it will compile on Haiku 2017-07-02 11:53:59 +02:00
Benno Schulenberg b93767b54f screen: defeat a VTE/Konsole bug also for the case of --constantshow
When also --nohelp is active and the terminal is so narrow that the
message that --constantshow displays on the bottom row does not fit,
this causes the cursor to be pushed "offscreen".  Some terminal
emulators don't handle this case correctly, and leave the cursor
in an invisible or mistaken position.  Compensate for this by
moving the cursor back to the start of the row.

This fixes https://savannah.gnu.org/bugs/?51335.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-06-30 10:08:17 +02:00
Benno Schulenberg 84cd0abd6f tweaks: avoid compiler warning about implicit type 2017-06-04 12:59:05 +02:00
Benno Schulenberg 6a70d2b6e2 tweaks: rename two functions and a variable, and invert its logic 2017-06-04 12:34:21 +02:00
Benno Schulenberg 16482f99b8 tweaks: unglobalize the nodelay_mode variable 2017-06-04 12:15:26 +02:00
Benno Schulenberg a2038a9b2b input: give an appropriate message when there are too many errors
This fixes a secondary part of https://savannah.gnu.org/bugs/?51124.
2017-05-31 15:11:11 +02:00
Benno Schulenberg a969adf804 suspension: fake a SIGWINCH when coming back out of the background
When receiving a SIGCONT, don't call regenerate_screen() directly
but act as if a SIGWINCH occurred.  Also insert a dummy key, and
thus let the relevant input routine redraw the relevant subwindows.

Use KEY_F0 as the dummy key, as both Ncurses and Slang know it, and
it should normally do nothing at all.

This fixes https://savannah.gnu.org/bugs/?51124.
2017-05-31 14:57:56 +02:00
Benno Schulenberg 59b0f81bfa display: redraw title bar and edit window only when needed
When we are in the file browser, browser_refresh() will take care of
redrawing the title bar and the file list, so total_refresh() should
leave those two subwindows alone in that case.

This fixes https://savannah.gnu.org/bugs/?51147.
2017-05-31 12:44:02 +02:00
Benno Schulenberg 6ad3d3d6c0 display: show the cursor position also when searching took a while
Achieve this by making the suppression flag global, so that we can
just reset it instead of making an improper call of do_cursorpos().

This fixes the secondary part of https://savannah.gnu.org/bugs/?51134.
2017-05-29 22:15:38 +02:00
Benno Schulenberg ca70885564 tweaks: don't bother calculating the position when we won't show it
Also, remove a useless assert.
2017-05-29 21:51:47 +02:00
Benno Schulenberg cfa20c3f42 display: don't show the cursor while we are busy calculating its position
This fixes https://savannah.gnu.org/bugs/?51134.
2017-05-29 21:47:38 +02:00
Benno Schulenberg 7b23878b42 tweaks: do actual screen refreshes in a single call, when possible 2017-05-19 16:31:08 +02:00
Benno Schulenberg aa14526cb3 tweaks: exclude from the tiny version five error-betraying messages 2017-05-16 22:13:10 +02:00
Benno Schulenberg 28beb3f9c5 replacing: don't let placewewant influence the placement of the cursor
When spotlighting the string to be replaced, placewewant isn't valid,
so tell place_the_cursor() to ignore its value to avoid the cursor
getting mistakenly placed at the beginning of the next row.

This fixes https://savannah.gnu.org/bugs/?50997.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-05-11 22:28:34 +02:00
Benno Schulenberg dc3610fc8e tweaks: transform the token DISABLE_BROWSER to ENABLE_BROWSER
Also, allow Ctrl+Left/Right with --enable-tiny --enable-browser.
2017-05-08 21:56:50 +02:00
David Lawrence Ramsey 03c3e2b7c0 tweaks: fix several whitespace irregularities
Add missing spaces, remove excess spaces, and
replace groups of indentation spaces with tabs.
2017-05-07 18:20:01 +02:00
Benno Schulenberg 5a3de7f117 tweaks: avoid an empty function call in tiny version with line numbers 2017-05-05 12:39:20 +02:00
David Lawrence Ramsey 2b38547875 display: ensure smooth scrolling when the edit window is resized
When the editing space gets narrower, either by toggling line numbers on
or making nano's window smaller, and when the cursor is near the bottom,
it can be pushed offscreen.  In that case, don't get it back onscreen by
centering the current line but by putting it on the bottom row.  This
makes for a smoother experience.

This fixes http://savannah.gnu.org/bugs/?50933.
2017-05-05 12:31:02 +02:00
Benno Schulenberg 5033cfd81a tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE
Also, trim some comments and avoid an unused-variable warning.
2017-05-01 20:53:07 +02:00
Benno Schulenberg a9c4682c25 tweaks: rename another function, to better describe what it does
Also, reshuffle two initializations to go sit with the other ones.
2017-05-01 17:54:48 +02:00
Benno Schulenberg 3275c4e514 display: initialize the colors only when starting to draw the content
This avoids https://savannah.gnu.org/bugs/?49912 while at the same time
avoiding to draw the edit window twice in a row -- the first drawing
would use a wrong margin, which results in a visible and irritating
shift left or right of the content upon the second drawing.

This fixes https://savannah.gnu.org/bugs/?50877.
2017-04-30 17:29:17 +02:00
Benno Schulenberg 8edaa38a1e tweaks: condense two bits of code, and drop two asserts 2017-04-28 15:57:51 +02:00
Benno Schulenberg 1f55c8819b tweaks: swap the names of two variables, to make more sense
An iterator should not be called "start_col", because it is only the
starting column at the very beginning.

Also, start_col (after the rename) can never be /larger/ than column.
2017-04-28 15:48:50 +02:00
Benno Schulenberg 03ecbf3d55 tweaks: remove a superfluous check
The mbwidth() function itself checks whether UTF-8 is being used
and does the right thing.
2017-04-28 15:47:53 +02:00
Benno Schulenberg 26fe2118c4 docs: update the list of who authored what
Also, mention that help texts can now be searched through, update
a copyright notice, and update and simplify a copyright year.
2017-04-25 20:32:05 +02:00
Benno Schulenberg 46430999d5 build: make --enable-help properly depend on --enable-multibuffer
And in the process transform the token DISABLE_HELP to ENABLE_HELP.
2017-04-25 18:27:55 +02:00
Benno Schulenberg f9fea02fc5 help: suppress nano's name and number to make it clearer this is help
The top-left corner changing is far more conspicuous than the top right.
2017-04-25 17:21:02 +02:00
Rishabh Dave 90bd25c1bb new feature: add a search facility to the help viewer
Allow the user to search in a help text with ^W and M-W.

Achieve this by not writing the help text directly to the screen
but first writing it to a temporary file and then opening this file
in a new buffer, and treating it specially: the normal file-reading
feedback is suppressed, the titlebar shows the headline of the text,
the cursor is hidden, and the menu is limited to just the up and down
movements and searching.

This fulfills https://savannah.gnu.org/bugs/?28994.

Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
2017-04-25 17:20:34 +02:00
Benno Schulenberg ca6d7b6a46 input: avoid crashing when resizing the window during verbatim input
This fixes https://savannah.gnu.org/bugs/?50872.
2017-04-25 13:01:21 +02:00
Benno Schulenberg 861d81edba scrolling: don't bother to limit the number of lines to step back
The go_back_chunks() function will do this clipping.

This fixes https://savannah.gnu.org/bugs/?50866.
2017-04-24 19:48:55 +02:00
Benno Schulenberg 1fbe7596f8 options: allow -U (--quickblank) to be used in the tiny version
It takes almost no code and is a useful little improvement over Pico.
2017-04-19 13:47:40 +02:00
Benno Schulenberg 74f128859b tweaks: rename a constant, to match the corresponding option 2017-04-17 11:51:48 +02:00
Benno Schulenberg 3dc6ccbe86 tweaks: rename a function, to be more accurate
Because nothing gets reset to zero or to some initial value.
2017-04-17 11:29:29 +02:00
Benno Schulenberg b98545f455 display: push the titlebar to the screen as soon as it has been drawn
To avoid an ncurses hiccup (miscoloring) when running on musl.

This fixes https://savannah.gnu.org/bugs/?50787.
Reported-by: Avi Halachmi <avihpit@yahoo.com>
2017-04-17 10:53:38 +02:00
Benno Schulenberg 5a741a0205 tweaks: remove some superfluous placements of the cursor
The cursor needs to be placed in its proper spot in the edit window
/only/ when nano is about to accept input from the user and needs to
show where this input will go.

(This might cause a scrolling issue to appear, because reset_cursor()
does not just place the cursor, it also recomputes current_y, which
is used in several places to determine whether and how much to scroll.
If it so happens, we'll deal with that fallout later.)
2017-04-17 10:35:05 +02:00
Benno Schulenberg 6723ac6fcc tweaks: add three warnings for conditions that should never occur 2017-04-17 10:17:47 +02:00
Benno Schulenberg 999d99c6e4 tweaks: delete a function that hasn't been used since 2005 2017-04-09 13:33:25 +02:00
Benno Schulenberg 754c62c5cc copyright: update the years, use ranges, and explain this usage
The interval 2013-2017 for the Free Software Foundation is valid
because in those years there were releases with changes by either
Chris or David, and the GNU maintainers guide advises to mention
a new year in all files of a package, not just in the ones that
actually changed, and be done with it for the rest of the year.
2017-04-09 12:09:23 +02:00
David Lawrence Ramsey 23ae7bfbbf input: support escape sequences for ^Home and ^End
Make nano recognize the escape sequences for Ctrl-Home, Ctrl-End,
Shift-Ctrl-Home, and Shift-Ctrl-End on xterm, rxvt, and Eterm.
2017-04-06 21:25:41 +02:00
Benno Schulenberg cb0806b2a0 bindings: make ^Home and ^End go to top and tail of buffer
On some terminal emulators, Ctrl+Home and Ctrl+End produce special
keycodes, distinct from plain Home and End.  Make the users of those
emulators (and of the Linux console) glad by making ^Home and ^End
do the obvious thing, and the combinations with Shift too.
2017-04-06 21:19:00 +02:00
Benno Schulenberg f3e2ad945d display: with softwrap, show the cursor where the eye expects it
When a multi-column character straddles a chunk boundary, and the
preferred column (placewewant) for the cursor is zero, cheat: show
the cursor not where the character starts but on the beginning of
the next row.  This makes the cursor move smoothly in the leftmost
column of the screen when using <Up> and <Down> and such, instead
of jumping around.

In this way the scrolling logic won't get confused and the screen
will scroll properly when stepping beyond the top or bottom row.

This fixes https://savannah.gnu.org/bugs/?50687.
2017-04-06 19:51:07 +02:00
Benno Schulenberg 6ec65d5500 display: check the correct character for being double-width
This fixes https://savannah.gnu.org/bugs/?50741.
2017-04-06 17:39:58 +02:00
Benno Schulenberg aedc3ddd49 tweaks: replace a function call or a macro with a hard number
Verify at startup that the number is not too small.
2017-04-04 19:17:02 +02:00
David Lawrence Ramsey f9a8d6ff4e scrolling: properly compensate for the onscreen chunks
If edittop is partially offscreen before we scroll, and it gets
scrolled more offscreen, we do need to compensate for the chunks
between firstcolumn and leftedge -- that is: the chunks between
the top row and the cursor row.

This fixes https://savannah.gnu.org/bugs/?50691.
2017-04-04 10:55:24 +02:00
David Lawrence Ramsey c3830517cc display: show '<' and '>' placeholders for characters that get split
When a two-column character cannot be shown because it straddles the
boundary between two chunks of a line, show the '>' placeholder for
its left "half", and '<' for its right "half".

This mitigates https://savannah.gnu.org/bugs/?49440.
2017-04-03 21:51:46 +02:00
Benno Schulenberg 33cefa9208 tweaks: elide an intermediate variable 2017-03-29 10:20:41 +02:00
Benno Schulenberg 873e3d6fa6 tweaks: don't loop over an initializer 2017-03-29 10:13:08 +02:00
Benno Schulenberg 54e4505b2f tweaks: frob a couple of comments 2017-03-28 19:44:41 +02:00
Benno Schulenberg 8091d0a574 tweaks: simplify and correct a computation
The leftedge variable is a column number, not an x position.
2017-03-28 19:24:37 +02:00
David Lawrence Ramsey 93c6248956 display: don't compensate for chunks before firstcolumn
The number of rows to draw shouldn't be compensated for the chunks
of edittop that are before firstcolumn, because they are offscreen.

This completes the fix for https://savannah.gnu.org/bugs/?50621.
2017-03-28 19:10:45 +02:00
David Lawrence Ramsey 66ef8f45a3 display: don't draw more chunks than the screen can hold
There is no need to always increase nrows by 1 or 2 -- an increase
of 1 is only needed when the line that borders on the scrolled region
needs to redrawn too: when this line was horizontally scrolled or when
the mark is on.

This fixes https://savannah.gnu.org/bugs/?50621.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-28 12:32:51 +02:00
Benno Schulenberg 58faff50ae tweaks: shorten a bit of logic 2017-03-24 21:37:06 +01:00
David Lawrence Ramsey 87a7c2e42d tweaks: fix a comment typo 2017-03-24 21:21:51 +01:00
Benno Schulenberg e46c6c9607 tweaks: ehm... the warning is more important for the softwrap case
But apparently none of these cases occur, because I can't trigger them.
2017-03-22 11:05:22 +01:00
Benno Schulenberg 8b7bbebeeb tweaks: add a warning for a condition that should never occur 2017-03-22 10:50:59 +01:00
Benno Schulenberg 55159b7b39 painting: don't try to start highlighting before column zero
This could happen when a tab or a double-width character straddles
the boundary between two softwrapped chunks.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey 0389a1d939 softwrap: adjust firstcolumn when the window width changes
If the number of columns in the edit window changes (which currently
only happens in two places: in regenerate_screen(), called when the
window is resized; and in main(), when line numbering mode is toggled),
the display will break if we're in softwrap mode and firstcolumn is
nonzero.  This is because the column width of softwrapped chunks has
changed, and firstcolumn is no longer the starting column of a chunk,
an assumption that all code using firstcolumn relies on.

To fix this problem, add a new function, ensure_firstcolumn_is_aligned(),
to adjust firstcolumn to the starting column of the chunk it's on, and
use it when the number of columns in the edit window changes.

(Note that this function uses the simplest possible fix, and could
probably be made more sophisticated.)
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey 2f6c8987ea softwrap: move the updating of a softwrapped line to a new function
The new function, update_softwrapped_line(), is called from inside
update_line() when softwrap mode is on, so that existing calls remain
unchanged.  It takes no index, instead displaying edittop from column
firstcolumn, and all other lines from column zero.

If current is on edittop, it's displayed using the edittop rules, but
this is not a problem: if current[current_x] is above edittop at column
firstcolumn, it's offscreen, and that should be handled before calling
update_line() anyway.

Together with the preceding bunch of changes,
this fixes https://savannah.gnu.org/bugs/?47667.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 98b029cf3e softwrap: account for firstcolumn in reset_cursor()
When counting rows in softwrap mode, reset_cursor() should compensate for
the number of softwrapped chunks that edittop takes up before firstcolumn.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey c0fa3f04b1 softwrap: account for firstcolumn when checking for offscreen current
Make current_is_above_screen() check for current[current_x] being above
edittop at column firstcolumn, and make current_is_below_screen() start
counting down from edittop at column firstcolumn instead of edittop at
column zero.  This means that both functions now account for softwrapped
chunks properly.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey e52d5b0672 softwrap: remove and replace workarounds for firstcolumn
Actually enable scrolling edittop partially off the screen by making
edit_scroll() and adjust_viewport() use firstcolumn properly when
iterating through softwrapped chunks in softwrap mode, or lines in
non-softwrap mode.

In non-softwrap mode, firstcolumn should still always be zero, because
it's initially set to that, and because passing it through the iterators
will maintain it at that.

This fixes https://savannah.gnu.org/bugs/?49100.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 812ecaeb0c weeding: remove maxlines and related code
Since all lines can be partially scrolled off the screen now
(except for edittop, which is forthcoming), the maxlines global
variable and its computation mechanism are no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 2abf7b755b softwrap: iterate through softwrapped chunks in adjust_viewport()
Use go_back_chunks() to adjust edittop, instead of special casing
the computation of goal when softwrapping.  Now softwrap mode and
non-softwrap mode will behave the same way when edittop can be
partially scrolled off the screen, which is forthcoming.

(Note that the top line of the screen can't be partially scrolled
yet, so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey ba4858de83 softwrap: iterate through softwrapped chunks in edit_scroll()
Use go_back_chunks() and go_forward_chunks() to adjust edittop and to
move up or down to the scrolled region before updating the rows there.
Now softwrap mode and non-softwrap mode will behave the same way when
we can scroll the top line of the screen partially off the screen,
which is forthcoming.

(Note that the top line of the screen can't be partially scrolled yet,
so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey fa025f0ca3 display: limit an optimization to non-softwrap mode
Not drawing a line on a row if we're on the top row and scrolled down,
or if we're on the bottom row and scrolled up, will only work properly
if the line on that row takes up only that row.  The latter might not
be the case in softwrap mode: if the line occupies multiple chunks and
begins on that row -- in that case none of the chunks would be drawn.
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
David Lawrence Ramsey 380ad30a53 softwrap: account for softwrap when checking whether current is offscreen
Add the new functions current_is_above_screen() (which doesn't account
for softwrapped chunks yet, but will when we can scroll edittop partially
off the screen, which is forthcoming), current_is_below_screen() (which
determines whether current[current_x] is past the softwrapped chunk at
the bottom of the screen), and current_is_offscreen() (the union of the
previous two functions).

edit_redraw() and edit_refresh() now use current_is_offscreen() to check
whether they should adjust the viewport, and adjust_viewport() now uses
current_is_above_screen() to determine whether current is on or below
the screen in FLOWING mode.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 4f9c563e6b softwrap: count softwrapped chunks properly in do_uncut_text()
Add the new function less_than_a_screenful() to accomplish this.
It uses go_back_chunks() to count the number of softwrapped chunks
between the end point and the starting point of the paste.

Now softwrap mode and non-softwrap mode behave the same way when
uncutting fewer than editwinrows rows of text.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 456d66b904 softwrap: add two chunk-iterator functions
These functions, go_back_chunks() and go_forward_chunks(), take a number
of softwrapped chunks (screen rows) to move, a pointer to a buffer, and
a location (specifically, a starting column of a softwrapped chunk).  If
they move successfully, they will update the buffer pointer and location
to point to the beginning of the softwrapped chunk they moved to.

Since non-softwrap mode is effectively just a subset of softwrap mode
in which every line takes up one chunk, these functions also work in
non-softwrap mode.  In this case, their starting column will always be
zero, as it would be in softwrap mode on a line that takes up one chunk.

Nothing uses these functions yet, but that is forthcoming.
2017-03-22 10:44:04 +01:00
Benno Schulenberg 6d873d3760 startup: add option 'nopauses' to disable pausing after a warning
This addresses a followup of https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-03-16 19:26:39 +01:00
Benno Schulenberg 5283acdcf3 tweaks: trim a displayable string in a more efficient manner
Instead of redetermining the entire span of the converted string,
simply move one character left, and then bite it off to make place
for the trailing $.
2017-03-14 21:20:50 +01:00
Benno Schulenberg 69784d51db screen: don't push the longer-line indicator ($) to the next row
If the last two columns of a row would be taken up by a double-width
character (and the line is longer than that), don't print it, because
it wouldn't leave any room for the $ character.

This fixes https://savannah.gnu.org/bugs/?50491.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-08 21:24:13 +01:00
Benno Schulenberg 355a07bbce tweaks: don't optimize for the wrong case
Running strlenpt() on a string that takes up more than 80 columns
(the width of an average terminal) takes /more/ time than simply
converting an extra character (the one that will be overwritten
by the "$" at the edge of the terminal).  So... just convert one
more character than necessary when the line is overlong.  In the
most common case, however, the line will fit fully onscreen, and
we save a whole call of strlenpt().
2017-02-28 17:07:38 +01:00
David Lawrence Ramsey 0404474ec2 tweaks: stop converting text once we overshoot span columns
Since we only need span columns of the string, stop scanning the string
as soon as we have that many columns, instead of scanning the string all
the way to the end.  This speeds up the conversion of very long lines.
2017-02-28 16:50:22 +01:00
Benno Schulenberg a80ade38d7 tweaks: rename two variables, to be more distinctive 2017-02-28 15:17:03 +01:00
Benno Schulenberg 48643cbdf3 tweaks: elide a small intermediate buffer 2017-02-28 15:05:02 +01:00
Benno Schulenberg aa013aa007 tweaks: elide a variable 2017-02-28 14:53:10 +01:00
Benno Schulenberg 91910b2364 input: count a manually entered unicode as one character
This fixes https://savannah.gnu.org/bugs/?50403.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-28 14:47:45 +01:00
Benno Schulenberg efdd73922e oops -- that's what you get when you don't test things before pushing
Of course 'row' needs to be initialized to zero for the softwrap case.
2017-02-26 18:29:18 +01:00
Benno Schulenberg 2e53ed2928 tweaks: use two extra variables to make it clearer what is being done
This addresses https://savannah.gnu.org/patch/?9215.
Inspired-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-26 17:33:10 +01:00
Benno Schulenberg 0378146add tweaks: rename a variable, drop a false assert, and reshuffle a bit 2017-02-24 15:07:04 +01:00
David Lawrence Ramsey 6e9d6a08b9 replacing: fix spotlight() to highlight words properly in softwrap mode
In softwrap mode, the entire line is onscreen, so the word is never
partially offscreen, so we always have enough columns to show it.

This fixes https://savannah.gnu.org/bugs/?50389.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-24 15:06:44 +01:00
Benno Schulenberg 07ebba5e99 tweaks: rename a variable and invert its logic 2017-02-24 12:21:59 +01:00
David Lawrence Ramsey f1d214c0ef tweaks: slightly optimize an allocation in display_string()
Instead of allocating enough space to convert the entire passed string,
just allocate space for converting the part that will be converted --
that is: starting from start_index.  This still allocates far too much
(if the passed string is very long and its tail part won't fit on the
screen), but it's better than before.
2017-02-24 10:52:04 +01:00
Benno Schulenberg 1d3f3a6e25 tweaks: mark a message for translation 2017-02-23 15:22:07 +01:00
Benno Schulenberg 23c3fd9bcd statusbar: display at most three consecutive alert messages
Cap the number of pauses when displaying ALERT messages, to avoid
making the user wait for ages when tens or hundreds of files were
specified on the command line.

This fixes https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-02-22 10:48:26 +01:00
Benno Schulenberg c118397a14 tweaks: update some copyright years
Reflect the significant changes in painting and regex searching
in the copyright notices.
2017-02-21 20:27:49 +01:00
Benno Schulenberg 407f2d5bcf tweaks: move a comment and rewrap a line 2017-02-17 12:01:25 +01:00
David Lawrence Ramsey 61e8b3d542 screen: don't hide two-column characters at left edge in softwrap mode
When in softwrap mode, no "$" continuation characters are displayed,
so the code that reserves space for them should be skipped then.

This fixes https://savannah.gnu.org/bugs/?50335.
2017-02-17 11:39:37 +01:00
Benno Schulenberg fccfcccd37 tweaks: reshuffle an assignment and trim some comments 2017-02-13 19:46:51 +01:00
Benno Schulenberg 03148804e6 tweaks: scrap some debugging stuff 2017-02-13 19:46:41 +01:00
Benno Schulenberg 7ef5c53263 painting: mark an unpaired start match as CWOULDBE
The lines that come after an unpaired start have to know about this.

This fixes https://savannah.gnu.org/bugs/?50293.
2017-02-13 11:18:54 +01:00
Benno Schulenberg 6bd94040df painting: don't look at the current multidata when coloring a line
When coloring a line, look only at the multidata of the preceding
line, and based on that determine what to seek in the current line.

This fixes https://savannah.gnu.org/bugs/?50292.
2017-02-13 10:03:07 +01:00
Benno Schulenberg b3bcc8eeac painting: make use of the multidata of the preceding line
When painting a line, the multidata of the line /before/ it is valid
in most cases: it was determined just a moment ago.  And it tells us
all we need to know: whether there is an unpaired start match before
the current line or not.

The only exception is when painting the first line of the screen:
the multidata of the line before it might be stale.  So for the
first screen line we will always have to do some backtracking.
But that is left for later.

This fixes https://savannah.gnu.org/bugs/?50121.
2017-02-12 18:24:49 +01:00
David Lawrence Ramsey b1b9770c57 tweaks: rename a variable and adjust some types in edit_scroll()
Scrolling works on rows, not on lines.  Accordingly, rename the nlines
variable to nrows.  And rows should be of the type int, not ssize_t.
2017-02-05 20:04:31 +01:00
David Lawrence Ramsey 78037831f8 tweaks: rename a variable in edit_scroll(), to make sense 2017-02-05 19:44:42 +01:00
David Lawrence Ramsey 34e086f038 tweaks: rename a variable in edit_redraw(), to make sense 2017-02-05 12:30:09 +01:00
David Lawrence Ramsey f2ac20114e tweaks: adjust and correct some comments 2017-02-05 12:29:43 +01:00
Benno Schulenberg 1d10d79860 painting: account for index maybe being zero after the preceding change 2017-01-22 10:12:27 +01:00
Benno Schulenberg 8441887ec0 painting: advance only when both start /and/ end match are zero-length 2017-01-22 10:07:48 +01:00
Benno Schulenberg 775f007348 tweaks: use a cheaper way to detect an end-of-line
There is no need to compute the line length: just avoid overstepping
the terminating NUL byte when being forced to advance the index.
2017-01-21 19:44:48 +01:00
Benno Schulenberg 9a4a5454f2 painting: properly look for a new start match only after the end match 2017-01-21 12:30:56 +01:00
Benno Schulenberg af7201f9a0 tweaks: reshuffle three variables 2017-01-21 12:30:51 +01:00
Benno Schulenberg 2f80193d96 tweaks: reshuffle a test to a better place 2017-01-21 12:30:44 +01:00
Benno Schulenberg 23595c8376 tweaks: differentiate single-regex matches from paired-regex matches
Don't use the 'startmatch' variable when the corresponding match is
not the start of anything but is the entire match by itself.
2017-01-21 12:30:38 +01:00
Benno Schulenberg 669453506c painting: when skipping a zero-length match, skip a character, not a byte 2017-01-21 12:29:27 +01:00
Benno Schulenberg 9de376deed painting: stay within the line when skipping zero-length matches
Don't blithely overshoot the end of a line when both start regex and
end regex match an empty string.  Overshooting would let the matching
run on into uncharted country and thus ultimately cause a segfault.

This fixes https://savannah.gnu.org/bugs/?50056.
Reported-by: Elia Geretto <elia.f.geretto@gmail.com>
2017-01-20 17:03:10 +01:00
Benno Schulenberg 94907aa534 painting: do not bluntly ignore zero-length start matches -- handle them
The segmentation fault that this causes when both start and end match are
zero-length will be tackled later (https://savannah.gnu.org/bugs/?50056).

This fixes https://savannah.gnu.org/bugs/?50078.
Inspired-by: Elia Geretto <elia.f.geretto@gmail.com>
2017-01-20 14:00:14 +01:00
Benno Schulenberg 7e5524bb66 painting: do not let a match for 'end' overlap a match for 'start'
During precalculation and in step_two, we begin looking for an end
match only after the full start match, not merely one byte beyond
its starting point.  So do that too when searching backward for an
unpaired start match.

Also, index can never be zero here, because if the match was of length
zero, this piece of code will have been skipped by the preceding goto.
So we can always use REG_NOTBOL here.

(That goto is wrong, by the way: https://savannah.gnu.org/bugs/?50078,
but that will follow later.)
2017-01-20 13:17:10 +01:00
Benno Schulenberg 9f884810b6 tweaks: use a subtraction instead of a counter
And return a better value, so that less calculation is needed.
2017-01-13 19:33:32 +01:00
Benno Schulenberg 5d5666fba6 tweaks: swap two blocks of code to reduce the number of #ifdefs 2017-01-13 19:29:39 +01:00
Benno Schulenberg 980e334e37 tweaks: rearrange some code to separate softwrap and normal mode more
(Ignore the indentation for the moment.)
2017-01-13 19:17:59 +01:00
Benno Schulenberg 9bb64fccef tweaks: chuck some obscuring debugging stuff 2017-01-13 17:47:55 +01:00
David Lawrence Ramsey 6e3adf31b8 tweaks: let update_line() return the correct value on error
If the given line is out of range of editwinrows, we don't display it
at all, so we obviously don't display more than one line of it.  Thus,
the return value in this case should be zero, not one.
2017-01-13 17:41:26 +01:00
David Lawrence Ramsey c67c431239 tweaks: improve comments and formatting in update_line() 2017-01-13 17:36:02 +01:00
Benno Schulenberg bf0268d41d tweaks: condense a comment, rename a variable, and use a while loop 2017-01-12 21:31:08 +01:00
Benno Schulenberg b7c2513f7d tweaks: rename some variables, to better distinguish rows from lines
And columns from indexes -- columns are places on the screen, while
indexes point to characters in a line in the current buffer.
2017-01-12 19:32:21 +01:00
Benno Schulenberg 892762d99c tweaks: rename some variables, to show they refer to screen rows 2017-01-12 18:03:36 +01:00
Benno Schulenberg f7d320d932 tweaks: rename a function, to show it refers to screen rows 2017-01-12 17:48:33 +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 26fb907aa6 screen: ehm... no, that was wrong: page_start /is/ a column position
(The mistake becomes visible when you go to the end of a very long line
of double-width characters: the $ will be shown on the right edge, even
though you're already at line's end.)

This reverts commit 16a7fd4b from yesterday.
2017-01-12 10:29:20 +01:00
Benno Schulenberg 16a7fd4bfc screen: don't compare a character index with a column position
This addresses part of https://savannah.gnu.org/patch/?9216.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-01-11 17:22:46 +01:00
Benno Schulenberg a898fa5dcc tweaks: if there is no end match, there is nothing to paint
When there is no end match after a start, it is pointless to look
for any more starts because also they will not have any end match,
so nothing will get painted -- just cut the loop short.
2017-01-09 19:14:51 +01:00
Benno Schulenberg c0aa5ad258 tweaks: miscellaneous frobbings 2017-01-09 18:25:25 +01:00
Benno Schulenberg f6fbc1572d tweaks: adjust whitespace after the previous change 2017-01-09 12:01:27 +01:00
Benno Schulenberg 38d7362f20 tweaks: rename two variables to be just one as they play the same role
The renamed variable 'index' is not the start of a match (as some comment
mistakenly said), but from where in the line we start looking for a next
match.

Also, use one more goto to allow unindenting a big piece of code, and
shortcircuit two while loops for two more small unindents.
2017-01-09 11:39:37 +01:00