Commit Graph

5523 Commits (5e4f16da445d824ad0ecdf05e4867e2a36a0acee)

Author SHA1 Message Date
Benno Schulenberg 5e4f16da44 tweaks: remove a superfluous call of 'wnoutrefresh'
The function 'bottombars' has already done this.
2016-05-12 11:59:45 +02:00
Benno Schulenberg 81b29d9a21 tweaks: remove a superfluous setting of 'refresh_needed'
An interactive 'gotolinecolumn' has already refreshed the screen.
2016-05-12 11:56:59 +02:00
Benno Schulenberg 8ddc5e7b93 browser: make the calculation of files-per-line a straightforward one
There is no need to iterate through all the file names, as we already
know the length of the longest.  From this it's easy to calculate how
many names fit on a line.
2016-05-10 21:24:34 +02:00
Benno Schulenberg c6ec435ae9 browser: use the reselection mechanism also after resizing and after help
Also rename some things to be more fitting.  And make sure that something
will be selected even when many files, including the selected one, have
disappeared.
2016-05-10 17:50:07 +02:00
Rishabh Dave 8a5b4f616b browser: keep the same file selected when the directory contents change
When refreshing the screen (and thus the file list), use the prev_dir
mechanism to reselect the file that was selected before the refresh,
to prevent the selection from changing when files were added or deleted.

Also, when the selected name has disappeared, move the highlight one step
back, so that it is obvious that the selection has changed.  (Decrementing
'selected' will never make it negative, because selected == 0 means the
'..' entry, and every directory has a '..' entry, so it will be found.)

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

Signed-off-by: Rishabh Dave <rishabhddave@gmail.com
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-05-10 16:55:58 +02:00
Benno Schulenberg 9cbe6a640c search: when polling the keyboard, consume all waiting keystrokes
When during searching we look at the keyboard, then don't look at
just the first keystroke, but check if there are more, and if so,
check each one until we find a Cancel -- or until all keystrokes
have been consumed and we can continue.

This fixes the first half of https://savannah.gnu.org/bugs/?47438.
2016-05-06 09:31:49 +02:00
Benno Schulenberg c918c6563b input: properly restore waiting mode, or retain non-waiting mode
Cancelling a search should restore waiting mode for the keyboard,
just like at the other exit points of the search routine.

And when the input routine has read in multiple keystrokes, it
should not blindly switch back to waiting mode, but only when
that mode was on before.

This fixes the second half of https://savannah.gnu.org/bugs/?47438.
2016-05-06 09:30:55 +02:00
Benno Schulenberg 577f7fafa9 screen: make better use of the available space in the titlebar
When the terminal is very narrow, there is little point in showing only
part of the version string -- and chewing off one or two digits from the
version number might even give someone a wrong idea.  The user is better
served with always showing the full filename, as long as it fits in the
available screen width.

This fixes https://savannah.gnu.org/bugs/?47703.
2016-05-05 20:09:10 +02:00
Benno Schulenberg 338807a327 help: bring some air into the lists of shortcuts, giving the eye a hold 2016-05-05 13:27:07 +02:00
Benno Schulenberg a7c158d07d input: simplify a bit of code, reducing a four-case switch to a single if 2016-05-05 13:21:19 +02:00
Benno Schulenberg 97e9849d6c TODO: tidy up the punctuation
Also remove the item about one Replacement Character per invalid UTF-8
sequence, because how many bytes form a sequence?  Two?  Three?  Four?
Better just put one Replacement Character per invalid byte, like is
done now.
2016-05-05 13:00:20 +02:00
Benno Schulenberg be4a3f8273 spelling: separate the fixing of different words with a short pause
When fixing a misspelling and not answering 'All' (but 'Yes' or 'No'),
the chance is quite substantial that one will type y or n at the end of
the next word.  Diminish this chance by showing for a moment a message
on the statusbar.
2016-05-04 19:45:09 +02:00
Benno Schulenberg 433c7e5dc6 spelling: don't partition the file for replacements in a marked region
Partitioning the file makes the undo system lose track, so that undoing
things has a good chance of losing data.  Instead, just make sure that
the region is marked "backwards", with current at the top and the mark
at the bottom, and then let the replace loop take care of not going
outside of the marked region.

This also has the effect that if the marked region fits entirely on the
screen, or all the misspellings are onscreen, then the screen will not
be scrolled at all.  Which makes for a smooth experience.

This fixes https://savannah.gnu.org/bugs/?47836,
and fixes https://savannah.gnu.org/bugs/?45573.
2016-05-04 19:45:09 +02:00
Benno Schulenberg 9d6d5b679a screen: rename a variable, because 'disable' sounds too permanent 2016-05-04 12:18:21 +02:00
Benno Schulenberg f1b9ba2781 rcfile: make an error message equal to another, and more informative 2016-05-04 10:22:28 +02:00
Benno Schulenberg 318ed6b105 scrolling: center the cursor when inserted stuff does not fit on screen
Since nano-2.4.1, reading in or pasting a large piece of text would put
the cursor on the bottom line, leaving only one line of the non-read or
non-pasted text visible.  This is different from the centering behavior
of Pico, and somewhat disorienting, as you can't see "where you are" any
more in relation to the file as it was.

So now center the cursor whenever the read or pasted text is larger than
the screen, but don't center it when the text fits entirely on the screen.
(The latter avoids the effect of the screen jumping unnecessarily when
inserting just a few lines while the cursor is near the bottom.)

To achieve this behavior: default to focusing, and temporarily set it to
FALSE when the focusing effect is unwanted.

This fixes https://savannah.gnu.org/bugs/?47841.
2016-05-04 10:13:36 +02:00
Benno Schulenberg 402cf718c4 input: trim some oververbose comments 2016-05-04 09:56:28 +02:00
Benno Schulenberg 7b3649abc9 input: don't take multiple keystrokes to be a single sequence
For some reason the keyboard code seems to assume that all integers
waiting in the keybuffer form a single sequence.  But this isn't the
case: when there is an escape (0x1b) among them, then that is where
a new sequence starts.  So, prevent the input code from considering
an escape after a non-escape as part of the current sequence.

This fixes https://savannah.gnu.org/bugs/?47839.
2016-05-04 09:56:15 +02:00
Benno Schulenberg 937c47898a spelling: pass the correct position of the cursor
When starting to replace misspelled words, pass the actual position
of the cursor instead of the position of the first found occurrence,
so that the cursor position will be updated for changed lengths.

This fixes https://savannah.gnu.org/bugs/?47834.
2016-05-03 13:07:40 +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 e666f8c50d input: write a few ifs more compactly 2016-05-02 21:58:43 +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 e21e954742 browser: add a binding for the refresh function
And make the function actually refresh the list.  Useful for when files
have been added or deleted since opening the browser.
2016-05-02 12:00:56 +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 eb871e72f5 input: distinguish an unknown escape sequence from an unbound key
It is misleading to say "Unknown Command" when there is no way to rebind
the relevant key stroke do anything useful.
2016-05-01 22:04:17 +02:00
Benno Schulenberg 3c8647e713 search: terminate the loop a tiny bit earlier when spell checking
The internal spell checker starts searching/replacing always at the top
of the buffer, so reaching the end of the buffer means we're done with
the current search/replace.  This prevents the "Search Wrapped" message
from flashing over the statusbar at the end of a spelling replacement.
2016-05-01 13:00:30 +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 9f1a44d9e3 replacing: properly detect when we've rereached the starting position
Commit 8704dde mistakenly removed this part of code -- it is not dead,
it is just that it will only fire when the user answered No at some of
the replacement prompts.  So... when we've rereached the starting line,
a found occurrence is invalid when it is beyond the starting x (either
after or before it, dependending on the direction of search).

This fixes https://savannah.gnu.org/bugs/?47816.
2016-05-01 12:44:58 +02:00
Benno Schulenberg 3ea8f42c7f browser: rearrange the search loop to elide two unneeded variables
Simply move to the next filename first before starting to match.
2016-04-29 17:50:53 +02:00
Benno Schulenberg 02153402ec browser: when nothing was found, restore the global search flags
Don't skip the end of the function: use break instead of return.
2016-04-29 17:03:45 +02:00
Benno Schulenberg b26aaa7e42 screen: fix compilation when configured with --enable-tiny 2016-04-27 17:45:36 +02:00
Benno Schulenberg 9330aa60a5 rcfile: disallow 'bind' and 'unbind' in an included file
Included files are meant to contain only syntax definitions; they may
not set or unset options, nor rebind keys, nor include other files.

This fixes https://savannah.gnu.org/bugs/?47391.
2016-04-27 10:07:45 +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 133ed4e21d tabbing: don't null-terminate a directory name on the slash but after it
This fixes https://savannah.gnu.org/bugs/?47786.
2016-04-26 14:28:01 +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 b97c36c218 screen: don't always set 'edit_refresh_needed' when adjusting edittop
The function edit_update() is called by edit_refresh() itself, so it is
silly that the first sets 'edit_refresh_needed' to TRUE.  This setting
is needed only in a few cases -- in the others it's not needed because
the screen does not need to be refreshed (it was just about positioning
the cursor), or 'edit_refresh_needed' has already been set by a call to
goto_line_posx().  So, just set the flag in the five places that need it
and spare the other four calls.
2016-04-25 20:17:40 +02:00
Benno Schulenberg 3e1d2b9049 tabbing: make sure to refresh the edit window when returning to it
Since commit 41ed690, cancelling a prompt after tabbing would sometimes
leave the list of file names on the screen.  When testing this first,
it worked fine -- I was fooled again by 'edit_refresh_needed' already
being TRUE when nano has just started up and sits waiting for the first
key stroke.  I have to hunt this down and kill it.
2016-04-25 17:56:23 +02:00
Benno Schulenberg 907ba3a2e2 scrolling: catch the special case of reading a file from standard input
Since commit dac0aa1, nano would leave edittop at current after reading
data from standard input, meaning that everything that had been read in
was invisible, "scrolled off" the top of the screen.  Correct this by
explicitly setting edittop.

The above does not happen for ^R (^X) because it has a special mechanism
to save and restore edittop.  Nor does it happen for ^R ^X M-F because it
sets current to the top of the file and refreshing the screen will make
edittop follow, or -- in case just one unterminated line was read in --
edittop will already be equal to current.
2016-04-25 17:48:06 +02:00
Benno Schulenberg 981b414980 utils: distinguish between width (columns) and length (bytes) 2016-04-24 22:02:48 +02:00
Benno Schulenberg 06b1fcad13 tabbing: fix erroneous use of strnlenpt()
Names could be strings of multibyte characters, so they could be more
than COLS - 1 bytes long and still be less than COLS - 1 columns wide.
2016-04-24 21:44:11 +02:00
Benno Schulenberg 92b8d6fb24 files: miscellaneous tweaks of braces, comments, and variable names 2016-04-24 21:24:17 +02:00
Benno Schulenberg 0b33ab552b files: make an 'if' more transparent and snip an unneeded condition
Also unwrap or improve some comments.
2016-04-24 17:28:21 +02:00
Benno Schulenberg 2faad1230a locking: don't try to read more bytes than the buffer can hold
A normal lock file is apparently 1024 bytes in size, so the second
attempt at reading bytes from the file would try to read 8192 more
bytes into a buffer that has room for only 7168 left.  According to
valgrind, the read() function doesn't like that -- and true: if for
some reason the lock file had suddenly expanded, the buffer would
overflow.

This fixes https://savannah.gnu.org/bugs/?47156.
2016-04-23 20:41:23 +02:00
Benno Schulenberg bfe418febb files: when opening a buffer, make sure to expand a tilde in its name
When a tilde is used in the name given at the ^R or ^O prompts, nano
expands it, but /not/ when a tilde is given on the command line (in
such a way that the shell leaves it as is).  Correct that asymmetry.

This fixes https://savannah.gnu.org/bugs/?44929
and fixes https://savannah.gnu.org/bugs/?47702
and fixes https://savannah.gnu.org/bugs/?47771.
2016-04-23 18:17:48 +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 553b7af355 files: do not use two variables for two different purposes each
Use 'slash' to point at a possible slash, use 'filename' just to
point at the real file name, and use 'wasdirname' just to point at
the dir's name before expanding it in order to be able to free it.

Also, remove two superfluous asserts: 'dirname' cannot be NULL
because it has just been mallocstrcpy'd, and checking 'num_matches'
is pointless as it would crash on the next statement anyway.
2016-04-23 15:03:39 +02:00
Benno Schulenberg 2815eaa5f8 files: rewrap en reindent some lines 2016-04-23 13:45:05 +02:00
Benno Schulenberg 5c5fefc8cf files: tweak the function tail() and rename two variables 2016-04-23 13:26:28 +02:00
Mike Frysinger 8aeb8434d6 more svn->git updates 2016-04-17 23:39:07 -04:00