Commit Graph

3914 Commits (46430999d5e64aa6e091b2897a9508018e4f5b0a)

Author SHA1 Message Date
David Lawrence Ramsey b1b9770c57 tweaks: rename a variable and adjust some types in edit_scroll()
Scrolling works on rows, not on lines.  Accordingly, rename the nlines
variable to nrows.  And rows should be of the type int, not ssize_t.
2017-02-05 20:04:31 +01:00
David Lawrence Ramsey 78037831f8 tweaks: rename a variable in edit_scroll(), to make sense 2017-02-05 19:44:42 +01:00
David Lawrence Ramsey 83ff644b6a tweaks: do a comparison a bit differently in do_output() and do_deletion()
Make it clearer we're comparing the number of rows, not string lengths.
2017-02-05 12:30:09 +01:00
David Lawrence Ramsey 3e22240fd5 tweaks: rename mouse_x & mouse_y to mouse_col & mouse_row in do_mouse() 2017-02-05 12:30:09 +01:00
David Lawrence Ramsey 34e086f038 tweaks: rename a variable in edit_redraw(), to make sense 2017-02-05 12:30:09 +01:00
David Lawrence Ramsey f2ac20114e tweaks: adjust and correct some comments 2017-02-05 12:29:43 +01:00
Benno Schulenberg da5643853f replacing: start at the region's edge instead of one step before it
After the changes to the search routine, it is no longer necessary to
take one step back before starting a replacement session.

This fixes https://savannah.gnu.org/bugs/?50147.
2017-01-26 21:36:13 +01:00
Benno Schulenberg 437cb410e9 replacing: detect when the whole region has already been covered
Even when a match falls within the marked region, this does not mean
that it is a true match when already the whole file has been searched,
because then this is the second time we find this match.

This fixes https://savannah.gnu.org/bugs/?50158.
2017-01-26 21:25:15 +01:00
Benno Schulenberg 94e563232e general: stop the spell checker from crashing after the changes in search
The spell fixer does not provide a beginning line, so the search routine
should then not try to refer to any data of this line.  Also, since the
changes to the search routine there is no need any more to retreat one
step before starting to search for a misspelled word.

This fixes https://savannah.gnu.org/bugs/?50159.
2017-01-26 20:21:41 +01:00
Benno Schulenberg ef7a7c5360 replacing: ignore the first match when the user said no
When the user answered No to a replacement prompt, skip the match
at the current position, so we don't stay stuck there.

Also, when replacing in the backward direction, or the match is
of length zero, skip the match at the current position, to not
get stuck.

This fixes https://savannah.gnu.org/bugs/?50126.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>

This also fixes https://savannah.gnu.org/bugs/?50137,
and refixes https://savannah.gnu.org/bugs/?48635,
and fixes https://savannah.gnu.org/bugs/?50144.
2017-01-26 17:41:49 +01:00
Benno Schulenberg 64aa8757a8 search: make the \b and \B anchors work correctly in both directions
That is: remove the special treatment of BOW anchors, and instead make
regexes match against the whole line instead of against an artificially
shortened one, because the latter method creates ghost matches: matches
at the starting point of the search that aren't really matches when seen
in the context of the whole line.

This fixes https://savannah.gnu.org/bugs/?50030.
2017-01-26 16:24:18 +01:00
Benno Schulenberg 4ed3591703 replacing: don't go outside of the selected region
When the tail of a match falls outside of the marked region,
it is in fact not a match and should not be replaced.

This fixes https://savannah.gnu.org/bugs/?50136.
2017-01-25 11:59:50 +01:00
Benno Schulenberg 3534d8ff25 replacing: compensate cursor position only for replacements /before/ it
When a replacement happens right at where the cursor sits, the position
of the cursor should not be adjusted, because the real cursor position
is between the current character and the preceding one: the place where
the cursor is shown is in fact right /after/ the insertion point.

This fixes https://savannah.gnu.org/bugs/?50134,
and fixes https://savannah.gnu.org/bugs/?50135.
2017-01-24 19:32:27 +01:00
Benno Schulenberg a8a70f0f29 tweaks: slightly speed up the change detection for multiline matches 2017-01-22 10:17:24 +01:00
Benno Schulenberg 1d10d79860 painting: account for index maybe being zero after the preceding change 2017-01-22 10:12:27 +01:00
Benno Schulenberg 8441887ec0 painting: advance only when both start /and/ end match are zero-length 2017-01-22 10:07:48 +01:00
Benno Schulenberg 775f007348 tweaks: use a cheaper way to detect an end-of-line
There is no need to compute the line length: just avoid overstepping
the terminating NUL byte when being forced to advance the index.
2017-01-21 19:44:48 +01:00
Benno Schulenberg 414a1ecc8d tweaks: and rename another variable, to keep in style 2017-01-21 19:26:43 +01:00
Benno Schulenberg e0bdf671b8 tweaks: rename another variable, to be shorter 2017-01-21 17:53:00 +01:00
Benno Schulenberg 13fbf13b85 tweaks: rename a variable, to be more general and match one elsewhere 2017-01-21 17:38:21 +01:00
Benno Schulenberg 96f50b8d55 tweaks: adjust some comments, reshuffle a line, and use a while loop 2017-01-21 17:36:52 +01:00
Benno Schulenberg 76d83070c4 tweaks: elide a variable plus its corresponding dark logic
Just assign the 'CNONE' value upfront, instead of figuring out
at the end of the line whether anything has been assigned yet.

Also, the old logic would leave unmarked a line that contains a
start match without any terminating end match.  Not serious, but
not right.
2017-01-21 16:56:50 +01:00
Benno Schulenberg 1194a41cdb tweaks: scrap a bunch of debugging lines -- they obscure the logic 2017-01-21 16:17:43 +01:00
Benno Schulenberg 9a4a5454f2 painting: properly look for a new start match only after the end match 2017-01-21 12:30:56 +01:00
Benno Schulenberg af7201f9a0 tweaks: reshuffle three variables 2017-01-21 12:30:51 +01:00
Benno Schulenberg 2f80193d96 tweaks: reshuffle a test to a better place 2017-01-21 12:30:44 +01:00
Benno Schulenberg 23595c8376 tweaks: differentiate single-regex matches from paired-regex matches
Don't use the 'startmatch' variable when the corresponding match is
not the start of anything but is the entire match by itself.
2017-01-21 12:30:38 +01:00
Benno Schulenberg 669453506c painting: when skipping a zero-length match, skip a character, not a byte 2017-01-21 12:29:27 +01:00
Benno Schulenberg 9de376deed painting: stay within the line when skipping zero-length matches
Don't blithely overshoot the end of a line when both start regex and
end regex match an empty string.  Overshooting would let the matching
run on into uncharted country and thus ultimately cause a segfault.

This fixes https://savannah.gnu.org/bugs/?50056.
Reported-by: Elia Geretto <elia.f.geretto@gmail.com>
2017-01-20 17:03:10 +01:00
Benno Schulenberg 94907aa534 painting: do not bluntly ignore zero-length start matches -- handle them
The segmentation fault that this causes when both start and end match are
zero-length will be tackled later (https://savannah.gnu.org/bugs/?50056).

This fixes https://savannah.gnu.org/bugs/?50078.
Inspired-by: Elia Geretto <elia.f.geretto@gmail.com>
2017-01-20 14:00:14 +01:00
Benno Schulenberg 7e5524bb66 painting: do not let a match for 'end' overlap a match for 'start'
During precalculation and in step_two, we begin looking for an end
match only after the full start match, not merely one byte beyond
its starting point.  So do that too when searching backward for an
unpaired start match.

Also, index can never be zero here, because if the match was of length
zero, this piece of code will have been skipped by the preceding goto.
So we can always use REG_NOTBOL here.

(That goto is wrong, by the way: https://savannah.gnu.org/bugs/?50078,
but that will follow later.)
2017-01-20 13:17:10 +01:00
Benno Schulenberg e8c7cf2071 startup: report an error when the given line or column number is invalid
This fixes https://savannah.gnu.org/bugs/?50028.
2017-01-19 10:33:42 +01:00
Benno Schulenberg 605f031833 files: leave out the confusing "[from ./]" when prompting for a command
This fixes https://savannah.gnu.org/bugs/?49892.
2017-01-19 10:31:55 +01:00
Benno Schulenberg c88d7ce530 search: begin from where we are, to be able to find the first \B
A search should start at the place of the cursor, not one step beyond,
so that the non-word boundary between the current character and the next
will be found.  Starting one step beyond the current character, as was
done until now, would find the non-word boundary between the next and
the overnext character as the first one.
2017-01-17 11:33:57 +01:00
Benno Schulenberg 9f884810b6 tweaks: use a subtraction instead of a counter
And return a better value, so that less calculation is needed.
2017-01-13 19:33:32 +01:00
Benno Schulenberg 5d5666fba6 tweaks: swap two blocks of code to reduce the number of #ifdefs 2017-01-13 19:29:39 +01:00
Benno Schulenberg 980e334e37 tweaks: rearrange some code to separate softwrap and normal mode more
(Ignore the indentation for the moment.)
2017-01-13 19:17:59 +01:00
Benno Schulenberg 9bb64fccef tweaks: chuck some obscuring debugging stuff 2017-01-13 17:47:55 +01:00
David Lawrence Ramsey 6e3adf31b8 tweaks: let update_line() return the correct value on error
If the given line is out of range of editwinrows, we don't display it
at all, so we obviously don't display more than one line of it.  Thus,
the return value in this case should be zero, not one.
2017-01-13 17:41:26 +01:00
David Lawrence Ramsey c67c431239 tweaks: improve comments and formatting in update_line() 2017-01-13 17:36:02 +01:00
Benno Schulenberg bf0268d41d tweaks: condense a comment, rename a variable, and use a while loop 2017-01-12 21:31:08 +01:00
Benno Schulenberg b7c2513f7d tweaks: rename some variables, to better distinguish rows from lines
And columns from indexes -- columns are places on the screen, while
indexes point to characters in a line in the current buffer.
2017-01-12 19:32:21 +01:00
Benno Schulenberg 892762d99c tweaks: rename some variables, to show they refer to screen rows 2017-01-12 18:03:36 +01:00
Benno Schulenberg f7d320d932 tweaks: rename a function, to show it refers to screen rows 2017-01-12 17:48:33 +01:00
Benno Schulenberg 0208ae7149 tweaks: rename a variable -- lines refers to buffer, rows to screen 2017-01-12 17:33:46 +01:00
Benno Schulenberg 26fb907aa6 screen: ehm... no, that was wrong: page_start /is/ a column position
(The mistake becomes visible when you go to the end of a very long line
of double-width characters: the $ will be shown on the right edge, even
though you're already at line's end.)

This reverts commit 16a7fd4b from yesterday.
2017-01-12 10:29:20 +01:00
Benno Schulenberg ea40765904 tweaks: rename two variables, and always pass a valid result back
What is the point of parsing a number when you're not interested in
the result?  All callers of parse_num() pass a container for it.
2017-01-11 19:24:35 +01:00
Benno Schulenberg 16a7fd4bfc screen: don't compare a character index with a column position
This addresses part of https://savannah.gnu.org/patch/?9216.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-01-11 17:22:46 +01:00
Benno Schulenberg eca6faee5b tweaks: free an option string also when it was invalid 2017-01-11 09:49:24 +01:00
Benno Schulenberg a898fa5dcc tweaks: if there is no end match, there is nothing to paint
When there is no end match after a start, it is pointless to look
for any more starts because also they will not have any end match,
so nothing will get painted -- just cut the loop short.
2017-01-09 19:14:51 +01:00
Benno Schulenberg c0aa5ad258 tweaks: miscellaneous frobbings 2017-01-09 18:25:25 +01:00
Benno Schulenberg 58c3dd6cd0 softwrap: when typing M-/, ensure the last line is fully visible 2017-01-09 15:21:15 +01:00
Benno Schulenberg 5ca765f107 tweaks: discard some conditional compilation 2017-01-09 15:09:06 +01:00
Benno Schulenberg cf75da9888 softwrap: when pasting an overlong line, ensure it is fully visible
This fixes https://savannah.gnu.org/bugs/?50009.
2017-01-09 15:00:29 +01:00
Benno Schulenberg f6fbc1572d tweaks: adjust whitespace after the previous change 2017-01-09 12:01:27 +01:00
Benno Schulenberg 38d7362f20 tweaks: rename two variables to be just one as they play the same role
The renamed variable 'index' is not the start of a match (as some comment
mistakenly said), but from where in the line we start looking for a next
match.

Also, use one more goto to allow unindenting a big piece of code, and
shortcircuit two while loops for two more small unindents.
2017-01-09 11:39:37 +01:00
Benno Schulenberg 26683a9e5f tweaks: frob some comments, and transform one variable 2017-01-08 21:31:49 +01:00
David Lawrence Ramsey d35ecd02b8 weeding: remove another unnecessary setting of openfile->current_y
The setting of current_y in copy_from_filestruct() also appears to be
a holdover from the days of a more-common STATIONARY scrolling mode.

do_cut_text() uses the above function when copying text (uncutting
text again right after cutting it).  Since the text is effectively
the same afterward, current_y doesn't need to change.

do_uncut_text(), however, does need current_y up to date in one case:
when uncutting a full screen or less' worth of lines, focusing will be
FALSE, and it uses edit_refresh(), so it will use STATIONARY scrolling
mode then.  Take a cue from do_insertfile() and call reset_cursor() to
get an updated current_y.

(Note that the check for a full screen or less' worth of lines uses
incorrect values when in softwrap mode, but that's a separate problem.)

undo_cut(), do_redo(), and backup_lines() do not need set current_y
because they all result in edit_refresh() with focusing = TRUE, so
they do a CENTERING scroll which does not need current_y.
2017-01-08 17:18:28 +01:00
Benno Schulenberg 61bc248555 tweaks: chuck a couple of useless asserts 2017-01-08 15:27:48 +01:00
David Lawrence Ramsey c38f571d4b tweaks: line numbers are ssize_t, not int 2017-01-08 15:13:11 +01:00
Benno Schulenberg a89437219d tweaks: don't use a variable for two different purposes
At first paintlen was computed as a column span, and then converted
to a character count...  Confusing.
2017-01-08 13:34:10 +01:00
Benno Schulenberg aa28441071 tweaks: the starting point for painting /cannot/ be offscreen
The top_x variable has already been forced to become equal to from_x
if it was before it.  So start_col will be at least zero.
2017-01-08 13:34:04 +01:00
Benno Schulenberg 5dbd288254 tweaks: rename another variable, to show it refers to columns not chars 2017-01-08 13:12:40 +01:00
Benno Schulenberg 8f21d256fb tweaks: rename two variables, for distinguishing characters from columns 2017-01-08 13:12:36 +01:00
Benno Schulenberg 08cfdbcbdb tweaks: don't compare a character offset with a column position
It is the misuse of "x_" to mean a column position on screen, and the
misuse of "_col" to mean a character position in a string that causes
this confusion.
2017-01-08 13:12:11 +01:00
Benno Schulenberg 6103c47f1c tweaks: rename three painting variables, to be more distinct
All these different "start"s and "end"s are confusing.  Use instead
'from_x and 'till_x' to remember which part of the current line is
visible now on screen and is thus represented in 'converted'.
2017-01-08 11:35:07 +01:00
Benno Schulenberg 88cf22f804 tweaks: rearrange and reindent some lines in the painting routines
Also adjust a few comments.
2017-01-08 11:33:57 +01:00
Benno Schulenberg 8177e62c18 screen: examine the whole line when painting, to set the correct info
In order to determine the correct multidata for a line that doesn't
have such data yet, the whole line must be examined, not just the
part that fits within the screen width.

This fixes https://savannah.gnu.org/bugs/?49978.
2017-01-08 11:33:57 +01:00
Benno Schulenberg 322120c980 undo: properly create separate items for deletes at different positions
That is: only extend the current Del or Backspace undo item when the
cursor is still (or again) at the same spot.

This fixes https://savannah.gnu.org/bugs/?50006.
2017-01-08 11:05:52 +01:00
David Lawrence Ramsey f35c3dbd57 softwrap: ensure the current line is fully visible after inserting a file
This fixes https://savannah.gnu.org/bugs/?49994.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-01-06 14:01:47 +01:00
David Lawrence Ramsey acb394aec0 screen: properly place the cursor after inserting a file
Instead of setting openfile->current_y (and wrongly so), just call
reset_cursor() to recompute current_y and place the cursor on that
line (if it is not offscreen).
2017-01-06 14:00:37 +01:00
Benno Schulenberg 4223b83f75 tweaks: condense two ifs to a single one 2017-01-06 10:57:53 +01:00
Benno Schulenberg 4a1302ef55 tweaks: rename two variables, to be more telling 2017-01-05 22:47:01 +01:00
Benno Schulenberg cbf7e57ed0 search: make a regex with a beginning-of-word anchor work correctly
The search routine begins searching right after the cursor and behaves
as if the line starts there, which means that a beginning-of-word anchor
(\< or \b) will match there also when in fact the cursor is sitting in
the middle of a word.  To prevent finding a false match, verify that
for a regex that starts with a BOW anchor the found match is actually
the start of a word.

This fixes https://savannah.gnu.org/bugs/?45630.
2017-01-05 22:38:10 +01:00
Benno Schulenberg e36e829ad0 tweaks: set the length of a search match in a clearer manner 2017-01-05 21:25:30 +01:00
Benno Schulenberg 8d692a87dc softwrap: don't scroll half a page when just a few lines will do
This fixes https://savannah.gnu.org/bugs/?49824.
2017-01-03 15:26:05 +01:00
Benno Schulenberg 13176792f0 tweaks: frob some comments, elide a variable, and use 'while' loops 2017-01-03 15:05:42 +01:00
David Lawrence Ramsey d7fbc70a72 tweaks: avoid an unnecessary fiddling with current_y in do_mouse()
Since do_mouse() uses edit_redraw(), openfile->current_y will be
immediately recalculated, so there's no point in changing it now.
Use a temporary variable instead.
2017-01-03 14:44:53 +01:00
David Lawrence Ramsey 1dd01eb4e1 tweaks: move a setting, fix a type, and rearrange a line in do_mouse()
The value of sameline doesn't change, so it can be initialized to that.

Since i holds openfile->current_y, it should be ssize_t, not size_t.

And it's better to do the most significant part of a calculation first.
2017-01-03 14:23:40 +01:00
Benno Schulenberg fd0589d8bc tweaks: remove the cluttering conditional compilation of a parameter
The conditionalizing saved negligible amounts of space, of memory, and
of speed.
2017-01-03 14:11:45 +01:00
Benno Schulenberg a381021ffc tweaks: when allow_tabs is FALSE, allow_files is irrelevant
In that case setting the latter to TRUE is misleading.  So don't do that.
2017-01-03 14:02:52 +01:00
Benno Schulenberg 0b0ddb1e5f tweaks: rename a variable, chuck an assert, and frob a comment 2017-01-03 14:01:35 +01:00
David Lawrence Ramsey b1c20629f5 weeding: remove unnecessary settings of openfile->current_y
Many of the adjustments of the value of openfile->current_y appear to be
a holdover from the days when certain functions had to account for what
is now called STATIONARY scrolling mode, which depends on the value of
current_y.  Remove these adjustement where they are superfluous.

do_para_begin(), do_para_end(), and do_bracket_match() update the screen
through edit_redraw(), which uses either CENTERING or FLOWING scrolling
mode, so their setting of current_y is redundant and useless, as it will
be ignored and then overridden by the next call to reset_cursor().

findnextstr() is called by go_looking() [which calls edit_redraw(), see
above], and by do_replace_loop() and do_int_spell_fix(), which both call
edit_refresh(), which in this case only uses CENTERING scrolling mode
since focusing is TRUE.

(Additionally, the adjustments of current_y in findnextstr() and
do_bracket_match() use incorrect values when in softwrap mode.)

find_paragraph() doesn't need to save or restore current_y, because it
doesn't do any screen updates.  do_justify() calls edit_refresh() with
focusing set to TRUE, so it uses the CENTERING scrolling mode.

do_alt_speller() and do_formatter() do not need to save and restore
current_y, because they don't modify it in any way.

This addresses https://savannah.gnu.org/patch/?9197.
2017-01-02 12:40:21 +01:00
Benno Schulenberg 7373e4cd46 tweaks: fix compilation when configured with --disable-wrapping 2017-01-01 16:33:40 +01:00
Benno Schulenberg 5f30775d62 inserting: adjust the desired x position (don't restore the old one)
This makes nano's cursor behavior consistent across 1) typing text by
hand; 2) pasting in text with ^U; 3) inserting text from a file; and
4) redoing with M-E that same typing or pasting or inserting.

This fixes https://savannah.gnu.org/bugs/?49968.
2017-01-01 15:32:25 +01:00
Benno Schulenberg 69bd4d1f06 tweaks: slightly condense a function and its comment 2017-01-01 15:06:39 +01:00
Benno Schulenberg d3429a7a57 copy: properly set preferred x position when region was marked backwards
This fixes https://savannah.gnu.org/bugs/?49964.
2016-12-31 16:36:14 +01:00
Benno Schulenberg e1538e6dc3 tweaks: reshuffle a statement to a better place and condense some comments 2016-12-31 13:55:52 +01:00
Benno Schulenberg 1c46551ce8 cut: indicate a buffer as modified only if actually something was deleted
This fixes https://savannah.gnu.org/bugs/?49962.
2016-12-31 13:10:06 +01:00
Felix Janda fc89ac11d2 speller: fix build when tiny build is enabled
URL: https://bugs.gentoo.org/604000
2016-12-29 13:43:06 -05:00
Benno Schulenberg 32719d64a1 locking: disable an annoying warning
The warning is wrong when the user has just saved a buffer under a
new name.  And when --quickblank is used, the warning most likely
gets cleared off before it is seen, and the user would just hear
the beep and be left wondering what happened.

This avoids https://savannah.gnu.org/bugs/?49875.
2016-12-28 12:04:55 +01:00
Benno Schulenberg 908663e8fc input: discard a verbatim 0x0A or 0x00 byte, depending on the mode
This disallows entering a verbatim ^J (0x0A) when typing text or
search terms, and disallows a verbatim ^@ (0x00) when typing a
filename.  Nano beeps when the disallowed code is attempted.

This addresses https://savannah.gnu.org/bugs/?49897.
2016-12-27 16:46:09 +01:00
Benno Schulenberg 1fb820386b tweaks: chuck a special case, and reduce the scope of two variables
A KEY_WINCH does not need to be separately treated since the basic
action for anything that is not recognized at the yes-no prompt is:
to continue.
2016-12-26 20:25:06 +01:00
Benno Schulenberg 9973366685 prompt: represent newlines as ^J instead of breaking the bar
Also at the yes-no prompt, a 0x0A byte should be displayed as a ^J
instead of splitting the prompt bar in two and spreading it over
two lines.

This fixes https://savannah.gnu.org/bugs/?49934.
2016-12-26 19:59:51 +01:00
Benno Schulenberg e72db0e350 files: show newlines in filenames as ^J also in error messages
When a given file is, for example, unreadable or unwritable, the
error message should use ^J instead of ^@ in its name.
2016-12-26 12:35:50 +01:00
Benno Schulenberg 87b2df6dea utils: go on to parse the line number even if the column number is bad
This fixes https://savannah.gnu.org/bugs/?49933.
2016-12-26 11:45:38 +01:00
Benno Schulenberg c24caf5fb8 tweaks: rename four variables, for density and aptness 2016-12-26 11:01:40 +01:00
Benno Schulenberg 8db21b68d5 tweaks: use memory on the stack instead of calling malloc() and free() 2016-12-26 10:39:48 +01:00
Benno Schulenberg cb31e45f6c tweaks: remove pointless or obscuring asserts 2016-12-26 10:29:57 +01:00
Benno Schulenberg 588daf949e tweaks: condense the setting of three flags 2016-12-25 13:11:17 +01:00
Benno Schulenberg d21a9c8fc3 text: discard the undo stack after formatting and after spell checking
After a call to the Formatter or the Alternate spell checker, the data
on the undo stack could refer to line positions that don't exist any
more -- the chance is small, but it is there.  So... throw the whole
undo stack away, to prevent undoing things wrongly or even crashing.

(Changes made with the internal spell checker can be undone and redone
without a problem -- nano keeps full track of those.  But the changes
made with a formatter or an external spell checker happen in another
process, so nano has no record of them.)

This fixes https://savannah.gnu.org/bugs/?49920.
2016-12-24 12:22:50 +01:00
Benno Schulenberg edbc1e5950 text: avoid a crash when a spell-checked line has gotten shorter
When using an external spell checker or formatter, the line with
the cursor might become shorter, which might result in the stored
cursor position being beyond the end-of-line.  So, when restoring
the x position, make sure to limit it to the length of the line.

This fixes https://savannah.gnu.org/bugs/?49923.
2016-12-24 12:22:17 +01:00
Benno Schulenberg dc18746cbd tweaks: retype, rename, and reshuffle a function 2016-12-23 13:51:58 +01:00
Benno Schulenberg c92b9be6cd tweaks: rename three variables, to be more fitting 2016-12-23 13:01:15 +01:00
Benno Schulenberg eef7d1047a screen: display byte value 0x0A in the right places as ^@ or as ^J
In path names and file names, 0x0A means an embedded newline and
should be shown as ^J, but in anything related to the file's data,
0x0A is an encoded NUL and should be displayed as ^@.

So... switch mode at the two main entry points into the "file system"
(reading in a file, and writing out a file), and also when drawing the
titlebar.  Switch back to the default mode in the main loop.

This fixes https://savannah.gnu.org/bugs/?49893.
2016-12-23 11:00:55 +01:00
Benno Schulenberg d49d4f7b56 history: search items *can* contain newlines -- encoded NUL bytes
Decode 0x0A bytes to 0x00 when saving the search history, and encode
them again when reading the file back in, to prevent nano from hanging
or aborting when encountering 0x00 on a line by itself.
2016-12-23 10:54:09 +01:00
Benno Schulenberg 66356ec7e2 screen: draw new content immediately, to prevent color flashes
After updating the color palette, the corresponding new window content
should be drawn immediately, before some other part of the code calls
doupdate(), to prevent the old content being shown in the new colors.

This fixes https://savannah.gnu.org/bugs/?49912.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2016-12-23 09:25:29 +01:00
Benno Schulenberg 4edc83c3c2 tweaks: move a setting to a better place -- it needs setting just once 2016-12-22 17:08:10 +01:00
Benno Schulenberg e6350aaba4 prompt: do not treat a leading newline in a filename specially
This fixes https://savannah.gnu.org/bugs/?49884.
2016-12-22 13:46:53 +01:00
Benno Schulenberg 8bf8682b17 binding: use the code for the Enter directly instead of a function call
And certainly don't return zero when the key wouldn't have been found,
because that would have meant jumping a word to the right.
2016-12-22 12:13:03 +01:00
Benno Schulenberg a9b5a0e029 tweaks: rename a function to something less abbrevy
Also, swap the logic around, to use less braces.
2016-12-22 12:04:10 +01:00
Benno Schulenberg 026393a91a binding: use plain codes instead of function calls for the jumping keys
Which is possible because those keycodes are hard-bound to the relevant
functions.
2016-12-22 11:50:24 +01:00
Benno Schulenberg db897b574f input: detect again when both Shift and Ctrl are being held on a VT
In nano 2.7.1 and 2.7.2, pressing Shift+Ctrl+Arrow on a Linux console
would behave as if Shift wasn't held.  It got broken three months ago,
by commit 08cd197b, messing up the proper order of the checks.

This fixes https://savannah.gnu.org/bugs/?49906.
2016-12-22 11:13:39 +01:00
Benno Schulenberg 2b1bc6866a input: don't crash when receiving a KEY_CANCEL
On some systems, typing ^C apparently results in a KEY_CANCEL in
the input stream, which gets hard-bound to the do_cancel function.
But in the main menu there is no Cancel function.  So... in that
case, let it fall back to the plain old Ctrl-C code: 0x03.

Reported-by: Liam Gretton <liam.gretton@leicester.ac.uk>
2016-12-21 17:42:15 +01:00
Benno Schulenberg 90b959a677 history: avoid crashing when the positionlog file is malformed 2016-12-21 17:28:09 +01:00
Benno Schulenberg 116d9e6f01 chars: use memory on the stack instead of calling malloc() and free() 2016-12-20 10:05:09 +01:00
Benno Schulenberg 6620acbff4 tweaks: use a faster comparison 2016-12-20 10:03:53 +01:00
Benno Schulenberg 1cb6619d6a undo: there are just two forms of deletion: backspacing and deleting
A third method does not exist.
2016-12-19 21:18:43 +01:00
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
Benno Schulenberg ae648778e2 screen: refresh when a new magicline is added in line-numbering mode
This fixes https://savannah.gnu.org/bugs/?49406.
2016-10-21 15:59:16 +02:00
Benno Schulenberg 023edffe3d screen: move the margin determination to the main loop
There is no need to look at this for every painted line, because
the margin can only change when some key is struck.
2016-10-21 14:56:56 +02:00
Benno Schulenberg 2789bb0813 screen: repaint the edit window in a single place -- the main loop
Instead of doing this in two places: after interpreting shortcuts,
and after injecting characters.
2016-10-21 14:56:53 +02:00
Benno Schulenberg 4d996e4c39 screen: suppress line numbers when the terminal is very narrow
To prevent the display from getting messed up, making nano unusable.
2016-10-21 14:55:43 +02:00
Benno Schulenberg de2aa4f24a rcfile: add an option to customize the color of line numbers 2016-10-20 16:48:45 +02:00
Faissal Bensefia de95ca68f7 new feature: the ability to show line numbers before the text
It can be activated with --linenumbers on the command line or with
'set linenumbers' in a nanorc file, and it can be toggled with M-#.

Signed-off-by: Faissal Bensefia <faissaloo@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-10-20 16:47:52 +02:00
Benno Schulenberg 55878efe5d binding: supply the keycode for most special keys directly
Instead of figuring them out from the string.  This is possible
because those dedicated editing keys cannot be rebound anyway.
2016-10-18 20:38:27 +02:00
Benno Schulenberg 43f35fc7a9 softwrap: ensure the current line is fully visible when moving in it
This fixes https://savannah.gnu.org/bugs/?49099,
and fixes the unreported corresponding bugs for
<End> and <Del> and typing extra characters.
2016-10-18 15:07:47 +02:00
Benno Schulenberg d66ea08473 moving: adjust the Y position to correspond with the changed X position
So the softwrap code in do_down() can compute the correct amount to scroll.

This fixes https://savannah.gnu.org/bugs/?49374.
2016-10-18 11:46:15 +02:00
Benno Schulenberg 8476bf86a1 tweaks: fix compilation when configured with --enable-tiny 2016-10-15 18:05:01 +02:00
Benno Schulenberg c92982d60f binding: fix some duplicated carets and too restrictive menus 2016-10-15 17:18:51 +02:00
Benno Schulenberg 7a274d621a binding: use arrows instead of words to designate the cursor keys 2016-10-15 17:04:01 +02:00
Benno Schulenberg fdee0df849 input: keep the Ctrl+Arrow keys working when their synonyms are unbound
This fixes https://savannah.gnu.org/bugs/?49058 reported by Rishabh Dave.
2016-10-15 17:03:10 +02:00
Benno Schulenberg 7013039c3a tweaks: rename a variable, for consistency 2016-10-12 21:10:04 +02:00
Benno Schulenberg 925ad6393a tweaks: remove a superfluous setting, and add a comment 2016-10-12 21:07:16 +02:00
Benno Schulenberg 3264d0c5be tweaks: move a variable that doesn't need to be global 2016-10-12 19:59:26 +02:00
Benno Schulenberg d9148e7b3f tweaks: elide an unneeded variable 2016-10-12 19:20:39 +02:00
Benno Schulenberg 0a18d8912b screen: defeat a VTE bug by doing an extra cursor move and update
This fixes https://savannah.gnu.org/bugs/?49106.
2016-10-12 13:56:48 +02:00
Rishabh Dave 01bf034bb6 rcfile: reject rebindings that have no effect or have side effects
Also, show in green only the ^ and M- combinations that are valid.

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

Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-10-11 19:46:18 +02:00
Benno Schulenberg d716809228 scrolling: don't put the last line at the bottom when softwrap in on
This avoids https://savannah.gnu.org/bugs/?49298.
2016-10-10 13:19:51 +02:00
Benno Schulenberg 8041627cc3 tweaks: remove a bit of duplication 2016-09-20 12:54:16 +02:00
Benno Schulenberg 598e0af7af softwrap: scroll the current line fully into view when jumping words
This fixes https://savannah.gnu.org/bugs/?47710
and fixes https://savannah.gnu.org/bugs/?49088.
2016-09-20 12:29:10 +02:00
Benno Schulenberg 8ba57cf87b input: don't return zero when some function is completely unbound
Returning a zero would mean returning a ^Space -- the keycode that
by default is bound to the Next-Word function.  So, unbinding the
keys to which the modified Arrow keys are hard bound would cause
the latter ones to mysteriously jump to the next word.

This partially fixes https://savannah.gnu.org/bugs/?49058.
2016-09-20 11:11:44 +02:00
Rishabh Dave e2027aee15 rcfile: reject key names that are wrong or too long
Meta keys should have a dash as second character, and apart from ^Space
and M-Space key names should be at most two or three characters long.

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

Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
2016-09-14 19:53:38 +02:00
Benno Schulenberg 97f6ae5267 softwrap: scroll 'enough' whenever it surpasses 'amount'
This fixes https://savannah.gnu.org/bugs/?49086.
2016-09-14 12:40:58 +02:00
Benno Schulenberg fc9c7b4917 softwrap: scroll when searching lands on an overlong bottom line
This fixes https://savannah.gnu.org/bugs/index.php?42189.
2016-09-14 11:02:36 +02:00
Benno Schulenberg 77a1a5c3e4 tweaks: reshuffle some ifdefs, for less fragmentation 2016-09-14 11:00:18 +02:00
Benno Schulenberg bc8bb7e942 screen: keep the help items nicely lined up also in the tiny version 2016-09-13 09:29:44 +02:00
Benno Schulenberg 08cd197bf1 general: include word-jumping and block-jumping into the tiny version
And also case-sensitive searches, backward searches, and searching again.
2016-09-13 09:27:04 +02:00
Benno Schulenberg 4de0a5049b tweaks: reshuffle an if statement 2016-09-11 21:43:47 +02:00
Benno Schulenberg dc76e84657 files: alert about an unwritable file also in the tiny version 2016-09-11 21:40:50 +02:00
Benno Schulenberg 1c2b35675e tweaks: adjust some indentation 2016-09-11 21:36:46 +02:00