Commit Graph

3965 Commits (28beb3f9c592792c6fb7bd5c24754c857288250a)

Author SHA1 Message Date
David Lawrence Ramsey 812ecaeb0c weeding: remove maxlines and related code
Since all lines can be partially scrolled off the screen now
(except for edittop, which is forthcoming), the maxlines global
variable and its computation mechanism are no longer needed.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey d0c3084eb5 softwrap: improve PageUp and PageDown's behavior with softwrapped chunks
Use go_back_chunks() and go_forward_chunks() to move a screenful of
lines or chunks up or down, instead of using special computations in
the softwrap case.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey eb647dfb44 softwrap: improve Up and Down's behavior with softwrapped chunks
Use go_back_chunks() and go_forward_chunks() in do_up() and do_down()
(instead of using a special and complicated computation in do_down())
so that they now properly move vertically to the previous/next chunk
in softwrap mode.  This also means that do_left() and do_right() will
now properly move vertically at actual line boundaries.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey 56402e7589 softwrap: improve Left and Right's behavior with softwrapped chunks
Use the new "unclever" functionality of Home and End to make do_left()
and do_right() move properly to the end of the previous chunk or to the
start of the next chunk in softwrap mode when crossing a line boundary.
(Furthermore, doing Up plus End, or Down plus Home, does all needed
screen updates, which simplifies the code.)

The do_left() and do_right() functions don't yet properly move vertically
at line boundaries, but that will be fixed once do_up() and do_down() are
updated for softwrap mode, which is forthcoming.

This fixes https://savannah.gnu.org/bugs/?49384.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey a5e106d764 tweaks: add a parameter to do_home() and do_end()
Add the parameter be_clever to both functions.  When be_clever is FALSE,
smart home and dynamic home are disabled in do_home(), and dynamic end is
disabled in do_end(), so that these functions only move to the beginning
or end of the current line or chunk.

This simple home and end functionality is needed to improve do_left()
and do_right()'s horizontal behavior with softwrapped chunks, which is
forthcoming.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey e478682c55 softwrap: improve End's behavior with softwrapped chunks
Make do_end() more useful in softwrap mode: let it move to the end of the
current chunk instead of the end of the line; only when already at the end
of a chunk, let it move to the end of the line.  This is "dynamic end".
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey bd2d0863d6 softwrap: improve Home's behavior with softwrapped lines
Make do_home() more useful in softwrap mode: let it move to the beginning
of the current chunk instead of to the beginning of the whole line; only
when already at the beginning of a chunk, let it move to the beginning of
the line.  This is called "dynamic home'.

The above rules are ignored when --smarthome is in effect and the cursor
is somewhere in the leading whitespace of a line -- then the cursor is
moved to the first non-whitespace character of the line.
2017-03-22 10:44:05 +01:00
David Lawrence Ramsey d8189703b1 tweaks: prepare for improvements to do_home() and do_end()
These improvements will eventually make do_home() and do_end() take
parameters.  Since the global function lists can hold only functions
without parameters, preemptively add do_home_void() and do_end_void(),
and make the global function lists use them.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 52087408ef softwrap: iterate through softwrapped chunks better in do_mouse()
Use go_back_chunks() and go_forward_chunks() to move from the row
current_y is on to the row mouse_row is on.  Now softwrap mode and
non-softwrap mode will behave the same way when we can scroll edittop
partially off the screen, which is forthcoming.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.

The old code did work, but it behaved differently between softwrap mode
(which counted down from edittop) and non-softwrap mode (which counted
up or down from current_y to take less time, and used a double loop to
keep current from going to NULL).

The new code counts up or down from current_y in both softwrap mode and
non-softwrap mode.  In non-softwrap mode, it also avoids the double loop,
since go_back_chunks() and go_forward_chunks() keep the filestructs they
operate on from going to NULL.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 2abf7b755b softwrap: iterate through softwrapped chunks in adjust_viewport()
Use go_back_chunks() to adjust edittop, instead of special casing
the computation of goal when softwrapping.  Now softwrap mode and
non-softwrap mode will behave the same way when edittop can be
partially scrolled off the screen, which is forthcoming.

(Note that the top line of the screen can't be partially scrolled
yet, so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey ba4858de83 softwrap: iterate through softwrapped chunks in edit_scroll()
Use go_back_chunks() and go_forward_chunks() to adjust edittop and to
move up or down to the scrolled region before updating the rows there.
Now softwrap mode and non-softwrap mode will behave the same way when
we can scroll the top line of the screen partially off the screen,
which is forthcoming.

(Note that the top line of the screen can't be partially scrolled yet,
so we have to work around that for now.)
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey fa025f0ca3 display: limit an optimization to non-softwrap mode
Not drawing a line on a row if we're on the top row and scrolled down,
or if we're on the bottom row and scrolled up, will only work properly
if the line on that row takes up only that row.  The latter might not
be the case in softwrap mode: if the line occupies multiple chunks and
begins on that row -- in that case none of the chunks would be drawn.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey eb369c0e00 tweaks: rename need_horizontal_scroll() to line_needs_update()
The old name made it sound as if it didn't apply in softwrap mode.  But
it does: in softwrap mode a line needs updating  when the mark is on.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey df2a4679d5 softwrap: account for softwrap in get_page_start()
In softwrap mode, nano doesn't horizontally scroll lines at all, so in
this case get_page_start() should always return zero.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 380ad30a53 softwrap: account for softwrap when checking whether current is offscreen
Add the new functions current_is_above_screen() (which doesn't account
for softwrapped chunks yet, but will when we can scroll edittop partially
off the screen, which is forthcoming), current_is_below_screen() (which
determines whether current[current_x] is past the softwrapped chunk at
the bottom of the screen), and current_is_offscreen() (the union of the
previous two functions).

edit_redraw() and edit_refresh() now use current_is_offscreen() to check
whether they should adjust the viewport, and adjust_viewport() now uses
current_is_above_screen() to determine whether current is on or below
the screen in FLOWING mode.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey fd82989e29 softwrap: count softwrapped chunks properly in read_file()
Use less_than_a_screenful() again, just as in do_uncut_text().
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 4f9c563e6b softwrap: count softwrapped chunks properly in do_uncut_text()
Add the new function less_than_a_screenful() to accomplish this.
It uses go_back_chunks() to count the number of softwrapped chunks
between the end point and the starting point of the paste.

Now softwrap mode and non-softwrap mode behave the same way when
uncutting fewer than editwinrows rows of text.  Accordingly, remove
the call to ensure_line_is_visible(), as it no longer applies.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 1570651e30 softwrap: count softwrapped chunks properly in do_gotolinecolumn()
Use go_forward_chunks() to count softwrapped chunks between the current
cursor position and the bottom of the file.  Now softwrap mode and
non-softwrap mode behave the same way when moving to a line and column
non-interactively, instead of the former's always centering the screen.
2017-03-22 10:44:04 +01:00
David Lawrence Ramsey 456d66b904 softwrap: add two chunk-iterator functions
These functions, go_back_chunks() and go_forward_chunks(), take a number
of softwrapped chunks (screen rows) to move, a pointer to a buffer, and
a location (specifically, a starting column of a softwrapped chunk).  If
they move successfully, they will update the buffer pointer and location
to point to the beginning of the softwrapped chunk they moved to.

Since non-softwrap mode is effectively just a subset of softwrap mode
in which every line takes up one chunk, these functions also work in
non-softwrap mode.  In this case, their starting column will always be
zero, as it would be in softwrap mode on a line that takes up one chunk.

Nothing uses these functions yet, but that is forthcoming.
2017-03-22 10:44:04 +01:00
Benno Schulenberg 9b336a9d66 bindings: group the three search-again shortcuts together 2017-03-20 15:59:41 +01:00
Benno Schulenberg d42f71a2ef tweaks: avoid a few needless reallocations
Most of these variables are freed moments later -- reallocating
them is thus a waste of time.
2017-03-20 13:07:57 +01:00
Benno Schulenberg f48e15f2a3 tweaks: rename and shorten a small helper function 2017-03-20 12:24:42 +01:00
Benno Schulenberg 6d873d3760 startup: add option 'nopauses' to disable pausing after a warning
This addresses a followup of https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-03-16 19:26:39 +01:00
Benno Schulenberg 5283acdcf3 tweaks: trim a displayable string in a more efficient manner
Instead of redetermining the entire span of the converted string,
simply move one character left, and then bite it off to make place
for the trailing $.
2017-03-14 21:20:50 +01:00
Benno Schulenberg 69784d51db screen: don't push the longer-line indicator ($) to the next row
If the last two columns of a row would be taken up by a double-width
character (and the line is longer than that), don't print it, because
it wouldn't leave any room for the $ character.

This fixes https://savannah.gnu.org/bugs/?50491.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-03-08 21:24:13 +01:00
David Lawrence Ramsey 3c3eb4909d usage: mention the -g/--showcursor option
It's already in the external documentation; it should be here as well.
2017-03-06 21:09:59 +01:00
Hans-Bernhard Broeker 636b7348a6 tweaks: make sure calls to <ctype.h> functions/macros use "unsigned char"
The platform's default char type might be signed, which could cause
problems in 8-bit locales.

This addresses https://savannah.gnu.org/bugs/?50289.
Reported-by: Hans-Bernhard Broeker <HBBroeker@T-Online.de>
2017-03-06 20:58:25 +01:00
Mike Frysinger ca86045918 handle builds on systems without termios.h
Windows doesn't have this, so add some build time checks.
2017-03-06 12:02:28 +01:00
Mike Frysinger cab33779ae handle deficient signal systems
Pull in the sigaction module from gnulib, and add ifdef checks
for a bunch of signals that don't exist on Windows.
2017-03-06 12:02:25 +01:00
Mike Frysinger a8deac5845 add an explicit test for set_escdelay()
Not all curses implementations provide this function, so drop it
from depending on slang (and assuming ncurses) to a general build
time test.
2017-03-06 12:02:16 +01:00
Mike Frysinger a9a45f2b55 fix build on systems without pwd.h
Windows doesn't have *nix style account databases.
2017-03-06 12:02:09 +01:00
Mike Frysinger e7c43521fc drop the wchar.h/wctype.h/stdarg.h checks
Since gnulib provides these now, we can assume them.
2017-03-06 12:01:21 +01:00
Mike Frysinger 9a2deb4182 drop the glib fallback for snprintf/vsnprintf
The gnulib imports handle this for us now.
2017-03-06 12:01:17 +01:00
Mike Frysinger 272345ccf9 assume getopt_long support is always available
Now that we pull in the gnulib getopt-gnu module, we can assume it exists.
2017-03-06 12:01:12 +01:00
Mike Frysinger 3deec4352b assume regex.h support is always available
Now that we pull in the gnulib regex module, we can assume it exists.
2017-03-06 12:01:08 +01:00
Mike Frysinger 63cae0c199 drop the isblank/iswblank fallback functions
Switch over to gnulib for these.
2017-03-06 12:01:05 +01:00
Mike Frysinger e9a3f858bc drop the getdelim/getline fallback functions
Switch over to gnulib for these.
2017-03-06 12:01:02 +01:00
Mike Frysinger 28133e934d drop various str fallback functions
These are provided by gnulib now.
2017-03-06 12:00:57 +01:00
Mike Frysinger ba8d71f447 add support for gnulib
On a system with up-to-date GNU tools, this does not change
the size of nano's binary.

We start off with importing only a few modules, although we
don't yet delete the fallback logic for them.
2017-03-06 11:56:02 +01:00
Benno Schulenberg 83a841cd06 tweaks: chuck some debugging stuff and some useless asserts 2017-03-01 13:56:08 +01:00
Benno Schulenberg 0af5788a94 tweaks: reduce the scope of five variables, and frob some comments 2017-03-01 09:56:38 +01:00
Benno Schulenberg d5b950cc29 tweaks: don't turn the mark off before it's needed
The mark only needs to be off when calling replace_marked_buffer(),
because this indirectly calls ingraft_buffer(), which fiddles with
the end points if the mark is on.
2017-03-01 09:35:45 +01:00
Benno Schulenberg adf69a05f1 spelling: keep the cursor at end-of-line if it was there
This fixes https://savannah.gnu.org/bugs/?50415.
2017-02-28 20:45:49 +01:00
Benno Schulenberg 355a07bbce tweaks: don't optimize for the wrong case
Running strlenpt() on a string that takes up more than 80 columns
(the width of an average terminal) takes /more/ time than simply
converting an extra character (the one that will be overwritten
by the "$" at the edge of the terminal).  So... just convert one
more character than necessary when the line is overlong.  In the
most common case, however, the line will fit fully onscreen, and
we save a whole call of strlenpt().
2017-02-28 17:07:38 +01:00
David Lawrence Ramsey 0404474ec2 tweaks: stop converting text once we overshoot span columns
Since we only need span columns of the string, stop scanning the string
as soon as we have that many columns, instead of scanning the string all
the way to the end.  This speeds up the conversion of very long lines.
2017-02-28 16:50:22 +01:00
Benno Schulenberg a80ade38d7 tweaks: rename two variables, to be more distinctive 2017-02-28 15:17:03 +01:00
Benno Schulenberg 48643cbdf3 tweaks: elide a small intermediate buffer 2017-02-28 15:05:02 +01:00
Benno Schulenberg aa013aa007 tweaks: elide a variable 2017-02-28 14:53:10 +01:00
Benno Schulenberg 91910b2364 input: count a manually entered unicode as one character
This fixes https://savannah.gnu.org/bugs/?50403.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-28 14:47:45 +01:00
David Lawrence Ramsey 29681e0e9f weeding: remove partitioning and related stuff from do_justify()
Replace partitioning with calls to extract_buffer() and ingraft_buffer().

In addition to pasting the unjustified text back into the buffer at
current[current_x], ingraft_buffer() also deals with renumbering and
updating totsize, so do_justify() doesn't need to do those anymore
when unjustifying.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey 234bd9c9be speller: fix replacing marked text in the alternate spell checker
With read_file() revamped, it now uses partition_filestruct() indirectly
via ingraft_buffer(), so we can't use partition_filestruct() to replace
marked text in the alternate spell checker anymore without segfaulting.

Add the new function replace_marked_buffer() to accomplish this instead.
Based on replace_buffer(), it uses extract_buffer() to throw away the
marked un-spell-checked text, and then uses read_file() to insert the
spell-checked text at the position where the mark was.

Accordingly, remove unneeded partitioning and related stuff from
do_alt_speller().  Besides pasting the file into the buffer at
current[current_x], ingraft_buffer() also deals with renumbering,
updating totsize, and handling a magicline, so do_alt_speller()
doesn't need to do those anymore.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey 0d9313763d undo: fix undoing/redoing insertions, since they no longer do partitioning 2017-02-28 14:35:44 +01:00
David Lawrence Ramsey ef43ebfef4 weeding: remove partitioning and related stuff from do_insertfile()
With read_file() revamped to handle inserting a file at the current
position, partitioning the buffer is no longer needed.
2017-02-28 14:35:44 +01:00
David Lawrence Ramsey 86f7bc1868 files: revamp the insertion of a file, to be more like pasting text
Move buffer handling and '\r' stripping from read_line() to read_file(),
so that the file gets its format determined and gets stored in its own
buffer entirely in one function.  Then use ingraft_buffer() to insert
this new buffer into the current one.

In addition to pasting the file at current[current_x], ingraft_buffer()
also deals with renumbering, the updating of totsize, and the handling
of a magicline, so read_file() doesn't need to do those anymore.

Note that all this makes read_file() depend on the position of
current[current_x] to know where to insert the file.  Accordingly,
set current_x to zero in initialize_buffer_text() instead of in
make_new_buffer(), so that replace_buffer() keeps working properly.
2017-02-28 14:35:44 +01:00
Benno Schulenberg 3d9a4d6257 tweaks: make WhereIsNext available in browser in tiny version
Also, avoid a warning with with --enable-tiny --enable-browser.
2017-02-27 19:22:50 +01:00
Benno Schulenberg eb67af9347 tweaks: fix compilation with --enable-tiny --enable-help 2017-02-27 19:10:39 +01:00
Benno Schulenberg efdd73922e oops -- that's what you get when you don't test things before pushing
Of course 'row' needs to be initialized to zero for the softwrap case.
2017-02-26 18:29:18 +01:00
Benno Schulenberg 2e53ed2928 tweaks: use two extra variables to make it clearer what is being done
This addresses https://savannah.gnu.org/patch/?9215.
Inspired-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-26 17:33:10 +01:00
Benno Schulenberg 59e10bdef2 usage: don't mention +LINE,COLUMN as an option, because it isn't
Add its explanation as a separate paragraph.

Also: improve the argument of the --syntax option, as this is a <name>
and not merely a bundle of characters like the other <str> arguments.
2017-02-25 14:05:07 +01:00
David Lawrence Ramsey 6eefad4fff tweaks: mention nano's ability to read from standard input in usage() 2017-02-25 14:00:27 +01:00
Benno Schulenberg e5731fe198 tweaks: reshuffle three statements, and shorten a comment 2017-02-25 12:33:01 +01:00
Benno Schulenberg 2bbb6cfeb5 wrapping: add the correct char length when skipping consecutive blanks
In this last loop of break_line(), the pointer 'line' is one step ahead
of the index 'lastblank'.  So the loop should first add the length of
the preceding character to 'lastblank' before determining the length
of the current character (and using this to advance 'line').
2017-02-25 11:18:24 +01:00
Benno Schulenberg 1623bc7779 tweaks: rename three variables, to better distinguish bytes from columns
(There is something wrong in the last loop: line is one character ahead
of lastblank, but the current character length is added to both of them.
It thus assumes that all blank characters are the same number of bytes.
For spaces and tabs this works fine.  But for more exotic blanks...)
2017-02-24 22:08:55 +01:00
Benno Schulenberg 99ecd33c18 tweaks: elide two variables, and condense some statements
Also, remove an assert and adjust some comments.
2017-02-24 21:11:37 +01:00
David Lawrence Ramsey 6500f769aa tweaks: move comments outside of if blocks in break_line() 2017-02-24 21:04:31 +01:00
David Lawrence Ramsey f95836a951 tweaks: remove cluttering #ifdefs from break_line()
Also, rename a parameter to be less cryptic, and remove an entire
condition because the relevant block will never be reached when
getting called from the help routines: if blank_loc is negative,
the function will have bailed out in the preceding if.
2017-02-24 17:33:39 +01:00
Benno Schulenberg 0378146add tweaks: rename a variable, drop a false assert, and reshuffle a bit 2017-02-24 15:07:04 +01:00
David Lawrence Ramsey 6e9d6a08b9 replacing: fix spotlight() to highlight words properly in softwrap mode
In softwrap mode, the entire line is onscreen, so the word is never
partially offscreen, so we always have enough columns to show it.

This fixes https://savannah.gnu.org/bugs/?50389.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-24 15:06:44 +01:00
Benno Schulenberg 07ebba5e99 tweaks: rename a variable and invert its logic 2017-02-24 12:21:59 +01:00
Benno Schulenberg 9e6e1ebe58 tweaks: remove a disabled warning, and adjust a translator hint 2017-02-24 12:06:15 +01:00
Benno Schulenberg d365ca80bf tweaks: optimize determining the number of columns that a text spans
Give the strlenpt() routine its own implementation, so that it avoids
a needless comparison plus subtraction in the inner loop.
2017-02-24 11:01:24 +01:00
David Lawrence Ramsey f1d214c0ef tweaks: slightly optimize an allocation in display_string()
Instead of allocating enough space to convert the entire passed string,
just allocate space for converting the part that will be converted --
that is: starting from start_index.  This still allocates far too much
(if the passed string is very long and its tail part won't fit on the
screen), but it's better than before.
2017-02-24 10:52:04 +01:00
Benno Schulenberg 1d3f3a6e25 tweaks: mark a message for translation 2017-02-23 15:22:07 +01:00
Benno Schulenberg de3260cdb1 justify: reduce the character count when trimming trailing spaces
This fixes https://savannah.gnu.org/bugs/?50379.
2017-02-22 17:29:39 +01:00
Benno Schulenberg 23c3fd9bcd statusbar: display at most three consecutive alert messages
Cap the number of pauses when displaying ALERT messages, to avoid
making the user wait for ages when tens or hundreds of files were
specified on the command line.

This fixes https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-02-22 10:48:26 +01:00
Benno Schulenberg c118397a14 tweaks: update some copyright years
Reflect the significant changes in painting and regex searching
in the copyright notices.
2017-02-21 20:27:49 +01:00
David Lawrence Ramsey a847d37b24 tweaks: split the grafting code off from copy_from_buffer()
Later on we're going to need the ability to graft a buffer into the
current file buffer without making a copy of it first.
2017-02-17 21:00:34 +01:00
David Lawrence Ramsey 1cb945fe8e tweaks: rename the functions for moving to and copying from a buffer
The name "filestruct" was a mistake.  What was meant was:
buffer -- a linked list of structs that each describe a line.
2017-02-17 20:06:32 +01:00
Benno Schulenberg 330741b650 tweaks: adjust two comments, to be more accurate 2017-02-17 19:59:34 +01:00
David Lawrence Ramsey f773d715e8 tweaks: rewrap two lines and fix two typos 2017-02-17 19:55:54 +01:00
Benno Schulenberg 407f2d5bcf tweaks: move a comment and rewrap a line 2017-02-17 12:01:25 +01:00
David Lawrence Ramsey 61e8b3d542 screen: don't hide two-column characters at left edge in softwrap mode
When in softwrap mode, no "$" continuation characters are displayed,
so the code that reserves space for them should be skipped then.

This fixes https://savannah.gnu.org/bugs/?50335.
2017-02-17 11:39:37 +01:00
Benno Schulenberg de36e1c120 tweaks: rename a variable, to be more general 2017-02-16 13:27:09 +01:00
Benno Schulenberg a8c1dc1402 rcfile: don't accept empty regexes for syntax coloring
As a small service to the user, reject empty regex strings,
because an entirely empty regex simply doesn't make sense.

Inspired-by: Elia Geretto <elia.f.geretto@gmail.com>
2017-02-16 13:25:38 +01:00
Benno Schulenberg d60e7d374c spelling: correctly adjust the length of a single-line region
When the marked region covers only a single line (or a part of it),
its new endpoint is not simply the length of the last line of the
spell-checked text, but instead the old endpoint plus the /change/
in length.

This fixes https://savannah.gnu.org/bugs/?50316.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-02-16 11:52:24 +01:00
Benno Schulenberg 2358badc65 painting: properly detect a change in start/end matches
The inversion of the logic in commit a6605dce was incomplete -- oops.

This fixes https://savannah.gnu.org/bugs/?50306.
2017-02-14 16:56:43 +01:00
David Lawrence Ramsey efdb543f8c tweaks: fix compilation when configured with --enable-tiny 2017-02-13 20:41:48 +01:00
David Lawrence Ramsey c24545fe9a tweaks: always directly do a refresh when the margin changes
The previous code only directly refreshed the screen when the margin
changed due to toggling line numbering on.  When the margin changed
due to toggling it off, it would indirectly refresh via do_toggle().
2017-02-13 20:25:38 +01:00
Benno Schulenberg 8fbadecf0a tweaks: adjust whitespace after preceding changes 2017-02-13 19:47:24 +01:00
Benno Schulenberg a6605dce00 tweaks: rename two variables, to avoid double negatives 2017-02-13 19:47:20 +01:00
Benno Schulenberg 9ec546d293 tweaks: rename a function, and drop an unneeded parameter
When replacements are made, nothing needs to be reset any more
(it was done insufficiently anyway).  Just make sure the screen
is refreshed when all is done -- this may be superfluous when
doing interactive replacements, but not when replacing all.
2017-02-13 19:47:03 +01:00
Benno Schulenberg fccfcccd37 tweaks: reshuffle an assignment and trim some comments 2017-02-13 19:46:51 +01:00
Benno Schulenberg 03148804e6 tweaks: scrap some debugging stuff 2017-02-13 19:46:41 +01:00
Benno Schulenberg 3b86c7a190 tweaks: discard the now unused multidata-resetting routine 2017-02-13 12:14:58 +01:00
Benno Schulenberg 7ef5c53263 painting: mark an unpaired start match as CWOULDBE
The lines that come after an unpaired start have to know about this.

This fixes https://savannah.gnu.org/bugs/?50293.
2017-02-13 11:18:54 +01:00
Benno Schulenberg 6bd94040df painting: don't look at the current multidata when coloring a line
When coloring a line, look only at the multidata of the preceding
line, and based on that determine what to seek in the current line.

This fixes https://savannah.gnu.org/bugs/?50292.
2017-02-13 10:03:07 +01:00
Benno Schulenberg b3bcc8eeac painting: make use of the multidata of the preceding line
When painting a line, the multidata of the line /before/ it is valid
in most cases: it was determined just a moment ago.  And it tells us
all we need to know: whether there is an unpaired start match before
the current line or not.

The only exception is when painting the first line of the screen:
the multidata of the line before it might be stale.  So for the
first screen line we will always have to do some backtracking.
But that is left for later.

This fixes https://savannah.gnu.org/bugs/?50121.
2017-02-12 18:24:49 +01:00
David Lawrence Ramsey 17f5c056ca tweaks: reduce duplicate code in new_magicline() and move_to_filestruct()
These two functions unnecessarily copy make_new_node(); use that instead.
2017-02-12 10:46:50 +01:00
Benno Schulenberg 914af36546 spelling: don't unnecessarily fiddle with the viewport
If we're somewhere deep into the file and do a spell check, and the
first misspelled word happens to be right there, onscreen already,
then this word does not need to be centered -- it /should/ not be
centered.  We should scroll only when necessary.
2017-02-10 22:09:03 +01:00
Benno Schulenberg 5c3d529761 tweaks: rename a variable and condense an if 2017-02-10 14:07:42 +01:00
Benno Schulenberg 8f10e364bb replacing: stop searching in a region when edge of buffer is reached
Just like when spell-checking, there is no need to wrap around when
doing replacements in a region, because a region cannot straddle the
buffer's edges.

This is the proper fix for https://savannah.gnu.org/bugs/?50158,
and fixes https://savannah.gnu.org/bugs/?50273.
2017-02-10 13:51:51 +01:00
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