Commit Graph

1570 Commits (abd4c47acf4ec71a3eb142e44493d29ba1201465)

Author SHA1 Message Date
Benno Schulenberg 2e9fb7d840 build: exclude option --tabsize (-T) from the tiny version
An unneeded option when wanting nano to be small.  Excluding it saves
roughly 120 bytes.  It also makes the output of --help nice and clean.
2020-10-03 11:25:43 +02:00
Benno Schulenberg a4e3d88c67 version: remove URL and email address from the --version output
Web links and email addresses do not belong in the version information.
This has bothered me for a long time.  The URL is in the man page, and
bug reports should go to Savannah.
2020-10-02 10:23:40 +02:00
Benno Schulenberg 072c8aa39b options: move --stateflags (-%) and --magic (-!) to the end of the list
It's nicer to start the list with -A, -B, -C.  And, when the user
does 'nano --help', these new flags are more likely to be noticed.
2020-10-01 11:24:39 +02:00
Benno Schulenberg 5bd92d4c60 options: add -? as a synonym of -h (--help), but leave it undocumented
This option was lost six years ago in commit 43019189, without giving a
reason for it.  It's not really needed, but it doesn't hurt to have it.
2020-10-01 10:45:22 +02:00
Benno Schulenberg d6c194265f build: exclude excessive version information from the tiny version
The tiny version is about being tiny.  Copyright information and
website links are not essential.
2020-10-01 10:44:37 +02:00
Benno Schulenberg 58a3293efc options: require --magic or 'set magic' to enable the use of libmagic
Trying to determine which syntax to apply with the help of libmagic
can be a somewhat time-consuming and yet often still fruitless affair.
Therefore using libmagic should not be the default; it should require
an option to tell nano to try using libmagic when it can't determine
the applicable syntax from the file's name or first line.

This is better than having a --nomagic option (and using libmagic by
default), because when the user has 'set nomagic' in their nanorc or
--nomagic in their alias, then switching the use of libmagic back on
is troublesome.  But with --magic (and not using libmagic by default),
when nano fails to recognize a file, it is a simple ^X, add -! to the
command line, and restart.

The short form of the option is -! because we have run out of letters.

This addresses https://savannah.gnu.org/bugs/?59028.
2020-09-25 16:34:01 +02:00
Benno Schulenberg d679bbc802 new feature: option --stateflags to show some states in top-right corner
With --stateflags (short form: -%) or 'set stateflags', nano reserves
the righthand end of the title bar not for showing "Modified" but for
showing the state of auto-indentation (I), the mark (M), the breaking
of long lines (L), macro recording (R), and softwrapping (S).

When the buffer is modified, this is indicated with a star (*) after
the file name (shown in the center of the title bar).

This fulfills https://savannah.gnu.org/bugs/?57953.
Requested-by: Sébastien Desreux <seb@h-k.fr>
2020-09-23 19:48:03 +02:00
Benno Schulenberg c3e74f02c2 build: exclude --emptyline, --jumpyscrolling, and --noread from tiny nano
When looking at the output of 'nano --help', why confuse the user with
a cosmetic option, an awkward behavioral one, and an obscure one?
2020-09-21 19:02:07 +02:00
Benno Schulenberg 89f8d71001 feedback: don't give a hint for <Bsp>, and not after an Alt+key was used 2020-09-19 12:15:07 +02:00
Benno Schulenberg 37f1d43ce3 tweaks: elide a one-line function, after reducing it to a single call 2020-09-18 15:22:12 +02:00
Benno Schulenberg cb841de3fc feedback: make an "Unbound key" message disappear on the next keystroke
When nano reports "Unbound key" or "Unknown sequence", this message
should stay onscreen only for the relevant keystroke, not for any
succeeding keystroke.

This addresses https://savannah.gnu.org/bugs/?59119.

Bug existed since before version 2.0.6.
2020-09-17 19:36:04 +02:00
Benno Schulenberg e12f397140 build: do not let Slang translate escape sequences to key codes
Slang fails to translate the longer sequences, and then truncates
these sequences to just four bytes, effectively destroying them.

Therefore, when built with --with-slang, always activate --raw-sequences.

This avoids https://savannah.gnu.org/bugs/?49771.

Bug was visible since version 2.5.0, since bindings
for Ctrl+Left/Ctrl+Right were added.
2020-09-17 16:54:41 +02:00
Benno Schulenberg e8abbc7045 build: stop using an obsolete macro, and use 'void' for signal handlers
The Autoconf manual says that 'AC_TYPE_SIGNAL' is obsolete and
that it is fine to simply use 'void' instead of 'RETSIGTYPE'.
2020-09-16 16:27:32 +02:00
Benno Schulenberg 93b25ce014 tweaks: adjust some whitespace in the docs, and improve a comment 2020-09-12 12:21:24 +02:00
Benno Schulenberg f883465263 build: exclude reading a file from standard input from the tiny version
The tiny version is about being small, not about convenience features
that hardly anyone uses anyway.

Also exclude the description of the "+line[,column]" feature -- it is
unneeded verbosity.

This addresses https://savannah.gnu.org/bugs/?59101.
2020-09-12 11:44:22 +02:00
Benno Schulenberg b9a1a586c0 display: force the cursor to reappear in a better way (when using Slang)
The cursor would disappear after any message on the status bar --
for example, also when M-W is typed and nothing is found -- so the
mitigation trick needs to be performed in statusline() itself.

This addresses https://savannah.gnu.org/bugs/?59091.
2020-09-11 18:54:49 +02:00
Benno Schulenberg d2d0c665b1 display: force the cursor to reappear after a message (when using Slang)
For some reason, when running a tiny nano built with Slang on the bterm
of a Debian installer image, the cursor disappears when certain things
are written to the status bar.  Make the cursor reappear by rewriting
the two help lines with dummy items (and then rewriting it again with
the normal menu in the central loop).  Of course, this does not help
when the user uses -x or --nohelp to suppress the help lines, but at
least in the default setup the cursor doesn't get hidden now and then.

This mitigates https://savannah.gnu.org/bugs/?59091.

Bug existed since before version 2.2.4.
2020-09-10 18:46:48 +02:00
Benno Schulenberg dd24f6a18d suspension: resume properly from an external SIGSTOP (when using Slang)
Slang apparently needs a call to SLsmg_refresh() to restore the screen
content and put the cursor in the right place.  But call this function
only when the suspension was actually caused by an external SIGSTOP,
because otherwise the original screen (from which nano was invoked)
gets plastered with nano's interface and content -- upon exit, this
is annoying and confusing.

Do not stuff a dummy keystroke into the input stream, as it seems to
get placed *after* the first byte of the next keystroke from the user.
That would cause an "Unknown sequence" for some keystrokes.

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

Bug existed since version 2.8.5, commit 84ff9ebb.
2020-09-08 16:54:06 +02:00
Benno Schulenberg 462e9d4822 suspension: switch off flow control at the right moment (for Slang)
This fixes https://savannah.gnu.org/bugs/?59078.

Bug existed since version 4.8, commit c09e96f2.
2020-09-08 09:15:12 +02:00
Benno Schulenberg 9f20fadee1 tweaks: normalize the indentation after the previous change 2020-09-07 11:44:29 +02:00
Benno Schulenberg 0f7a309adc suspension: properly resume from an external SIGSTOP
Trying to ignore an external SIGSTOP/SIGTSTP with SIG_IGN does not work,
so always install the SIGCONT handler so that it is possible to continue
from a SIGSTOP.

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

Bug existed since before version 2.0.6.
2020-09-07 11:26:04 +02:00
Benno Schulenberg 46e769a113 rcfile: add 'set scrollercolor', for changing the color of the indicator
This fulfills https://savannah.gnu.org/bugs/?59041.
2020-09-02 19:55:24 +02:00
Hussam al-Homsi c87bc1d55f tweaks: stop casting the return of malloc() and friends
Those casts are redundant, and sometimes ugly.  And as the types of
variables are extremely unlikely to change any more at this point,
the protection they offer against miscompilations is moot.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-08-31 12:17:27 +02:00
Benno Schulenberg 51f27d3f0c input: hold on to a shift-selected region when an unbound key is struck
There is no reason to deselect the region, as nothing has changed.

(This also retains the shift-selected region when a non-shortcut key is
typed in view mode, which makes sense, as again nothing was changed.)

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

Bug existed since version 4.9, commit 0ed62e84.
2020-08-19 08:36:00 +02:00
Benno Schulenberg 8b2114a25f rcfile: allow to bind M-[ (even though it is an escape-sequence starter)
The user had better avoid using the keystroke in a macro, but
when typing directly at a responsive machine there is no problem,
M-[ is a perfectly valid and recognizable keystroke.

This fulfills https://savannah.gnu.org/bugs/?58820.
2020-08-04 17:28:16 +02:00
Benno Schulenberg e59a0f5e77 build: replace the non-standard backslash escape "\e" with "\x1B"
Older compilers do not understand "\e".  Also, it's not in the standard
(see http://open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf, §6.4.4.4).

This addresses https://savannah.gnu.org/bugs/?58799.
Reported-by: Henry Bent <henry.r.bent@gmail.com>
2020-07-22 09:17:57 +02:00
Benno Schulenberg dcd34b246a tweaks: move a function to the file where it is used the most
Also, fully exclude the function from the tiny version.
2020-07-19 10:43:26 +02:00
Benno Schulenberg 1388af2bdc tweaks: elide a wrapper function, by checking a precondition earlier 2020-07-03 12:41:40 +02:00
Benno Schulenberg 2e6886406c tweaks: elide an unneeded global variable
The constant cursor display must be suppressed whenever a message
was printed to the status bar.  That is: whenever 'lastmessage' is
something other than 'VACUUM'.
2020-07-03 12:41:40 +02:00
Benno Schulenberg 712f68c697 options: add -O/--bookstyle to make leading whitespace mean new paragraph
Before version 2.9.8, nano would consider any line that started with
leading whitespace as the beginning of a new paragraph, and would thus
be unable to justify an indented piece of text (unless autoindent was
switched on).  I thought that this was too limiting and changed the
way nano detects and parses paragraphs.  It works fine in texts where
paragraphs occupy multiple lines, but breaks down for paragraphs of
a single line: nano merges those with adjoining lines.

Now, when -O or --bookstyle or 'set bookstyle' is used, nano will again
consider a line that begins with whitespace as the start of a paragraph
-- when 'autoindent' is OFF.

This addresses https://savannah.gnu.org/bugs/?57402.
Indirectly-reported-by: Sébastien Desreux <seb@h-k.fr>
Also-reported-by: Bill Kendrick <nbs@sonic.net>
2020-06-27 11:12:21 +02:00
Benno Schulenberg 096e36279f build: fix compilation for --enable-tiny --enable-color --enable-nanorc 2020-06-22 14:03:48 +02:00
Benno Schulenberg 90f6342fd1 tweaks: rename two header files, to be distinct and not an abbreviation 2020-06-20 12:09:31 +02:00
Benno Schulenberg d67faa2bb5 tweaks: remove a superfluous global variable
There were no calls of statusbar() or statusline() before curses mode
was entered.  But since the previous commit curses mode is entered
even earlier, so...
2020-06-14 13:09:23 +02:00
Benno Schulenberg 24cdf78a93 startup: enter curses mode before reading the nanorc files
This way the COLORS variable will be set when the nanorc files specify
interface colors, so that "light" will work for them.
2020-06-14 12:57:46 +02:00
Benno Schulenberg 926bc6751e startup: check stdout instead of stdin when probing for a Linux console
This way we don't have to probe twice, and the result is accurate also
when nano is reading data from standard input.  Standard output should
always be connected to a terminal, as nano is not meant to operate
without a screen.
2020-06-14 10:52:42 +02:00
Benno Schulenberg b535714671 tweaks: reshuffle a statement, to have major initialization in nano.c 2020-06-11 16:48:52 +02:00
Benno Schulenberg a2b85e0c12 indicator: recompute the extra rows also when justifying and resizing
And when the margin changes (when line numbers are switched on or off,
or when the buffer grows or shrinks), and when a piece of text from a
different buffer with a different margin is pasted.

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

Bug existed since commit 9a9f36fc from yesterday.
2020-06-07 12:16:15 +02:00
Benno Schulenberg 9a9f36fca7 indicator: rework how the "scrollbar" is computed when softwrapping
Instead of storing for each line the ordinal number of the first chunk
in that line, simply store the number of extra chunks in the line.

It now takes some more computation to actually draw the scrollbar, but
it saves a lot of computation when just inserting or deleting characters
(when using --softwrap and causing a change in chunk count).

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

Bug existed since commit 6bccedb3 from two days ago.
2020-06-06 19:21:23 +02:00
Benno Schulenberg 00d4a06cc7 tweaks: group the exiting routines together, and condense the comments 2020-06-05 19:10:36 +02:00
Benno Schulenberg 2aec478ea6 tweaks: elide an unneeded parameter, and rename the other 2020-06-05 17:23:52 +02:00
Benno Schulenberg ae7f5ebdeb tweaks: move a function to before the one that calls it 2020-06-05 17:14:38 +02:00
Benno Schulenberg bea5e85f3e tweaks: make an error message more accurate and reduce it to its essence
There is no need to be explicit about not having saved the buffer --
it is implied in the "Too many".  And anyway, no one is ever going to
see this message -- who will have a hundred thousand .save files?
Trimming this message makes the tiny version smaller.

Also, rewrap a neighbouring line.
2020-06-05 12:19:42 +02:00
Benno Schulenberg 8e7b869cd9 options: add --indicator and -q for switching on the scroll-bar thing
By default, the position indicator is off.  It can be turned on
by passing -q or --indicator on the command line, or by adding
'set indicator' in your nanorc file.
2020-06-04 18:52:28 +02:00
Marco Diego Aurélio Mesquita 6bccedb319 display: support the position indicator also when --softwrap is used
A new member ('chunk_nr') is added to each 'linestruct', to store
the serial number of the first chunk of that line, so that, when
softwrap is on, the scroll-bar thing can be computed relative to
chunks instead of relative to actual lines.

To guarantee that 'chunk_nr' is correctly synced, the buffer is
renumbered whenever the number of chunks in a line changes, and
also when softwrap is toggled on, and when buffers are switched.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-06-04 18:52:28 +02:00
Benno Schulenberg b33a62af8c new feature: a position-plus-portion indicator on the righthand side
This displays a scrollbar-like thing on the right edge of the screen,
giving a rough indication where in the buffer the text that is being
shown in the viewport is located, and how large/small a portion of
the buffer this text is.

(Support for softwrapping, and an option to turn the indicator on,
will arrive in subsequent commits.)

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

Original-patch-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2020-06-04 18:52:28 +02:00
Benno Schulenberg c5b0e1958a feedback: beep also at a prompt when receiving an unknown escape sequence
Nano would beep (and report "Unknown sequence") only when in the main
edit window, in the help viewer, or in the file browser.  But the same
keystroke at a prompt would be enigmatically silent.

Also, in the file browser, nano would leave the cursor at the end of
the "Unknown sequence" message when --showcursor was used.

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

Bug existed (in this form) since around version 2.7.4,
and in a worse form since around version 2.3.5.
2020-06-03 17:15:51 +02:00
Benno Schulenberg 19a124e806 display: avoid an additional redrawing when redrawing the screen
When resizing the screen or toggling the help lines or refreshing
the screen with ^L, what used to be total_refresh() would first call
what used to be total_redraw(), to tell ncurses to redraw whatever
had been on the screen so far, before proceeding to fully redraw the
content of the title bar and the edit window and the bottom bars.
That was duplicate work.

Thus, rename total_redraw() to total_refresh(), so that ^L in the
edit window, help viewer, and file browser will redraw the screen
just once.  This also preserves whatever was on the status bar
(when --quickblank isn't used).

Rename the old total_refresh() to draw_all_subwindows() and call
this routine when resizing the screen or toggling the help lines
or returning from the credits crawl.
2020-06-01 09:40:09 +02:00
Benno Schulenberg 7bad92c50b bindings: add ^Z (Suspend) to the "Execute Command" menu
This makes suspension more discoverable, and allows the user to rebind
^Z in the main menu without losing the ability to suspend nano.

This drops the ^X (Flip Execute) toggle from the menu -- keeping it
would make an ugly uneven number and would reduce the space for each
menu item too much (clipping "Full Justify" and "Cut Till End") --
but it is still present as a blind toggle.
2020-05-30 18:56:58 +02:00
Benno Schulenberg 933dd567de tweaks: separate a symbol from its definition by two spaces
It's a little clearer, and new ones were like that already.
2020-05-29 18:45:14 +02:00
Benno Schulenberg 6d00e75dc2 tweaks: rename a function, to be more correct 2020-05-28 16:59:50 +02:00
Benno Schulenberg 756b95748b tweaks: rename a struct element, to be shorter and preciser
And anyway, there are too many occurrences of 'current'.
2020-05-28 14:38:48 +02:00
Benno Schulenberg d909291b0c tweaks: rename one of the flag symbols, to be clearer
I kept understanding 'BACKUP_FILE' as a noun instead of as an imperative.
2020-05-25 18:52:09 +02:00
Benno Schulenberg 2c5045bfce feedback: skip wiping the prompt bar when the shortcut printed a message
When, at a prompt, the user chose a function shortcut instead of typing
an answer, and this function printed some message to the status bar,
then we do not want to wipe this message.  Also: the message overwrote
and cleared the prompt bar, so there is no need to wipe the latter.

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

Bug existed since version 4.0, since justifying started giving feedback
(or rather since version 4.1, since M-J no longer crashed).
2020-05-22 12:12:36 +02:00
Benno Schulenberg c9482bcd2b display: do not try to draw content when there is no open buffer yet
Commit b63c90bf avoided creating an empty buffer before asking the
yes-no question when encountering a lock file at startup, but the
SIGWINCH code still expected to have an open buffer whose contents
to show.

This fix also has the pleasant effect that, when resizing the screen
at the lock-file yes-no prompt, the title bar doesn't suddenly appear.

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

Bug existed since version 4.9, commit b63c90bf.
2020-05-21 09:24:02 +02:00
Benno Schulenberg 0f2dd8456f usage: unabbreviate option arguments where possible
And make it clearer what kind of argument is expected:
digits, characters, or a program name.
2020-05-14 17:27:15 +02:00
Benno Schulenberg 15fadd700a tweaks: rename a function, to be more precise, and reshuffle it 2020-05-13 12:43:22 +02:00
Benno Schulenberg f9ff902bbc tweaks: drop two redundant conditions, and improve three comments 2020-05-08 11:06:43 +02:00
Benno Schulenberg 95c966c3fc tweaks: do the saving of histories in a single place
Also, when finish() is called when the user presses Cancel upon
encountering a lock file, there is no need to save any history
files because nothing has changed.
2020-05-08 11:01:37 +02:00
Benno Schulenberg 982e226c3f tweaks: elide three parameters, as they are the same for both calls 2020-05-08 10:40:03 +02:00
Benno Schulenberg ad1331527e color: when syntax coloring is toggled back on, calculate multiline data
This will not catch all cases, but at least it will precalculate the
data when syntax coloring was toggled off (M-Y) while in one buffer
and then toggled back on after having switched to a new buffer.
2020-05-01 14:08:55 +02:00
Benno Schulenberg b9deb883fa tweaks: shorten the name of a symbol, to match its bindable function 2020-05-01 13:25:15 +02:00
Benno Schulenberg d4ee6a2b53 options: rename --tempfile to --saveonexit, to be far clearer
A long option should describe what it does, not vaguely hint at it.

Also, in several places of nano's code we deal with actual temp files,
and then having a flag called TEMP_FILE that doesn't have anything to
do with temp files is somewhat confusing.
2020-04-30 19:12:54 +02:00
Benno Schulenberg 4710b94cfb tweaks: move a function to before the one that calls it 2020-04-29 12:22:02 +02:00
Benno Schulenberg 5ca2fd887a startup: initialize colors only when the terminal is capable of colors
This avoids trying to show colors on a vt100, for example.
2020-04-29 12:07:31 +02:00
Benno Schulenberg d1e1438ca0 tweaks: delete some unneeded code, and rename the function accordingly
When set_colorpairs() is called, no files have been loaded yet, so
no syntaxes will have been loaded yet either.  Thus it is pointless
to run through the list of available syntaxes.
2020-04-28 16:49:45 +02:00
Benno Schulenberg bc4240dda5 tweaks: rename a function, to better describe what it does
Its major function is to find an applicable syntax, if there is any.
And if the syntax hasn't been used before, to prime its color pairs.

Also, reshuffle a line to be able to elide an #ifdef.
2020-04-28 16:34:45 +02:00
Benno Schulenberg 40053593a8 general: rename "bookmark" to "anchor", to sound less permanent 2020-04-13 11:25:29 +02:00
Benno Schulenberg 732cf88786 text: retain a bookmark when two lines are joined or something is cut
Also, do not copy the bookmark into the cutbuffer, so it will not get
pasted elsewhere.
2020-04-13 11:10:23 +02:00
Marco Diego Aurélio Mesquita 9fb0beca1d bindings: hard-bind the bookmark functions to M-Ins and M-PgUp/M-PgDn
Bind the toggling of a bookmark to <Alt+Insert>, and the jumping to the
previous and next bookmark to <Alt+PageUp> and <Alt+PageDown>, so that
these functions are available by default.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2020-04-13 10:51:40 +02:00
Marco Diego Aurélio Mesquita f091c34bac new feature: bindable functions for toggling and jumping to "bookmarks"
With the 'bookmark' function, the user can place a bookmark on any
line in the buffer.  Multiple lines can be bookmarked in this way.
With 'prevbookmark' and 'nextbookmark', the user can then easily
return to the bookmarked lines.  The search for a bookmark wraps
around, as if start and end of buffer are connected.

[However, in this implementation, when a bookmarked line is deleted,
the bookmark is deleted too.  This is undesirable.  Also, when such
a deleted line is pasted elsewhere, the bookmark reappears with it,
and when pasted multiple times, the bookmark will be there as many
times.  This is thoroughly undesirable.  These behaviors will be
changed in a later commit.]

A bookmark is not yet visible in any way.

This fulfills https://savannah.gnu.org/bugs/?57577.
Requested-by: Ken Tyler <kent@werple.net.au>

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-04-13 10:51:40 +02:00
Benno Schulenberg f4a33b868a tweaks: delete the now-unused partitioning and unpartitioning routines 2020-04-09 12:12:04 +02:00
Benno Schulenberg 9f1c3c8513 memory: plug a leak, by freeing the cutbuffer after a bracketed paste
Also, remove an unneeded assignment -- the 'cutbottom' variable is
needed only when consecutives cuts (^K) or copies (M-6) are made.
2020-03-30 16:55:38 +02:00
Benno Schulenberg 7d3aad403d options: make -S the short synonym of --softwrap
The form -$ is still accepted, but is deprecated.
2020-03-27 17:02:55 +01:00
Benno Schulenberg aa70f3d95e options: stop recognizing the obsolete --morespace and --smooth
They have been no-ops for a year.

Also remove their documentation entries.

(The nanorc options still remain -- to be removed next year.)
2020-03-27 16:54:09 +01:00
Benno Schulenberg ba25d0df1d tweaks: fix twenty typos, in old Changelogs and in some comments
They were found by a run of 'codespell' at https://fossies.org/.

Reported-by: Jens Schleusener <Jens.Schleusener@fossies.org>
2020-03-25 16:57:43 +01:00
Benno Schulenberg 481529e865 input: accommodate silly emulators that have LF instead of CR in a paste
Even though a user would never type ^J to start a new line, accept it
as a synonym of <Enter> (^M) in a bracketed paste, because apparently
bash accepts it as a synonym too.

This works around https://savannah.gnu.org/bugs/?58010.
2020-03-20 14:25:27 +01:00
Benno Schulenberg 4ce2e146ea tweaks: elide three unneeded #defines
Backspace and Tab and Carriage Return have standard backslash escapes.
2020-03-19 14:40:51 +01:00
Benno Schulenberg ea95ad24be usage: improve the description of --softwrap
Concisely say what the option actually does.
2020-03-17 09:51:03 +01:00
Benno Schulenberg 02efc760bf tweaks: rename a symbol, to match the corresponding renamed option 2020-03-13 16:17:10 +01:00
Benno Schulenberg 9a59cddcd4 options: rename --suspend to --suspendable, to make more sense 2020-03-13 15:54:24 +01:00
Benno Schulenberg ebf9279f95 tweaks: rename two more functions, to match the style of others 2020-03-11 19:47:21 +01:00
Benno Schulenberg 304548ef82 tweaks: rename two functions, to match the style of others 2020-03-11 19:45:06 +01:00
Benno Schulenberg dd6f129c3c tweaks: rename two functions, for shortness 2020-03-11 19:43:03 +01:00
Benno Schulenberg 750b51c343 copyright: update to the current year for significantly changed files 2020-03-11 11:52:15 +01:00
Benno Schulenberg 843dbd56ef tweaks: rename two more elements of an undo record, for symmetry
(Note that for a PASTE and a COUPLE_END the variables seem to be used
the wrong way around.  Maybe this can be improved.)
2020-02-27 10:08:48 +01:00
Benno Schulenberg be7e000389 tweaks: pull the NUL-terminating of a string into a function
Also, avoid copying one byte too many that afterward gets
overwritten with '\0'.
2020-02-20 17:08:32 +01:00
Benno Schulenberg 76f1a4af4f tweaks: add a different helping variable 2020-02-19 19:06:04 +01:00
Benno Schulenberg bb1a0bd86c input: after reallocating a string, do not write to its old address
The old address has become invalid, and probably does not have enough
room for the write, thus causing a crash.

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

Bug existed since commit 8625609c from two days ago.
2020-02-19 18:54:01 +01:00
Benno Schulenberg 8b2b9654ab tweaks: condense a comment, reshuffle conditions, and remove unwanted one 2020-02-18 16:26:56 +01:00
Benno Schulenberg 60ae71bf3a softwrap: when typing goes beyond the bottom row, scroll just one row
This fixes https://savannah.gnu.org/bugs/?57851.

Bug existed since version 2.8.0, when scrolling per soft-wrapped chunk
was made possible.
2020-02-18 15:42:20 +01:00
Benno Schulenberg 8625609c2d tweaks: rename a variable, and add a helping one 2020-02-18 15:00:27 +01:00
Benno Schulenberg 3c4a4b04ce tweaks: normalize the indentation after the previous change
Also rewrap two lines, reshuffle three, and improve three comments.
2020-02-18 14:58:06 +01:00
Benno Schulenberg b3faf353c9 tweaks: inject the entire burst of bytes at once into the edit buffer
Not doing it characterwise saves a reallocation, a memmove(), several
checks, and an update_undo() for each character over one.

This has been tested by temporarily setting 'bracketed_paste = FALSE'
instead of 'bracketed_paste = TRUE' in convert_sequence() in winio.c,
and then pasting stuff into nano.
2020-02-18 14:54:19 +01:00
Benno Schulenberg f700b422be tweaks: call add_undo() before the character is actually added
And before the buffer size is adjusted, so that the add_undo()
doesn't need to correct the stored former size of the buffer.

This will allow the injection of multiple characters at once,
in the next commit.
2020-02-18 14:40:15 +01:00
Benno Schulenberg 5c07a747bb tweaks: adjust some whitespace, reshuffle two ifs, and remove two braces 2020-02-17 11:29:13 +01:00
Benno Schulenberg 75f4309c1f tweaks: rename four parameters, to be more distinct and telling 2020-02-13 14:22:40 +01:00
Benno Schulenberg 78767b583d tweaks: elide an intermediate copy of a character during injection, twice 2020-02-13 14:22:23 +01:00
Benno Schulenberg 61dc2cab0b tweaks: rename two variables, and frob four comments 2020-02-12 16:20:20 +01:00
Benno Schulenberg 070ccf4a5b tweaks: rename two variables, and reshuffle a few things 2020-02-12 14:28:07 +01:00
Benno Schulenberg 8e4b68917c tweaks: rename a function, and condense a few comments 2020-02-12 14:15:35 +01:00
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