Commit Graph

1570 Commits (abd4c47acf4ec71a3eb142e44493d29ba1201465)

Author SHA1 Message Date
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
Benno Schulenberg c0b15c2982 signals: don't trap segfault/abort when envvar NANO_NOCATCH is defined
When the user wants to get a backtrace, the crash handler shouldn't
kick in.
2018-05-09 11:53:34 +02:00
Devin Hussey e889c28a95 signals: upon a crash, save changed buffers and reset terminal state
Upon a segmentation fault or an abort signal, instead of crashing,
losing all changes, and leaving the terminal in curses mode, nano
now calls die(), to save any changed buffers and to restore the
terminal to a usable state.

For the remote chance that nano segfaults in die(), the handler for
SIGSEGV and for SIGABRT is reset to its default value as soon as the
signal fires, to prevent a crash-handler loop.

Since a core dump is usually more helpful for debugging, the crash
handler is not included in a debug build.

This addresses https://savannah.gnu.org/patch/?9623.

Signed-off-by: Devin Hussey <husseydevin@gmail.com>
2018-05-06 16:36:25 +02:00
Benno Schulenberg 0da554e6d7 startup: suggest using ^D to finish reading from standard input
Also, add a period after the "Read nn lines" message, and
don't let the next shell prompt overwrite this message.

This addresses https://savannah.gnu.org/bugs/?53779.
2018-05-01 11:15:19 +02:00
Benno Schulenberg 0e46c0f4a5 main: clear a spurious error number, to avoid irrelevant messages later
This addresses https://savannah.gnu.org/bugs/?53777.
2018-04-29 12:08:42 +02:00
Benno Schulenberg 0c613cb1ac tweaks: rename a variable, to be more clear and to match another 2018-04-23 12:57:58 +02:00
Benno Schulenberg 1e5064ef84 tweaks: fix a typo, remove a blank line, and improve some comments 2018-04-23 12:19:25 +02:00
Benno Schulenberg 5b40bad629 files: prevent a hang when a call to sigaction() would fail
Don't try to re-enter curses mode when the terminal is not in
the correct state yet.

This fixes https://savannah.gnu.org/bugs/?53720.
2018-04-23 11:58:18 +02:00
Benno Schulenberg 544d426d86 tweaks: group some more of the empty functions together 2018-04-17 10:34:57 +02:00
Benno Schulenberg 9bce8bfeb3 build: fix compilation when configured with --disable-multibuffer 2018-03-23 19:14:56 +01:00
Benno Schulenberg 2c024a74a9 tweaks: adjust or correct some comments, and rename a function
Also, reshuffle a condition so it takes up less space.
2018-03-23 17:54:06 +01:00
Benno Schulenberg ab8698df47 tweaks: condense some code, to remove a bit of duplication 2018-03-23 17:14:39 +01:00
Benno Schulenberg 0f1f53a441 tweaks: drop a handful of unhelpful asserts 2018-03-23 11:09:56 +01:00
Benno Schulenberg bf1a080923 build: exclude more things when configured with --disable-multibuffer
This will make the tiny version slightly smaller.
2018-03-23 11:09:37 +01:00
Benno Schulenberg b7f8d4819b tweaks: frob some comments plus miscellaneous other stuff 2018-03-22 19:54:20 +01:00
Benno Schulenberg b9de5525c4 tweaks: elide a parameter, as it's always the inverse of another 2018-03-22 12:52:28 +01:00
Benno Schulenberg f4d1ef1c4e tweaks: remove unneeded settings and unsettings of MULTIBUFFER
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.
2018-03-22 12:50:48 +01:00
Benno Schulenberg dd157f1494 tweaks: change a parameter of open_buffer() and invert its logic 2018-03-22 12:35:50 +01:00
Benno Schulenberg 8b8c6bb818 tweaks: factor out the check for 'viewok' into its own function
And also prevent a theoretical crash for restricted prompt functions.
2018-03-20 20:10:08 +01:00
Kamil Dudka b830a7dd38 input: do not crash if sctofunc() returns NULL
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.
2018-03-20 19:36:55 +01:00
Benno Schulenberg 3e5b0ea5fd files: prevent an infinite loop when reading from standard input fails 2018-03-20 11:25:16 +01:00
Liu Hao 0496aed4ab build: fix compilation error when configured with --disable-justify
Signed-off-by: Liu Hao <lh_mouse@126.com>
2018-03-19 13:39:15 +01:00
David Lawrence Ramsey 7b1f3f4fe7 tweaks: correct several parameter types
This avoids a bunch of warnings when compiled with -pedantic:

	ISO C forbids comparison of ‘void *’ with function pointer
2018-03-18 20:01:25 +01:00
Benno Schulenberg 9517972b58 build: fix compilation again when configured with --enable-tiny 2018-03-18 16:33:21 +01:00
Benno Schulenberg 95989e7dfe selecting: don't cancel a softmark when just scrolling the screen
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.
2018-03-18 13:55:29 +01:00
Benno Schulenberg f0734dae3e cut: avoid calling renumber() on what might be NULL
This fixes https://savannah.gnu.org/bugs/?53317.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2018-03-12 10:46:02 +01:00
Benno Schulenberg 80605c3918 tweaks: exclude an unlikely warning from the tiny version 2018-03-06 12:05:52 +01:00
Benno Schulenberg e4cef3086b tweaks: drop an assert, add a warning, and change a 'for' to a 'while' 2018-03-05 12:46:25 +01:00
Benno Schulenberg 9936a6357a tweaks: rename a parameter and a variable, to be more fitting 2018-03-05 12:46:25 +01:00
Benno Schulenberg 1f7384ebd2 tweaks: appease valgrind concerning syscalls with uninitialized values 2018-03-05 11:02:52 +01:00
Benno Schulenberg 6f4f1878fc selecting: cancel the softmark upon any attempt to move the cursor
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>
2018-02-27 18:09:00 +01:00
Benno Schulenberg 5eccaa7633 tweaks: refactor the implanting of a key expansion 2018-02-27 13:34:32 +01:00
Benno Schulenberg 01457ae3d3 input: handle the implant() function separately, as it is special
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.
2018-02-27 11:11:02 +01:00
Benno Schulenberg 54103d8ed1 tweaks: elide another variable, to call a function less often
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.
2018-02-25 10:41:51 +01:00
Benno Schulenberg ffebd31cbb tweaks: shorten the name of two record elements
Exclude the confusing, pleonastic 'sc' abbreviation from their names.
2018-02-24 19:31:11 +01:00
Benno Schulenberg e55227f65f tweaks: unabbreviate two variable names 2018-02-24 18:20:30 +01:00
Benno Schulenberg b77b54bf73 tweaks: elide two unneeded booleans 2018-02-24 17:51:27 +01:00
Benno Schulenberg b027263a37 small addition: allow customizing the color of an error message
The new option 'set errorcolor' allows the user to specify the color
combination for the status bar when an error message is displayed.
2018-02-23 12:35:17 +01:00
Benno Schulenberg 28933cf572 tweaks: remove two superfluous checks, and restrict two others
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().]
2018-02-14 17:29:59 +01:00
David Lawrence Ramsey 7a038adfd4 input: don't stop prepending when the user adds text via a shortcut
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.
2018-02-08 17:35:56 +01:00
Benno Schulenberg a083d7f1e1 tweaks: rename a variable to be more distinct and greppable 2018-02-04 18:25:10 +01:00
Benno Schulenberg 919df09ffa general: detect in a better way whether we're running on a Linux console
Suggested-by: Mike Frysinger <vapier@gentoo.org>
2018-02-04 18:23:13 +01:00
Benno Schulenberg 467cc8edf3 tweaks: remove two deprecated options and six rebindable function names
This addresses https://savannah.gnu.org/bugs/?48992.
2018-02-04 13:51:13 +01:00
Benno Schulenberg 6d111c9343 new feature: allow binding a key to a string (in a nanorc file)
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.
2018-02-04 12:44:12 +01:00
Benno Schulenberg f5c87a7fee tweaks: swap the row and col parameters to a more consistent order 2018-01-27 20:00:14 +01:00
Benno Schulenberg 90ebff00ca tweaks: rename two variables, and swap their declaration order 2018-01-27 19:47:00 +01:00
Benno Schulenberg cdc9a29598 tweaks: move two functions to their proper place, orderingwise 2018-01-27 19:33:03 +01:00
Benno Schulenberg 7b9bd65362 tweaks: drop a useless assert, and don't abort over an unhandled option 2018-01-24 10:29:50 +01:00
Benno Schulenberg f72fecee9b copyright: update the years for the FSF
And one for me, for the much changed keyboard stuff.
2018-01-24 10:14:43 +01:00
Benno Schulenberg f095e20a86 tweaks: exclude --trimblanks when no wrapping or justifying is configured
Also, actually add the long option --trimblanks to the table.
2018-01-24 09:59:01 +01:00
Benno Schulenberg cb56a575fd options: recognize -M and --trimblanks on the command line 2018-01-23 13:49:48 +01:00
Benno Schulenberg 898c4c6fbb startup: move the initialization of colors, so any error gets printed
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-01-12 10:50:28 +01:00
Benno Schulenberg c1bb6485de tweaks: check for the type of terminal far earlier
So the result could be used during RC-file reading.
2018-01-12 09:51:43 +01:00
Benno Schulenberg 17429d7f38 tweaks: fix some whitespace errors, and convert alignment tabs to spaces 2017-12-29 21:35:14 +01:00
Benno Schulenberg 87206c0607 tweaks: convert the indentation to use only tabs
Each leading tab is converted to two tabs, and any leading four spaces
is converted to one tab.  The intended tab size (for keeping most lines
within 80 columns) is now four.
2017-12-29 20:06:50 +01:00
Benno Schulenberg b574f73e60 tweaks: add a separate function that actually wipes the status bar 2017-12-29 17:40:41 +01:00
Benno Schulenberg 440a128d25 indenting: keep affecting last line of marked region if it was at first
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.
2017-12-29 16:52:17 +01:00
Benno Schulenberg e1b0f2b275 display: ensure that cursor is visible when compiled with --with-slang
This fixes https://savannah.gnu.org/bugs/?52651.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-12-17 16:34:02 +01:00
Benno Schulenberg d2270e514b input: make <Ctrl+Shift+Arrow> work also when using --rebindkeypad
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.
2017-12-16 21:09:01 +01:00
Benno Schulenberg b4411b4f28 wrapping: we're still on the same line if the next line has not changed
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.
2017-12-07 19:41:10 +01:00
Benno Schulenberg 29f7654ab1 wrapping: keep prepending to the same next line as long as possible
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.
2017-12-07 19:41:04 +01:00
Benno Schulenberg 0c40f87b55 tweaks: invert the logic of a variable, and rename it
To get rid of two double negatives.
2017-12-03 20:49:01 +01:00
David Lawrence Ramsey b9638cb7cc undo: when adding text adds a magicline, an undo should remove both
This fixes http://savannah.gnu.org/bugs/?52523.
2017-11-30 21:20:38 +01:00
Benno Schulenberg c17a8a9836 undo: discarding the stack does not always lose information
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.
2017-11-27 16:19:28 +01:00
Benno Schulenberg 88a0bb9685 selecting: do not cancel the softmark when the cursor is not moved
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.
2017-11-26 19:41:14 +01:00
Benno Schulenberg d33b5f3dab tweaks: rename, rewrap, and reshuffle some stuff, and frob some comments 2017-11-21 21:17:08 +01:00
Benno Schulenberg c24e95e3d6 tweaks: elide the 'mark_set' boolean -- the 'mark' pointer is enough
The pointer not being NULL is enough indication that the mark is set.

Also, rename the pointer from 'mark_begin' to simply 'mark', since
the former is kind of pleonastic.
2017-11-21 21:14:33 +01:00
Benno Schulenberg 5239e7c52b copyright: update some years, and standardize on the dashed format 2017-11-12 10:46:20 +01:00
Benno Schulenberg dfcb1268ca tweaks: adjust a comment, and condense a fragment of code 2017-11-10 20:06:13 +01:00
Benno Schulenberg 2122a1a2b5 tweaks: constify the result strings of getenv(), as a reminder
Also, remove an unneeded pair of braces.
2017-11-10 20:03:07 +01:00
Brand Huntsman bfc53f308c history: prevent overwriting of positions between multiple instances
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>
2017-11-08 20:38:34 +01:00
Lion Yang f0d3685591 input: ensure that standard input uses blocking mode
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>
2017-11-08 20:28:26 +01:00
Simon Ochsenreither c16e79b612 startup: look for nanorc and history files also in the XDG directories
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>
2017-11-04 20:11:57 +01:00
Benno Schulenberg 1463781247 startup: when an rcfile contains errors, report this on the status bar
Suggested-by: Brand Huntsman <alpha@qzx.com>
2017-11-02 17:30:14 +01:00
Benno Schulenberg c3a11fb7ed options: remove '--quiet' and 'set quiet', because they hide problems
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).
2017-11-02 17:27:53 +01:00
Benno Schulenberg d054044d30 tweaks: transform the token DISABLE_EXTRA to ENABLE_EXTRA 2017-11-01 20:33:14 +01:00
Benno Schulenberg 9dc72cf3ba tweaks: avoid an unused-variable warning with --disable-nanorc 2017-11-01 20:08:55 +01:00
Benno Schulenberg d5ac1ed395 tweaks: transform the token DISABLE_COLOR to ENABLE_COLOR 2017-11-01 19:45:50 +01:00
Benno Schulenberg 2a4fc9591f tweaks: transform the token DISABLE_SPELLER to ENABLE_SPELLER 2017-10-31 19:32:42 +01:00
Benno Schulenberg f034992ed6 tweaks: transform the token DISABLE_WRAPJUSTIFY to ENABLED_WRAPORJUSTIFY 2017-10-31 17:40:54 +01:00
Benno Schulenberg db0b849f9b tweaks: transform the token DISABLE_JUSTIFY to ENABLE_JUSTIFY 2017-10-31 17:40:44 +01:00
Benno Schulenberg 028d12f4fb tweaks: transform the token DISABLE_OPERATINGDIR to ENABLE_OPERATINGDIR 2017-10-29 21:08:07 +01:00
Benno Schulenberg a5974bd1ec tweaks: transform the token DISABLE_WRAPPING to ENABLE_WRAPPING 2017-10-29 21:00:09 +01:00
Benno Schulenberg ff35a61355 tweaks: transform the token DISABLE_HISTORIES to ENABLE_HISTORIES 2017-10-29 19:43:05 +01:00
Benno Schulenberg fc36ff7275 options: retire 'set backwards' -- it's still recognized but a no-op 2017-10-15 10:45:22 +02:00
Benno Schulenberg ba65cd48cc bindings: make ^Q and ^S do something useful by default
^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.
2017-10-14 20:34:43 +02:00
Viorel Bota 217cfbf362 files: check for a changed disk file also for 'savefile' and --tempfile
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>
2017-10-13 20:24:10 +02:00
Benno Schulenberg 762fb4bec5 display: switch off the cursor early on during startup
So the cursor won't be visible at the end of the status-bar message
while reading in a large file.
2017-10-04 21:34:44 +02:00
Benno Schulenberg b5346bccb3 tweaks: rename a variable, to avoid a possible confusion
Or rather, to make searching for the PRESERVE option easier.
2017-09-24 21:06:08 +02:00
Benno Schulenberg 7c3c3cbb3b tweaks: discard some obsolete debugging stuff 2017-09-22 21:59:51 +02:00
Benno Schulenberg c74d2632bb tweaks: make the switching on and off of the cursor a bit more compact 2017-09-22 21:31:01 +02:00
Benno Schulenberg ae34825f58 display: rework the switching on and off of the cursor
The basic idea is that the cursor is always off, except when it needs
to be on: when waiting for text input, and in a few other cases: when
something was searched and found in the help viewer, and in the file
browser when option -g is in effect.

This fixes https://savannah.gnu.org/bugs/?51923.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-09-20 21:35:25 +02:00
Benno Schulenberg 5f4fb8e513 tweaks: frob some comments and rename a few variables and a function 2017-09-17 20:17:13 +02:00
Marco Diego Aurélio Mesquita 3fc89e0853 new feature: show current and total number of open buffers in title bar
When multiple buffers are open, replace nano's name and version number
with an indication how many buffers are open preceded by the sequence
number of the current buffer.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-09-13 19:29:38 +02:00
Benno Schulenberg 86e71fa09d tweaks: specify more directly in what manner to move the viewport 2017-08-18 21:46:55 +02:00
Urja Rannikko 1cc030f7c1 bindings: hard-bind Alt+Left and Alt+Right to buffer switching
This also fixes https://savannah.gnu.org/bugs/?51735.
Reported-by: Urja Rannikko <urjaman@gmail.com>

Signed-off-by: Urja Rannikko <urjaman@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2017-08-14 10:06:29 +02:00
David Lawrence Ramsey 8e779b6e85 softwrap: properly update the viewport when adding text at firstcolumn
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.
2017-08-13 13:46:49 +02:00
Benno Schulenberg 751e7f0fbe files: do not silently ignore an invalid backup directory, but die
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.
2017-08-13 10:08:29 +02:00
Benno Schulenberg 11072ed587 tweaks: sort the includes, so it's a little easier to see what is there 2017-08-06 19:40:30 +02:00
Benno Schulenberg 67915f5dae tweaks: restore an include that is necessary on some platforms
This fixes https://savannah.gnu.org/bugs/?51674.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-06 19:34:16 +02:00
David Lawrence Ramsey 1c1cbae6bc small addition: allow customizing the color of selected text
The new option 'set selectedcolor' applies to marked text, to the
currently selected file in the file browser, and to the highlighted
match during interactive search-and-replace.
2017-08-06 09:30:32 +02:00
Benno Schulenberg 276ab2c85e tweaks: reshuffle code and frob comments, to reduce the number of lines 2017-08-06 09:08:45 +02:00
Benno Schulenberg 80686bb525 tweaks: remove includes that appear to be superfluous
Without them, nano still compiles for me, with everything enabled,
even when using --enable-debug, --enable-utf8, and --with-slang.
2017-08-06 09:08:30 +02:00
David Lawrence Ramsey 381a386b01 weeding: drop the forreal parameter from place_the_cursor()
Commit 28beb3f added the 'forreal' parameter to prevent spotlight() from
placing the cursor wrongly due to an invalid placewewant.  However, since
the variable-width softwrap overhaul (specifically, since commit 8490f4a),
place_the_cursor() no longer checks placewewant, so the parameter is no
longer needed.

Furthermore, dropping 'forreal' and thus always setting current_y won't
affect the operation of spotlight(), since the only functions that use
spotlight() (do_replace_loop() and do_int_spell_fix()) both call
edit_refresh() beforehand, which means that current_y will already
have been set to the value it will be set to again.
2017-07-24 21:07:42 +02:00
Benno Schulenberg 43a5c87682 suspension: prevent entering an invalid byte upon resume (with S-Lang)
For some reason, when returning from suspension, SLang will produce
either a clipped error code (0xFF instead of 0xFFFF, when returning
from an externally induced suspension), or it will clip the code of
first subsequent keystroke to a single byte (when returning from a
normal, in-editor suspension: ^Z).

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

This fixes https://savannah.gnu.org/bugs/?51477.
2017-07-16 13:55:59 +02:00
Benno Schulenberg 1e2d9a697a tweaks: rename a constant, to match the corresponding option 2017-07-14 16:14:02 +02:00
Benno Schulenberg 63c428ad08 options: rename --cut to --cutfromcursor, to be clearer
Rename the corresponding rc-file option too, of course.
2017-07-14 16:06:52 +02:00
Benno Schulenberg 5df47bfef6 display: avoid a jumpy cursor by redrawing bottom bars only when needed
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.
2017-07-13 11:10:51 +02:00
Benno Schulenberg ecc7c26641 tweaks: rename a variable, to have more contrast 2017-07-09 21:11:01 +02:00
Benno Schulenberg fbbf501f8f tweaks: rename four functions, to be more distinct 2017-07-09 21:07:38 +02:00
Benno Schulenberg ac7a071893 options: recognize -a and --atblanks on the command line
In nano, -a is only effective when also -$ is given, so this will
not conflict with Pico since Pico does not know the -$ option.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey 4d7735c8f9 softwrap: in do_mouse(), keep the cursor before a softwrap breakpoint
Add the new function actual_last_column() to accomplish this.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey e375995d98 softwrap: add new functions for chunks of varying width
get_chunk_row() replaces the formula "column / editwincols".

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

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

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

This prepares us for any changes in those formulas, and for more such
functions later.
2017-07-07 13:07:10 +02:00
Benno Schulenberg 7d46eff738 display: when back in the main loop, always redraw the help lines
(Well, redraw them when they're switched on, of course.)  Redraw
them so that they are shown correctly if their content changed.

This fixes https://savannah.gnu.org/bugs/?51356.
and fixes https://savannah.gnu.org/bugs/?51357.
2017-07-02 19:57:11 +02:00
David Lawrence Ramsey d1ee41f319 usage: a dash doesn't have to come first among the filenames 2017-06-30 10:25:49 +02:00
Benno Schulenberg 8fbf10428c tweaks: avoid an unused-variable warning for the tiny version
The extra variable is not needed, because when having read from
standard input, the filename will simply be empty.  It will not
be empty for any other file that was read.
2017-06-30 09:58:40 +02:00
Benno Schulenberg 9026e04c73 startup: don't use position history when reading from standard input 2017-06-23 13:44:01 +02:00
Benno Schulenberg 92befae93d startup: don't mark the buffer as modified when in view mode 2017-06-23 10:43:52 +02:00
Benno Schulenberg 8b80ec3e1a startup: allow negative line and column numbers on the command line
They can be given at the prompt, so it's better to accept them on the
command line too.
2017-06-23 10:25:12 +02:00
Benno Schulenberg a71a2f9a0c startup: don't mark the buffer as modified when nothing was read 2017-06-23 09:51:58 +02:00
Benno Schulenberg 56ce5f2ba8 tweaks: rename a function and a variable, to better match what they do
Also improve some comments.
2017-06-23 09:50:48 +02:00
Benno Schulenberg 5ebdd3fe6e tweaks: reduce the scope of three variables, and rename them besides 2017-06-23 09:00:15 +02:00
Benno Schulenberg 426e6d37c5 startup: don't try placing the cursor when reading standard input failed
And rename the function while there anyway.
2017-06-23 08:30:24 +02:00
Benno Schulenberg 4dd9aadf8a startup: allow positioning the cursor also when reading standard input
A recent change (8dffb00f) removed this ability.  This change restores
it, and also allows reading from standard input multiple times -- maybe
not useful, but it works.
2017-06-20 11:22:57 +02:00
Benno Schulenberg 5ecd81bd19 tweaks: rename a variable, and frob a couple of comments
Also, conditionalize a statement that is only effective when
multiple file buffers are available.
2017-06-18 21:37:42 +02:00
Benno Schulenberg 33c7a4ca95 tweaks: adjust indentation after preceding changes
Also, shorten two variable names.
2017-06-18 11:29:09 +02:00
Benno Schulenberg 40d34862fd tweaks: reduce the scope of two variables, and rename them too
This reduction is possible since the routine no longer loops when
it encounters a +NUMBER argument.
2017-06-18 11:06:58 +02:00
Benno Schulenberg bee670424e tweaks: elide a variable 2017-06-18 11:00:21 +02:00
Benno Schulenberg 8dffb00fd9 startup: always open with the file that was mentioned first
Also when a dash is the first "file" mentioned on the command line,
nano should show this buffer at startup and not the next.

This fixes https://savannah.gnu.org/bugs/?51207.
2017-06-18 10:49:51 +02:00
Benno Schulenberg 942bb39547 startup: don't crash when opening standard input would fail
This fixes https://savannah.gnu.org/bugs/?51206.
2017-06-08 11:28:49 +02:00
Benno Schulenberg 52b7a41ea4 tweaks: elide a function that should not be a separate one
Reading from standard input is a purely sequential affair --
no need to split it into two functions.
2017-06-07 21:28:34 +02:00
Benno Schulenberg 6807e06a74 tweaks: frob a few comments, and elide and #ifndef 2017-06-06 22:22:48 +02:00
Benno Schulenberg 84ff9ebb91 display: don't let a SIGCONT write anything to the screen
The old praxis of calling total_refresh() upon a SIGCONT was confusing,
because the screen would look as if nano had returned from suspension,
but in fact the shell was still active.

Instead of calling total_refresh(), put a no-op key into ncurses' buffer,
so that, when nano actually does return out of suspension (through 'fg'),
this key will be read and discarded, upon which nano will go sit and wait
for the next key, just before which it calls doupdate().  The latter is
all we need to get the entire screen restored.

This also fixes https://savannah.gnu.org/bugs/?51131 for "tiny".
2017-06-02 21:00:13 +02:00
Benno Schulenberg a969adf804 suspension: fake a SIGWINCH when coming back out of the background
When receiving a SIGCONT, don't call regenerate_screen() directly
but act as if a SIGWINCH occurred.  Also insert a dummy key, and
thus let the relevant input routine redraw the relevant subwindows.

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

This fixes https://savannah.gnu.org/bugs/?51124.
2017-05-31 14:57:56 +02:00
Benno Schulenberg 4781d4d351 tweaks: reshuffle some stuff, to put related things closer together 2017-05-24 10:23:20 +02:00
Benno Schulenberg ef1a3b08ae suspension: remove a duplicate setting of the HUP and TERM handler
This has been done already during signal_init().
2017-05-24 10:15:42 +02:00
Benno Schulenberg 9ce41543ed startup: don't call delwin() with NULL, to avoid crashing on Solaris
Apparently the curses on SunOS is less forgiving than the one on GNU.
Or rather: delwin(NULL) should just return an error, it shouldn't crash.

This fixes https://savannah.gnu.org/bugs/?51053.
Reported-by: John Wiersba <jrw32982@yahoo.com>
Solved-by: John Wiersba <jrw32982@yahoo.com>
2017-05-18 10:26:11 +02:00
Benno Schulenberg aa14526cb3 tweaks: exclude from the tiny version five error-betraying messages 2017-05-16 22:13:10 +02:00
Benno Schulenberg 28beb3f9c5 replacing: don't let placewewant influence the placement of the cursor
When spotlighting the string to be replaced, placewewant isn't valid,
so tell place_the_cursor() to ignore its value to avoid the cursor
getting mistakenly placed at the beginning of the next row.

This fixes https://savannah.gnu.org/bugs/?50997.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-05-11 22:28:34 +02:00
Benno Schulenberg 858e75e4cf tweaks: transform the token DISABLE_NANORC to ENABLE_NANORC
Also, allow rebinding the word and block jumping functions
in the tiny version when nanorc files are reenabled.
2017-05-09 11:59:34 +02:00
Benno Schulenberg a05180ed2d tweaks: transform the token DISABLE_TABCOMP to ENABLE_TABCOMP 2017-05-09 11:31:54 +02:00
Benno Schulenberg dc3610fc8e tweaks: transform the token DISABLE_BROWSER to ENABLE_BROWSER
Also, allow Ctrl+Left/Right with --enable-tiny --enable-browser.
2017-05-08 21:56:50 +02:00
David Lawrence Ramsey 03c3e2b7c0 tweaks: fix several whitespace irregularities
Add missing spaces, remove excess spaces, and
replace groups of indentation spaces with tabs.
2017-05-07 18:20:01 +02:00
Benno Schulenberg 5a3de7f117 tweaks: avoid an empty function call in tiny version with line numbers 2017-05-05 12:39:20 +02:00
Benno Schulenberg 7b5cc1dcda display: keep the cursor put, also when toggling nohelp or morespace
Also when toggling the help lines back on or the extra editing space
back off, keep the cursor near the bottom of the screen if it /was/
there, instead of centering it -- if smooth scrolling is on, that is.

This supplements the fix for https://savannah.gnu.org/bugs/?50933.
2017-05-05 12:37:45 +02:00
Benno Schulenberg 5033cfd81a tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE
Also, trim some comments and avoid an unused-variable warning.
2017-05-01 20:53:07 +02:00
Benno Schulenberg 9c3a149b14 tweaks: transform the token DISABLE_MULTIBUFFER to ENABLE_MULTIBUFFER 2017-05-01 20:20:34 +02:00
Benno Schulenberg 1423e57199 tweaks: rename a function, to better suit what it does
Things have morphed over time and display_buffer() no longer actually
displays the buffer -- it just displays the title bar, precalculates
the multiline color info, and schedules a refresh of the edit window.
2017-05-01 16:53:13 +02:00
Benno Schulenberg a8a60b29e6 startup: warn about a strange character size only in the UTF-8 case
This addresses https://savannah.gnu.org/bugs/?50897.
Reported-by: Hannu Nyman <hannu.nyman@iki.fi>
2017-04-30 11:15:03 +02:00
Benno Schulenberg 46430999d5 build: make --enable-help properly depend on --enable-multibuffer
And in the process transform the token DISABLE_HELP to ENABLE_HELP.
2017-04-25 18:27:55 +02:00
Rishabh Dave 90bd25c1bb new feature: add a search facility to the help viewer
Allow the user to search in a help text with ^W and M-W.

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

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

Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
2017-04-25 17:20:34 +02:00
Benno Schulenberg 040bd93cc4 tweaks: distinguish (in the comments) between buffers and linestructs
Call something a buffer when it refers to a linked list of linestructs,
and call something a linestruct when it is a struct that describes a
single line.
2017-04-19 17:48:52 +02:00
Benno Schulenberg 1fbe7596f8 options: allow -U (--quickblank) to be used in the tiny version
It takes almost no code and is a useful little improvement over Pico.
2017-04-19 13:47:40 +02:00
Benno Schulenberg 74f128859b tweaks: rename a constant, to match the corresponding option 2017-04-17 11:51:48 +02:00
Benno Schulenberg 3dc6ccbe86 tweaks: rename a function, to be more accurate
Because nothing gets reset to zero or to some initial value.
2017-04-17 11:29:29 +02:00
Benno Schulenberg 9f696ef9af copyright: update the year in --version, and use the standard hyphen 2017-04-11 13:57:29 +02:00
David Lawrence Ramsey 5c51d4ea46 tweaks: avoid a compilation warning 2017-04-10 16:26:52 +02:00
Benno Schulenberg 754c62c5cc copyright: update the years, use ranges, and explain this usage
The interval 2013-2017 for the Free Software Foundation is valid
because in those years there were releases with changes by either
Chris or David, and the GNU maintainers guide advises to mention
a new year in all files of a package, not just in the ones that
actually changed, and be done with it for the rest of the year.
2017-04-09 12:09:23 +02:00
Benno Schulenberg cb0806b2a0 bindings: make ^Home and ^End go to top and tail of buffer
On some terminal emulators, Ctrl+Home and Ctrl+End produce special
keycodes, distinct from plain Home and End.  Make the users of those
emulators (and of the Linux console) glad by making ^Home and ^End
do the obvious thing, and the combinations with Shift too.
2017-04-06 21:19:00 +02:00
Benno Schulenberg aedc3ddd49 tweaks: replace a function call or a macro with a hard number
Verify at startup that the number is not too small.
2017-04-04 19:17:02 +02:00
Benno Schulenberg 754aa8ba79 tweaks: elide a variable and a pair of braces 2017-04-04 19:15:15 +02:00
Benno Schulenberg 53cea142e0 tweaks: use memory on the stack instead of calling malloc() and free()
Rename some variables in the process, and remove two cluttering asserts.
2017-04-04 19:14:14 +02:00
Benno Schulenberg bc9862fbff tweaks: condense some declarations by reshuffling 2017-03-29 21:35:56 +02:00
Benno Schulenberg 582a624998 tweaks: frob some parentheses and other things, to be more consistent 2017-03-29 19:30:37 +02:00
David Lawrence Ramsey 0389a1d939 softwrap: adjust firstcolumn when the window width changes
If the number of columns in the edit window changes (which currently
only happens in two places: in regenerate_screen(), called when the
window is resized; and in main(), when line numbering mode is toggled),
the display will break if we're in softwrap mode and firstcolumn is
nonzero.  This is because the column width of softwrapped chunks has
changed, and firstcolumn is no longer the starting column of a chunk,
an assumption that all code using firstcolumn relies on.

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

(Note that this function uses the simplest possible fix, and could
probably be made more sophisticated.)
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey dd08b638c1 softwrap: account for softwrapped chunks when adding text
Now that we can add text to the bottom right corner of the screen
without scrolling the full line onscreen, do_output() needs to refresh
the screen in that case, since it would put the cursor offscreen
otherwise.  Accomplish this by borrowing logic from do_right().
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey 4144f76e19 softwrap: prepare for a more flexible viewport
We want to be able to scroll the line at edittop partially off the
screen.  For this to be possible, the new variable firstcolumn stores
the starting column of the viewport -- the starting column in the line
that edittop points to.

Since firstcolumn is used by go_back_chunks() and go_forward_chunks(),
it can't be completely #ifdefed out when NANO_TINY is set, but outside
of softwrap mode it should always be zero.

Currently firstcolumn is initialized to zero, reset to zero when
toggling softwrap mode off, and reset to zero when switching buffers
while softwrap mode is off.  It's otherwise unused, but its uses are
forthcoming.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 80b3a3011b weeding: remove ensure_line_is_visible()
Since all lines can be partially scrolled off the screen now
(except for the top line of the edit window, which is forthcoming),
ensure_line_is_visible() is no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 52087408ef softwrap: iterate through softwrapped chunks better in do_mouse()
Use go_back_chunks() and go_forward_chunks() to move from the row
current_y is on to the row mouse_row is on.  Now softwrap mode and
non-softwrap mode will behave the same way when we can scroll edittop
partially off the screen, which is forthcoming.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.

The old code did work, but it behaved differently between softwrap mode
(which counted down from edittop) and non-softwrap mode (which counted
up or down from current_y to take less time, and used a double loop to
keep current from going to NULL).

The new code counts up or down from current_y in both softwrap mode and
non-softwrap mode.  In non-softwrap mode, it also avoids the double loop,
since go_back_chunks() and go_forward_chunks() keep the filestructs they
operate on from going to NULL.
2017-03-22 10:44:04 +01:00
Benno Schulenberg d42f71a2ef tweaks: avoid a few needless reallocations
Most of these variables are freed moments later -- reallocating
them is thus a waste of time.
2017-03-20 13:07:57 +01:00
David Lawrence Ramsey 3c3eb4909d usage: mention the -g/--showcursor option
It's already in the external documentation; it should be here as well.
2017-03-06 21:09:59 +01:00
Mike Frysinger ca86045918 handle builds on systems without termios.h
Windows doesn't have this, so add some build time checks.
2017-03-06 12:02:28 +01:00
Mike Frysinger cab33779ae handle deficient signal systems
Pull in the sigaction module from gnulib, and add ifdef checks
for a bunch of signals that don't exist on Windows.
2017-03-06 12:02:25 +01:00
Mike Frysinger a8deac5845 add an explicit test for set_escdelay()
Not all curses implementations provide this function, so drop it
from depending on slang (and assuming ncurses) to a general build
time test.
2017-03-06 12:02:16 +01:00
Mike Frysinger 272345ccf9 assume getopt_long support is always available
Now that we pull in the gnulib getopt-gnu module, we can assume it exists.
2017-03-06 12:01:12 +01:00
Mike Frysinger 3deec4352b assume regex.h support is always available
Now that we pull in the gnulib regex module, we can assume it exists.
2017-03-06 12:01:08 +01:00
Benno Schulenberg 59e10bdef2 usage: don't mention +LINE,COLUMN as an option, because it isn't
Add its explanation as a separate paragraph.

Also: improve the argument of the --syntax option, as this is a <name>
and not merely a bundle of characters like the other <str> arguments.
2017-02-25 14:05:07 +01:00
David Lawrence Ramsey 6eefad4fff tweaks: mention nano's ability to read from standard input in usage() 2017-02-25 14:00:27 +01:00
Benno Schulenberg 07ebba5e99 tweaks: rename a variable and invert its logic 2017-02-24 12:21:59 +01:00
Benno Schulenberg c118397a14 tweaks: update some copyright years
Reflect the significant changes in painting and regex searching
in the copyright notices.
2017-02-21 20:27:49 +01:00
David Lawrence Ramsey a847d37b24 tweaks: split the grafting code off from copy_from_buffer()
Later on we're going to need the ability to graft a buffer into the
current file buffer without making a copy of it first.
2017-02-17 21:00:34 +01:00
David Lawrence Ramsey 1cb945fe8e tweaks: rename the functions for moving to and copying from a buffer
The name "filestruct" was a mistake.  What was meant was:
buffer -- a linked list of structs that each describe a line.
2017-02-17 20:06:32 +01:00
David Lawrence Ramsey c24545fe9a tweaks: always directly do a refresh when the margin changes
The previous code only directly refreshed the screen when the margin
changed due to toggling line numbering on.  When the margin changed
due to toggling it off, it would indirectly refresh via do_toggle().
2017-02-13 20:25:38 +01:00
Benno Schulenberg 9ec546d293 tweaks: rename a function, and drop an unneeded parameter
When replacements are made, nothing needs to be reset any more
(it was done insufficiently anyway).  Just make sure the screen
is refreshed when all is done -- this may be superfluous when
doing interactive replacements, but not when replacing all.
2017-02-13 19:47:03 +01:00
David Lawrence Ramsey 17f5c056ca tweaks: reduce duplicate code in new_magicline() and move_to_filestruct()
These two functions unnecessarily copy make_new_node(); use that instead.
2017-02-12 10:46:50 +01:00
David Lawrence Ramsey 83ff644b6a tweaks: do a comparison a bit differently in do_output() and do_deletion()
Make it clearer we're comparing the number of rows, not string lengths.
2017-02-05 12:30:09 +01:00
David Lawrence Ramsey 3e22240fd5 tweaks: rename mouse_x & mouse_y to mouse_col & mouse_row in do_mouse() 2017-02-05 12:30:09 +01:00
Benno Schulenberg e8c7cf2071 startup: report an error when the given line or column number is invalid
This fixes https://savannah.gnu.org/bugs/?50028.
2017-01-19 10:33:42 +01:00
David Lawrence Ramsey d35ecd02b8 weeding: remove another unnecessary setting of openfile->current_y
The setting of current_y in copy_from_filestruct() also appears to be
a holdover from the days of a more-common STATIONARY scrolling mode.

do_cut_text() uses the above function when copying text (uncutting
text again right after cutting it).  Since the text is effectively
the same afterward, current_y doesn't need to change.

do_uncut_text(), however, does need current_y up to date in one case:
when uncutting a full screen or less' worth of lines, focusing will be
FALSE, and it uses edit_refresh(), so it will use STATIONARY scrolling
mode then.  Take a cue from do_insertfile() and call reset_cursor() to
get an updated current_y.

(Note that the check for a full screen or less' worth of lines uses
incorrect values when in softwrap mode, but that's a separate problem.)

undo_cut(), do_redo(), and backup_lines() do not need set current_y
because they all result in edit_refresh() with focusing = TRUE, so
they do a CENTERING scroll which does not need current_y.
2017-01-08 17:18:28 +01:00
Benno Schulenberg 8d692a87dc softwrap: don't scroll half a page when just a few lines will do
This fixes https://savannah.gnu.org/bugs/?49824.
2017-01-03 15:26:05 +01:00
Benno Schulenberg 13176792f0 tweaks: frob some comments, elide a variable, and use 'while' loops 2017-01-03 15:05:42 +01:00
David Lawrence Ramsey d7fbc70a72 tweaks: avoid an unnecessary fiddling with current_y in do_mouse()
Since do_mouse() uses edit_redraw(), openfile->current_y will be
immediately recalculated, so there's no point in changing it now.
Use a temporary variable instead.
2017-01-03 14:44:53 +01:00
David Lawrence Ramsey 1dd01eb4e1 tweaks: move a setting, fix a type, and rearrange a line in do_mouse()
The value of sameline doesn't change, so it can be initialized to that.

Since i holds openfile->current_y, it should be ssize_t, not size_t.

And it's better to do the most significant part of a calculation first.
2017-01-03 14:23:40 +01:00
Benno Schulenberg 908663e8fc input: discard a verbatim 0x0A or 0x00 byte, depending on the mode
This disallows entering a verbatim ^J (0x0A) when typing text or
search terms, and disallows a verbatim ^@ (0x00) when typing a
filename.  Nano beeps when the disallowed code is attempted.

This addresses https://savannah.gnu.org/bugs/?49897.
2016-12-27 16:46:09 +01:00
Benno Schulenberg dc18746cbd tweaks: retype, rename, and reshuffle a function 2016-12-23 13:51:58 +01:00
Benno Schulenberg eef7d1047a screen: display byte value 0x0A in the right places as ^@ or as ^J
In path names and file names, 0x0A means an embedded newline and
should be shown as ^J, but in anything related to the file's data,
0x0A is an encoded NUL and should be displayed as ^@.

So... switch mode at the two main entry points into the "file system"
(reading in a file, and writing out a file), and also when drawing the
titlebar.  Switch back to the default mode in the main loop.

This fixes https://savannah.gnu.org/bugs/?49893.
2016-12-23 11:00:55 +01:00
Benno Schulenberg 79a4bf81dc tweaks: rename five variables, for uniformity with a few others 2016-12-19 19:58:15 +01:00
Benno Schulenberg b77e6bd99d general: simplify the detection of a SIGWINCH
There is no need for a counter, nor an old counter to compare it with.
2016-12-19 10:04:01 +01:00
Benno Schulenberg d7af590c6b memory: don't bother making a snug fit for things that will be freed soon
Most full paths are needed only temporarily and will be freed within
milliseconds.  Only 'full_operating_dir' and 'backup_dir' continue to
exist for the whole current session.  Any partition, too, will soon be
unpartitioned, so the extra reallocation is just a waste of time.
2016-12-18 10:33:30 +01:00
Benno Schulenberg 8c7e4f5108 tweaks: rename a function to describe what it does
It doesn't align anything -- any allocations are already aligned to
whatever multiple is required -- it just shrinks the allocated space.
2016-12-18 10:30:35 +01:00
Benno Schulenberg 0562d27b9c tweaks: delete a bunch of unneeded asserts
Nano would crash straight afterward if any of these asserts would fail,
so they don't add anything.  A few others are simply superfluous.
2016-12-15 21:15:32 +01:00
Benno Schulenberg 1df4115013 version: properly mention --disable-wordcomp if it was used 2016-12-15 12:38:47 +01:00
Benno Schulenberg 30591c5e01 tweaks: use a while loop when the end point is not known in advance
It is easier to see the order of steps and what the terminating
condition is.
2016-12-10 21:18:10 +01:00
Benno Schulenberg 3f8e30efb1 tweaks: delete some obscuring debugging stuff
When wanting to debug something, it is far more useful
to temporarily insert lines like:

    statusline(ALERT, "name = %i", variable);

It provides instant feedback, and it slows things down,
so you can kind of see what happens.
2016-12-10 21:01:07 +01:00
Benno Schulenberg e9fde7d7dc mouse: use the correct screen width for calculating the cursor position
When there are line numbers, the effective available screen width is
smaller than COLS: editwincols.

This fixes https://savannah.gnu.org/bugs/?49821.
2016-12-10 20:06:59 +01:00
Benno Schulenberg 68a0314500 build: add configure option --disable-wordcomp to disable word completion
(The variable 'pletion_line' is not conditionalized with this option, as
it would become messy.  The compiler will probably be able to elide it.)

When using --enable-tiny, it is not possible to use --enable-wordcomp,
because the word completion function uses the undo system.
2016-12-07 17:02:25 +01:00
Sumedh Pendurkar dca4ab5d8f new feature: complete a fragment to a longer word found in the buffer
Executing the 'complete_a_word' function will search from the start
of the current buffer for entire words that begin with the fragment
that is before the cursor, and will complete this fragment to the
first word that is found.  Each consecutive call of 'complete_a_word'
will search for the next matching word and will complete the fragment
to that.  By default the function is bound to the ^] keystroke.

Signed-off-by: Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-12-07 16:42:39 +01:00
Benno Schulenberg bfcce57b69 screen: remove an unneeded blanking of the statusbar
It's redundant because the call of total_refresh() wipes everything.
2016-12-04 12:32:59 +01:00
Benno Schulenberg 4eac699df3 tweaks: remove some more annoying conditional compilation 2016-12-04 12:26:33 +01:00
Benno Schulenberg 372bd0f7dd screen: switch the cursor back on only in the main loop
This fixes https://savannah.gnu.org/bugs/?49750.
2016-12-03 18:03:11 +01:00
Benno Schulenberg f920e0d30c tweaks: replace some unneeded direct calls of edit_refresh() 2016-12-03 17:00:28 +01:00
Benno Schulenberg 0f3e303d1a tweaks: get rid of some spurious textual references to edit_refresh() 2016-12-02 18:13:10 +01:00
David Lawrence Ramsey e4d452424b files: give feedback when restricted mode prevents overwriting a file
Achieve this by reusing the code that gives feedback when trying to
save a buffer while using --tempfile and the file has no name yet.

This fixes https://savannah.gnu.org/bugs/?48622.
2016-11-29 12:08:39 +01:00
Benno Schulenberg c1a484270b rcfile: actually avoid opening directories and devices
Achieve this elegantly by factoring out the reading of one rcfile.
2016-11-27 18:21:04 +01:00
Benno Schulenberg eb5968f845 startup: activate restricted mode earlier, so --help will reflect it
Kind-of-discovered-by: Markus Bergholz <markuman@gmail.com>
2016-11-17 18:05:09 +01:00
Benno Schulenberg f2c72bf759 binding: always initialize some keycode variables to a standard value
Also when somehow key_defined() is missing.

This fixes https://savannah.gnu.org/bugs/?49614.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2016-11-17 17:32:28 +01:00
Benno Schulenberg ed165827bc screen: don't hide the cursor when --constantshow is used
(Bug was introduced yesterday, by commit a4132e2.)
2016-11-13 20:00:31 +01:00
Benno Schulenberg 7598b77e75 screen: use the correct width to determine whether a softwrap occurred
This fixes the two bugs reported by Anton Minaev
in https://savannah.gnu.org/bugs/?49511.
2016-11-13 19:20:38 +01:00
Benno Schulenberg a4132e2e64 screen: do a refresh before changing the value of 'focusing'
This fixes https://savannah.gnu.org/bugs/?49530.
2016-11-12 18:02:03 +01:00
Benno Schulenberg 9c2e270b3e softwrap: initialize 'editwincols' early, for computing the number of wraps
When giving a line number on the command line, do_gotolinecolumn() needs
to know the width of the screen to be able to (roughly) place the target
line in the center of the screen.

This fixes https://savannah.gnu.org/bugs/?49462.
2016-10-28 10:50:06 +02:00
Benno Schulenberg ffeb0f9d4b tweaks: don't spread a statement over multiple lines unnecessarily 2016-10-27 11:41:49 +02:00
Benno Schulenberg 10c9093942 general: add the option -g/--showcursor, to match Pico
The nanorc option already exists, but not the corresponding one
for the command line.
2016-10-27 11:34:41 +02:00
Benno Schulenberg b38cbfe173 startup: always initialize 'margin' and 'editwincols'
This fixes https://savannah.gnu.org/bugs/?49428.
2016-10-24 17:40:06 +02:00
Benno Schulenberg 01bbf7e82f tweaks: rename a function to better describe what it does
It does not update anything -- it just picks a new point from
where to start displaying the buffer.  All actual updating of
the screen is done by edit_refresh() and edit_redraw() and such.
2016-10-23 17:26:19 +02:00
Benno Schulenberg ae648778e2 screen: refresh when a new magicline is added in line-numbering mode
This fixes https://savannah.gnu.org/bugs/?49406.
2016-10-21 15:59:16 +02:00
Benno Schulenberg 023edffe3d screen: move the margin determination to the main loop
There is no need to look at this for every painted line, because
the margin can only change when some key is struck.
2016-10-21 14:56:56 +02:00
Benno Schulenberg 2789bb0813 screen: repaint the edit window in a single place -- the main loop
Instead of doing this in two places: after interpreting shortcuts,
and after injecting characters.
2016-10-21 14:56:53 +02:00
Benno Schulenberg de2aa4f24a rcfile: add an option to customize the color of line numbers 2016-10-20 16:48:45 +02:00
Faissal Bensefia de95ca68f7 new feature: the ability to show line numbers before the text
It can be activated with --linenumbers on the command line or with
'set linenumbers' in a nanorc file, and it can be toggled with M-#.

Signed-off-by: Faissal Bensefia <faissaloo@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-10-20 16:47:52 +02:00
Benno Schulenberg 43f35fc7a9 softwrap: ensure the current line is fully visible when moving in it
This fixes https://savannah.gnu.org/bugs/?49099,
and fixes the unreported corresponding bugs for
<End> and <Del> and typing extra characters.
2016-10-18 15:07:47 +02:00
Benno Schulenberg 08cd197bf1 general: include word-jumping and block-jumping into the tiny version
And also case-sensitive searches, backward searches, and searching again.
2016-09-13 09:27:04 +02:00
Benno Schulenberg 57d1755d10 tweaks: preen some comments, and reshuffle a few ifdefs 2016-09-03 12:14:08 +02:00
Benno Schulenberg 7b7d2bf7c9 tweaks: make tiny nano a teeny bit smaller 2016-09-02 12:01:03 +02:00
Benno Schulenberg 96fbdfbc7d input: unset a softmark whenever a character is typed 2016-08-30 10:41:28 +02:00
Benno Schulenberg 514cd9a099 update the license text to the preferred version
Mentioning "GNU nano" instead of "This program" and referring to the
website instead of to a postal address.
2016-08-29 21:27:16 +02:00
Benno Schulenberg 406e5242a3 update the copyright notices 2016-08-29 21:27:05 +02:00
Benno Schulenberg 5ad26f864a tweaks: adjust indentation after previous change 2016-08-29 13:36:29 +02:00
Benno Schulenberg e7f39bc248 tweaks: remove an unneeded check, reshuffle some things, add a comment
Resetting the cutbuffer is irrelevant when 'allow_funcs' is false or
when in view mode, so do_input() can just return in those cases.
2016-08-29 13:35:35 +02:00
Benno Schulenberg 382c9d792d new feature: allow text selection by holding Shift with the cursor keys
Add the keycodes and routines to allow the user to forego setting the
mark explicitly (with M-A / ^6) and instead quickly select a few words
or lines by holding down Shift together with the movement keys.

(Some combinations with Shift are swallowed by some terminal emulators.
To work around some of those, the combinations Shift+Alt+Left/Right work
as Shift+Home/End and Shift+Alt+Up/Down work as Shift+PageUp/PageDown.)
2016-08-28 11:29:28 +02:00
Benno Schulenberg 76a960d73d screen: continue to function also in a terminal with very few lines
This fixes https://savannah.gnu.org/bugs/?48787.
2016-08-17 10:13:22 +02:00
Benno Schulenberg 97eb0e515f tweaks: reshuffle some stuff in a more logical order 2016-08-16 19:22:56 +02:00
Benno Schulenberg 68010d931a startup: don't crash when dying early
That is: don't try to look at open files when none are open yet.
2016-08-16 16:59:37 +02:00
Benno Schulenberg c661506681 tweaks: use a separate function to ask ncurses for keycodes 2016-08-16 12:01:59 +02:00
Benno Schulenberg 0dd2a55284 screen: don't die when the window is narrower than four columns
This fixes https://savannah.gnu.org/bugs/?48520.
2016-08-15 17:25:33 +02:00
Benno Schulenberg 49fc528d88 restore the GNU marker in nano's name 2016-08-14 21:42:37 +02:00
Benno Schulenberg 928a24c204 input: look at the modifier keys only when compiled on Linux
This fixes https://savannah.gnu.org/bugs/?48751 reported by Andrew Ho.

This also fixes compilation when configured with --enable-tiny.
2016-08-14 21:42:08 +02:00
Benno Schulenberg 290d278f68 input: make the Ctrl+Arrow keys work on a Linux console
If this breaks your build, please send report or instructions or patch.
2016-08-07 18:20:34 +02:00
Benno Schulenberg 0a387d9d08 usage: show that the option --wordchars needs an argument 2016-08-07 17:04:23 +02:00
Benno Schulenberg f6dd0ad18a tweaks: compile a parameter unconditionally
Straightforward code is more important than the tiniest possible binary.

Also adjust some comments and rename a variable.
2016-08-02 17:30:58 +02:00
Benno Schulenberg a7ae1766c0 locking: remove any lock files when dying
This fixes https://savannah.gnu.org/bugs/?48675.
2016-08-02 17:30:40 +02:00
Benno Schulenberg 9cd30d4917 tweaks: don't bother setting meta_key to false when a key is invalid
That is a task for the key-getting routine.
2016-07-31 18:32:18 +02:00
Benno Schulenberg cb10b2b908 tweaks: elide the global variable 'func_key'
There is no need to specially flag a function key or editing key --
the keycode is indication enough in itself: outside of byte range.
2016-07-31 18:13:05 +02:00
Benno Schulenberg df7353b312 tweaks: compute the sizes of the subwindows in a more direct manner 2016-07-27 12:27:04 +02:00
Benno Schulenberg c6dbcf91c3 new feature: functions to jump to previous or following block of text
And hard-bind the keys Ctrl+Up and Ctrl+Down to these functions.

Unlike the paragraph-jumping code, these new functions disregard
any indentation, treating only blank lines as separators.  They
also do an automatic smart home when that option is set.

This fulfills https://savannah.gnu.org/bugs/?48291.
2016-07-24 12:00:00 +02:00
Benno Schulenberg b3fbb7c7ff input: report keystroke M-[ as being unbindable instead of just unbound 2016-07-16 14:05:33 +02:00
Benno Schulenberg 6f12992cea new feature: add the option --wordchars, to set extra word characters
This allows the user to specify which other characters, besides the
default alphanumeric ones, should be considered as part of a word, so
that word operations like Ctrl+Left and Ctrl+Right will pass them by.

Using this option overrides the option --wordbounds.

This fulfills https://savannah.gnu.org/bugs/?47283.
2016-07-13 20:49:30 +02:00
Benno Schulenberg f2150d3f98 input: treat Ctrl+Alt+key different from Esc followed by Ctrl+key
When the user changes her mind after having pressed Esc, she cannot
unpress Esc, so do that for her by ignoring the escape code when
the subsequent keycode is outside of the normal printable range.

This restores the behavior from before nano-2.3.5 -- except that
Ctrl+Alt+key continues to report an unbound key.

This fixes https://savannah.gnu.org/bugs/?48459.
2016-07-13 10:01:07 +02:00
Benno Schulenberg 960e848cc7 tweaks: elide a typedef, as it now has just one element 2016-07-12 09:35:48 +02:00
Benno Schulenberg b4737072a6 tweaks: delete an element that is always FALSE and never used 2016-07-12 09:24:32 +02:00
Benno Schulenberg 528b79b5f3 tweaks: rename a variable to be more accurate
When we get a ^J as verbatim input, it is not possible to include it
into the file buffer or the prompt answer, because this would mean
adding an encoded null to the buffer or answer, and that is not what
the user intended.  One option would have been to simply ignore a ^J
in verbatim input.  But the choice has been made to act the same way
as when the ^J (0x0A) is found in the file data: start a new line.

That is the same response as to the Enter key, yes -- but the code
for the Enter key is ^M (0x0D), not ^J.  So, to be more precise,
rename the relevant variable from 'got_enter' to 'got_newline'.
2016-07-03 16:19:27 +02:00
Benno Schulenberg 07a39e8e18 screen: don't simulate a sigwinch but directly reinitialize the screen
This fixes the second part of https://savannah.gnu.org/bugs/?48331.

Reported-by: Mike Frysinger <vapier@gentoo.org>
2016-06-29 15:55:38 +02:00
Benno Schulenberg 2ae490cd8f build: refresh the git description whenever something is recompiled
This fixes https://savannah.gnu.org/bugs/?47962 reported by Cody Taylor.
2016-06-27 19:45:21 +02:00
Benno Schulenberg 067b0a3367 input: elide an extra buffer for inserting stuff into the text
Do the casting from integer to character rightaway in the first
intermediate buffer.
2016-06-27 19:18:40 +02:00
Benno Schulenberg ddd9c7a022 tweaks: try to distinguish between keystrokes and characters
Keystrokes are single integers (aided by the flags meta_key and
func_key) but in the input stream they can be encoded as escape
sequences (a series of bytes).  Characters are values in byte
range, but in UTF-8 one character can consist of multiple bytes.

Also rename two variables, because the secondary input buffer
that they refer to contains only characters (mostly just one),
never any shortcuts; and there are too many "kbinput" already.
2016-06-25 20:34:09 +02:00
Jordi Mallach c2b199e926 docs: use https for nano-editor.org, and drop the www
Switch to https and drop the www. prefix for all occurrences of the
website URL.
2016-06-23 19:51:01 +02:00
Benno Schulenberg 80552aeab7 tweaks: elide an intermediate copy of some line data 2016-06-22 10:30:52 +02:00
Benno Schulenberg 9106cc8ecc main: let the main loop restore the main menu, if needed
Don't make it the responsibility of the executed functions to restore
the list of shortcuts of the edit window.  Just detect whether another
menu was displayed, and if so, redisplay the main menu.
2016-06-21 11:03:38 +02:00
Benno Schulenberg 17fb6dfdc0 tweaks: reshuffle two lines and improve two comments 2016-06-20 13:07:25 +02:00
Benno Schulenberg 95f417fa9a tweaks: rewrap a bunch of lines and some comments 2016-06-20 13:05:45 +02:00
Benno Schulenberg 3e45c9c5cf version: cover the copyrights that are not assigned to the FSF 2016-06-15 21:28:11 +02:00
Benno Schulenberg 7165bd5c33 input: don't allocate too much, and don't move too many
To add a character, one does not need to allocate twice its size.
And the amount to be moved does not depend on the size of the new
character; it just needs to include the terminating zero.

(This fixes in do_output() the same logical mistakes that were fixed
in do_statusbar_output() last February, in acf19bd and 7c0e433.)
2016-06-14 17:00:22 +02:00
Benno Schulenberg 3e5fcec76c remove the GNU marker from nano's name
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-06-13 12:22:33 +02:00
Benno Schulenberg aa09abe198 files: when the requested operating directory cannot be set, fail
Specifying an operating directory should either lead to a successfull
confinement, or nano should fail to start.

(Also: save the terminal settings as soon as possible, so that an early
die() will not restore uninitialized values.)

This fixes the first part of https://savannah.gnu.org/bugs/?47798 properly.
2016-06-12 11:13:45 +02:00
Benno Schulenberg 17cf833b9c tweaks: normalize some whitespace 2016-05-30 09:09:36 +02:00
Benno Schulenberg e3e3f655ee tweaks: use an available macro to silence a compiler warning 2016-05-27 21:48:38 +02:00
Benno Schulenberg 3129ff687a tweaks: rename a variable, because nothing is returned there 2016-05-27 21:43:39 +02:00
Mike Scalora 6a2032f5b0 new feature: comment/uncomment current line or selected lines
This allows for commenting or uncommenting a line or a bunch of lines
with a single keystroke (default binding: M-3).  The characters used
for commenting/uncommenting are specified by the active syntax file.

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Mike Scalora <mike@scalora.org>
2016-05-25 22:29:50 +02:00
Benno Schulenberg c0285682e4 startup: show an error message when argument of --operatingdir is invalid
Move the initialization of the operating directory to after the
initialization of the screen, so that the above error can be shown.

This fixes the first part of https://savannah.gnu.org/bugs/?47798.
2016-05-22 11:41:58 +02:00
Benno Schulenberg c8f530af93 statusbar: add a non-beeping message type that does not get overwritten
Error messages about lock files should not get overwritten by purely
informational messages, only by alerting ones.

This fixes https://savannah.gnu.org/bugs/?47963.
2016-05-21 13:58:09 +02:00
Benno Schulenberg 906ada8fe7 files: remove the special 'quiet' mechanism for not overwriting messages
The general mechanism for not allowing important messages to be overwritten
will take care of not overwriting warnings about failed file lockings.
2016-05-18 12:04:45 +02:00
Benno Schulenberg 2535f51e01 statusbar: prevent error messages from overwriting each other
If during startup there are multiple error messages, currently only the
last one remains and can be read.  To improve on that, introduce a short
pause between error messages -- even if it's not enough to read them all,
at least the user will be aware that there are multiple ones.

This also causes a few error messages to beep that currently don't beep,
such as when a file is unwritable.
2016-05-16 18:03:07 +02:00
Benno Schulenberg 04a230f933 tweaks: avoid a warning when configured with --disable-wrapping 2016-05-16 16:36:49 +02:00
Benno Schulenberg 318ed6b105 scrolling: center the cursor when inserted stuff does not fit on screen
Since nano-2.4.1, reading in or pasting a large piece of text would put
the cursor on the bottom line, leaving only one line of the non-read or
non-pasted text visible.  This is different from the centering behavior
of Pico, and somewhat disorienting, as you can't see "where you are" any
more in relation to the file as it was.

So now center the cursor whenever the read or pasted text is larger than
the screen, but don't center it when the text fits entirely on the screen.
(The latter avoids the effect of the screen jumping unnecessarily when
inserting just a few lines while the cursor is near the bottom.)

To achieve this behavior: default to focusing, and temporarily set it to
FALSE when the focusing effect is unwanted.

This fixes https://savannah.gnu.org/bugs/?47841.
2016-05-04 10:13:36 +02:00
Benno Schulenberg e0c4f9c5fe input: give more detailed feedback when an unbound key is struck 2016-05-01 22:04:32 +02:00
Benno Schulenberg 53f4a9f5a8 screen: rename 'edit_refresh_needed' to 'refresh_needed'
For a little contrast with the function edit_refresh() -- it's
annoying that when you search for the latter you get to see all
the settings of the flag too.
2016-04-25 21:14:18 +02:00
Benno Schulenberg b97c36c218 screen: don't always set 'edit_refresh_needed' when adjusting edittop
The function edit_update() is called by edit_refresh() itself, so it is
silly that the first sets 'edit_refresh_needed' to TRUE.  This setting
is needed only in a few cases -- in the others it's not needed because
the screen does not need to be refreshed (it was just about positioning
the cursor), or 'edit_refresh_needed' has already been set by a call to
goto_line_posx().  So, just set the flag in the five places that need it
and spare the other four calls.
2016-04-25 20:17:40 +02:00
Benno Schulenberg 907ba3a2e2 scrolling: catch the special case of reading a file from standard input
Since commit dac0aa1, nano would leave edittop at current after reading
data from standard input, meaning that everything that had been read in
was invisible, "scrolled off" the top of the screen.  Correct this by
explicitly setting edittop.

The above does not happen for ^R (^X) because it has a special mechanism
to save and restore edittop.  Nor does it happen for ^R ^X M-F because it
sets current to the top of the file and refreshing the screen will make
edittop follow, or -- in case just one unterminated line was read in --
edittop will already be equal to current.
2016-04-25 17:48:06 +02:00
Benno Schulenberg 34a20f8839 prompt: properly save and restore the x position in the statusbar
This fixes https://savannah.gnu.org/bugs/?47720.
2016-04-17 15:24:05 +02:00
Benno Schulenberg ec295f5e68 build-sys: detect a build from git and show its short commit hash 2016-04-12 10:28:45 +02:00
Benno Schulenberg aa1ae0a144 screen: concentrate the setting of placewewant
Instead of saving the current value of placewewant, then setting the
new value, and then passing the old value to edit_redraw() in seven
different places, just let edit_redraw() do this saving and setting.

In the bargain placewewant is now only recalculated when it matters
-- when allow_update is TRUE -- and not when it's superfluous.
2016-04-11 20:38:05 +02:00
Benno Schulenberg cb17732ac2 scrolling: don't scroll too much when having to bridge blank lines
Add a third mode of scrolling, FLOWING, besides CENTERING and STATIONARY.
This is used for word and paragraph jumping (and for bracket matching,
but that worked correctly already), and only when focusing is FALSE.

The new mode prevents the screen from scrolling too many lines when
there are several blank lines at the bottom of the edit window and
the next word or paragraph is out of view.

This fixes https://savannah.gnu.org/bugs/?47194.
2016-04-07 14:28:25 +02:00
Benno Schulenberg d92eb4fee3 all: eradicate SVN's $Id$ tags 2016-04-05 14:59:12 +02:00
Benno Schulenberg 7561b1b026 Placing the cursor in the edit window also when --constantshow is in effect.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5770 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-29 12:14:00 +00:00
Benno Schulenberg 51743233ed Removing the 'last_replace' variable that is never used.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5768 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-28 19:14:33 +00:00
Benno Schulenberg 2f817a6740 Checking for the existence of the REG_ENHANCED regex flag, and
using it when it's available (which it is on OS X systems).
This completes the fix for Savannah bug #47325.
Patch by Thomas Rosenau.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5759 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-22 10:42:28 +00:00
Benno Schulenberg 1ef62490dd Normalizing the punctuation in some prompts: no space before a question mark,
and a semicolon instead of a comma between phrases.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5750 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-20 10:57:14 +00:00
Benno Schulenberg 486e828443 Eliding splice_opennode() by handling the two cases (the creation of
the first element, and the insertion of a new element) directly.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5678 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-25 18:58:17 +00:00
Benno Schulenberg f5eb316603 Rewrapping and reshuffling some lines.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5673 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-23 12:37:10 +00:00
Benno Schulenberg a9a32d6d89 Centering the cursor when the thing being undone or redone is currently
off the screen.

See https://lists.gnu.org/archive/html/nano-devel/2016-02/msg00104.html.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5672 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-23 12:18:10 +00:00
Benno Schulenberg f4f9954556 Eliding the function free_openfilestruct() as it is used only once.
(Note that openfile cannot be NULL here.  And in case it is,
nano should crash because DEBUG is enabled.)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5658 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-22 09:02:58 +00:00
Benno Schulenberg 9703934479 Allowing the parameter of free_filestruct() to be NULL,
so we can delete four annoying pre-checks.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5651 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-18 19:58:18 +00:00
Benno Schulenberg 568d2a389c Switching the cursor on and off at the appropriate moments (that is: when
needed), so that it no longer shows in the help screen nor in the file list.
This fixes Savannah bug #47126.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5640 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-13 19:41:12 +00:00
Benno Schulenberg b8e0e22d64 Switching the cursor on in the right place: in the central input routine.
This makes the cursor visible again during linting.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5628 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-10 20:16:50 +00:00
Benno Schulenberg 97dcd377e7 Turning the cursor off when writing in the status bar,
and ensuring it is on when waiting for input.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5610 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-06 11:18:27 +00:00
Benno Schulenberg cc2d37053c Updating the screen immediately when a message is posted on the status bar.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5609 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-06 11:05:58 +00:00
Benno Schulenberg 6829241433 Removing the --nofollow option that hasn't been working for a dozen years.
With this option, nano would simply refuse to write to any symlinked file;
if anyone really used this option, they would certainly have complained.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5608 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-06 10:59:31 +00:00
Benno Schulenberg 98e72f50e6 Checking the position history only when 'positionlog' is set
/also/ for the first file.  :|


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5599 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-29 17:18:27 +00:00
Benno Schulenberg f8ed6bb099 Checking the position history only when option 'positionlog' is set.
This fixes a bug reported by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5597 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-29 16:20:28 +00:00
Benno Schulenberg 7a1709f03b Removing a now unneeded function, as nothing can break out of do_prompt()
any more, not a SIGWINCH either.  And deleting an always-FALSE 'if'.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5577 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-21 18:23:17 +00:00
Benno Schulenberg f845938e86 Freeing the items on the undo stack when a buffer is closed.
This fixes Savannah bug #46904 reported by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5567 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-15 16:44:50 +00:00
Benno Schulenberg 1b293ff34c Adjusting dates and version number.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5542 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-10 16:18:43 +00:00
Benno Schulenberg 9e6b9a29a5 Improving the name of allow_pending_sigwinch() to allow_sigwinch(),
and improving its comments too.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5532 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-04 10:37:11 +00:00
Benno Schulenberg dd29c56993 Rewriting the loop, and constifying the input of sctofunc().
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5530 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-04 09:52:43 +00:00
Benno Schulenberg 42a761e77f Adjusting the indentation after the previous change.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5527 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-03 17:37:05 +00:00
Benno Schulenberg 0d85c8c68c Alerting the user when a functionless shortcut is encountered.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5526 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-03 17:07:29 +00:00
Benno Schulenberg a5bc70a541 Aborting reset_multis() when there are zero multiline regexes.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5525 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-03 16:57:17 +00:00
Benno Schulenberg 37712fb120 Letting reset_multis() figure out whether after an addition a full refresh is
needed (for the sake of multiline regexes), instead of doing it always.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5524 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-03 16:21:04 +00:00
Benno Schulenberg 5765e9675f Letting reset_multis() figure out whether after a deletion a full refresh is
needed, before doing a redraw of the current line.
This fixes Savannah bug #46794


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5523 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-03 15:35:52 +00:00
Benno Schulenberg 46db638435 Chopping a duplicate parameter.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5519 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-31 19:20:40 +00:00
Benno Schulenberg 1592ca0585 Chopping an always FALSE parameter.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5518 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-31 17:20:46 +00:00
Benno Schulenberg 37d8ad8687 Not trying to position the cursor when opening a buffer failed.
This fixes Savannah bug #46778.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5514 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-30 10:11:20 +00:00
Benno Schulenberg 8cc6308f9c Offering ^Q in the writeout menu to close and discard the current buffer
without saving it.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5509 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-23 16:34:44 +00:00
Benno Schulenberg 1bebe34b56 Preventing valid pointers from getting truncated and rejected.
Patch by Mike Frysinger, tweaked by Benno.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5508 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-23 14:05:47 +00:00
Benno Schulenberg 31f0456e9a Moving two functions to the color.c file, where they belong.
And making the checking for an impatient user into a separate routine.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5501 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-22 16:51:00 +00:00
Benno Schulenberg 5737fe3461 Precalculating the multiline-regex cache data for each buffer,
not just for the first.  This fixes Savannah bug #46511.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5500 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-20 21:10:41 +00:00
Benno Schulenberg a64bfbee8b Letting also unlink_node() update 'filebot', instead of doing it in
four different places.  It is not a problem that the history routines
also use these functions, as history nodes will never equal filebot.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5491 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-08 16:02:05 +00:00
Benno Schulenberg 77c0357868 Making splice_node() update 'filebot', instead of doing it in
four different places.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5490 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-08 15:29:56 +00:00
Chris Allegretta c4a6725ad6 2015-12-05 Chris Allegretta <chrisa@asty.org>
* src/nano.c (main) : key_defined() is an ncurses-ism.  Add
	better checks for this.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5482 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-06 05:21:43 +00:00
Benno Schulenberg f2da466388 Rewrapping some lines and tweaking some comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5478 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-04 21:11:10 +00:00
Benno Schulenberg b1d6d7f95c Initializing a newly allocated multidata array.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5447 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-28 19:03:33 +00:00
Benno Schulenberg be01647a18 Allowing the user full control over the values of MALLOC_CHECK_ and
MALLOC_PERTURB_; nano shouldn't override them.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5446 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-28 17:29:39 +00:00
Benno Schulenberg 438cb110ff Refreshing the whole edit window only when there are multiline regexes,
and checking for this just once for every burst of keystrokes.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5439 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-25 09:10:02 +00:00
Benno Schulenberg e0d0ca4b97 Renaming a variable for clarity.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5438 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-24 13:28:32 +00:00
Benno Schulenberg fbe4376822 Inserting a new node into a linked list by using just two parameters:
the insertion point and the new node.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5437 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-24 13:24:01 +00:00
Benno Schulenberg f08d79d204 Making Ctrl+Left and Ctrl+Right work on more terminals by asking
ncurses for the keycodes.  This addresses Debian bug #800681.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5434 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-23 08:52:23 +00:00
Benno Schulenberg 72caa54020 Deleting a node right after unlinking it.
This now mirrors unlink_opennode() and delete_opennode().


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5433 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-22 16:14:42 +00:00
Benno Schulenberg 6007d6227b Rewrapping, rewriting, renaming, and reordering some things.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5431 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-22 16:08:28 +00:00
Benno Schulenberg 1f027a838e Letting the value of a --fill option on the command line
override the value of a "set fill" option in an rcfile.
This fixes Savannah bug #46492.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5428 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-21 19:44:27 +00:00
Benno Schulenberg 54c2f6b5ae Chopping the now unused parameter 'undoing'.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5401 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-11-11 19:04:31 +00:00
Benno Schulenberg df80bfd2fc Improving comments and combining two conditions.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5385 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-31 20:17:09 +00:00
Benno Schulenberg 4a1835fd93 Refreshing the mark's pointer only when it is on the same line as the cursor,
and recalculating the mark's x coordinate only when the mark comes after it.
Also correcting the recalculation in one case.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5384 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-31 19:03:53 +00:00
Benno Schulenberg 0d9397e5b0 Making ^O work the same way as under Pico when option -t is given:
writing out the file immediately, without prompting.
Patch by David Lawrence Ramsey.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5378 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-10-29 10:36:07 +00:00
Benno Schulenberg 8925eabd5e Not bothering to set things to NULL when they will be initialized right away,
nor bothering with a separate initialization function when it's used only once.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5365 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 15:21:32 +00:00
Benno Schulenberg 149b1fe439 Removing some duplication in the initialization of a new openfile node.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5364 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-16 13:05:35 +00:00
Benno Schulenberg f5234e583f Making a message sound more definitive instead of temporary.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5351 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-09 18:12:32 +00:00
Benno Schulenberg ea2b51a41d Removing an unneeded and mistaken condition:
if something should be blanked, then both.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5350 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-09 18:10:13 +00:00
Benno Schulenberg eac0446c86 Fixing compilation with --enable-tiny: file formats don't exist then.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5349 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-09 16:31:01 +00:00
Benno Schulenberg 90798fbfba Allowing to toggle whitespace display also when support for nanorc files
has not been built in, since the default values are quite usable.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5348 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-09 16:05:50 +00:00
Benno Schulenberg 30daf4d43f Letting malloc() help to find initialization failures and uses-after-free.
Change was suggested by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5345 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-06 09:01:33 +00:00
Benno Schulenberg 70cbbda87c Adding the option --unix (and 'set unix'),
to save a file by default in Unix format.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5342 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-04 18:49:57 +00:00
Benno Schulenberg ace151778b Adding "and exit" to the description of --help, for veracity, to match
--version, and to distinguish it more from the description of ^G.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5337 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-01 08:47:38 +00:00
Benno Schulenberg e919c22793 Setting each multiline-color value instead of OR-ing it.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5335 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-08-01 08:35:14 +00:00
Benno Schulenberg 20ba559b9f Providing feedback for ^Z when suspension is not enabled.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5333 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-30 20:15:01 +00:00
Benno Schulenberg 6847616aee Differentiating between something being disabled/restricted and
help texts being unavailable.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5331 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-30 18:10:16 +00:00
Benno Schulenberg 104ea6b0c3 Normalizing whitespace after the preceding changes.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5330 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-30 11:29:45 +00:00
Benno Schulenberg efbf7b6ef3 Making the four toggles that don't have any effect in restricted mode
say that they're disabled.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5328 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-29 20:21:45 +00:00
Benno Schulenberg 5885e34b23 Not showing options that don't have any effect when asking for --help in
restricted mode.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5327 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-29 19:31:50 +00:00
Benno Schulenberg bff6a905af Reenabling SIGWINCH-es also when invocation of the formatter fails,
and correcting some comments.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5324 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-28 19:39:34 +00:00
Benno Schulenberg d52f108526 Adjusting some comments for clarity and accuracy, and rewrapping some lines.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5312 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-19 09:25:25 +00:00
Benno Schulenberg 9dc544acbd Accepting again a +LINE argument for each file given on the command line,
instead of only for the first.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5311 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-19 09:01:59 +00:00
Benno Schulenberg 74e7521478 Adjusting some comments.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5308 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-18 10:32:01 +00:00
Benno Schulenberg cadb4f3689 Unabbreviating the long option --poslog to --positionlog.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5300 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-15 19:50:55 +00:00
Benno Schulenberg 79526151d5 Unabbreviating the long option --const to --constantshow.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5299 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-15 19:40:37 +00:00
Benno Schulenberg ea4b775a3e Eliding an unneeded variable.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5289 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-10 16:00:12 +00:00
Benno Schulenberg 9fcde23009 Plugging a small memory leak.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5287 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-07-10 15:54:06 +00:00
Benno Schulenberg 4499520c03 Removing the obsolete long option --undo, and sorting some things.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5265 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-20 18:48:43 +00:00
Benno Schulenberg c32a58a826 Not checking for non-NULL before freeing a variable, as it's unnecessary.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5249 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-06-14 19:14:41 +00:00
Benno Schulenberg 75d64e677e Handling a SIGWINCH (which signals a change in window size) not when it
happens but only when checking for keyboard input.  It now reports the
SIGWINCH via a special key value to the calling routine, to allow not
only the main editor but also the help viewer and the file browser to
adapt their display to the new size.
Patch by Mahyar Abbaspour, somewhat edited by Benno.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5228 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-28 13:02:29 +00:00
Benno Schulenberg a338798559 Adjusting a few comments and line wrappings.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5222 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-05-03 13:56:51 +00:00
Benno Schulenberg 1cf22d4d4f Initializing the search and replace strings in a central place.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5212 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-21 18:42:11 +00:00
Benno Schulenberg 296152ec67 Making the descriptions of the multibuffer feature more accurate.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5205 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-04-18 16:07:53 +00:00
Benno Schulenberg 0b6d6f45d2 Normalizing some whitespace.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5166 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-27 13:46:50 +00:00
Benno Schulenberg 3345e3407d Normalizing some whitespace, removing an old comment,
and placing another one better.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5141 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-20 11:18:22 +00:00
Benno Schulenberg 4d9b5e92b3 Getting out if there is nothing to renumber,
to prevent do_undo() from falling over when trying to renumber emptiness.
Patch basically by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5137 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-14 15:59:01 +00:00
Benno Schulenberg 18a2edfb84 Dropping compile time from version information to enable a reproducible
build.  Proposed by Jérémy Bobbio and Jordi Mallach.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5136 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-08 20:14:10 +00:00
Benno Schulenberg 03bcaf6067 Fixing compilation with --enable-tiny plus --enable-nanorc.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5133 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-03-08 12:10:52 +00:00
Benno Schulenberg 57fa775f25 Updating the copyright years to include 2015.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5107 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-02-01 09:32:02 +00:00
Chris Allegretta 5b1fb56a8f Take 2 at file locking fixes. New args to close_buffer() and
switch_to_prevnext_buffer() to support message passthrough
when trying to lock files using multibuffer.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5105 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-01-20 06:15:34 +00:00
Benno Schulenberg 2394e52ebc Making sure line renumbering starts far enough back after
undoing a cut or paste.  And fixing two memory leaks.
Patch by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5067 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-07-16 08:46:42 +00:00
Benno Schulenberg 92213f9de8 Handling the cases of cutting-from-cursor-to-end-of-line
(that is, when CUT_TO_END is set) properly.
Patch by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5054 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-07-02 20:29:57 +00:00
Benno Schulenberg 85ddc718f8 Properly excluding the --quiet option when --disable-nanorc was given.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5053 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-07-02 19:57:23 +00:00
Benno Schulenberg 49816fed70 Now that 'currmenu' is really global, stop passing it around.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5043 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-07-01 10:41:10 +00:00
Benno Schulenberg 95e77a9d5f Renaming '*cut_till_end' to '*cut_till_eof', to reduce
confusion with CUT_TO_END, which is about end-of-line.
Patch by Mark Majeres.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5041 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-30 20:39:27 +00:00
Benno Schulenberg 7e5324d164 Making 'meta_key' and 'func_key' into global variables, instead of
having them declared everywhere and passing them around endlessly.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5039 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-30 18:04:33 +00:00
Benno Schulenberg 8ea830f79b When toggling softwrap, only the edit window needs to be refreshed,
not the entire screen.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5010 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-22 19:23:54 +00:00
Benno Schulenberg f80dcb2b25 Miscellaneous whitespace fixes, one type fix, and one more #ifdef NANO_TINY.
Patch by David Lawrence Ramsey.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5004 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-21 19:01:51 +00:00
Benno Schulenberg 3060ce36d3 Letting +1 and +,1 make nano start on line one column one, overriding
a position from history.  This fixes Savannah bug #42538.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5003 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-20 19:10:24 +00:00
Benno Schulenberg 1930e8102d Fixing compilation with --enable-tiny --enable-mouse.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5001 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-20 18:06:22 +00:00
Benno Schulenberg b341f29cbd Transform many DISABLE_NANORC #ifdefs to the new DISABLE_HISTORIES.
This completes the fix for Savannah bug #42539.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4989 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-19 20:05:24 +00:00
Benno Schulenberg fcb4c3fc6e Allowing --historylog and --poslog to function
also when --ignorercfiles is given.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4987 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-19 15:09:23 +00:00
Benno Schulenberg e7c690d577 Renaming 'no_more_space()' to 'more_space()' for consistency.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4985 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-19 11:58:11 +00:00
Benno Schulenberg 4f3f976030 Displaying "No file name" on the statusbar for two seconds
when --tempfile was given and the current buffer has no name.
This fixes Savannah bug #41750.  Patch by David Lawrence Ramsey.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4974 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-16 20:44:34 +00:00
Benno Schulenberg 0ec771009c Putting a common statement outside of the then/else branches.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4969 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-16 12:40:14 +00:00
Benno Schulenberg 99a649ddf6 Avoiding an "Unknown Command" on every cursor-positioning mouse click.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4968 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-16 12:30:35 +00:00
Benno Schulenberg 736fbf2e3f Removing the --undo option, having the undo functions always enabled.
If wished, the user can unbind them.  This fixes Savannah bug #42456.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4964 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-13 15:20:26 +00:00
Benno Schulenberg 3af22aad8d Letting a toggle not break a series of ^Ks.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4962 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-13 12:28:33 +00:00
Benno Schulenberg 1d06455ca5 Letting a click on titlebar or statusbar not break a series of ^Ks.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4961 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-13 12:19:44 +00:00
Benno Schulenberg 454563c9dc Letting a mousal repositioning of the cursor break a series of ^Ks.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4960 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-13 12:07:18 +00:00
Benno Schulenberg 8cc8b08dfc Removing a superfluous switch statement.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4958 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-11 18:34:35 +00:00
Benno Schulenberg fc35e20052 Always accepting mouse events, also when just looking for Unjustify.
This fixes Savannah bug #42322.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4957 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-11 18:23:29 +00:00
Benno Schulenberg a3f421ca2b Producing the correct return value for when a mouse event reinserted something
into the keyboard buffer.  And not continuing but getting out when there is a
spurious  mouse event.  Continuing would result in the cutbuffer being cleared
upon the next cut.  These two changes together fix Savannah bug #42326.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4956 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2014-06-11 18:04:36 +00:00