Commit Graph

758 Commits (eed765f4f757067165b75d32410dada963c46e3a)

Author SHA1 Message Date
David Lawrence Ramsey 2f6c8987ea softwrap: move the updating of a softwrapped line to a new function
The new function, update_softwrapped_line(), is called from inside
update_line() when softwrap mode is on, so that existing calls remain
unchanged.  It takes no index, instead displaying edittop from column
firstcolumn, and all other lines from column zero.

If current is on edittop, it's displayed using the edittop rules, but
this is not a problem: if current[current_x] is above edittop at column
firstcolumn, it's offscreen, and that should be handled before calling
update_line() anyway.

Together with the preceding bunch of changes,
this fixes https://savannah.gnu.org/bugs/?47667.
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 812ecaeb0c weeding: remove maxlines and related code
Since all lines can be partially scrolled off the screen now
(except for edittop, which is forthcoming), the maxlines global
variable and its computation mechanism are no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey a5e106d764 tweaks: add a parameter to do_home() and do_end()
Add the parameter be_clever to both functions.  When be_clever is FALSE,
smart home and dynamic home are disabled in do_home(), and dynamic end is
disabled in do_end(), so that these functions only move to the beginning
or end of the current line or chunk.

This simple home and end functionality is needed to improve do_left()
and do_right()'s horizontal behavior with softwrapped chunks, which is
forthcoming.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey d8189703b1 tweaks: prepare for improvements to do_home() and do_end()
These improvements will eventually make do_home() and do_end() take
parameters.  Since the global function lists can hold only functions
without parameters, preemptively add do_home_void() and do_end_void(),
and make the global function lists use them.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey eb369c0e00 tweaks: rename need_horizontal_scroll() to line_needs_update()
The old name made it sound as if it didn't apply in softwrap mode.  But
it does: in softwrap mode a line needs updating  when the mark is on.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 380ad30a53 softwrap: account for softwrap when checking whether current is offscreen
Add the new functions current_is_above_screen() (which doesn't account
for softwrapped chunks yet, but will when we can scroll edittop partially
off the screen, which is forthcoming), current_is_below_screen() (which
determines whether current[current_x] is past the softwrapped chunk at
the bottom of the screen), and current_is_offscreen() (the union of the
previous two functions).

edit_redraw() and edit_refresh() now use current_is_offscreen() to check
whether they should adjust the viewport, and adjust_viewport() now uses
current_is_above_screen() to determine whether current is on or below
the screen in FLOWING mode.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 4f9c563e6b softwrap: count softwrapped chunks properly in do_uncut_text()
Add the new function less_than_a_screenful() to accomplish this.
It uses go_back_chunks() to count the number of softwrapped chunks
between the end point and the starting point of the paste.

Now softwrap mode and non-softwrap mode behave the same way when
uncutting fewer than editwinrows rows of text.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 456d66b904 softwrap: add two chunk-iterator functions
These functions, go_back_chunks() and go_forward_chunks(), take a number
of softwrapped chunks (screen rows) to move, a pointer to a buffer, and
a location (specifically, a starting column of a softwrapped chunk).  If
they move successfully, they will update the buffer pointer and location
to point to the beginning of the softwrapped chunk they moved to.

Since non-softwrap mode is effectively just a subset of softwrap mode
in which every line takes up one chunk, these functions also work in
non-softwrap mode.  In this case, their starting column will always be
zero, as it would be in softwrap mode on a line that takes up one chunk.

Nothing uses these functions yet, but that is forthcoming.
2017-03-22 10:44:04 +01:00
Benno Schulenberg f48e15f2a3 tweaks: rename and shorten a small helper function 2017-03-20 12:24:42 +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
Mike Frysinger 63cae0c199 drop the isblank/iswblank fallback functions
Switch over to gnulib for these.
2017-03-06 12:01:05 +01:00
Mike Frysinger e9a3f858bc drop the getdelim/getline fallback functions
Switch over to gnulib for these.
2017-03-06 12:01:02 +01:00
Mike Frysinger 28133e934d drop various str fallback functions
These are provided by gnulib now.
2017-03-06 12:00:57 +01:00
David Lawrence Ramsey 234bd9c9be speller: fix replacing marked text in the alternate spell checker
With read_file() revamped, it now uses partition_filestruct() indirectly
via ingraft_buffer(), so we can't use partition_filestruct() to replace
marked text in the alternate spell checker anymore without segfaulting.

Add the new function replace_marked_buffer() to accomplish this instead.
Based on replace_buffer(), it uses extract_buffer() to throw away the
marked un-spell-checked text, and then uses read_file() to insert the
spell-checked text at the position where the mark was.

Accordingly, remove unneeded partitioning and related stuff from
do_alt_speller().  Besides pasting the file into the buffer at
current[current_x], ingraft_buffer() also deals with renumbering,
updating totsize, and handling a magicline, so do_alt_speller()
doesn't need to do those anymore.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey 86f7bc1868 files: revamp the insertion of a file, to be more like pasting text
Move buffer handling and '\r' stripping from read_line() to read_file(),
so that the file gets its format determined and gets stored in its own
buffer entirely in one function.  Then use ingraft_buffer() to insert
this new buffer into the current one.

In addition to pasting the file at current[current_x], ingraft_buffer()
also deals with renumbering, the updating of totsize, and the handling
of a magicline, so read_file() doesn't need to do those anymore.

Note that all this makes read_file() depend on the position of
current[current_x] to know where to insert the file.  Accordingly,
set current_x to zero in initialize_buffer_text() instead of in
make_new_buffer(), so that replace_buffer() keeps working properly.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey f95836a951 tweaks: remove cluttering #ifdefs from break_line()
Also, rename a parameter to be less cryptic, and remove an entire
condition because the relevant block will never be reached when
getting called from the help routines: if blank_loc is negative,
the function will have bailed out in the preceding if.
2017-02-24 17:33:39 +01:00
Benno Schulenberg 07ebba5e99 tweaks: rename a variable and invert its logic 2017-02-24 12:21:59 +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 f773d715e8 tweaks: rewrap two lines and fix two typos 2017-02-17 19:55:54 +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
Benno Schulenberg 8f10e364bb replacing: stop searching in a region when edge of buffer is reached
Just like when spell-checking, there is no need to wrap around when
doing replacements in a region, because a region cannot straddle the
buffer's edges.

This is the proper fix for https://savannah.gnu.org/bugs/?50158,
and fixes https://savannah.gnu.org/bugs/?50273.
2017-02-10 13:51:51 +01:00
David Lawrence Ramsey b1b9770c57 tweaks: rename a variable and adjust some types in edit_scroll()
Scrolling works on rows, not on lines.  Accordingly, rename the nlines
variable to nrows.  And rows should be of the type int, not ssize_t.
2017-02-05 20:04:31 +01:00
Benno Schulenberg ef7a7c5360 replacing: ignore the first match when the user said no
When the user answered No to a replacement prompt, skip the match
at the current position, so we don't stay stuck there.

Also, when replacing in the backward direction, or the match is
of length zero, skip the match at the current position, to not
get stuck.

This fixes https://savannah.gnu.org/bugs/?50126.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

This also fixes https://savannah.gnu.org/bugs/?50137,
and refixes https://savannah.gnu.org/bugs/?48635,
and fixes https://savannah.gnu.org/bugs/?50144.
2017-01-26 17:41:49 +01:00
Benno Schulenberg f7d320d932 tweaks: rename a function, to show it refers to screen rows 2017-01-12 17:48:33 +01:00
Benno Schulenberg 0208ae7149 tweaks: rename a variable -- lines refers to buffer, rows to screen 2017-01-12 17:33:46 +01:00
Benno Schulenberg c0aa5ad258 tweaks: miscellaneous frobbings 2017-01-09 18:25:25 +01:00
Benno Schulenberg fd0589d8bc tweaks: remove the cluttering conditional compilation of a parameter
The conditionalizing saved negligible amounts of space, of memory, and
of speed.
2017-01-03 14:11:45 +01:00
Benno Schulenberg d3429a7a57 copy: properly set preferred x position when region was marked backwards
This fixes https://savannah.gnu.org/bugs/?49964.
2016-12-31 16:36:14 +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 a9b5a0e029 tweaks: rename a function to something less abbrevy
Also, swap the logic around, to use less braces.
2016-12-22 12:04:10 +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 cd705a7c4c tweaks: elide a counter and a comparison
For clarity and a tiny bit more speed.  Also rename some variables.
2016-12-19 09:44:30 +01:00
Benno Schulenberg bc8a3a50a4 tweaks: rename three variables, for visibility
(I don't /see/ single-letter variables -- they are too small.)
2016-12-18 19:31:11 +01:00
Benno Schulenberg eafae5d417 screen: show an embedded newline in filenames as ^J instead of ^@
The byte 0x0A means 0x00 *only* when it is found in nano's internal
representation of a file's data, not when it occurs in a file name.

This fixes the second part of https://savannah.gnu.org/bugs/?49867.
2016-12-18 11:13:50 +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 9fa95a3680 tweaks: put some prototypes in the proper order, and move a bit of code 2016-12-15 13:04:52 +01:00
Benno Schulenberg d6cc2c40fe tweaks: conditionalize a function that is not used in the tiny version
The fsfromline() function is mostly used by the undo functions, which
are not present in the tiny version.  It is also used by the comment/
uncomment feature, but this feature cannot be enabled when --enable-tiny
is in effect.
2016-12-15 12:45:02 +01:00
David Lawrence Ramsey c9f743f676 tweaks: elide two unneeded variables from line numbering mode
Instead compute directly whether we're at a softwrapped part or not.
2016-12-13 17:01:39 +01:00
David Lawrence Ramsey bd920b1f49 tweaks: adjust the type of two arguments
Convert digits() to take a ssize_t instead of an int, since it's
used on ssize_t line numbers.  And properly use the long modifier
when displaying a line number.

Also, conditionalize the digits() prototype.
2016-12-13 13:06:20 +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 379b1556ed prompt: remove two fragments of dead code
None of the prompts offer a total-refresh shortcut -- only the
edit window, the help viewer, and the file browser provide this.
2016-12-04 12:34:56 +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 77023a749b tweaks: remove an annoying conditional compilation of an argument
Also remove some unneeded prototypes, adjust some comments, and
move a constant definition to the top of the file.
2016-11-27 16:34:34 +01:00
Benno Schulenberg 7287300e0d tweaks: compile two parameters unconditionally 2016-10-27 12:24:41 +02:00
Benno Schulenberg 702b09c859 tweaks: elide a parameter that is always FALSE 2016-10-23 20:07:39 +02:00
Benno Schulenberg 2cd8ca4eb1 tweaks: stop compiling the whole_word_only parameter conditionally
This make tiny nano slightly less tiny, but makes the code more readable.
2016-10-23 20:07:30 +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
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 55878efe5d binding: supply the keycode for most special keys directly
Instead of figuring them out from the string.  This is possible
because those dedicated editing keys cannot be rebound anyway.
2016-10-18 20:38:27 +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 3264d0c5be tweaks: move a variable that doesn't need to be global 2016-10-12 19:59:26 +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 7b7d2bf7c9 tweaks: make tiny nano a teeny bit smaller 2016-09-02 12:01:03 +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 4d2ada60f5 tweaks: don't bother avoiding unneeded rewrites of the promptbar
Leave the optimization of actual screen writes to ncurses.
2016-08-28 17:37:25 +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 7e0c4e5726 tweaks: rename a function and adjust indentation 2016-08-25 20:20:50 +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 20058a1b63 spelling: don't consider digits as word parts, because GNU spell doesn't
This fixes https://savannah.gnu.org/bugs/?48660.
2016-08-03 12:43:57 +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 2f6647687a tweaks: rename a function, and adjust some comments 2016-08-01 19:41:13 +02:00
Benno Schulenberg c9e9964207 screen: don't look at placewewant but at where we actually were and are
For horizontal scrolling, it is not the /desired/ column position that
is relevant for determining whether a line needs to be redrawn after a
cursor movement, but the /actual/ column positions before and after.

This fixes https://savannah.gnu.org/bugs/?48627,
and fixes https://savannah.gnu.org/bugs/?48629.
2016-08-01 19:41:13 +02:00
Benno Schulenberg 0a3a6441bc tweaks: unconditionally compile a couple of parameters
Having two unneeded parameters in the tiny version is acceptable --
the code gets so much more readable.
2016-08-01 19:41:13 +02:00
Benno Schulenberg 08c51cfd45 input: ingest as verbatim just one control code or one or two escapes
Leave the rest of any escape sequence to be processed normally, which
should be possible because those characters are all in ASCII range.

This fixes https://savannah.gnu.org/bugs/?48318.
2016-08-01 14:47:02 +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 e295070193 shortcuts: group the setting of key string and keycode into one function
And instead of using two key types, just use a bool to indicate whether
a keystroke involves Meta.
2016-07-30 12:21:42 +02:00
Benno Schulenberg 91951ab22a input: don't bother putting a keycode into byte range
A keycode is either already in byte range (so there is nothing to do)
or it is not and it shouldn't be (so there is nothing to do either).
2016-07-30 12:19:47 +02:00
Benno Schulenberg 5b0ab8be62 shortcuts: remove any unnecessary classifying of keys
After initialization, the type of a key is never used nor needed
(other than for meta keys).
2016-07-30 12:13:47 +02:00
Benno Schulenberg f3e8991206 credits: don't bother blanking the second line nor the help lines
Those lines don't exist in that mode -- the relevant subwindows are
smaller, or have been made smaller just before.
2016-07-27 12:40:11 +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
David Lawrence Ramsey fc0ddab349 input: provide feedback on the Unicode digits typed so far
This fulfills https://savannah.gnu.org/bugs/?48154.
2016-07-24 12:19:42 +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 c2a0c78d9b tweaks: rename a variable and a type, to be less confusing 2016-07-16 13:29:50 +02:00
Benno Schulenberg a37cd9f0ef tweaks: rename a variable, to clarify it refers to columns, not to bytes 2016-07-14 14:28:15 +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 8b28de1313 tweaks: don't call a thing malloc... when it doesn't call malloc() 2016-07-13 15:04:40 +02:00
Benno Schulenberg e33a0b6dbe screen: avoid converting each character twice from multibyte to wide 2016-07-12 19:41:13 +02:00
Benno Schulenberg 0894587305 screen: elide another intermediate buffer for every visible character 2016-07-12 19:30:50 +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 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 af53c56ec8 chars: speed up the determination whether something is a control character
Use knowledge of UTF-8 instead of converting to wide characters first.
2016-06-29 20:56:50 +02:00
Benno Schulenberg 019d7b34ca chars: delete a now-unused function 2016-06-29 20:56:50 +02:00
Benno Schulenberg 622995fb12 chars: the representation of a control character is always two bytes
Any control character is represented by a ^ plus an ASCII character.
2016-06-29 20:56:50 +02:00
Benno Schulenberg 03586c60da chars: represent the high-bit controls more intelligibly
Instead of showing the upper control codes like this:

   ^À ^Á ^Â ^Ã ^Ä ^Å ^Æ ^Ç ^È ^É ^Ê ^Ë ^Ì ^Í ^Î ^Ï
   ^Ð ^Ñ ^Ò ^Ó ^Ô ^Õ ^Ö ^× ^Ø ^Ù ^Ú ^Û ^Ü ^Ý ^Þ ^ß

show them like this:

   ^` ^a ^b ^c ^d ^e ^f ^g ^h ^i ^j ^k ^l ^m ^n ^o
   ^p ^q ^r ^s ^t ^u ^v ^w ^x ^y ^z ^{ ^| ^} ^~ ^=

The lower control codes continue to be shown like this:

   ^@ ^A ^B ^C ^D ^E ^F ^G ^H ^I ^J ^K ^L ^M ^N ^O
   ^P ^Q ^R ^S ^T ^U ^V ^W ^X ^Y ^Z ^[ ^\ ^] ^^ ^_

The representation of DEL (0x7F) continues as ^?.

Further, use knowledge of UTF-8 to avoid a roundtrip through
wide characters.
2016-06-29 20:56:50 +02:00
Benno Schulenberg 9192b7fe8c text: add an undo item before starting to comment or uncomment lines
By moving the test for the only situation where do_comment() does nothing
(when only the magic line is selected) further up front, the add_undo()
can be called before the commenting/uncommenting starts and two variables
and an extra function are made unnecessary.
2016-06-07 11:08:06 +02:00
Mike Scalora 115aeda69b text: keep the file size correct when undoing/redoing a comment/uncomment
Store the file sizes from before and after the commenting/uncommenting
in the undo struct, so they can be restored when undoing or redoing.

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

Signed-off-by: Mike Scalora <mike@scalora.org>
2016-05-31 21:36:22 +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 d3bd855c9d tweaks: rename a function, and move the sorting there too 2016-05-25 12:09:22 +02:00
Rishabh Dave bd3f156044 browser: move all openings and closings of a directory to the same function
Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-05-25 12:02:33 +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 cc0a3d8490 search: modify a function to take a length as parameter instead of a word
When verifying that a match is a separate word (during spell checking),
instead of first copying out the word, then passing the word, and then
measuring its length, just pass its length straigtaway.
2016-05-03 11:08:59 +02:00
Benno Schulenberg 05238f31f4 search: elide an unneeded function
When we're spell checking, we don't need a special mechanism to detect
we have come full circle: reaching the end-of-buffer means we're done.
So don't bother to reset came_full_circle when we're spell checking
(when begin == NULL) but simply ignore its value.
2016-05-02 21:07:27 +02:00
Benno Schulenberg e2556274f7 browser: provide tab completion also outside of the working directory
Add a global variable, 'present_path', so that 'cwd_tab_completion()'
knows where the user is in the browser, so that it can try completions
against names in that directory instead of always against names in the
current working directory (where nano was invoked).

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

Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-05-02 12:00:18 +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 ae8df00b92 search: rename a variable and a function, for clarity and contrast 2016-05-01 12:59:32 +02:00
Benno Schulenberg 30f3c53305 tabbing: refresh the window also when Goto-Dir in browser was cancelled
This restores things to the way they were before commit 36ec76a.
Apparently all those refreshes are needed in some cases after all.
2016-04-26 17:55:56 +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 41ed690791 tabbing: refresh the edit window in case a previous tab listed names
Commit 36ec76a made the wrong change: after a tab that did not list any
file names on the screen, a refresh /is/ needed, because a previous tab
might have listed things on the screen.  But at the end of the prompt,
it is not necessary to refresh the edit window if things were listed,
because the window will be refreshed anyway after reading in a file.
2016-04-23 15:46:31 +02:00
Benno Schulenberg 5c5fefc8cf files: tweak the function tail() and rename two variables 2016-04-23 13:26:28 +02:00
Benno Schulenberg 36ec76a508 tabbing: don't refresh the edit window when nothing was printed on it
This is a remnant from 2001, when things were different.  Now, there
is no need to refresh the edit window when tabbing produced no list.
When it did produce a list, it is cleared off later.
2016-04-17 18:12:53 +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 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 d92eb4fee3 all: eradicate SVN's $Id$ tags 2016-04-05 14:59:12 +02:00
Benno Schulenberg 284877104f search: fix compilation when configured with --enable-tiny
SVN revision 5748 could cause some 'else's to be orphaned.

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

Reported-by: Thomas Rosenau <thomasr@fantasymail.de>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-04-04 19:44:39 +02:00
Benno Schulenberg 532d73ccc7 Renaming a variable to better indicate booleanness.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5779 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-30 12:27:06 +00:00
Benno Schulenberg c98afde096 Renaming 'do_replace_highlight()' to 'spotlight()', for clarity,
for aptness, for contrast.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5777 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-30 12:09:39 +00:00
Benno Schulenberg 400e7ce13f Reporting "Cancelled" instead of "Not found" when the user aborts a replace
that is taking too long.  This fixes Savannah bug #47439.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5776 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-30 12:00:48 +00:00
Benno Schulenberg b834ed3b28 Chopping a parameter that is now unused, or rather: always NULL.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5775 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-29 15:05:47 +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 7f3dc2de46 Eliding an unneeded 'if' and unneeded variable.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5765 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-23 20:21:36 +00:00
Benno Schulenberg 4b2751c3b9 Cleaning up, improving comments, and renaming a variable.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5761 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-23 10:19:01 +00:00
Benno Schulenberg f150894d4e Factoring out the common part of do_search() and do_research()
into the new function go_looking().


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5756 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-20 16:57:15 +00:00
Benno Schulenberg 6ed6462154 Combining the regular-expression flags at compile time instead of at run time.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5732 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-13 19:37:21 +00:00
Benno Schulenberg 3cb80ff7ea Renaming two functions, to be more distinguishable --
a leading underscore as the only difference is not enough.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5726 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-12 09:43:10 +00:00
Benno Schulenberg ed296525f4 Eliding the functions parse_header_exp() and parse_magic_exp(),
and reshuffling the parameters in grab_and_store().


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5715 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-10 11:00:59 +00:00
Benno Schulenberg 2f63e8dfc1 Using the grab_and_store() function also for gathering up extension regexes.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5712 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-03-09 21:00:42 +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 c115166f5b Sorting the prev_word() and next_word() functions in the standard way:
the backward one first.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5661 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-22 12:49:08 +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 e86dc0381c Avoiding a memory leak when tabbing on a string that doesn't occur in the
history.  This fixes Savannah bug #47124 reported by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5653 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-20 12:16:43 +00:00
Benno Schulenberg 2163d961a1 Deleting two dead prototypes, adjusting two comments for correctness,
and two other minute tweaks.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5649 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-16 10:09:26 +00:00
Benno Schulenberg e540053eb3 Renaming and condensing some stuff, and correcting the main comment,
because 'allow_cntrls == FALSE' meant that controls were being filtered.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5644 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-14 12:03:47 +00:00
Benno Schulenberg ef16a2a250 Doing the copying of typed stuff from input to output just once.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5643 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-14 11:16:54 +00:00
Benno Schulenberg 2cfa96bde9 Renaming 'update_bar_if_needed()' for more contrast and aptness.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5612 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-06 11:44:33 +00:00
Benno Schulenberg d844f05a1e Chopping two parameters that are always the same, and that are
global variables anyway.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5611 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-02-06 11:40:15 +00:00
Benno Schulenberg ba987350a9 Being more specific in how a given path is invalid.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5602 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-31 13:06:06 +00:00
Benno Schulenberg decee32067 Eliding an unneeded function.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5587 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-24 20:44:39 +00:00
Benno Schulenberg f01dd29f48 Bundling four statements (that in total occur seven times)
into a separate function.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5586 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-24 20:36:02 +00:00
Benno Schulenberg eed1aab3f0 Chopping an always-FALSE parameter and deleting an unused return value.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5584 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-24 15:42:45 +00:00
Benno Schulenberg fe3d849a75 Getting rid of a global variable.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5574 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-20 15:56:40 +00:00
Benno Schulenberg 8bd76d8302 Verifying that the containing directory of the given filename exists.
Original patch by Rishabh Dave, edited by Benno.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5572 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-20 15:14:52 +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 431cec477d Deleting two duplicate declarations.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5560 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-14 13:52:39 +00:00
Benno Schulenberg deb271d708 Differentiating a variable name from function names.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5551 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-12 19:20:40 +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 539a4b42be Constifying the input parameter of strtosc() and strtomenu().
Patch by Mike Frysinger.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5528 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2016-01-04 09:12:21 +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 8f0262f51e Deleting a now unused function.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5517 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2015-12-31 16:49:07 +00:00