Commit Graph

534 Commits (b368faf11c8889c7d4875bd1e4caa980340b0428)

Author SHA1 Message Date
Benno Schulenberg 48b94d71c7 tweaks: pass an empty string for copying instead of a non-existent one 2019-10-15 11:49:07 +02:00
Benno Schulenberg d256d0cbc0 tweaks: add a helper function without the ubiquitous NULL argument
For conciseness and clarity.
2019-10-13 12:24:27 +02:00
Benno Schulenberg d12191db5a tweaks: pass any special undo/redo messages to the add_undo() function
For the three operations (justification, spell checking, and filtering)
that need to undo or redo two suboperations (cutting and then pasting)
in one go, pass the message that describes the operation to add_undo(),
so that the undo item does not need to be modified after the call.

This looks better, but does add some twenty NULL parameters elsewhere.
2019-10-09 19:21:27 +02:00
Benno Schulenberg e0d9b7a8af tweaks: add a translator hint, and correct two others 2019-09-29 15:08:57 +02:00
Benno Schulenberg f7d5a82a5d search: wipe the status bar before searching again (M-W / M-Q)
So that any message that is on the status bar after the search
will be a response to this search and not some leftover.

This fixes https://savannah.gnu.org/bugs/?56737.
2019-08-10 13:11:41 +02:00
Benno Schulenberg 1075de1222 tweaks: rename two functions, to get rid of the "mb" abbreviation
Also, for me "move" is about moving the cursor.  But these functions
are about moving an index in a text, which is more general.
2019-06-09 19:37:56 +02:00
Benno Schulenberg ca77254968 tweaks: use a slightly faster function where appropriate
Also, correct a call of move_mbright() to use the intended format.
2019-06-09 19:22:24 +02:00
Benno Schulenberg 843eef65b8 tweaks: put some timing code back into the search function 2019-06-09 18:48:52 +02:00
Benno Schulenberg 781c7a7a5f chars: create a dedicated function for getting the length of a character
Instead of calling in twenty places parse_mbchar(pointer, NULL, NULL),
use a simpler and faster char_length(pointer).  This saves pushing two
unneeded parameters onto the stack, avoids two needless ifs, and elides
an intermediate variable.

Its main purpose will follow in a later commit: to speed up searching.
2019-06-09 18:38:46 +02:00
Benno Schulenberg fb17929fab tweaks: use FALSE for booleans instead of zero
Also adjust some indentation and reduce the scope of a variable.
2019-06-09 10:41:14 +02:00
Benno Schulenberg 4fb9f298c9 tweaks: adjust some indentation after the previous change
Also reshuffle some arguments.
2019-05-08 19:35:42 +02:00
Benno Schulenberg c338d86843 tweaks: rename some single-letter variables to the same significant word
And simply elide one of those variables.
2019-05-08 19:35:03 +02:00
Benno Schulenberg 247dd8f052 tweaks: rename a variable, reshuffle declarations, and drop an assert 2019-05-08 15:34:06 +02:00
Benno Schulenberg c55d144748 tweaks: drop most of the remaining debugging code, and some timing code 2019-05-08 15:23:36 +02:00
Benno Schulenberg 02d3a2c0fb tweaks: remove some unneeded braces, and reshuffle for more symmetry 2019-05-06 11:20:31 +02:00
Benno Schulenberg 5764619655 search: stay in the Search menu when trying to Replace in view mode
This fixes https://savannah.gnu.org/bugs/?56274.

Bug existed since version 3.1, commit 6cd53e7f.
2019-05-06 11:08:22 +02:00
Benno Schulenberg f0bc94fd02 tweaks: move the tyding-up-after-a-search to a single exit point 2019-05-06 10:29:45 +02:00
Benno Schulenberg 37eccd3117 tweaks: rename a function, to be more fitting
Also, adjust some whitespace, for esthetics.
2019-04-28 11:01:51 +02:00
Benno Schulenberg 6e3a3964ce tweaks: adjust the indentation after the previous change
Also, condense a couple of comments.
2019-04-27 17:17:06 +02:00
Benno Schulenberg 18eb7e6d21 tweaks: elide an unneeded 'if' and 'break' 2019-04-27 17:10:10 +02:00
Benno Schulenberg e84a790b5d tweaks: rename a variable, to better indicate it contains two characters
Also rename a function, to differentiate it more from do_find_bracket().
2019-04-27 17:01:34 +02:00
Benno Schulenberg 20d9070aa1 tweaks: move an assignment that is useful only when searching forward 2019-04-27 16:31:57 +02:00
Benno Schulenberg 482b2814b4 tweaks: step away one character from the current bracket, not one byte 2019-04-27 14:41:53 +02:00
Benno Schulenberg 0b6889cbd8 tweaks: rename another function, to be distinct and fitting 2019-04-24 10:52:49 +02:00
Benno Schulenberg 00410d83fc tweaks: rename a function, to be distinct and fitting
It was hard to remember that the "pt" stood for "plus tabs", and the
"len" seemed to say it was about number of bytes instead of columns.
2019-04-24 10:52:35 +02:00
Benno Schulenberg 5601b9a66b tweaks: switch back from checking FINAL_NEWLINE to checking NO_NEWLINES
This effectively reverts commit b6a76223 from a good two months ago.
2019-04-07 08:50:35 +02:00
Benno Schulenberg 580fd13424 tweaks: do a check up front instead of every time round the loop
Instead of doing a check every time round the loop when it is useful
only the first time, duplicate a bit a code and do the check and its
related action beforehand.

Also, improve some comments.
2019-04-06 21:07:20 +02:00
Benno Schulenberg 790ce3791a tweaks: reshuffle some lines, condense a comment and drop another
Also, find_bracket_match() is only called when there is a bracket under
the cursor, so stepping forward will never go beyond the end-of-line,
so the central loop does not need to check for that.
2019-04-06 20:37:22 +02:00
Benno Schulenberg 97cd62a8fb tweaks: rename two variables, to make more sense 2019-04-06 20:29:04 +02:00
Benno Schulenberg 2f68bbb5e8 tweaks: reword a comment, and drop an unneeded assert 2019-04-06 20:08:39 +02:00
Benno Schulenberg b9581bd50a tweaks: rename two variables, to match others
Also, initialize them straightaway.
2019-04-06 11:54:32 +02:00
Benno Schulenberg 408f15954e feedback: replace an assert with a check plus error message at startup 2019-04-06 10:03:52 +02:00
Benno Schulenberg 601973ddc2 tweaks: rename another variable, to be more descriptive 2019-04-05 11:01:07 +02:00
Benno Schulenberg 25a5fb8231 tweaks: rename a variable, to get out of the way for another rename 2019-04-05 10:50:15 +02:00
Benno Schulenberg 897e557ce3 tweaks: rename a variable, to be more distinct and more descriptive 2019-04-05 10:45:22 +02:00
Benno Schulenberg 81bee1f5fd tweaks: shorten and improve some comments, and reshuffle a few lines 2019-04-05 10:35:48 +02:00
Benno Schulenberg cddfcb1b9d tweaks: rename a struct element, to make sense 2019-03-21 17:23:49 +01:00
Benno Schulenberg aac4fc46e9 tweaks: rename a type, to make more sense 2019-03-21 17:08:52 +01:00
David Lawrence Ramsey f13dd140eb display: correctly trim an overshooting character from a prompt answer
Tell display_string() explicitly when we're at a prompt, instead of
letting it glean this from the current menu not being MMAIN, which
fails in some circumstances.

This improves the fix for https://savannah.gnu.org/bugs/?55620,
fixes https://savannah.gnu.org/bugs/?55680 in a better way,
and fixes https://savannah.gnu.org/bugs/?55773.
2019-02-28 19:47:55 +01:00
Benno Schulenberg 79ca3ceabf copyright: update the years for the FSF 2019-02-24 19:35:56 +01:00
Benno Schulenberg 322a6f46fa tweaks: switch from checking SMOOTH_SCROLL to checking JUMPY_SCROLLING 2019-02-19 19:52:57 +01:00
Benno Schulenberg b6a762232e tweaks: switch from referencing NO_NEWLINES to referencing FINAL_NEWLINE 2019-02-19 19:45:55 +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 14f32577ee display: ensure that spotlighted text is not treated as a prompt answer
When doing replacements or fixing misspelled words, and edit_refresh()
is called to highlight the relevant word, then the current menu can be
anything from MREPLACEWITH, MYESNO, MSPELL, or MMAIN.  Make sure it is
always set to the latter just before calling edit_refresh(), so that
display_string() will use the full length and the word gets properly
highlighted.

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

Bug was introduced by the previous commit, 56181896.
2019-02-12 15:07:55 +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 798695ff1e utils: retire the fixbounds() function -- it is no longer needed
All tested systems (FreeBSD, NetBSD, OpenBSD, Alpine, and Ubuntu)
support the GNU-style word boundaries (\< and \>), either natively
or through using the regex module from gnulib.

If this change breaks regexes containing \< or \> on your system,
please report a bug: https://savannah.gnu.org/bugs/?group=nano

This addresses https://savannah.gnu.org/bugs/?55207.
2018-12-31 13:49:07 +01:00
David Lawrence Ramsey c2e4f77594 display: do spotlighting as part of drawing the screen
When something is spotlighted, it should survive a refresh of
the screen and an excursion to a help text, so the spotlight
should get painted whenever the edit window is drawn.

This fully fixes https://savannah.gnu.org/bugs/?54721.
2018-10-09 20:03:47 +02:00
Liu Hao 6cd53e7f44 search: disallow switching to the Replace prompt when in view mode
Switching to Replace allows modifiying the buffer, which should
not be possible in view mode.

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

Bug existed since version 2.9.4, commit 54103d8e.

Signed-off-by: Liu Hao <lh_mouse@126.com>
2018-09-12 19:22:08 +02:00
Benno Schulenberg 33c4bb22d5 tweaks: adjust some translator hints for past changes, and add two more 2018-08-29 20:20:43 +02:00
Benno Schulenberg 8e1ce7034d search: include 'findprevious' and 'findnext' in the tiny version
Thus fix a compilation failure when configured with --enable-tiny.

Now M-Q will be functional also in a tiny nano.
2018-07-24 19:19:27 +02:00
Benno Schulenberg 2e1e157967 copyright: update the years for significantly changed files 2018-06-01 10:18:32 +02:00
Benno Schulenberg 62007c84c6 tweaks: invert two conditions and reshuffle, to reduce duplication 2018-04-24 13:27:57 +02:00
Benno Schulenberg d0f37205af search: always go forward by default, also when coming from Goto-Line
This fixes https://savannah.gnu.org/bugs/?53735.
2018-04-24 13:13:38 +02:00
Benno Schulenberg 7ab8a4d835 tweaks: improve the ordering of a couple of functions 2018-04-13 21:09:44 +02:00
Benno Schulenberg d4304ca88c search: use a better value to mean "nothing was typed"
When the keyboard buffer is empty, return a value that is not equivalent
to <Ctrl+Space>, so that typing a bunch of these while searching is going
on will not result in some of them getting executed afterward.
2018-04-13 20:13:05 +02:00
Benno Schulenberg 02d8da3bdd tweaks: rename a function, to be more fitting and descriptive
It is not an abort but simply a bit of cleaning up.
2018-04-13 10:32:29 +02:00
Benno Schulenberg 7a09b655c1 tweaks: rename a variable, for clarity 2018-04-13 10:22:39 +02:00
Benno Schulenberg c8b26baee8 tweaks: elide a function that is called just once
Also adjust and correct a comment.
2018-04-13 10:17:08 +02:00
Liu Hao bb394990cd replacing: always clear the backwards flag for ^\, just like for ^W
This makes it easier to predict in which direction the replacements
will go when hitting ^\ or M-R.

Signed-off-by: Liu Hao <lh_mouse@126.com>
2018-04-12 20:32:15 +02:00
Benno Schulenberg 206d89b739 tweaks: revert commit c88a2fd9 -- the extra variable is needed
This variable will be modified by go_forward_chunks(), but the value
of openfile->current itself should be maintained.
2018-03-23 11:31:08 +01:00
Benno Schulenberg c88a2fd9ca tweaks: elide an unneeded and shadowing variable 2018-03-22 15:20:05 +01:00
Benno Schulenberg f1b5be4bbf tweaks: elide an unneeded variable 2018-02-07 19:42:19 +01:00
Benno Schulenberg d865d7ac8f search: clear the existing answer when starting a new search
When doing for example: ^W xx ^R ^C ^W, the "xx" would again be shown
after the prompt.  This is wrong -- when starting a new search, the
current answer should be empty.

Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-02-05 12:47:55 +01:00
Benno Schulenberg 16d237ba1b tweaks: rename two variables, to be more meaningful 2018-02-04 22:07:33 +01:00
Benno Schulenberg c3031b9b8f tweaks: reshuffle some of the search-and-replace cleanup calls 2018-02-04 21:31:04 +01:00
Benno Schulenberg d289510724 tweaks: adjust comments and indentation after the previous change 2018-02-04 21:23:48 +01:00
Benno Schulenberg 60f1090da0 search: get rid of some unneeded recursion when just toggling things
Instead of weaving back and forth between do_search()/do_replace() and
search_init() every time that one of the options is toggled, just keep
looping in the latter function until the user presses <Enter>.

The weaving for the do_gotolinecolumn() function remains, but is
shortened to involve only search_init().
2018-02-04 20:26:06 +01:00
Benno Schulenberg bb667beb5a bindings: rename the bindable function 'gototext' to 'flipgoto'
This brings it in line with the other three "flip" toggles.
2018-02-04 10:34:39 +01:00
Benno Schulenberg eed765f4f7 tweaks: elide an unneeded variable 2018-02-04 10:15:26 +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 00c1105c1b search: suppress the occurrence at the cursor only when replacing
When we're just searching, we do want to report the occurrence at
the cursor (after coming full circle) as a match, so that we can
mention that this is the only occurrence.  When replacing, we do
not want to replace this match twice.

This fixes https://savannah.gnu.org/bugs/?52888.
2018-01-15 11:38:19 +01:00
Benno Schulenberg e3b13ae124 tweaks: reshuffle a couple of lines 2018-01-09 16:52:42 +01:00
Benno Schulenberg e5440b390e replacing: don't skip the first character of a backwards-marked region
Also, when replacing forwards, do not first skip the occurrence at the
cursor and then replace it at the end of the cycle, but begin with it,
as one would expect.

This fixes https://savannah.gnu.org/bugs/?52789
and fixes https://savannah.gnu.org/bugs/?52791.
2018-01-09 16:52:42 +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 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 ab14df074f search: wipe reassuring feedback as soon as searching has finished
When there are no help lines, there won't be any call to update the
actual contents of the bottom window, so... do it immediately after
blanking the row.

This fixes https://savannah.gnu.org/bugs/?52377.
2017-11-13 19:37:39 +01:00
Benno Schulenberg 5239e7c52b copyright: update some years, and standardize on the dashed format 2017-11-12 10:46:20 +01:00
David Lawrence Ramsey 477b246771 tweaks: use printf's z modifier for most of the size_t/ssize_t types
Also, properly refer to numreplaced as signed, since it's ssize_t
(even though it's only shown when positive).
2017-11-07 17:55:21 +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 ff35a61355 tweaks: transform the token DISABLE_HISTORIES to ENABLE_HISTORIES 2017-10-29 19:43:05 +01:00
Benno Schulenberg 3f27c312c4 tweaks: get rid of some cluttering conditional compilation
In the tiny version, do_prompt() will now have an extra NULL
parameter, which will cost maybe twenty extra bytes of code.
That is acceptable when it saves thirty lines in the source.
2017-10-29 11:39:27 +01:00
Benno Schulenberg ded02d858f search: suppress the "Search Wrapped" message when doing replacements
This completes the fix for https://savannah.gnu.org/bugs/?52282.
Reported-by: Chime Hart <chime@hubert-humphrey.com>
2017-10-26 21:07:06 +02:00
Benno Schulenberg d4945c67a4 search: suppress the "not found" message when replacements were made
After any replacements were made, the "not found" message is pointless
because it will be overwritten rightaway by "Replaced xx occurrences".
The message is confusing and annoying when using speech output.

This partially fixes https://savannah.gnu.org/bugs/?52282.
Reported-by: Chime Hart <chime@hubert-humphrey.com>
2017-10-26 21:06:54 +02:00
David Lawrence Ramsey f8c75c43ed search: don't bother saving and restoring the search direction
Most people who make use of 'do_findprevious' and 'do_findnext'
will not make use of 'do_search' (the default binding of M-W),
so for them it is superfluous to remember the state of the
Backwards toggle in the Search menu.  For the people that do
mix the usage of Alt+Up/Down with M-W, it means that M-W will
always search in the same direction as the last search.  It is
a small change in behavior.
2017-10-19 21:21:31 +02:00
Benno Schulenberg c7eecd74de new feature: a bindable function that starts always a backward search 2017-10-14 20:30:46 +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 f6b396f206 tweaks: chuck an assert, and then condense the code and a comment 2017-09-19 21:14:05 +02:00
David Lawrence Ramsey 5561d22f19 search: trim a failed search string for width instead of length
When reducing the search string to at most half the screen width,
it should employ its width in columns, not its length in bytes.

Also adjust the type of a variable.

This fixes http://savannah.gnu.org/bugs/?52057.
2017-09-19 21:08:05 +02:00
Benno Schulenberg a1c73317f7 organization: move all history-related stuff to its own file 2017-09-17 12:46:36 +02:00
Marco Diego Aurélio Mesquita c8363a0d0b history: remember the commands that were executed during this session
Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2017-09-14 20:10:22 +02:00
Benno Schulenberg 86e71fa09d tweaks: specify more directly in what manner to move the viewport 2017-08-18 21:46:55 +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
Benno Schulenberg 255f5478e4 startup: in default mode, display the tail of the file as Pico does
When not using --smooth (nor 'set smooth'), and a line near or beyond
the end-of-file is addressed with the + command-line argument, then
center the cursor, just like Pico does -- so in the default mode,
nano is again more like Pico.

This partially addresses https://savannah.gnu.org/bugs/?51489.
2017-07-18 21:32:20 +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