Commit Graph

5628 Commits (49cb559c5bad6fa79702a5d642d456c8f40de248)

Author SHA1 Message Date
Benno Schulenberg a5b3f00d78 chars: make comparing multibyte strings twice as fast
Instead of parsing every multibyte character twice, first with
parse_mbchar() and then with mbtowc(), just let mbtowc() do all
the work.  This makes searching for a fixed string twice as fast.

This also gets rid of four variables and lots of memory allocations.
(And, more importantly: it stops nano messing up the internal state
of the multibyte-to-wide character conversion, and thus would make
the calls to mbtowc_reset() superfluous.)
2016-05-27 10:37:43 +02:00
Benno Schulenberg 1bffa17c01 tweaks: rename two more variables 2016-05-27 10:36:54 +02:00
Benno Schulenberg a151167416 tweaks: rename some variables for contrast 2016-05-27 10:36:12 +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 3b21659661 tweaks: elide four #ifdefs, improve one comment and unwrap some others 2016-05-24 17:55:24 +02:00
Benno Schulenberg bf64386717 tweaks: rename a variable, for aptness 2016-05-24 17:52:16 +02:00
Benno Schulenberg 1b902d6267 tweaks: elide unneeded intermediate assignments 2016-05-24 17:52:01 +02:00
Benno Schulenberg 619044e83d tweaks: put some conditions in a better order: the main one first 2016-05-24 17:51:50 +02:00
Benno Schulenberg e0e788e218 tweaks: reshuffle a few things 2016-05-23 21:34:02 +02:00
Benno Schulenberg a617d9c05e tweaks: remove a redundant assignment 2016-05-23 21:25:00 +02:00
Benno Schulenberg 99e6293cd0 tweaks: remove an unnecessary intermediate assignment 2016-05-23 20:57:08 +02:00
Benno Schulenberg 286b6a9088 tweaks: rename a variable, to indicate better what it contains
And to contrast it more with 'answer'.
2016-05-23 20:46:58 +02:00
Benno Schulenberg 27e07d2af5 tweaks: rename two variables, to avoid using a name for different purposes
When calling do_prompt(), 'ans' is used to offer a default answer or the
answer given so far.
2016-05-23 20:30:01 +02:00
Benno Schulenberg 1228b2c05b tweaks: rename a variable, to indicate what it contains 2016-05-23 20:29:52 +02:00
Benno Schulenberg d6a04b8a62 tweaks: improve a few comments 2016-05-23 20:29:31 +02:00
Benno Schulenberg fbb6208d15 browser, files: use full path in error message when in confined mode
The relative path could be . or .. or even empty, which is uninformative.

This fixes the last part of https://savannah.gnu.org/bugs/?47798.
2016-05-22 11:41:58 +02:00
Benno Schulenberg c0285682e4 startup: show an error message when argument of --operatingdir is invalid
Move the initialization of the operating directory to after the
initialization of the screen, so that the above error can be shown.

This fixes the first part of https://savannah.gnu.org/bugs/?47798.
2016-05-22 11:41:58 +02:00
Benno Schulenberg 60da39cdf7 files: fix a memory leak 2016-05-21 21:35:12 +02:00
Benno Schulenberg 2e75c22759 browser: fix a memory leak 2016-05-21 21:35:02 +02:00
Benno Schulenberg 9576eb62e6 browser: show a message when getcwd() fails, instead of just beeping 2016-05-21 21:34:25 +02:00
Benno Schulenberg f9fe9a7d57 backups: take an unlikely condition into account
Between the first stat (that sets 'realexists') and the second stat
(directly after), the file might have disappeared, which would mean
that current_stat would be NULL.  Prevent dereferencing this further
down.
2016-05-21 13:58:41 +02:00
Benno Schulenberg 8bf5e58f37 tweaks: improve a few comments 2016-05-21 13:58:41 +02:00
Benno Schulenberg f6fdeeb3af files: remove a redundant condition 2016-05-21 13:58:41 +02:00
Benno Schulenberg e65352bc8a files: when writing a lockfile fails, continue loading the file
Only when the user decides not to override an existing lockfile should
loading the corresponding file be skipped.  Any failure to write the
lockfile should be ignored -- the file itself should be loaded anyway.

This fixes https://savannah.gnu.org/bugs/?47945.
2016-05-21 13:58:41 +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 c9d1936f02 files: don't reuse a variable that may have been modified by dirname()
The variable 'namecopy' has been passed to dirname(), so it is likely
to have been changed when it contains a slash.  So, use a new variable
instead.  Also, free the result of display_string().

This fixes https://savannah.gnu.org/bugs/?47956.
2016-05-18 21:34:16 +02:00
Benno Schulenberg faf5227bc5 files: remove a superfluous condition, and do not ignore a "No"
Having just opened a fresh buffer, 'openfile->next' will never be NULL,
because the list is circular.

Second, when compiled with --disable-nultibuffer, and deciding not to
override an existing lock, the 'return FALSE' should *not* be skipped,
because otherwise the named file will be opened after all.

This fixes an unreported bug.
2016-05-18 17:59:22 +02:00
Benno Schulenberg bc33539b11 files: upgrade the locking errors, so they will not be overwritten
Make the failures to read or write a lock file into important messages,
so they will not be overwritten by the number of lines read.
2016-05-18 12:08:54 +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 a878f5f183 screen: catch a window resize also when the keyboard is in nodelay mode
This fixes https://savannah.gnu.org/bugs/?47954.
2016-05-18 11:14:17 +02:00
Benno Schulenberg 5cbaf5903b tweaks: rearrange some key reading stuff in a clearer way 2016-05-18 10:36:37 +02:00
Benno Schulenberg f7c3e1cac2 spelling: gettextize the next-word message 2016-05-18 10:25:16 +02:00
Benno Schulenberg d7d3a87624 tweaks: elide an unneeded variable 2016-05-17 21:29:44 +02:00
Benno Schulenberg c03ce956c8 browser: after getting a mouse click, don't try any further interpretation
Either the selected file was changed, or a file or directory was chosen
(and the Enter key virtually pressed), or a shortcut was executed.  So,
just go and read the next key.

This fixes https://savannah.gnu.org/bugs/?47944.
2016-05-17 17:49:15 +02:00
Benno Schulenberg eedec06cc4 tweaks: fix compilation when configured with --enable-tiny --enable-browser 2016-05-17 12:48:47 +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 58404e4ba2 browser: keep the highlight in the same spot or column, when possible
When doing a PageUp or PageDown in the browser, don't move the highlight
to the first line in the same column, but keep it in the same relative
position of the screen.  If we're already on the first or last page,
move the highlight to the first or last line, but keep it in the same
column.  If we're already on the first or last line, only then move it
to the first or last entry.
2016-05-16 17:03:45 +02:00
Benno Schulenberg 36df5ceef6 browser: make Ctrl+Left and Ctrl+Right jump to left and right column 2016-05-16 17:01:45 +02:00
Benno Schulenberg 3d82986725 help: add an extra blank line to the lists of searching shortcuts
To separate things that have little to do with each other.
2016-05-16 16:55:11 +02:00
Benno Schulenberg 04a230f933 tweaks: avoid a warning when configured with --disable-wrapping 2016-05-16 16:36:49 +02:00
Benno Schulenberg 71e452aef2 screen: improve the conditional placement of a help-line item
When compiled with --disable-justify, try to keep the vertical pairing
of related items.
2016-05-16 16:34:07 +02:00
Benno Schulenberg 18bdde4aa4 search: when looking for whole words, examine the entire line
This fixes https://savannah.gnu.org/bugs/?47933.
2016-05-16 13:12:33 +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 b7f1136342 tweaks: trim or improve some comments, and rewrap two lines 2016-05-16 11:31:47 +02:00
Benno Schulenberg 2503503a2a tweaks: make the conditions for statusbar blanking more transparent 2016-05-15 11:36:51 +02:00
Benno Schulenberg 2cd21da4f0 tweaks: remove the fiddling with an unrelated setting
CONST_UPDATE is only relevant when in the main menu, not when in the
browser.  So, check for that condition, instead of saving, changing,
and then restoring the setting.
2016-05-15 11:22:44 +02:00
Benno Schulenberg 681f042326 tweaks: remove a superfluous condition
CONST_UPDATE does not need to influence the delay for blanking the
statusbar; it is enough when it simply prevents it.
2016-05-15 11:17:27 +02:00