Commit Graph

677 Commits (86c08560ad45fd905c49a9cb9eeee10c5af31bb3)

Author SHA1 Message Date
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 ac8eb42a4f tweaks: elide a superfluous allocation 2017-09-12 20:46:14 +02:00
David Lawrence Ramsey 19a1129698 text: hook up indenting and unindenting to the undo/redo code
This is modeled after the comment/uncomment code.  Each line's
individual indent is saved in the string array of the undo
group structure.

This fixes http://savannah.gnu.org/bugs/?46860.
2017-09-12 20:08:30 +02:00
David Lawrence Ramsey f722c53223 undo: generalize update_comment_undo() into update_multiline_undo()
The function does not contain any comment-specific code, so it can
be used to handle any kind of multiline undo item.

Also, extend the undo group structure to contain an array of strings,
one for each line in the group.  When indent/unindent is hooked up to
the undo/redo code, this will allow the latter to restore the exact
original indents.
2017-09-12 19:49:44 +02:00
Benno Schulenberg ffc550521c tweaks: chuck a bunch of asserts -- they have lost their usefulness 2017-09-10 14:08:24 +02:00
Benno Schulenberg 8d229cb712 tweaks: rename a variable, to make more sense
Also, remove an unneeded null_at() -- the null byte has been copied,
and reallocating the string would recover very little memory.

Also, call charmove() without using the & operator.
2017-09-10 13:28:13 +02:00
Benno Schulenberg abf7ac48a1 tweaks: rename three variables, for more contrast 2017-09-10 13:04:03 +02:00
David Lawrence Ramsey fc0e16f6bc text: move the unindenting of a single line into its own function 2017-09-10 12:59:04 +02:00
David Lawrence Ramsey 57d7f8852d text: move the indenting of a single line into its own function
This is modeled after the undo/redo code for commenting.  do_indent() now
calls indent_a_line() on each line it covers.  The latter function will
eventually be used by the undo/redo code.
2017-09-10 12:43:10 +02:00
Benno Schulenberg 807f5c2e69 tweaks: do not leak the indentation when all lines are empty 2017-08-16 17:16:18 +02:00
Benno Schulenberg 1b2a091de9 tweaks: condense or improve some comments
Also reshuffle an initialization and drop two useless asserts.
2017-08-16 17:10:40 +02:00
Benno Schulenberg bd770ea2e7 text: properly unindent lines that consist of only whitespace
The preceding 'for' loop has already established that all the lines are
either unindentable or composed of only blanks.  So if now a line cannot
be unindented, it means it is fully blank, so it can be simply skipped.

This fixes https://savannah.gnu.org/bugs/?51760.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-08-16 16:42:44 +02:00
Benno Schulenberg d8e5799e84 tweaks: adjust the indentation after the previous change
Also, trim or improve some comments.
2017-08-15 10:38:58 +02:00
David Lawrence Ramsey 0f4716e168 text: make unindenting remove from the beginning of the line
Also, only unindent when all selected lines can be unindented,
which means that the relative indentation will be preserved.
For this purpose, it ignores empty lines and lines consisting
of only whitespace.

When unindenting is not possible, a message is shown.

This fixes https://savannah.gnu.org/bugs/?47684.
2017-08-15 10:38:58 +02:00
David Lawrence Ramsey 749b1b3d79 text: make indenting add to the beginning of the line
Instead of inserting the extra whitespace after the current indentation
of a line, add it to the start of the line.  This causes a fixed amount
of visual whitespace to be added regardless of whether --tabstospaces
is used or not.

This fixes http://savannah.gnu.org/bugs/?51438,
and its ancestor https://savannah.gnu.org/bugs/?51408.
2017-08-15 10:38:58 +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 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 ac2c81fad1 tweaks: correct a comment typo and an indentation error 2017-07-31 21:42:39 +02:00
Benno Schulenberg 5dcf375f33 linting: skip the introductory message produced by 'gcc -fshow-column'
Assume that a linter line that contains an actual error message or
warning includes a colon followed by a space -- something that that
opening message from a modern gcc lacks.
2017-07-29 13:15:22 +02:00
Benno Schulenberg 50379cc4ff tweaks: elide an unneeded pointer 2017-07-27 22:05:19 +02:00
David Lawrence Ramsey e2d3ee2364 tweaks: replace a misplaced tab with a space 2017-07-27 21:58:00 +02:00
Benno Schulenberg 79c836b11b tweaks: drop some debugging stuff, and frob two comments 2017-07-27 21:45:53 +02:00
Benno Schulenberg c24432edc4 linting: don't try to put the cursor at a negative x position
Human column numbers are one-based, whereas x positions are zero-based.
Converting from the one to the other involves subtracting one.  But when
the linter message does not provide a column number, the latter defaults
to zero.  Catch that case and change the number to one.

This fixes https://savannah.gnu.org/bugs/?51550.
2017-07-26 21:31:41 +02:00
David Lawrence Ramsey 85bffcfeb9 tweaks: use charalloc() instead of (char *)nmalloc() * sizeof(char)
The charalloc() macro does exactly this.
2017-07-25 21:50:13 +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 14c5f03e38 tweaks: rename another constant, to be more precise 2017-07-14 16:18:41 +02:00
Benno Schulenberg 1e2d9a697a tweaks: rename a constant, to match the corresponding option 2017-07-14 16:14:02 +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
David Lawrence Ramsey fb51d617fd text: adjust the comments in do_indent() and do_unindent()
Make them reflect the split into two functions, the direct use of
tabsize, and the difference in behavior between indent and unindent.
2017-07-12 17:24:46 +02:00
David Lawrence Ramsey 7e9799d42b text: remove the last usage of cols in do_indent() and do_unindent()
Since all indentation and unindentation is by a tab, or by a tab's
worth of spaces, use tabsize directly.
2017-07-12 17:23:46 +02:00
David Lawrence Ramsey d02c1993d8 text: normalize the indentation in do_indent() and do_unindent()
Also remove one unneeded blank line.
2017-07-12 16:58:23 +02:00
David Lawrence Ramsey 42f5a84c6f text: remove indent-related code from do_unindent() 2017-07-12 16:57:20 +02:00
David Lawrence Ramsey 109ad0915d text: remove unindent-related code from do_indent() 2017-07-12 16:56:36 +02:00
David Lawrence Ramsey ee52f45b01 text: remove unneeded references to cols from the indentation routines
The parameter 'cols', that indicates how many columns to indent or
unindent, is changed to be always positive, so the check for being
negative can go.  And it could never be zero anyway.
2017-07-12 16:51:21 +02:00
David Lawrence Ramsey 2367f3d8e6 text: make do_unindent() an exact copy of do_indent()
This is the first step toward splitting them into two dedicated
functions, instead of letting do_indent() handle both cases.
2017-07-12 16:45:41 +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
David Lawrence Ramsey aa04ad4f83 replacing: make spotlight() account for varying chunk width
spotlight() now displays softwrapped lines chunk by chunk instead of all
at once.  Since softwrapped lines are no longer of constant width, the
latter approach would fail if softwrapping breaks the spotlighted text.

Instead of taking a string, spotlight() now takes the starting and ending
columns of that string.  Also, its handling of softwrapped lines is now
split off into a separate function, spotlight_softwrapped().
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
David Lawrence Ramsey 5bc4abeefe text: update placewewant properly when indenting/unindenting
If the position of the cursor changes horizontally,
placewewant should change with it.

This fixes https://savannah.gnu.org/bugs/?51407.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-07-07 12:09:14 +02:00
Benno Schulenberg 1439016c20 tweaks: recognize the empty string as comment inhibitor, instead of NULL 2017-07-07 10:15:17 +02:00
David Lawrence Ramsey 7c41c8641f tweaks: remove unneeded braces, and mark empty parameter list as void
This matches the style in the rest of the code.
2017-07-03 09:52:13 +02:00
Benno Schulenberg 14bd52ced8 display: wipe stale messages from the status bar straightaway
When blank_statusbar() has been called, make sure it is effective.

This fixes https://savannah.gnu.org/bugs/?51358.
2017-07-02 19:57:11 +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 2abe7c03fe text: make sure commenting is disabled when comment "" was specified
When the active syntax contains a comment command that specifies the
empty string, this should override the default comment of "#" and
should disable the Meta-3 keystroke.

To achieve this, the comment string is now set by default to "#" for
all syntaxes, so that it will be set when no comment command is given
(including for the "none" syntax), and is unset only by explicitly
specifying «comment ""» in a syntax file.

This fixes https://savannah.gnu.org/bugs/?51355.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-07-02 19:44:56 +02:00
Benno Schulenberg bf72cdd814 tweaks: rename two variables, to make a little sense
And rename a third variable, to match another in its style.
2017-07-02 12:05:12 +02:00
Benno Schulenberg 4239e5fe1a tweaks: put declarations always first, so it will compile on Haiku 2017-07-02 11:53:59 +02:00
Benno Schulenberg 6ad3d3d6c0 display: show the cursor position also when searching took a while
Achieve this by making the suppression flag global, so that we can
just reset it instead of making an improper call of do_cursorpos().

This fixes the secondary part of https://savannah.gnu.org/bugs/?51134.
2017-05-29 22:15:38 +02:00
Benno Schulenberg 5cdadc3eb1 tweaks: avoid an unused-variable warning when using --disable-comment 2017-05-19 11:55:37 +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 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
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 a43eee6aec tweaks: fix compilation with --enable-tiny --enable-color --enable-speller
Also avoid an unused-variable warning, and trim a useless assert.
2017-04-19 14:30:36 +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 2439e1e451 linting: treat a tab as one "column", not eight
This fixes https://savannah.gnu.org/bugs/?47131.
2017-04-10 20:32:36 +02:00
Benno Schulenberg dab70d06ed linting: when no is said to a file, remove all corresponding entries
When the user chooses not to open a file that some message refers to,
remove all messages for that file from the linting results, so the user
does not get asked about that same file again.

This fixes https://savannah.gnu.org/bugs/?47130.
2017-04-10 19:55:46 +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 005ee8eda6 editing: avoid creating blank lines when using autoindent
When Enter is pressed while the cursor is exactly on the current
indent width, remove the blank characters on that line to avoid
creating a line that consists only of trailing whitespace.

(When Enter is pressed somewhere in the middle of the blanks,
however, the whitespace is preserved.)

Suggested-by: Florian Zeitz <florob@babelmonkeys.de>
2017-04-06 20:34:04 +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 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 582a624998 tweaks: frob some parentheses and other things, to be more consistent 2017-03-29 19:30:37 +02:00
David Lawrence Ramsey c888edf409 softwrap: save and restore firstcolumn when internally spell-fixing text
In do_int_spell_fix(), spell-checking text may change firstcolumn if
the next match is offscreen, and spell-checking text after that will
not change it back.  In order to keep the viewport unchanged, we have
to save and restore not just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +01:00
David Lawrence Ramsey 7cd50b8c02 softwrap: save firstcolumn when justifying, restore it when unjustifying
In do_justify(), justifying text may change firstcolumn if the paragraph
ends offscreen, and unjustifying the text again will not change it back.
In order to keep the viewport unchanged, we have to save and restore not
just edittop, but firstcolumn as well.
2017-03-22 10:44:06 +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
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
Mike Frysinger 3deec4352b assume regex.h support is always available
Now that we pull in the gnulib regex module, we can assume it exists.
2017-03-06 12:01:08 +01:00
Benno Schulenberg 0af5788a94 tweaks: reduce the scope of five variables, and frob some comments 2017-03-01 09:56:38 +01:00
Benno Schulenberg d5b950cc29 tweaks: don't turn the mark off before it's needed
The mark only needs to be off when calling replace_marked_buffer(),
because this indirectly calls ingraft_buffer(), which fiddles with
the end points if the mark is on.
2017-03-01 09:35:45 +01:00
Benno Schulenberg adf69a05f1 spelling: keep the cursor at end-of-line if it was there
This fixes https://savannah.gnu.org/bugs/?50415.
2017-02-28 20:45:49 +01:00
David Lawrence Ramsey 29681e0e9f weeding: remove partitioning and related stuff from do_justify()
Replace partitioning with calls to extract_buffer() and ingraft_buffer().

In addition to pasting the unjustified text back into the buffer at
current[current_x], ingraft_buffer() also deals with renumbering and
updating totsize, so do_justify() doesn't need to do those anymore
when unjustifying.
2017-02-28 14:35:44 +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 0d9313763d undo: fix undoing/redoing insertions, since they no longer do partitioning 2017-02-28 14:35:44 +01:00
Benno Schulenberg e5731fe198 tweaks: reshuffle three statements, and shorten a comment 2017-02-25 12:33:01 +01:00
Benno Schulenberg 2bbb6cfeb5 wrapping: add the correct char length when skipping consecutive blanks
In this last loop of break_line(), the pointer 'line' is one step ahead
of the index 'lastblank'.  So the loop should first add the length of
the preceding character to 'lastblank' before determining the length
of the current character (and using this to advance 'line').
2017-02-25 11:18:24 +01:00
Benno Schulenberg 1623bc7779 tweaks: rename three variables, to better distinguish bytes from columns
(There is something wrong in the last loop: line is one character ahead
of lastblank, but the current character length is added to both of them.
It thus assumes that all blank characters are the same number of bytes.
For spaces and tabs this works fine.  But for more exotic blanks...)
2017-02-24 22:08:55 +01:00
Benno Schulenberg 99ecd33c18 tweaks: elide two variables, and condense some statements
Also, remove an assert and adjust some comments.
2017-02-24 21:11:37 +01:00
David Lawrence Ramsey 6500f769aa tweaks: move comments outside of if blocks in break_line() 2017-02-24 21:04:31 +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
Benno Schulenberg de3260cdb1 justify: reduce the character count when trimming trailing spaces
This fixes https://savannah.gnu.org/bugs/?50379.
2017-02-22 17:29:39 +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
Benno Schulenberg d60e7d374c spelling: correctly adjust the length of a single-line region
When the marked region covers only a single line (or a part of it),
its new endpoint is not simply the length of the last line of the
spell-checked text, but instead the old endpoint plus the /change/
in length.

This fixes https://savannah.gnu.org/bugs/?50316.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-16 11:52:24 +01:00
Benno Schulenberg 914af36546 spelling: don't unnecessarily fiddle with the viewport
If we're somewhere deep into the file and do a spell check, and the
first misspelled word happens to be right there, onscreen already,
then this word does not need to be centered -- it /should/ not be
centered.  We should scroll only when necessary.
2017-02-10 22:09: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 83ff644b6a tweaks: do a comparison a bit differently in do_output() and do_deletion()
Make it clearer we're comparing the number of rows, not string lengths.
2017-02-05 12:30:09 +01:00
Benno Schulenberg 94e563232e general: stop the spell checker from crashing after the changes in search
The spell fixer does not provide a beginning line, so the search routine
should then not try to refer to any data of this line.  Also, since the
changes to the search routine there is no need any more to retreat one
step before starting to search for a misspelled word.

This fixes https://savannah.gnu.org/bugs/?50159.
2017-01-26 20:21:41 +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 c0aa5ad258 tweaks: miscellaneous frobbings 2017-01-09 18:25:25 +01:00
Benno Schulenberg 322120c980 undo: properly create separate items for deletes at different positions
That is: only extend the current Del or Backspace undo item when the
cursor is still (or again) at the same spot.

This fixes https://savannah.gnu.org/bugs/?50006.
2017-01-08 11:05:52 +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 a381021ffc tweaks: when allow_tabs is FALSE, allow_files is irrelevant
In that case setting the latter to TRUE is misleading.  So don't do that.
2017-01-03 14:02:52 +01:00
David Lawrence Ramsey b1c20629f5 weeding: remove unnecessary settings of openfile->current_y
Many of the adjustments of the value of openfile->current_y appear to be
a holdover from the days when certain functions had to account for what
is now called STATIONARY scrolling mode, which depends on the value of
current_y.  Remove these adjustement where they are superfluous.

do_para_begin(), do_para_end(), and do_bracket_match() update the screen
through edit_redraw(), which uses either CENTERING or FLOWING scrolling
mode, so their setting of current_y is redundant and useless, as it will
be ignored and then overridden by the next call to reset_cursor().

findnextstr() is called by go_looking() [which calls edit_redraw(), see
above], and by do_replace_loop() and do_int_spell_fix(), which both call
edit_refresh(), which in this case only uses CENTERING scrolling mode
since focusing is TRUE.

(Additionally, the adjustments of current_y in findnextstr() and
do_bracket_match() use incorrect values when in softwrap mode.)

find_paragraph() doesn't need to save or restore current_y, because it
doesn't do any screen updates.  do_justify() calls edit_refresh() with
focusing set to TRUE, so it uses the CENTERING scrolling mode.

do_alt_speller() and do_formatter() do not need to save and restore
current_y, because they don't modify it in any way.

This addresses https://savannah.gnu.org/patch/?9197.
2017-01-02 12:40:21 +01:00
Benno Schulenberg 7373e4cd46 tweaks: fix compilation when configured with --disable-wrapping 2017-01-01 16:33:40 +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
Felix Janda fc89ac11d2 speller: fix build when tiny build is enabled
URL: https://bugs.gentoo.org/604000
2016-12-29 13:43:06 -05:00
Benno Schulenberg 588daf949e tweaks: condense the setting of three flags 2016-12-25 13:11:17 +01:00
Benno Schulenberg d21a9c8fc3 text: discard the undo stack after formatting and after spell checking
After a call to the Formatter or the Alternate spell checker, the data
on the undo stack could refer to line positions that don't exist any
more -- the chance is small, but it is there.  So... throw the whole
undo stack away, to prevent undoing things wrongly or even crashing.

(Changes made with the internal spell checker can be undone and redone
without a problem -- nano keeps full track of those.  But the changes
made with a formatter or an external spell checker happen in another
process, so nano has no record of them.)

This fixes https://savannah.gnu.org/bugs/?49920.
2016-12-24 12:22:50 +01:00
Benno Schulenberg edbc1e5950 text: avoid a crash when a spell-checked line has gotten shorter
When using an external spell checker or formatter, the line with
the cursor might become shorter, which might result in the stored
cursor position being beyond the end-of-line.  So, when restoring
the x position, make sure to limit it to the length of the line.

This fixes https://savannah.gnu.org/bugs/?49923.
2016-12-24 12:22:17 +01:00
Benno Schulenberg 6620acbff4 tweaks: use a faster comparison 2016-12-20 10:03:53 +01:00
Benno Schulenberg 1cb6619d6a undo: there are just two forms of deletion: backspacing and deleting
A third method does not exist.
2016-12-19 21:18:43 +01:00
Benno Schulenberg 79a4bf81dc tweaks: rename five variables, for uniformity with a few others 2016-12-19 19:58:15 +01:00
Benno Schulenberg 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 ea9f62fc0f tweaks: adjust some comments and indentation and ordering 2016-12-13 19:27:33 +01:00
Benno Schulenberg 13ec5d8ce9 spelling: correctly restore the selected region
An added magic linefeed should be removed again /before/ restoring
the x position, as the latter needs to be calculated from the real
last line of the region.

This fixes https://savannah.gnu.org/bugs/?49817.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2016-12-11 09:55:38 +01:00
Benno Schulenberg 173bbe11ef tweaks: add a few translator hints 2016-12-07 21:05:41 +01:00
Benno Schulenberg 7531b71fa1 docs: note Sumedh as the author of the word-completion feature 2016-12-07 21:05:23 +01:00
Benno Schulenberg 964c10db17 tweaks: miscellaneous frobbings and rewrappings 2016-12-07 20:37:08 +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 86121cf3fc tweaks: move a cursor-on switch to a more logical place (again)
But do it correctly this time: don't switch it on when replacing.
2016-12-05 15:47:44 +01:00
Benno Schulenberg f920e0d30c tweaks: replace some unneeded direct calls of edit_refresh() 2016-12-03 17:00:28 +01:00
Benno Schulenberg 0f3e303d1a tweaks: get rid of some spurious textual references to edit_refresh() 2016-12-02 18:13:10 +01:00
Benno Schulenberg e4b8d6fab5 tweaks: remove a bit of obscuring conditional compilation 2016-11-30 11:46:05 +01:00
Benno Schulenberg 7598b77e75 screen: use the correct width to determine whether a softwrap occurred
This fixes the two bugs reported by Anton Minaev
in https://savannah.gnu.org/bugs/?49511.
2016-11-13 19:20:38 +01:00
Benno Schulenberg 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
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 d9148e7b3f tweaks: elide an unneeded variable 2016-10-12 19:20:39 +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 514cd9a099 update the license text to the preferred version
Mentioning "GNU nano" instead of "This program" and referring to the
website instead of to a postal address.
2016-08-29 21:27:16 +02:00
Benno Schulenberg 406e5242a3 update the copyright notices 2016-08-29 21:27:05 +02:00
Benno Schulenberg 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 d8031af030 screen: retain the placewewant also when using an alternate speller
When using the default speller or the formatter, the placewewant is
remembered.  So it should be remembered too when the user specifies
a different speller.

(This behavior was inadvertently lost last year, in commit 82d737e.)
2016-08-12 20:02:04 +02:00
Benno Schulenberg 14ac47517b spelling: don't abort when a misspelled word isn't found, just note it
This fixes https://savannah.gnu.org/bugs/?48660 doubly, in case there
are other ways in which 'spell' sees words differently from 'nano'.
2016-08-03 12:55:21 +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 24b10179a1 files: beep whenever writing out a file fails
Just like when reading a file fails.  It needs the user's attention.
2016-06-27 19:17:53 +02:00
Benno Schulenberg 68acc1dfc5 tabs: compute the number of required spaces without iterating 2016-06-24 14:56:41 +02:00
Benno Schulenberg 79e3eaf73c linter: refresh the edit window in order to actually place the cursor
This fixes https://savannah.gnu.org/bugs/?48283.
2016-06-21 16:25:07 +02:00
Benno Schulenberg 9106cc8ecc main: let the main loop restore the main menu, if needed
Don't make it the responsibility of the executed functions to restore
the list of shortcuts of the edit window.  Just detect whether another
menu was displayed, and if so, redisplay the main menu.
2016-06-21 11:03:38 +02:00
Benno Schulenberg 95f417fa9a tweaks: rewrap a bunch of lines and some comments 2016-06-20 13:05:45 +02:00
Benno Schulenberg 158388c5a6 justify: enable cursor display also for the first keystroke afterward
This fixes https://savannah.gnu.org/bugs/?48246.
2016-06-16 20:40:09 +02:00
Benno Schulenberg 883373cd76 undo: start renumbering from the head of the paste, not from its tail
Because when undoing a paste at the end of the buffer, the tail line
probably does not exist any more.

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

(It would have been the proper fix for
https://savannah.gnu.org/bugs/?44488.)
2016-06-14 16:34:29 +02:00
Benno Schulenberg d87c357abe tweaks: remove two redundant assignments
The mark has already been unset by do_cut_text().  And any assignment
to 'mark_begin' is useless when 'mark_set' is FALSE.
2016-06-07 19:53:27 +02:00
Benno Schulenberg ccffc548e1 text: after undoing or redoing something, unset the mark
This fixes https://savannah.gnu.org/bugs/?48108,
and fixes https://savannah.gnu.org/bugs/?48157.
2016-06-07 19:52:23 +02:00
Benno Schulenberg 83b89a49ef text: remove a redundant undo element
Implement its single use case by making better use of another element.
2016-06-07 19:23:51 +02:00
Benno Schulenberg 87a254400e text: remove a pointless setting of an undo element; it is never used 2016-06-07 19:23:51 +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
Benno Schulenberg f0c65bc988 tweaks: add come comments and rename a variable 2016-06-06 20:29:53 +02:00
Benno Schulenberg 5f4d759679 tweaks: fix compilation when configured with --enable-tiny
Reported-by: Mike Scalora <mike@scalora.org>
2016-06-06 19:57:51 +02:00
Benno Schulenberg edf230b7df text: store the new file size in the undo item also when joining lines
This fixes https://savannah.gnu.org/bugs/?48099 reported by Mike Scalora.
2016-06-04 11:39:59 +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
Benno Schulenberg 17cf833b9c tweaks: normalize some whitespace 2016-05-30 09:09:36 +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 f7c3e1cac2 spelling: gettextize the next-word message 2016-05-18 10:25:16 +02:00
Benno Schulenberg cdcd365d34 tweaks: normalize some whitespace 2016-05-17 11:33:21 +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 0cc3da5d5e spelling: retreat one x position, to not miss the first word
This fixes https://savannah.gnu.org/bugs/?47932.
2016-05-16 12:31:34 +02:00
Benno Schulenberg 06b449b22c utils: provide a failure message for all uses of 'fsfromline' 2016-05-12 12:07:19 +02:00