Don't make it the responsibility of the executed functions to restore
the list of shortcuts of the edit window. Just detect whether another
menu was displayed, and if so, redisplay the main menu.
By moving the test for the only situation where do_comment() does nothing
(when only the magic line is selected) further up front, the add_undo()
can be called before the commenting/uncommenting starts and two variables
and an extra function are made unnecessary.
Store the file sizes from before and after the commenting/uncommenting
in the undo struct, so they can be restored when undoing or redoing.
This fixes https://savannah.gnu.org/bugs/?48062.
Signed-off-by: Mike Scalora <mike@scalora.org>
This allows for commenting or uncommenting a line or a bunch of lines
with a single keystroke (default binding: M-3). The characters used
for commenting/uncommenting are specified by the active syntax file.
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Mike Scalora <mike@scalora.org>
If during startup there are multiple error messages, currently only the
last one remains and can be read. To improve on that, introduce a short
pause between error messages -- even if it's not enough to read them all,
at least the user will be aware that there are multiple ones.
This also causes a few error messages to beep that currently don't beep,
such as when a file is unwritable.
When fixing a misspelling and not answering 'All' (but 'Yes' or 'No'),
the chance is quite substantial that one will type y or n at the end of
the next word. Diminish this chance by showing for a moment a message
on the statusbar.
Partitioning the file makes the undo system lose track, so that undoing
things has a good chance of losing data. Instead, just make sure that
the region is marked "backwards", with current at the top and the mark
at the bottom, and then let the replace loop take care of not going
outside of the marked region.
This also has the effect that if the marked region fits entirely on the
screen, or all the misspellings are onscreen, then the screen will not
be scrolled at all. Which makes for a smooth experience.
This fixes https://savannah.gnu.org/bugs/?47836,
and fixes https://savannah.gnu.org/bugs/?45573.
Since nano-2.4.1, reading in or pasting a large piece of text would put
the cursor on the bottom line, leaving only one line of the non-read or
non-pasted text visible. This is different from the centering behavior
of Pico, and somewhat disorienting, as you can't see "where you are" any
more in relation to the file as it was.
So now center the cursor whenever the read or pasted text is larger than
the screen, but don't center it when the text fits entirely on the screen.
(The latter avoids the effect of the screen jumping unnecessarily when
inserting just a few lines while the cursor is near the bottom.)
To achieve this behavior: default to focusing, and temporarily set it to
FALSE when the focusing effect is unwanted.
This fixes https://savannah.gnu.org/bugs/?47841.
When starting to replace misspelled words, pass the actual position
of the cursor instead of the position of the first found occurrence,
so that the cursor position will be updated for changed lengths.
This fixes https://savannah.gnu.org/bugs/?47834.
When we're spell checking, we don't need a special mechanism to detect
we have come full circle: reaching the end-of-buffer means we're done.
So don't bother to reset came_full_circle when we're spell checking
(when begin == NULL) but simply ignore its value.
For a little contrast with the function edit_refresh() -- it's
annoying that when you search for the latter you get to see all
the settings of the flag too.
Instead of saving the current value of placewewant, then setting the
new value, and then passing the old value to edit_redraw() in seven
different places, just let edit_redraw() do this saving and setting.
In the bargain placewewant is now only recalculated when it matters
-- when allow_update is TRUE -- and not when it's superfluous.
In the innermost search loop, don't set placewewant, because this loop
is also used for replacing and spell fixing, when we don't really want
to be there: we are just passing through. Not setting placewewant means
we don't need to save and restore it in those passing-through routines.
The value of placewewant is only relevant when doing cursor movement,
which doesn't happen during replacing nor spell checking, so there is
no need to keep placewewant up to date -- it is set when it matters:
at the end of go_looking().
Add a third mode of scrolling, FLOWING, besides CENTERING and STATIONARY.
This is used for word and paragraph jumping (and for bracket matching,
but that worked correctly already), and only when focusing is FALSE.
The new mode prevents the screen from scrolling too many lines when
there are several blank lines at the bottom of the edit window and
the next word or paragraph is out of view.
This fixes https://savannah.gnu.org/bugs/?47194.
When finding a misspelled word, the length of the match is simply the
length of that word, and its span in columns is simply the number of
columns that it occupies. Compute it thus directly.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
When searching for a misspelled word takes a while, and the user
stops this search with ^C, then abort the spelling-checking session.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
that is taking too long. This fixes Savannah bug #47439.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5776 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
invalid escape sequence, and when entering a verbatim keystroke.
But leaving the cursor off during Unicode input, for extra feedback.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5771 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
deletion of words like the pressing of Backspace/Delete, so they don't
overwrite the lines you cut elsewhere and want to paste into the place
of the cut words.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5751 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
And not minding when the column number is zero or negative.
This partially fixes Savannah bug #47131.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5669 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* Add ability to kill the trailing spaces when justifying
code. New nanorc option kill_spaces_on_wrap, we'll see
whether this warrants a command line flahg or not.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5664 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
needed), so that it no longer shows in the help screen nor in the file list.
This fixes Savannah bug #47126.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5640 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
error messages upon reentry. And, if there are any messages,
allowing the user a little time to read them.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5632 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This fixes Savannah bug #46904 reported by Mike Frysinger.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5567 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
needed, before doing a redraw of the current line.
This fixes Savannah bug #46794
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5523 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
four different places. It is not a problem that the history routines
also use these functions, as history nodes will never equal filebot.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5491 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
when trying to undo edits after an indentation change.
This works around Savannah bug #46591.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5474 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
making mistakes) when trying to undo edits after a justification.
This works around Savannah bug #45531.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5473 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
directly on the statusbar instead of as an undid or redid message.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5442 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This now mirrors unlink_opennode() and delete_opennode().
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5433 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
because the latter behaves differently depending on the setting of autoindent.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5400 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
more symmetrical: wrapped in add_undo() + update_undo() where needed.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5390 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
last action. Necessary for when typing text is broken by an undo+redo.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5379 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
'u->mark_begin_lineno' is being used as the length of the insertion.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5375 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
from the cursor to the preceding or succeeding word start.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5334 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
two superfluous checks for the definition of a formatter.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5325 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Removing an unneeded condition -- 'added_magicline' can only be
true when NO_NEWLINES isn't.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5297 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
at the end-of-file; just adding a token undo item to be able to put the
cursor back at the very tail of the file.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5285 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
backspacing at the tail of the file no longer has any efffect.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5263 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
happens but only when checking for keyboard input. It now reports the
SIGWINCH via a special key value to the calling routine, to allow not
only the main editor but also the help viewer and the file browser to
adapt their display to the new size.
Patch by Mahyar Abbaspour, somewhat edited by Benno.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5228 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Adding a new function to glue together the invocation-error string.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5199 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
for any change in length of the region's last line.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5169 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
to fix compilation with --disable-speller.
This fixes Savannah bug #44607.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5168 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* src/text.c (do_alt_speller): timestamp can just be a __time_t.
Fixes compilation on win32.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5153 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* New formatter code to support syntaxes like
go which have tools to automatically lint and reformat the text for
you (gofmt), which is lovely. rcfile option formatter, function
text.c:do_formatter() and some other calls.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5100 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
undoing a cut or paste. And fixing two memory leaks.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5067 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
text additions that caused automatic line breaks.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5064 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
(that is, when CUT_TO_END is set) properly.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5054 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
having them declared everywhere and passing them around endlessly.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5039 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
when undoing line deletions at file's end.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5033 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
and removing an unneeded iteration of cutbottom.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5008 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
make sure openfile->filebot is updated.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5007 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
make sure openfile->filebot is updated.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5006 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
where the cut started, and not at the bottom of the file.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5005 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
where it was when the cut was made.
Patch by Mark Majeres, edited by Benno Schulenberg.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4966 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
If wished, the user can unbind them. This fixes Savannah bug #42456.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4964 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
line numbers are long, x positions unsigned long.
Patch by David Lawrence Ramsey.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4950 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
And undoing line wraps together with their causal text additions, and not as
separate actions because the user did not make them.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4945 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
cursor should be in a slightly but significantly different position.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4944 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
null_at(), adding a cast, and using an unsigned type for a length.
Patch by David Lawrence Ramsey.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4939 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
deleting a newline and any other character.
Patch by Mark Majeres.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4934 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
and handling multibyte characters correctly.
*Patch by Mark Majeres.*
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4908 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
using 'size_t' instead of 'int' for line lengths.
Patch by David Lawrence Ramsey.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4895 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
and mentioning the name of the terminal-tickling character (NBSP).
Patch by David Lawrence Ramsey.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4894 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
pastes. This fixes many undo problems and Savannah bug #25585.
*Patch by Mark Majeres.*
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4893 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* src/rcfile.c (parse_color_names): Redefine false and true to
their appropriate macro names so --with-slang works (slangv2 anyway).
* src/text.c (do_linter): Care about whether user cancelled the file
save (cancel the operation) versus justy said no (continue but don't
save the file). Also doupdate() after statusbar message that
linter is being invoked and blank the shortcuts to draw the eye.
Also allow user to cancel at the "open in a new buffer" prompt.
New function lint_cleanup(). Fixes Savannah bug 42203.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4855 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
adding and tweaking some comments, and removing an unneeded 'if'.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4771 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
to change its description to Unjustify at the appropriate moment.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4739 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* global.c (shortcut_init) - Don't actually free the shortcut
list, since the next pass via justifying will then remove
all custom shortcuts. Fixed bug discovered by Benno Schulenberg.
* text.c (do_linter) - Remove some unused variables to quiet
-pedanic -Wall.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4637 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* new linter functionality. rcfile option "linter"
* src/global.c (shortcut_init) - Actually free the sclist
if it was allocated before.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4600 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* src/text.c (do_histify): Don't allow sigwinch to be received while justifying
as that puts us into a wacky state. Fixess crash on justify by Joshua Rogers.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4565 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* text.c (do_enter): Only increment totsize by the auto-indented amount, size the previous line's size was
already counted. Fixes bug reported by Robert Spanjaard.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4544 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This does add 20KB to nano's executable size but it gets rid of a lot of indirection
that makes people stomach turn. There are several new stub functions and need of more
tidying as a result of this.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4527 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* Add check for RESTRICTED mode back to speller, suspend and insert file
routines, since adding key bindings broke the fact that they should be
disabled in restricted mode. Fixes Savannah bug 31625 reported by
Charlie Somerville.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4519 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* text.c (do_alt_speller): Skip invoking the alt speller if the file size
is 0 bytes. Fixes Savannah bug 29393 reported by Mike Frysinger.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4499 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* text.c (do_delete), nano.c (do_output): Add check for length of current line
before and after adding/deleting text, and do full refresh if it is now
a different multiple of COLS. Also get rid of superfluous do_refresh
vars now that we have edit_refresh_needed.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4462 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* files.c (read_file) - Add parameter for whether we should even try to check
file writability, as the message is useless when we're inserting into an
existing buffer. Fixes Savannah bug 28219.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4460 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* text.c (add_undo, do_undo, do_redo) - Do not execute cases for SPLIT when DISABLE_WRAPPING
is defined. Fixes Savannah bug 28151 (anon).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4455 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* Update documentation for 2.2 features including sample nanorc file, texinfo
file, man pages, UPGRADE file, and update copyright noticed for the current year.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4453 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* prompt.c (get_prompt_string) - Universally handle help key when is disabled. Fixes Savannah
bug 28117 by David Lawrence Ramsey <pooka109@gmail.com>.
* chars.c, files.c: Add junk vars to silence the compiler. Sigh.
2009-11-29 David Lawrence Ramsey <pooka109@gmail.com>
* Change several *chars to const char, additional cleanups and casts to make compilers happier.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4448 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* winio.c: Large tweaking of cursor and text display based on COLS not COLS - 1,
due to finally understanding that display_string wasn't being called properly
when softwrap was enabled. Fixes Savnnah bug 27603, Return key doesn't scroll
viewport reported by Hannes Schueller.
* - Fix size_t formatting issues with -pedantic by converting vals to long unsigned
for printing.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4420 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* Attempt to check file writability and emit a warning on the status bar
if nano doesn't think the file can be written to. Feature originally
requested by Damien Jolders <madamien@skullsquad.com> et al.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4407 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* Initial soft line wrapping implementation. Command line flags
-$ or --softwrap.
* nano.c, text.c: Clean up some fprintf warnings in debug mode due to printing
a size_t without using the zd specifier.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4402 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* New global flag implementation courtesy of Adam Wysocki <gophi@arcabit.pl>, allows
previous undo flag to be implemented consistent with other flags.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4400 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* text.c (undo_cut, redo_cut): Don't actually try and undo/redo an empty cut, i.e. the magicline.
Fixes crash on cutting last line discovered by Eitan Adler <eitanadlerlist@gmail.com>.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4397 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
* nano-regress: Small tweaks
* Change undo code to off unless unabled via a command line option (-u/--undo). Until this code
stabilizes this is the only responsible way to treat it.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4395 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Hate to piecemeal these fixed but system unstability is teh suck.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4392 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Change message for line split to line wrap, since split ~= break
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4391 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
- Fix undo line split uglyness. Still not perfect but switching work envs.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4390 35c25a1d-7b9e-4130-9fde-d3aeb78583b8