Commit Graph

654 Commits (f26e88bb52181899ad2e713614681be52e64fa1a)

Author SHA1 Message Date
Benno Schulenberg f26e88bb52 tweaks: a few last tiny adjustments before release 2016-06-17 15:04:44 +02:00
Benno Schulenberg aa09abe198 files: when the requested operating directory cannot be set, fail
Specifying an operating directory should either lead to a successfull
confinement, or nano should fail to start.

(Also: save the terminal settings as soon as possible, so that an early
die() will not restore uninitialized values.)

This fixes the first part of https://savannah.gnu.org/bugs/?47798 properly.
2016-06-12 11:13:45 +02:00
Benno Schulenberg 5aa1df37d1 files: recompute the multidata only when the applicable syntax changed 2016-06-08 14:17:30 +02:00
Benno Schulenberg ca2c808f69 files: free all the multidata when a file is saved, then recompute it
This fixes https://savannah.gnu.org/bugs/?48103.

(The fix is wasteful -- it should only discard the multidata if actually
the name *did* change, *and* if the applicable syntax changed.)
2016-06-08 13:31:18 +02:00
Benno Schulenberg 5dee9fb2c6 files: it is fine to "change" the name of a nameless buffer
This fixes https://savannah.gnu.org/bugs/?48156.
2016-06-07 10:15:25 +02:00
Benno Schulenberg 9f4b4c975a files: prevent dereferencing a possible (although very unlikely) NULL
Don't catch the NULL earlier, because we do want an error message when
opening the lockfile fails.
2016-06-04 11:18:29 +02:00
Benno Schulenberg 0293eac1d1 files: report an unwritable file in a separate message
That is: don't mix the number of lines read with a warning about the
file being unwritable -- the former is just convenience information,
the latter is a must-see.

This fixes https://savannah.gnu.org/bugs/?48047.
2016-06-03 21:18:14 +02:00
Benno Schulenberg 17cf833b9c tweaks: normalize some whitespace 2016-05-30 09:09:36 +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 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 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 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 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 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 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
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 eb2661dc2d spelling: if rereading the file fails, don't destroy the current buffer
If for some reason opening the spell-checked or formatted file fails,
don't throw away the current contents of the buffer.

(It should also give proper feedback about the failure, but we'll leave
that for some other time.)
2016-04-17 17:33:18 +02:00
Benno Schulenberg c2518dd5f0 inserting: differentiate not finding a file from not finding a string
Because it is a little clearer, and it is what Pico does too.

This partly fixes https://savannah.gnu.org/bugs/?47721.
2016-04-17 17:30:52 +02:00