Commit Graph

5678 Commits (528b79b5f399f9a3aec6617de460e19771f46e95)

Author SHA1 Message Date
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
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
Benno Schulenberg 34a20f8839 prompt: properly save and restore the x position in the statusbar
This fixes https://savannah.gnu.org/bugs/?47720.
2016-04-17 15:24:05 +02:00
Benno Schulenberg 6f185d3022 inserting: strip a carriage return before copying the line
Also, store the input character earlier, so we don't have to use len - 1.
Furthermore, len increments in steps of 1, so it cannot pass the value of
bufx unnoticed, so use a comparison for equality.
2016-04-17 13:02:04 +02:00
Benno Schulenberg c5b8f52c07 inserting: don't bother zero-terminating every single character
Just let read_line() zero-terminate the intermediate buffer when
the line is complete.
2016-04-17 12:34:07 +02:00
Benno Schulenberg bcdc90e85f inserting: reshuffle some conditions for a teeny bit more speed
Most of the time NO_CONVERT will not be set, the number of lines will
not be zero, and the format of the file will be zero.  Rearrange the
conditions so that they will evaluate as FALSE as soon as possible.
2016-04-17 11:44:22 +02:00
Benno Schulenberg f5c6246433 inserting: prune a duplicate variable
Index i follows almost synchronously the value of len.  Since we're
adding characters to the intermediate buffer always only at the end,
just use len as the index.
2016-04-17 10:46:56 +02:00
Benno Schulenberg 086b85215f inserting: treat also the final \r of a Mac file as a newline
Until now (when not leaving files unconverted), nano would fumble and
drop the final carriage return of a Mac file, and would thus treat the
last line of such a file as an unterminated line and prepend it to the
current line of the buffer.  Correct that, and delete the dead piece
of code that was meant to do this.

This fixes https://savannah.gnu.org/bugs/?47716.
2016-04-17 10:19:02 +02:00
Benno Schulenberg dac0aa1d89 inserting: prune some superfluous settings, and do one differently
When we don't set edittop in read_line(), we don't need to readjust it in
read_file(), because in that particular case it will still be pointing at
current.  And since fileptr is a new, freshly created line, it can never
be equal to filebot, so there is no point in comparing them.

If more than one line was inserted at the beginning of the file, leave it
up to the screen handling to set edittop to what it should be.

Move the setting of fileage a bit down, to its sister setting: the line
at current gets "connected" either to the top-of-file pointer or to the
last line of the inserted file.
2016-04-16 21:38:17 +02:00
Benno Schulenberg 04013fb7fa search: untangle two lines and tweak two comments 2016-04-16 12:52:42 +02:00
Benno Schulenberg a101b30fa8 keyboard: reshuffle some lines to avoid an empty while 2016-04-16 11:57:05 +02:00
Benno Schulenberg 0bffd99dcb scrolling: elide a variable, to make clearer that edittop is being moved 2016-04-16 11:38:39 +02:00
Benno Schulenberg 4c075f3771 tabbing: rename four variables, snipping a redundant part 2016-04-16 11:32:37 +02:00
Benno Schulenberg 0ccdaff960 tabbing: avoid recalculating the length of the first match every time
Also don't zero-terminate the matches in order to compare them,
but just limit the length of the comparison.
2016-04-16 11:15:33 +02:00
Benno Schulenberg 2d50c4f257 softwrap: adjust for current_x when computing the amount to scroll
The number of lines to scroll is: the y position of the start of the
current line, plus the extra lines that this line occupies, plus the
extra lines that the next line occupies, plus one, minus the y position
of the last window line.

The y position of the start of the current line is current_y -
xplustabs() / COLS, the extra lines are strlenpt(data) / COLS,
and the y position of the last window line is editwinrows - 1.

Note that we first compute the amount to scroll before actually moving
to the next line, because we need the current value of current_x, not
the one that it will have in the next line.  The placewewant value is
not good either, because it might be beyond where we actually are.

This fixes https://savannah.gnu.org/bugs/?47665.
2016-04-15 17:16:28 +02:00
Benno Schulenberg 6a9e2a4d3e files: handle systems that disallow NULL as first parameter of getcwd
(This change will be made superfluous when we start using gnulib.)

This prevents getcwd() from failing on Android and thus completes the
fix for https://savannah.gnu.org/bugs/index.php?47659.

Reported-by: Chris Renshaw <osm0sis@outlook.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-04-15 13:35:27 +02:00
Benno Schulenberg ff1bf88562 files: limit the number of attempts at climbing up the directory tree
Doing a chdir("..") will not fail when the root directory is reached,
and when getcwd() keeps failing too, we have no way of knowing when
to stop.  So, simply limit the number of attempted chdirs, to avoid
getting into an endless loop.

This avoids the hang in https://savannah.gnu.org/bugs/index.php?47659.

Reported-by: Chris Renshaw <osm0sis@outlook.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-04-15 12:36:07 +02:00
Benno Schulenberg 6414f9f000 titlebar: snip two superfluous tests for having enough space
If nano has less than four columns available, it will die,
so there will always be room for at least four characters.
2016-04-13 17:54:06 +02:00
Benno Schulenberg 2246029447 screen: elide a variable and serialize some logic for clarity
Also, don't force a full refresh of the edit window simply because the
current line needs to be horizontally scrolled.  And further, when the
adjustment of edittop has determined that a full refresh is needed,
get out and don't bother scrolling some lines first.
2016-04-13 13:19:24 +02:00
Benno Schulenberg 503654e60e screen: don't redraw some lines when doing a full refresh anyway
When in softwrap mode and scrolling down a line, and thus going to
do a full refresh, get out and don't bother redrawing the current
and prior lines first.
2016-04-13 13:12:25 +02:00
Benno Schulenberg e393a6c345 screen: don't redraw the current line unnecessarily
When moving the cursor up or down one line, redraw the new current
line only when the target column (placewewant) is beyond the screen,
or when the mark is on.

(This still redraws the current and prior lines unnecessarily when
they are in fact shorter than the screen is wide and the mark is off,
but we'll let that pass for now.)

Also, when softwrap is on, we don't have have to redraw the current
and prior lines at all (when the mark is off): they are in full view,
there is nothing to show or hide.
2016-04-13 13:04:35 +02:00
Benno Schulenberg 9d7930328b screen: a full refresh is only needed when softwrap is on
When scrolling down a line, a full refresh of the edit window is only
needed when softwrap is on, because only then the movement is irregular.
When each file line takes up just one screen line (softwrap is off),
edit_scroll() is perfectly able to scroll and redraw only the necessary
lines.

(But... when doing a full refresh anyway with softwrap, why bother
scrolling at all?  Why not just adjust edittop and call refresh?)
2016-04-13 13:04:35 +02:00
Mike Frysinger 111b30008a syntax: changelog: support more bug/issue styles
These are formats used by binutils/glibc/gdb/gcc.
2016-04-12 15:20:30 -04:00
Benno Schulenberg ec295f5e68 build-sys: detect a build from git and show its short commit hash 2016-04-12 10:28:45 +02:00
Benno Schulenberg 4b5b66a806 screen: avoid redrawing a line twice
The old_current line needs to be redrawn only if it differs from current,
and if it wasn't drawn already by the iteration for when the mark is on.

Also make the conditions involving horizontal scrolling more precise.
2016-04-11 20:40:21 +02:00
Benno Schulenberg aa1ae0a144 screen: concentrate the setting of placewewant
Instead of saving the current value of placewewant, then setting the
new value, and then passing the old value to edit_redraw() in seven
different places, just let edit_redraw() do this saving and setting.

In the bargain placewewant is now only recalculated when it matters
-- when allow_update is TRUE -- and not when it's superfluous.
2016-04-11 20:38:05 +02:00
Benno Schulenberg dbe39901b2 utils: snip a superfluous check for NULL
Nano doesn't start doing anything with the edit window or the keyboard
until all files have been read in or a blank buffer has been opened, so
the case of openfile->current == NULL will never occur.

Also correct the comment -- because with multibyte characters, it is
very well possible that the screen column corresponding to current_x
is smaller than current_x itself.
2016-04-10 17:49:22 +02:00
Benno Schulenberg fc7eb69b70 files: allocate enough space for the prompt when finding a lock file
Instead of allocating a fixed amount of 128 bytes, which will overflow
and segfault, adjust the allocation to the length of the file name, and
if necessary trim the file name to make the prompt fit on the screen.

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

Reported-by: Aapo Rantalainen <aapo.rantalainen@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-04-10 11:17:38 +02:00
Benno Schulenberg 023fccb966 search: avoid saving and restoring placewewant when bracket matching
Now that findnextstr() no longer sets placewewant, we can can make
a copy of the old value just where needed: when a bracket is found.
2016-04-10 11:14:03 +02:00
Benno Schulenberg ea4e9b3156 search: don't set placewewant when we are just iterating
In the innermost search loop, don't set placewewant, because this loop
is also used for replacing and spell fixing, when we don't really want
to be there: we are just passing through.  Not setting placewewant means
we don't need to save and restore it in those passing-through routines.

The value of placewewant is only relevant when doing cursor movement,
which doesn't happen during replacing nor spell checking, so there is
no need to keep placewewant up to date -- it is set when it matters:
at the end of go_looking().
2016-04-10 11:11:24 +02:00
Benno Schulenberg 7ba356a62c searching: don't keep track of current_y, but calculate it at the end
Stop keeping track of the vertical screen position when searching for
something.  If nothing is found, current_y doesn't change, and all the
incrementing/decrementing was a waste of time.  If something is found
and it is onscreen, it is easy to calculate the new current_y.  And if
something is found and it is offscreen, then current_y is irrelevant,
because we will be either centering the found occurrence (searching)
or putting it on the top or bottom line (bracket matching).

(The above does not take softwrapping into account, but neither did
the old code, so this doesn't introduce any new bugs.)

(Also, when the search wraps, and the viewport is away from head or
tail of the file, and the found occurrence is within the viewport,
then the incremented/decremented current_y would be way wrong, but
this didn't have any adverse effects as far as I could tell.  It
seems that current_y is irrelevant in most cases.)
2016-04-08 18:31:15 +02:00
Benno Schulenberg cb17732ac2 scrolling: don't scroll too much when having to bridge blank lines
Add a third mode of scrolling, FLOWING, besides CENTERING and STATIONARY.
This is used for word and paragraph jumping (and for bracket matching,
but that worked correctly already), and only when focusing is FALSE.

The new mode prevents the screen from scrolling too many lines when
there are several blank lines at the bottom of the edit window and
the next word or paragraph is out of view.

This fixes https://savannah.gnu.org/bugs/?47194.
2016-04-07 14:28:25 +02:00
Mike Scalora d851ccdd41 keyboard: recognize four escape sequences produced by iTerm2
On iTerm2 on OS X, the Option+Arrow keys produce special sequences
that start with two escapes.  Catch these sequences and interpret
them appropriately as WordLeft / WordRight / Home / End.

Signed-off-by: Mike Scalora <mike@scalora.org>
Signed-off-by: Thomas Rosenau <thomasr@fantasymail.de>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-04-05 21:00:54 +02:00
Benno Schulenberg da9ea91b37 build-sys: ignore .patch, .orig and .swp files 2016-04-05 17:14:30 +02:00
Benno Schulenberg 54217ea500 i18n: advise the translators about the maximum length of some strings 2016-04-05 16:29:36 +02:00
Benno Schulenberg ba38d61f22 files: prune a message to be less than 76 characters
So it will fit on the screen when using a standard 80-column terminal.
2016-04-05 16:13:54 +02:00
Benno Schulenberg 4a9b97b101 help: only speak of Control and Meta sequences
Don't call the latter ones Escape sequences, because both Control
and Meta sequences can be entered using the Escape key.
2016-04-05 16:11:56 +02:00
Benno Schulenberg 28b4bd7932 build-sys: identify a build from git not as one from svn 2016-04-05 15:11:09 +02:00
Benno Schulenberg dea708bf94 i18n: gather three more translatable strings into the POT file 2016-04-05 15:00:43 +02:00
Benno Schulenberg d92eb4fee3 all: eradicate SVN's $Id$ tags 2016-04-05 14:59:12 +02:00
Mike Frysinger 5cda85caaa README.GIT: update a few more points to match current tree 2016-04-04 18:46:21 -04:00
Chris Allegretta 5cb3f09a78 Rename README.SVN -> README.GIT and take out the branch details since we're generally using trunk 2016-04-04 18:08:32 -04:00
Chris Allegretta 686b784d04 Add /intl to gitignore 2016-04-04 18:03:03 -04:00
Benno Schulenberg 33a6f6a1b6 files: do not call free on the result of dirname
This fixes https://savannah.gnu.org/bugs/?47544,
and thus also http://gnats.netbsd.org/51010.

Reported-by: Adrian Siekierka <asiekierka@gmail.com>
Reported-by: Matthew Hall <mhall@mhcomputing.net>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-04-04 21:11:46 +02:00