Commit Graph

1570 Commits (abd4c47acf4ec71a3eb142e44493d29ba1201465)

Author SHA1 Message Date
Benno Schulenberg 0d0d011579 tweaks: combine two ifs into one 2020-02-12 12:09:12 +01:00
Benno Schulenberg 71daa1ef6b tweaks: update several comments after the previous changes 2020-02-12 12:05:52 +01:00
Benno Schulenberg 0ed62e84de tweaks: weld two fragments together, twice, by eliding an unneeded 'if'
The get_kbinput() routine will never return ERR, so there is no need
to check for that.
2020-02-12 11:46:15 +01:00
Benno Schulenberg 0a31a9aa38 tweaks: make two conditions more direct, and thus elide two functions
Using straightforward comparisons is clearer and faster and shorter.

Again, note that this does not filter out 0x7F (DEL).  But that is
okay, as that code will never be returned from get_kbinput().
2020-02-12 11:38:33 +01:00
Benno Schulenberg 6747142cd7 tweaks: remove some redundant filtering, and thus elide a parameter
The few calls of the injection routines that had 'filtering' set to
TRUE have already filtered out ASCII control codes earlier on.  And
in the case of injecting a completion, this completion only contains
word-forming characters -- and if the user somehow added a control
code to the word-forming characters, then nano should NOT filter it
out, so in fact that setting of 'filtering' to TRUE was mistaken.

Note that this filtering did not filter out 0x7F (DEL).  But that is
fine: it should not occur in the input stream at that point anyway,
as it gets translated to either KEY_DC or KEY_BACKSPACE earlier in
the keyboard parsing routines.
2020-02-12 11:12:34 +01:00
Benno Schulenberg cbeea859c2 shutdown: don't refer to an open file when there aren't any
This fixes https://savannah.gnu.org/bugs/?57780.

Bug existed since commit b63c90bf from yesterday.
2020-02-10 09:28:37 +01:00
Benno Schulenberg 7ce1f6d86d locking: when finding a lock file at startup, quit when user cancels
When at startup the user presses Cancel at the "open anyway?" prompt,
cancel the whole startup: quit.  But when the user answers No, just
skip the file and continue starting up.
2020-02-02 13:00:37 +01:00
Benno Schulenberg a2f8703df5 tweaks: tumble three conditions, for consistency in comparisons 2020-01-31 16:05:51 +01:00
Benno Schulenberg a692b01c04 tweaks: reshuffle two lines, to do the linking first, then the content 2020-01-29 12:33:30 +01:00
Benno Schulenberg a197ccf12d tweaks: move another function, to group the deleting ones together 2020-01-29 12:16:09 +01:00
Benno Schulenberg 67e5913edf tweaks: move another function to before the one that calls it 2020-01-29 10:54:30 +01:00
Benno Schulenberg e864107046 tweaks: move a function to right before the one that calls it 2020-01-29 10:53:05 +01:00
Benno Schulenberg 7984ea4eb6 tweaks: remove two superfluous assignments, and rename a variable
The 'prev' and 'next' links get assigned to immediately after the
call of copy_node().  And anyway, it does not make sense to link
a copied node to the predecessor and successor of its original.

Also slightly regroup some lines.
2020-01-29 10:47:09 +01:00
Benno Schulenberg f38bd5030d tweaks: add a little change that was overlooked in the previous commit
Option --showcursor applies also to the help viewer, which means that
it can do something useful in restricted mode too.
2020-01-28 12:00:05 +01:00
Benno Schulenberg a2fea9928d build: exclude option '-g' when configured without browser and help 2020-01-28 10:33:56 +01:00
Benno Schulenberg 445cd2a6c5 usage: improve the description of --restricted and --quickblank
Give a little more information than just a rehash of the long option.
2020-01-28 10:04:01 +01:00
Benno Schulenberg c09e96f294 suspension: put in an extra terminal-initialization call for Slang
Also, the disabling of the keyboard interrupt (SIGINT) must happen
after that initialization call, otherwise ^C will still do nothing
after returning from suspension (when nano is built against Slang).

This fixes https://savannah.gnu.org/bugs/?57656.

Bug existed since version 2.2.0, commit daaf468c.
2020-01-27 16:46:01 +01:00
Benno Schulenberg f8553f6d3a feedback: restore a message that can occur in help viewer or file browser
It was mistakenly removed in commit ea874112, two days ago.
2020-01-24 19:45:07 +01:00
Benno Schulenberg d764d7094f tweaks: don't enable bracketed pasting when not handling such pastes
The tiny version is oblivious of bracketed pastes, as it serves no
purpose: in the tiny version there is no auto-indent nor undo nor
tabs-to-spaces conversion.
2020-01-24 17:21:47 +01:00
Benno Schulenberg fa686457c2 input: ignore modifiers on a VT while executing a macro or a string bind
Any modifier keys that are needed to start the execution of a macro
(or of a string bind) should not affect the interpretation of the
keystrokes that are contained within the macro or the string.

This fixes https://savannah.gnu.org/bugs/?57660.

Bug existed since macros were introduced, in version 2.9.0.
2020-01-23 12:39:23 +01:00
Benno Schulenberg 1cd5005d06 bindings: allow to bind shifted Meta+letter combinations with Sh-M-X
As long as the user does not define any Sh-M-X bindings in their nanorc,
<Shift> and <CapsLock> will not have any effect on <Alt+letter> combos.
But as soon as any Sh-M-X combination is bound, <Shift+Alt+letter> will
be seen as different from the unshifted keystroke.

This kind of fulfills https://savannah.gnu.org/bugs/?54659.
Requested-by: Peter Passchier <peter@passchier.net>
2020-01-23 11:11:34 +01:00
Benno Schulenberg ea874112d8 tweaks: remove a feedback message that is never shown
A plain printable ASCII character (from 0x20 to 0x7E) can never be
a shortcut, so it also can never get reported as being unbound.
2020-01-22 15:41:04 +01:00
Benno Schulenberg 25d397e7b3 feedback: report Ctrl+Alt keystrokes as unbindable
When reporting them as simply unbound, the user might think that M-^X
keystrokes might somehow become bound.
2020-01-22 15:10:41 +01:00
Benno Schulenberg 5111b20bf5 build: exclude bracketed pasting from the tiny version 2020-01-22 12:58:48 +01:00
Benno Schulenberg f571d6ba36 tweaks: gather four calls that are always done together into a function 2020-01-22 12:49:00 +01:00
Benno Schulenberg 092711e412 tweaks: remove the now-unneeded code related to bracketed pasting
The suppression of auto-indentation, automatic hard-wrapping, and
tab-to-spaces conversion is now inherent in the way the reading-in
of a bracketed paste is handled by the previous commit: as a single
block of text.
2020-01-19 14:44:28 +01:00
Benno Schulenberg 0e6d693dc8 input: read in an external paste in one go, to allow undoing with one M-U
This makes an external paste (with mouse or <Shift+Insert>) behave
the same as an internal paste (^U), and also inherently suppresses
auto-indentation, automatic hard-wrapping, and tab conversion.

This fulfills https://savannah.gnu.org/bugs/?54950.
2020-01-19 14:44:28 +01:00
Benno Schulenberg 7dcc8f1d7a tweaks: adjust the indentation after the previous change
Also reshuffle some lines, and adjust the comments.
2020-01-17 16:51:21 +01:00
Benno Schulenberg 343f97b3ac new feature: allow specifying a custom nanorc file on the command line
This fulfills https://savannah.gnu.org/bugs/?57547.
Requested-by: Saagar Jha <saagar@saagarjha.com>
2020-01-17 16:51:21 +01:00
Benno Schulenberg 706f3e93f4 tweaks: in comments, reword "titlebar" and "statusbar" to two words each
To differentiate them from the function names.
2020-01-16 19:37:28 +01:00
Benno Schulenberg afa4c6b9fc copyright: update the years for the FSF 2020-01-15 11:42:38 +01:00
Benno Schulenberg 27127853db tweaks: exclude an unneeded fragment of code from the tiny version 2020-01-14 16:28:28 +01:00
Benno Schulenberg 7d483987ce input: do not auto-indent when something is pasted into nano from outside
Also, do not break overlong lines and do not convert tabs to spaces,
nor interpret a <Tab> as an indent command (when the mark is on).
In other words: accept an outside paste as literally as possible.

This fulfills https://savannah.gnu.org/bugs/?40060.
Requested-by: Egmont Koblinger <egmont@gmail.com>

And fulfills https://savannah.gnu.org/bugs/?57527.
Requested-by: Sébastien Desreux <seb@h-k.fr>
Requested-by: Hans Ecke <hecke@gxt.com>

Original-idea-by: Brand Huntsman <alpha@qzx.com>
2020-01-12 11:18:51 +01:00
Brand Huntsman f705a9674b input: recognize the start and stop sequences of a bracketed paste
Also, tell the terminal to switch on bracketed-paste mode, and toggle
a boolean when the start and stop sequences of such a paste are seen.
This boolean can later be used to suppress auto-indent and such.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2020-01-12 11:18:51 +01:00
Benno Schulenberg 72e5c15110 tweaks: move three functions to the file where they are mainly used
The extract() and copy_from_buffer() functions are mainly used for
cutting a line or a region, so move them to src/cut.c.  Also move
the function for which copy_from_buffer() is a wrapper.
2020-01-08 16:04:49 +01:00
Benno Schulenberg 97c8140cea tweaks: rename two functions, to make more sense 2020-01-08 11:09:57 +01:00
Benno Schulenberg c2f2c659d9 tweaks: rename a parameter and invert its logic, and correct a comment
This changes the main injection routine in the same way that the prompt
injection routine was changed four years ago in commit e540053e.
2020-01-08 10:49:19 +01:00
Benno Schulenberg 9364bd6c81 tweaks: reword two comments, and rewrap another 2020-01-08 10:27:30 +01:00
Benno Schulenberg baa2be3217 tweaks: improve a comment by indirectly referring to the ncurses docs
See https://invisible-island.net/ncurses/ncurses-intro.html#xterm.
2020-01-07 20:25:31 +01:00
Benno Schulenberg 3f0d2fd5ca display: don't let a message write over the second help line
When suspending nano on a Linux console (or FreeBSD console), the
helpful message about using the 'fg' command overwrote the start
of the second help line, kind of hiding the message.  So, output
a double newline before the message to make it stand out.

Also, drop a pointless cursor movement, as endwin() determines
the placement of the cursor all by itself.
2020-01-07 13:38:52 +01:00
Benno Schulenberg 3cae32390d display: show the cursor during suspension also when built with Slang
This fixes https://savannah.gnu.org/bugs/?57517.

Bug existed since version 2.9.0.
2020-01-03 12:08:27 +01:00
Benno Schulenberg 1be0285832 tweaks: delete some fragments of code that have become irrelevant
Since the previous commit, USE_SLANG can only be defined when NANO_TINY
is also defined.  This means that code that is present only in non-tiny
versions does not need to cater for Slang.
2020-01-03 12:00:06 +01:00
Benno Schulenberg c4d2bf59fb display: adjust line and column count upon a resize also when using Slang
This partially fixes https://savannah.gnu.org/bugs/?57513.
2020-01-01 14:17:03 +01:00
Benno Schulenberg 67b89459d5 tweaks: drop an unneeded call of keypad() -- we never read from topwin
The title bar is used only for showing things, never for typing anything
into.  That is: we never call wgetch() with 'topwin' as an argument.
2019-12-29 14:14:08 +01:00
Benno Schulenberg 76d90617cc build: avoid three compiler warnings when using gcc-9.2 or newer
This addresses https://savannah.gnu.org/bugs/?57360.
Reported-by: Brand Huntsman <alpha@qzx.com>
2019-12-08 11:27:06 +01:00
Benno Schulenberg 3ffefbfddc build: fix compilation for --enable-tiny --enable-histories 2019-11-25 19:17:41 +01:00
Benno Schulenberg fa88fcc8f2 tweaks: rename a function, and elide a parameter that is always NULL
After the previous change, all remaining calls of parse_mbchar() have
NULL as their third parameter.  So, drop that parameter and remove the
chunk of code that handles it.  Also rename the function, as there are
already too many functions that start with "parse".
2019-10-21 12:35:14 +02:00
Benno Schulenberg 95ae124891 history: don't wait when there is something wrong with the history files
Do not wait for the user to press a key when there is some problem
with any of the history files.  Just start and indicate the problem
on the status bar.  The precise error message is stored and will be
shown on the terminal when exiting from nano.

This addresses https://savannah.gnu.org/bugs/?56524.
2019-10-20 14:30:04 +02:00
Benno Schulenberg 17c16a4bf5 tweaks: rename a function and elide its first parameter 2019-10-20 09:45:58 +02:00
Benno Schulenberg 7d3290fb91 tweaks: rename three variables, to be consistent with other linestructs 2019-10-16 11:04:26 +02:00
Benno Schulenberg d256d0cbc0 tweaks: add a helper function without the ubiquitous NULL argument
For conciseness and clarity.
2019-10-13 12:24:27 +02:00
Benno Schulenberg d12191db5a tweaks: pass any special undo/redo messages to the add_undo() function
For the three operations (justification, spell checking, and filtering)
that need to undo or redo two suboperations (cutting and then pasting)
in one go, pass the message that describes the operation to add_undo(),
so that the undo item does not need to be modified after the call.

This looks better, but does add some twenty NULL parameters elsewhere.
2019-10-09 19:21:27 +02:00
Benno Schulenberg 785efc2087 tweaks: make a function do a check so its calls don't need to 2019-10-09 18:58:30 +02:00
Benno Schulenberg b480e7fc9c tweaks: remove some timing code that has served its purpose 2019-10-03 19:00:50 +02:00
Benno Schulenberg 1861052234 tweaks: avoid a comparison between signed and unsigned [coverity] 2019-09-30 19:30:54 +02:00
Benno Schulenberg 2307b31887 tweaks: use 'void' in prototypes of parameterless functions [coverity] 2019-09-30 19:06:25 +02:00
Benno Schulenberg 2d16c27820 tweaks: add two hints for translators, to try and help avoid mistakes 2019-09-22 17:31:27 +02:00
Benno Schulenberg ad65b79ac7 usage: mark the -J/--guidestripe option plus argument as translatable
This fixes https://savannah.gnu.org/bugs/?56930.

Bug existed since the vertical guiding bar was introduced,
in version 4.0, commit 66c6eb51.
2019-09-21 19:50:55 +02:00
Benno Schulenberg fe5bd8cdef usage: properly align --help output also when it has accented characters
As printf() is not UTF8-aware, we have to determine ourselves how many
columns each short and long flag take up and add the required number of
spaces (not tabs, because their size is not fixed) to fill things up.

This fixes https://savannah.gnu.org/bugs/?56928.

Bug existed since version 4.3, commit 2f169107.
2019-09-21 19:31:48 +02:00
Benno Schulenberg ab6390cad0 tweaks: remove two superfluous macros, as sizeof(char) is always 1 2019-09-18 15:20:08 +02:00
Benno Schulenberg ba5b85baf0 tweaks: rename three variables, to better indicate what they hold
They hold not a terminal but flags, settings, state.
2019-09-06 19:40:38 +02:00
Benno Schulenberg 9f95fa9ce5 tweaks: reshuffle a line, to group things better 2019-09-06 19:25:43 +02:00
Brand Huntsman 8853bc448d search: accept a match at start of file when searching from command line
For a forward search from the command line, pass FALSE to 'skipone'
so that an occurrence at the head of the file is not skipped over.

This fixes https://savannah.gnu.org/bugs/?56845.
Reported-by: Derek Wolfe <dwwolfe1@gmail.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-09-02 09:05:50 +02:00
Benno Schulenberg 15148a5e6d search: after search-at-startup, store the column (for vertical movement)
This fixes https://savannah.gnu.org/bugs/?56846.
2019-09-01 16:15:15 +02:00
Benno Schulenberg 5c399dfc6e build: exclude the search-at-startup feature from the tiny version 2019-08-18 13:03:11 +02:00
Benno Schulenberg ed4b6486a1 search: don't wipe the status bar at startup when there was an error 2019-08-18 12:59:23 +02:00
Brand Huntsman 2326bf695e search: accept toggles for case and regex when searching at startup
Allow the user to specify that the search string should be interpreted
case-sensitively and/or as a regular expression by preceding the search
indicator (/ or ?) with c and/or r.  Or to switch these things off by
using C and/or R.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2019-08-18 12:59:04 +02:00
Benno Schulenberg a9dd73fb16 new feature: allow specifying a search string to "jump to" at startup
The string to "jump to" is specified with +/ for a forward search
(from the top of the file), or with +? for a backward search (from
the bottom of the file).

This fulfills https://savannah.gnu.org/bugs/?54535.
Requested-by: Derek Wolfe <dwwolfe1@gmail.com>

With-help-from: Brand Huntsman <alpha@qzx.com>
2019-08-18 11:16:03 +02:00
Benno Schulenberg a578d2706c copying: do not prevent M-6 from copying emptiness into the cutbuffer
The check mistakenly prevented the user from copying a region that
ended at EOF.  Removing the check also gives the user a way to clear
the cutbuffer (with M-A M-6 or ^6 M-6, for example).

This fixes https://savannah.gnu.org/bugs/?56563.
Reported-by: Liu Hao <lh_mouse@126.com>
2019-07-29 19:00:22 +02:00
Benno Schulenberg aa205f58ca tweaks: rename a bunch of variables, to become identical to others 2019-06-09 17:07:02 +02:00
Benno Schulenberg 33fea90bcd justify: remove "--" from the quoting regex, to avoid false paragraphs
The use of a double dash (for an option name or as sentence separator)
is too common to allow it to be seen always as a comment introducer.
Users of Lua and Postgres will have to redefine 'quotestr' themselves
if they want to be able to rewrap block comments with ^J.

The other characters that were added in commit c5a72103 (!, %, and ;)
are less problematic because they tend to be glued to the end of words,
so they are unlikely to appear at the start of a line.

This fixes https://savannah.gnu.org/bugs/?56462,
and fixes https://savannah.gnu.org/bugs/?56461.

Bug existed since version 4.0, commit c5a72103.
2019-06-08 16:47:08 +02:00
Benno Schulenberg 9b34d0a4fb tweaks: rename two variables, to be unique 2019-06-08 10:10:31 +02:00
Benno Schulenberg 26d16ab9d1 tweaks: rename a variable, to better suit its counterpart 2019-06-08 10:05:32 +02:00
Benno Schulenberg 6ca8518428 tweaks: make better use of two variables, and reshuffle two comments 2019-06-08 10:03:15 +02:00
Benno Schulenberg 8d4e171d3c tweaks: improve a couple of comments 2019-06-05 16:23:34 +02:00
Benno Schulenberg 6f1e5912a9 tweaks: stop allocating and freeing a holder struct for every cut/paste
This "holder" information is needed for every cut and paste and other
block operation.  Instead of allocating and freeing it for every such
operation, just have the six elements as static variables.  This saves
a little churn, and saves having to declare a type that is used just
once.  Plus, the access to these variables will be a little quicker.
2019-06-05 16:10:07 +02:00
Benno Schulenberg 28a6d9f300 tweaks: rename four elements of the holder struct, for more contrast 2019-06-05 15:32:50 +02:00
Benno Schulenberg ea1016efdb feedback: make an error check work also when curses hasn't started yet
Add a temporary boolean for this, because isendwin() returns TRUE
only when curses mode has actually been started with initscr() and
then exited with endwin().
2019-06-03 13:38:21 +02:00
Benno Schulenberg 2003413989 tweaks: move a function to the file where it is used 2019-06-01 10:52:38 +02:00
Benno Schulenberg 9369af77ce tweaks: elide a function that is used just once 2019-06-01 10:43:50 +02:00
Benno Schulenberg 35d2bc6b38 build: fix compilation on another system
The <signal.h> header file is needed to define 'sig_atomic_t'.
(Don't know why on my main system it compiled fine without it.)
2019-05-31 20:53:00 +02:00
Benno Schulenberg b52d166afa tweaks: rename a type, to make more sense
The sphere, the holder, is everything *around* the partition;
it was confusing to call this holder type 'partition'.

Also correct and improve some comments.
2019-05-31 19:44:47 +02:00
Benno Schulenberg 3952dcb629 tweaks: rename a variable, reduce its scope, and use it consistently 2019-05-31 19:25:50 +02:00
Benno Schulenberg 7e9dd385f5 tweaks: elide a parameter and a return value
As 'filepart' is a global variable, there is no need to pass it around.
Just use it directly.
2019-05-31 19:00:20 +02:00
Benno Schulenberg 58ca5fb0f3 build: move an #include to where it is needed 2019-05-31 17:14:28 +02:00
Benno Schulenberg c5d157dd9d tweaks: close a buffer differently and elide a parameter 2019-05-31 09:15:12 +02:00
Benno Schulenberg 477ff49f66 feedback: don't try to represent keys outside of the seven-bit range
This fixes https://savannah.gnu.org/bugs/?56415.
2019-05-30 19:06:06 +02:00
Benno Schulenberg 5a48edc9ae tweaks: reshuffle some code to the one place that needs it
The extra things that close_buffer() did are only needed and useful
when manually closing a buffer, so move them there.  The other three
calls of close_buffer() only need to get rid of the current buffer
(making the preceding buffer the new current one) and nothing else.
2019-05-30 17:09:49 +02:00
Benno Schulenberg 7e422402d5 tweaks: change a function to void, to make things more direct 2019-05-29 20:02:50 +02:00
Benno Schulenberg d9deaf9f2f tweaks: reduce the scope of a variable, and let the compiler zero it
Also, rename the variable, to have a unique name.
2019-05-28 14:09:54 +02:00
Benno Schulenberg b75563b88e tweaks: use a symbol instead of zero to refer to standard input 2019-05-28 12:31:16 +02:00
Benno Schulenberg 33e1bf1435 startup: remove the now-unneeded workaround for a SIGWINCH during input
The previous commit makes that the terminal's state is only resaved
when standard input is actually reconnected to the terminal, and
leaves it unchanged otherwise.  Apparently this is enough to fix
https://savannah.gnu.org/bugs/?56394.
2019-05-28 12:19:49 +02:00
Benno Schulenberg d946f38a2b files: when needed, reconnect the keyboard and reenter curses mode
When after reading a file we are not in curses mode, it means we have
read data from standard input, either from the keyboard or from a pipe.
In the latter case, we first need to reconnect standard input to the tty.
And in both cases, we then need to reenter curses mode before being able
to display the number of lines that were read (or an error message).

So, move the reconnecting code from scoop_stdin() to its own function,
and call this function from read_file() when needed.

This fixes https://savannah.gnu.org/bugs/?56310.

Bug existed since version 2.1.8 when reading from stdin was introduced.
2019-05-28 11:28:23 +02:00
Benno Schulenberg b53dffaeed startup: resave the terminal's state only when there were no signals
For some reason a SIGWINCH or SIGINT "corrupts" the current state of
the terminal, and magically validates the state that was saved first.

This fixes https://savannah.gnu.org/bugs/?56394 properly.
2019-05-27 19:35:46 +02:00
Benno Schulenberg 6dcfcd11ce tweaks: rename two functions, to better describe what they do 2019-05-27 17:24:35 +02:00
Benno Schulenberg f21b094dad tweaks: condense a couple of comments, and reshuffle a line 2019-05-27 17:21:05 +02:00
Benno Schulenberg a521ac4ae7 tweaks: exclude a bug check from the tiny version 2019-05-27 10:11:22 +02:00
Benno Schulenberg b7e2da7434 files: don't save the state of the terminal a second time
The user will understand that changing the state of the terminal
while inputting data into nano is not the same as changing this
state before nano has started or after nano has exited.

This fixes https://savannah.gnu.org/bugs/?56394.

Bug existed since version 2.4.2.
2019-05-26 19:16:40 +02:00
Benno Schulenberg 8c5b67379f tweaks: factor out the installing and restoring of the ^C signal handler
So that these two functions can be used elsewhere too.
2019-05-26 13:55:59 +02:00
Benno Schulenberg b2926eb675 tweaks: include the enabling of SIGINT into the tiny version
Either this enabling is not needed at all when the original terminal
state has been restored, or it will be needed in the tiny version too.

Also condense some comments.
2019-05-26 13:49:38 +02:00
Benno Schulenberg e3e81879b1 tweaks: condense the setup of the two signal handlers for Ctrl+C
Don't bother checking for an error from sigaction(), because the only
things it could error out for is when it is passed an invalid signal
(which SIGINT isn't) or oldaction/newaction would point to memory that
is outside of nano's control (which is obviously not the case).

Also, the setup of signal handlers during startup does not check for
errors, so why do it here?
2019-05-24 10:48:03 +02:00
Benno Schulenberg 2f1691079e usage: make the --help output independent from the terminal's tab size
Use printf's ability to align things (instead of trying to do it
ourselves and failing when the tab size of the terminal is not 8.)

Suggested-by: Vincent Huisman <site.gentoobugzilla@dataghost.com>

This fixes https://savannah.gnu.org/bugs/?56372.
Reported-by: Vincent Huisman <site.gentoobugzilla@dataghost.com>
2019-05-22 19:55:25 +02:00
Brand Huntsman 0e29c2a24a rcfile: store errors and display them when nano terminates
This is needed to implement the demand loading of syntax files, as any
errors that these files may contain would otherwise overwrite things on
the screen and the messages wouldn't be on the terminal when nano exits.

It also allows nano to start up on a Linux console when there are errors.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-05-20 10:25:47 +02:00
Benno Schulenberg 9e182722cc feedback: print helpful message only when data comes from keyboard
When the data is fed to nano through a pipe, it is pointless to print
this message as it can be seen only after nano has exited.

This addresses https://savannah.gnu.org/bugs/?56348.
2019-05-19 19:49:47 +02:00
Benno Schulenberg 53352d0b26 files: try matching a syntax after scooping data from standard input
The blank filename should not give any match, but maybe the header line
or the magic finds a fitting syntax.

This fixes https://savannah.gnu.org/bugs/?56344.
2019-05-19 17:48:08 +02:00
Benno Schulenberg 8723375443 tweaks: remove a superfluous and ineffective assignment
This assignment became superfluous two years ago, by David's revamping
of read_file() in commit 86f7bc18.
2019-05-18 17:21:54 +02:00
Benno Schulenberg 527c6c1ca0 tweaks: reshuffle a few lines, to be more straightforward 2019-05-16 16:04:12 +02:00
Benno Schulenberg a9e8f88e77 tweaks: enforce the miminum amount of scrolling in a simpler way
This improves the fix for https://savannah.gnu.org/bugs/?56317.
2019-05-16 16:00:42 +02:00
Benno Schulenberg 0ebfd54e17 softwrap: use smooth scrolling when softwrapping is toggled on
If the cursor is near the bottom row when softwrap gets switched on, the
screen should scroll just the amount needed to keep the cursor onscreen.

This fixes https://savannah.gnu.org/bugs/?56317.

Bug existed since softwrapping was introduced in version 2.1.11.
2019-05-13 10:25:12 +02:00
Benno Schulenberg 71d0847b19 tweaks: merge two functions, as the one is used only by the other 2019-05-08 15:25:11 +02:00
Benno Schulenberg c55d144748 tweaks: drop most of the remaining debugging code, and some timing code 2019-05-08 15:23:36 +02:00
Benno Schulenberg 8720cfcce9 tweaks: rename two more functions, to be simpler too 2019-05-04 11:21:45 +02:00
Benno Schulenberg 954c4d03ac tweaks: rename two functions, to be simpler 2019-05-04 11:21:45 +02:00
Benno Schulenberg edf6995be4 zapping: use the 'keep_cutbuffer' logic to keep undo items apart
The 'keep_cutbuffer' variable becomes FALSE whenever there is cursor
movement or there was a marked region.  Use this variable to simplify
the condition for creating a new ZAP undo item.  But then typing the
'zap' shortcut should not cause the variable to be set to FALSE.

This fixes the first part of https://savannah.gnu.org/bugs/?56261.

Bug existed since zapping was introduced, in version 3.2.
2019-05-04 11:18:51 +02:00
Benno Schulenberg e0c5c589ad tweaks: remove a superfluous condition, in three places
When 'last_action' has a specific value, then necessarily there must
exist a corresponding current undo item.

(The condition is already absent in do_deletion(), for the BACK and DEL
undo items, and it works fine there.)
2019-05-03 12:18:04 +02:00
Benno Schulenberg 6c4f228f6f tweaks: invert two conditions, in order to elide an extra variable 2019-05-02 14:34:05 +02:00
Benno Schulenberg fe06ae5f48 tweaks: normalize the indentation after the previous two changes 2019-05-02 14:27:35 +02:00
Benno Schulenberg 07289f437f tweaks: invert a condition, in order to return earlier 2019-05-02 14:12:23 +02:00
Benno Schulenberg 99d155d80f tweaks: reshuffle an assignment, to be able to return earlier 2019-05-02 14:10:23 +02:00
Benno Schulenberg 404a6862cd tweaks: really don't bother renumbering the lines in the cutbuffer
The lines from the cutbuffer will be renumbered when it matters: when
they get pasted.

The only place that used the numbering of (a copy of) the cutbuffer
(the updating of an undo item) already iterates through its lines.
Just add a counter there instead of making use of the line numbers.
2019-05-01 13:09:22 +02:00
Benno Schulenberg 85fc41470b tweaks: stop passing 'cutbuffer' and 'cutbottom' back and forth
All extractions are done into the cutbuffer, so it is pointless to pass
'cutbuffer' and 'cutbottom' in and back out as parameters all the time.
Just use those global variables directly.

Also, rename the function as there is no longer a buffer among its
parameters.
2019-05-01 11:33:37 +02:00
Benno Schulenberg fa21986ecf oops: apparently the line numbers in the cutbuffer do matter
The line numbers don't matter for the cutbuffer itself, but they matter
for the copy of the cutbuffer that is stored in an undo item.

This reverts commit 14140d52 from two hours ago.

This fixes https://savannah.gnu.org/bugs/?56245.
2019-04-30 12:49:57 +02:00
Benno Schulenberg 772137cabe tweaks: rename a variable, to fit a bit better 2019-04-30 12:24:56 +02:00
Benno Schulenberg 4c53e2f56b tweaks: elide two unneeded variables
After extracting a line or region, the current line is always the one
where renumbering should start.  And when ingrafting a buffer, it is
always the first ingrafted line where renumbering should start.  The
'top_save' variable was indirectly getting set to those lines.

Also, renumber immediately after unpartitioning the file buffer, before
doing anything else.
2019-04-30 12:20:41 +02:00
Benno Schulenberg 14140d5249 tweaks: don't bother renumbering the lines in the cutbuffer
The numbering of the lines in the cutbuffer is irrelevant.  These lines
will be renumbered when it matters: when they get pasted.
2019-04-30 10:55:15 +02:00
Benno Schulenberg 17aa9371b5 tweaks: rename a function, to better indicate what it does 2019-04-30 10:27:10 +02:00
Benno Schulenberg 208995e4a7 tweaks: move a bit of timing code to where it will be needed 2019-04-30 10:15:46 +02:00
Benno Schulenberg b503670750 tweaks: rename a variable, to match another with the same meaning
Also, remove a redundant condition.
2019-04-30 10:15:11 +02:00
Benno Schulenberg 542426f1f1 tweaks: add a warning for something that shouldn't occur 2019-04-30 09:44:47 +02:00
Benno Schulenberg 6319a86178 tweaks: improve some comments, reshuffle a line, and rename a variable 2019-04-29 11:08:21 +02:00
Benno Schulenberg 9888e67b20 tweaks: rename two variables, for more contrast with the partition stuff 2019-04-29 09:45:41 +02:00
Benno Schulenberg 8fe19e344f tweaks: use a more direct call when a single linestruct is deleted 2019-04-28 17:20:08 +02:00
Benno Schulenberg d54180ad8b tweaks: reduce a bit of mark-adjusting code to its essence
It doesn't matter whether the grafted text contains a newline or not.

It only matters whether the mark was before or after the cursor.  When
it was after the cursor, the mark needs to be set to the bottom line of
the grafted text and its x coordinate needs adjustment; and when it was
before the cursor, the mark just needs to be set to the top line of the
grafted text.
2019-04-28 12:18:24 +02:00
Benno Schulenberg 065afe6e0f tweaks: reshuffle a bit of code, to be less intertwined 2019-04-28 11:54:23 +02:00
Benno Schulenberg b9dd572a67 tweaks: set a boolean directly, instead of using a function call 2019-04-28 10:40:37 +02:00
Benno Schulenberg 00410d83fc tweaks: rename a function, to be distinct and fitting
It was hard to remember that the "pt" stood for "plus tabs", and the
"len" seemed to say it was about number of bytes instead of columns.
2019-04-24 10:52:35 +02:00
Benno Schulenberg 34d22d3f00 wrapping: improve the persistence of the prepending behavior
Now you can have a look elsewhere in the buffer (and even delete
or paste stuff there) and when you return to the original line
and continue typing, any spillover from automatic hard-wrapping
will spill over onto the same line it spilled over to before.

You can even switch to a different buffer and return and continue
typing, and stuff will still spill over to the same line.

In the bargain, this gets rid of a bit of flag-resetting code
that was run for many keystrokes, in most cases needlessly.

This addresses https://savannah.gnu.org/bugs/?56189.
2019-04-23 10:20:12 +02:00
Benno Schulenberg 11aa191bdc tweaks: rename a variable, to distinguish it from a browser function 2019-04-22 19:58:43 +02:00
Benno Schulenberg 7668bfe6f2 tweaks: remove a redundant, enclosed #ifdef 2019-04-22 19:18:29 +02:00
Benno Schulenberg 4e52c75568 options: make --breaklonglines work also when --ignorercfiles is used
This fixes https://savannah.gnu.org/bugs/?56179.

Bug existed since version 4.1, commit 167a8e5c.
2019-04-20 14:04:07 +02:00
Benno Schulenberg 286c877853 tweaks: elide an unneeded parameter, as the function already assumes it
The do_wrap() function always gets 'openfile->current' as parameter,
and, internally, it assumes that it is handling the current line.
2019-04-19 09:47:21 +02:00
Benno Schulenberg 167a8e5c09 options: make --nowrap override again a contrary nanorc setting
All other options are off by default and can only be switched *on*
(either by a command-line option or a nanorc setting) -- there are
no command-line options to switch them off again.  Except for the
--breaklonglines/--nowrap pair.  So these need special handling.

This fixes https://savannah.gnu.org/bugs/?56119.
Reported-by: Sébastien Desreux <seb@h-k.fr>

Bug existed since version 4.0, commit 4d40bea5.
2019-04-12 10:35:20 +02:00
Benno Schulenberg 2552307064 options: remove -f (--finalnewline); go back to auto-adding this newline
For relatively inexperienced users (as most users of nano probably are)
it is far better that nano produces POSIX text files by default, where
each line ends with a newline character.  This means that these files
will "print" properly (not gluing the next prompt at the end of the
last line), tools will see and process each line of them, and, while
editing, adding text at the end is easier.

This addresses https://savannah.gnu.org/bugs/?55997.
Reported-by: Ralph Corderoy <ralph@inputplus.co.uk>
2019-04-07 10:02:05 +02:00
Benno Schulenberg 5601b9a66b tweaks: switch back from checking FINAL_NEWLINE to checking NO_NEWLINES
This effectively reverts commit b6a76223 from a good two months ago.
2019-04-07 08:50:35 +02:00
Benno Schulenberg 671db5e1e3 tweaks: rename an overshort type to something that makes some sense 2019-04-03 17:34:05 +02:00
Benno Schulenberg acfee2538e tweaks: rename a cryptic type to something that makes a little sense 2019-04-03 17:11:24 +02:00
Brand Huntsman 32431cddf8 files: block the resizing signal while reading from an external command
A SIGWINCH somehow causes the input stream to see EOT, with the result
that any remaining output of an external program would be lost.

This fixes https://savannah.gnu.org/bugs/?56038,
and fixes https://savannah.gnu.org/bugs/?56033.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2019-04-03 15:14:33 +02:00
Benno Schulenberg aa2568858e tweaks: remove a superfluous check for NULL plus the associated message
The message has been there for a year and no one ever reported seeing it.
2019-04-03 15:11:18 +02:00
Benno Schulenberg 19c82e6a43 feedback: spare the user a superfluous scaring when trying to exit
Also, a simple question is easier to answer than an annotated one.
2019-04-01 19:56:10 +02:00
Benno Schulenberg 3f695b8fb7 speller: resizing can happen also when configured with --enable-tiny
When nano was configured with --enable-tiny --enable-speller, the
block_sigwinch() function should be available, to mask SIGWINCHes
during a spell check.
2019-03-30 19:23:15 +01:00
Benno Schulenberg 6f07f2b444 tweaks: rename a function plus parameter, to stay closer to what it does 2019-03-27 19:46:37 +01:00
Benno Schulenberg 978c121de1 speller: block the resizing signal again during an external spell check
Somehow a SIGWINCH pushes nano past the wait() in do_alt_speller(),
even though the external spelling program hasn't finished.

This fixes https://savannah.gnu.org/bugs/?56010
by reverting commit 1f39f60b.

Bug existed since version 3.2.
2019-03-27 17:43:43 +01:00
Benno Schulenberg b58418b32f tweaks: rename a variable, to be more distinct 2019-03-21 19:21:45 +01:00
Benno Schulenberg cddfcb1b9d tweaks: rename a struct element, to make sense 2019-03-21 17:23:49 +01:00
Benno Schulenberg 6755b7c0a0 tweaks: rename four functions, to make more sense 2019-03-21 17:18:50 +01:00
Benno Schulenberg aac4fc46e9 tweaks: rename a type, to make more sense 2019-03-21 17:08:52 +01:00
Benno Schulenberg 15959346fb tweaks: exclude the guide-stripe code from the tiny version
The option is not available, so including the code is pointless.
2019-03-14 19:34:35 +01:00
Benno Schulenberg 19a833c94e startup: check again for a Linux console after reading all files
When there is a dash among the files on the command line, nano will read
data from standard input, which means that the latter is not connected to
a terminal and thus cannot be recognized as a Linux VT until nano has
finished reading the input and has reconnected the input source to the
terminal.

The first probe for a Linux VT is kept in place for now, so that nano
can stop when there are errors in an rcfile while running on a VT.
(This stopping will not work when data is read from standard input,
of course, but that is a smaller fish.)

This fixes https://savannah.gnu.org/bugs/?55912.
Reported-by: Enrico Mioso <mrkiko.rs@gmail.com>

Bug existed since the recognition of modified cursor keys on a Linux
console was introduced, in version 2.6.3, commit 290d278f.
2019-03-13 19:31:11 +01:00
Benno Schulenberg 20514eca19 feedback: make two error messages better match the option
And keep them identical.
2019-03-11 09:07:08 +01:00
Benno Schulenberg 4240423b9c help: in the tiny version, don't list an option that is the default
And don't recognize it either.
2019-03-10 19:19:31 +01:00
Benno Schulenberg 74752686f4 help: don't list the obsoleted -O and -S options in the --help output
And don't bother to recognize them either.
2019-03-10 19:19:17 +01:00
Benno Schulenberg a20340b5a8 copyright: update the years for significantly changed files 2019-03-10 17:03:42 +01:00
Benno Schulenberg 916b4d81d0 rcfile: add 'stripecolor' for changing the color of the guiding stripe
The default is now simply reverse video, which works better than a
"loud" colored bar in an interface that for the rest is monochrome.
2019-03-09 09:27:08 +01:00
Benno Schulenberg 66c6eb5166 new feature: option --guidestripe that shows a vertical guiding bar
Option -J (--guidestripe) takes a column number as argument and then
shows a vertical, colored bar over the entire height of the buffer,
to aid the user in regulating the width of the text when the terminal
is wider than this desired width.

This fulfills https://bugs.debian.org/916392.
Requested-by: Arturo Borrero González <arturo@debian.org>
And fulfills https://savannah.gnu.org/bugs/?55315.
Requested-by: Bryan Christ <bryan.christ@gmail.com>
2019-03-09 09:27:08 +01:00
Benno Schulenberg 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg 420fe4d1e6 tweaks: switch from checking MORE_SPACE to checking EMPTY_LINE 2019-02-19 19:53:19 +01:00
Benno Schulenberg 322a6f46fa tweaks: switch from checking SMOOTH_SCROLL to checking JUMPY_SCROLLING 2019-02-19 19:52:57 +01:00
Benno Schulenberg b6a762232e tweaks: switch from referencing NO_NEWLINES to referencing FINAL_NEWLINE 2019-02-19 19:45:55 +01:00
Benno Schulenberg 54055b6174 tweaks: switch from referencing NO_WRAP to referencing BREAK_LONG_LINES 2019-02-19 19:45:55 +01:00
Benno Schulenberg cb7c8255f4 options: warn when option -O or -S is given, and ignore them
If these two command-line options would override an rcfile setting of
their counterpart new option, the user might come to expect being able
to do this also in the future.  But these old options will be obsoleted
at some moment, so... better start ignoring them right now.
2019-02-19 19:13:53 +01:00
Benno Schulenberg 894aff0816 options: let --fill no longer imply automatic hard-wrapping
Now --fill only sets the target width for hard-wrapping and justifying,
but automatic hard-wrapping itself is switched on with --breaklonglines.
2019-02-18 09:34:18 +01:00
Benno Schulenberg 556c0a3865 rcfile: when an old flag is unset, set the corresponding new flag
This fixes https://savannah.gnu.org/bugs/?55583.
2019-02-18 09:34:18 +01:00
Benno Schulenberg ee979ae7b3 options: add -e, --emptyline, the counterpart of --morespace 2019-02-18 09:34:18 +01:00
Benno Schulenberg 401e43969c options: add -j, --jumpyscrolling, the counterpart of --smooth 2019-02-18 09:34:18 +01:00
Benno Schulenberg 5dbd9c0043 options: add -f, --finalnewline, the counterpart of --nonewlines 2019-02-18 09:34:18 +01:00
Benno Schulenberg cd9328fbf5 options: add -b, --breaklonglines, the counterpart of --nowrap 2019-02-18 09:34:18 +01:00
Benno Schulenberg ebfe752841 tweaks: rename some variables from a single letter to meaningful word 2019-02-12 16:06:24 +01:00
Benno Schulenberg b89540218d tweaks: add two comments, and reduce the scope of another variable 2019-01-27 11:18:55 +01:00
Benno Schulenberg 77c60201d5 tweaks: reduce the scope of a variable, and rename it 2019-01-27 11:10:29 +01:00
Benno Schulenberg 2482cfca56 build: eradicate the --disable-wrapping-as-root configure option
Hard-wrapping is disabled by default for any user, so this special
configure option is no longer needed.
2019-01-25 11:37:51 +01:00
Benno Schulenberg 946755a307 options: disable hard-wrapping and automatic newlines by default
Also, enable smooth scrolling by default, and don't waste the row
directly below the title bar.  The use of the latter also serves
as a small visual reminder that this nano is different.

This addresses https://savannah.gnu.org/bugs/?55067.
2019-01-25 11:37:21 +01:00
Benno Schulenberg 98b1f8f059 options: stop recognizing and ignoring -b, -e, -f, -j, and -q
This signals our break from trying to be as compatible with Pico as
possible.  We were already incompatible with modern Pico in the -n
and -W options, and in several character-set and color options, so
ignoring those five options brought us very little.

Anyway, soon some of those options will be reused and will have the
effect of making nano look and behave more like Pico.
2019-01-25 11:22:56 +01:00
Benno Schulenberg c5a72103bf justify: extend the quoting regex, to cover more types of comments
Now also comment blocks in Fortran, Lisp, Lua, Postgres, and TeX
can be rewrapped with ^J.

This partially addresses https://savannah.gnu.org/bugs/?55435.
Kind-of-requested-by: David Griffith <dave@661.org>
2019-01-22 17:57:19 +01:00
Benno Schulenberg e1a6f58da6 startup: check that a backup directory is valid also when backups are off
When the user switches backups on later (with M-B in the ^O menu),
the specified folder should have been checked for validity.

This fixes https://savannah.gnu.org/bugs/?55423.

Bug existed since the check for a valid backup directory was introduced
in version 2.8.7, commit 751e7f0f.
2019-01-10 20:31:48 +01:00
Benno Schulenberg f74a120803 tweaks: refer to the magic line as "magic line", not as "magicline" 2019-01-06 15:35:31 +01:00
Benno Schulenberg b596639f95 options: actually rename --rebindkeypad to --rawsequences (-K) 2018-12-31 18:35:46 +01:00
Benno Schulenberg 34b8d58871 rcfile: reject an attempt to bind ^[
Also, for <Esc> <Esc> [, report that it is unbindable.

This fixes https://savannah.gnu.org/bugs/?55336.
2018-12-30 19:47:43 +01:00
Benno Schulenberg 125cc0cd74 tweaks: elide a tiny function by making a variable global
And in the bargain it makes things clearer, because the name
cutbuffer_reset() is misleading.
2018-12-30 13:36:29 +01:00
Benno Schulenberg afab65e8a8 tweaks: elide a parameter that is always TRUE
The parameter was made redundant by David's overhaul of the
justification code.
2018-12-30 12:48:26 +01:00
Benno Schulenberg d3c0fe3923 options: make --rawsequences disable --mouse, to prevent entering junk
When using --raw, ncurses does not catch and convert any mouse event,
and thus the coordinates of a mouse click would get inserted into the
buffer as seemingly random characters.  So, let --rawsequences override
and disable --mouse, to prevent the accidental entering of junk.

This fixes https://savannah.gnu.org/bugs/?55303.
2018-12-28 19:15:20 +01:00
Benno Schulenberg 997826d794 tweaks: rename a symbol, to match its corresponding option 2018-12-28 17:47:03 +01:00
David Lawrence Ramsey 77bd8c2630 tweaks: swap the names of the variables 'wrap_at' and 'fill'
Now 'fill' contains the original specified value,
and 'wrap_at' the column that 'fill' translates to.
2018-12-18 19:50:59 +01:00
Benno Schulenberg 3121ee4b2e options: stop recognizing and mentioning --quiet and 'set quiet'
Those options have been a no-op and obsolete for over a year.

Just continue to accept and ignore -q, for some "compatibility"
with Pico.
2018-12-18 19:29:40 +01:00
Benno Schulenberg 38ca2a41f4 tweaks: reduce the scope of two variables, and rename one of them
Also, swap the order of the 'if', and don't bother setting a freed
string pointer to NULL as it will never be used again.
2018-12-11 10:59:12 +01:00
David Lawrence Ramsey 6e3b9ac058 options: exit on a bad quoting regex, instead of crashing later
The paragraph-jumping functions used the regex unverified...

This fixes https://savannah.gnu.org/bugs/?55169.
2018-12-11 10:29:29 +01:00
Benno Schulenberg 7dad21f4f4 tweaks: don't bother asking ncurses for keycodes for shifted Left/Right
These modified keys have codes by default: KEY_SLEFT and KEY_SRIGHT.
It's just the shifted Up/Down keys that don't have default codes.
2018-11-06 19:18:54 +01:00
Brand Huntsman 252f14796e bindings: hard-bind the zap function to M-Del (Alt+Delete)
So that the function is available in a default setup.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:47:03 +01:00
Brand Huntsman ae3ec1784d options: add --zap, that makes <Bsp> and <Del> erase a marked region
Using --zap or -Z on the command line, or 'set zap' in a nanorc file,
makes the <Bsp> and <Del> keys erase selected text (a marked region)
as they do in some other editors, and without affecting the cutbuffer.

This fulfills https://savannah.gnu.org/bugs/?54837.
Requested-by: Liu Hao <lh_mouse@126.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-11-04 11:46:57 +01:00
Benno Schulenberg e9ba058f3d tweaks: elide a function that is used just once and is a oneliner 2018-10-30 19:34:03 +01:00
Benno Schulenberg 5be94a3bbe debug: report for which modified editing keys ncurses has no keycode 2018-10-30 19:01:39 +01:00
Benno Schulenberg 63f2be7a2f options: let view mode activate "multibuffer" to allow viewing more files
When --view is used without --ignorercfiles, the user could view
other files anyway if they had 'set multibuffer' in their nanorc.
So, just make this the default when --view is used, also because
"multibuffer" cannot be toggled once nano is running in view mode.

When the viewing of other files in view mode should not be allowed,
one should now additionally use --restricted.
2018-10-23 19:15:27 +02:00
Benno Schulenberg 5c5806bbe7 wrapping: make the --fill option override 'set fill' again
This completes the reverting of commit e90b7cf4 as intended by the
previous commit.
2018-10-21 17:24:20 +02:00
David Lawrence Ramsey 16a3dc90c7 wrapping: make relative fill values work again also for screen resizes
The 'wrap_at' variable, removed in commit e90b7cf4, is actually needed
to store the original value of the --fill option when it is negative.
Otherwise, changing the screen width will not update the wrapping point
properly.

This fixes https://savannah.gnu.org/bugs/?54861.
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-10-18 20:35:49 +02:00
Benno Schulenberg 769a0e661f tweaks: reduce some repetitious and superfluous comments to just one
The code itself is clear enough.
2018-10-16 19:22:40 +02:00
Benno Schulenberg b167444ee8 tweaks: remove a check that was made redundant by the previous commit
The previous commit also fixes https://savannah.gnu.org/bugs/?54650,
so the change that was made to address that bug can be removed.
2018-10-12 12:23:44 +02:00
Benno Schulenberg 6b08648377 feedback: give proper message for ^R when combining --view & --restricted
When using --view --multibuffer --restricted, it is the latter option
that forbids reading in another file, so that is what the status bar
should say.

This fixes https://savannah.gnu.org/bugs/?54824.

Bug existed since version 2.9.5, commit 8b8c6bb8.
2018-10-12 12:04:39 +02:00
Benno Schulenberg f9134af504 docs, usage: mention that --showcursor now covers help texts too 2018-10-07 10:38:11 +02:00
Benno Schulenberg 826be439db bindings: make the Shift+arrow keys work by default on more terminals
Ask ncurses for the codes for the Shift+arrow keys, so that also
<Shift+Up> and <Shift+Down> can be recognized, for which ncurses
doesn't have standard codes.

This fixes https://savannah.gnu.org/bugs/?54790.
Reported-by: Javier Valencia <javiervalencia80@gmail.com>
2018-10-07 10:17:10 +02:00
Benno Schulenberg fb8d981bfa tweaks: exclude word-deletion keystrokes from the tiny version
Because word deletion is not available there.
2018-10-05 19:24:38 +02:00
Benno Schulenberg 9c2b67231e tweaks: rename a flag, to match the name of the option 2018-10-02 19:18:55 +02:00
Benno Schulenberg b81995af8a options: --ignorercfiles is now available in restricted mode
Also, allow syntax highlighting to be toggled in restricted mode,
and adjust a comment.
2018-10-02 19:18:55 +02:00
Benno Schulenberg 339e0c131a tweaks: rename a bunch of variables, to make it clearer what they contain 2018-10-02 19:18:55 +02:00
Benno Schulenberg 2ee2407e63 tweaks: reshuffle some lines, to put things in order of option name 2018-10-02 19:18:55 +02:00
Benno Schulenberg 5ca444e5df startup: allow reading nanorc in restricted mode, to permit customization
Move the unsetting of some options further down, to prevent the user's
nanorc enabling things that are not permitted in restricted mode.

Also, in restricted mode, suppress error messages about functions not
being present in the requested menus, so that a nanorc that is valid in
normal mode does not cause unnecessary messages when using --restricted.

This fulfills https://savannah.gnu.org/bugs/?54732.
Requested-by: Mark Webb-Johnson <mark@webb-johnson.net>
2018-10-02 19:18:55 +02:00
Benno Schulenberg 062b6691bb tweaks: drop the checking of two flags that can no longer be toggled
Also, remove a superfluous condition, and swap two others.
2018-09-30 13:11:43 +02:00
Benno Schulenberg 0b63de335e tweaks: elide a wrapper function that is no longer useful 2018-09-28 20:09:12 +02:00
Benno Schulenberg 8d0b7a490d undo: move another piece of checking to the two places that need it
And in the bargain get rid of a function that is used just once.
2018-09-26 19:25:21 +02:00
Benno Schulenberg 1f39f60b2f tweaks: there is no reason to block SIGWINCHes while waiting for speller
In the past, SIGWINCHes were responded to immediately (which was madness),
but since commit 75d64e67 all a SIGWINCH does is set a flag so that, when
the time comes to update the screen, nano knows the dimensions may have
changed.  The mentioned commit removed most blockings and unblockings of
SIGWINCH, but not this one.
2018-09-23 14:07:36 +02:00
Benno Schulenberg 368ec04870 build: fix compilation again when configured with --enable-tiny
Reported-by: Jordi Mallach <jordi@mallach.net>
2018-09-19 20:36:39 +02:00
Benno Schulenberg eaeafe29ca suspension: don't try to show the cursor position when going to sleep
As the statusbar() function will write the position directly to the
terminal when not in curses mode, the final part of this position
message will seem to be after the prompt when exiting from nano.

The cursor position will get written correctly to the status bar
anyway, because returning from suspension enters a fake key into
the keyboard buffer, and this key elicits an update of the display.

This fixes https://savannah.gnu.org/bugs/?54639.
Reported-by: Lauri Kasanen <cand@gmx.com>

Bug existed since version 2.4.2, commit 75d64e67.
2018-09-13 19:55:20 +02:00
Benno Schulenberg fe3a72ce3e main: allow toggling all editor features when in view mode
Most of these toggles just change the appearance of things, and
all of them are harmless -- none of them modify the contents of
the buffer.

This fixes https://savannah.gnu.org/bugs/?54650.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 2.9.4, commit 54103d8e.

(The offending commit meant in the previous commit was 60f1090d.
My mistake.)
2018-09-12 19:54:32 +02:00
Benno Schulenberg 09ab2e3d0e bindings: when Ctrl+Shift+Delete has no keycode, don't use KEY_BSP
When curses gives no code for Ctrl+Shift+Delete, do not fall back
to KEY_BACKSPACE, because then ^H and/or <Backspace> get bound to
'cutwordleft'.

This fixes https://savannah.gnu.org/bugs/?54642.

Bug was introduced with version 3.0, commit e6429e78.
2018-09-12 14:34:50 +02:00
Benno Schulenberg e6429e782a bindings: hard-bind <Ctrl+Shift+Delete> to 'cutwordleft'
On FreeBSD and NetBSD (when reached through ssh from a Linux machine)
this has the absurd effect of making <Ctrl+Backspace> do a 'cutwordleft'
by default, out of the box, without needing any rebindings.  Weird, but
wonderful, because the ideal behavior.

Also ensure that <Shift+Delete> always does a Backspace.

This makes that we have the following set of "congruent" keys:

  <Tab> moves text to the right,
  <Shift+Tab> moves text to the left,
  <Delete> "eats" a character to the right,
  <Shift+Delete> "eats" a character to the left,
  <Ctrl+Delete> "eats" a word to the right,
  <Shift+Ctrl+Delete> "eats" a word to the left.
2018-09-07 19:31:38 +02:00
Brand Huntsman 3270aac7db input: give feedback for all unbound keys also in the help viewer
Silently doing nothing robs the user of a bit of information.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-09-01 10:05:23 +02:00
Benno Schulenberg 63b15275bd bindings: remove the More-Space toggle entirely
It is so unlikely that a user will want to bind it that it
just clutters the help text (and the documentation).
2018-08-25 10:10:27 +02:00
Benno Schulenberg 3218d8358a tweaks: remove a redundant "struct" word, and replace it in comments 2018-08-20 19:33:31 +02:00
Benno Schulenberg a3a10dfafe tweaks: don't bother having debug code that deallocates all memory
Who runs debug builds for any length of time?
2018-08-18 11:00:03 +02:00
Benno Schulenberg 4170454837 tweaks: exclude a global flagging variable when it is not needed 2018-08-05 13:00:44 +02:00
Benno Schulenberg e90b7cf4aa tweaks: elide an unneeded/duplicate variable 2018-08-04 11:34:44 +02:00
Marco Diego Aurélio Mesquita a67f6c6031 input: erase the next word when Ctrl is held while pressing Delete
Bind the until-now unbound function 'cutwordright' to <Ctrl+Delete>.
The complementary function, 'cutwordleft', is not bound by default
because on many terminals the keystroke <Ctrl+Backspace> generates
^H -- the canonical ASCII backspace character.  We cannot change the
existing action of ^H without upsetting some users.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-07-22 19:27:50 +02:00
Benno Schulenberg c46696d40c tweaks: delete some old debugging code that no longer seems useful 2018-07-18 19:53:44 +02:00
Benno Schulenberg 063a8b0870 startup: show the correct number of lines when opening multiple files
When switching to a different buffer, don't just show its name but
also the number of lines it contains.  This is useful extra info.

Then use this same message when at startup multiple files are opened
and (after reading them all) we switch back to the first buffer.

(This loses, when multiple files are opened, the information about
format conversion that nano still shows when a single file is opened,
but... this bug has shown that people don't really look at this line
anyway, so... let it be.  The info can still be seen when writing out
the file with ^O.)

This addresses https://savannah.gnu.org/bugs/?54047.
2018-07-13 09:37:04 +02:00
Benno Schulenberg 769504c495 tweaks: rename a function, to better state what it does 2018-07-11 11:03:14 +02:00
Benno Schulenberg 430d3bad7a debug: add some code to time the performance of get_totsize()
Don't activate this by passing --enable-debug.  Just remove the
relevant #ifdefs when you want to test the performance of changes
in the counting code.
2018-06-03 20:06:28 +02:00
Benno Schulenberg 71f859377d cut: concentrate the logic for clearing the cutbuffer mostly in one place
It should not be the task of the undo code to take care that the
cutbuffer will be cleared at the right moments.
2018-06-02 17:57:19 +02:00
Benno Schulenberg 2e1e157967 copyright: update the years for significantly changed files 2018-06-01 10:18:32 +02:00
Benno Schulenberg 856322b01e main: interpret only a double slash (//) as quoting, not a single one
Otherwise the first line of a multiline /*...*/-comment would be
seen as quoted and thus *not* as the first line of a paragraph.

In the code, use "/{2}" to prevent the remainder of the line
getting colored as a comment.
2018-06-01 09:21:03 +02:00
Benno Schulenberg cd8e932c65 main: add "/" to the quoting regex, to allow justifying //-comments
And adjust the documentation accordingly.
2018-05-27 20:29:52 +02:00
Benno Schulenberg b9f533a69e tweaks: rename a function, for more aptness and extra contrast 2018-05-25 20:09:24 +02:00
Benno Schulenberg 86c08560ad linter: make sure that the margin is updated before displaying a buffer
This fixes https://savannah.gnu.org/bugs/?53977.
Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-25 17:58:25 +02:00
Benno Schulenberg c07586d9f3 tweaks: condense some repetitious comments, and check before assigning
Check that the option argument is okay (contains no blank characters),
before assigning it to the relevant variable.
2018-05-24 20:49:29 +02:00
Benno Schulenberg 299e710845 docs, usage: make it clear that the argument of --quotestr is a regex
In the past, the argument could be either a regex or a literal string,
so the wording was kind of vague.  But nowadays we can count on having
regex support (through gnulib), so be more precise in the description.
2018-05-22 18:45:58 +02:00
Benno Schulenberg d9ba6c10d2 tweaks: give some continuation lines a more obvious indentation
Also, put a translator hint in a better place: not in the middle
of a function call.
2018-05-22 18:07:50 +02:00
Benno Schulenberg 03c184d7f2 tweaks: condense a comment, and elide an unneeded 'if' 2018-05-22 18:01:15 +02:00
Benno Schulenberg 4ec19847a3 startup: provide a hint for people unfamiliar with the ^char convention
But give this hint only when nano was started without any file arguments.
2018-05-22 11:53:17 +02:00
Benno Schulenberg ae1ba5e259 tweaks: put check for -h and -l options in their alphabetical positions
And put the Pico-compatibility flags last, as normally they are never
given.
2018-05-12 19:56:37 +02:00
Benno Schulenberg 87283711ee tweaks: improve a couple of comments 2018-05-10 18:10:23 +02:00
Benno Schulenberg 2d5c917b1a signals: exclude the crash handler from the tiny version
The tiny version contains much less code, so is less likely
to crash.  And the users most likely use it for very simple
and short editing jobs, making the chance of a crash still
smaller.  So the handler would just be bloat.
2018-05-10 12:21:53 +02:00
Benno Schulenberg 95002da66c tweaks: normalize indentation and whitespace after previous changes 2018-05-10 11:33:24 +02:00
Mark-Weston 858663444e new feature: an option to make the 'nextword' function stop at word ends
When 'afterends' is set and Ctrl+Right or Shift+Ctrl+Right is pressed,
nano will stop at the ends of words instead of their beginnings.

Signed-off-by: Mark-Weston <markweston@cock.li>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-05-10 11:32:01 +02:00