Commit Graph

1396 Commits (ba25d0df1d0bec5f6803f8b5082e78e73299cf7a)

Author SHA1 Message Date
Benno Schulenberg 5dbd9c0043 options: add -f, --finalnewline, the counterpart of --nonewlines 2019-02-18 09:34:18 +01:00
Benno Schulenberg cd9328fbf5 options: add -b, --breaklonglines, the counterpart of --nowrap 2019-02-18 09:34:18 +01:00
Benno Schulenberg ebfe752841 tweaks: rename some variables from a single letter to meaningful word 2019-02-12 16:06:24 +01:00
Benno Schulenberg b89540218d tweaks: add two comments, and reduce the scope of another variable 2019-01-27 11:18:55 +01:00
Benno Schulenberg 77c60201d5 tweaks: reduce the scope of a variable, and rename it 2019-01-27 11:10:29 +01:00
Benno Schulenberg 2482cfca56 build: eradicate the --disable-wrapping-as-root configure option
Hard-wrapping is disabled by default for any user, so this special
configure option is no longer needed.
2019-01-25 11:37:51 +01:00
Benno Schulenberg 946755a307 options: disable hard-wrapping and automatic newlines by default
Also, enable smooth scrolling by default, and don't waste the row
directly below the title bar.  The use of the latter also serves
as a small visual reminder that this nano is different.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Bug existed since version 2.9.4, commit 54103d8e.

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

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

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

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

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

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

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

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

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

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

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

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

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