In the preceding commit, open_buffer() was changed so that it gets
told whether to load into a new buffer or not, so it is no longer
needed to convey this information through a flag.
This fixes a regression introduced by commit 54103d8e: a crash that
can be triggered by running 'nano --restrict' and pressing <Insert>.
This addresses https://bugzilla.redhat.com/1558532.
As, since commit 0e30177d, the scrollup and scrolldown commands
no longer intend to move the cursor, they should not be seen as
movement functions.
Also, it is not guaranteed that functions are ordered in the same
way in the binary as in the source code, so an ordered comparison
of function pointers will not always work.
This fixes https://savannah.gnu.org/bugs/?53333.
This assumes that all movement functions are located together,
starting with to_first_line() and ending with do_right().
This fixes https://savannah.gnu.org/bugs/?53195.
Reported-by: Brand Huntsman <alpha@qzx.com>
The implant() function itself cannot be bound to anything, so it
is not in the linked list of functions -- trying to find it would
lead to a NULL pointer, and thus to a segfault.
This fixes https://savannah.gnu.org/bugs/?53233.
Instead of always calling sctofunc(), it is now only called when
in view mode OR when (after the keystroke's function has been run)
no need for a refresh has been established yet.
When 'refresh_needed' is already TRUE, there is no need any more
to check whether it should be set.
[Those first two calls are leftovers from before the time that
reset_multis() morphed into check_the_multis().]
When characters are added via Verbatim Input or by pressing <Tab>,
the prepend flag should be retained, just like when characters are
typed directly.
This fixes https://savannah.gnu.org/bugs/?52956.
In this way a single keystroke can produce a fragment of text or a
series of commands, or a mix of the two. It is like a prerecorded
macro.
This fulfills https://savannah.gnu.org/bugs/?52931.
Each leading tab is converted to two tabs, and any leading four spaces
is converted to one tab. The intended tab size (for keeping most lines
within 80 columns) is now four.
When unindenting/uncommenting affected the bottom line of the marked
region, keep affecting this line also during subsequent consecutive
indenting/commenting.
This fixes https://savannah.gnu.org/bugs/?52718.
The function get_keycode() should never return zero -- it should
return either the code from ncurses or the given fallback code.
This fixes https://savannah.gnu.org/bugs/?52682.
In this way we can delete things on the current line with ^K (after
Shift-selecting some text) without nano misdetecting a line change,
This fully fixes https://savannah.gnu.org/bugs/?52576.
Only when the cursor has moved off of the currrent line do we stop
prepending wrapped words to the next line.
This partially fixes https://savannah.gnu.org/bugs/?52576.
When some or all edits have been undone, and the user starts to make
new edits, the old part of the undo stack is discarded, but this does
not mean that the undo stack doesn't go back to the very beginning.
This really fixes https://savannah.gnu.org/bugs/?52504.
The softmark is now only cancelled when the cursor is moved without
Shift being held, not for things like ^L (Refresh), ^C (Position),
or ^G (Help).
This addresses https://savannah.gnu.org/bugs/?52470.
The pointer not being NULL is enough indication that the mark is set.
Also, rename the pointer from 'mark_begin' to simply 'mark', since
the former is kind of pleonastic.
Whenever a buffer is closed, check whether the positions file on disk
was modified, and if so, reload it. Then update the position for the
closed buffer and write out the positions file to disk.
Signed-off-by: Brand Huntsman <alpha@qzx.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
The function get_key_buffer() assumes waiting_mode = TRUE, but stdin
can be in non-blocking mode when a program (before nano) turned stdin
to non-blocking mode and did not change it back (possibly because it
crashed). So, explicitly set stdin to blocking mode at startup.
Signed-off-by: Lion Yang <lion@aosc.io>
When not finding a .nanorc file in the user's home directory, nano will
look for a nanorc file in $XDG_CONFIG_HOME and in the ~/.config/nano/
fallback directory. And when not finding a .nano/ subdir in the user's
home directory, nano will look for (or create) the history files in
$XDG_DATA_HOME or in the ~/.local/share/nano/ fallback directory.
This is a partial implementation of the XDG Base Directory Specification:
https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html,
for the purpose of reducing the clutter in a user's home directory, and
to make it easier to back up just the configuration files.
Signed-off-by: Simon Ochsenreither <simon@ochsenreither.de>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
If the user uses a single version of nano, they have no need for
--quiet. If they do sometimes use an older version and don't want
to see the warnings, they can use 2>/dev/null (they could make an
alias for that and put it before the call of nano).
^S will be the first thing people will try for saving a file,
and ^Q is somewhat mnemonic because it is to the left of ^W:
it searches backward.
Make these keystrokes available also in the tiny version.
Before writing a file out, nano should check that the file on disk
hasn't been modified since it was read -- not only for the normal
"Write Out" action (^O), but also for "Save File" (future ^S) and
for "Save and Exit" (^X when --tempfile is used).
When writing fails and --tempfile is in effect, don't go on to prompt
for a file name; instead let the user decide what she wants to do.
This fixes https://savannah.gnu.org/bugs/?51040.
Signed-off-by: Viorel Bota <botaviorel@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
The basic idea is that the cursor is always off, except when it needs
to be on: when waiting for text input, and in a few other cases: when
something was searched and found in the help viewer, and in the file
browser when option -g is in effect.
This fixes https://savannah.gnu.org/bugs/?51923.
Reported-by: Mike Frysinger <vapier@gentoo.org>
When multiple buffers are open, replace nano's name and version number
with an indication how many buffers are open preceded by the sequence
number of the current buffer.
Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
Adding text plus whitespace while the cursor is at or near the topleft
corner of the edit window can cause a change in the preceding chunk,
throwing firstcolumn out of alignment. Catch this special case.
This fixes http://savannah.gnu.org/bugs/?51743.
It would be horrible if the user expects to find numbered backups
of all the files that were changed but they are NOT there because
the config file contains a typo or the relevant directory was moved
or renamed or something. So... if the specified backup directory
is not usable, nano should complain and simply not start up.
The new option 'set selectedcolor' applies to marked text, to the
currently selected file in the file browser, and to the highlighted
match during interactive search-and-replace.
Commit 28beb3f added the 'forreal' parameter to prevent spotlight() from
placing the cursor wrongly due to an invalid placewewant. However, since
the variable-width softwrap overhaul (specifically, since commit 8490f4a),
place_the_cursor() no longer checks placewewant, so the parameter is no
longer needed.
Furthermore, dropping 'forreal' and thus always setting current_y won't
affect the operation of spotlight(), since the only functions that use
spotlight() (do_replace_loop() and do_int_spell_fix()) both call
edit_refresh() beforehand, which means that current_y will already
have been set to the value it will be set to again.
For some reason, when returning from suspension, SLang will produce
either a clipped error code (0xFF instead of 0xFFFF, when returning
from an externally induced suspension), or it will clip the code of
first subsequent keystroke to a single byte (when returning from a
normal, in-editor suspension: ^Z).
Side-step this by ignoring the clipped error code, and by using an
undefined control code as the first fake keystroke. Ignoring the
clipped error code is not possible when using a single-byte locale,
otherwise the user would not be able to type the character with
code 0xFF (although it could still be entered with Esc Esc 255).
This fixes https://savannah.gnu.org/bugs/?51477.
The help lines need to be redrawn one step after a justification
(whether it has been undone or not, to replace "Unjustify" with
"Uncut" again for ^U), and after switching buffers (to update a
possibly changed tag for ^T).
This fixes https://savannah.gnu.org/bugs/?51455.
get_chunk_row() replaces the formula "column / editwincols".
get_chunk_leftedge() replaces "(column / editwincols) * editwincols".
get_last_chunk_row() replaces "strlenpt() / editwincols".
get_last_chunk_leftedge() replaces "(strlenpt() / editwincols) * editwincols".
This prepares us for any changes in those formulas, and for more such
functions later.