Benno Schulenberg
79a4bf81dc
tweaks: rename five variables, for uniformity with a few others
2016-12-19 19:58:15 +01:00
Benno Schulenberg
b77e6bd99d
general: simplify the detection of a SIGWINCH
...
There is no need for a counter, nor an old counter to compare it with.
2016-12-19 10:04:01 +01:00
Benno Schulenberg
2bcc6d7f66
tweaks: start searching at a better place
...
Taking the terminating newline into account, and that there is
at least one digit per number.
2016-12-19 09:57:31 +01:00
Benno Schulenberg
cd705a7c4c
tweaks: elide a counter and a comparison
...
For clarity and a tiny bit more speed. Also rename some variables.
2016-12-19 09:44:30 +01:00
Benno Schulenberg
ecd18c1694
history: search for the two position numbers from EOL instead of BOL
...
A filename might contain spaces, so we can't look for the numbers
(the second and third elements) starting from the head of the line
-- we have to start at the tail and work backward.
This fixes https://savannah.gnu.org/bugs/?49879 .
2016-12-18 19:57:33 +01:00
Benno Schulenberg
bc8a3a50a4
tweaks: rename three variables, for visibility
...
(I don't /see/ single-letter variables -- they are too small.)
2016-12-18 19:31:11 +01:00
Benno Schulenberg
9b90ec877a
tweaks: drive closer to the edge
2016-12-18 17:56:18 +01:00
Benno Schulenberg
8b483c10ba
history: don't bother encoding search items -- they cannot contain newlines
2016-12-18 17:55:39 +01:00
Benno Schulenberg
f915a28d30
tweaks: don't bother trimming the final newline from a position item
...
It is irrelevant -- the line is discarded as soon as the data has been
extracted.
2016-12-18 16:44:39 +01:00
Benno Schulenberg
cb3fc8892a
tweaks: rename a variable and rewrap two lines
2016-12-18 16:34:19 +01:00
Benno Schulenberg
06d9ee89e5
history: encode newlines in filenames as nulls
...
So they will not break a line in the positionlog file in two.
(Strangely, the reading in of such a log file already decodes
nulls back into newlines.)
This fixes https://savannah.gnu.org/bugs/?49877 .
2016-12-18 12:27:55 +01:00
Benno Schulenberg
0b0b812206
files: don't change embedded newlines into nulls in filenames
...
Because changing anything to a null effectively means to truncate
the name.
This fixes https://savannah.gnu.org/bugs/?49868
and fixes https://savannah.gnu.org/bugs/?49874 .
2016-12-18 11:37:57 +01:00
Benno Schulenberg
eafae5d417
screen: show an embedded newline in filenames as ^J instead of ^@
...
The byte 0x0A means 0x00 *only* when it is found in nano's internal
representation of a file's data, not when it occurs in a file name.
This fixes the second part of https://savannah.gnu.org/bugs/?49867 .
2016-12-18 11:13:50 +01:00
Benno Schulenberg
dfff78dffe
titlebar: always pass a pathname through display_string()
...
So that embedded control characters will be represented
instead of acted upon.
This fixes the first part of https://savannah.gnu.org/bugs/?49867 .
2016-12-18 11:13:49 +01:00
Benno Schulenberg
40acb8714c
oops: forgot to add and amend this to the previous commit
2016-12-18 11:12:04 +01:00
Benno Schulenberg
d7af590c6b
memory: don't bother making a snug fit for things that will be freed soon
...
Most full paths are needed only temporarily and will be freed within
milliseconds. Only 'full_operating_dir' and 'backup_dir' continue to
exist for the whole current session. Any partition, too, will soon be
unpartitioned, so the extra reallocation is just a waste of time.
2016-12-18 10:33:30 +01:00
Benno Schulenberg
8c7e4f5108
tweaks: rename a function to describe what it does
...
It doesn't align anything -- any allocations are already aligned to
whatever multiple is required -- it just shrinks the allocated space.
2016-12-18 10:30:35 +01:00
Benno Schulenberg
1144d38316
tweaks: don't bother reallocating a string of which there is only one
...
And which normally is just some ten or twenty characters long, and
never gets wildly overallocated.
2016-12-18 10:28:30 +01:00
Benno Schulenberg
0562d27b9c
tweaks: delete a bunch of unneeded asserts
...
Nano would crash straight afterward if any of these asserts would fail,
so they don't add anything. A few others are simply superfluous.
2016-12-15 21:15:32 +01:00
Benno Schulenberg
c5f49167ea
tweaks: write two pieces of conditionalized code like all others
...
Also trim or improve a few comments.
2016-12-15 19:48:09 +01:00
Benno Schulenberg
9765c2faa0
tweaks: elide a function that is called just once
2016-12-15 19:28:43 +01:00
Benno Schulenberg
85ebe971e2
chars: optimize for the most common case
...
That is: elide a second test from the most travelled path: a valid
character. This adds a second call of mblen() when parse_mbchar()
is called on a terminating zero, but that should never happen.
2016-12-15 17:44:18 +01:00
Benno Schulenberg
fc101a6ded
tweaks: rename a variable to be shorter and clearer
2016-12-15 15:50:07 +01:00
Benno Schulenberg
eb88ad980a
tweaks: use a slightly faster comparison
2016-12-15 13:15:46 +01:00
Benno Schulenberg
9fa95a3680
tweaks: put some prototypes in the proper order, and move a bit of code
2016-12-15 13:04:52 +01:00
Benno Schulenberg
d6cc2c40fe
tweaks: conditionalize a function that is not used in the tiny version
...
The fsfromline() function is mostly used by the undo functions, which
are not present in the tiny version. It is also used by the comment/
uncomment feature, but this feature cannot be enabled when --enable-tiny
is in effect.
2016-12-15 12:45:02 +01:00
Benno Schulenberg
1df4115013
version: properly mention --disable-wordcomp if it was used
2016-12-15 12:38:47 +01:00
Benno Schulenberg
ea9f62fc0f
tweaks: adjust some comments and indentation and ordering
2016-12-13 19:27:33 +01:00
Benno Schulenberg
a772194102
tweaks: rename two variables, for self-documentation
2016-12-13 17:13:38 +01:00
Benno Schulenberg
faf77fb1ec
tweaks: don't bother making the next line of an end point NULL
2016-12-13 17:12:52 +01:00
Benno Schulenberg
b0b24d9c3a
utils: slightly speed up the calculation of the size of a buffer
...
Achieve this by eliding two conditions from the inner loop,
which is possible because 'end' will never be NULL.
2016-12-13 17:11:08 +01:00
David Lawrence Ramsey
c9f743f676
tweaks: elide two unneeded variables from line numbering mode
...
Instead compute directly whether we're at a softwrapped part or not.
2016-12-13 17:01:39 +01:00
David Lawrence Ramsey
bd920b1f49
tweaks: adjust the type of two arguments
...
Convert digits() to take a ssize_t instead of an int, since it's
used on ssize_t line numbers. And properly use the long modifier
when displaying a line number.
Also, conditionalize the digits() prototype.
2016-12-13 13:06:20 +01:00
Benno Schulenberg
13ec5d8ce9
spelling: correctly restore the selected region
...
An added magic linefeed should be removed again /before/ restoring
the x position, as the latter needs to be calculated from the real
last line of the region.
This fixes https://savannah.gnu.org/bugs/?49817 .
Reported-by: Mike Frysinger <vapier@gentoo.org>
2016-12-11 09:55:38 +01:00
Benno Schulenberg
30591c5e01
tweaks: use a while loop when the end point is not known in advance
...
It is easier to see the order of steps and what the terminating
condition is.
2016-12-10 21:18:10 +01:00
Benno Schulenberg
3f8e30efb1
tweaks: delete some obscuring debugging stuff
...
When wanting to debug something, it is far more useful
to temporarily insert lines like:
statusline(ALERT, "name = %i", variable);
It provides instant feedback, and it slows things down,
so you can kind of see what happens.
2016-12-10 21:01:07 +01:00
Benno Schulenberg
e9fde7d7dc
mouse: use the correct screen width for calculating the cursor position
...
When there are line numbers, the effective available screen width is
smaller than COLS: editwincols.
This fixes https://savannah.gnu.org/bugs/?49821 .
2016-12-10 20:06:59 +01:00
Benno Schulenberg
a4044a7e5d
tweaks: remove some cluttering conditional compilation
2016-12-09 13:32:15 +01:00
Benno Schulenberg
2fa93ae999
tweaks: rename two variables to make more sense
2016-12-09 12:47:00 +01:00
David Lawrence Ramsey
c8c6340ce8
tweaks: conditionalize a bit of softwrap code
...
This addresses https://savannah.gnu.org/bugs/?49803 .
2016-12-09 12:34:56 +01:00
David Lawrence Ramsey
6263416355
moving: always account for the margin when in line numbering mode
...
Like do_down() does already, do_pageup() and do_right() should use
editwincols instead of COLS.
This addresses https://savannah.gnu.org/bugs/?49796 .
2016-12-09 12:23:23 +01:00
David Lawrence Ramsey
84d6f1a5b6
tweaks: adjust the type of four lockfile variables
...
The functions read() and fwrite() take size_t, not ssize_t.
And line numbers in the file should be displayed as a long type instead
of an int, since the effective type of ssize_t is not int, but long.
2016-12-09 10:05:33 +01:00
Benno Schulenberg
ecccb8d027
tweaks: correct the wording of a string
2016-12-07 21:06:05 +01:00
Benno Schulenberg
173bbe11ef
tweaks: add a few translator hints
2016-12-07 21:05:41 +01:00
Benno Schulenberg
7531b71fa1
docs: note Sumedh as the author of the word-completion feature
2016-12-07 21:05:23 +01:00
Benno Schulenberg
964c10db17
tweaks: miscellaneous frobbings and rewrappings
2016-12-07 20:37:08 +01:00
Benno Schulenberg
0e01080983
binding: allow to rebind the word-completion function, and document it
2016-12-07 17:18:56 +01:00
Benno Schulenberg
68a0314500
build: add configure option --disable-wordcomp to disable word completion
...
(The variable 'pletion_line' is not conditionalized with this option, as
it would become messy. The compiler will probably be able to elide it.)
When using --enable-tiny, it is not possible to use --enable-wordcomp,
because the word completion function uses the undo system.
2016-12-07 17:02:25 +01:00
Sumedh Pendurkar
dca4ab5d8f
new feature: complete a fragment to a longer word found in the buffer
...
Executing the 'complete_a_word' function will search from the start
of the current buffer for entire words that begin with the fragment
that is before the cursor, and will complete this fragment to the
first word that is found. Each consecutive call of 'complete_a_word'
will search for the next matching word and will complete the fragment
to that. By default the function is bound to the ^] keystroke.
Signed-off-by: Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-12-07 16:42:39 +01:00
Benno Schulenberg
86121cf3fc
tweaks: move a cursor-on switch to a more logical place (again)
...
But do it correctly this time: don't switch it on when replacing.
2016-12-05 15:47:44 +01:00
Benno Schulenberg
379b1556ed
prompt: remove two fragments of dead code
...
None of the prompts offer a total-refresh shortcut -- only the
edit window, the help viewer, and the file browser provide this.
2016-12-04 12:34:56 +01:00
Benno Schulenberg
bfcce57b69
screen: remove an unneeded blanking of the statusbar
...
It's redundant because the call of total_refresh() wipes everything.
2016-12-04 12:32:59 +01:00
Benno Schulenberg
4eac699df3
tweaks: remove some more annoying conditional compilation
2016-12-04 12:26:33 +01:00
Benno Schulenberg
454f5cbdce
tweaks: remove a superfluous cleanup call
...
At the very beginning of do_replace(), nothing has been changed
or initialized yet, so there is nothing to refresh or clean up.
2016-12-04 11:56:13 +01:00
Benno Schulenberg
248d7be8ef
build: clean out the revision.h file, to make 'make distcheck' pass
2016-12-04 11:21:10 +01:00
Benno Schulenberg
372bd0f7dd
screen: switch the cursor back on only in the main loop
...
This fixes https://savannah.gnu.org/bugs/?49750 .
2016-12-03 18:03:11 +01:00
Benno Schulenberg
f920e0d30c
tweaks: replace some unneeded direct calls of edit_refresh()
2016-12-03 17:00:28 +01:00
Benno Schulenberg
0f3e303d1a
tweaks: get rid of some spurious textual references to edit_refresh()
2016-12-02 18:13:10 +01:00
Benno Schulenberg
c9680b8b64
input: add the shifted PageUp and PageDown keycodes produced by VTE
...
Modern VTE-based terminals now produce codes for those keys and
no longer swallow them when nano is active.
This addresses https://savannah.gnu.org/bugs/?49746 .
2016-12-01 17:34:57 +01:00
Benno Schulenberg
656563beda
screen: don't restore the previous menu after a yesno prompt
...
There is no need for that -- it just causes flicker.
This fixes https://savannah.gnu.org/bugs/?49742 .
2016-12-01 15:54:56 +01:00
Benno Schulenberg
8f95f9b1aa
tweaks: reshuffle three initializations and trim some comments
2016-12-01 15:28:59 +01:00
Benno Schulenberg
c6512a9717
screen: don't request an update of the edit window for every yesno prompt
...
Only when doing replacements does the edit window need a refresh: for
every new spotlight. So, do the update request in the latter routine.
2016-12-01 15:20:05 +01:00
David Lawrence Ramsey
b5400ffe65
general: gettextize three overlooked statusbar messages
...
This fixes https://savannah.gnu.org/bugs/?48622 .
2016-12-01 13:02:43 +01:00
Benno Schulenberg
ac41587d4e
oops: the yesno prompt for replacing does not want a visible cursor
2016-11-30 13:47:50 +01:00
Benno Schulenberg
e4b8d6fab5
tweaks: remove a bit of obscuring conditional compilation
2016-11-30 11:46:05 +01:00
Benno Schulenberg
72e8bcb027
tweaks: move a switching on of the cursor to a more logical place
2016-11-30 11:11:06 +01:00
Benno Schulenberg
7401670d58
tweaks: fix compilation when configured with --enable-tiny
2016-11-30 11:05:07 +01:00
David Lawrence Ramsey
e4d452424b
files: give feedback when restricted mode prevents overwriting a file
...
Achieve this by reusing the code that gives feedback when trying to
save a buffer while using --tempfile and the file has no name yet.
This fixes https://savannah.gnu.org/bugs/?48622 .
2016-11-29 12:08:39 +01:00
David Lawrence Ramsey
d48071b2b2
input: properly check the full escape sequences for all keys
...
Also for Delete, End, PageUp and PageDown (on some terminals)
the last byte in the sequence needs to be checked.
This fixes https://savannah.gnu.org/bugs/?49710 .
2016-11-27 20:31:12 +01:00
Benno Schulenberg
c1a484270b
rcfile: actually avoid opening directories and devices
...
Achieve this elegantly by factoring out the reading of one rcfile.
2016-11-27 18:21:04 +01:00
Benno Schulenberg
981a1d39bf
tweaks: factor out a small function
2016-11-27 17:30:53 +01:00
Benno Schulenberg
925a001658
rcfile: check the vital shortcuts just once, not for every included file
2016-11-27 16:40:54 +01:00
Benno Schulenberg
77023a749b
tweaks: remove an annoying conditional compilation of an argument
...
Also remove some unneeded prototypes, adjust some comments, and
move a constant definition to the top of the file.
2016-11-27 16:34:34 +01:00
Benno Schulenberg
1762920808
rcfile: actually don't try to open things that cannot be syntax files
2016-11-26 17:48:31 +01:00
Benno Schulenberg
281a56fb74
tweaks: reshuffle some things in a more linear manner
...
Also improve or correct some comments.
2016-11-26 17:42:27 +01:00
Benno Schulenberg
592d0d6c9a
files: trying to open a non-existent file will never succeed
...
If it would, the returned file descriptor would make nano crash,
because the corresponding stream has not been opened. And when
returning zero instead (as the code did originally), nano would
open an empty buffer, although it claims to be reading the file.
In short: I think this is a leftover of an attempted fix of
https://savannah.gnu.org/bugs/?25297 , from commit 2823c99
.
2016-11-26 17:00:41 +01:00
Benno Schulenberg
3cc561e36e
input: distinguish <Shift+Home> from <Home> on an rxvt terminal
...
That is: when --rebindkeypad is in effect -- without this option
they were already getting distinguished.
2016-11-26 12:25:36 +01:00
Benno Schulenberg
0333b87ad7
input: distinguish <Alt+Left> from <Alt+Right> on an rxvt terminal
...
Both would jump a word to the left -- now each jumps a word in the
proper direction.
2016-11-26 12:07:33 +01:00
David Lawrence Ramsey
059c8efb44
input: make Shift+Alt+Arrow work properly on rxvt and Eterm terminals
...
This fixes https://savannah.gnu.org/bugs/?49636 .
2016-11-26 11:57:39 +01:00
Benno Schulenberg
eb5968f845
startup: activate restricted mode earlier, so --help will reflect it
...
Kind-of-discovered-by: Markus Bergholz <markuman@gmail.com>
2016-11-17 18:05:09 +01:00
Benno Schulenberg
f2c72bf759
binding: always initialize some keycode variables to a standard value
...
Also when somehow key_defined() is missing.
This fixes https://savannah.gnu.org/bugs/?49614 .
Reported-by: Mike Frysinger <vapier@gentoo.org>
2016-11-17 17:32:28 +01:00
Benno Schulenberg
ed165827bc
screen: don't hide the cursor when --constantshow is used
...
(Bug was introduced yesterday, by commit a4132e2.)
2016-11-13 20:00:31 +01:00
Benno Schulenberg
65bf36baa5
rcfile: let a 'set fill' reenable hardwrapping
...
Otherwise the user can override a 'set nowrap' in /etc/nanorc only
via the command line.
This fixes https://savannah.gnu.org/bugs/?49593 reported by Shirish.
2016-11-13 19:47:15 +01:00
Benno Schulenberg
7598b77e75
screen: use the correct width to determine whether a softwrap occurred
...
This fixes the two bugs reported by Anton Minaev
in https://savannah.gnu.org/bugs/?49511 .
2016-11-13 19:20:38 +01:00
Benno Schulenberg
a4132e2e64
screen: do a refresh before changing the value of 'focusing'
...
This fixes https://savannah.gnu.org/bugs/?49530 .
2016-11-12 18:02:03 +01:00
Benno Schulenberg
33bc848c5b
binding: properly conditionalize the UTF-8 parts
...
Reported-by: Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
2016-10-29 10:19:28 +02:00
Benno Schulenberg
4c476bc872
scrolling: use a comparison that will work also in softwrap mode
...
This fixes https://savannah.gnu.org/bugs/?49467 .
2016-10-28 11:38:58 +02:00
Benno Schulenberg
9c2e270b3e
softwrap: initialize 'editwincols' early, for computing the number of wraps
...
When giving a line number on the command line, do_gotolinecolumn() needs
to know the width of the screen to be able to (roughly) place the target
line in the center of the screen.
This fixes https://savannah.gnu.org/bugs/?49462 .
2016-10-28 10:50:06 +02:00
Benno Schulenberg
0eef5610eb
files: mark a new buffer as modified after inserting command output
...
This fixes https://savannah.gnu.org/bugs/?49423 .
2016-10-27 20:05:05 +02:00
Benno Schulenberg
2a55d2b29a
tweaks: adjust some comments and reduce the scope of some variables
...
Also remove some cluttering conditional compilation.
2016-10-27 20:04:50 +02:00
Benno Schulenberg
5416b9c09d
tweaks: remove a band-aid condition that is no longer needed
...
Also, don't bother conditionalizing two booleans for the tiny version.
2016-10-27 20:00:01 +02:00
Benno Schulenberg
7287300e0d
tweaks: compile two parameters unconditionally
2016-10-27 12:24:41 +02:00
Benno Schulenberg
ffeb0f9d4b
tweaks: don't spread a statement over multiple lines unnecessarily
2016-10-27 11:41:49 +02:00
Benno Schulenberg
10c9093942
general: add the option -g/--showcursor, to match Pico
...
The nanorc option already exists, but not the corresponding one
for the command line.
2016-10-27 11:34:41 +02:00
Benno Schulenberg
b38cbfe173
startup: always initialize 'margin' and 'editwincols'
...
This fixes https://savannah.gnu.org/bugs/?49428 .
2016-10-24 17:40:06 +02:00
Benno Schulenberg
702b09c859
tweaks: elide a parameter that is always FALSE
2016-10-23 20:07:39 +02:00
Benno Schulenberg
2cd8ca4eb1
tweaks: stop compiling the whole_word_only parameter conditionally
...
This make tiny nano slightly less tiny, but makes the code more readable.
2016-10-23 20:07:30 +02:00
Benno Schulenberg
55b1403542
tweaks: adjust some whitespace and a comment
2016-10-23 17:26:19 +02:00
Benno Schulenberg
9d5ee16614
tweaks: don't bother redrawing some lines when whole screen will be redrawn
2016-10-23 17:26:19 +02:00
Benno Schulenberg
01bbf7e82f
tweaks: rename a function to better describe what it does
...
It does not update anything -- it just picks a new point from
where to start displaying the buffer. All actual updating of
the screen is done by edit_refresh() and edit_redraw() and such.
2016-10-23 17:26:19 +02:00