Compare commits
123 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c45d5f4bb3 | ||
|
|
733ca94f8e | ||
|
|
a9c3bbf8e0 | ||
|
|
be3e4404ee | ||
|
|
6d5b2fd936 | ||
|
|
637b76b582 | ||
|
|
92213f9de8 | ||
|
|
85ddc718f8 | ||
|
|
6c86ee1a5b | ||
|
|
6418ffa289 | ||
|
|
3933a30c9e | ||
|
|
e6a4a64619 | ||
|
|
b095725429 | ||
|
|
4947ad83cb | ||
|
|
ebcc68f51d | ||
|
|
645841fd25 | ||
|
|
3cd3e32ec3 | ||
|
|
49816fed70 | ||
|
|
3b031b1bad | ||
|
|
95e77a9d5f | ||
|
|
776931a0b0 | ||
|
|
7e5324d164 | ||
|
|
eaf235f1e6 | ||
|
|
e94a00a26c | ||
|
|
09dd0a4acb | ||
|
|
6f28d35eef | ||
|
|
41e19a14f4 | ||
|
|
484a0be6e6 | ||
|
|
d48d84a3ba | ||
|
|
b71cf98ec7 | ||
|
|
0a1e56ed3c | ||
|
|
d4623f3ca3 | ||
|
|
b5895f0a51 | ||
|
|
4868f83874 | ||
|
|
607b226e4e | ||
|
|
26de2dd843 | ||
|
|
29dfb68b6e | ||
|
|
64fd3b8d0e | ||
|
|
4651f49fca | ||
|
|
a8c13d79fe | ||
|
|
40ae394b6a | ||
|
|
0c0fbd585c | ||
|
|
45417c76f3 | ||
|
|
cfa1338fb0 | ||
|
|
12ecfbbae8 | ||
|
|
ef16223661 | ||
|
|
a0f66c0691 | ||
|
|
ce0ea44596 | ||
|
|
4cf39e4191 | ||
|
|
64039e9337 | ||
|
|
8ea830f79b | ||
|
|
cda06a9491 | ||
|
|
016669128b | ||
|
|
07f40612e1 | ||
|
|
fb6c0cd20c | ||
|
|
76e150b47f | ||
|
|
f80dcb2b25 | ||
|
|
3060ce36d3 | ||
|
|
b14fbf719f | ||
|
|
1930e8102d | ||
|
|
691689d2b3 | ||
|
|
3b47ff756e | ||
|
|
cf8a296279 | ||
|
|
c923fa7c61 | ||
|
|
b0555990c2 | ||
|
|
492e9f605b | ||
|
|
ac6846a3e9 | ||
|
|
03f37add07 | ||
|
|
4147c5e0fc | ||
|
|
3f816eeb58 | ||
|
|
ae2d300375 | ||
|
|
b341f29cbd | ||
|
|
0615acd739 | ||
|
|
fcb4c3fc6e | ||
|
|
d840302f28 | ||
|
|
e7c690d577 | ||
|
|
a81e141326 | ||
|
|
336d1b8902 | ||
|
|
45fe2adf72 | ||
|
|
b39db7bc63 | ||
|
|
3cf338aca8 | ||
|
|
c55c0db2bb | ||
|
|
a872709ab4 | ||
|
|
b439f55678 | ||
|
|
e96022b923 | ||
|
|
38cb8fc328 | ||
|
|
4f3f976030 | ||
|
|
7152a4b544 | ||
|
|
73a8aa0a74 | ||
|
|
d21649e906 | ||
|
|
1f67c1244d | ||
|
|
0ec771009c | ||
|
|
99a649ddf6 | ||
|
|
ca9abd8216 | ||
|
|
948b8e9bcf | ||
|
|
c5c0d748c2 | ||
|
|
736fbf2e3f | ||
|
|
cd59a646e6 | ||
|
|
3af22aad8d | ||
|
|
1d06455ca5 | ||
|
|
454563c9dc | ||
|
|
62bb6e85fc | ||
|
|
8cc8b08dfc | ||
|
|
fc35e20052 | ||
|
|
a3f421ca2b | ||
|
|
7d5f42ca08 | ||
|
|
a8a23abc00 | ||
|
|
53435b0efc | ||
|
|
6af5bdea27 | ||
|
|
1102aaa374 | ||
|
|
acda255b47 | ||
|
|
ed0086bde5 | ||
|
|
505125e259 | ||
|
|
c35eb5a16e | ||
|
|
9ac910e9d3 | ||
|
|
be10c2a48c | ||
|
|
64896ba2ff | ||
|
|
5dfab51576 | ||
|
|
25df3ab995 | ||
|
|
04a38da312 | ||
|
|
95592ce5df | ||
|
|
1eb23d4988 | ||
|
|
1de337de9c |
161
BUGS
161
BUGS
@@ -1,161 +0,0 @@
|
||||
** Open BUGS **
|
||||
|
||||
** Fixed BUGS **
|
||||
- Marked cutting sometimes leaves a newline in the file unintelligently,
|
||||
such as when all of a line is selected but the mark doesn't proceed to
|
||||
the new line. (8) [FIXED/IRRELEVANT]
|
||||
- Certains are not lined up properly when there are tabs in them at
|
||||
certain col values. (9) [FIXED]
|
||||
- edit_refresh() and update_line() do not handle selecting text when the
|
||||
cursor is beyond COLS (10) [FIXED]
|
||||
- No way to do a replace with the empty string (11) [FIXED, yay!]
|
||||
- Spelling support is not elegant like Pico's integration of the 'spell'
|
||||
program. nano only uses ispell (for now) (12) [FIXED]
|
||||
- Moving to the end of a line when close to a multiple of COLS and at
|
||||
least COLS * 2 does not make the screen jump early like it would for
|
||||
if we were around COLS (bugs in edit_refresh, update_line) (13)
|
||||
[FIXED, mostly]
|
||||
- When at the very bottom of the edit window, do_wrap() goes berserk and
|
||||
puts the cursor somewhere bad; subsequent keystrokes crash the program
|
||||
(14) [FIXED, mostly]
|
||||
- Doing a replacement of a substring of the replace string (e.g.
|
||||
replacing "ed" with "fred" causes an infinite loop). (15) [FIXED]
|
||||
- Cutting a file with marked text and both marker ends on the same line
|
||||
causes a random segfault (16) [FIXED]
|
||||
- Cutting more than one line resets the KEEP_CUTBUFFER flag in 0.9.3.
|
||||
Error is in bitwise assignment (nano.h). (17) [FIXED]
|
||||
- The wrapping code does not work right for lines like the following:
|
||||
* *
|
||||
Error is in do_wrap, must be rewritten. (18) [FIXED]
|
||||
- nano fails to follow symlinks, even though -l isn't being used (20).
|
||||
[Bug in global flag init, FIXED]
|
||||
- When using --help or --version, the SIGINT character gets lost. (21)
|
||||
[FIXED]
|
||||
- edit_refresh() and update_line() (and related functions) have
|
||||
trouble when a tab is the character that is the boundary at COLS (23)
|
||||
[FIXED]
|
||||
- There is an off-by-one error in keeping track of totsize. It is
|
||||
caused by the fact that we count the newline at the end when we read
|
||||
in a file but we do not, in fact, display this newline. This should
|
||||
go away implicitly when the "Magic Line" returns, but it is noted here
|
||||
for documentation's sake. (24) [FIXED]
|
||||
- In replace with completely adjacent strings, every other search string
|
||||
will be missed (try replace ':' in a string like ':::::::::') (28)
|
||||
[FIXED]
|
||||
- If nano opens a read-only file with the --tempfile option, and a
|
||||
change is made to the buffer, and a write is attempted, nano will not
|
||||
give you a dialog about not being able to write the file, and it will
|
||||
not let the user exit (29, discovered by Joshua Jensen) [FIXED]
|
||||
- Using nano -k, marked text is not cut properly. (31) [FIXED]
|
||||
- Invoking -t or -k has the effect of invoking both options. (32)
|
||||
[FIXED]
|
||||
- totsize becomes incorrect after word-wrapping (25) [FIXED]
|
||||
- Wrapping a line with autoindent mode sometimes causes a segfault (19)
|
||||
[FIXED]
|
||||
- When inserting files, the display sometimes fails to display properly
|
||||
until a pageup/down occurs (22) [FIXED]
|
||||
- In search/replace code, there is too much refreshing in bottomwin (26)
|
||||
[FIXED]
|
||||
- In replace, there is no way to accept the default replace string. (27)
|
||||
[FIXED]
|
||||
- Using nano -t, user can not exit until a filename is given via ^O.
|
||||
(30) [FIXED]
|
||||
- totsize problems still abound in do_justify (33) [FIXED]
|
||||
- Using -k, cut text is not pasted properly. (34) [FIXED].
|
||||
- Using -k, pasted text is not updated properly if it goes beyond
|
||||
editbot. (35) [FIXED]
|
||||
- Doing a cut with -k can screw up the filestruct; fault is in cutting
|
||||
code. (36) [FIXED]
|
||||
- Hitting enter on the magic line makes new lines, but they are not
|
||||
written out to disk when saved..... (37). [FIXED]
|
||||
- Page up and page down do not work the same way as in Pico (# of
|
||||
lines). (38) [FIXED]
|
||||
- When doing a search and the marker is set, the screen does not always
|
||||
properly update the inverted text (39). [FIXED]
|
||||
- Searches for a string that only exists on one line multiple times will
|
||||
fail after finding the last occurrence (discovered by Ken Tyler) (40).
|
||||
[FIXED]
|
||||
- Meta-Z is currently broken to toggle suspend. I guess I still don't
|
||||
know signals very well =-) (41) [FIXED].
|
||||
- Unable to cut the entire file using the marker (discovered by Ken
|
||||
Tyler) (42). [FIXED]
|
||||
- The keypad does not work when nano runs in the Gnome terminal (43).
|
||||
[FIXED]
|
||||
- When reading in a file, if the file is a directory, the contents of
|
||||
the file being edited are blown away (discovered by Chris Pimlot)
|
||||
(44). [FIXED]
|
||||
- In certain terms, nano will leave a "ghost" of screen upon exit when
|
||||
called from inside mutt (among other settings) (45). [FIXED]
|
||||
- In replace, hitting the Goto line shortcut key does nothing after a
|
||||
search string is entered (discovered by Rocco Corsi) (46) [FIXED].
|
||||
- When typing in a string in search or replace and hitting
|
||||
CASE_SENSITIVE or the other search string, the current string edit is
|
||||
blown away in favor of the last stored search (47) [FIXED]
|
||||
- If nano fails to open a file when it starts up, doing almost anything
|
||||
causes a segfault (discovered by Ben Roberts) (48). [FIXED]
|
||||
- In certain terminals, nano would not work properly with keypad().
|
||||
Turned out to be the silly timeout(0) call, which is completely
|
||||
unneeded, anyway. (49) [FIXED]
|
||||
- With less than a page of text, doing a page down will move the current
|
||||
line to the top of the screen, which it shouldn't do. (50) [FIXED]
|
||||
- With PDCurses, running Meta-X turns off the keypad. (51) [FIXED]
|
||||
- Resizing the window completely screws up the display if in any other
|
||||
mode than normal editing (help screen, search and replace, file
|
||||
browser...) (52) [FIXED]
|
||||
- Alt speller argument (-s, --speller) does not take a string argument
|
||||
of more than one word. (53) [FIXED].
|
||||
- Cut to end cutting (-k) causes segfaults (try cutting "- Backup making
|
||||
(filename~)?" line in TODO file) (discovered by
|
||||
higuita@cadernoverde.com) (54) [FIXED].
|
||||
- When using autoindent (-i), wrapped text does not get autoindented
|
||||
(55, discovered by Mark Senior) [FIXED].
|
||||
- When using -R (regex) and -p (Pico mode), subsequent searches after
|
||||
the first fail if no string is entered (56) [FIXED].
|
||||
- Page down on a file of editwinrows fails (again). Reported by Ryan
|
||||
Krebs (57) [FIXED].
|
||||
- File browser aborts on Solaris in qsort() call. (Reported by Matthias
|
||||
Andree) (58) [FIXED].
|
||||
- Can modify the current file in view mode with ^W^R (discovered by
|
||||
Rocco Corsi) (58) [FIXED].
|
||||
- When page up is used after two page downs, the screen doesn't update
|
||||
properly (discovered by David Lawrence Ramsey) (59) [FIXED].
|
||||
- On BSD systems, marked cutting and paste often screws up the last line
|
||||
in the cutbuffer (discovered by Barry Pederson) (60) [FIXED]
|
||||
- Blank lines are not kept when cutting with -k (discovered by Rocco)
|
||||
(61) [FIXED].
|
||||
- nano will not suspend properly inside of mutt (62) [FIXED].
|
||||
- When switching from Pico mode to normal mode, the previous search is
|
||||
not displayed until cancelling the search (63) [FIXED].
|
||||
- If you change search options but don't change the search string in
|
||||
normal mode, hitting Enter causes the search/replace to abort (64)
|
||||
(Jordi Mallach) [FIXED].
|
||||
- Cutting one line of text causes the screen to recenter the line
|
||||
(reported and fixed by David Lawrence Ramsey) (65) [FIXED].
|
||||
- When cutting marked text including the bottom of the file, a new
|
||||
"magic line" is not created" (reported by David Lawrence Ramsey, fixed
|
||||
by David Lawrence Ramsey & Chris) (66) [FIXED].
|
||||
- ^C does not work after a suspend in tcsh (discovered by Trevor Cordes)
|
||||
(68) [FIXED].
|
||||
- Home and End control keys (^A, ^E) do not always work in filename
|
||||
prompt (bug found by Ian Turner) (69) [1.0 series only] [FIXED].
|
||||
- Trying to insert a file of 0 bytes will hang nano (70) [FIXED].
|
||||
- Meta-space and ^Space are not yet handled in new backend code (77) [FIXED]
|
||||
- F-keys do not work with new shortcut backend (72) [FIXED]
|
||||
- Many menu items are probably missing from the new backend (73) [FIXED]
|
||||
- Need a 'check-vitals-mapped' function to check that the end used didn't
|
||||
unbind all the keys for exit or cancel before starting up the editor (74) [FIXED]
|
||||
- Browser and prompt code still implement old switch on raw key input instead
|
||||
of new if block for subnfunc values (75) [FIXED]
|
||||
- New backend code probably does not compile under anything but default options,
|
||||
if that (76) [FIXED]
|
||||
- -enable-tiny does not work with new code (78) [FIXED]
|
||||
- If a user only binds meta sequences to a function like left, right
|
||||
page up/down, insert, and unbinds all other control and F keys for it,
|
||||
nano will do the wrong thing when reading the key which is normally
|
||||
assigned to it (79 - may not be worth fixing) [FIXED]
|
||||
- Segfault editing at COLS presumably due to new color syntax
|
||||
highlighting (80) [FIXED]
|
||||
- Cutting the line at the top of the screen recenters to center (71) [FIXED]
|
||||
|
||||
|
||||
$Id$
|
||||
372
ChangeLog
372
ChangeLog
@@ -1,17 +1,348 @@
|
||||
2014-07-11 Chris Allegretta <chrisa@asty.org>
|
||||
* src/files.c (do_lockfile, open_file): If locking fails,
|
||||
allow the lock failure message to be preserved AND
|
||||
preserve the filename passed on the cmdline. Fixes
|
||||
Savannah bug #42668.
|
||||
|
||||
2014-07-02 Chris Allegretta <chrisa@asty.org>
|
||||
* src/files.c (do_lockfile): Check whether the directory
|
||||
of the file we're trying to lock exists, and make the
|
||||
resulting error message more intuitive. Fixes
|
||||
Savannah bug #42639 reported by Benno Schulenberg.
|
||||
|
||||
2014-07-02 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (undo_cut, redo_cut, update_undo): Handle the
|
||||
cases of cutting-from-cursor-to-end-of-line correctly.
|
||||
* src/nano.c (do_input): Don't preserve the cutbuffer when
|
||||
CUT_TO_END is toggled -- it would intermix two cut types.
|
||||
* src/text.c (redo_cut, do_undo, do_redo): Don't forget to
|
||||
free the cutbuffer after use.
|
||||
|
||||
2014-07-02 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/proto.h: Add a typedef for a pointer to a function.
|
||||
* src/global.c (func_from_key): New wrapper.
|
||||
* src/prompt.c (get_prompt_string, do_prompt): Use the new
|
||||
wrapper to make the code a bit cleaner.
|
||||
* src/help.c (do_help, parse_help_input): Use the wrapper.
|
||||
* src/browser.c (do_browser, parse_browser_input): Likewise.
|
||||
* src/search.c (search_init, do_gotolinecolumn): Likewise.
|
||||
* src/search.c (findnextstr): Replace a call of old wrapper
|
||||
'getfuncfromkey()' with a call of new 'func_from_key()'.
|
||||
* src/winio.c (getfuncfromkey): Delete now unneeded wrapper.
|
||||
* src/nano.c (usage, main), doc/texinfo/nano.texi: Properly
|
||||
exclude the --quiet option when --disable-nanorc was given.
|
||||
|
||||
2014-07-01 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (do_browser), src/help.c (do_help): Make sure
|
||||
to always set 'currmenu', so that we can rely on it.
|
||||
* src/*.c (get_shortcut): Now that 'currmenu' is really global,
|
||||
stop passing it around.
|
||||
* src/help.c (help_init), src/winio.c (bottombars): There are
|
||||
no tagless functions, so there is no need to check.
|
||||
* src/prompt.c (do_prompt, get_prompt_string): Don't pass the
|
||||
menu, just set it earlier.
|
||||
* src/prompt.c (get_prompt_string): Group the arguments better.
|
||||
* src/global.c (shortcut_init), src/browser.c (do_filesearch):
|
||||
Show that it is possible to have backwards, regular-expressive
|
||||
and case-sensitive searching in the file browser.
|
||||
* src/browser.c (filesearch_init, do_filesearch): Now delete
|
||||
these abilities again and all provisions for them.
|
||||
* src/global.c (shortcut_init): Add two defines to make the
|
||||
functions list clearer.
|
||||
|
||||
2014-06-30 Mark Majeres <mark@engine12.com>
|
||||
* src/cut.c, src/global.c, src/nano.c: Rename 'cut_till_end' to
|
||||
'cut_till_eof', and 'do_cut_till_end' to 'do_cut_till_eof', to
|
||||
reduce confusion with CUT_TO_END, which is about end-of-line.
|
||||
|
||||
2014-06-30 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/color.c (color_update): When there are no syntaxes, for example
|
||||
with --ignorercfiles, do not try to find one, because that would lead
|
||||
to the magic database being searched, which slows down startup a lot.
|
||||
* src/color.c (color_update): Move some variables to a better place.
|
||||
* src/*: Make 'meta_key' and 'func_key' into global variables, instead
|
||||
of having them declared everywhere and passing them around endlessly.
|
||||
* src/global.c (sc_seq_or): Now fix a bug introduced somewhere after
|
||||
2.3.2 where binding a movement function to a Meta key would make the
|
||||
corresponding Arrow key stop working (producing a character instead).
|
||||
|
||||
2014-06-29 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/rcfile.c: Fix compilation with --enable-tiny --enable-nanorc.
|
||||
* src/winio.c (parse_kbinput, get_escape_seq_kbinput): Make Ctrl-Left
|
||||
and Ctrl-Right produce special codes, and map these codes to Prevword
|
||||
and Nextword instead of reducing them to a plain Left and Right. The
|
||||
codes 539 and 554 were so chosen because some terminals produce these.
|
||||
|
||||
2014-06-29 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (do_undo): Update the pointer to the bottom of the file
|
||||
when undoing line deletions at file's end.
|
||||
|
||||
2014-06-28 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/prompt.c (do_statusbar_input): Remove the useless parameters
|
||||
'have_shortcut and 'allow_funcs'; the latter is only ever TRUE.
|
||||
* src/global.c (shortcut_init), src/prompt.c (do_statusbar_input):
|
||||
Eradicate the execute flag -- it is only FALSE for functions that are
|
||||
empty placeholders (so executing them will not do anything anyway) or
|
||||
for functions ('total_refresh', 'do_suspend_void') that do not exist
|
||||
in menus with a prompt. The only two exceptions are 'do_cancel' and
|
||||
'do_gotolinecolumn_void'. The first is handled specially, so do that
|
||||
too for the second and then get to drop 140 parameters.
|
||||
* src/global.c (strtosc): Move recognition of the toggles to the end,
|
||||
use a single assignment of do_toggle_void, trim the unneeded braces.
|
||||
|
||||
2014-06-27 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/global.c (shortcut_init): Add default keybindings for Cut,
|
||||
PrevWord and NextWord in the prompt input lines; the code for those
|
||||
special operations already exists, just the shortcuts were missing.
|
||||
* src/rcfile.c (parse_binding): When binding keys, only allow those
|
||||
menus where the bound function is actually present. This reduces
|
||||
the meaning of 'all' to "all menus where the function exists".
|
||||
* src/rcfile.c (is_universal): New function, returning TRUE for the
|
||||
functions that are present in most menus but only listed in MMAIN.
|
||||
* doc/man/nanorc.5, doc/texinfo/nano.texi: Update the docs for this.
|
||||
* prompt.c (find_statusbar_bracket_match, do_statusbar_find_bracket):
|
||||
Remove these functions and thus the ability to search for a matching
|
||||
bracket in a prompt input line. The find_bracket function never had
|
||||
a default keybinding outside MMAIN, so is unlikely to have been used.
|
||||
* src/prompt.c (do_statusbar_input): Normalize the indentation.
|
||||
* src/winio.c: Normalize some whitespace.
|
||||
* Makefile.am, nano.spec.in: Stop distributing the BUGS file.
|
||||
* BUGS: Remove obsolete file, as all the bugs in it have been fixed
|
||||
long ago. Nowadays bugs are tracked on Savannah.
|
||||
* configure.ac: Silence a useless warning about ignoring datarootdir.
|
||||
|
||||
2014-06-25 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (do_browser): Allow 'firstfile' and 'lastfile' to be
|
||||
rebound to Ctrl keys -- checking meta_key is wrong, the function has
|
||||
already been determined, that is all that matters.
|
||||
* src/help.c (do_help): Same thing for 'firstline'/'lastline'.
|
||||
|
||||
2014-06-23 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/nano.h, src/move.c (do_up, do_down), src/winio.c (edit_scrol):
|
||||
Rename UP_DIR and DOWN_DIR to UPWARD and DOWNWARD, for clarity.
|
||||
* src/proto.h, src/global.c, src/search.c: Rename 'no_replace_void()'
|
||||
to 'flip_replace_void()', to show what it actually does.
|
||||
* doc/man/nanorc.5, doc/texinfo/nano.texi: Update the docs for that.
|
||||
* src/global.c (strtosc): Add the bindable function 'gotodir'.
|
||||
* doc/man/nanorc.5, doc/texinfo/nano.texi: Document the bindable
|
||||
functions 'tofiles','gotodir' and 'flipnewbuffer', and correct
|
||||
the description of 'gototext' (not being about the file browser).
|
||||
* doc/syntax/nanorc.nanorc: Show Ins and Del as valid rebindable keys.
|
||||
* src/help.c (do_help): Normalize the indentation.
|
||||
* src/files.c (do_insertfile): Give audible feedback when flipping
|
||||
the new buffer to off is not allowed in view mode.
|
||||
|
||||
2014-06-22 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c (parse_browser_input), src/help.c (parse_help_input):
|
||||
Remove two pointless calls of get_shortcut(), and adjust the comments.
|
||||
* src/nano.c (do_toggle): When toggling softwrap, only the edit window
|
||||
needs to be refreshed, not the entire screen.
|
||||
* src/browser.c (do_browser): Remove superfluous abortion variable,
|
||||
and place two comments better.
|
||||
* src/text.c (do_redo): Rename 'undidmsg' to 'redidmsg', to be apt.
|
||||
|
||||
2014-06-22 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (do_redo): When redoing a line join at the tail
|
||||
of the file, make sure openfile->filebot is updated.
|
||||
* src/text.c (undo_cut, redo_cut, do_undo, add_undo, update_undo):
|
||||
Fix three leaks of the cutbuffer, shorten and regroup some stuff,
|
||||
and remove an unneeded iteration of cutbottom.
|
||||
|
||||
2014-06-21 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (undo_cut, add_undo): When undoing a cut-till-eof,
|
||||
put the cursor back where the cut started, and not at the end.
|
||||
* src/text.c (do_undo): When undoing a line break at the tail
|
||||
of the file, make sure openfile->filebot is updated.
|
||||
|
||||
2014-06-21 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* src/move.c, src/nano.c: Miscellaneous whitespace fixes, one
|
||||
type fix, and one more #ifdef NANO_TINY.
|
||||
|
||||
2014-06-20 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/proto.h, src/global.c: Remove two obsolete variables and an
|
||||
unneeded extern, and regroup some stuff.
|
||||
* src/files.c (check_dotnano): Wrap long lines and actually report
|
||||
the name that is not a directory.
|
||||
* src/*: Miscellaneous whitespace adjustments and comment tweaks.
|
||||
* src/files.c: Fix compilation with --enable-tiny --enable-browser.
|
||||
* doc/man/nano.1, doc/texinfo/nano.texi: History logging no longer
|
||||
depends upon nanorc support, plus many other tweaks.
|
||||
* src/global.c (strtosc): Fix compilation with --enable-tiny
|
||||
--enable-histories --enable-nanorc.
|
||||
* src/text.c: Fix compilation with --enable-tiny --enable-wrapping.
|
||||
* src/files.c (do_insertfile): Fix compilation with --enable-tiny
|
||||
--enable-histories --enable-multibuffer.
|
||||
* src/nano.c: Fix compilation with --enable-tiny --enable-mouse.
|
||||
* doc/man/nanorc.5, doc/texinfo/nano.texi: Explain better what "all"
|
||||
means when rebinding keys. This is a fix for Savannah bug #42552.
|
||||
* src/nano.c (main): Make +1 and +,1 start on line one column one,
|
||||
overriding a historical position. This fixes Savannah bug #42538.
|
||||
|
||||
2014-06-19 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/nano.c (window_init): Rename 'no_more_space()' to 'more_space()'
|
||||
for consistency, and tweak the related comments.
|
||||
* src/files.c: Update some comments to match the current status.
|
||||
* src/nano (finish, main): Allow -H/--historylog and -P/--poslog to
|
||||
function also when -I/--ignorercfiles is given.
|
||||
* configure.ac: Add a --disable-histories flag, to disable the code
|
||||
for the histories of search/replace strings and cursor positions.
|
||||
* doc/texinfo/nano.texi: Document the new configure flag.
|
||||
* src/*: Transform many DISABLE_NANORC to the new DISABLE_HISTORIES.
|
||||
This completes the fix for Savannah bug #42539.
|
||||
|
||||
2014-06-18 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c: Rename 'to_end' to 'to_eof', to lessen confusion
|
||||
with CUT_TO_END (which is about cutting to end-of-line).
|
||||
* src/text.c: Upon better thought, elide the unneeded 'to_eof'.
|
||||
* src/text.c: And elide a totally unused 'strdata2'.
|
||||
* src/text.c: Rename the undo type UNSPLIT to JOIN, for clarity.
|
||||
* src/global.c, src/rcfile.c: Rename function_type to key_type.
|
||||
* src/text.c (break_line): Remove a condition and a break that
|
||||
cancel each other.
|
||||
|
||||
2014-06-18 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (add_undo): Don't start a new undo for CUT when the
|
||||
cutbuffer is being preserved, because then the cuts are contiguous
|
||||
and will form a single undo item. And make sure the cutbuffer will
|
||||
be cleared when a new undo item for CUT is created.
|
||||
* src/cut.c (keeping_cutbuffer): New function, to access the status
|
||||
of 'keep_cutbuffer' from the undo/redo code in src/text.c.
|
||||
* src/cut.c (do_copy_text): Blow away the contents of the cutbuffer
|
||||
if the mark is set or the cursor has moved between two copy commands.
|
||||
|
||||
2014-06-17 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (do_undo, do_redo): After an undo or redo, update the
|
||||
'placewewant' (the desired horizontal position of the cursor).
|
||||
|
||||
2014-06-17 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/text.c (do_undo, do_redo): Remove obsolete boolean variable.
|
||||
* doc/man/nano.1, doc/man/nanorc.5, doc/texinfo/nano.texi: Replace
|
||||
SYSCONFDIR with an absolute path or a circumlocution, as suggested
|
||||
by Mike Frysinger, plus some other tweaks.
|
||||
|
||||
2014-06-16 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* src/nano.c (do_exit): Display the message "No file name" on the
|
||||
statusbar for two seconds when --tempfile was given and the current
|
||||
buffer has no name. This fixes Savannah bug #41750.
|
||||
|
||||
2014-06-16 Benno Schulenberg <bensberg@justemail.net>
|
||||
* configure.ac: For the sake of statically linked systems, make sure
|
||||
the compiler also links against libz, which is used by libmagic.
|
||||
This fixes Savannah bug #38378, reported by Alan Hourihane.
|
||||
* src/nano.c (do_mouse, do_input): Don't bother returning zero when
|
||||
the cursor moved, just reset the cutbuffer directly. This avoids an
|
||||
"Unknown Command" message on every cursor-positioning mouse click.
|
||||
* src/nano.c (do_mouse): Put a common statement outside of then/else.
|
||||
* src/Makefile.am: Remove -I m4; it is needed only at the top level.
|
||||
* Makefile.am: Trim the contents of EXTRA_DIST to what is required.
|
||||
* doc/man/nano.1, doc/man/nanorc.5, doc/texinfo/nano.texi: Update
|
||||
the docs for the changed location of nano's search history.
|
||||
* doc/man/nano.1, doc/man/nanorc.5, doc/texinfo/nano.texi: Change
|
||||
some wordings, triggered by Savannah bug #52539.
|
||||
|
||||
2014-06-14 Mark Majeres <mark@engine12.com>
|
||||
* src/nano.h, src/text.c (undo_cut, update_undo): When undoing a
|
||||
backwards cut, put the cursor back in front of it, where it was.
|
||||
|
||||
2014-06-13 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/nano.c (do_input): Repositioning the cursor with the mouse
|
||||
(result == 0) should break a series of ^Ks.
|
||||
* src/nano.c (do_mouse): Clicking on the titlebar or the statusbar
|
||||
should not break a series of ^Ks, thus result must not be zero.
|
||||
* src/nano.c (do_input): A toggle should not break a series of ^Ks.
|
||||
* src/winio.c (get_shortcut): Do not treat holding both Control and
|
||||
Meta the same as holding only Control.
|
||||
* src/global.c, src/rcfile.c, src/nano.h, src/nano.c, src/text.c:
|
||||
Remove the --undo option, having the undo functions always enabled.
|
||||
If wished, the user can unbind them. This fixes Savannah bug #42456.
|
||||
* doc/man/{nano.1,nanorc.5}, doc/texinfo/nano.texi: Update the docs.
|
||||
* nano.spec.in: Remove useless info dir file from the build directory,
|
||||
don't clean this directory first, it's unnecessary, add a suggestion
|
||||
for a pico symlink, and update the license and the source URL.
|
||||
|
||||
2014-06-11 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/winio.c (get_mouseinput): Produce the correct return value for
|
||||
when a mouse event reinserted something into the keyboard buffer.
|
||||
* src/nano.c (do_input): Do not continue when there is a spurious
|
||||
mouse event (a touch of the touchpad, for example) but get out.
|
||||
Continuing would result in the cutbuffer being cleared upon the
|
||||
next cut. These two changes together fix Savannah bug #42326.
|
||||
* src/nano.c (do_input): Always accept mouse events, also when
|
||||
just looking for Unjustify. This fixes Savannah bug #42322.
|
||||
* src/nano.c (do_input): Remove a superfluous switch statement.
|
||||
* src/winio.c (get_mouseinput): Set the type of a reinserted key,
|
||||
also when it is a function key. This fixes Savannah bug #42092.
|
||||
|
||||
2014-06-10 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/browser.c, src/files.c, src/nano.c src/prompt.c, src/winio.c:
|
||||
A few minimalistic whitespace adjustments.
|
||||
* src/rcfile.c (check_bad_binding): Avoid a compiler warning.
|
||||
|
||||
2014-06-10 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* src/winio.c: One more type fix and two tiny message tweaks.
|
||||
|
||||
2014-06-09 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* src/*.c: Cosmetic tweaks of comments and whitespace.
|
||||
* src/help.c, src/rcfile.c, src/winio.c: Elide a function call by
|
||||
not comparing with an empty string but checking for the final \0.
|
||||
* src/files.c, src/nano.c, src/text.c, src/winio.c: Type fixes in
|
||||
debugging stuff -- line numbers are long, x positions unsigned long.
|
||||
* src/files.c, src/move.c, src/nano.c, src/text.c, src/winio.c:
|
||||
Make tiny nano a bit tinier by preening out some soft-wrap stuff.
|
||||
* src/global.c, src/nano.c, src/winio.c: A few more cosmetic tweaks
|
||||
(whitespace, order, braces, parentheses, and a typo) and type fixes.
|
||||
|
||||
2014-06-09 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/nano.c (do_input): Remove two superfluous false conditions.
|
||||
* src/nano.h, src/text.c (add_undo): Avoid a compiler warning with
|
||||
--disable-wrapping.
|
||||
|
||||
2014-06-09 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (do_undo, do_redo, add_undo, update_undo, do-wrap):
|
||||
Rewrite the line-wrapping code to make use of the existing line-break
|
||||
code. And undo line wraps together with their causal text additions,
|
||||
and not as separate actions because the user did not make them.
|
||||
|
||||
2014-06-08 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (do_delete, do_deletion, do_undo, do_redo, update_undo):
|
||||
Differentiate between undoing a Delete and undoing a Backspace -- the
|
||||
cursor should be in a slightly but significantly different position.
|
||||
|
||||
2014-06-04 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/global.c (shortcut_init), src/files.c (do_insertfile): Rename
|
||||
'ext_cmd_void' to 'flip_execute_void' to better match what it does.
|
||||
* src/global.c (strtosc), doc/man/nanorc.5, doc/texinfo/nano.texi:
|
||||
Add function name 'flipexecute' to enable rebinding ^X in the menus
|
||||
Read File and Execute Command.
|
||||
|
||||
2014-06-04 David Lawrence Ramsey <pooka109@gmail.com>
|
||||
* src/*.c: Adjustments of whitespace and comments.
|
||||
* doc/nanorc.sample.in: Interpunction tweaks.
|
||||
* src/global.c (add_to_funcs): Add cast to subnfunc* for nmalloc().
|
||||
* src/files.c (do_lockfile): Properly make the variable 'lockfilesize'
|
||||
a size_t instead of a ssize_t, since it holds the result of strlen().
|
||||
And use charalloc() instead of (char *)nmalloc().
|
||||
* src/text.c (do_undo): Use charealloc() and not (char *)nrealloc().
|
||||
* src/text.c (add_undo): Make use of null_at() to both null-terminate
|
||||
the multibyte character and align it to use only the amount of memory
|
||||
necessary.
|
||||
|
||||
GNU nano 2.3.4 - 2014.06.02
|
||||
2014-06-02 Chris Allegretta <chrisa@asty.org>
|
||||
* doc/syntax/default.nanorc: Can't do trailing spaces in the
|
||||
default syntax or it will hilight the spaces as you type
|
||||
them into a new file, which for non-programming is infuriating.
|
||||
default syntax or it will hilight the spaces as you type them
|
||||
into a new file, which for non-programming is infuriating.
|
||||
|
||||
2014-05-29 Mark Majeres <mark@engine12.com>
|
||||
* src/text.c (do_delete): For the undo structure, differentiate
|
||||
between deleting a newline and any other character.
|
||||
|
||||
2014-05-29 Chris Allegretta <chrisa@asty.org>
|
||||
* src/chars.c (addstrings): Needs to be available even on
|
||||
non-utf-8 sustems.
|
||||
* nano-regress: Added --disable-utf8 to regression check
|
||||
* src/chars.c (addstrings): This function needs to be available even
|
||||
on non-utf-8 systems.
|
||||
* nano-regress: Added --disable-utf8 to regression check.
|
||||
|
||||
GNU nano 2.3.3 - 2014.05.29
|
||||
2014-05-28 Chris Allegretta <chrisa@asty.org>
|
||||
* doc/syntax/mutt.nanorc: Include Benno's awesome signature
|
||||
matcher, modified slightly to also work for quoted sigs.
|
||||
@@ -728,7 +1059,7 @@
|
||||
* doc/syntax/makefile.nanorc: Highlight trailing whitespace.
|
||||
|
||||
2014-02-26 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/global.c (shortcut_init): Put PageUp and PageDown
|
||||
* src/global.c (shortcut_init): Put PageUp and PageDown
|
||||
and also WhereIs and WhereIsNext together in the help lines
|
||||
of the file browser, and WriteOut and Readfile in the help
|
||||
lines of the main window -- related stuff in one column.
|
||||
@@ -988,6 +1319,7 @@ GNU nano 2.3.0 - 2011.02.26
|
||||
with failing to write the backup file compared to 'allow_insecure_backup'.
|
||||
* winio.c (edit_redraw): Removed unused variable.
|
||||
|
||||
GNU nano 2.2.6 - 2010.11.22
|
||||
2010-11-15 Chris Allegretta <chrisa@asty.org>
|
||||
* Add a section to the FAQ about using nanorc on Win32 systems.
|
||||
|
||||
@@ -1054,7 +1386,7 @@ GNU nano 2.2.4 - 2010.04.15
|
||||
2010-03-21 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (page_stdin et al): Don't attempt to reset/reopen the terminal
|
||||
settings when reading stdin if it was aborted with SIGINT. May fix
|
||||
Savannah bug #29114 reported by Mike Frysinger.
|
||||
Savannah bug #29114 reported by Mike Frysinger.
|
||||
|
||||
2010-03-21 Mike Frysinger <vapier@gentoo.org>
|
||||
* doc/syntax/c.nanorc: Add additional support for #include_next and #pragma.
|
||||
@@ -1250,8 +1582,7 @@ GNU nano 2.1.99pre1 - 2009.11.15
|
||||
writing the same file we originally opened.
|
||||
|
||||
2009-11-13 Chris Allegretta <chrisa@asty.org>
|
||||
* winio.c: Add new static maxsize to be able to easier calculation with
|
||||
softwrap.
|
||||
* winio.c: Add new static maxsize for easier calculation with softwrap.
|
||||
* nano.c (do_mouse): Fix mouse support not working with soft wrapping.
|
||||
Fixes Savannah bug #27549 reported by Hannes Schueller.
|
||||
|
||||
@@ -1307,11 +1638,11 @@ GNU nano 2.1.11 - 2009.09.14
|
||||
|
||||
2009-08-29 Chris Allegretta <chrisa@asty.org>
|
||||
* Fix more soft wrapping issues, particularly with scrolling,
|
||||
discovered by Hannes <mr_creosote@mutantwatch.de>.
|
||||
discovered by Hannes Schueller <mr_creosote@mutantwatch.de>.
|
||||
|
||||
2009-08-19 Chris Allegretta <chrisa@asty.org>
|
||||
* Fix issue with soft wrapping not displaying the last character of each line,
|
||||
fixed bug discovered by Hannes <mr_creosote@mutantwatch.de>.
|
||||
fixed bug discovered by Hannes Schueller <mr_creosote@mutantwatch.de>.
|
||||
|
||||
2009-08-17 Mike Frysinger <vapier@gentoo.org>
|
||||
* doc/syntax/(gentoo|sh|tcl).nanorc: Fix problems with empty regexes on POSIX.
|
||||
@@ -1321,6 +1652,7 @@ GNU nano 2.1.11 - 2009.09.14
|
||||
* 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.
|
||||
|
||||
2009-08-13 Chris Allegretta <chrisa@asty.org>
|
||||
* New global flag implementation courtesy of Adam Wysocki <gophi@arcabit.pl>, allows
|
||||
previous undo flag to be implemented consistent with other flags.
|
||||
@@ -1331,9 +1663,9 @@ GNU nano 2.1.10 - 2009.07.28
|
||||
Fixes crash on cutting last line discovered by Eitan Adler <eitanadlerlist@gmail.com>.
|
||||
|
||||
2009-07-11 Chris Allegretta <chrisa@asty.org>
|
||||
* nano-regress: Small tweaks
|
||||
* Change undo code to off unless enabled via a command line option (-u/--undo). Until this code
|
||||
stabilizes this is the only responsible way to treat it.
|
||||
* nano-regress: Small tweaks.
|
||||
* Change undo code to off unless enabled via a command line option (-u/--undo).
|
||||
Until this code stabilizes this is the only responsible way to treat it.
|
||||
|
||||
2009-03-08 Chris Allegretta <chrisa@asty.org>
|
||||
* TODO: Break out some targets for various features into 2.2
|
||||
@@ -1367,7 +1699,7 @@ GNU nano 2.1.9 - 2009.02.16
|
||||
|
||||
2009-02-14 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.c (precalc_multicolorinfo): Add debugging so we have a better clue if further
|
||||
issues arise. Also start at the beginning of later lines when trying to match the
|
||||
issues arise. Also start at the beginning of later lines when trying to match the
|
||||
end of a multi-line regex. Fixes more overly aggressive highlighting found by
|
||||
Mike Frysinger. Finally, advance to the match end for performance.
|
||||
|
||||
@@ -1381,7 +1713,7 @@ GNU nano 2.1.9 - 2009.02.16
|
||||
errors about the rcfile and asking user to press enter. Also, nano should
|
||||
now only ask for one enter press when there is an error when not using -q.
|
||||
Based on discussion between Eitan Adler and Mike Frysinger.
|
||||
* rcfile.c (parse_keybinding): Significant cleanups and fixes for
|
||||
* rcfile.c (parse_keybinding): Significant cleanups and fixes for
|
||||
detecting and reporting errors in key bindings code.
|
||||
|
||||
2009-02-08 Chris Allegretta <chrisa@asty.org>
|
||||
@@ -1398,7 +1730,7 @@ GNU nano 2.1.8 - 2009.02.07
|
||||
causes nano to segfault.
|
||||
|
||||
2009-02-05 Chris Allegretta <chrisa@asty.org>
|
||||
* More color syntax speedups: Determine in reset_multis() whether we really need to call
|
||||
* More color syntax speedups: Determine in reset_multis() whether we really need to call
|
||||
edit_refresh(). Additional global var edit_refresh_needed() to hopefully reduce
|
||||
repeated calls to the function. New helper funcs reset_multis_before() and
|
||||
reset_multis_after().
|
||||
@@ -1498,7 +1830,7 @@ GNU nano 2.1.5 - 2008.08.30
|
||||
treating ^G the same as ^M.
|
||||
|
||||
2008-08-28 Chris Allegretta <chrisa@asty.org>
|
||||
* configure.ac, rcfile.c: Add support for an alternate rcfilename at configure time. Maybe this
|
||||
* configure.ac, rcfile.c: Add support for an alternate rcfilename at configure time. Maybe this
|
||||
should become a command line option some day, but I don't see the need currently. Start of
|
||||
fix for Savannah bug #24128: Add nanorc support to win32 platform.
|
||||
|
||||
@@ -1621,8 +1953,8 @@ GNU nano 2.1.1 - 2008.04.01
|
||||
* winio.c: Fix shortcut labels not being translated.
|
||||
|
||||
2008-03-17 Mike Frysinger <vapier@gentoo.org>
|
||||
* */.gitignore: Git ignore files for those running a local git
|
||||
against SVN.
|
||||
* */.gitignore: Git ignore files for those running a local git
|
||||
against SVN.
|
||||
|
||||
2008-03-16 Benno Schulenberg <bensberg@justemail.net>
|
||||
* src/help.c, src/global: Fix help strings no longer being
|
||||
|
||||
@@ -3,9 +3,6 @@ AUTOMAKE_OPTIONS = gnu no-dependencies
|
||||
|
||||
SUBDIRS = doc m4 po src
|
||||
|
||||
EXTRA_DIST = ABOUT-NLS AUTHORS BUGS COPYING COPYING.DOC ChangeLog \
|
||||
ChangeLog.pre-2.1 INSTALL NEWS README README.SVN \
|
||||
THANKS TODO UPGRADE config.rpath install-sh missing \
|
||||
mkinstalldirs nano.spec
|
||||
EXTRA_DIST = ChangeLog.pre-2.1 README.SVN UPGRADE nano.spec
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
13
NEWS
13
NEWS
@@ -1,3 +1,16 @@
|
||||
2014.07.11 - GNU nano 2.3.5 "lucky day" is released. This release
|
||||
contains many visible and under-the-hood fixes for
|
||||
components such as file locking, more fixes to the
|
||||
undo system, and you no longer have to explicitly ask
|
||||
nano to have undo/redo support as it now defaults to
|
||||
being enabled. Other notable fixes include a better
|
||||
handling of --tempfile mode, and better handling of
|
||||
command line arguments when also attempting to specify
|
||||
+<line number>. As always, please file any bugs you
|
||||
find at the Savannah page for nano, at
|
||||
https://savannah.gnu.org/bugs/index.php?42639 and
|
||||
thanks for using nano.
|
||||
|
||||
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry. This
|
||||
release contains only a small number of fixes, but in
|
||||
particular allows nano to compile on non-UTF8 curses
|
||||
|
||||
17
configure.ac
17
configure.ac
@@ -20,12 +20,16 @@
|
||||
#
|
||||
# $Id$
|
||||
|
||||
AC_INIT([GNU nano], [2.3.4], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [2.3.5], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
|
||||
dnl Silence a pointless warning from the gettext Makefile.
|
||||
|
||||
AC_DEFUN([AC_DATAROOTDIR_CHECKED])
|
||||
|
||||
dnl Make sure the ONCE macros are available.
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
@@ -98,6 +102,12 @@ if test "x$enable_help" = xno; then
|
||||
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(histories,
|
||||
AS_HELP_STRING([--disable-histories], [Disable search and position histories]))
|
||||
if test "x$enable_histories" = xno; then
|
||||
AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(justify,
|
||||
AS_HELP_STRING([--disable-justify], [Disable justify/unjustify functions]))
|
||||
if test "x$enable_justify" = xno; then
|
||||
@@ -186,6 +196,9 @@ if test "x$enable_tiny" = xyes; then
|
||||
if test "x$enable_help" != xyes; then
|
||||
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
|
||||
fi
|
||||
if test "x$enable_histories" != xyes; then
|
||||
AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.])
|
||||
fi
|
||||
if test "x$enable_justify" != xyes; then
|
||||
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.])
|
||||
fi
|
||||
@@ -649,6 +662,8 @@ AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
|
||||
AS_IF([test "x$enable_libmagic" != "xno"], [
|
||||
AC_CHECK_HEADERS_ONCE([magic.h])
|
||||
AC_CHECK_LIB(magic, magic_open)
|
||||
AC_CHECK_HEADERS_ONCE([zlib.h])
|
||||
AC_CHECK_LIB(z, inflate)
|
||||
])
|
||||
|
||||
# Check for groff html support.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
.\" Hey, EMACS: -*- nroff -*-
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
|
||||
.\" 2009, 2010, 2013, 2014 Free Software Foundation, Inc.
|
||||
.\"
|
||||
@@ -18,8 +20,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANO 1 "version 2.3.3" "April 2014"
|
||||
.TH NANO 1 "version 2.3.5" "June 2014"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
|
||||
@@ -67,18 +68,17 @@ Use bold text instead of reverse video text.
|
||||
Convert typed tabs to spaces.
|
||||
.TP
|
||||
.B \-F (\-\-multibuffer)
|
||||
Enable multiple file buffers, if available.
|
||||
Enable multiple file buffers (if support for them has been compiled in).
|
||||
.TP
|
||||
.B \-G (\-\-locking)
|
||||
Enable vim-style file locking when editing files.
|
||||
.TP
|
||||
.B \-H (\-\-historylog)
|
||||
Log search and replace strings to \fI~/.nano_history\fP, so they can be
|
||||
retrieved in later sessions, if \fInanorc\fP support is available.
|
||||
Log search and replace strings to \fI~/.nano/search_history\fP, so they can be
|
||||
retrieved in later sessions.
|
||||
.TP
|
||||
.B \-I (\-\-ignorercfiles)
|
||||
Don't look at \fISYSCONFDIR/nanorc\fP or \fI~/.nanorc\fP, if
|
||||
\fInanorc\fP support is available.
|
||||
Don't look at the system's \fBnanorc\fP nor at \fB~/.nanorc\fP.
|
||||
.TP
|
||||
.B \-K (\-\-rebindkeypad)
|
||||
Interpret the numeric keypad keys so that they all work properly. You
|
||||
@@ -106,10 +106,11 @@ Tab.
|
||||
.TP
|
||||
.B \-R (\-\-restricted)
|
||||
Restricted mode: don't read or write to any file not specified on the
|
||||
command line; don't read any \fInanorc\fP files; don't allow suspending;
|
||||
command line; don't read any \fInanorc\fP files nor history files;
|
||||
don't allow suspending nor spell checking;
|
||||
don't allow a file to be appended to, prepended to, or saved under a
|
||||
different name if it already has one; don't use backup files nor spell
|
||||
checking. This restricted mode is also accessible by invoking \fBnano\fP
|
||||
different name if it already has one; and don't use backup files.
|
||||
This restricted mode is also accessible by invoking \fBnano\fP
|
||||
with any name beginning with 'r' (e.g. "rnano").
|
||||
.TP
|
||||
.B \-S (\-\-smooth)
|
||||
@@ -131,9 +132,9 @@ Show the current version number and exit.
|
||||
Detect word boundaries more accurately by treating punctuation
|
||||
characters as part of a word.
|
||||
.TP
|
||||
.B \-Y \fIstr\fP (\-\-syntax=\fIstr\fP)
|
||||
Specify a specific syntax highlighting from the \fInanorc\fP to use, if
|
||||
available.
|
||||
.B \-Y \fIname\fP (\-\-syntax=\fIname\fP)
|
||||
Specify the name of the syntax highlighting to use from among the ones
|
||||
defined in the \fInanorc\fP files.
|
||||
.TP
|
||||
.B \-c (\-\-const)
|
||||
Constantly show the cursor position. Note that this overrides \fB\-U\fP.
|
||||
@@ -174,15 +175,15 @@ and will write to the pipe when the user saves the "file". This way
|
||||
\fBgpg\fR without having to write sensitive data to disk first.
|
||||
.TP
|
||||
.B \-o \fIdir\fP (\-\-operatingdir=\fIdir\fP)
|
||||
Set operating directory. Makes \fBnano\fP set up something similar to a
|
||||
chroot.
|
||||
Set the operating directory. This makes \fBnano\fP set up something
|
||||
similar to a chroot.
|
||||
.TP
|
||||
.B \-p (\-\-preserve)
|
||||
Preserve the XON and XOFF sequences (^Q and ^S) so they will be caught
|
||||
by the terminal.
|
||||
.TP
|
||||
.B \-q (\-\-quiet)
|
||||
Do not report errors in the \fInanorc\fP file nor ask them to be
|
||||
Do not report errors in the \fInanorc\fP files nor ask them to be
|
||||
acknowledged by pressing Enter at startup.
|
||||
.TP
|
||||
.B \-r \fInumber\fP (\-\-fill=\fInumber\fP)
|
||||
@@ -200,10 +201,6 @@ Enable alternative spell checker command.
|
||||
Always save changed buffer without prompting. Same as Pico's \fB\-t\fP
|
||||
option.
|
||||
.TP
|
||||
.B \-u (\-\-undo)
|
||||
Enable the experimental generic-purpose undo/redo code. The default undo
|
||||
and redo shortcuts are Meta-U and Meta-E, respectively.
|
||||
.TP
|
||||
.B \-v (\-\-view)
|
||||
View-file (read-only) mode.
|
||||
.TP
|
||||
@@ -231,13 +228,14 @@ Ignored, for compatibility with Pico.
|
||||
|
||||
.SH INITIALIZATION FILE
|
||||
\fBnano\fP will read initialization files in the following order:
|
||||
\fISYSCONFDIR/nanorc\fP, then \fI~/.nanorc\fP. Please see
|
||||
\fBnanorc(5)\fP and the example file \fBnanorc.sample\fP, both of which
|
||||
should be provided with \fBnano\fP.
|
||||
the system's \fBnanorc\fP (if it exists), and then the user's
|
||||
\fB~/.nanorc\fP (if it exists). Please see
|
||||
.BR nanorc (5)
|
||||
for more information on the possible contents of those files.
|
||||
|
||||
.SH NOTES
|
||||
If no alternative spell checker command is specified on the command
|
||||
line or in one of the \fInanorc\fP files, \fBnano\fP will check the
|
||||
line nor in one of the \fInanorc\fP files, \fBnano\fP will check the
|
||||
\fBSPELL\fP environment variable for one.
|
||||
|
||||
In some cases \fBnano\fP will try to dump the buffer into an emergency
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
.\" Hey, EMACS: -*- nroff -*-
|
||||
.\" $Id$
|
||||
.\"
|
||||
.\" Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
|
||||
.\" 2013, 2014 Free Software Foundation, Inc.
|
||||
.\"
|
||||
@@ -18,8 +20,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <http://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.\" $Id$
|
||||
.TH NANORC 5 "version 2.3.3" "May 2014"
|
||||
.TH NANORC 5 "version 2.3.5" "June 2014"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.SH NAME
|
||||
@@ -28,8 +29,8 @@ nanorc \- GNU nano's rcfile
|
||||
The \fInanorc\fP file contains the default settings for \fBnano\fP, a
|
||||
small and friendly editor. The file should be in Unix format, not in
|
||||
DOS or Mac format. During startup, \fBnano\fP will first read the
|
||||
system-wide settings, from \fBSYSCONFDIR/nanorc\fP, and then the
|
||||
user-specific settings, from \fB~/.nanorc\fP.
|
||||
system-wide settings, from \fB/etc/nanorc\fP (the exact path might be
|
||||
different), and then the user-specific settings, from \fB~/.nanorc\fP.
|
||||
|
||||
.SH OPTIONS
|
||||
The configuration file accepts a series of \fBset\fP and \fBunset\fP
|
||||
@@ -52,7 +53,7 @@ The supported commands and arguments are:
|
||||
.TP 3
|
||||
.B set/unset allow_insecure_backup
|
||||
When backing up files, allow the backup to succeed even if its permissions
|
||||
can't be (re)set due to special OS considerations. You should
|
||||
can't be (re)set due to special OS considerations. You should
|
||||
NOT enable this option unless you are sure you need it.
|
||||
.TP
|
||||
.B set/unset autoindent
|
||||
@@ -99,7 +100,7 @@ in the two help lines at the bottom of the screen.
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set/unset historylog
|
||||
Enable the use of \fB~/.nano_history\fP for saving and reading
|
||||
Enable the use of \fB~/.nano/search_history\fP for saving and reading
|
||||
search/replace strings.
|
||||
.TP
|
||||
.B set keycolor \fIfgcolor\fR,\fIbgcolor\fR
|
||||
@@ -168,7 +169,7 @@ keystroke instead of 25.
|
||||
.TP
|
||||
.B set/unset quiet
|
||||
\fBnano\fP will not report errors in the \fInanorc\fP file nor ask them
|
||||
to be acknowledged by pressing Enter at startup. If this is used it
|
||||
to be acknowledged by pressing Enter at startup. If this is used, it
|
||||
should be placed at the top of the file to be fully effective.
|
||||
.TP
|
||||
.B set quotestr "\fIstring\fP"
|
||||
@@ -218,7 +219,7 @@ Allow \fBnano\fP to be suspended.
|
||||
.TP
|
||||
.B set tabsize \fIn\fP
|
||||
Use a tab size of \fIn\fP columns. The value of \fIn\fP must be greater
|
||||
than 0. The default value is 8.
|
||||
than 0. The default value is 8.
|
||||
.TP
|
||||
.B set/unset tabstospaces
|
||||
Convert typed tabs to spaces.
|
||||
@@ -232,9 +233,6 @@ Valid color names for foreground and background are:
|
||||
.BR white , \ black , \ red , \ blue , \ green , \ yellow , \ magenta ", and " cyan .
|
||||
And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
|
||||
.TP
|
||||
.B set/unset undo
|
||||
Enable the experimental generic-purpose undo/redo code.
|
||||
.TP
|
||||
.B set/unset view
|
||||
Disallow file modification.
|
||||
.TP
|
||||
@@ -274,11 +272,11 @@ be compared against the very first line of the file to be edited,
|
||||
to determine whether this syntax should be used for that file.
|
||||
.TP
|
||||
.BR magic " [""\fIregex\fR"" ...]
|
||||
For the currently defined syntax, add one or more regexes which
|
||||
For the currently defined syntax, add one or more regexes which
|
||||
will be compared against the result of querying the \fBmagic\fP
|
||||
database about the file to be edited, to determine whether this
|
||||
syntax should be used for that file. This
|
||||
functionality only works when \fBlibmagic\fP is installed on the
|
||||
functionality only works when \fBlibmagic\fP is installed on the
|
||||
system and will be silently ignored otherwise.
|
||||
.TP
|
||||
.B color \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
|
||||
@@ -328,21 +326,21 @@ context of menu \fImenu\fP (or in all menus where the function exists
|
||||
by using \fBall\fP).
|
||||
.TP
|
||||
.BI unbind " key menu"
|
||||
Unbinds the key \fIkey\fP from the menu named \fImenu\fP (or from all
|
||||
Unbinds the key \fIkey\fP from the menu named \fImenu\fP (or from all
|
||||
menus where it exists by using \fBall\fP).
|
||||
|
||||
.TP
|
||||
The format of \fIkey\fP should be one of:
|
||||
.TP
|
||||
.B ^
|
||||
.B ^
|
||||
followed by an alpha character or the word "Space".
|
||||
Example: ^C
|
||||
.TP
|
||||
.B M-
|
||||
.B M-
|
||||
followed by a printable character or the word "Space".
|
||||
Example: M-C
|
||||
.TP
|
||||
.B F
|
||||
.B F
|
||||
followed by a numeric value from 1 to 16.
|
||||
Example: F10
|
||||
.TP
|
||||
@@ -367,7 +365,8 @@ Inserts a file into the current buffer (or into a new buffer when multibuffer
|
||||
is enabled).
|
||||
.TP
|
||||
.B whereis
|
||||
Searches for text in the current buffer.
|
||||
Searches for text in the current buffer -- or for filenames matching
|
||||
a string in the current list in the file browser.
|
||||
.TP
|
||||
.B searchagain
|
||||
Repeats the last search command.
|
||||
@@ -464,6 +463,9 @@ Goes to the last line of the file.
|
||||
.B gotoline
|
||||
Goes to a specific line (and column if specified).
|
||||
.TP
|
||||
.B gototext
|
||||
Switches from targetting a line number to searching for text.
|
||||
.TP
|
||||
.B findbracket
|
||||
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
|
||||
(pairs) with the one under the cursor.
|
||||
@@ -517,11 +519,22 @@ Shows the previous history entry in the prompt menus (e.g. search).
|
||||
.B nexthistory
|
||||
Shows the next history entry in the prompt menus (e.g. search).
|
||||
.TP
|
||||
.B dontreplace
|
||||
Switches back to searching instead of replacing.
|
||||
.B flipreplace
|
||||
Toggles between searching for something and replacing something.
|
||||
.TP
|
||||
.B gototext
|
||||
Searches for files matching a string in the file browser (reading or writing files).
|
||||
.B flipexecute
|
||||
Toggles between inserting a file and executing a command.
|
||||
.TP
|
||||
.B flipnewbuffer
|
||||
Toggles between inserting into the current buffer and into a new
|
||||
empty buffer.
|
||||
.TP
|
||||
.B tofiles
|
||||
Starts the file browser, allowing to select a file from a list.
|
||||
.TP
|
||||
.B gotodir
|
||||
Goes to a directory to be specified, allowing to browse anywhere
|
||||
in the filesystem.
|
||||
.TP
|
||||
.B dosformat
|
||||
When writing a file, switches to writing a DOS format (CR/LF).
|
||||
@@ -585,7 +598,7 @@ Toggles whether typed tabs will be converted to spaces.
|
||||
Toggles whether a backup will be made of the file to be edited.
|
||||
.TP
|
||||
.B multibuffer
|
||||
Toggles the use of multiple file buffers (if available).
|
||||
Toggles the use of multiple file buffers (if support for them has been compiled in).
|
||||
.TP
|
||||
.B mouse
|
||||
Toggles mouse support.
|
||||
@@ -643,15 +656,17 @@ The 'search for a file' menu in the file browser.
|
||||
The 'go to directory' menu in the file browser.
|
||||
.TP
|
||||
.B all
|
||||
A special name meaning: apply to all menus where this function exists.
|
||||
A special name that encompasses all menus.
|
||||
For \fBbind\fR it means all menus where the specified \fIfunction\fR exists;
|
||||
for \fBunbind\fR it means all menus where the specified \fIkey\fR exists.
|
||||
|
||||
.SH FILES
|
||||
.TP
|
||||
.B SYSCONFDIR/nanorc
|
||||
System-wide configuration file
|
||||
.B /etc/nanorc
|
||||
System-wide configuration file.
|
||||
.TP
|
||||
.B ~/.nanorc
|
||||
Per-user configuration file
|
||||
Per-user configuration file.
|
||||
.SH SEE ALSO
|
||||
.TP
|
||||
\fBnano\fP(1)
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
## Enable vim-style lock-files. This is just to let a vim user know you
|
||||
## are editing a file [s]he is trying to edit and vice versa. There are
|
||||
## no plans to implement vim-style undo state in these files
|
||||
## no plans to implement vim-style undo state in these files.
|
||||
# set locking
|
||||
|
||||
## The opening and closing brackets that can be found by bracket
|
||||
@@ -162,7 +162,7 @@
|
||||
## Convert typed tabs to spaces.
|
||||
# set tabstospaces
|
||||
|
||||
## Save automatically on exit, don't prompt.
|
||||
## Save automatically on exit; don't prompt.
|
||||
# set tempfile
|
||||
|
||||
## Enable the new (EXPERIMENTAL) generic undo code, not just for line
|
||||
@@ -186,7 +186,7 @@
|
||||
|
||||
|
||||
## Paint the interface elements of nano.
|
||||
## This is an example, by default there are no colors.
|
||||
## This is an example; by default there are no colors.
|
||||
# set titlecolor brightwhite,blue
|
||||
# set statuscolor brightwhite,green
|
||||
# set keycolor green
|
||||
|
||||
@@ -9,8 +9,8 @@ icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|lint
|
||||
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backwards|boldtext|casesensitive|const|cut|fill|historylog|locking|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|poslog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|suspend|tabsize|tabstospaces|tempfile|undo|view|wordbounds)\>"
|
||||
icolor yellow "^[[:space:]]*set[[:space:]]+(functioncolor|keycolor||statuscolor|titlecolor)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
|
||||
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|operatingdir|punct|quotestr|speller|statuscolor|titlecolor|whitespace)[[:space:]]+"
|
||||
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6]))[[:space:]]+[[:alpha:]]+[[:space:]]+[[:alpha:]]+[[:space:]]*$"
|
||||
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6]))[[:space:]]+[[:alpha:]]+[[:space:]]*$"
|
||||
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+[[:alpha:]]+[[:space:]]*$"
|
||||
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^|M-)([[:alpha:]]|space|[]]|[0-9_=+{}|;:'\",./<>\?-])|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]*$"
|
||||
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|linter)[[:space:]]+.*$"
|
||||
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|linter|extendsyntax)\>"
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
@c This file has the new style title page commands.
|
||||
@c Run 'makeinfo' rather than 'texinfo-format-buffer'.
|
||||
@smallbook
|
||||
@set EDITION 0.1
|
||||
@set VERSION 2.3.3
|
||||
@set UPDATED May 2014
|
||||
@set EDITION 0.2
|
||||
@set VERSION 2.3.5
|
||||
@set UPDATED June 2014
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @code{nano}
|
||||
@subtitle a small and friendly text editor.
|
||||
@subtitle version 2.3.3
|
||||
@subtitle version 2.3.5
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -148,18 +148,17 @@ Use bold text instead of reverse video text.
|
||||
Convert typed tabs to spaces.
|
||||
|
||||
@item -F, --multibuffer
|
||||
Enable multiple file buffers, if available.
|
||||
Enable multiple file buffers (if support for them has been compiled in).
|
||||
|
||||
@item -G, --locking
|
||||
Enable vim-style file locking when editing files.
|
||||
|
||||
@item -H, --historylog
|
||||
Log search and replace strings to ~/.nano_history, so they can be
|
||||
retrieved in later sessions, if nanorc support is available.
|
||||
Log search and replace strings to ~/.nano/search_history, so they can be
|
||||
retrieved in later sessions.
|
||||
|
||||
@item -I, --ignorercfiles
|
||||
Don't look at SYSCONFDIR/nanorc or ~/.nanorc, if nanorc support is
|
||||
available.
|
||||
Don't look at the system's nanorc file nor at the user's ~/.nanorc.
|
||||
|
||||
@item -K, --rebindkeypad
|
||||
Interpret the numeric keypad keys so that they all work properly. You
|
||||
@@ -176,8 +175,8 @@ Disable automatic conversion of files from DOS/Mac format.
|
||||
Use the blank line below the titlebar as extra editing space.
|
||||
|
||||
@item -P, --poslog
|
||||
Log and later read back the location of the cursor and place it
|
||||
there again.
|
||||
Log for each file the last location of the cursor, and read it
|
||||
back upon reopening the file and place it there again.
|
||||
|
||||
@item -Q <str>, --quotestr=<str>
|
||||
Set the quoting string for justifying. The default value is
|
||||
@@ -191,9 +190,10 @@ Note that @code{\t} above stands for a literal Tab character.
|
||||
|
||||
@item -R, --restricted
|
||||
Restricted mode: don't read or write to any file not specified on the
|
||||
command line; don't read any nanorc files; don't allow suspending; don't
|
||||
command line; don't read any nanorc files nor history files; don't allow
|
||||
suspending nor spell checking; don't
|
||||
allow a file to be appended to, prepended to, or saved under a different
|
||||
name if it already has one; don't use backup files nor spell checking.
|
||||
name if it already has one; and don't use backup files.
|
||||
This restricted mode is also accessible by invoking @code{nano} with
|
||||
any name beginning with 'r' (e.g. "rnano").
|
||||
|
||||
@@ -216,9 +216,9 @@ Show the current version number and exit.
|
||||
Detect word boundaries more accurately by treating punctuation
|
||||
characters as parts of words.
|
||||
|
||||
@item -Y <str>, --syntax=<str>
|
||||
Specify a specific syntax from the nanorc to use for highlighting, if
|
||||
available. See @xref{Syntax Highlighting}, for more info.
|
||||
@item -Y <name>, --syntax=<name>
|
||||
Specify a specific syntax from the nanorc files to use for highlighting.
|
||||
See @xref{Syntax Highlighting}, for more info.
|
||||
|
||||
@item -c, --const
|
||||
Constantly display the cursor position and line number on the statusbar.
|
||||
@@ -264,10 +264,10 @@ a chroot.
|
||||
|
||||
@item -p, --preserve
|
||||
Preserve the ^Q (XON) and ^S (XOFF) sequences so data being sent to the
|
||||
editor can be can be stopped and started.
|
||||
editor can be stopped and started.
|
||||
|
||||
@item -q, --quiet
|
||||
Do not report errors in the nanorc file and ask them to be acknowledged
|
||||
Do not report errors in the nanorc file nor ask them to be acknowledged
|
||||
by pressing Enter at startup.
|
||||
|
||||
@item -r <number>, --fill=<number>
|
||||
@@ -289,10 +289,6 @@ Don't ask whether or not to save the current contents of the file when
|
||||
exiting, assume yes. This is most useful when using @code{nano} as the
|
||||
composer of a mailer program.
|
||||
|
||||
@item -u, --undo
|
||||
Enable the experimental generic-purpose undo/redo code. The default undo
|
||||
and redo shortcuts are Meta-U and Meta-E, respectively.
|
||||
|
||||
@item -v, --view
|
||||
Don't allow the contents of the file to be altered. Note that this
|
||||
option should NOT be used in place of correct file permissions to
|
||||
@@ -495,8 +491,8 @@ toggles the -N (@code{--noconvert}) command line option.
|
||||
toggles the -O (@code{--morespace}) command line option.
|
||||
|
||||
@item Whitespace Display Toggle (Meta-P)
|
||||
toggles whitespace display mode if you have a "whitespace" option in
|
||||
your nanorc. See @xref{Whitespace}, for more info.
|
||||
toggles whitespace-display mode.
|
||||
See @xref{Whitespace}, for more info.
|
||||
|
||||
@item Tabs to Spaces Toggle (Meta-Q)
|
||||
toggles the -E (@code{--tabstospaces}) command line option.
|
||||
@@ -525,8 +521,9 @@ toggles the -$ (@code{--softwrap}) command line option.
|
||||
|
||||
The nanorc files contain the default settings for @code{nano}. They
|
||||
should be in Unix format, not in DOS or Mac format. During startup,
|
||||
@code{nano} will first read the system-wide settings, from /etc/nanorc,
|
||||
and then the user-specific settings, from ~/.nanorc.
|
||||
@code{nano} will first read the system-wide settings, from /etc/nanorc
|
||||
(the exact path might be different), and then the user-specific settings,
|
||||
from ~/.nanorc.
|
||||
|
||||
A nanorc file accepts a series of "set" and "unset" commands, which can
|
||||
be used to configure @code{nano} on startup without using command-line
|
||||
@@ -610,7 +607,8 @@ in the two help lines at the bottom of the screen.
|
||||
See "set titlecolor" for more details.
|
||||
|
||||
@item set/unset historylog
|
||||
Enable ~/.nano_history for saving and reading search/replace strings.
|
||||
Enable the use of ~/.nano/search_history for saving and reading
|
||||
search/replace strings.
|
||||
|
||||
@item set keycolor fgcolor,bgcolor
|
||||
Specify the color combination to use for the shortcut key combos
|
||||
@@ -747,9 +745,6 @@ Valid color names for foreground and background are:
|
||||
white, black, red, blue, green, yellow, magenta, and cyan.
|
||||
And either "fgcolor" or ",bgcolor" may be left out.
|
||||
|
||||
@item set/unset undo
|
||||
Enable the experimental generic-purpose undo/redo code.
|
||||
|
||||
@item set/unset view
|
||||
Disallow file modification.
|
||||
|
||||
@@ -851,7 +846,7 @@ Rebinds @code{key} to @code{function} in the context of @code{menu}
|
||||
(or in all menus where the function exists by using @code{all}).
|
||||
|
||||
@item unbind key menu
|
||||
Unbinds @code{key} from the specified @code{menu}
|
||||
Unbinds @code{key} from @code{menu}
|
||||
(or from all menus where it exists by using @code{all}).
|
||||
|
||||
@end table
|
||||
@@ -895,7 +890,8 @@ Inserts a file into the current buffer (or into a new buffer when multibuffer
|
||||
is enabled).
|
||||
|
||||
@item whereis
|
||||
Searches for text in the current buffer.
|
||||
Searches for text in the current buffer -- or for filenames matching
|
||||
a string in the current list in the file browser
|
||||
|
||||
@item searchagain
|
||||
Repeats the last search command.
|
||||
@@ -992,6 +988,9 @@ Goes to the last line of the file.
|
||||
@item gotoline
|
||||
Goes to a specific line (and column if specified).
|
||||
|
||||
@item gototext
|
||||
Switches from targetting a line number to searching for text.
|
||||
|
||||
@item findbracket
|
||||
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
|
||||
(pairs) with the one under the cursor.
|
||||
@@ -1045,11 +1044,15 @@ Shows the previous history entry in the prompt menus (e.g. search).
|
||||
@item nexthistory
|
||||
Shows the next history entry in the prompt menus (e.g. search).
|
||||
|
||||
@item dontreplace
|
||||
Switches back to searching instead of replacing.
|
||||
@item flipreplace
|
||||
Toggles between searching for something and replacing something.
|
||||
|
||||
@item gototext
|
||||
Searches for files matching a string in the file browser (reading or writing files).
|
||||
@item flipexecute
|
||||
Toggles between inserting a file and executing a command.
|
||||
|
||||
@item flipnewbuffer
|
||||
Toggles between inserting into the current buffer and into a new
|
||||
empty buffer.
|
||||
|
||||
@item dosformat
|
||||
When writing a file, switches to writing a DOS format (CR/LF).
|
||||
@@ -1066,6 +1069,13 @@ When writing a file, 'prepends' (writes at the beginning) instead of overwriting
|
||||
@item backup
|
||||
When writing a file, creates a backup of the current file.
|
||||
|
||||
@item tofiles
|
||||
Starts the file browser, allowing to select a file from a list.
|
||||
|
||||
@item gotodir
|
||||
Goes to a directory to be specified, allowing to browse anywhere
|
||||
in the filesystem.
|
||||
|
||||
@item firstfile
|
||||
Goes to the first file when using the file browser (reading or writing files).
|
||||
|
||||
@@ -1173,7 +1183,9 @@ The 'search for a file' menu in the file browser.
|
||||
The 'go to directory' menu in the file browser.
|
||||
|
||||
@item all
|
||||
A special name meaning: apply to all menus where this function exists.
|
||||
A special name that encompasses all menus. For @code{bind} it means
|
||||
all menus where the specified @code{function} exists; for @code{unbind}
|
||||
it means all menus where the specified @code{key} exists.
|
||||
@end table
|
||||
|
||||
|
||||
@@ -1269,7 +1281,8 @@ The possible options to @code{./configure} are:
|
||||
Disable the mini file browser when reading or writing files.
|
||||
|
||||
@item --disable-color
|
||||
Disable support for syntax coloring of files using the nanorc file.
|
||||
Disable support for the syntax coloring of files. This also eliminates
|
||||
the -Y command-line option, which chooses a specific syntax.
|
||||
|
||||
@item --disable-extra
|
||||
Disable extra features. At the moment, this is just easter-egg-type
|
||||
@@ -1280,6 +1293,13 @@ Disable the help function. Doing this makes the binary much smaller,
|
||||
but makes it difficult for new users to learn more than very basic
|
||||
things about using the editor.
|
||||
|
||||
@item --disable-histories
|
||||
Disable the code for the handling of the history files: the search and
|
||||
replace strings that were used, and the cursor position at which each
|
||||
file was closed. This also eliminates the -H and -P command-line
|
||||
options, which switch on the logging of search/replace strings and
|
||||
cursor positions.
|
||||
|
||||
@item --disable-justify
|
||||
Disable the justify and unjustify functions.
|
||||
|
||||
@@ -1294,13 +1314,17 @@ command-line option, which enables the mouse functionality.
|
||||
|
||||
@item --disable-multibuffer
|
||||
Disable support for opening multiple files at a time and switching
|
||||
between them on the fly.
|
||||
between them on the fly. This also eliminates the -F command-line
|
||||
option, which switches the use of multiple file buffers on.
|
||||
|
||||
@item --disable-nanorc
|
||||
Disable support for reading the nanorc files at startup. With such
|
||||
support, you can store custom settings in a system-wide and a per-user
|
||||
nanorc file rather than having to pass command-line options to get
|
||||
the desired behavior. See @xref{Nanorc Files}, for more info.
|
||||
Disabling this also eliminates the -I and -q command-line options;
|
||||
the first inhibits the reading of nanorcfiles, and the second
|
||||
suppresses warnings about errors in those files.
|
||||
|
||||
@item --disable-operatingdir
|
||||
Disable setting the operating directory. This also eliminates the -o
|
||||
@@ -1320,14 +1344,16 @@ command-line option, which enables long-line wrapping.
|
||||
@item --enable-tiny
|
||||
This option disables all the above. It also disables some of the larger
|
||||
internals of the editor, like the marking code and the cut-to-end-of-line
|
||||
code. It also disables the function toggles.
|
||||
code. It also disables the function toggles. By using the enabling
|
||||
counterpart of the above options together with --enable-tiny, specific
|
||||
features can be switched back on.
|
||||
|
||||
@item --enable-debug
|
||||
Enable support for runtime debug output. This can get pretty messy, so
|
||||
chances are you only want this feature when you're working on the nano source.
|
||||
|
||||
@item --disable-nls
|
||||
Disables Native Language support. This will disable use of the
|
||||
Disables Native Language support. This will disable the use of any
|
||||
available GNU @code{nano} translations.
|
||||
|
||||
@item --disable-wrapping-as-root
|
||||
|
||||
@@ -6,10 +6,10 @@ Summary : Pico editor clone with enhancements
|
||||
Name : %{name}
|
||||
Version : %{version}
|
||||
Release : %{release}
|
||||
License : GPL
|
||||
License : GPLv3+
|
||||
Group : Applications/Editors
|
||||
URL : http://www.nano-editor.org/
|
||||
Source : http://www.nano-editor.org/dist/v2.0/%{name}-%{version}.tar.gz
|
||||
Source : http://www.nano-editor.org/dist/v2.3/%{name}-%{version}.tar.gz
|
||||
BuildRoot : %{_tmppath}/%{name}-%{version}-root
|
||||
BuildRequires : autoconf, automake, gettext-devel, ncurses-devel
|
||||
|
||||
@@ -25,12 +25,13 @@ Pico text editor while also offering a few enhancements.
|
||||
make
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
make DESTDIR="%{buildroot}" install
|
||||
#ln -s nano %{buildroot}%{_bindir}/pico
|
||||
rm -f %{buildroot}%{_infodir}/dir
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc AUTHORS BUGS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/nanorc.sample
|
||||
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/nanorc.sample
|
||||
%{_bindir}/*
|
||||
%{_mandir}/man*/*
|
||||
%{_mandir}/fr/man*/*
|
||||
|
||||
899
po/nano.pot
899
po/nano.pot
File diff suppressed because it is too large
Load Diff
906
po/pt_BR.po
906
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
909
po/zh_CN.po
909
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
908
po/zh_TW.po
908
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,5 @@
|
||||
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\"
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
bin_PROGRAMS = nano
|
||||
nano_SOURCES = browser.c \
|
||||
chars.c \
|
||||
|
||||
521
src/browser.c
521
src/browser.c
@@ -50,9 +50,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
{
|
||||
char *retval = NULL;
|
||||
int kbinput;
|
||||
bool meta_key, func_key, old_const_update = ISSET(CONST_UPDATE);
|
||||
bool abort = FALSE;
|
||||
/* Whether we should abort the file browser. */
|
||||
bool old_const_update = ISSET(CONST_UPDATE);
|
||||
char *prev_dir = NULL;
|
||||
/* The directory we were in, if any, before backing up via
|
||||
* browsing to "..". */
|
||||
@@ -60,14 +58,12 @@ char *do_browser(char *path, DIR *dir)
|
||||
/* The last answer the user typed at the statusbar prompt. */
|
||||
size_t old_selected;
|
||||
/* The selected file we had before the current selected file. */
|
||||
const sc *s;
|
||||
const subnfunc *f;
|
||||
functionptrtype func;
|
||||
/* The function of the key the user typed in. */
|
||||
|
||||
curs_set(0);
|
||||
blank_statusbar();
|
||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||
currmenu = MBROWSER;
|
||||
#endif
|
||||
bottombars(MBROWSER);
|
||||
wnoutrefresh(bottomwin);
|
||||
|
||||
@@ -108,7 +104,7 @@ char *do_browser(char *path, DIR *dir)
|
||||
|
||||
titlebar(path);
|
||||
|
||||
while (!abort) {
|
||||
while (TRUE) {
|
||||
struct stat st;
|
||||
int i;
|
||||
size_t fileline = selected / width;
|
||||
@@ -124,240 +120,220 @@ char *do_browser(char *path, DIR *dir)
|
||||
|
||||
old_selected = selected;
|
||||
|
||||
kbinput = get_kbinput(edit, &meta_key, &func_key);
|
||||
kbinput = get_kbinput(edit);
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
if (kbinput == KEY_MOUSE) {
|
||||
if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
int mouse_x, mouse_y;
|
||||
|
||||
/* We can click on the edit window to select a
|
||||
* filename. */
|
||||
if (get_mouseinput(&mouse_x, &mouse_y, TRUE) == 0 &&
|
||||
wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
|
||||
/* longest is the width of each column. There
|
||||
* are two spaces between each column. */
|
||||
selected = (fileline / editwinrows) *
|
||||
/* We can click on the edit window to select a
|
||||
* filename. */
|
||||
if (get_mouseinput(&mouse_x, &mouse_y, TRUE) == 0 &&
|
||||
wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
|
||||
/* longest is the width of each column. There
|
||||
* are two spaces between each column. */
|
||||
selected = (fileline / editwinrows) *
|
||||
(editwinrows * width) + (mouse_y *
|
||||
width) + (mouse_x / (longest + 2));
|
||||
|
||||
/* If they clicked beyond the end of a row,
|
||||
* select the filename at the end of that
|
||||
* row. */
|
||||
if (mouse_x > width * (longest + 2))
|
||||
selected--;
|
||||
/* If they clicked beyond the end of a row,
|
||||
* select the filename at the end of that
|
||||
* row. */
|
||||
if (mouse_x > width * (longest + 2))
|
||||
selected--;
|
||||
|
||||
/* If we're off the screen, select the last
|
||||
* filename. */
|
||||
if (selected > filelist_len - 1)
|
||||
selected = filelist_len - 1;
|
||||
/* If we're off the screen, select the last
|
||||
* filename. */
|
||||
if (selected > filelist_len - 1)
|
||||
selected = filelist_len - 1;
|
||||
|
||||
/* If we selected the same filename as last
|
||||
* time, put back the Enter key so that it's
|
||||
* read in. */
|
||||
if (old_selected == selected)
|
||||
unget_kbinput(sc_seq_or(do_enter_void, 0), FALSE, FALSE);
|
||||
}
|
||||
/* If we selected the same filename as last
|
||||
* time, put back the Enter key so that it's
|
||||
* read in. */
|
||||
if (old_selected == selected)
|
||||
unget_kbinput(sc_seq_or(do_enter_void, 0), FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
#endif /* !DISABLE_MOUSE */
|
||||
|
||||
parse_browser_input(&kbinput, &meta_key);
|
||||
s = get_shortcut(MBROWSER, &kbinput, &meta_key);
|
||||
if (!s)
|
||||
continue;
|
||||
f = sctofunc((sc *) s);
|
||||
if (!f)
|
||||
break;
|
||||
func = parse_browser_input(&kbinput);
|
||||
|
||||
if (f->scfunc == total_refresh) {
|
||||
total_redraw();
|
||||
} else if (f->scfunc == do_help_void) {
|
||||
if (func == total_refresh) {
|
||||
total_redraw();
|
||||
} else if (func == do_help_void) {
|
||||
#ifndef DISABLE_HELP
|
||||
do_help_void();
|
||||
curs_set(0);
|
||||
#else
|
||||
nano_disabled_msg();
|
||||
#endif
|
||||
} else if (func == do_search) {
|
||||
/* Search for a filename. */
|
||||
} else if (f->scfunc == do_search) {
|
||||
curs_set(1);
|
||||
do_filesearch();
|
||||
curs_set(0);
|
||||
curs_set(1);
|
||||
do_filesearch();
|
||||
curs_set(0);
|
||||
} else if (func == do_research) {
|
||||
/* Search for another filename. */
|
||||
} else if (f->scfunc == do_research) {
|
||||
do_fileresearch();
|
||||
} else if (f->scfunc == do_page_up) {
|
||||
if (selected >= (editwinrows + fileline % editwinrows) *
|
||||
width)
|
||||
selected -= (editwinrows + fileline % editwinrows) *
|
||||
width;
|
||||
else
|
||||
selected = 0;
|
||||
} else if (f->scfunc == do_page_down) {
|
||||
selected += (editwinrows - fileline % editwinrows) *
|
||||
width;
|
||||
if (selected > filelist_len - 1)
|
||||
selected = filelist_len - 1;
|
||||
} else if (f->scfunc == do_first_file) {
|
||||
if (meta_key)
|
||||
selected = 0;
|
||||
} else if (f->scfunc == do_last_file) {
|
||||
if (meta_key)
|
||||
selected = filelist_len - 1;
|
||||
do_fileresearch();
|
||||
} else if (func == do_page_up) {
|
||||
if (selected >= (editwinrows + fileline % editwinrows) * width)
|
||||
selected -= (editwinrows + fileline % editwinrows) * width;
|
||||
else
|
||||
selected = 0;
|
||||
} else if (func == do_page_down) {
|
||||
selected += (editwinrows - fileline % editwinrows) * width;
|
||||
if (selected > filelist_len - 1)
|
||||
selected = filelist_len - 1;
|
||||
} else if (func == do_first_file) {
|
||||
selected = 0;
|
||||
} else if (func == do_last_file) {
|
||||
selected = filelist_len - 1;
|
||||
} else if (func == goto_dir_void) {
|
||||
/* Go to a specific directory. */
|
||||
} else if (f->scfunc == goto_dir_void) {
|
||||
curs_set(1);
|
||||
|
||||
i = do_prompt(TRUE,
|
||||
curs_set(1);
|
||||
i = do_prompt(TRUE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
FALSE,
|
||||
#endif
|
||||
MGOTODIR, ans,
|
||||
&meta_key, &func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
#endif
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
browser_refresh, _("Go To Directory"));
|
||||
|
||||
curs_set(0);
|
||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||
currmenu = MBROWSER;
|
||||
#endif
|
||||
bottombars(MBROWSER);
|
||||
curs_set(0);
|
||||
currmenu = MBROWSER;
|
||||
bottombars(MBROWSER);
|
||||
|
||||
/* If the directory begins with a newline (i.e. an
|
||||
* encoded null), treat it as though it's blank. */
|
||||
if (i < 0 || *answer == '\n') {
|
||||
/* We canceled. Indicate that on the statusbar, and
|
||||
* blank out ans, since we're done with it. */
|
||||
statusbar(_("Cancelled"));
|
||||
ans = mallocstrcpy(ans, "");
|
||||
continue;
|
||||
} else if (i != 0) {
|
||||
/* Put back the "Go to Directory" key and save
|
||||
* answer in ans, so that the file list is displayed
|
||||
* again, the prompt is displayed again, and what we
|
||||
* typed before at the prompt is displayed again. */
|
||||
unget_kbinput(sc_seq_or(do_gotolinecolumn_void, 0), FALSE, FALSE);
|
||||
ans = mallocstrcpy(ans, answer);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We have a directory. Blank out ans, since we're done
|
||||
* with it. */
|
||||
/* If the directory begins with a newline (i.e. an
|
||||
* encoded null), treat it as though it's blank. */
|
||||
if (i < 0 || *answer == '\n') {
|
||||
/* We canceled. Indicate that on the statusbar, and
|
||||
* blank out ans, since we're done with it. */
|
||||
statusbar(_("Cancelled"));
|
||||
ans = mallocstrcpy(ans, "");
|
||||
continue;
|
||||
} else if (i != 0) {
|
||||
/* Put back the "Go to Directory" key and save
|
||||
* answer in ans, so that the file list is displayed
|
||||
* again, the prompt is displayed again, and what we
|
||||
* typed before at the prompt is displayed again. */
|
||||
unget_kbinput(sc_seq_or(do_gotolinecolumn_void, 0), FALSE, FALSE);
|
||||
ans = mallocstrcpy(ans, answer);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Convert newlines to nulls, just before we go to the
|
||||
* directory. */
|
||||
sunder(answer);
|
||||
align(&answer);
|
||||
/* We have a directory. Blank out ans, since we're done
|
||||
* with it. */
|
||||
ans = mallocstrcpy(ans, "");
|
||||
|
||||
new_path = real_dir_from_tilde(answer);
|
||||
/* Convert newlines to nulls, just before we go to the
|
||||
* directory. */
|
||||
sunder(answer);
|
||||
align(&answer);
|
||||
|
||||
if (new_path[0] != '/') {
|
||||
new_path = charealloc(new_path, strlen(path) +
|
||||
strlen(answer) + 1);
|
||||
sprintf(new_path, "%s%s", path, answer);
|
||||
}
|
||||
new_path = real_dir_from_tilde(answer);
|
||||
|
||||
if (new_path[0] != '/') {
|
||||
new_path = charealloc(new_path, strlen(path) +
|
||||
strlen(answer) + 1);
|
||||
sprintf(new_path, "%s%s", path, answer);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
if (check_operating_dir(new_path, FALSE)) {
|
||||
statusbar(
|
||||
_("Can't go outside of %s in restricted mode"),
|
||||
operating_dir);
|
||||
free(new_path);
|
||||
continue;
|
||||
}
|
||||
if (check_operating_dir(new_path, FALSE)) {
|
||||
statusbar(_("Can't go outside of %s in restricted mode"),
|
||||
operating_dir);
|
||||
free(new_path);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
dir = opendir(new_path);
|
||||
if (dir == NULL) {
|
||||
/* We can't open this directory for some reason.
|
||||
* Complain. */
|
||||
statusbar(_("Error reading %s: %s"), answer,
|
||||
strerror(errno));
|
||||
beep();
|
||||
free(new_path);
|
||||
continue;
|
||||
}
|
||||
dir = opendir(new_path);
|
||||
if (dir == NULL) {
|
||||
/* We can't open this directory for some reason.
|
||||
* Complain. */
|
||||
statusbar(_("Error reading %s: %s"), answer,
|
||||
strerror(errno));
|
||||
beep();
|
||||
free(new_path);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Start over again with the new path value. */
|
||||
free(path);
|
||||
path = new_path;
|
||||
goto change_browser_directory;
|
||||
} else if (f->scfunc == do_up_void) {
|
||||
if (selected >= width)
|
||||
selected -= width;
|
||||
} else if (f->scfunc == do_left) {
|
||||
if (selected > 0)
|
||||
selected--;
|
||||
} else if (f->scfunc == do_down_void) {
|
||||
if (selected + width <= filelist_len - 1)
|
||||
selected += width;
|
||||
} else if (f->scfunc == do_right) {
|
||||
if (selected < filelist_len - 1)
|
||||
selected++;
|
||||
} else if (f->scfunc == do_enter_void) {
|
||||
/* We can't move up from "/". */
|
||||
if (strcmp(filelist[selected], "/..") == 0) {
|
||||
statusbar(_("Can't move up a directory"));
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
/* Start over again with the new path value. */
|
||||
free(path);
|
||||
path = new_path;
|
||||
goto change_browser_directory;
|
||||
} else if (func == do_up_void) {
|
||||
if (selected >= width)
|
||||
selected -= width;
|
||||
} else if (func == do_left) {
|
||||
if (selected > 0)
|
||||
selected--;
|
||||
} else if (func == do_down_void) {
|
||||
if (selected + width <= filelist_len - 1)
|
||||
selected += width;
|
||||
} else if (func == do_right) {
|
||||
if (selected < filelist_len - 1)
|
||||
selected++;
|
||||
} else if (func == do_enter_void) {
|
||||
/* We can't move up from "/". */
|
||||
if (strcmp(filelist[selected], "/..") == 0) {
|
||||
statusbar(_("Can't move up a directory"));
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
/* Note: The selected file can be outside the operating
|
||||
* directory if it's ".." or if it's a symlink to a
|
||||
* directory outside the operating directory. */
|
||||
if (check_operating_dir(filelist[selected], FALSE)) {
|
||||
statusbar(
|
||||
_("Can't go outside of %s in restricted mode"),
|
||||
operating_dir);
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
/* Note: The selected file can be outside the operating
|
||||
* directory if it's ".." or if it's a symlink to a
|
||||
* directory outside the operating directory. */
|
||||
if (check_operating_dir(filelist[selected], FALSE)) {
|
||||
statusbar(_("Can't go outside of %s in restricted mode"),
|
||||
operating_dir);
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (stat(filelist[selected], &st) == -1) {
|
||||
/* We can't open this file for some reason.
|
||||
* Complain. */
|
||||
statusbar(_("Error reading %s: %s"),
|
||||
filelist[selected], strerror(errno));
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
if (stat(filelist[selected], &st) == -1) {
|
||||
/* We can't open this file for some reason.
|
||||
* Complain. */
|
||||
statusbar(_("Error reading %s: %s"),
|
||||
filelist[selected], strerror(errno));
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If we've successfully opened a file, we're done, so
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
/* We've successfully opened a file, we're done, so
|
||||
* get out. */
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
retval = mallocstrcpy(NULL, filelist[selected]);
|
||||
abort = TRUE;
|
||||
continue;
|
||||
/* If we've successfully opened a directory, and it's
|
||||
* "..", save the current directory in prev_dir, so that
|
||||
* we can select it later. */
|
||||
} else if (strcmp(tail(filelist[selected]), "..") == 0)
|
||||
prev_dir = mallocstrcpy(NULL,
|
||||
striponedir(filelist[selected]));
|
||||
retval = mallocstrcpy(NULL, filelist[selected]);
|
||||
break;
|
||||
} else if (strcmp(tail(filelist[selected]), "..") == 0)
|
||||
/* We've successfully opened the parent directory,
|
||||
* save the current directory in prev_dir, so that
|
||||
* we can easily return to it by hitting Enter. */
|
||||
prev_dir = mallocstrcpy(NULL, striponedir(filelist[selected]));
|
||||
|
||||
dir = opendir(filelist[selected]);
|
||||
if (dir == NULL) {
|
||||
/* We can't open this directory for some reason.
|
||||
* Complain. */
|
||||
statusbar(_("Error reading %s: %s"),
|
||||
filelist[selected], strerror(errno));
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
dir = opendir(filelist[selected]);
|
||||
if (dir == NULL) {
|
||||
/* We can't open this directory for some reason.
|
||||
* Complain. */
|
||||
statusbar(_("Error reading %s: %s"),
|
||||
filelist[selected], strerror(errno));
|
||||
beep();
|
||||
continue;
|
||||
}
|
||||
|
||||
path = mallocstrcpy(path, filelist[selected]);
|
||||
path = mallocstrcpy(path, filelist[selected]);
|
||||
|
||||
/* Start over again with the new path value. */
|
||||
goto change_browser_directory;
|
||||
/* Abort the file browser. */
|
||||
} else if (f->scfunc == do_exit) {
|
||||
abort = TRUE;
|
||||
/* Start over again with the new path value. */
|
||||
goto change_browser_directory;
|
||||
} else if (func == do_exit) {
|
||||
/* Exit from the file browser. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
titlebar(NULL);
|
||||
@@ -461,7 +437,7 @@ void browser_init(const char *path, DIR *dir)
|
||||
|
||||
/* Don't show the "." entry. */
|
||||
if (strcmp(nextdir->d_name, ".") == 0)
|
||||
continue;
|
||||
continue;
|
||||
|
||||
d_len = strlenpt(nextdir->d_name);
|
||||
if (d_len > longest)
|
||||
@@ -488,7 +464,7 @@ void browser_init(const char *path, DIR *dir)
|
||||
while ((nextdir = readdir(dir)) != NULL && i < filelist_len) {
|
||||
/* Don't show the "." entry. */
|
||||
if (strcmp(nextdir->d_name, ".") == 0)
|
||||
continue;
|
||||
continue;
|
||||
|
||||
filelist[i] = charalloc(path_len + strlen(nextdir->d_name) + 1);
|
||||
sprintf(filelist[i], "%s%s", path, nextdir->d_name);
|
||||
@@ -540,46 +516,33 @@ void browser_init(const char *path, DIR *dir)
|
||||
width = longest;
|
||||
}
|
||||
|
||||
/* Determine the shortcut key corresponding to the values of kbinput
|
||||
* (the key itself) and meta_key (whether the key is a meta sequence).
|
||||
* Also convert certain non-shortcut keys into their corresponding
|
||||
* shortcut keys. */
|
||||
void parse_browser_input(int *kbinput, bool *meta_key)
|
||||
/* Return the function that is bound to the given key, accepting certain
|
||||
* plain characters too, for compatibility with Pico. */
|
||||
functionptrtype parse_browser_input(int *kbinput)
|
||||
{
|
||||
get_shortcut(MBROWSER, kbinput, meta_key);
|
||||
|
||||
/* Pico compatibility. */
|
||||
if (!*meta_key) {
|
||||
if (!meta_key) {
|
||||
switch (*kbinput) {
|
||||
case ' ':
|
||||
*kbinput = KEY_NPAGE;
|
||||
break;
|
||||
return do_page_down;
|
||||
case '-':
|
||||
*kbinput = KEY_PPAGE;
|
||||
break;
|
||||
return do_page_up;
|
||||
case '?':
|
||||
#ifndef DISABLE_HELP
|
||||
*kbinput = sc_seq_or(do_help_void, 0);
|
||||
#endif
|
||||
break;
|
||||
return do_help_void;
|
||||
case 'E':
|
||||
case 'e':
|
||||
*kbinput = sc_seq_or(do_exit, 0);
|
||||
break;
|
||||
return do_exit;
|
||||
case 'G':
|
||||
case 'g':
|
||||
*kbinput = sc_seq_or(goto_dir_void, 0);
|
||||
break;
|
||||
return goto_dir_void;
|
||||
case 'S':
|
||||
case 's':
|
||||
*kbinput = sc_seq_or(do_enter_void, 0);
|
||||
break;
|
||||
return do_enter_void;
|
||||
case 'W':
|
||||
case 'w':
|
||||
*kbinput = sc_seq_or(do_search, 0);
|
||||
break;
|
||||
return do_search;
|
||||
}
|
||||
}
|
||||
return func_from_key(kbinput);
|
||||
}
|
||||
|
||||
/* Set width to the number of files that we can display per line, if
|
||||
@@ -759,8 +722,6 @@ int filesearch_init(void)
|
||||
{
|
||||
int i = 0;
|
||||
char *buf;
|
||||
bool meta_key, func_key;
|
||||
const sc *s;
|
||||
static char *backupstring = NULL;
|
||||
/* The search string we'll be using. */
|
||||
|
||||
@@ -793,23 +754,10 @@ int filesearch_init(void)
|
||||
TRUE,
|
||||
#endif
|
||||
MWHEREISFILE, backupstring,
|
||||
&meta_key, &func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
&search_history,
|
||||
#endif
|
||||
browser_refresh, "%s%s%s%s%s", _("Search"),
|
||||
#ifndef NANO_TINY
|
||||
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") :
|
||||
#endif
|
||||
"",
|
||||
#ifdef HAVE_REGEX_H
|
||||
ISSET(USE_REGEXP) ? _(" [Regexp]") :
|
||||
#endif
|
||||
"",
|
||||
#ifndef NANO_TINY
|
||||
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") :
|
||||
#endif
|
||||
"", buf);
|
||||
browser_refresh, "%s%s", _("Search"), buf);
|
||||
|
||||
/* Release buf now that we don't need it anymore. */
|
||||
free(buf);
|
||||
@@ -822,36 +770,6 @@ int filesearch_init(void)
|
||||
*answer == '\0')) {
|
||||
statusbar(_("Cancelled"));
|
||||
return -1;
|
||||
} else {
|
||||
s = get_shortcut(MBROWSER, &i, &meta_key);
|
||||
if (i == -2 || i == 0) {
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Use last_search if answer is an empty string, or
|
||||
* answer if it isn't. */
|
||||
if (ISSET(USE_REGEXP) && !regexp_init((i == -2) ?
|
||||
last_search : answer))
|
||||
return -1;
|
||||
#endif
|
||||
} else
|
||||
#ifndef NANO_TINY
|
||||
if (s && s->scfunc == case_sens_void) {
|
||||
TOGGLE(CASE_SENSITIVE);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
} else if (s && s->scfunc == backwards_void) {
|
||||
TOGGLE(BACKWARDS_SEARCH);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
} else
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (s && s->scfunc == regexp_void) {
|
||||
TOGGLE(USE_REGEXP);
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
} else
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -870,11 +788,6 @@ bool findnextfile(bool no_sameline, size_t begin, const char *needle)
|
||||
/* The filename we display, minus the path. */
|
||||
const char *rev_start = filetail, *found = NULL;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
rev_start += strlen(rev_start);
|
||||
#endif
|
||||
|
||||
/* Look for needle in the current filename we're searching. */
|
||||
while (TRUE) {
|
||||
found = strstrwrapper(filetail, needle, rev_start);
|
||||
@@ -891,27 +804,14 @@ bool findnextfile(bool no_sameline, size_t begin, const char *needle)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Move to the previous or next filename in the list. If we've
|
||||
* reached the start or end of the list, wrap around. */
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(BACKWARDS_SEARCH)) {
|
||||
if (currselected > 0)
|
||||
currselected--;
|
||||
else {
|
||||
currselected = filelist_len - 1;
|
||||
statusbar(_("Search Wrapped"));
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
if (currselected < filelist_len - 1)
|
||||
currselected++;
|
||||
else {
|
||||
currselected = 0;
|
||||
statusbar(_("Search Wrapped"));
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
/* Move to the next filename in the list. If we've reached the
|
||||
* end of the list, wrap around. */
|
||||
if (currselected < filelist_len - 1)
|
||||
currselected++;
|
||||
else {
|
||||
currselected = 0;
|
||||
statusbar(_("Search Wrapped"));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We've reached the original starting file. */
|
||||
if (currselected == begin)
|
||||
@@ -920,10 +820,6 @@ bool findnextfile(bool no_sameline, size_t begin, const char *needle)
|
||||
filetail = tail(filelist[currselected]);
|
||||
|
||||
rev_start = filetail;
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(BACKWARDS_SEARCH))
|
||||
rev_start += strlen(rev_start);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We've definitely found something. */
|
||||
@@ -940,37 +836,28 @@ void findnextfile_wrap_reset(void)
|
||||
}
|
||||
|
||||
/* Abort the current filename search. Clean up by setting the current
|
||||
* shortcut list to the browser shortcut list, displaying it, and
|
||||
* decompiling the compiled regular expression we used in the last
|
||||
* search, if any. */
|
||||
* shortcut list to the browser shortcut list, and displaying it. */
|
||||
void filesearch_abort(void)
|
||||
{
|
||||
currmenu = MBROWSER;
|
||||
bottombars(MBROWSER);
|
||||
#ifdef HAVE_REGEX_H
|
||||
regexp_cleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Search for a filename. */
|
||||
void do_filesearch(void)
|
||||
{
|
||||
size_t begin = selected;
|
||||
int i;
|
||||
bool didfind;
|
||||
|
||||
i = filesearch_init();
|
||||
if (i == -1) /* Cancel, blank search string, or regcomp()
|
||||
* failed. */
|
||||
filesearch_abort();
|
||||
#if !defined(NANO_TINY) || defined(HAVE_REGEX_H)
|
||||
else if (i == 1) /* Case Sensitive, Backwards, or Regexp search
|
||||
* toggle. */
|
||||
do_filesearch();
|
||||
#endif
|
||||
UNSET(CASE_SENSITIVE);
|
||||
UNSET(USE_REGEXP);
|
||||
UNSET(BACKWARDS_SEARCH);
|
||||
|
||||
if (i != 0)
|
||||
if (filesearch_init() != 0) {
|
||||
/* Cancelled or a blank search string. */
|
||||
filesearch_abort();
|
||||
return;
|
||||
}
|
||||
|
||||
/* If answer is now "", copy last_search into answer. */
|
||||
if (*answer == '\0')
|
||||
@@ -978,7 +865,7 @@ void do_filesearch(void)
|
||||
else
|
||||
last_search = mallocstrcpy(last_search, answer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
/* If answer is not "", add this search string to the search history
|
||||
* list. */
|
||||
if (answer[0] != '\0')
|
||||
@@ -1011,12 +898,6 @@ void do_fileresearch(void)
|
||||
search_init_globals();
|
||||
|
||||
if (last_search[0] != '\0') {
|
||||
#ifdef HAVE_REGEX_H
|
||||
/* Since answer is "", use last_search! */
|
||||
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
|
||||
return;
|
||||
#endif
|
||||
|
||||
findnextfile_wrap_reset();
|
||||
didfind = findnextfile(FALSE, begin, answer);
|
||||
|
||||
|
||||
14
src/color.c
14
src/color.c
@@ -155,18 +155,15 @@ void color_update(void)
|
||||
colortype *tmpcolor, *defcolor = NULL;
|
||||
regexlisttype *e;
|
||||
|
||||
/* Var magicstring will stay NULL if we fail to get a magic result. */
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
const char *magicstring = NULL;
|
||||
magic_t cookie = NULL;
|
||||
struct stat fileinfo;
|
||||
#endif
|
||||
|
||||
assert(openfile != NULL);
|
||||
|
||||
openfile->syntax = NULL;
|
||||
openfile->colorstrings = NULL;
|
||||
|
||||
/* If the rcfiles were not read, or contained no syntaxes, get out. */
|
||||
if (syntaxes == NULL)
|
||||
return;
|
||||
|
||||
/* If we specified a syntax override string, use it. */
|
||||
if (syntaxstr != NULL) {
|
||||
/* If the syntax override is "none", it's the same as not having
|
||||
@@ -262,6 +259,9 @@ void color_update(void)
|
||||
#ifdef HAVE_LIBMAGIC
|
||||
/* Check magic if we don't have an answer yet. */
|
||||
if (openfile->colorstrings == NULL) {
|
||||
struct stat fileinfo;
|
||||
magic_t cookie = NULL;
|
||||
const char *magicstring = NULL;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "No result from headerline either, trying libmagic...\n");
|
||||
#endif
|
||||
|
||||
30
src/cut.c
30
src/cut.c
@@ -37,6 +37,12 @@ void cutbuffer_reset(void)
|
||||
keep_cutbuffer = FALSE;
|
||||
}
|
||||
|
||||
/* Return the status of cutbuffer preservation. */
|
||||
inline bool keeping_cutbuffer(void)
|
||||
{
|
||||
return keep_cutbuffer;
|
||||
}
|
||||
|
||||
/* If we aren't on the last line of the file, move all the text of the
|
||||
* current line, plus the newline at the end, into the cutbuffer. If we
|
||||
* are, move all of the text of the current line into the cutbuffer. In
|
||||
@@ -114,11 +120,11 @@ void cut_to_eof(void)
|
||||
|
||||
/* Move text from the current filestruct into the cutbuffer. If
|
||||
* copy_text is TRUE, copy the text back into the filestruct afterward.
|
||||
* If cut_till_end is TRUE, move all text from the current cursor
|
||||
* If cut_till_eof is TRUE, move all text from the current cursor
|
||||
* position to the end of the file into the cutbuffer. */
|
||||
void do_cut_text(
|
||||
#ifndef NANO_TINY
|
||||
bool copy_text, bool cut_till_end, bool undoing
|
||||
bool copy_text, bool cut_till_eof, bool undoing
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
@@ -167,8 +173,8 @@ void do_cut_text(
|
||||
keep_cutbuffer = TRUE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (cut_till_end) {
|
||||
/* If cut_till_end is TRUE, move all text up to the end of the
|
||||
if (cut_till_eof) {
|
||||
/* If cut_till_eof is TRUE, move all text up to the end of the
|
||||
* file into the cutbuffer. */
|
||||
cut_to_eof();
|
||||
} else if (openfile->mark_set) {
|
||||
@@ -209,7 +215,7 @@ void do_cut_text(
|
||||
if (!old_no_newlines)
|
||||
UNSET(NO_NEWLINES);
|
||||
} else if (!undoing)
|
||||
update_undo(cut_till_end ? CUT_EOF : CUT);
|
||||
update_undo(cut_till_eof ? CUT_EOF : CUT);
|
||||
|
||||
/* Leave the text in the cutbuffer, and mark the file as
|
||||
* modified. */
|
||||
@@ -245,14 +251,24 @@ void do_cut_text_void(void)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Move text from the current filestruct into the cutbuffer, and copy it
|
||||
* back into the filestruct afterward. */
|
||||
* back into the filestruct afterward. If the mark is set or the cursor
|
||||
* was moved, blow away previous contents of the cutbuffer. */
|
||||
void do_copy_text(void)
|
||||
{
|
||||
static struct filestruct *next_contiguous_line = NULL;
|
||||
bool mark_set = openfile->mark_set;
|
||||
|
||||
if (mark_set || openfile->current != next_contiguous_line)
|
||||
cutbuffer_reset();
|
||||
|
||||
do_cut_text(TRUE, FALSE, FALSE);
|
||||
|
||||
/* If the mark was set, blow away the cutbuffer on the next copy. */
|
||||
next_contiguous_line = (mark_set ? NULL : openfile->current);
|
||||
}
|
||||
|
||||
/* Cut from the current cursor position to the end of the file. */
|
||||
void do_cut_till_end(void)
|
||||
void do_cut_till_eof(void)
|
||||
{
|
||||
add_undo(CUT_EOF);
|
||||
do_cut_text(FALSE, TRUE, FALSE);
|
||||
|
||||
187
src/files.c
187
src/files.c
@@ -141,7 +141,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
mypid = getpid();
|
||||
|
||||
if (gethostname(myhostname, 31) < 0) {
|
||||
statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno));
|
||||
statusbar(_("Couldn't determine hosttname for lock file: %s"), strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "In write_lockfile(), write successful (wrote %d bytes)\n", wroteamt);
|
||||
fprintf(stderr, "In write_lockfile(), write successful (wrote %lu bytes)\n", (unsigned long)wroteamt);
|
||||
#endif
|
||||
|
||||
if (fclose(filestream) == EOF) {
|
||||
@@ -244,9 +244,10 @@ int do_lockfile(const char *filename)
|
||||
{
|
||||
char *lockdir = dirname((char *) mallocstrcpy(NULL, filename));
|
||||
char *lockbase = basename((char *) mallocstrcpy(NULL, filename));
|
||||
ssize_t lockfilesize = (sizeof (char *) * (strlen(filename)
|
||||
+ strlen(locking_prefix) + strlen(locking_suffix) + 3));
|
||||
char *lockfilename = (char *) nmalloc(lockfilesize);
|
||||
size_t lockfilesize = strlen(filename) + strlen(locking_prefix)
|
||||
+ strlen(locking_suffix) + 3;
|
||||
char *lockfilename = charalloc(lockfilesize);
|
||||
char *lockfiledir = NULL;
|
||||
char lockprog[12], lockuser[16];
|
||||
struct stat fileinfo;
|
||||
int lockfd, lockpid;
|
||||
@@ -259,8 +260,8 @@ int do_lockfile(const char *filename)
|
||||
if (stat(lockfilename, &fileinfo) != -1) {
|
||||
ssize_t readtot = 0;
|
||||
ssize_t readamt = 0;
|
||||
char *lockbuf = (char *) nmalloc(8192);
|
||||
char *promptstr = (char *) nmalloc(128);
|
||||
char *lockbuf = charalloc(8192);
|
||||
char *promptstr = charalloc(128);
|
||||
int ans;
|
||||
if ((lockfd = open(lockfilename, O_RDONLY)) < 0) {
|
||||
statusbar(_("Error opening lock file %s: %s"),
|
||||
@@ -294,8 +295,17 @@ int do_lockfile(const char *filename)
|
||||
blank_statusbar();
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
lockfiledir = mallocstrcpy(NULL, lockfilename);
|
||||
lockfiledir = dirname(lockfiledir);
|
||||
if (stat(lockfiledir, &fileinfo) == -1) {
|
||||
statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"),
|
||||
lockfiledir);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return write_lockfile(lockfilename, filename, FALSE);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -477,8 +487,8 @@ bool close_buffer(void)
|
||||
if (openfile == openfile->next)
|
||||
return FALSE;
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs()+1);
|
||||
#ifndef DISABLE_HISTORIES
|
||||
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs() + 1);
|
||||
#endif
|
||||
|
||||
/* Switch to the next file buffer. */
|
||||
@@ -881,7 +891,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkw
|
||||
int open_file(const char *filename, bool newfie, FILE **f)
|
||||
{
|
||||
struct stat fileinfo, fileinfo2;
|
||||
int fd;
|
||||
int fd, quiet = 0;
|
||||
char *full_filename;
|
||||
|
||||
assert(filename != NULL && f != NULL);
|
||||
@@ -897,22 +907,28 @@ int open_file(const char *filename, bool newfie, FILE **f)
|
||||
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING))
|
||||
if (do_lockfile(full_filename) < 0)
|
||||
return -1;
|
||||
if (ISSET(LOCKING)) {
|
||||
int lockstatus = do_lockfile(full_filename);
|
||||
if (lockstatus < 0)
|
||||
return -1;
|
||||
else if (lockstatus == 0)
|
||||
quiet = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (stat(full_filename, &fileinfo) == -1) {
|
||||
/* Well, maybe we can open the file even if the OS says it's
|
||||
* not there. */
|
||||
if ((fd = open(filename, O_RDONLY)) != -1) {
|
||||
statusbar(_("Reading File"));
|
||||
if (!quiet)
|
||||
statusbar(_("Reading File"));
|
||||
free(full_filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (newfie) {
|
||||
statusbar(_("New File"));
|
||||
if (!quiet)
|
||||
statusbar(_("New File"));
|
||||
return -2;
|
||||
}
|
||||
statusbar(_("\"%s\" not found"), filename);
|
||||
@@ -1009,7 +1025,7 @@ void do_insertfile(
|
||||
filestruct *edittop_save = openfile->edittop;
|
||||
size_t current_x_save = openfile->current_x;
|
||||
ssize_t current_y_save = openfile->current_y;
|
||||
bool edittop_inside = FALSE, meta_key = FALSE, func_key = FALSE;
|
||||
bool edittop_inside = FALSE;
|
||||
const sc *s;
|
||||
#ifndef NANO_TINY
|
||||
bool right_side_up = FALSE, single_line = FALSE;
|
||||
@@ -1026,17 +1042,16 @@ void do_insertfile(
|
||||
_("Command to execute in new buffer [from %s] ") :
|
||||
#endif
|
||||
_("Command to execute [from %s] ");
|
||||
} else {
|
||||
#endif
|
||||
} else
|
||||
#endif /* NANO_TINY */
|
||||
{
|
||||
msg =
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
ISSET(MULTIBUFFER) ?
|
||||
_("File to insert into new buffer [from %s] ") :
|
||||
#endif
|
||||
_("File to insert [from %s] ");
|
||||
#ifndef NANO_TINY
|
||||
}
|
||||
#endif
|
||||
|
||||
i = do_prompt(TRUE,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
@@ -1046,8 +1061,7 @@ void do_insertfile(
|
||||
execute ? MEXTCMD :
|
||||
#endif
|
||||
MINSERTFILE, ans,
|
||||
&meta_key, &func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
#endif
|
||||
edit_refresh, msg,
|
||||
@@ -1073,7 +1087,7 @@ void do_insertfile(
|
||||
|
||||
ans = mallocstrcpy(ans, answer);
|
||||
|
||||
s = get_shortcut(currmenu, &i, &meta_key);
|
||||
s = get_shortcut(&i);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
@@ -1081,16 +1095,15 @@ void do_insertfile(
|
||||
/* Don't allow toggling if we're in view mode. */
|
||||
if (!ISSET(VIEW_MODE))
|
||||
TOGGLE(MULTIBUFFER);
|
||||
else
|
||||
beep();
|
||||
continue;
|
||||
} else
|
||||
}
|
||||
#endif
|
||||
if (s && s->scfunc == ext_cmd_void) {
|
||||
if (s && s->scfunc == flip_execute_void) {
|
||||
execute = !execute;
|
||||
continue;
|
||||
}
|
||||
#ifndef DISABLE_BROWSER
|
||||
else
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
@@ -1188,18 +1201,19 @@ void do_insertfile(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(DISABLE_MULTIBUFFER) && !defined(DISABLE_NANORC)
|
||||
#if !defined(DISABLE_MULTIBUFFER) && !defined(DISABLE_HISTORIES)
|
||||
if (ISSET(MULTIBUFFER)) {
|
||||
/* Update the screen to account for the current
|
||||
* buffer. */
|
||||
display_buffer();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
ssize_t savedposline, savedposcol;
|
||||
if (!execute && ISSET(POS_HISTORY)
|
||||
&& check_poshistory(answer, &savedposline, &savedposcol))
|
||||
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE, FALSE);
|
||||
if (ISSET(POS_HISTORY) &&
|
||||
#ifndef NANO_TINY
|
||||
!execute &&
|
||||
#endif
|
||||
check_poshistory(answer, &savedposline, &savedposcol))
|
||||
do_gotolinecolumn(savedposline, savedposcol, FALSE, FALSE, FALSE, FALSE);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -1280,7 +1294,7 @@ void do_insertfile(
|
||||
void do_insertfile_void(void)
|
||||
{
|
||||
if (ISSET(RESTRICTED)) {
|
||||
nano_disabled_msg();
|
||||
nano_disabled_msg();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1675,12 +1689,14 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
/* The file descriptor we use. */
|
||||
mode_t original_umask = 0;
|
||||
/* Our umask, from when nano started. */
|
||||
#ifndef NANO_TINY
|
||||
bool realexists;
|
||||
/* The result of stat(). TRUE if the file exists, FALSE
|
||||
* otherwise. If name is a link that points nowhere, realexists
|
||||
* is FALSE. */
|
||||
struct stat st;
|
||||
/* The status fields filled in by stat(). */
|
||||
#endif
|
||||
bool anyexists;
|
||||
/* The result of lstat(). The same as realexists, unless name
|
||||
* is a link. */
|
||||
@@ -1729,10 +1745,10 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Check whether the file (at the end of the symlink) exists. */
|
||||
realexists = (stat(realname, &st) != -1);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If we haven't stat()d this file before (say, the user just
|
||||
* specified it interactively), stat and save the value now,
|
||||
* or else we will chase null pointers when we do modtime checks,
|
||||
@@ -1840,7 +1856,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
|
||||
if (ISSET(INSECURE_BACKUP))
|
||||
backup_cflags = O_WRONLY | O_CREAT | O_APPEND;
|
||||
else
|
||||
else
|
||||
backup_cflags = O_WRONLY | O_CREAT | O_EXCL | O_APPEND;
|
||||
|
||||
backup_fd = open(backupname, backup_cflags,
|
||||
@@ -1856,8 +1872,8 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
|
||||
goto cleanup_and_exit;
|
||||
}
|
||||
|
||||
/* We shouldn't worry about chown()ing something if we're not
|
||||
root, since it's likely to fail! */
|
||||
/* We shouldn't worry about chown()ing something if we're not
|
||||
* root, since it's likely to fail! */
|
||||
if (geteuid() == NANO_ROOT_UID && fchown(backup_fd,
|
||||
openfile->current_stat->st_uid, openfile->current_stat->st_gid) == -1
|
||||
&& !ISSET(INSECURE_BACKUP)) {
|
||||
@@ -2206,7 +2222,8 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
|
||||
/* Write the current file to disk. If the mark is on, write the current
|
||||
* marked selection to disk. If exiting is TRUE, write the file to disk
|
||||
* regardless of whether the mark is on, and without prompting if the
|
||||
* TEMP_FILE flag is set. Return TRUE on success or FALSE on error. */
|
||||
* TEMP_FILE flag is set and the current file has a name. Return TRUE
|
||||
* on success or FALSE on error. */
|
||||
bool do_writeout(bool exiting)
|
||||
{
|
||||
int i;
|
||||
@@ -2216,7 +2233,7 @@ bool do_writeout(bool exiting)
|
||||
#ifndef DISABLE_EXTRA
|
||||
static bool did_credits = FALSE;
|
||||
#endif
|
||||
bool retval = FALSE, meta_key = FALSE, func_key = FALSE;
|
||||
bool retval = FALSE;
|
||||
const sc *s;
|
||||
|
||||
currmenu = MWRITEFILE;
|
||||
@@ -2271,8 +2288,7 @@ bool do_writeout(bool exiting)
|
||||
TRUE,
|
||||
#endif
|
||||
MWRITEFILE, ans,
|
||||
&meta_key, &func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
#endif
|
||||
edit_refresh, "%s%s%s", msg,
|
||||
@@ -2291,7 +2307,7 @@ bool do_writeout(bool exiting)
|
||||
break;
|
||||
} else {
|
||||
ans = mallocstrcpy(ans, answer);
|
||||
s = get_shortcut(currmenu, &i, &meta_key);
|
||||
s = get_shortcut(&i);
|
||||
|
||||
#ifndef DISABLE_BROWSER
|
||||
if (s && s->scfunc == to_files_void) {
|
||||
@@ -2409,8 +2425,10 @@ bool do_writeout(bool exiting)
|
||||
/* Complain if the file exists, the name hasn't changed,
|
||||
* and the stat information we had before does not match
|
||||
* what we have now. */
|
||||
else if (name_exists && openfile->current_stat && (openfile->current_stat->st_mtime < st.st_mtime ||
|
||||
openfile->current_stat->st_dev != st.st_dev || openfile->current_stat->st_ino != st.st_ino)) {
|
||||
else if (name_exists && openfile->current_stat &&
|
||||
(openfile->current_stat->st_mtime < st.st_mtime ||
|
||||
openfile->current_stat->st_dev != st.st_dev ||
|
||||
openfile->current_stat->st_ino != st.st_ino)) {
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("File was modified since you opened it, continue saving ? "));
|
||||
if (i == 0 || i == -1)
|
||||
@@ -2892,8 +2910,8 @@ const char *tail(const char *foo)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
/* Return the constructed dorfile path, or NULL if we can't find the home
|
||||
#ifndef DISABLE_HISTORIES
|
||||
/* Return the constructed dirfile path, or NULL if we can't find the home
|
||||
* directory. The string is dynamically allocated, and should be
|
||||
* freed. */
|
||||
char *construct_filename(const char *str)
|
||||
@@ -2930,7 +2948,7 @@ char *poshistfilename(void)
|
||||
|
||||
void history_error(const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, msg);
|
||||
vfprintf(stderr, _(msg), ap);
|
||||
@@ -2951,32 +2969,36 @@ int check_dotnano(void)
|
||||
|
||||
if (stat(nanodir, &dirstat) == -1) {
|
||||
if (mkdir(nanodir, S_IRWXU | S_IRWXG | S_IRWXO) == -1) {
|
||||
history_error(N_("Unable to create directory %s: %s\nIt is required for saving/loading search history or cursor position\n"),
|
||||
nanodir, strerror(errno));
|
||||
history_error(N_("Unable to create directory %s: %s\n"
|
||||
"It is required for saving/loading search history or cursor positions.\n"),
|
||||
nanodir, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
} else if (!S_ISDIR(dirstat.st_mode)) {
|
||||
history_error(N_("Path %s is not a directory and needs to be.\nNano will be unable to load or save search or cursor position history\n"));
|
||||
history_error(N_("Path %s is not a directory and needs to be.\n"
|
||||
"Nano will be unable to load or save search history or cursor positions.\n"),
|
||||
nanodir);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Load histories from ~/.nano_history. */
|
||||
/* Load the search and replace histories from ~/.nano/search_history. */
|
||||
void load_history(void)
|
||||
{
|
||||
char *nanohist = histfilename();
|
||||
char *legacyhist = legacyhistfilename();
|
||||
struct stat hstat;
|
||||
|
||||
|
||||
if (stat(legacyhist, &hstat) != -1 && stat(nanohist, &hstat) == -1) {
|
||||
if (rename(legacyhist, nanohist) == -1)
|
||||
history_error(N_("Detected a legacy nano history file (%s) which I tried to move\nto the preferred location (%s) but encountered an error: %s"),
|
||||
legacyhist, nanohist, strerror(errno));
|
||||
history_error(N_("Detected a legacy nano history file (%s) which I tried to move\n"
|
||||
"to the preferred location (%s) but encountered an error: %s"),
|
||||
legacyhist, nanohist, strerror(errno));
|
||||
else
|
||||
history_error(N_("Detected a legacy nano history file (%s) which I moved\nto the preferred location (%s)\n(see the nano FAQ about this change)"),
|
||||
legacyhist, nanohist);
|
||||
history_error(N_("Detected a legacy nano history file (%s) which I moved\n"
|
||||
"to the preferred location (%s)\n(see the nano FAQ about this change)"),
|
||||
legacyhist, nanohist);
|
||||
}
|
||||
|
||||
/* Assume do_rcfile() has reported a missing home directory. */
|
||||
@@ -3043,7 +3065,7 @@ bool writehist(FILE *hist, filestruct *h)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Save histories to ~/.nano/search_history. */
|
||||
/* Save the search and replace histories to ~/.nano/search_history. */
|
||||
void save_history(void)
|
||||
{
|
||||
char *nanohist;
|
||||
@@ -3078,7 +3100,7 @@ void save_history(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Analogs for the POS history. */
|
||||
/* Save the recorded last file positions to ~/.nano/filepos_history. */
|
||||
void save_poshistory(void)
|
||||
{
|
||||
char *poshist;
|
||||
@@ -3098,10 +3120,10 @@ void save_poshistory(void)
|
||||
* history file. */
|
||||
chmod(poshist, S_IRUSR | S_IWUSR);
|
||||
|
||||
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
|
||||
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
|
||||
statusstr = charalloc(strlen(posptr->filename) + 2 * sizeof(ssize_t) + 4);
|
||||
sprintf(statusstr, "%s %d %d\n", posptr->filename, (int) posptr->lineno,
|
||||
(int) posptr->xno);
|
||||
sprintf(statusstr, "%s %ld %ld\n", posptr->filename, (long)posptr->lineno,
|
||||
(long)posptr->xno);
|
||||
if (fwrite(statusstr, sizeof(char), strlen(statusstr), hist) < strlen(statusstr))
|
||||
history_error(N_("Error writing %s: %s"), poshist,
|
||||
strerror(errno));
|
||||
@@ -3113,27 +3135,27 @@ void save_poshistory(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Update the POS history, given a filename line and column. If no
|
||||
* entry is found, add a new entry on the end. */
|
||||
/* Update the recorded last file positions, given a filename, a line
|
||||
* and a column. If no entry is found, add a new one at the end. */
|
||||
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
|
||||
{
|
||||
poshiststruct *posptr, *posprev = NULL;
|
||||
char *fullpath = get_full_path(filename);
|
||||
poshiststruct *posptr, *posprev = NULL;
|
||||
char *fullpath = get_full_path(filename);
|
||||
|
||||
if (fullpath == NULL)
|
||||
return;
|
||||
return;
|
||||
|
||||
for (posptr = poshistory; posptr != NULL; posptr = posptr->next) {
|
||||
if (!strcmp(posptr->filename, fullpath)) {
|
||||
if (!strcmp(posptr->filename, fullpath)) {
|
||||
posptr->lineno = lineno;
|
||||
posptr->xno = xpos;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
posprev = posptr;
|
||||
}
|
||||
|
||||
/* Didn't find it, make a new node yo! */
|
||||
posptr = (poshiststruct *) nmalloc(sizeof(poshiststruct));
|
||||
posptr = (poshiststruct *)nmalloc(sizeof(poshiststruct));
|
||||
posptr->filename = mallocstrcpy(NULL, fullpath);
|
||||
posptr->lineno = lineno;
|
||||
posptr->xno = xpos;
|
||||
@@ -3147,10 +3169,9 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
|
||||
free(fullpath);
|
||||
}
|
||||
|
||||
|
||||
/* Check the POS history to see if file matches an existing entry. If
|
||||
* so, return 1 and set line and column to the right values. Otherwise,
|
||||
* return 0. */
|
||||
/* Check the recorded last file positions to see if the given file
|
||||
* matches an existing entry. If so, return 1 and set line and column
|
||||
* to the retrieved values. Otherwise, return 0. */
|
||||
int check_poshistory(const char *file, ssize_t *line, ssize_t *column)
|
||||
{
|
||||
poshiststruct *posptr;
|
||||
@@ -3171,7 +3192,7 @@ int check_poshistory(const char *file, ssize_t *line, ssize_t *column)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Load histories from ~/.nano_history. */
|
||||
/* Load the recorded file positions from ~/.nano/filepos_history. */
|
||||
void load_poshistory(void)
|
||||
{
|
||||
char *nanohist = poshistfilename();
|
||||
@@ -3193,21 +3214,21 @@ void load_poshistory(void)
|
||||
ssize_t read, lineno, xno;
|
||||
poshiststruct *posptr;
|
||||
|
||||
/* See if we can find the file we're currently editing. */
|
||||
/* Read and parse each line, and put the data into the
|
||||
* positions history structure. */
|
||||
while ((read = getline(&line, &buf_len, hist)) >= 0) {
|
||||
if (read > 0 && line[read - 1] == '\n') {
|
||||
read--;
|
||||
line[read] = '\0';
|
||||
}
|
||||
if (read > 0) {
|
||||
if (read > 0)
|
||||
unsunder(line, read);
|
||||
}
|
||||
lineptr = parse_next_word(line);
|
||||
xptr = parse_next_word(lineptr);
|
||||
lineno = atoi(lineptr);
|
||||
xno = atoi(xptr);
|
||||
if (poshistory == NULL) {
|
||||
poshistory = (poshiststruct *) nmalloc(sizeof(poshiststruct));
|
||||
poshistory = (poshiststruct *)nmalloc(sizeof(poshiststruct));
|
||||
poshistory->filename = mallocstrcpy(NULL, line);
|
||||
poshistory->lineno = lineno;
|
||||
poshistory->xno = xno;
|
||||
@@ -3215,13 +3236,12 @@ void load_poshistory(void)
|
||||
} else {
|
||||
for (posptr = poshistory; posptr->next != NULL; posptr = posptr->next)
|
||||
;
|
||||
posptr->next = (poshiststruct *) nmalloc(sizeof(poshiststruct));
|
||||
posptr->next = (poshiststruct *)nmalloc(sizeof(poshiststruct));
|
||||
posptr->next->filename = mallocstrcpy(NULL, line);
|
||||
posptr->next->lineno = lineno;
|
||||
posptr->next->xno = xno;
|
||||
posptr->next->next = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fclose(hist);
|
||||
@@ -3230,5 +3250,4 @@ void load_poshistory(void)
|
||||
free(nanohist);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* !NANO_TINY && !DISABLE_NANORC */
|
||||
#endif /* !DISABLE_HISTORIES */
|
||||
|
||||
754
src/global.c
754
src/global.c
File diff suppressed because it is too large
Load Diff
103
src/help.c
103
src/help.c
@@ -37,23 +37,21 @@ static char *help_text = NULL;
|
||||
void do_help(void (*refresh_func)(void))
|
||||
{
|
||||
int kbinput = ERR;
|
||||
bool meta_key, func_key, old_no_help = ISSET(NO_HELP);
|
||||
bool old_no_help = ISSET(NO_HELP);
|
||||
size_t line = 0;
|
||||
/* The line number in help_text of the first displayed help
|
||||
* line. This variable is zero-based. */
|
||||
size_t last_line = 0;
|
||||
/* The line number in help_text of the last help line. This
|
||||
* variable is zero-based. */
|
||||
#ifndef DISABLE_MOUSE
|
||||
int oldmenu = currmenu;
|
||||
/* The menu we were called from. */
|
||||
#endif
|
||||
const char *ptr;
|
||||
/* The current line of the help text. */
|
||||
size_t old_line = (size_t)-1;
|
||||
/* The line we were on before the current line. */
|
||||
const sc *s;
|
||||
const subnfunc *f;
|
||||
functionptrtype func;
|
||||
/* The function of the key the user typed in. */
|
||||
|
||||
curs_set(0);
|
||||
blank_edit();
|
||||
@@ -64,11 +62,9 @@ void do_help(void (*refresh_func)(void))
|
||||
|
||||
assert(help_text != NULL);
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
/* Set currmenu to allow clicking on the help screen's shortcut
|
||||
* list, after help_init() is called. */
|
||||
currmenu = MHELP;
|
||||
#endif
|
||||
|
||||
if (ISSET(NO_HELP)) {
|
||||
/* Make sure that the help screen's shortcut list will actually
|
||||
@@ -123,57 +119,46 @@ void do_help(void (*refresh_func)(void))
|
||||
|
||||
old_line = line;
|
||||
|
||||
kbinput = get_kbinput(edit, &meta_key, &func_key);
|
||||
kbinput = get_kbinput(edit);
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
if (kbinput == KEY_MOUSE) {
|
||||
int mouse_x, mouse_y;
|
||||
get_mouseinput(&mouse_x, &mouse_y, TRUE);
|
||||
continue; /* Redraw the screen. */
|
||||
int mouse_x, mouse_y;
|
||||
get_mouseinput(&mouse_x, &mouse_y, TRUE);
|
||||
continue; /* Redraw the screen. */
|
||||
}
|
||||
#endif
|
||||
|
||||
parse_help_input(&kbinput, &meta_key);
|
||||
s = get_shortcut(MHELP, &kbinput, &meta_key);
|
||||
if (!s)
|
||||
continue;
|
||||
f = sctofunc((sc *) s);
|
||||
if (!f)
|
||||
continue;
|
||||
func = parse_help_input(&kbinput);
|
||||
|
||||
if (f->scfunc == total_refresh) {
|
||||
total_redraw();
|
||||
} else if (f->scfunc == do_page_up) {
|
||||
if (line > editwinrows - 2)
|
||||
line -= editwinrows - 2;
|
||||
else
|
||||
line = 0;
|
||||
} else if (f->scfunc == do_page_down) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line += editwinrows - 2;
|
||||
} else if (f->scfunc == do_up_void) {
|
||||
if (line > 0)
|
||||
line--;
|
||||
} else if (f->scfunc == do_down_void) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line++;
|
||||
} else if (f->scfunc == do_first_line) {
|
||||
if (meta_key)
|
||||
line = 0;
|
||||
} else if (f->scfunc == do_last_line) {
|
||||
if (meta_key) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line = last_line - (editwinrows - 1);
|
||||
}
|
||||
} else if (f->scfunc == do_exit) {
|
||||
/* Abort the help browser. */
|
||||
if (func == total_refresh) {
|
||||
total_redraw();
|
||||
} else if (func == do_page_up) {
|
||||
if (line > editwinrows - 2)
|
||||
line -= editwinrows - 2;
|
||||
else
|
||||
line = 0;
|
||||
} else if (func == do_page_down) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line += editwinrows - 2;
|
||||
} else if (func == do_up_void) {
|
||||
if (line > 0)
|
||||
line--;
|
||||
} else if (func == do_down_void) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line++;
|
||||
} else if (func == do_first_line) {
|
||||
line = 0;
|
||||
} else if (func == do_last_line) {
|
||||
if (line + (editwinrows - 1) < last_line)
|
||||
line = last_line - (editwinrows - 1);
|
||||
} else if (func == do_exit) {
|
||||
/* Exit from the help browser. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
currmenu = oldmenu;
|
||||
#endif
|
||||
|
||||
if (old_no_help) {
|
||||
blank_bottombars();
|
||||
@@ -419,9 +404,6 @@ void help_init(void)
|
||||
if ((f->menus & currmenu) == 0)
|
||||
continue;
|
||||
|
||||
if (!f->desc || !strcmp(f->desc, ""))
|
||||
continue;
|
||||
|
||||
/* Let's simply show the first two shortcuts from the list. */
|
||||
for (s = sclist, scsfound = 0; s != NULL; s = s->next) {
|
||||
|
||||
@@ -479,29 +461,22 @@ void help_init(void)
|
||||
assert(strlen(help_text) <= allocsize + 1);
|
||||
}
|
||||
|
||||
/* Determine the shortcut key corresponding to the values of kbinput
|
||||
* (the key itself) and meta_key (whether the key is a meta sequence).
|
||||
* Also convert certain non-shortcut keys into their corresponding
|
||||
* shortcut keys. */
|
||||
void parse_help_input(int *kbinput, bool *meta_key)
|
||||
/* Return the function that is bound to the given key, accepting certain
|
||||
* plain characters too, for consistency with the file browser. */
|
||||
functionptrtype parse_help_input(int *kbinput)
|
||||
{
|
||||
get_shortcut(MHELP, kbinput, meta_key);
|
||||
|
||||
if (!*meta_key) {
|
||||
if (!meta_key) {
|
||||
switch (*kbinput) {
|
||||
/* For consistency with the file browser. */
|
||||
case ' ':
|
||||
*kbinput = KEY_NPAGE;
|
||||
break;
|
||||
return do_page_down;
|
||||
case '-':
|
||||
*kbinput = KEY_PPAGE;
|
||||
break;
|
||||
return do_page_up;
|
||||
case 'E':
|
||||
case 'e':
|
||||
*kbinput = sc_seq_or(do_exit, 0);
|
||||
break;
|
||||
return do_exit;
|
||||
}
|
||||
}
|
||||
return func_from_key(kbinput);
|
||||
}
|
||||
|
||||
/* Calculate the next line of help_text, starting at ptr. */
|
||||
|
||||
30
src/move.c
30
src/move.c
@@ -55,7 +55,10 @@ void do_page_up(void)
|
||||
/* If there's less than a page of text left on the screen, put the
|
||||
* cursor at the beginning of the first line of the file, and then
|
||||
* update the edit window. */
|
||||
if (openfile->current->lineno == 1 || (!ISSET(SOFTWRAP) &&
|
||||
if (openfile->current->lineno == 1 || (
|
||||
#ifndef NANO_TINY
|
||||
!ISSET(SOFTWRAP) &&
|
||||
#endif
|
||||
openfile->current->lineno <= editwinrows - 2)) {
|
||||
do_first_line();
|
||||
return;
|
||||
@@ -63,7 +66,6 @@ void do_page_up(void)
|
||||
|
||||
/* If we're not in smooth scrolling mode, put the cursor at the
|
||||
* beginning of the top line of the edit window, as Pico does. */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (!ISSET(SMOOTH_SCROLL)) {
|
||||
#endif
|
||||
@@ -76,13 +78,15 @@ void do_page_up(void)
|
||||
for (i = editwinrows - 2; i - skipped > 0 && openfile->current !=
|
||||
openfile->fileage; i--) {
|
||||
openfile->current = openfile->current->prev;
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP) && openfile->current) {
|
||||
skipped += strlenpt(openfile->current->data) / COLS;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_up: i = %d, skipped = %d based on line %lu len %d\n",
|
||||
i, skipped, (unsigned long) openfile->current->lineno, strlenpt(openfile->current->data));
|
||||
fprintf(stderr, "do_page_up: i = %d, skipped = %d based on line %ld len %lu\n",
|
||||
i, skipped, (long)openfile->current->lineno, (unsigned long)strlenpt(openfile->current->data));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
@@ -90,7 +94,7 @@ void do_page_up(void)
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_up: openfile->current->lineno = %lu, skipped = %d\n",
|
||||
(unsigned long) openfile->current->lineno, skipped);
|
||||
(unsigned long)openfile->current->lineno, skipped);
|
||||
#endif
|
||||
|
||||
/* Scroll the edit window up a page. */
|
||||
@@ -126,7 +130,7 @@ void do_page_down(void)
|
||||
openfile->filebot; i--) {
|
||||
openfile->current = openfile->current->next;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_page_down: moving to line %lu\n", (unsigned long) openfile->current->lineno);
|
||||
fprintf(stderr, "do_page_down: moving to line %lu\n", (unsigned long)openfile->current->lineno);
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -514,12 +518,12 @@ void do_up(
|
||||
* smooth scrolling mode, or up half a page if we're not. If
|
||||
* scroll_only is TRUE, scroll the edit window up one line
|
||||
* unconditionally. */
|
||||
if (openfile->current_y == 0 || (ISSET(SOFTWRAP) && openfile->edittop->lineno == openfile->current->next->lineno)
|
||||
if (openfile->current_y == 0
|
||||
#ifndef NANO_TINY
|
||||
|| scroll_only
|
||||
|| (ISSET(SOFTWRAP) && openfile->edittop->lineno == openfile->current->next->lineno) || scroll_only
|
||||
#endif
|
||||
)
|
||||
edit_scroll(UP_DIR,
|
||||
edit_scroll(UPWARD,
|
||||
#ifndef NANO_TINY
|
||||
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
|
||||
#endif
|
||||
@@ -612,7 +616,7 @@ void do_down(
|
||||
if (amount < 1 || scroll_only)
|
||||
amount = 1;
|
||||
#endif
|
||||
edit_scroll(DOWN_DIR,
|
||||
edit_scroll(DOWNWARD,
|
||||
#ifndef NANO_TINY
|
||||
(ISSET(SMOOTH_SCROLL) || scroll_only) ? amount :
|
||||
#endif
|
||||
@@ -623,7 +627,11 @@ void do_down(
|
||||
* we were on before and the line we're on now. The former needs to
|
||||
* be redrawn if we're not on the first page, and the latter needs
|
||||
* to be drawn unconditionally. */
|
||||
if (ISSET(SOFTWRAP) || openfile->current_y < editwinrows - 1) {
|
||||
if (openfile->current_y < editwinrows - 1
|
||||
#ifndef NANO_TINY
|
||||
|| ISSET(SOFTWRAP)
|
||||
#endif
|
||||
) {
|
||||
if (need_vertical_update(0))
|
||||
update_line(openfile->current->prev, 0);
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
|
||||
337
src/nano.c
337
src/nano.c
@@ -612,11 +612,11 @@ void finish(void)
|
||||
/* Restore the old terminal settings. */
|
||||
tcsetattr(0, TCSANOW, &oldterm);
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
if (!no_rcfiles && ISSET(HISTORYLOG))
|
||||
#ifndef DISABLE_HISTORIES
|
||||
if (ISSET(HISTORYLOG))
|
||||
save_history();
|
||||
if (!no_rcfiles && ISSET(POS_HISTORY)) {
|
||||
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs()+1);
|
||||
if (ISSET(POS_HISTORY)) {
|
||||
update_poshistory(openfile->filename, openfile->current->lineno, xplustabs() + 1);
|
||||
save_poshistory();
|
||||
}
|
||||
#endif
|
||||
@@ -734,7 +734,7 @@ void die_save_file(const char *die_filename
|
||||
void window_init(void)
|
||||
{
|
||||
/* If the screen height is too small, get out. */
|
||||
editwinrows = LINES - 5 + no_more_space() + no_help();
|
||||
editwinrows = LINES - 5 + more_space() + no_help();
|
||||
if (COLS < MIN_EDITOR_COLS || editwinrows < MIN_EDITOR_ROWS)
|
||||
die(_("Window size is too small for nano...\n"));
|
||||
|
||||
@@ -755,10 +755,10 @@ void window_init(void)
|
||||
delwin(bottomwin);
|
||||
|
||||
/* Set up the windows. */
|
||||
topwin = newwin(2 - no_more_space(), COLS, 0, 0);
|
||||
edit = newwin(editwinrows, COLS, 2 - no_more_space(), 0);
|
||||
topwin = newwin(2 - more_space(), COLS, 0, 0);
|
||||
edit = newwin(editwinrows, COLS, 2 - more_space(), 0);
|
||||
bottomwin = newwin(3 - no_help(), COLS, editwinrows + (2 -
|
||||
no_more_space()), 0);
|
||||
more_space()), 0);
|
||||
|
||||
/* Turn the keypad on for the windows, if necessary. */
|
||||
if (!ISSET(REBIND_KEYPAD)) {
|
||||
@@ -856,13 +856,15 @@ void usage(void)
|
||||
#ifndef DISABLE_MULTIBUFFER
|
||||
print_opt("-F", "--multibuffer", N_("Enable multiple file buffers"));
|
||||
#endif
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-G", "--locking",
|
||||
N_("Use (vim-style) lock files"));
|
||||
#endif
|
||||
#ifndef DISABLE_HISTORIES
|
||||
print_opt("-H", "--historylog",
|
||||
N_("Log & read search/replace string history"));
|
||||
#endif
|
||||
#ifndef DISABLE_NANORC
|
||||
print_opt("-I", "--ignorercfiles",
|
||||
N_("Don't look at nanorc files"));
|
||||
#endif
|
||||
@@ -875,7 +877,7 @@ void usage(void)
|
||||
N_("Don't convert files from DOS/Mac format"));
|
||||
#endif
|
||||
print_opt("-O", "--morespace", N_("Use one more line for editing"));
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
print_opt("-P", "--poslog",
|
||||
N_("Log & read location of cursor position"));
|
||||
#endif
|
||||
@@ -906,8 +908,8 @@ void usage(void)
|
||||
print_opt("-c", "--const", N_("Constantly show cursor position"));
|
||||
print_opt("-d", "--rebinddelete",
|
||||
N_("Fix Backspace/Delete confusion problem"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-h", "--help", N_("Show this help text"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-i", "--autoindent",
|
||||
N_("Automatically indent new lines"));
|
||||
print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
|
||||
@@ -924,8 +926,10 @@ void usage(void)
|
||||
#endif
|
||||
print_opt("-p", "--preserve",
|
||||
N_("Preserve XON (^Q) and XOFF (^S) keys"));
|
||||
#ifndef DISABLE_NANORC
|
||||
print_opt("-q", "--quiet",
|
||||
N_("Silently ignore startup issues like rc file errors"));
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
print_opt(_("-r <#cols>"), _("--fill=<#cols>"),
|
||||
N_("Set hard-wrapping point at column #cols"));
|
||||
@@ -936,10 +940,6 @@ void usage(void)
|
||||
#endif
|
||||
print_opt("-t", "--tempfile",
|
||||
N_("Auto save on exit, don't prompt"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-u", "--undo", N_("Allow generic undo [EXPERIMENTAL]"));
|
||||
#endif
|
||||
|
||||
print_opt("-v", "--view", N_("View mode (read-only)"));
|
||||
#ifndef DISABLE_WRAPPING
|
||||
print_opt("-w", "--nowrap", N_("Don't hard-wrap long lines"));
|
||||
@@ -977,6 +977,9 @@ void version(void)
|
||||
#ifndef DISABLE_HELP
|
||||
printf(" --enable-help");
|
||||
#endif
|
||||
#ifndef DISABLE_HISTORIES
|
||||
printf(" --enable-histories");
|
||||
#endif
|
||||
#ifndef DISABLE_JUSTIFY
|
||||
printf(" --enable-justify");
|
||||
#endif
|
||||
@@ -1017,6 +1020,9 @@ void version(void)
|
||||
#ifdef DISABLE_HELP
|
||||
printf(" --disable-help");
|
||||
#endif
|
||||
#ifdef DISABLE_HISTORIES
|
||||
printf(" --disable-histories");
|
||||
#endif
|
||||
#ifdef DISABLE_JUSTIFY
|
||||
printf(" --disable-justify");
|
||||
#endif
|
||||
@@ -1067,16 +1073,15 @@ void version(void)
|
||||
}
|
||||
|
||||
/* Return 1 if the MORE_SPACE flag is set, and 0 otherwise. This is
|
||||
* used to calculate the relative screen position while taking this flag
|
||||
* into account, since it adds one line to the edit window. */
|
||||
int no_more_space(void)
|
||||
* used to calculate the sizes and Y coordinates of the subwindows. */
|
||||
int more_space(void)
|
||||
{
|
||||
return ISSET(MORE_SPACE) ? 1 : 0;
|
||||
}
|
||||
|
||||
/* Return 2 if the NO_HELP flag is set, and 0 otherwise. This is used
|
||||
* to calculate the relative screen position while taking this flag into
|
||||
* account, since it removes two lines from the edit window. */
|
||||
* to calculate the sizes and Y coordinates of the subwindows, because
|
||||
* having NO_HELP adds two lines to the edit window. */
|
||||
int no_help(void)
|
||||
{
|
||||
return ISSET(NO_HELP) ? 2 : 0;
|
||||
@@ -1090,9 +1095,10 @@ void nano_disabled_msg(void)
|
||||
|
||||
/* If the current file buffer has been modified, and the TEMP_FILE flag
|
||||
* isn't set, ask whether or not to save the file buffer. If the
|
||||
* TEMP_FILE flag is set, save it unconditionally. Then, if more than
|
||||
* one file buffer is open, close the current file buffer and switch to
|
||||
* the next one. If only one file buffer is open, exit from nano. */
|
||||
* TEMP_FILE flag is set and the current file has a name, save it
|
||||
* unconditionally. Then, if more than one file buffer is open, close
|
||||
* the current file buffer and switch to the next one. If only one file
|
||||
* buffer is open, exit from nano. */
|
||||
void do_exit(void)
|
||||
{
|
||||
int i;
|
||||
@@ -1101,13 +1107,31 @@ void do_exit(void)
|
||||
* save. */
|
||||
if (!openfile->modified)
|
||||
i = 0;
|
||||
/* If the TEMP_FILE flag is set, pretend the user chose to save. */
|
||||
else if (ISSET(TEMP_FILE))
|
||||
/* If the TEMP_FILE flag is set and the current file has a name,
|
||||
* pretend the user chose to save. */
|
||||
else if (openfile->filename[0] != '\0' && ISSET(TEMP_FILE))
|
||||
i = 1;
|
||||
/* Otherwise, ask the user whether or not to save. */
|
||||
else
|
||||
else {
|
||||
/* If the TEMP_FILE flag is set, and the current file doesn't
|
||||
* have a name, handle it the same way Pico does. */
|
||||
if (ISSET(TEMP_FILE)) {
|
||||
curs_set(0);
|
||||
|
||||
/* Warn that the current file has no name. */
|
||||
statusbar(_("No file name"));
|
||||
beep();
|
||||
|
||||
/* Ensure that we see the warning. */
|
||||
doupdate();
|
||||
napms(2000);
|
||||
|
||||
curs_set(1);
|
||||
}
|
||||
|
||||
i = do_yesno_prompt(FALSE,
|
||||
_("Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? "));
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
dump_filestruct(openfile->fileage);
|
||||
@@ -1433,11 +1457,9 @@ void do_toggle(int flag)
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
case NO_COLOR_SYNTAX:
|
||||
edit_refresh();
|
||||
break;
|
||||
#endif
|
||||
case SOFTWRAP:
|
||||
total_refresh();
|
||||
edit_refresh();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1565,11 +1587,10 @@ void terminal_init(void)
|
||||
}
|
||||
|
||||
/* Read in a character, interpret it as a shortcut or toggle if
|
||||
* necessary, and return it. Set meta_key to TRUE if the character is a
|
||||
* meta sequence, set func_key to TRUE if the character is a function key.
|
||||
* necessary, and return it.
|
||||
* If allow_funcs is FALSE, don't actually run any functions associated
|
||||
* with shortcut keys. */
|
||||
int do_input(bool *meta_key, bool *func_key, bool allow_funcs)
|
||||
int do_input(bool allow_funcs)
|
||||
{
|
||||
int input;
|
||||
/* The character we read in. */
|
||||
@@ -1577,32 +1598,29 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs)
|
||||
/* The input buffer. */
|
||||
static size_t kbinput_len = 0;
|
||||
/* The length of the input buffer. */
|
||||
bool cut_copy = FALSE;
|
||||
/* Are we cutting or copying text? */
|
||||
bool preserve = FALSE;
|
||||
/* Preserve the contents of the cutbuffer? */
|
||||
const sc *s;
|
||||
bool have_shortcut;
|
||||
|
||||
/* Read in a character. */
|
||||
input = get_kbinput(edit, meta_key, func_key);
|
||||
input = get_kbinput(edit);
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
if (allow_funcs) {
|
||||
/* If we got a mouse click and it was on a shortcut, read in the
|
||||
* shortcut character. */
|
||||
if (*func_key && input == KEY_MOUSE) {
|
||||
if (do_mouse() == 1)
|
||||
input = get_kbinput(edit, meta_key, func_key);
|
||||
else {
|
||||
*meta_key = FALSE;
|
||||
*func_key = FALSE;
|
||||
input = ERR;
|
||||
}
|
||||
}
|
||||
if (func_key && input == KEY_MOUSE) {
|
||||
/* We received a mouse click. */
|
||||
if (do_mouse() == 1)
|
||||
/* The click was on a shortcut -- read in the character
|
||||
* that it was converted into. */
|
||||
input = get_kbinput(edit);
|
||||
else
|
||||
/* The click was invalid or has been handled -- get out. */
|
||||
return ERR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check for a shortcut in the main list. */
|
||||
s = get_shortcut(MMAIN, &input, meta_key);
|
||||
s = get_shortcut(&input);
|
||||
|
||||
/* If we got a shortcut from the main list, or a "universal"
|
||||
* edit window shortcut, set have_shortcut to TRUE. */
|
||||
@@ -1611,11 +1629,11 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs)
|
||||
/* If we got a non-high-bit control key, a meta key sequence, or a
|
||||
* function key, and it's not a shortcut or toggle, throw it out. */
|
||||
if (!have_shortcut) {
|
||||
if (is_ascii_cntrl_char(input) || *meta_key || *func_key) {
|
||||
if (is_ascii_cntrl_char(input) || meta_key || func_key) {
|
||||
statusbar(_("Unknown Command"));
|
||||
beep();
|
||||
*meta_key = FALSE;
|
||||
*func_key = FALSE;
|
||||
meta_key = FALSE;
|
||||
func_key = FALSE;
|
||||
input = ERR;
|
||||
}
|
||||
}
|
||||
@@ -1642,12 +1660,11 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs)
|
||||
* output all the characters in the input buffer if it isn't
|
||||
* empty. Note that it should be empty if we're in view
|
||||
* mode. */
|
||||
if (have_shortcut || get_key_buffer_len() == 0) {
|
||||
if (have_shortcut || get_key_buffer_len() == 0) {
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* If we got a shortcut or toggle, and it's not the shortcut
|
||||
* for verbatim input, turn off prepending of wrapped text. */
|
||||
if (have_shortcut && (!have_shortcut || s == NULL || s->scfunc !=
|
||||
do_verbatim_input))
|
||||
if (have_shortcut && s->scfunc != do_verbatim_input)
|
||||
wrap_reset();
|
||||
#endif
|
||||
|
||||
@@ -1673,55 +1690,51 @@ int do_input(bool *meta_key, bool *func_key, bool allow_funcs)
|
||||
}
|
||||
|
||||
if (have_shortcut) {
|
||||
switch (input) {
|
||||
/* Handle the normal edit-window shortcuts. */
|
||||
default:
|
||||
/* If the function associated with this shortcut is
|
||||
* cutting or copying text, indicate this. */
|
||||
if (s->scfunc == do_cut_text_void
|
||||
/* If the function associated with this shortcut is
|
||||
* cutting or copying text, remember this. */
|
||||
if (s->scfunc == do_cut_text_void
|
||||
#ifndef NANO_TINY
|
||||
|| s->scfunc == do_copy_text || s->scfunc ==
|
||||
do_cut_till_end
|
||||
|| s->scfunc == do_copy_text || s->scfunc == do_cut_till_eof
|
||||
#endif
|
||||
)
|
||||
cut_copy = TRUE;
|
||||
)
|
||||
preserve = TRUE;
|
||||
|
||||
if (s->scfunc != 0) {
|
||||
const subnfunc *f = sctofunc((sc *) s);
|
||||
if (ISSET(VIEW_MODE) && f && !f->viewok)
|
||||
print_view_warning();
|
||||
else {
|
||||
if (s->scfunc != 0) {
|
||||
const subnfunc *f = sctofunc((sc *) s);
|
||||
if (ISSET(VIEW_MODE) && f && !f->viewok)
|
||||
print_view_warning();
|
||||
else {
|
||||
#ifndef NANO_TINY
|
||||
if (s->scfunc == do_toggle_void)
|
||||
do_toggle(s->toggle);
|
||||
else
|
||||
if (s->scfunc == do_toggle_void) {
|
||||
do_toggle(s->toggle);
|
||||
if (s->toggle != CUT_TO_END)
|
||||
preserve = TRUE;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
s->scfunc();
|
||||
{
|
||||
/* Execute the function of the shortcut. */
|
||||
s->scfunc();
|
||||
#ifndef DISABLE_COLOR
|
||||
if (f && !f->viewok && openfile->syntax != NULL
|
||||
&& openfile->syntax->nmultis > 0) {
|
||||
reset_multis(openfile->current, FALSE);
|
||||
}
|
||||
if (f && !f->viewok && openfile->syntax != NULL
|
||||
&& openfile->syntax->nmultis > 0)
|
||||
reset_multis(openfile->current, FALSE);
|
||||
#endif
|
||||
if (edit_refresh_needed) {
|
||||
if (edit_refresh_needed) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "running edit_refresh() as edit_refresh_needed is true\n");
|
||||
fprintf(stderr, "running edit_refresh() as edit_refresh_needed is true\n");
|
||||
#endif
|
||||
edit_refresh();
|
||||
edit_refresh_needed = FALSE;
|
||||
}
|
||||
}
|
||||
edit_refresh();
|
||||
edit_refresh_needed = FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we aren't cutting or copying text, blow away the text in the
|
||||
* cutbuffer. */
|
||||
if (!cut_copy)
|
||||
/* If we aren't cutting or copying text, and the key wasn't a toggle,
|
||||
* blow away the text in the cutbuffer upon the next cutting action. */
|
||||
if (!preserve)
|
||||
cutbuffer_reset();
|
||||
|
||||
return input;
|
||||
@@ -1745,8 +1758,12 @@ int do_mouse(void)
|
||||
int mouse_x, mouse_y;
|
||||
int retval = get_mouseinput(&mouse_x, &mouse_y, TRUE);
|
||||
|
||||
if (retval != 0)
|
||||
/* The click is wrong or already handled. */
|
||||
return retval;
|
||||
|
||||
/* We can click on the edit window to move the cursor. */
|
||||
if (retval == 0 && wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
|
||||
if (wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
|
||||
bool sameline;
|
||||
/* Did they click on the line with the cursor? If they
|
||||
* clicked on the cursor, we set the mark. */
|
||||
@@ -1759,20 +1776,21 @@ int do_mouse(void)
|
||||
sameline = (mouse_y == openfile->current_y);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "mouse_y = %d, current_y = %d\n", mouse_y, openfile->current_y);
|
||||
fprintf(stderr, "mouse_y = %d, current_y = %ld\n", mouse_y, (long)openfile->current_y);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
int i = 0;
|
||||
size_t i = 0;
|
||||
for (openfile->current = openfile->edittop;
|
||||
openfile->current->next && i < mouse_y;
|
||||
openfile->current = openfile->current->next, i++) {
|
||||
openfile->current_y = i;
|
||||
i += strlenpt(openfile->current->data) / COLS;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): moving to current_y = %d, i %d\n", openfile->current_y, i);
|
||||
fprintf(stderr, "do_mouse(): moving to current_y = %ld, index i = %lu\n",
|
||||
(long)openfile->current_y, (unsigned long)i);
|
||||
fprintf(stderr, " openfile->current->data = \"%s\"\n", openfile->current->data);
|
||||
#endif
|
||||
|
||||
@@ -1780,18 +1798,19 @@ int do_mouse(void)
|
||||
openfile->current = openfile->current->prev;
|
||||
openfile->current_x = actual_x(openfile->current->data, mouse_x + (mouse_y - openfile->current_y) * COLS);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): i > mouse_y, mouse_x = %d, current_x to = %d\n", mouse_x, openfile->current_x);
|
||||
fprintf(stderr, "do_mouse(): i > mouse_y, mouse_x = %d, current_x to = %lu\n",
|
||||
mouse_x, (unsigned long)openfile->current_x);
|
||||
#endif
|
||||
} else {
|
||||
openfile->current_x = actual_x(openfile->current->data, mouse_x);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "do_mouse(): i <= mouse_y, mouse_x = %d, setting current_x to = %d\n", mouse_x, openfile->current_x);
|
||||
fprintf(stderr, "do_mouse(): i <= mouse_y, mouse_x = %d, setting current_x to = %lu\n",
|
||||
mouse_x, (unsigned long)openfile->current_x);
|
||||
#endif
|
||||
}
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
} else {
|
||||
} else
|
||||
#endif /* NANO_TINY */
|
||||
{
|
||||
/* Move to where the click occurred. */
|
||||
for (; openfile->current_y < mouse_y && openfile->current !=
|
||||
openfile->filebot; openfile->current_y++)
|
||||
@@ -1802,22 +1821,26 @@ int do_mouse(void)
|
||||
|
||||
openfile->current_x = actual_x(openfile->current->data,
|
||||
get_page_start(xplustabs()) + mouse_x);
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Clicking where the cursor is toggles the mark, as does
|
||||
* clicking beyond the line length with the cursor at the end of
|
||||
* the line. */
|
||||
if (sameline && openfile->current_x == current_x_save)
|
||||
do_mark();
|
||||
else
|
||||
#endif
|
||||
/* The cursor moved; clean the cutbuffer on the next cut. */
|
||||
cutbuffer_reset();
|
||||
|
||||
edit_redraw(current_save, pww_save);
|
||||
}
|
||||
|
||||
return retval;
|
||||
/* No more handling is needed. */
|
||||
return 2;
|
||||
}
|
||||
#endif /* !DISABLE_MOUSE */
|
||||
|
||||
@@ -1825,7 +1848,7 @@ int do_mouse(void)
|
||||
void alloc_multidata_if_needed(filestruct *fileptr)
|
||||
{
|
||||
if (!fileptr->multidata)
|
||||
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
}
|
||||
|
||||
/* Precalculate the multi-line start and end regex info so we can
|
||||
@@ -1860,7 +1883,7 @@ void precalc_multicolorinfo(void)
|
||||
int startx = 0;
|
||||
int nostart = 0;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "working on lineno %lu... ", (unsigned long) fileptr->lineno);
|
||||
fprintf(stderr, "working on lineno %ld... ", (long)fileptr->lineno);
|
||||
#endif
|
||||
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
@@ -1877,7 +1900,7 @@ void precalc_multicolorinfo(void)
|
||||
* encompassed, which should speed up rendering later. */
|
||||
startx += startmatch.rm_eo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "start found at pos %d... ", startx);
|
||||
fprintf(stderr, "start found at pos %lu... ", (unsigned long)startx);
|
||||
#endif
|
||||
|
||||
/* Look first on this line for an end. */
|
||||
@@ -1894,7 +1917,7 @@ void precalc_multicolorinfo(void)
|
||||
/* Nice, we didn't find the end regex on this line. Let's start looking for it. */
|
||||
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "\nadvancing to line %lu to find end... ", (unsigned long) endptr->lineno);
|
||||
fprintf(stderr, "\nadvancing to line %ld to find end... ", (long)endptr->lineno);
|
||||
#endif
|
||||
/* Check for keyboard input, again. */
|
||||
if ((cur_check = time(NULL)) - last_check > 1) {
|
||||
@@ -1903,7 +1926,7 @@ void precalc_multicolorinfo(void)
|
||||
goto precalc_cleanup;
|
||||
}
|
||||
if (regexec(tmpcolor->end, endptr->data, 1, &endmatch, 0) == 0)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
if (endptr == NULL) {
|
||||
@@ -1920,24 +1943,24 @@ void precalc_multicolorinfo(void)
|
||||
* the lines in between and the end properly. */
|
||||
fileptr->multidata[tmpcolor->id] |= CENDAFTER;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking line %lu as CENDAFTER\n", (unsigned long) fileptr->lineno);
|
||||
fprintf(stderr, "marking line %ld as CENDAFTER\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) {
|
||||
alloc_multidata_if_needed(fileptr);
|
||||
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking intermediary line %lu as CWHOLELINE\n", (unsigned long) fileptr->lineno);
|
||||
fprintf(stderr, "marking intermediary line %ld as CWHOLELINE\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
}
|
||||
alloc_multidata_if_needed(endptr);
|
||||
fileptr->multidata[tmpcolor->id] |= CBEGINBEFORE;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "marking line %lu as CBEGINBEFORE\n", (unsigned long) fileptr->lineno);
|
||||
fprintf(stderr, "marking line %ld as CBEGINBEFORE\n", (long)fileptr->lineno);
|
||||
#endif
|
||||
/* Skip to the end point of the match. */
|
||||
startx = endmatch.rm_eo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "jumping to line %lu pos %d to continue\n", (unsigned long) fileptr->lineno, startx);
|
||||
fprintf(stderr, "jumping to line %ld pos %lu to continue\n", (long)fileptr->lineno, (unsigned long)startx);
|
||||
#endif
|
||||
}
|
||||
if (nostart && startx == 0) {
|
||||
@@ -1960,15 +1983,22 @@ precalc_cleanup:
|
||||
* TRUE. */
|
||||
void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
{
|
||||
size_t current_len, orig_lenpt = 0, i = 0;
|
||||
size_t current_len, i = 0;
|
||||
#ifndef NANO_TINY
|
||||
size_t orig_lenpt = 0;
|
||||
#endif
|
||||
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
int char_buf_len;
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL);
|
||||
|
||||
current_len = strlen(openfile->current->data);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
orig_lenpt = strlenpt(openfile->current->data);
|
||||
#endif
|
||||
|
||||
while (i < output_len) {
|
||||
/* If allow_cntrls is TRUE, convert nulls and newlines
|
||||
@@ -2037,7 +2067,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* If we're wrapping text, we need to call edit_refresh(). */
|
||||
if (!ISSET(NO_WRAP))
|
||||
if (do_wrap(openfile->current, FALSE))
|
||||
if (do_wrap(openfile->current))
|
||||
edit_refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
@@ -2049,11 +2079,13 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Well we might also need a full refresh if we've changed the
|
||||
#ifndef NANO_TINY
|
||||
/* Well, we might also need a full refresh if we've changed the
|
||||
* line length to be a new multiple of COLS. */
|
||||
if (ISSET(SOFTWRAP) && edit_refresh_needed == FALSE)
|
||||
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
|
||||
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
|
||||
edit_refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
free(char_buf);
|
||||
|
||||
@@ -2072,10 +2104,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int optchr;
|
||||
ssize_t startline = 1;
|
||||
/* Line to try and start at. */
|
||||
ssize_t startcol = 1;
|
||||
/* Column to try and start at. */
|
||||
ssize_t startline = 0, startcol = 0;
|
||||
/* Target line and column when specified on the command line. */
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
bool fill_used = FALSE;
|
||||
/* Was the fill option used? */
|
||||
@@ -2186,11 +2216,11 @@ int main(int argc, char **argv)
|
||||
while ((optchr =
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
getopt_long(argc, argv,
|
||||
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$",
|
||||
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$",
|
||||
long_options, NULL)
|
||||
#else
|
||||
getopt(argc, argv,
|
||||
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tuvwxz$")
|
||||
"ABC:DEFGHIKLNOPQ:RST:UVWY:abcdefghijklmno:pqr:s:tvwxz$")
|
||||
#endif
|
||||
) != -1) {
|
||||
switch (optchr) {
|
||||
@@ -2226,15 +2256,17 @@ int main(int argc, char **argv)
|
||||
SET(MULTIBUFFER);
|
||||
break;
|
||||
#endif
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifndef NANO_TINY
|
||||
case 'G':
|
||||
SET(LOCKING);
|
||||
break;
|
||||
#endif
|
||||
#ifndef DISABLE_HISTORIES
|
||||
case 'H':
|
||||
SET(HISTORYLOG);
|
||||
break;
|
||||
#endif
|
||||
#ifndef DISABLE_NANORC
|
||||
case 'I':
|
||||
no_rcfiles = TRUE;
|
||||
break;
|
||||
@@ -2253,7 +2285,7 @@ int main(int argc, char **argv)
|
||||
case 'O':
|
||||
SET(MORE_SPACE);
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
case 'P':
|
||||
SET(POS_HISTORY);
|
||||
break;
|
||||
@@ -2329,9 +2361,11 @@ int main(int argc, char **argv)
|
||||
case 'p':
|
||||
SET(PRESERVE);
|
||||
break;
|
||||
#ifndef DISABLE_NANORC
|
||||
case 'q':
|
||||
SET(QUIET);
|
||||
break;
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
case 'r':
|
||||
if (!parse_num(optarg, &wrap_at)) {
|
||||
@@ -2350,11 +2384,6 @@ int main(int argc, char **argv)
|
||||
case 't':
|
||||
SET(TEMP_FILE);
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case 'u':
|
||||
SET(UNDOABLE);
|
||||
break;
|
||||
#endif
|
||||
case 'v':
|
||||
SET(VIEW_MODE);
|
||||
break;
|
||||
@@ -2391,14 +2420,16 @@ int main(int argc, char **argv)
|
||||
if (*(tail(argv[0])) == 'r')
|
||||
SET(RESTRICTED);
|
||||
|
||||
/* If we're using restricted mode, disable suspending, backups, and
|
||||
* reading rcfiles, since they all would allow reading from or
|
||||
* writing to files not specified on the command line. */
|
||||
/* If we're using restricted mode, disable suspending, backups,
|
||||
* rcfiles, and history files, since they all would allow reading
|
||||
* from or writing to files not specified on the command line. */
|
||||
if (ISSET(RESTRICTED)) {
|
||||
UNSET(SUSPEND);
|
||||
UNSET(BACKUP_FILE);
|
||||
#ifndef DISABLE_NANORC
|
||||
no_rcfiles = TRUE;
|
||||
UNSET(HISTORYLOG);
|
||||
UNSET(POS_HISTORY);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2496,7 +2527,7 @@ int main(int argc, char **argv)
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
/* Overwrite an rcfile "set nowrap" or --disable-wrapping-as-root
|
||||
if a --fill option was given on the command line. */
|
||||
* if a --fill option was given on the command line. */
|
||||
if (fill_used)
|
||||
UNSET(NO_WRAP);
|
||||
#endif
|
||||
@@ -2506,24 +2537,24 @@ int main(int argc, char **argv)
|
||||
if (ISSET(BOLD_TEXT))
|
||||
hilite_attribute = A_BOLD;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
/* Set up the search/replace history. */
|
||||
history_init();
|
||||
#ifndef DISABLE_NANORC
|
||||
if (!no_rcfiles) {
|
||||
if (ISSET(HISTORYLOG) || ISSET(POS_HISTORY)) {
|
||||
if (check_dotnano() == 0) {
|
||||
UNSET(HISTORYLOG);
|
||||
UNSET(POS_HISTORY);
|
||||
}
|
||||
/* Verify that the home directory and ~/.nano subdir exist. */
|
||||
if (ISSET(HISTORYLOG) || ISSET(POS_HISTORY)) {
|
||||
get_homedir();
|
||||
if (homedir == NULL || check_dotnano() == 0) {
|
||||
UNSET(HISTORYLOG);
|
||||
UNSET(POS_HISTORY);
|
||||
}
|
||||
if (ISSET(HISTORYLOG))
|
||||
load_history();
|
||||
if (ISSET(POS_HISTORY))
|
||||
load_poshistory();
|
||||
}
|
||||
#endif /* !DISABLE_NANORC */
|
||||
if (ISSET(HISTORYLOG))
|
||||
load_history();
|
||||
if (ISSET(POS_HISTORY))
|
||||
load_poshistory();
|
||||
#endif /* !DISABLE_HISTORIES */
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Set up the backup directory (unless we're using restricted mode,
|
||||
* in which case backups are disabled, since they would allow
|
||||
* reading from or writing to files not specified on the command
|
||||
@@ -2531,7 +2562,7 @@ int main(int argc, char **argv)
|
||||
* that backup files will be saved there. */
|
||||
if (!ISSET(RESTRICTED))
|
||||
init_backup_dir();
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
/* Set up the operating directory. This entails chdir()ing there,
|
||||
@@ -2687,7 +2718,7 @@ int main(int argc, char **argv)
|
||||
* new buffers. */
|
||||
{
|
||||
int i = optind + 1;
|
||||
ssize_t iline = 1, icol = 1;
|
||||
ssize_t iline = 0, icol = 0;
|
||||
|
||||
for (; i < argc; i++) {
|
||||
/* If there's a +LINE or +LINE,COLUMN flag here, it is
|
||||
@@ -2699,13 +2730,13 @@ int main(int argc, char **argv)
|
||||
else {
|
||||
open_buffer(argv[i], FALSE);
|
||||
|
||||
if (iline > 1 || icol > 1) {
|
||||
if (iline > 0 || icol > 0) {
|
||||
do_gotolinecolumn(iline, icol, FALSE, FALSE, FALSE,
|
||||
FALSE);
|
||||
iline = 1;
|
||||
icol = 1;
|
||||
}
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
#ifndef DISABLE_HISTORIES
|
||||
else {
|
||||
/* See if we have a POS history to use if we haven't overridden it. */
|
||||
ssize_t savedposline, savedposcol;
|
||||
@@ -2749,10 +2780,10 @@ int main(int argc, char **argv)
|
||||
precalc_multicolorinfo();
|
||||
#endif
|
||||
|
||||
if (startline > 1 || startcol > 1)
|
||||
if (startline > 0 || startcol > 0)
|
||||
do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE,
|
||||
FALSE);
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
#ifndef DISABLE_HISTORIES
|
||||
else {
|
||||
/* See if we have a POS history to use if we haven't overridden it. */
|
||||
ssize_t savedposline, savedposcol;
|
||||
@@ -2766,8 +2797,6 @@ int main(int argc, char **argv)
|
||||
display_buffer();
|
||||
|
||||
while (TRUE) {
|
||||
bool meta_key, func_key;
|
||||
|
||||
/* Make sure the cursor is in the edit window. */
|
||||
reset_cursor();
|
||||
wnoutrefresh(edit);
|
||||
@@ -2796,7 +2825,7 @@ int main(int argc, char **argv)
|
||||
currmenu = MMAIN;
|
||||
|
||||
/* Read in and interpret characters. */
|
||||
do_input(&meta_key, &func_key, TRUE);
|
||||
do_input(TRUE);
|
||||
}
|
||||
|
||||
/* We should never get here. */
|
||||
|
||||
42
src/nano.h
42
src/nano.h
@@ -31,8 +31,8 @@
|
||||
#ifdef NEED_XOPEN_SOURCE_EXTENDED
|
||||
#ifndef _XOPEN_SOURCE_EXTENDED
|
||||
#define _XOPEN_SOURCE_EXTENDED 1
|
||||
#endif /* _XOPEN_SOURCE_EXTENDED */
|
||||
#endif /* NEED_XOPEN_SOURCE_EXTENDED */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __TANDEM
|
||||
/* Tandem NonStop Kernel support. */
|
||||
@@ -175,7 +175,7 @@ typedef enum {
|
||||
} append_type;
|
||||
|
||||
typedef enum {
|
||||
UP_DIR, DOWN_DIR
|
||||
UPWARD, DOWNWARD
|
||||
} scroll_dir;
|
||||
|
||||
typedef enum {
|
||||
@@ -184,10 +184,14 @@ typedef enum {
|
||||
|
||||
typedef enum {
|
||||
CONTROL, META, FKEY, RAWINPUT
|
||||
} function_type;
|
||||
} key_type;
|
||||
|
||||
typedef enum {
|
||||
ADD, DEL, REPLACE, SPLIT, UNSPLIT, CUT, CUT_EOF, PASTE, ENTER, INSERT, OTHER
|
||||
ADD, DEL, BACK, CUT, CUT_EOF, REPLACE,
|
||||
#ifndef DISABLE_WRAPPING
|
||||
SPLIT_BEGIN, SPLIT_END,
|
||||
#endif
|
||||
JOIN, PASTE, INSERT, ENTER, OTHER
|
||||
} undo_type;
|
||||
|
||||
typedef struct color_pair {
|
||||
@@ -328,8 +332,6 @@ typedef struct undo {
|
||||
/* Where did this action begin or end. */
|
||||
char *strdata;
|
||||
/* String type data we will use for copying the affected line back. */
|
||||
char *strdata2;
|
||||
/* Sigh, need this too, it looks like. */
|
||||
int xflags;
|
||||
/* Some flag data we need. */
|
||||
|
||||
@@ -340,16 +342,15 @@ typedef struct undo {
|
||||
/* Copy of cutbottom. */
|
||||
bool mark_set;
|
||||
/* Was the marker set when we cut? */
|
||||
bool to_end;
|
||||
/* Was this a cut to end? */
|
||||
ssize_t mark_begin_lineno;
|
||||
/* copy copy copy */
|
||||
size_t mark_begin_x;
|
||||
/* Another shadow variable. */
|
||||
struct undo *next;
|
||||
} undo;
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
|
||||
#ifndef DISABLE_HISTORIES
|
||||
typedef struct poshiststruct {
|
||||
char *filename;
|
||||
/* The file. */
|
||||
@@ -359,9 +360,7 @@ typedef struct poshiststruct {
|
||||
/* x position in the file we left off on. */
|
||||
struct poshiststruct *next;
|
||||
} poshiststruct;
|
||||
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct openfilestruct {
|
||||
char *filename;
|
||||
@@ -441,14 +440,13 @@ typedef struct rcoption {
|
||||
long flag;
|
||||
/* The flag associated with it, if any. */
|
||||
} rcoption;
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct sc {
|
||||
char *keystr;
|
||||
/* The shortcut key for a function, ASCII version. */
|
||||
function_type type;
|
||||
/* What kind of function key it is, for convenience later. */
|
||||
key_type type;
|
||||
/* What kind of command key it is, for convenience later. */
|
||||
int seq;
|
||||
/* The actual sequence to check on the type is determined. */
|
||||
int menu;
|
||||
@@ -533,7 +531,6 @@ enum
|
||||
NO_NEWLINES,
|
||||
BOLD_TEXT,
|
||||
QUIET,
|
||||
UNDOABLE,
|
||||
SOFTWRAP,
|
||||
POS_HISTORY,
|
||||
LOCKING,
|
||||
@@ -566,18 +563,19 @@ enum
|
||||
#define NANO_CONTROL_7 31
|
||||
#define NANO_CONTROL_8 127
|
||||
|
||||
/* Codes for "modified" Arrow keys. Chosen like this because some
|
||||
* terminals produce them, and they are beyond KEY_MAX of ncurses. */
|
||||
#define CONTROL_LEFT 539
|
||||
#define CONTROL_RIGHT 554
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Extra bits for the undo function. */
|
||||
#define UNdel_del (1<<0)
|
||||
#define UNdel_backspace (1<<1)
|
||||
#define UNsplit_madenew (1<<2)
|
||||
#define UNdel_backspace (1<<1)
|
||||
#define UNcut_marked_forward (1<<2)
|
||||
#define UNcut_cutline (1<<3)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#define VIEW TRUE
|
||||
#define NOVIEW FALSE
|
||||
|
||||
/* The maximum number of entries displayed in the main shortcut list. */
|
||||
#define MAIN_VISIBLE (((COLS + 40) / 20) * 2)
|
||||
|
||||
|
||||
442
src/prompt.c
442
src/prompt.c
@@ -42,18 +42,13 @@ static bool reset_statusbar_x = FALSE;
|
||||
* prompt? */
|
||||
|
||||
/* Read in a character, interpret it as a shortcut or toggle if
|
||||
* necessary, and return it. Set meta_key to TRUE if the character is a
|
||||
* meta sequence, set func_key to TRUE if the character is a function
|
||||
* key, set have_shortcut to TRUE if the character is a shortcut
|
||||
* key, set ran_func to TRUE if we ran a function associated with a
|
||||
* necessary, and return it.
|
||||
* Set ran_func to TRUE if we ran a function associated with a
|
||||
* shortcut key, and set finished to TRUE if we're done after running
|
||||
* or trying to run a function associated with a shortcut key. If
|
||||
* allow_funcs is FALSE, don't actually run any functions associated
|
||||
* with shortcut keys. refresh_func is the function we will call to
|
||||
* refresh the edit window. */
|
||||
int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
bool *ran_func, bool *finished, bool allow_funcs, void
|
||||
(*refresh_func)(void))
|
||||
* or trying to run a function associated with a shortcut key.
|
||||
* refresh_func is the function we will call to refresh the edit window. */
|
||||
int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
void (*refresh_func)(void))
|
||||
{
|
||||
int input;
|
||||
/* The character we read in. */
|
||||
@@ -62,101 +57,94 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
static size_t kbinput_len = 0;
|
||||
/* The length of the input buffer. */
|
||||
const sc *s;
|
||||
bool have_shortcut = FALSE;
|
||||
const subnfunc *f;
|
||||
|
||||
*have_shortcut = FALSE;
|
||||
*ran_func = FALSE;
|
||||
*finished = FALSE;
|
||||
|
||||
/* Read in a character. */
|
||||
input = get_kbinput(bottomwin, meta_key, func_key);
|
||||
input = get_kbinput(bottomwin);
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
if (allow_funcs) {
|
||||
/* If we got a mouse click and it was on a shortcut, read in the
|
||||
* shortcut character. */
|
||||
if (*func_key && input == KEY_MOUSE) {
|
||||
if (do_statusbar_mouse() == 1)
|
||||
input = get_kbinput(bottomwin, meta_key, func_key);
|
||||
else {
|
||||
*meta_key = FALSE;
|
||||
*func_key = FALSE;
|
||||
input = ERR;
|
||||
}
|
||||
/* If we got a mouse click and it was on a shortcut, read in the
|
||||
* shortcut character. */
|
||||
if (func_key && input == KEY_MOUSE) {
|
||||
if (do_statusbar_mouse() == 1)
|
||||
input = get_kbinput(bottomwin);
|
||||
else {
|
||||
meta_key = FALSE;
|
||||
func_key = FALSE;
|
||||
input = ERR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check for a shortcut in the current list. */
|
||||
s = get_shortcut(currmenu, &input, meta_key);
|
||||
s = get_shortcut(&input);
|
||||
|
||||
/* If we got a shortcut from the current list, or a "universal"
|
||||
* statusbar prompt shortcut, set have_shortcut to TRUE. */
|
||||
*have_shortcut = (s != NULL);
|
||||
have_shortcut = (s != NULL);
|
||||
|
||||
/* If we got a non-high-bit control key, a meta key sequence, or a
|
||||
* function key, and it's not a shortcut or toggle, throw it out. */
|
||||
if (!*have_shortcut) {
|
||||
if (is_ascii_cntrl_char(input) || *meta_key || *func_key) {
|
||||
if (!have_shortcut) {
|
||||
if (is_ascii_cntrl_char(input) || meta_key || func_key) {
|
||||
beep();
|
||||
*meta_key = FALSE;
|
||||
*func_key = FALSE;
|
||||
meta_key = FALSE;
|
||||
func_key = FALSE;
|
||||
input = ERR;
|
||||
}
|
||||
}
|
||||
|
||||
if (allow_funcs) {
|
||||
/* If we got a character, and it isn't a shortcut or toggle,
|
||||
* it's a normal text character. Display the warning if we're
|
||||
* in view mode, or add the character to the input buffer if
|
||||
* we're not. */
|
||||
if (input != ERR && !*have_shortcut) {
|
||||
/* If we're using restricted mode, the filename isn't blank,
|
||||
* and we're at the "Write File" prompt, disable text
|
||||
* input. */
|
||||
if (!ISSET(RESTRICTED) || openfile->filename[0] == '\0' ||
|
||||
/* If we got a character, and it isn't a shortcut or toggle,
|
||||
* it's a normal text character. Display the warning if we're
|
||||
* in view mode, or add the character to the input buffer if
|
||||
* we're not. */
|
||||
if (input != ERR && !have_shortcut) {
|
||||
/* If we're using restricted mode, the filename isn't blank,
|
||||
* and we're at the "Write File" prompt, disable text input. */
|
||||
if (!ISSET(RESTRICTED) || openfile->filename[0] == '\0' ||
|
||||
currmenu != MWRITEFILE) {
|
||||
kbinput_len++;
|
||||
kbinput = (int *)nrealloc(kbinput, kbinput_len *
|
||||
sizeof(int));
|
||||
kbinput[kbinput_len - 1] = input;
|
||||
}
|
||||
kbinput_len++;
|
||||
kbinput = (int *)nrealloc(kbinput, kbinput_len * sizeof(int));
|
||||
kbinput[kbinput_len - 1] = input;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we got a shortcut, or if there aren't any other characters
|
||||
* waiting after the one we read in, we need to display all the
|
||||
* characters in the input buffer if it isn't empty. */
|
||||
if (have_shortcut || get_key_buffer_len() == 0) {
|
||||
if (kbinput != NULL) {
|
||||
/* Display all the characters in the input buffer at
|
||||
* once, filtering out control characters. */
|
||||
char *output = charalloc(kbinput_len + 1);
|
||||
size_t i;
|
||||
bool got_enter;
|
||||
/* Whether we got the Enter key. */
|
||||
|
||||
for (i = 0; i < kbinput_len; i++)
|
||||
output[i] = (char)kbinput[i];
|
||||
output[i] = '\0';
|
||||
|
||||
do_statusbar_output(output, kbinput_len, &got_enter, FALSE);
|
||||
|
||||
free(output);
|
||||
|
||||
/* Empty the input buffer. */
|
||||
kbinput_len = 0;
|
||||
free(kbinput);
|
||||
kbinput = NULL;
|
||||
}
|
||||
|
||||
/* If we got a shortcut, or if there aren't any other characters
|
||||
* waiting after the one we read in, we need to display all the
|
||||
* characters in the input buffer if it isn't empty. */
|
||||
if (*have_shortcut || get_key_buffer_len() == 0) {
|
||||
if (kbinput != NULL) {
|
||||
/* Display all the characters in the input buffer at
|
||||
* once, filtering out control characters. */
|
||||
char *output = charalloc(kbinput_len + 1);
|
||||
size_t i;
|
||||
bool got_enter;
|
||||
/* Whether we got the Enter key. */
|
||||
|
||||
for (i = 0; i < kbinput_len; i++)
|
||||
output[i] = (char)kbinput[i];
|
||||
output[i] = '\0';
|
||||
|
||||
do_statusbar_output(output, kbinput_len, &got_enter,
|
||||
FALSE);
|
||||
|
||||
free(output);
|
||||
|
||||
/* Empty the input buffer. */
|
||||
kbinput_len = 0;
|
||||
free(kbinput);
|
||||
kbinput = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (*have_shortcut) {
|
||||
if (have_shortcut) {
|
||||
if (s->scfunc == do_tab || s->scfunc == do_enter_void)
|
||||
;
|
||||
else if (s->scfunc == total_refresh)
|
||||
total_statusbar_refresh(refresh_func);
|
||||
else if (s->scfunc == do_cut_text_void) {
|
||||
else if (s->scfunc == do_cut_text_void) {
|
||||
/* If we're using restricted mode, the filename
|
||||
* isn't blank, and we're at the "Write File"
|
||||
* prompt, disable Cut. */
|
||||
@@ -167,44 +155,36 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
do_statusbar_right();
|
||||
else if (s->scfunc == do_left)
|
||||
do_statusbar_left();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
else if (s->scfunc == do_next_word_void)
|
||||
do_statusbar_next_word(FALSE);
|
||||
else if (s->scfunc == do_prev_word_void)
|
||||
do_statusbar_prev_word(FALSE);
|
||||
do_statusbar_prev_word(FALSE);
|
||||
#endif
|
||||
else if (s->scfunc == do_home)
|
||||
do_statusbar_home();
|
||||
do_statusbar_home();
|
||||
else if (s->scfunc == do_end)
|
||||
do_statusbar_end();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
else if (s->scfunc == do_find_bracket)
|
||||
do_statusbar_find_bracket();
|
||||
#endif
|
||||
do_statusbar_end();
|
||||
else if (s->scfunc == do_verbatim_input) {
|
||||
/* If we're using restricted mode, the filename
|
||||
* isn't blank, and we're at the "Write File"
|
||||
* prompt, disable verbatim input. */
|
||||
if (!ISSET(RESTRICTED) ||
|
||||
openfile->filename[0] == '\0' ||
|
||||
currmenu != MWRITEFILE) {
|
||||
bool got_enter;
|
||||
/* Whether we got the Enter key. */
|
||||
/* If we're using restricted mode, the filename
|
||||
* isn't blank, and we're at the "Write File"
|
||||
* prompt, disable verbatim input. */
|
||||
if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE ||
|
||||
openfile->filename[0] == '\0') {
|
||||
bool got_enter;
|
||||
/* Whether we got the Enter key. */
|
||||
|
||||
do_statusbar_verbatim_input(&got_enter);
|
||||
do_statusbar_verbatim_input(&got_enter);
|
||||
|
||||
/* If we got the Enter key, remove it from
|
||||
* the input buffer, set input to the key
|
||||
* value for Enter, and set finished to TRUE
|
||||
* to indicate that we're done. */
|
||||
if (got_enter) {
|
||||
get_input(NULL, 1);
|
||||
input = sc_seq_or(do_enter_void, 0);
|
||||
*finished = TRUE;
|
||||
}
|
||||
/* If we got the Enter key, remove it from the input
|
||||
* buffer, set input to the key value for Enter, and
|
||||
* set finished to TRUE to indicate that we're done. */
|
||||
if (got_enter) {
|
||||
get_input(NULL, 1);
|
||||
input = sc_seq_or(do_enter_void, 0);
|
||||
*finished = TRUE;
|
||||
}
|
||||
}
|
||||
} else if (s->scfunc == do_delete) {
|
||||
/* If we're using restricted mode, the filename
|
||||
* isn't blank, and we're at the "Write File"
|
||||
@@ -220,16 +200,17 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
'\0' || currmenu != MWRITEFILE)
|
||||
do_statusbar_backspace();
|
||||
} else {
|
||||
/* Handle the normal statusbar prompt shortcuts, setting
|
||||
/* Handle any other shortcut in the current menu, setting
|
||||
* ran_func to TRUE if we try to run their associated
|
||||
* functions and setting finished to TRUE to indicate
|
||||
* that we're done after running or trying to run their
|
||||
* associated functions. */
|
||||
f = sctofunc((sc *) s);
|
||||
if (s->scfunc != 0 && s->execute == TRUE) {
|
||||
if (s->scfunc != NULL) {
|
||||
*ran_func = TRUE;
|
||||
if (f && (!ISSET(VIEW_MODE) || (f->viewok)))
|
||||
f->scfunc();
|
||||
if (f && (!ISSET(VIEW_MODE) || f->viewok) &&
|
||||
f->scfunc != do_gotolinecolumn_void)
|
||||
f->scfunc();
|
||||
}
|
||||
*finished = TRUE;
|
||||
}
|
||||
@@ -650,162 +631,6 @@ void do_statusbar_verbatim_input(bool *got_enter)
|
||||
free(output);
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Search for a match to one of the two characters in bracket_set. If
|
||||
* reverse is TRUE, search backwards for the leftmost bracket.
|
||||
* Otherwise, search forwards for the rightmost bracket. Return TRUE if
|
||||
* we found a match, and FALSE otherwise. */
|
||||
bool find_statusbar_bracket_match(bool reverse, const char
|
||||
*bracket_set)
|
||||
{
|
||||
const char *rev_start = NULL, *found = NULL;
|
||||
|
||||
assert(mbstrlen(bracket_set) == 2);
|
||||
|
||||
/* rev_start might end up 1 character before the start or after the
|
||||
* end of the line. This won't be a problem because we'll skip over
|
||||
* it below in that case. */
|
||||
rev_start = reverse ? answer + (statusbar_x - 1) : answer +
|
||||
(statusbar_x + 1);
|
||||
|
||||
while (TRUE) {
|
||||
/* Look for either of the two characters in bracket_set.
|
||||
* rev_start can be 1 character before the start or after the
|
||||
* end of the line. In either case, just act as though no match
|
||||
* is found. */
|
||||
found = ((rev_start > answer && *(rev_start - 1) == '\0') ||
|
||||
rev_start < answer) ? NULL : (reverse ?
|
||||
mbrevstrpbrk(answer, bracket_set, rev_start) :
|
||||
mbstrpbrk(rev_start, bracket_set));
|
||||
|
||||
/* We've found a potential match. */
|
||||
if (found != NULL)
|
||||
break;
|
||||
|
||||
/* We've reached the start or end of the statusbar text, so
|
||||
* get out. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* We've definitely found something. */
|
||||
statusbar_x = found - answer;
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Search for a match to the bracket at the current cursor position, if
|
||||
* there is one. */
|
||||
void do_statusbar_find_bracket(void)
|
||||
{
|
||||
size_t statusbar_x_save, pww_save;
|
||||
const char *ch;
|
||||
/* The location in matchbrackets of the bracket at the current
|
||||
* cursor position. */
|
||||
int ch_len;
|
||||
/* The length of ch in bytes. */
|
||||
const char *wanted_ch;
|
||||
/* The location in matchbrackets of the bracket complementing
|
||||
* the bracket at the current cursor position. */
|
||||
int wanted_ch_len;
|
||||
/* The length of wanted_ch in bytes. */
|
||||
char *bracket_set;
|
||||
/* The pair of characters in ch and wanted_ch. */
|
||||
size_t i;
|
||||
/* Generic loop variable. */
|
||||
size_t matchhalf;
|
||||
/* The number of single-byte characters in one half of
|
||||
* matchbrackets. */
|
||||
size_t mbmatchhalf;
|
||||
/* The number of multibyte characters in one half of
|
||||
* matchbrackets. */
|
||||
size_t count = 1;
|
||||
/* The initial bracket count. */
|
||||
bool reverse;
|
||||
/* The direction we search. */
|
||||
char *found_ch;
|
||||
/* The character we find. */
|
||||
|
||||
assert(mbstrlen(matchbrackets) % 2 == 0);
|
||||
|
||||
ch = answer + statusbar_x;
|
||||
|
||||
if (ch == '\0' || (ch = mbstrchr(matchbrackets, ch)) == NULL)
|
||||
return;
|
||||
|
||||
/* Save where we are. */
|
||||
statusbar_x_save = statusbar_x;
|
||||
pww_save = statusbar_pww;
|
||||
|
||||
/* If we're on an opening bracket, which must be in the first half
|
||||
* of matchbrackets, we want to search forwards for a closing
|
||||
* bracket. If we're on a closing bracket, which must be in the
|
||||
* second half of matchbrackets, we want to search backwards for an
|
||||
* opening bracket. */
|
||||
matchhalf = 0;
|
||||
mbmatchhalf = mbstrlen(matchbrackets) / 2;
|
||||
|
||||
for (i = 0; i < mbmatchhalf; i++)
|
||||
matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL,
|
||||
NULL);
|
||||
|
||||
reverse = ((ch - matchbrackets) >= matchhalf);
|
||||
|
||||
/* If we're on an opening bracket, set wanted_ch to the character
|
||||
* that's matchhalf characters after ch. If we're on a closing
|
||||
* bracket, set wanted_ch to the character that's matchhalf
|
||||
* characters before ch. */
|
||||
wanted_ch = ch;
|
||||
|
||||
while (mbmatchhalf > 0) {
|
||||
if (reverse)
|
||||
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
|
||||
wanted_ch - matchbrackets);
|
||||
else
|
||||
wanted_ch += move_mbright(wanted_ch, 0);
|
||||
|
||||
mbmatchhalf--;
|
||||
}
|
||||
|
||||
ch_len = parse_mbchar(ch, NULL, NULL);
|
||||
wanted_ch_len = parse_mbchar(wanted_ch, NULL, NULL);
|
||||
|
||||
/* Fill bracket_set in with the values of ch and wanted_ch. */
|
||||
bracket_set = charalloc((mb_cur_max() * 2) + 1);
|
||||
strncpy(bracket_set, ch, ch_len);
|
||||
strncpy(bracket_set + ch_len, wanted_ch, wanted_ch_len);
|
||||
null_at(&bracket_set, ch_len + wanted_ch_len);
|
||||
|
||||
found_ch = charalloc(mb_cur_max() + 1);
|
||||
|
||||
while (TRUE) {
|
||||
if (find_statusbar_bracket_match(reverse, bracket_set)) {
|
||||
/* If we found an identical bracket, increment count. If we
|
||||
* found a complementary bracket, decrement it. */
|
||||
parse_mbchar(answer + statusbar_x, found_ch, NULL);
|
||||
count += (strncmp(found_ch, ch, ch_len) == 0) ? 1 : -1;
|
||||
|
||||
/* If count is zero, we've found a matching bracket. Update
|
||||
* the statusbar prompt and get out. */
|
||||
if (count == 0) {
|
||||
if (need_statusbar_horizontal_update(pww_save))
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* We didn't find either an opening or closing bracket.
|
||||
* Restore where we were, and get out. */
|
||||
statusbar_x = statusbar_x_save;
|
||||
statusbar_pww = pww_save;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clean up. */
|
||||
free(bracket_set);
|
||||
free(found_ch);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Return the placewewant associated with statusbar_x, i.e. the
|
||||
* zero-based column position of the cursor. The value will be no
|
||||
@@ -896,30 +721,26 @@ void total_statusbar_refresh(void (*refresh_func)(void))
|
||||
|
||||
/* Get a string of input at the statusbar prompt. This should only be
|
||||
* called from do_prompt(). */
|
||||
const sc *get_prompt_string(int *actual, bool allow_tabs,
|
||||
functionptrtype get_prompt_string(int *actual, bool allow_tabs,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
bool allow_files,
|
||||
bool *list,
|
||||
#endif
|
||||
const char *curranswer,
|
||||
bool *meta_key, bool *func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
filestruct **history_list,
|
||||
#endif
|
||||
void (*refresh_func)(void), int menu
|
||||
#ifndef DISABLE_TABCOMP
|
||||
, bool *list
|
||||
#endif
|
||||
)
|
||||
void (*refresh_func)(void))
|
||||
{
|
||||
int kbinput = ERR;
|
||||
bool have_shortcut, ran_func, finished;
|
||||
bool ran_func, finished;
|
||||
size_t curranswer_len;
|
||||
const sc *s;
|
||||
functionptrtype func;
|
||||
#ifndef DISABLE_TABCOMP
|
||||
bool tabbed = FALSE;
|
||||
/* Whether we've pressed Tab. */
|
||||
#endif
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
char *history = NULL;
|
||||
/* The current history string. */
|
||||
char *magichistory = NULL;
|
||||
@@ -932,7 +753,7 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
|
||||
/* The length of the original string that we're trying to
|
||||
* tab complete, if any. */
|
||||
#endif
|
||||
#endif /* !NANO_TINY */
|
||||
#endif /* !DISABLE_HISTORIES */
|
||||
|
||||
answer = mallocstrcpy(answer, curranswer);
|
||||
curranswer_len = strlen(answer);
|
||||
@@ -955,8 +776,6 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
|
||||
statusbar_pww = statusbar_xplustabs();
|
||||
}
|
||||
|
||||
currmenu = menu;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answer, (unsigned long) statusbar_x);
|
||||
#endif
|
||||
@@ -973,23 +792,21 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
* allow writing to files not specified on the command line. In
|
||||
* this case, disable all keys that would change the text if the
|
||||
* filename isn't blank and we're at the "Write File" prompt. */
|
||||
while (1) {
|
||||
kbinput = do_statusbar_input(meta_key, func_key, &have_shortcut,
|
||||
&ran_func, &finished, TRUE, refresh_func);
|
||||
while (TRUE) {
|
||||
kbinput = do_statusbar_input(&ran_func, &finished, refresh_func);
|
||||
assert(statusbar_x <= strlen(answer));
|
||||
|
||||
s = get_shortcut(currmenu, &kbinput, meta_key);
|
||||
func = func_from_key(&kbinput);
|
||||
|
||||
if (s)
|
||||
if (s->scfunc == do_cancel || s->scfunc == do_enter_void)
|
||||
break;
|
||||
if (func == do_cancel || func == do_enter_void)
|
||||
break;
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
if (s && s->scfunc != do_tab)
|
||||
if (func != do_tab)
|
||||
tabbed = FALSE;
|
||||
|
||||
if (s && s->scfunc == do_tab) {
|
||||
#ifndef NANO_TINY
|
||||
if (func == do_tab) {
|
||||
#ifndef DISABLE_HISTORIES
|
||||
if (history_list != NULL) {
|
||||
if (last_kbinput != sc_seq_or(do_tab, NANO_CONTROL_I))
|
||||
complete_len = strlen(answer);
|
||||
@@ -1001,7 +818,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
statusbar_x = strlen(answer);
|
||||
}
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
#endif
|
||||
if (allow_tabs)
|
||||
answer = input_tab(answer, allow_files, &statusbar_x,
|
||||
&tabbed, refresh_func, list);
|
||||
@@ -1009,8 +826,8 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
} else
|
||||
#endif /* !DISABLE_TABCOMP */
|
||||
#ifndef NANO_TINY
|
||||
if (s && s->scfunc == get_history_older_void) {
|
||||
#ifndef DISABLE_HISTORIES
|
||||
if (func == get_history_older_void) {
|
||||
if (history_list != NULL) {
|
||||
/* If we're scrolling up at the bottom of the history list
|
||||
* and answer isn't blank, save answer in magichistory. */
|
||||
@@ -1030,9 +847,9 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
* move to an older search, which means that finished has
|
||||
* been set to TRUE. Set it back to FALSE here, so that
|
||||
* we aren't kicked out of the statusbar prompt. */
|
||||
finished = FALSE;
|
||||
finished = FALSE;
|
||||
}
|
||||
} else if (s && s->scfunc == get_history_newer_void) {
|
||||
} else if (func == get_history_newer_void) {
|
||||
if (history_list != NULL) {
|
||||
/* Get the newer search from the history list and save it in
|
||||
* answer. If there is no newer search, don't do anything. */
|
||||
@@ -1059,8 +876,8 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
finished = FALSE;
|
||||
}
|
||||
} else
|
||||
#endif /* !NANO_TINY */
|
||||
if (s && s->scfunc == do_help_void) {
|
||||
#endif /* !DISABLE_HISTORIES */
|
||||
if (func == do_help_void) {
|
||||
update_statusbar_line(answer, statusbar_x);
|
||||
|
||||
/* This key has a shortcut-list entry when it's used to go to
|
||||
@@ -1076,7 +893,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
if (finished)
|
||||
break;
|
||||
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_TABCOMP)
|
||||
#if !defined(DISABLE_HISTORIES) && !defined(DISABLE_TABCOMP)
|
||||
last_kbinput = kbinput;
|
||||
#endif
|
||||
|
||||
@@ -1085,7 +902,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
}
|
||||
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
/* Set the current position in the history list to the bottom,
|
||||
* and free magichistory if we need to. */
|
||||
if (history_list != NULL) {
|
||||
@@ -1101,9 +918,8 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
* associated function, so reset statusbar_x and statusbar_pww. If
|
||||
* we've finished putting in an answer, reset the statusbar cursor
|
||||
* position too. */
|
||||
if (s) {
|
||||
if (s->scfunc == do_cancel || s->scfunc == do_enter_void ||
|
||||
ran_func) {
|
||||
if (func) {
|
||||
if (func == do_cancel || func == do_enter_void || ran_func) {
|
||||
statusbar_x = old_statusbar_x;
|
||||
statusbar_pww = old_pww;
|
||||
|
||||
@@ -1117,7 +933,8 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answe
|
||||
}
|
||||
|
||||
*actual = kbinput;
|
||||
return s;
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
/* Ask a question on the statusbar. The prompt will be stored in the
|
||||
@@ -1137,15 +954,14 @@ int do_prompt(bool allow_tabs,
|
||||
bool allow_files,
|
||||
#endif
|
||||
int menu, const char *curranswer,
|
||||
bool *meta_key, bool *func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
filestruct **history_list,
|
||||
#endif
|
||||
void (*refresh_func)(void), const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int retval;
|
||||
const sc *s;
|
||||
functionptrtype func;
|
||||
#ifndef DISABLE_TABCOMP
|
||||
bool list = FALSE;
|
||||
#endif
|
||||
@@ -1157,6 +973,7 @@ int do_prompt(bool allow_tabs,
|
||||
|
||||
prompt = charalloc(((COLS - 4) * mb_cur_max()) + 1);
|
||||
|
||||
currmenu = menu;
|
||||
bottombars(menu);
|
||||
|
||||
va_start(ap, msg);
|
||||
@@ -1164,20 +981,16 @@ int do_prompt(bool allow_tabs,
|
||||
va_end(ap);
|
||||
null_at(&prompt, actual_x(prompt, COLS - 4));
|
||||
|
||||
s = get_prompt_string(&retval, allow_tabs,
|
||||
func = get_prompt_string(&retval, allow_tabs,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
allow_files,
|
||||
&list,
|
||||
#endif
|
||||
curranswer,
|
||||
meta_key, func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
history_list,
|
||||
#endif
|
||||
refresh_func, menu
|
||||
#ifndef DISABLE_TABCOMP
|
||||
, &list
|
||||
#endif
|
||||
);
|
||||
refresh_func);
|
||||
|
||||
free(prompt);
|
||||
prompt = NULL;
|
||||
@@ -1189,9 +1002,9 @@ int do_prompt(bool allow_tabs,
|
||||
|
||||
/* If we left the prompt via Cancel or Enter, set the return value
|
||||
* properly. */
|
||||
if (s && s->scfunc == do_cancel)
|
||||
if (func == do_cancel)
|
||||
retval = -1;
|
||||
else if (s && s->scfunc == do_enter_void)
|
||||
else if (func == do_enter_void)
|
||||
retval = (*answer == '\0') ? -2 : 0;
|
||||
|
||||
blank_statusbar();
|
||||
@@ -1293,14 +1106,13 @@ int do_yesno_prompt(bool all, const char *msg)
|
||||
|
||||
do {
|
||||
int kbinput;
|
||||
bool meta_key, func_key;
|
||||
#ifndef DISABLE_MOUSE
|
||||
int mouse_x, mouse_y;
|
||||
#endif
|
||||
|
||||
currmenu = MYESNO;
|
||||
kbinput = get_kbinput(bottomwin, &meta_key, &func_key);
|
||||
s = get_shortcut(currmenu, &kbinput, &meta_key);
|
||||
kbinput = get_kbinput(bottomwin);
|
||||
s = get_shortcut(&kbinput);
|
||||
|
||||
if (s && s->scfunc == do_cancel)
|
||||
ok = -1;
|
||||
|
||||
131
src/proto.h
131
src/proto.h
@@ -30,9 +30,11 @@
|
||||
#ifndef NANO_TINY
|
||||
extern sigjmp_buf jump_buf;
|
||||
extern bool jump_buf_main;
|
||||
extern bool use_undo;
|
||||
#endif
|
||||
|
||||
extern bool meta_key;
|
||||
extern bool func_key;
|
||||
|
||||
#ifndef DISABLE_WRAPJUSTIFY
|
||||
extern ssize_t fill;
|
||||
extern ssize_t wrap_at;
|
||||
@@ -63,7 +65,6 @@ extern char *matchbrackets;
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
extern char *whitespace;
|
||||
extern int whitespace_len[2];
|
||||
extern undo_type last_action;
|
||||
#endif
|
||||
|
||||
extern const char *exit_tag;
|
||||
@@ -81,7 +82,8 @@ extern char *quoteerr;
|
||||
#else
|
||||
extern size_t quotelen;
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !DISABLE_JUSTIFY */
|
||||
|
||||
extern bool nodelay_mode;
|
||||
extern char *answer;
|
||||
|
||||
@@ -101,20 +103,20 @@ extern char *full_operating_dir;
|
||||
extern char *alt_speller;
|
||||
#endif
|
||||
|
||||
extern sc *sclist;
|
||||
extern subnfunc *allfuncs;
|
||||
extern subnfunc *exitfunc;
|
||||
extern subnfunc *uncutfunc;
|
||||
#ifndef DISABLE_COLOR
|
||||
extern syntaxtype *syntaxes;
|
||||
extern char *syntaxstr;
|
||||
#endif
|
||||
|
||||
extern bool edit_refresh_needed;
|
||||
extern const shortcut *currshortcut;
|
||||
extern int currmenu;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
extern int currmenu;
|
||||
extern sc *sclist;
|
||||
extern subnfunc *allfuncs;
|
||||
extern subnfunc *exitfunc;
|
||||
extern subnfunc *uncutfunc;
|
||||
|
||||
#ifndef DISABLE_HISTORIES
|
||||
extern filestruct *search_history;
|
||||
extern filestruct *searchage;
|
||||
extern filestruct *searchbot;
|
||||
@@ -122,7 +124,6 @@ extern filestruct *replace_history;
|
||||
extern filestruct *replaceage;
|
||||
extern filestruct *replacebot;
|
||||
extern poshiststruct *poshistory;
|
||||
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
@@ -138,12 +139,14 @@ extern color_pair interface_color_pair[NUMBER_OF_ELEMENTS];
|
||||
|
||||
extern char *homedir;
|
||||
|
||||
typedef void (*functionptrtype)(void);
|
||||
|
||||
/* All functions in browser.c. */
|
||||
#ifndef DISABLE_BROWSER
|
||||
char *do_browser(char *path, DIR *dir);
|
||||
char *do_browse_from(const char *inpath);
|
||||
void browser_init(const char *path, DIR *dir);
|
||||
void parse_browser_input(int *kbinput, bool *meta_key);
|
||||
functionptrtype parse_browser_input(int *kbinput);
|
||||
void browser_refresh(void);
|
||||
bool browser_select_filename(const char *needle);
|
||||
int filesearch_init(void);
|
||||
@@ -249,6 +252,7 @@ void color_update(void);
|
||||
|
||||
/* All functions in cut.c. */
|
||||
void cutbuffer_reset(void);
|
||||
bool keeping_cutbuffer(void);
|
||||
void cut_line(void);
|
||||
#ifndef NANO_TINY
|
||||
void cut_marked(void);
|
||||
@@ -257,7 +261,7 @@ void cut_to_eof(void);
|
||||
#endif
|
||||
void do_cut_text(
|
||||
#ifndef NANO_TINY
|
||||
bool copy_text, bool cut_till_end, bool undoing
|
||||
bool copy_text, bool cut_till_eof, bool undoing
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
@@ -265,7 +269,7 @@ void do_cut_text(
|
||||
void do_cut_text_void(void);
|
||||
#ifndef NANO_TINY
|
||||
void do_copy_text(void);
|
||||
void do_cut_till_end(void);
|
||||
void do_cut_till_eof(void);
|
||||
#endif
|
||||
void do_uncut_text(void);
|
||||
|
||||
@@ -333,7 +337,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool
|
||||
*lastwastab, void (*refresh_func)(void), bool *list);
|
||||
#endif
|
||||
const char *tail(const char *foo);
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
#ifndef DISABLE_HISTORIES
|
||||
char *histfilename(void);
|
||||
void load_history(void);
|
||||
bool writehist(FILE *hist, filestruct *histhead);
|
||||
@@ -341,16 +345,27 @@ void save_history(void);
|
||||
int check_dotnano(void);
|
||||
void load_poshistory(void);
|
||||
void save_poshistory(void);
|
||||
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos);
|
||||
int check_poshistory(const char *file, ssize_t *line, ssize_t *column);
|
||||
#endif
|
||||
#ifndef DISABLE_COLOR
|
||||
void set_lint_shortcuts(void);
|
||||
void set_spell_shortcuts(void);
|
||||
#endif
|
||||
|
||||
/* Some functions in global.c. */
|
||||
size_t length_of_list(int menu);
|
||||
key_type strtokeytype(const char *str);
|
||||
const sc *first_sc_for(int menu, void (*func)(void));
|
||||
int sc_seq_or(void (*func)(void), int defaultval);
|
||||
functionptrtype func_from_key(int *kbinput);
|
||||
void assign_keyinfo(sc *s);
|
||||
void print_sclist(void);
|
||||
void shortcut_init(void);
|
||||
#ifndef DISABLE_COLOR
|
||||
void set_lint_shortcuts(void);
|
||||
void set_spell_shortcuts(void);
|
||||
#endif
|
||||
const subnfunc *sctofunc(sc *s);
|
||||
const char *flagtostr(int flag);
|
||||
sc *strtosc(char *input);
|
||||
int strtomenu(char *input);
|
||||
#ifdef DEBUG
|
||||
void thanks_for_all_the_fish(void);
|
||||
#endif
|
||||
@@ -359,7 +374,7 @@ void thanks_for_all_the_fish(void);
|
||||
#ifndef DISABLE_HELP
|
||||
void do_help(void (*refresh_func)(void));
|
||||
void help_init(void);
|
||||
void parse_help_input(int *kbinput, bool *meta_key);
|
||||
functionptrtype parse_help_input(int *kbinput);
|
||||
size_t help_line_len(const char *ptr);
|
||||
#endif
|
||||
void do_help_void(void);
|
||||
@@ -453,7 +468,7 @@ void print_opt_full(const char *shortflag
|
||||
, const char *desc);
|
||||
void usage(void);
|
||||
void version(void);
|
||||
int no_more_space(void);
|
||||
int more_space(void);
|
||||
int no_help(void);
|
||||
void nano_disabled_msg(void);
|
||||
void do_exit(void);
|
||||
@@ -477,16 +492,15 @@ void enable_signals(void);
|
||||
void disable_flow_control(void);
|
||||
void enable_flow_control(void);
|
||||
void terminal_init(void);
|
||||
int do_input(bool *meta_key, bool *func_key, bool allow_funcs);
|
||||
int do_input(bool allow_funcs);
|
||||
#ifndef DISABLE_MOUSE
|
||||
int do_mouse(void);
|
||||
#endif
|
||||
void do_output(char *output, size_t output_len, bool allow_cntrls);
|
||||
|
||||
/* All functions in prompt.c. */
|
||||
int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
|
||||
bool *ran_func, bool *finished, bool allow_funcs, void
|
||||
(*refresh_func)(void));
|
||||
int do_statusbar_input(bool *ran_func, bool *finished,
|
||||
void (*refresh_func)(void));
|
||||
#ifndef DISABLE_MOUSE
|
||||
int do_statusbar_mouse(void);
|
||||
#endif
|
||||
@@ -504,38 +518,28 @@ bool do_statusbar_next_word(bool allow_punct);
|
||||
bool do_statusbar_prev_word(bool allow_punct);
|
||||
#endif
|
||||
void do_statusbar_verbatim_input(bool *got_enter);
|
||||
#ifndef NANO_TINY
|
||||
bool find_statusbar_bracket_match(bool reverse, const char
|
||||
*bracket_set);
|
||||
void do_statusbar_find_bracket(void);
|
||||
#endif
|
||||
size_t statusbar_xplustabs(void);
|
||||
size_t get_statusbar_page_start(size_t start_col, size_t column);
|
||||
void reset_statusbar_cursor(void);
|
||||
void update_statusbar_line(const char *curranswer, size_t index);
|
||||
bool need_statusbar_horizontal_update(size_t pww_save);
|
||||
void total_statusbar_refresh(void (*refresh_func)(void));
|
||||
const sc *get_prompt_string(int *value, bool allow_tabs,
|
||||
functionptrtype get_prompt_string(int *value, bool allow_tabs,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
bool allow_files,
|
||||
bool *list,
|
||||
#endif
|
||||
const char *curranswer,
|
||||
bool *meta_key, bool *func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
filestruct **history_list,
|
||||
#endif
|
||||
void (*refresh_func)(void), int menu
|
||||
#ifndef DISABLE_TABCOMP
|
||||
, bool *list
|
||||
#endif
|
||||
);
|
||||
void (*refresh_func)(void));
|
||||
int do_prompt(bool allow_tabs,
|
||||
#ifndef DISABLE_TABCOMP
|
||||
bool allow_files,
|
||||
#endif
|
||||
int menu, const char *curranswer,
|
||||
bool *meta_key, bool *func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
filestruct **history_list,
|
||||
#endif
|
||||
void (*refresh_func)(void), const char *msg, ...);
|
||||
@@ -543,9 +547,11 @@ void do_prompt_abort(void);
|
||||
int do_yesno_prompt(bool all, const char *msg);
|
||||
|
||||
/* Most functions in rcfile.c. */
|
||||
#if !defined(DISABLE_NANORC) || !defined(DISABLE_HISTORIES)
|
||||
char *parse_next_word(char *ptr);
|
||||
#endif
|
||||
#ifndef DISABLE_NANORC
|
||||
void rcfile_error(const char *msg, ...);
|
||||
char *parse_next_word(char *ptr);
|
||||
char *parse_argument(char *ptr);
|
||||
#ifndef DISABLE_COLOR
|
||||
char *parse_next_regex(char *ptr);
|
||||
@@ -564,7 +570,7 @@ void parse_rcfile(FILE *rcstream
|
||||
#endif
|
||||
);
|
||||
void do_rcfile(void);
|
||||
#endif
|
||||
#endif /* !DISABLE_NANORC */
|
||||
|
||||
/* All functions in search.c. */
|
||||
#ifdef HAVE_REGEX_H
|
||||
@@ -608,9 +614,12 @@ void goto_line_posx(ssize_t line, size_t pos_x);
|
||||
#ifndef NANO_TINY
|
||||
bool find_bracket_match(bool reverse, const char *bracket_set);
|
||||
void do_find_bracket(void);
|
||||
#ifndef DISABLE_NANORC
|
||||
bool history_has_changed(void);
|
||||
#ifndef DISABLE_TABCOMP
|
||||
char *get_history_completion(filestruct **h, const char *s, size_t len);
|
||||
#endif
|
||||
#endif
|
||||
#ifndef DISABLE_HISTORIES
|
||||
bool history_has_changed(void);
|
||||
void history_init(void);
|
||||
void history_reset(const filestruct *h);
|
||||
filestruct *find_history(const filestruct *h_start, const filestruct
|
||||
@@ -620,9 +629,6 @@ char *get_history_older(filestruct **h);
|
||||
char *get_history_newer(filestruct **h);
|
||||
void get_history_older_void(void);
|
||||
void get_history_newer_void(void);
|
||||
#ifndef DISABLE_TABCOMP
|
||||
char *get_history_completion(filestruct **h, const char *s, size_t len);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* All functions in text.c. */
|
||||
@@ -647,7 +653,7 @@ bool execute_command(const char *command);
|
||||
#endif
|
||||
#ifndef DISABLE_WRAPPING
|
||||
void wrap_reset(void);
|
||||
bool do_wrap(filestruct *line, bool undoing);
|
||||
bool do_wrap(filestruct *line);
|
||||
#endif
|
||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
|
||||
ssize_t break_line(const char *line, ssize_t goal
|
||||
@@ -744,10 +750,10 @@ void dump_filestruct_reverse(void);
|
||||
void get_key_buffer(WINDOW *win);
|
||||
size_t get_key_buffer_len(void);
|
||||
void unget_input(int *input, size_t input_len);
|
||||
void unget_kbinput(int kbinput, bool meta_key, bool func_key);
|
||||
void unget_kbinput(int kbinput, bool metakey, bool funckey);
|
||||
int *get_input(WINDOW *win, size_t input_len);
|
||||
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
|
||||
int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key);
|
||||
int get_kbinput(WINDOW *win);
|
||||
int parse_kbinput(WINDOW *win);
|
||||
int get_escape_seq_kbinput(const int *seq, size_t seq_len);
|
||||
int get_escape_seq_abcd(int kbinput);
|
||||
int parse_escape_seq_kbinput(WINDOW *win, int kbinput);
|
||||
@@ -763,8 +769,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
|
||||
#ifndef DISABLE_MOUSE
|
||||
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
|
||||
#endif
|
||||
const sc *get_shortcut(int menu, int *kbinput, bool *meta_key);
|
||||
const sc *first_sc_for(int menu, void (*func)(void));
|
||||
const sc *get_shortcut(int *kbinput);
|
||||
void blank_line(WINDOW *win, int y, int x, int n);
|
||||
void blank_titlebar(void);
|
||||
void blank_topbar(void);
|
||||
@@ -795,27 +800,11 @@ void display_main_list(void);
|
||||
void do_cursorpos(bool constant);
|
||||
void do_cursorpos_void(void);
|
||||
void do_replace_highlight(bool highlight, const char *word);
|
||||
const char *flagtostr(int flag);
|
||||
const subnfunc *sctofunc(sc *s);
|
||||
const subnfunc *getfuncfromkey(WINDOW *win);
|
||||
void print_sclist(void);
|
||||
sc *strtosc(char *input);
|
||||
function_type strtokeytype(const char *str);
|
||||
int strtomenu(char *input);
|
||||
void assign_keyinfo(sc *s);
|
||||
void xon_complaint(void);
|
||||
void xoff_complaint(void);
|
||||
int sc_seq_or (void (*func)(void), int defaultval);
|
||||
void do_suspend_void(void);
|
||||
|
||||
|
||||
void enable_nodelay(void);
|
||||
void disable_nodelay(void);
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
extern const char *regexp_msg;
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_EXTRA
|
||||
void do_credits(void);
|
||||
#endif
|
||||
@@ -836,7 +825,7 @@ void backup_file_void(void);
|
||||
void new_buffer_void(void);
|
||||
void backwards_void(void);
|
||||
void goto_dir_void(void);
|
||||
void no_replace_void(void);
|
||||
void ext_cmd_void(void);
|
||||
void flip_replace_void(void);
|
||||
void flip_execute_void(void);
|
||||
|
||||
#endif /* !PROTO_H */
|
||||
|
||||
78
src/rcfile.c
78
src/rcfile.c
@@ -95,7 +95,6 @@ static const rcoption rcopts[] = {
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTH_SCROLL},
|
||||
{"tabstospaces", TABS_TO_SPACES},
|
||||
{"undo", UNDOABLE},
|
||||
{"whitespace", 0},
|
||||
{"wordbounds", WORD_BOUNDS},
|
||||
{"softwrap", SOFTWRAP},
|
||||
@@ -144,7 +143,9 @@ void rcfile_error(const char *msg, ...)
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
#endif /* !DISABLE_NANORC */
|
||||
|
||||
#if !defined(DISABLE_NANORC) || !defined(DISABLE_HISTORIES)
|
||||
/* Parse the next word from the string, null-terminate it, and return
|
||||
* a pointer to the first character after the null terminator. The
|
||||
* returned pointer will point to '\0' if we hit the end of the line. */
|
||||
@@ -164,7 +165,9 @@ char *parse_next_word(char *ptr)
|
||||
|
||||
return ptr;
|
||||
}
|
||||
#endif /* !DISABLE_NANORC || !DISABLE_HISTORIES */
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
/* Parse an argument, with optional quotes, after a keyword that takes
|
||||
* one. If the next word starts with a ", we say that it ends with the
|
||||
* last " of the line. Otherwise, we interpret it as usual, so that the
|
||||
@@ -383,7 +386,7 @@ void parse_syntax(char *ptr)
|
||||
int check_bad_binding(sc *s)
|
||||
{
|
||||
#define BADLISTLEN 1
|
||||
int badtypes[BADLISTLEN] = {META};
|
||||
key_type badtypes[BADLISTLEN] = {META};
|
||||
int badseqs[BADLISTLEN] = { 91 };
|
||||
int i;
|
||||
|
||||
@@ -394,6 +397,24 @@ int check_bad_binding(sc *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check whether the given executable function is "universal" (meaning
|
||||
* any horizontal movement or deletion) and thus is present in almost
|
||||
* all menus. */
|
||||
bool is_universal(void (*func))
|
||||
{
|
||||
if (func == do_left || func == do_right ||
|
||||
func == do_home || func == do_end ||
|
||||
#ifndef NANO_TINY
|
||||
func == do_prev_word_void || func == do_next_word_void ||
|
||||
#endif
|
||||
func == do_verbatim_input || func == do_cut_text_void ||
|
||||
func == do_delete || func == do_backspace ||
|
||||
func == do_tab || func == do_enter)
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Bind or unbind a key combo, to or from a function. */
|
||||
void parse_binding(char *ptr, bool dobind)
|
||||
{
|
||||
@@ -446,7 +467,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
funcptr = ptr;
|
||||
ptr = parse_next_word(ptr);
|
||||
|
||||
if (!strcmp(funcptr, "")) {
|
||||
if (funcptr[0] == '\0') {
|
||||
rcfile_error(N_("Must specify a function to bind the key to"));
|
||||
return;
|
||||
}
|
||||
@@ -455,7 +476,7 @@ void parse_binding(char *ptr, bool dobind)
|
||||
menuptr = ptr;
|
||||
ptr = parse_next_word(ptr);
|
||||
|
||||
if (!strcmp(menuptr, "")) {
|
||||
if (menuptr[0] == '\0') {
|
||||
/* TRANSLATORS: Do not translate the word "all". */
|
||||
rcfile_error(N_("Must specify a menu (or \"all\") in which to bind/unbind the key"));
|
||||
return;
|
||||
@@ -484,6 +505,26 @@ void parse_binding(char *ptr, bool dobind)
|
||||
#endif
|
||||
|
||||
if (dobind) {
|
||||
subnfunc *f;
|
||||
int mask = 0;
|
||||
|
||||
/* Tally up the menus where the function exists. */
|
||||
for (f = allfuncs; f != NULL; f = f->next)
|
||||
if (f->scfunc == newsc->scfunc)
|
||||
mask = mask | f->menus;
|
||||
|
||||
/* Now limit the given menu to those where the function exists. */
|
||||
if (is_universal(newsc->scfunc))
|
||||
menu = menu & MMOST;
|
||||
else
|
||||
menu = menu & mask;
|
||||
|
||||
if (!menu) {
|
||||
rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr);
|
||||
free(newsc);
|
||||
return;
|
||||
}
|
||||
|
||||
newsc->keystr = keycopy;
|
||||
newsc->menu = menu;
|
||||
newsc->type = strtokeytype(newsc->keystr);
|
||||
@@ -763,8 +804,8 @@ void parse_colors(char *ptr, bool icase)
|
||||
0)) ? mallocstrcpy(NULL, fgstr) : NULL;
|
||||
|
||||
/* Lame way to skip another static counter. */
|
||||
newcolor->id = endsyntax->nmultis;
|
||||
endsyntax->nmultis++;
|
||||
newcolor->id = endsyntax->nmultis;
|
||||
endsyntax->nmultis++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -967,19 +1008,19 @@ static void check_vitals_mapped(void)
|
||||
int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE };
|
||||
|
||||
for (v = 0; v < VITALS; v++) {
|
||||
for (f = allfuncs; f != NULL; f = f->next) {
|
||||
if (f->scfunc == vitals[v] && f->menus & inmenus[v]) {
|
||||
const sc *s = first_sc_for(inmenus[v], f->scfunc);
|
||||
if (!s) {
|
||||
fprintf(stderr, _("Fatal error: no keys mapped for function "
|
||||
for (f = allfuncs; f != NULL; f = f->next) {
|
||||
if (f->scfunc == vitals[v] && f->menus & inmenus[v]) {
|
||||
const sc *s = first_sc_for(inmenus[v], f->scfunc);
|
||||
if (!s) {
|
||||
fprintf(stderr, _("Fatal error: no keys mapped for function "
|
||||
"\"%s\". Exiting.\n"), f->desc);
|
||||
fprintf(stderr, _("If needed, use nano with the -I option "
|
||||
fprintf(stderr, _("If needed, use nano with the -I option "
|
||||
"to adjust your nanorc settings.\n"));
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1265,9 +1306,6 @@ void parse_rcfile(FILE *rcstream
|
||||
else
|
||||
rcfile_error(N_("Cannot unset option \"%s\""),
|
||||
rcopts[i].name);
|
||||
/* If undo/redo was enabled, reinitialize the lists. */
|
||||
if (strcasecmp(rcopts[i].name, "undo") == 0)
|
||||
shortcut_init();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
53
src/search.c
53
src/search.c
@@ -32,7 +32,7 @@
|
||||
|
||||
static bool search_last_line = FALSE;
|
||||
/* Have we gone past the last line while searching? */
|
||||
#if !defined(NANO_TINY) && !defined(DISABLE_NANORC)
|
||||
#ifndef DISABLE_HISTORIES
|
||||
static bool history_changed = FALSE;
|
||||
/* Have any of the history lists changed? */
|
||||
#endif
|
||||
@@ -137,8 +137,6 @@ int search_init(bool replacing, bool use_answer)
|
||||
{
|
||||
int i = 0;
|
||||
char *buf;
|
||||
sc *s;
|
||||
bool meta_key = FALSE, func_key = FALSE;
|
||||
static char *backupstring = NULL;
|
||||
/* The search string we'll be using. */
|
||||
|
||||
@@ -177,8 +175,7 @@ int search_init(bool replacing, bool use_answer)
|
||||
TRUE,
|
||||
#endif
|
||||
replacing ? MREPLACE : MWHEREIS, backupstring,
|
||||
&meta_key, &func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
&search_history,
|
||||
#endif
|
||||
/* TRANSLATORS: This is the main search prompt. */
|
||||
@@ -216,13 +213,7 @@ int search_init(bool replacing, bool use_answer)
|
||||
statusbar(_("Cancelled"));
|
||||
return -1;
|
||||
} else {
|
||||
void (*func)(void) = NULL;
|
||||
|
||||
for (s = sclist; s != NULL; s = s->next)
|
||||
if ((s->menu & currmenu) && i == s->seq) {
|
||||
func = s->scfunc;
|
||||
break;
|
||||
}
|
||||
functionptrtype func = func_from_key(&i);
|
||||
|
||||
if (i == -2 || i == 0 ) {
|
||||
#ifdef HAVE_REGEX_H
|
||||
@@ -249,7 +240,7 @@ int search_init(bool replacing, bool use_answer)
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return 1;
|
||||
#endif
|
||||
} else if (func == do_replace || func == no_replace_void) {
|
||||
} else if (func == do_replace || func == flip_replace_void) {
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return -2; /* Call the opposite search function. */
|
||||
} else if (func == do_gotolinecolumn_void) {
|
||||
@@ -286,7 +277,6 @@ bool findnextstr(
|
||||
ssize_t current_y_find = openfile->current_y;
|
||||
filestruct *fileptr = openfile->current;
|
||||
const char *rev_start = fileptr->data, *found = NULL;
|
||||
const subnfunc *f;
|
||||
time_t lastkbcheck = time(NULL);
|
||||
|
||||
/* rev_start might end up 1 character before the start or after the
|
||||
@@ -305,9 +295,11 @@ bool findnextstr(
|
||||
enable_nodelay();
|
||||
while (TRUE) {
|
||||
if (time(NULL) - lastkbcheck > 1) {
|
||||
int input = parse_kbinput(edit);
|
||||
|
||||
lastkbcheck = time(NULL);
|
||||
f = getfuncfromkey(edit);
|
||||
if (f && f->scfunc == do_cancel) {
|
||||
|
||||
if (input && func_from_key(&input) == do_cancel) {
|
||||
statusbar(_("Cancelled"));
|
||||
return FALSE;
|
||||
}
|
||||
@@ -474,7 +466,7 @@ void do_search(void)
|
||||
else
|
||||
last_search = mallocstrcpy(last_search, answer);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
/* If answer is not "", add this search string to the search history
|
||||
* list. */
|
||||
if (answer[0] != '\0')
|
||||
@@ -910,7 +902,6 @@ void do_replace(void)
|
||||
{
|
||||
filestruct *edittop_save, *begin;
|
||||
size_t begin_x, pww_save;
|
||||
bool meta_key = FALSE, func_key = FALSE;
|
||||
ssize_t numreplaced;
|
||||
int i;
|
||||
|
||||
@@ -940,7 +931,7 @@ void do_replace(void)
|
||||
/* If answer is not "", add answer to the search history list and
|
||||
* copy answer into last_search. */
|
||||
if (answer[0] != '\0') {
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
update_history(&search_history, answer);
|
||||
#endif
|
||||
last_search = mallocstrcpy(last_search, answer);
|
||||
@@ -953,14 +944,13 @@ void do_replace(void)
|
||||
TRUE,
|
||||
#endif
|
||||
MREPLACEWITH, last_replace,
|
||||
&meta_key, &func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
&replace_history,
|
||||
#endif
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
edit_refresh, _("Replace with"));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
/* Add this replace string to the replace history list. i == 0
|
||||
* means that the string is not "". */
|
||||
if (i == 0)
|
||||
@@ -1027,11 +1017,9 @@ void goto_line_posx(ssize_t line, size_t pos_x)
|
||||
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
bool interactive, bool save_pos, bool allow_update)
|
||||
{
|
||||
bool meta_key = FALSE, func_key = FALSE;
|
||||
const sc *s;
|
||||
|
||||
if (interactive) {
|
||||
char *ans = mallocstrcpy(NULL, answer);
|
||||
functionptrtype func;
|
||||
|
||||
/* Ask for the line and column. */
|
||||
int i = do_prompt(FALSE,
|
||||
@@ -1039,8 +1027,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
TRUE,
|
||||
#endif
|
||||
MGOTOLINE, use_answer ? ans : "",
|
||||
&meta_key, &func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
#endif
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
@@ -1055,9 +1042,9 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
||||
return;
|
||||
}
|
||||
|
||||
s = get_shortcut(currmenu, &i, &meta_key);
|
||||
func = func_from_key(&i);
|
||||
|
||||
if (s && s->scfunc == gototext_void) {
|
||||
if (func == gototext_void) {
|
||||
/* Keep answer up on the statusbar. */
|
||||
search_init(TRUE, TRUE);
|
||||
|
||||
@@ -1304,14 +1291,14 @@ void do_find_bracket(void)
|
||||
free(bracket_set);
|
||||
free(found_ch);
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
#ifndef DISABLE_HISTORIES
|
||||
/* Indicate whether any of the history lists have changed. */
|
||||
bool history_has_changed(void)
|
||||
{
|
||||
return history_changed;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize the search and replace history lists. */
|
||||
void history_init(void)
|
||||
@@ -1408,10 +1395,8 @@ void update_history(filestruct **h, const char *s)
|
||||
*hbot = (*hbot)->next;
|
||||
(*hbot)->data = mallocstrcpy(NULL, "");
|
||||
|
||||
#ifndef DISABLE_NANORC
|
||||
/* Indicate that the history's been changed. */
|
||||
history_changed = TRUE;
|
||||
#endif
|
||||
|
||||
/* Set the current position in the list to the bottom. */
|
||||
*h = *hbot;
|
||||
@@ -1510,4 +1495,4 @@ char *get_history_completion(filestruct **h, const char *s, size_t len)
|
||||
return (char *)s;
|
||||
}
|
||||
#endif /* !DISABLE_TABCOMP */
|
||||
#endif /* !NANO_TINY */
|
||||
#endif /* !DISABLE_HISTORIES */
|
||||
|
||||
467
src/text.c
467
src/text.c
@@ -64,9 +64,11 @@ void do_mark(void)
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Delete the character under the cursor. */
|
||||
void do_delete(void)
|
||||
void do_deletion(undo_type action)
|
||||
{
|
||||
#ifndef NANO_TINY
|
||||
size_t orig_lenpt = 0;
|
||||
#endif
|
||||
|
||||
assert(openfile->current != NULL && openfile->current->data != NULL && openfile->current_x <= strlen(openfile->current->data));
|
||||
|
||||
@@ -81,10 +83,11 @@ void do_delete(void)
|
||||
assert(openfile->current_x < strlen(openfile->current->data));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
update_undo(DEL);
|
||||
#endif
|
||||
update_undo(action);
|
||||
|
||||
if (ISSET(SOFTWRAP))
|
||||
orig_lenpt = strlenpt(openfile->current->data);
|
||||
#endif
|
||||
|
||||
/* Let's get dangerous. */
|
||||
charmove(&openfile->current->data[openfile->current_x],
|
||||
@@ -106,7 +109,7 @@ void do_delete(void)
|
||||
assert(openfile->current_x == strlen(openfile->current->data));
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(DEL);
|
||||
add_undo(action);
|
||||
#endif
|
||||
/* If we're deleting at the end of a line, we need to call
|
||||
* edit_refresh(). */
|
||||
@@ -140,9 +143,11 @@ void do_delete(void)
|
||||
} else
|
||||
return;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP) && edit_refresh_needed == FALSE)
|
||||
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
|
||||
edit_refresh_needed = TRUE;
|
||||
#endif
|
||||
|
||||
set_modified();
|
||||
|
||||
@@ -150,6 +155,11 @@ void do_delete(void)
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
}
|
||||
|
||||
void do_delete(void)
|
||||
{
|
||||
do_deletion(DEL);
|
||||
}
|
||||
|
||||
/* Backspace over one character. That is, move the cursor left one
|
||||
* character, and then delete the character under the cursor. */
|
||||
void do_backspace(void)
|
||||
@@ -157,7 +167,7 @@ void do_backspace(void)
|
||||
if (openfile->current != openfile->fileage ||
|
||||
openfile->current_x > 0) {
|
||||
do_left();
|
||||
do_delete();
|
||||
do_deletion(BACK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,23 +380,15 @@ void undo_cut(undo *u)
|
||||
if (!u->cutbuffer)
|
||||
return;
|
||||
|
||||
cutbuffer = copy_filestruct(u->cutbuffer);
|
||||
|
||||
/* Compute cutbottom for the uncut using our copy. */
|
||||
for (cutbottom = cutbuffer; cutbottom->next != NULL; cutbottom = cutbottom->next)
|
||||
;
|
||||
|
||||
/* Get to where we need to uncut from. */
|
||||
if (u->xflags == UNcut_cutline)
|
||||
goto_line_posx(u->mark_begin_lineno, 0);
|
||||
else
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
|
||||
copy_from_filestruct(cutbuffer);
|
||||
free_filestruct(cutbuffer);
|
||||
cutbuffer = NULL;
|
||||
copy_from_filestruct(u->cutbuffer);
|
||||
|
||||
if (u->xflags == UNcut_cutline)
|
||||
if (u->xflags != UNcut_marked_forward && u->type != PASTE)
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
}
|
||||
|
||||
@@ -397,6 +399,10 @@ void redo_cut(undo *u)
|
||||
if (!u->cutbuffer)
|
||||
return;
|
||||
|
||||
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
|
||||
cutbuffer = NULL;
|
||||
cutbottom = NULL;
|
||||
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
|
||||
if (ISSET(NO_NEWLINES) && openfile->current->lineno != u->lineno) {
|
||||
@@ -404,33 +410,30 @@ void redo_cut(undo *u)
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
|
||||
openfile->mark_set = u->mark_set;
|
||||
if (cutbuffer)
|
||||
free(cutbuffer);
|
||||
cutbuffer = NULL;
|
||||
|
||||
openfile->mark_set = TRUE;
|
||||
openfile->mark_begin = fsfromline(u->mark_begin_lineno);
|
||||
|
||||
if (!ISSET(CUT_TO_END))
|
||||
openfile->mark_set = TRUE;
|
||||
|
||||
openfile->mark_begin_x = (u->xflags == UNcut_cutline) ? 0 : u->mark_begin_x;
|
||||
do_cut_text(FALSE, u->to_end, TRUE);
|
||||
|
||||
do_cut_text(FALSE, FALSE, TRUE);
|
||||
|
||||
openfile->mark_set = FALSE;
|
||||
openfile->mark_begin = NULL;
|
||||
openfile->mark_begin_x = 0;
|
||||
edit_refresh_needed = TRUE;
|
||||
|
||||
if (cutbuffer != NULL)
|
||||
free_filestruct(cutbuffer);
|
||||
cutbuffer = oldcutbuffer;
|
||||
cutbottom = oldcutbottom;
|
||||
}
|
||||
|
||||
/* Undo the last thing(s) we did. */
|
||||
void do_undo(void)
|
||||
{
|
||||
bool gotolinecolumn = FALSE;
|
||||
undo *u = openfile->current_undo;
|
||||
filestruct *t = 0;
|
||||
size_t len = 0;
|
||||
char *undidmsg, *data;
|
||||
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
|
||||
|
||||
if (!u) {
|
||||
statusbar(_("Nothing in undo buffer!"));
|
||||
@@ -439,7 +442,7 @@ void do_undo(void)
|
||||
|
||||
filestruct *f = fsfromline(u->mark_begin_lineno);
|
||||
if (!f) {
|
||||
statusbar(_("Internal error: can't match line %d. Please save your work."), u->mark_begin_lineno);
|
||||
statusbar(_("Internal error: can't match line %ld. Please save your work."), (long)u->mark_begin_lineno);
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
@@ -459,6 +462,7 @@ void do_undo(void)
|
||||
f->data = data;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
break;
|
||||
case BACK:
|
||||
case DEL:
|
||||
undidmsg = _("text delete");
|
||||
len = strlen(f->data) + strlen(u->strdata) + 1;
|
||||
@@ -471,30 +475,28 @@ void do_undo(void)
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
break;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
case SPLIT:
|
||||
case SPLIT_END:
|
||||
undidmsg = _("line wrap");
|
||||
f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
|
||||
strcpy(&f->data[strlen(f->data) - 1], u->strdata);
|
||||
if (u->strdata2 != NULL)
|
||||
f->next->data = mallocstrcpy(f->next->data, u->strdata2);
|
||||
else {
|
||||
filestruct *foo = openfile->current->next;
|
||||
unlink_node(foo);
|
||||
delete_node(foo);
|
||||
}
|
||||
renumber(f);
|
||||
gotolinecolumn = TRUE;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
openfile->current_undo = openfile->current_undo->next;
|
||||
openfile->last_action = OTHER;
|
||||
while (openfile->current_undo->type != SPLIT_BEGIN)
|
||||
do_undo();
|
||||
u = openfile->current_undo;
|
||||
f = openfile->current;
|
||||
break;
|
||||
#endif /* !DISABLE_WRAPPING */
|
||||
case UNSPLIT:
|
||||
case JOIN:
|
||||
undidmsg = _("line join");
|
||||
t = make_new_node(f);
|
||||
t->data = mallocstrcpy(NULL, u->strdata);
|
||||
data = mallocstrncpy(NULL, f->data, u->begin + 1);
|
||||
data[u->begin] = '\0';
|
||||
data = mallocstrncpy(NULL, f->data, u->mark_begin_x + 1);
|
||||
data[u->mark_begin_x] = '\0';
|
||||
free(f->data);
|
||||
f->data = data;
|
||||
splice_node(f, t, f->next);
|
||||
if (f == openfile->filebot)
|
||||
openfile->filebot = t;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
break;
|
||||
case CUT_EOF:
|
||||
@@ -510,8 +512,10 @@ void do_undo(void)
|
||||
undidmsg = _("line break");
|
||||
if (f->next) {
|
||||
filestruct *foo = f->next;
|
||||
f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(&f->next->data[u->mark_begin_x]) + 1);
|
||||
f->data = charealloc(f->data, strlen(f->data) + strlen(&f->next->data[u->mark_begin_x]) + 1);
|
||||
strcat(f->data, &f->next->data[u->mark_begin_x]);
|
||||
if (foo == openfile->filebot)
|
||||
openfile->filebot = f;
|
||||
unlink_node(foo);
|
||||
delete_node(foo);
|
||||
}
|
||||
@@ -519,6 +523,7 @@ void do_undo(void)
|
||||
break;
|
||||
case INSERT:
|
||||
undidmsg = _("text insert");
|
||||
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
|
||||
cutbuffer = NULL;
|
||||
cutbottom = NULL;
|
||||
/* When we updated mark_begin_lineno in update_undo, it was effectively
|
||||
@@ -529,6 +534,8 @@ void do_undo(void)
|
||||
openfile->mark_set = TRUE;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
cut_marked();
|
||||
if (u->cutbuffer != NULL)
|
||||
free_filestruct(u->cutbuffer);
|
||||
u->cutbuffer = cutbuffer;
|
||||
u->cutbottom = cutbottom;
|
||||
cutbuffer = oldcutbuffer;
|
||||
@@ -547,22 +554,21 @@ void do_undo(void)
|
||||
break;
|
||||
}
|
||||
|
||||
renumber(f);
|
||||
if (gotolinecolumn)
|
||||
do_gotolinecolumn(u->lineno, u->begin, FALSE, FALSE, FALSE, TRUE);
|
||||
statusbar(_("Undid action (%s)"), undidmsg);
|
||||
|
||||
renumber(f);
|
||||
openfile->current_undo = openfile->current_undo->next;
|
||||
openfile->last_action = OTHER;
|
||||
openfile->placewewant = xplustabs();
|
||||
set_modified();
|
||||
}
|
||||
|
||||
/* Redo the last thing(s) we undid. */
|
||||
void do_redo(void)
|
||||
{
|
||||
bool gotolinecolumn = FALSE;
|
||||
undo *u = openfile->undotop;
|
||||
size_t len = 0;
|
||||
char *undidmsg, *data;
|
||||
char *redidmsg, *data;
|
||||
|
||||
for (; u != NULL && u->next != openfile->current_undo; u = u->next)
|
||||
;
|
||||
@@ -587,7 +593,7 @@ void do_redo(void)
|
||||
|
||||
switch (u->type) {
|
||||
case ADD:
|
||||
undidmsg = _("text add");
|
||||
redidmsg = _("text add");
|
||||
len = strlen(f->data) + strlen(u->strdata) + 1;
|
||||
data = charalloc(len);
|
||||
strncpy(data, f->data, u->begin);
|
||||
@@ -597,8 +603,9 @@ void do_redo(void)
|
||||
f->data = data;
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
break;
|
||||
case BACK:
|
||||
case DEL:
|
||||
undidmsg = _("text delete");
|
||||
redidmsg = _("text delete");
|
||||
len = strlen(f->data) + strlen(u->strdata) + 1;
|
||||
data = charalloc(len);
|
||||
strncpy(data, f->data, u->begin);
|
||||
@@ -606,69 +613,73 @@ void do_redo(void)
|
||||
free(f->data);
|
||||
f->data = data;
|
||||
openfile->current_x = u->begin;
|
||||
openfile->placewewant = xplustabs();
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
break;
|
||||
case ENTER:
|
||||
undidmsg = _("line break");
|
||||
redidmsg = _("line break");
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
do_enter(TRUE);
|
||||
break;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
case SPLIT:
|
||||
undidmsg = _("line wrap");
|
||||
if (u->xflags & UNsplit_madenew)
|
||||
prepend_wrap = TRUE;
|
||||
do_wrap(f, TRUE);
|
||||
renumber(f);
|
||||
gotolinecolumn = TRUE;
|
||||
case SPLIT_BEGIN:
|
||||
redidmsg = _("line wrap");
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
openfile->current_undo = u;
|
||||
openfile->last_action = OTHER;
|
||||
while (openfile->current_undo->type != SPLIT_END)
|
||||
do_redo();
|
||||
u = openfile->current_undo;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
break;
|
||||
#endif /* !DISABLE_WRAPPING */
|
||||
case UNSPLIT:
|
||||
undidmsg = _("line join");
|
||||
case JOIN:
|
||||
redidmsg = _("line join");
|
||||
len = strlen(f->data) + strlen(u->strdata) + 1;
|
||||
f->data = charealloc(f->data, len);
|
||||
strcat(f->data, u->strdata);
|
||||
if (f->next != NULL) {
|
||||
filestruct *tmp = f->next;
|
||||
if (tmp == openfile->filebot)
|
||||
openfile->filebot = f;
|
||||
unlink_node(tmp);
|
||||
delete_node(tmp);
|
||||
}
|
||||
renumber(f);
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
|
||||
break;
|
||||
case CUT_EOF:
|
||||
case CUT:
|
||||
undidmsg = _("text cut");
|
||||
redidmsg = _("text cut");
|
||||
redo_cut(u);
|
||||
break;
|
||||
case PASTE:
|
||||
undidmsg = _("text uncut");
|
||||
redidmsg = _("text uncut");
|
||||
redo_paste(u);
|
||||
break;
|
||||
case REPLACE:
|
||||
undidmsg = _("text replace");
|
||||
redidmsg = _("text replace");
|
||||
data = u->strdata;
|
||||
u->strdata = f->data;
|
||||
f->data = data;
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
break;
|
||||
case INSERT:
|
||||
undidmsg = _("text insert");
|
||||
redidmsg = _("text insert");
|
||||
goto_line_posx(u->lineno, u->begin);
|
||||
copy_from_filestruct(u->cutbuffer);
|
||||
free_filestruct(u->cutbuffer);
|
||||
u->cutbuffer = NULL;
|
||||
break;
|
||||
default:
|
||||
undidmsg = _("Internal error: unknown type. Please save your work.");
|
||||
redidmsg = _("Internal error: unknown type. Please save your work.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (gotolinecolumn)
|
||||
do_gotolinecolumn(u->lineno, u->begin, FALSE, FALSE, FALSE, TRUE);
|
||||
statusbar(_("Redid action (%s)"), undidmsg);
|
||||
statusbar(_("Redid action (%s)"), redidmsg);
|
||||
|
||||
openfile->current_undo = u;
|
||||
openfile->last_action = OTHER;
|
||||
openfile->placewewant = xplustabs();
|
||||
set_modified();
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
@@ -843,17 +854,12 @@ void add_undo(undo_type current_action)
|
||||
char *data;
|
||||
openfilestruct *fs = openfile;
|
||||
/* Last thing we cut to set up the undo for uncut. */
|
||||
ssize_t wrap_loc;
|
||||
/* For calculating split beginning. */
|
||||
|
||||
if (!ISSET(UNDOABLE))
|
||||
return;
|
||||
|
||||
/* Ugh, if we were called while cutting not-to-end, non-marked, and
|
||||
* on the same lineno, we need to abort here. */
|
||||
u = fs->current_undo;
|
||||
if (u && u->mark_begin_lineno == fs->current->lineno &&
|
||||
((current_action == CUT && u->type == CUT && !u->mark_set) ||
|
||||
((current_action == CUT && u->type == CUT && !u->mark_set && keeping_cutbuffer()) ||
|
||||
(current_action == ADD && u->type == ADD && u->mark_begin_x == fs->current_x)))
|
||||
return;
|
||||
|
||||
@@ -873,70 +879,80 @@ void add_undo(undo_type current_action)
|
||||
u->type = current_action;
|
||||
u->lineno = fs->current->lineno;
|
||||
u->begin = fs->current_x;
|
||||
u->next = fs->undotop;
|
||||
fs->undotop = u;
|
||||
fs->current_undo = u;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
if (u->type == SPLIT_BEGIN) {
|
||||
/* Some action, most likely an ADD, was performed that invoked
|
||||
* do_wrap(). Rearrange the undo order so that this previous
|
||||
* action is after the SPLIT_BEGIN undo. */
|
||||
u->next = fs->undotop->next ;
|
||||
fs->undotop->next = u;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
u->next = fs->undotop;
|
||||
fs->undotop = u;
|
||||
fs->current_undo = u;
|
||||
}
|
||||
u->strdata = NULL;
|
||||
u->strdata2 = NULL;
|
||||
u->cutbuffer = NULL;
|
||||
u->cutbottom = NULL;
|
||||
u->mark_set = 0;
|
||||
u->mark_set = FALSE;
|
||||
u->mark_begin_lineno = fs->current->lineno;
|
||||
u->mark_begin_x = fs->current_x;
|
||||
u->xflags = 0;
|
||||
u->to_end = FALSE;
|
||||
|
||||
switch (u->type) {
|
||||
/* We need to start copying data into the undo buffer
|
||||
* or we won't be able to restore it later. */
|
||||
case ADD:
|
||||
break;
|
||||
case BACK:
|
||||
case DEL:
|
||||
if (u->begin != strlen(fs->current->data)) {
|
||||
char *char_buf = charalloc(mb_cur_max() + 1);
|
||||
int char_buf_len = parse_mbchar(&fs->current->data[u->begin], char_buf, NULL);
|
||||
char_buf[char_buf_len] = '\0';
|
||||
u->strdata = char_buf; /* Note: there is likely more memory allocated than necessary. */
|
||||
u->mark_begin_x += char_buf_len;
|
||||
null_at(&char_buf, char_buf_len);
|
||||
u->strdata = char_buf;
|
||||
if (u->type == BACK)
|
||||
u->mark_begin_x += char_buf_len;
|
||||
break;
|
||||
}
|
||||
/* Else purposely fall into unsplit code. */
|
||||
current_action = u->type = UNSPLIT;
|
||||
case UNSPLIT:
|
||||
/* Else purposely fall into the line-joining code. */
|
||||
case JOIN:
|
||||
if (fs->current->next) {
|
||||
if (u->type == BACK) {
|
||||
u->lineno = fs->current->next->lineno;
|
||||
u->begin = 0;
|
||||
}
|
||||
data = mallocstrcpy(NULL, fs->current->next->data);
|
||||
u->strdata = data;
|
||||
}
|
||||
current_action = u->type = JOIN;
|
||||
break;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
case SPLIT:
|
||||
wrap_loc = break_line(openfile->current->data, fill
|
||||
#ifndef DISABLE_HELP
|
||||
, FALSE
|
||||
#endif
|
||||
);
|
||||
u->strdata = mallocstrcpy(NULL, &openfile->current->data[wrap_loc]);
|
||||
/* Don't bother saving the next line if we're not prepending,
|
||||
* as a new line will be created. */
|
||||
if (prepend_wrap)
|
||||
u->strdata2 = mallocstrcpy(NULL, fs->current->next->data);
|
||||
u->begin = wrap_loc;
|
||||
case SPLIT_BEGIN:
|
||||
current_action = fs->undotop->type;
|
||||
break;
|
||||
case SPLIT_END:
|
||||
break;
|
||||
#endif /* !DISABLE_WRAPPING */
|
||||
case INSERT:
|
||||
break;
|
||||
case REPLACE:
|
||||
data = mallocstrcpy(NULL, fs->current->data);
|
||||
u->strdata = data;
|
||||
break;
|
||||
case CUT_EOF:
|
||||
u->to_end = TRUE;
|
||||
cutbuffer_reset();
|
||||
break;
|
||||
case CUT:
|
||||
cutbuffer_reset();
|
||||
u->mark_set = openfile->mark_set;
|
||||
if (u->mark_set) {
|
||||
u->mark_begin_lineno = openfile->mark_begin->lineno;
|
||||
u->mark_begin_x = openfile->mark_begin_x;
|
||||
}
|
||||
else if (!ISSET(CUT_TO_END) && !u->to_end) {
|
||||
else if (!ISSET(CUT_TO_END)) {
|
||||
/* The entire line is being cut regardless of the cursor position. */
|
||||
u->begin = 0;
|
||||
u->xflags = UNcut_cutline;
|
||||
@@ -947,7 +963,7 @@ void add_undo(undo_type current_action)
|
||||
statusbar(_("Internal error: cannot set up uncut. Please save your work."));
|
||||
else {
|
||||
if (u->cutbuffer)
|
||||
free(u->cutbuffer);
|
||||
free_filestruct(u->cutbuffer);
|
||||
u->cutbuffer = copy_filestruct(cutbuffer);
|
||||
u->mark_begin_lineno = fs->current->lineno;
|
||||
u->mark_begin_x = fs->current_x;
|
||||
@@ -963,8 +979,8 @@ void add_undo(undo_type current_action)
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d, type = %d\n",
|
||||
fs->current->data, (unsigned long) fs->current_x, u->begin, current_action);
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %lu, type = %d\n",
|
||||
fs->current->data, (unsigned long)fs->current_x, (unsigned long)u->begin, current_action);
|
||||
fprintf(stderr, "left add_undo...\n");
|
||||
#endif
|
||||
fs->last_action = current_action;
|
||||
@@ -979,14 +995,11 @@ void update_undo(undo_type action)
|
||||
undo *u;
|
||||
openfilestruct *fs = openfile;
|
||||
|
||||
if (!ISSET(UNDOABLE))
|
||||
return;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %lu",
|
||||
action, fs->last_action, (unsigned long) openfile->current->lineno);
|
||||
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %ld",
|
||||
action, fs->last_action, (long)openfile->current->lineno);
|
||||
if (fs->current_undo)
|
||||
fprintf(stderr, "fs->current_undo->lineno = %lu\n", (unsigned long) fs->current_undo->lineno);
|
||||
fprintf(stderr, "fs->current_undo->lineno = %ld\n", (long)fs->current_undo->lineno);
|
||||
else
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
@@ -994,7 +1007,7 @@ void update_undo(undo_type action)
|
||||
/* Change to an add if we're not using the same undo struct
|
||||
* that we should be using. */
|
||||
if (action != fs->last_action
|
||||
|| (action != ENTER && action != CUT && action != INSERT && action != SPLIT
|
||||
|| (action != ENTER && action != CUT && action != INSERT
|
||||
&& openfile->current->lineno != fs->current_undo->lineno)) {
|
||||
add_undo(action);
|
||||
return;
|
||||
@@ -1006,12 +1019,12 @@ void update_undo(undo_type action)
|
||||
switch (u->type) {
|
||||
case ADD: {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d\n",
|
||||
fs->current->data, (unsigned long) fs->current_x, u->begin);
|
||||
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %lu\n",
|
||||
fs->current->data, (unsigned long)fs->current_x, (unsigned long)u->begin);
|
||||
#endif
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
size_t char_buf_len = parse_mbchar(&fs->current->data[u->mark_begin_x], char_buf, NULL);
|
||||
u->strdata = addstrings(u->strdata, u->strdata?strlen(u->strdata):0, char_buf, char_buf_len);
|
||||
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_buf_len);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "current undo data now \"%s\"\n", u->strdata);
|
||||
#endif
|
||||
@@ -1019,25 +1032,26 @@ void update_undo(undo_type action)
|
||||
u->mark_begin_x = fs->current_x;
|
||||
break;
|
||||
}
|
||||
case BACK:
|
||||
case DEL: {
|
||||
char *char_buf = charalloc(mb_cur_max());
|
||||
size_t char_buf_len = parse_mbchar(&fs->current->data[fs->current_x], char_buf, NULL);
|
||||
if (fs->current_x == u->begin) {
|
||||
if (fs->current_x == u->begin) {
|
||||
/* They're deleting. */
|
||||
u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_buf_len);
|
||||
u->mark_begin_x = fs->current_x;
|
||||
} else if (fs->current_x == u->begin - char_buf_len){
|
||||
} else if (fs->current_x == u->begin - char_buf_len) {
|
||||
/* They're backspacing. */
|
||||
u->strdata = addstrings(char_buf, char_buf_len, u->strdata, strlen(u->strdata));
|
||||
u->begin = fs->current_x;
|
||||
} else {
|
||||
/* They deleted something else on the line. */
|
||||
free(char_buf);
|
||||
add_undo(DEL);
|
||||
add_undo(u->type);
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "current undo data now \"%s\"\nu->begin = %d\n", u->strdata, u->begin);
|
||||
fprintf(stderr, "current undo data now \"%s\"\nu->begin = %lu\n", u->strdata, (unsigned long)u->begin);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -1046,7 +1060,7 @@ void update_undo(undo_type action)
|
||||
if (!cutbuffer)
|
||||
break;
|
||||
if (u->cutbuffer)
|
||||
free(u->cutbuffer);
|
||||
free_filestruct(u->cutbuffer);
|
||||
u->cutbuffer = copy_filestruct(cutbuffer);
|
||||
if (u->mark_set) {
|
||||
/* If the "marking" operation was from right-->left or
|
||||
@@ -1060,14 +1074,19 @@ void update_undo(undo_type action)
|
||||
ssize_t line = u->lineno;
|
||||
u->lineno = u->mark_begin_lineno;
|
||||
u->mark_begin_lineno = line;
|
||||
}
|
||||
} else if (!ISSET(CUT_TO_END)) {
|
||||
} else
|
||||
u->xflags = UNcut_marked_forward;
|
||||
} else {
|
||||
/* Compute cutbottom for the uncut using our copy. */
|
||||
u->cutbottom = u->cutbuffer;
|
||||
while (u->cutbottom->next != NULL)
|
||||
u->cutbottom = u->cutbottom->next;
|
||||
if (!u->to_end)
|
||||
u->lineno++;
|
||||
u->lineno = u->mark_begin_lineno + u->cutbottom->lineno - u->cutbuffer->lineno;
|
||||
if (ISSET(CUT_TO_END) || u->type == CUT_EOF) {
|
||||
u->begin = strlen(u->cutbottom->data);
|
||||
if(u->lineno == u->mark_begin_lineno)
|
||||
u->begin += u->mark_begin_x;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case REPLACE:
|
||||
@@ -1082,13 +1101,10 @@ void update_undo(undo_type action)
|
||||
u->mark_begin_x = fs->current_x;
|
||||
break;
|
||||
#ifndef DISABLE_WRAPPING
|
||||
case SPLIT:
|
||||
/* This will only be called if we made a completely new line,
|
||||
* and as such we should note that so we can destroy it later. */
|
||||
u->xflags = UNsplit_madenew;
|
||||
break;
|
||||
case SPLIT_BEGIN:
|
||||
case SPLIT_END:
|
||||
#endif /* !DISABLE_WRAPPING */
|
||||
case UNSPLIT:
|
||||
case JOIN:
|
||||
/* These cases are handled by the earlier check for a new line and action. */
|
||||
case OTHER:
|
||||
break;
|
||||
@@ -1097,9 +1113,7 @@ void update_undo(undo_type action)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Done in update_undo (type was %d)\n", action);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
#ifndef DISABLE_WRAPPING
|
||||
@@ -1110,10 +1124,8 @@ void wrap_reset(void)
|
||||
prepend_wrap = FALSE;
|
||||
}
|
||||
|
||||
/* We wrap the given line. Precondition: we assume the cursor has been
|
||||
* moved forward since the last typed character. Return TRUE if we
|
||||
* wrapped, and FALSE otherwise. */
|
||||
bool do_wrap(filestruct *line, bool undoing)
|
||||
/* Try wrapping the given line. Return TRUE if wrapped, FALSE otherwise. */
|
||||
bool do_wrap(filestruct *line)
|
||||
{
|
||||
size_t line_len;
|
||||
/* The length of the line we wrap. */
|
||||
@@ -1129,16 +1141,10 @@ bool do_wrap(filestruct *line, bool undoing)
|
||||
/* The text after the wrap point. */
|
||||
size_t after_break_len;
|
||||
/* The length of after_break. */
|
||||
bool prepending = FALSE;
|
||||
/* Do we prepend to the next line? */
|
||||
const char *next_line = NULL;
|
||||
/* The next line, minus indentation. */
|
||||
size_t next_line_len = 0;
|
||||
/* The length of next_line. */
|
||||
char *new_line = NULL;
|
||||
/* The line we create. */
|
||||
size_t new_line_len = 0;
|
||||
/* The eventual length of new_line. */
|
||||
|
||||
/* There are three steps. First, we decide where to wrap. Then, we
|
||||
* create the new wrap line. Finally, we clean up. */
|
||||
@@ -1178,9 +1184,6 @@ bool do_wrap(filestruct *line, bool undoing)
|
||||
return FALSE;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (!undoing)
|
||||
add_undo(SPLIT);
|
||||
|
||||
/* If autoindent is turned on, and we're on the character just after
|
||||
* the indentation, we don't wrap. */
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
@@ -1191,8 +1194,14 @@ bool do_wrap(filestruct *line, bool undoing)
|
||||
if (wrap_loc == indent_len)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
add_undo(SPLIT_BEGIN);
|
||||
#endif
|
||||
|
||||
size_t old_x = openfile->current_x;
|
||||
filestruct * oldLine = openfile->current;
|
||||
openfile->current = line;
|
||||
|
||||
/* Step 2, making the new wrap line. It will consist of indentation
|
||||
* followed by the text after the wrap point, optionally followed by
|
||||
* a space (if the text after the wrap point doesn't end in a blank)
|
||||
@@ -1212,9 +1221,15 @@ bool do_wrap(filestruct *line, bool undoing)
|
||||
const char *end = after_break + move_mbleft(after_break,
|
||||
after_break_len);
|
||||
|
||||
/* Go to the end of the line. */
|
||||
openfile->current_x = line_len;
|
||||
|
||||
/* If after_break doesn't end in a blank, make sure it ends in a
|
||||
* space. */
|
||||
if (!is_blank_mbchar(end)) {
|
||||
#ifndef NANO_TINY
|
||||
add_undo(ADD);
|
||||
#endif
|
||||
line_len++;
|
||||
line->data = charealloc(line->data, line_len + 1);
|
||||
line->data[line_len - 1] = ' ';
|
||||
@@ -1222,128 +1237,42 @@ bool do_wrap(filestruct *line, bool undoing)
|
||||
after_break = line->data + wrap_loc;
|
||||
after_break_len++;
|
||||
openfile->totsize++;
|
||||
openfile->current_x++;
|
||||
#ifndef NANO_TINY
|
||||
update_undo(ADD);
|
||||
#endif
|
||||
}
|
||||
|
||||
next_line = line->next->data;
|
||||
next_line_len = strlen(next_line);
|
||||
|
||||
if (after_break_len + next_line_len <= fill) {
|
||||
prepending = TRUE;
|
||||
new_line_len += next_line_len;
|
||||
/* Delete the LF to join the two lines. */
|
||||
do_delete();
|
||||
/* Delete any leading blanks from the joined-on line. */
|
||||
while (is_blank_mbchar(&line->data[openfile->current_x]))
|
||||
do_delete();
|
||||
renumber(line);
|
||||
}
|
||||
}
|
||||
|
||||
/* new_line_len is now the length of the text that will be wrapped
|
||||
* to the next line, plus (if we're prepending to it) the length of
|
||||
* the text of the next line. */
|
||||
new_line_len += after_break_len;
|
||||
/* Go to the wrap location and split the line there. */
|
||||
openfile->current_x = wrap_loc;
|
||||
do_enter(FALSE);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
if (prepending) {
|
||||
/* If we're prepending, the indentation will come from the
|
||||
* next line. */
|
||||
indent_string = next_line;
|
||||
indent_len = indent_length(indent_string);
|
||||
next_line += indent_len;
|
||||
} else {
|
||||
/* Otherwise, it will come from this line, in which case
|
||||
* we should increase new_line_len to make room for it. */
|
||||
new_line_len += indent_len;
|
||||
openfile->totsize += mbstrnlen(indent_string, indent_len);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now we allocate the new line and copy the text into it. */
|
||||
new_line = charalloc(new_line_len + 1);
|
||||
new_line[0] = '\0';
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
/* Copy the indentation. */
|
||||
strncpy(new_line, indent_string, indent_len);
|
||||
new_line[indent_len] = '\0';
|
||||
new_line_len += indent_len;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Copy all the text after the wrap point of the current line. */
|
||||
strcat(new_line, after_break);
|
||||
|
||||
/* Break the current line at the wrap point. */
|
||||
null_at(&line->data, wrap_loc);
|
||||
|
||||
if (prepending) {
|
||||
#ifndef NANO_TINY
|
||||
if (!undoing)
|
||||
update_undo(SPLIT);
|
||||
#endif
|
||||
/* If we're prepending, copy the text from the next line, minus
|
||||
* the indentation that we already copied above. */
|
||||
strcat(new_line, next_line);
|
||||
|
||||
free(line->next->data);
|
||||
line->next->data = new_line;
|
||||
|
||||
/* If the NO_NEWLINES flag isn't set, and text has been added to
|
||||
* the magicline, make a new magicline. */
|
||||
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
|
||||
new_magicline();
|
||||
if (old_x < wrap_loc) {
|
||||
openfile->current_x = old_x;
|
||||
openfile->current = oldLine;
|
||||
prepend_wrap = TRUE;
|
||||
} else {
|
||||
/* Otherwise, make a new line and copy the text after where we
|
||||
* broke this line to the beginning of the new line. */
|
||||
splice_node(openfile->current, make_new_node(openfile->current),
|
||||
openfile->current->next);
|
||||
|
||||
/* If the current line is the last line of the file, move the
|
||||
* last line of the file down to the next line. */
|
||||
if (openfile->filebot == openfile->current)
|
||||
openfile->filebot = openfile->current->next;
|
||||
|
||||
openfile->current->next->data = new_line;
|
||||
|
||||
openfile->totsize++;
|
||||
}
|
||||
|
||||
/* Step 3, clean up. Reposition the cursor and mark, and do some
|
||||
* other sundry things. */
|
||||
|
||||
/* Set the prepend_wrap flag, so that later wraps of this line will
|
||||
* be prepended to the next line. */
|
||||
prepend_wrap = TRUE;
|
||||
|
||||
/* Each line knows its number. We recalculate these if we inserted
|
||||
* a new line. */
|
||||
if (!prepending)
|
||||
renumber(line);
|
||||
|
||||
/* If the cursor was after the break point, we must move it. We
|
||||
* also clear the prepend_wrap flag in this case. */
|
||||
if (openfile->current_x > wrap_loc) {
|
||||
openfile->current_x += (old_x - wrap_loc);
|
||||
prepend_wrap = FALSE;
|
||||
|
||||
openfile->current = openfile->current->next;
|
||||
openfile->current_x -= wrap_loc
|
||||
#ifndef NANO_TINY
|
||||
- indent_len
|
||||
#endif
|
||||
;
|
||||
openfile->placewewant = xplustabs();
|
||||
}
|
||||
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* If the mark was on this line after the wrap point, we move it
|
||||
* down. If it was on the next line and we prepended to that line,
|
||||
* we move it right. */
|
||||
if (openfile->mark_set) {
|
||||
if (openfile->mark_begin == line && openfile->mark_begin_x >
|
||||
wrap_loc) {
|
||||
openfile->mark_begin = line->next;
|
||||
openfile->mark_begin_x -= wrap_loc - indent_len + 1;
|
||||
} else if (prepending && openfile->mark_begin == line->next)
|
||||
openfile->mark_begin_x += after_break_len;
|
||||
}
|
||||
add_undo(SPLIT_END);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
@@ -1439,16 +1368,7 @@ ssize_t break_line(const char *line, ssize_t goal
|
||||
char_len = parse_mbchar(line, NULL, NULL);
|
||||
line += char_len;
|
||||
|
||||
while (*line != '\0' && (is_blank_mbchar(line)
|
||||
#ifndef DISABLE_HELP
|
||||
|| (newln && *line == '\n')
|
||||
#endif
|
||||
)) {
|
||||
#ifndef DISABLE_HELP
|
||||
if (newln && *line == '\n')
|
||||
break;
|
||||
#endif
|
||||
|
||||
while (*line != '\0' && is_blank_mbchar(line)) {
|
||||
char_len = parse_mbchar(line, NULL, NULL);
|
||||
|
||||
line += char_len;
|
||||
@@ -1972,7 +1892,6 @@ void do_justify(bool full_justify)
|
||||
bool modified_save = openfile->modified;
|
||||
|
||||
int kbinput;
|
||||
bool meta_key, func_key;
|
||||
const sc *s;
|
||||
|
||||
/* Move to the beginning of the current line, so that justifying at
|
||||
@@ -2287,12 +2206,13 @@ void do_justify(bool full_justify)
|
||||
|
||||
/* Display the shortcut list with UnJustify. */
|
||||
uncutfunc->desc = unjust_tag;
|
||||
currmenu = MMAIN;
|
||||
display_main_list();
|
||||
|
||||
/* Now get a keystroke and see if it's unjustify. If not, put back
|
||||
* the keystroke and return. */
|
||||
kbinput = do_input(&meta_key, &func_key, FALSE);
|
||||
s = get_shortcut(MMAIN, &kbinput, &meta_key);
|
||||
kbinput = do_input(FALSE);
|
||||
s = get_shortcut(&kbinput);
|
||||
|
||||
if (s && s->scfunc == do_uncut_text) {
|
||||
/* Splice the justify buffer back into the file, but only if we
|
||||
@@ -2384,7 +2304,6 @@ bool do_int_spell_fix(const char *word)
|
||||
char *save_search, *save_replace;
|
||||
size_t match_len, current_x_save = openfile->current_x;
|
||||
size_t pww_save = openfile->placewewant;
|
||||
bool meta_key = FALSE, func_key = FALSE;
|
||||
filestruct *edittop_save = openfile->edittop;
|
||||
filestruct *current_save = openfile->current;
|
||||
/* Save where we are. */
|
||||
@@ -2472,8 +2391,7 @@ bool do_int_spell_fix(const char *word)
|
||||
TRUE,
|
||||
#endif
|
||||
MSPELL, word,
|
||||
&meta_key, &func_key,
|
||||
#ifndef NANO_TINY
|
||||
#ifndef DISABLE_HISTORIES
|
||||
NULL,
|
||||
#endif
|
||||
edit_refresh, _("Edit a replacement")) == -1);
|
||||
@@ -3113,7 +3031,7 @@ void do_linter(void)
|
||||
while ((bytesread = read(lint_fd[0], read_buff_ptr,
|
||||
pipe_buff_size)) > 0) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "text.c:do_linter:%d bytes (%s)\n", bytesread, read_buff_ptr);
|
||||
fprintf(stderr, "text.c:do_linter:%ld bytes (%s)\n", (long)bytesread, read_buff_ptr);
|
||||
#endif
|
||||
read_buff_read += bytesread;
|
||||
read_buff_size += pipe_buff_size;
|
||||
@@ -3170,7 +3088,7 @@ void do_linter(void)
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "text.c:do_lint:Successful parse! %d:%d:%s\n", tmplineno, tmpcolno, message);
|
||||
fprintf(stderr, "text.c:do_lint:Successful parse! %ld:%ld:%s\n", (long)tmplineno, (long)tmpcolno, message);
|
||||
#endif
|
||||
/* Nice. We have a lint message we can use. */
|
||||
parsesuccess++;
|
||||
@@ -3215,7 +3133,6 @@ void do_linter(void)
|
||||
while (1) {
|
||||
ssize_t tmpcol = 1;
|
||||
int kbinput;
|
||||
bool meta_key, func_key;
|
||||
|
||||
if (curlint->colno > 0)
|
||||
tmpcol = curlint->colno;
|
||||
@@ -3270,8 +3187,8 @@ void do_linter(void)
|
||||
bottombars(MLINTER);
|
||||
}
|
||||
|
||||
kbinput = get_kbinput(bottomwin, &meta_key, &func_key);
|
||||
s = get_shortcut(currmenu, &kbinput, &meta_key);
|
||||
kbinput = get_kbinput(bottomwin);
|
||||
s = get_shortcut(&kbinput);
|
||||
tmplint = curlint;
|
||||
|
||||
if (!s)
|
||||
|
||||
25
src/utils.c
25
src/utils.c
@@ -72,8 +72,8 @@ bool parse_num(const char *str, ssize_t *val)
|
||||
|
||||
assert(str != NULL);
|
||||
|
||||
/* Man page for strtol() says this is required, and
|
||||
it looks like it is! */
|
||||
/* The manual page for strtol() says this is required, and
|
||||
* it looks like it is! */
|
||||
errno = 0;
|
||||
|
||||
j = (ssize_t)strtol(str, &first_error, 10);
|
||||
@@ -261,7 +261,8 @@ bool regexp_bol_or_eol(const regex_t *preg, const char *string)
|
||||
|
||||
/* Fix the regex if we're on platforms which require an adjustment
|
||||
* from GNU-style to BSD-style word boundaries. */
|
||||
const char *fixbounds(const char *r) {
|
||||
const char *fixbounds(const char *r)
|
||||
{
|
||||
#ifndef GNU_WORDBOUNDS
|
||||
int i, j = 0;
|
||||
char *r2 = charalloc(strlen(r) * 5);
|
||||
@@ -272,15 +273,15 @@ const char *fixbounds(const char *r) {
|
||||
#endif
|
||||
|
||||
for (i = 0; i < strlen(r); i++) {
|
||||
if (r[i] != '\0' && r[i] == '\\' && (r[i+1] == '>' || r[i+1] == '<')) {
|
||||
strcpy(&r2[j], "[[:");
|
||||
r2[j+3] = r[i+1];
|
||||
strcpy(&r2[j+4], ":]]");
|
||||
i++;
|
||||
j += 6;
|
||||
} else
|
||||
r2[j] = r[i];
|
||||
j++;
|
||||
if (r[i] != '\0' && r[i] == '\\' && (r[i + 1] == '>' || r[i + 1] == '<')) {
|
||||
strcpy(&r2[j], "[[:");
|
||||
r2[j + 3] = r[i + 1];
|
||||
strcpy(&r2[j + 4], ":]]");
|
||||
i++;
|
||||
j += 6;
|
||||
} else
|
||||
r2[j] = r[i];
|
||||
j++;
|
||||
}
|
||||
r2[j] = '\0';
|
||||
r3 = mallocstrcpy(NULL, r2);
|
||||
|
||||
257
src/winio.c
257
src/winio.c
@@ -124,7 +124,7 @@ void get_key_buffer(WINDOW *win)
|
||||
errcount = 0;
|
||||
if (nodelay_mode) {
|
||||
if ((input = wgetch(win)) == ERR)
|
||||
return;
|
||||
return;
|
||||
} else
|
||||
while ((input = wgetch(win)) == ERR) {
|
||||
errcount++;
|
||||
@@ -224,17 +224,17 @@ void unget_input(int *input, size_t input_len)
|
||||
}
|
||||
|
||||
/* Put back the character stored in kbinput, putting it in byte range
|
||||
* beforehand. If meta_key is TRUE, put back the Escape character after
|
||||
* putting back kbinput. If func_key is TRUE, put back the function key
|
||||
* beforehand. If metakey is TRUE, put back the Escape character after
|
||||
* putting back kbinput. If funckey is TRUE, put back the function key
|
||||
* (a value outside byte range) without putting it in byte range. */
|
||||
void unget_kbinput(int kbinput, bool meta_key, bool func_key)
|
||||
void unget_kbinput(int kbinput, bool metakey, bool funckey)
|
||||
{
|
||||
if (!func_key)
|
||||
if (!funckey)
|
||||
kbinput = (char)kbinput;
|
||||
|
||||
unget_input(&kbinput, 1);
|
||||
|
||||
if (meta_key) {
|
||||
if (metakey) {
|
||||
kbinput = NANO_CONTROL_3;
|
||||
unget_input(&kbinput, 1);
|
||||
}
|
||||
@@ -298,20 +298,19 @@ int *get_input(WINDOW *win, size_t input_len)
|
||||
|
||||
/* Read in a single character. If it's ignored, swallow it and go on.
|
||||
* Otherwise, try to translate it from ASCII, meta key sequences, escape
|
||||
* sequences, and/or extended keypad values. Set meta_key to TRUE when
|
||||
* we get a meta key sequence, and set func_key to TRUE when we get an
|
||||
* extended keypad value. Supported extended keypad values consist of
|
||||
* sequences, and/or extended keypad values. Supported extended keypad
|
||||
* values consist of
|
||||
* [arrow key], Ctrl-[arrow key], Shift-[arrow key], Enter, Backspace,
|
||||
* the editing keypad (Insert, Delete, Home, End, PageUp, and PageDown),
|
||||
* the function keypad (F1-F16), and the numeric keypad with NumLock
|
||||
* off. */
|
||||
int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
int get_kbinput(WINDOW *win)
|
||||
{
|
||||
int kbinput;
|
||||
|
||||
/* Read in a character and interpret it. Continue doing this until
|
||||
* we get a recognized value or sequence. */
|
||||
while ((kbinput = parse_kbinput(win, meta_key, func_key)) == ERR)
|
||||
while ((kbinput = parse_kbinput(win)) == ERR)
|
||||
;
|
||||
|
||||
/* If we read from the edit window, blank the statusbar if we need
|
||||
@@ -326,13 +325,13 @@ int get_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
* sequences into their corresponding key values. Set meta_key to TRUE
|
||||
* when we get a meta key sequence, and set func_key to TRUE when we get
|
||||
* a function key. */
|
||||
int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
int parse_kbinput(WINDOW *win)
|
||||
{
|
||||
static int escapes = 0, byte_digits = 0;
|
||||
int *kbinput, retval = ERR;
|
||||
|
||||
*meta_key = FALSE;
|
||||
*func_key = FALSE;
|
||||
meta_key = FALSE;
|
||||
func_key = FALSE;
|
||||
|
||||
/* Read in a character. */
|
||||
if (nodelay_mode) {
|
||||
@@ -379,7 +378,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
* meta key sequence mode. Set meta_key to
|
||||
* TRUE, and save the lowercase version of the
|
||||
* non-escape character as the result. */
|
||||
*meta_key = TRUE;
|
||||
meta_key = TRUE;
|
||||
retval = tolower(*kbinput);
|
||||
} else
|
||||
/* One escape followed by a non-escape, and
|
||||
@@ -469,7 +468,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
* escape counter, set meta_key to TRUE, and
|
||||
* interpret the escape sequence. */
|
||||
escapes = 0;
|
||||
*meta_key = TRUE;
|
||||
meta_key = TRUE;
|
||||
retval = parse_escape_seq_kbinput(win,
|
||||
*kbinput);
|
||||
}
|
||||
@@ -545,9 +544,9 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
/* Slang doesn't support KEY_SDC. */
|
||||
case KEY_SDC:
|
||||
if (ISSET(REBIND_DELETE))
|
||||
retval = sc_seq_or(do_delete, *kbinput);
|
||||
retval = sc_seq_or(do_delete, *kbinput);
|
||||
else
|
||||
retval = sc_seq_or(do_backspace, *kbinput);
|
||||
retval = sc_seq_or(do_backspace, *kbinput);
|
||||
break;
|
||||
#endif
|
||||
#ifdef KEY_SIC
|
||||
@@ -634,16 +633,26 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
|
||||
retval = ERR;
|
||||
break;
|
||||
#endif
|
||||
case CONTROL_LEFT:
|
||||
#ifndef NANO_TINY
|
||||
retval = sc_seq_or(do_prev_word_void, 0);
|
||||
#endif
|
||||
break;
|
||||
case CONTROL_RIGHT:
|
||||
#ifndef NANO_TINY
|
||||
retval = sc_seq_or(do_next_word_void, 0);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
/* If our result is an extended keypad value (i.e. a value
|
||||
* outside of byte range), set func_key to TRUE. */
|
||||
if (retval != ERR)
|
||||
*func_key = !is_byte(retval);
|
||||
func_key = !is_byte(retval);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "parse_kbinput(): kbinput = %d, meta_key = %s, func_key = %s, escapes = %d, byte_digits = %d, retval = %d\n", *kbinput, *meta_key ? "TRUE" : "FALSE", *func_key ? "TRUE" : "FALSE", escapes, byte_digits, retval);
|
||||
fprintf(stderr, "parse_kbinput(): kbinput = %d, meta_key = %s, func_key = %s, escapes = %d, byte_digits = %d, retval = %d\n", *kbinput, meta_key ? "TRUE" : "FALSE", func_key ? "TRUE" : "FALSE", escapes, byte_digits, retval);
|
||||
#endif
|
||||
|
||||
free(kbinput);
|
||||
@@ -709,11 +718,15 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
* Terminal. */
|
||||
case 'B': /* Esc O 1 ; 5 B == Ctrl-Down on
|
||||
* Terminal. */
|
||||
retval = get_escape_seq_abcd(seq[4]);
|
||||
break;
|
||||
case 'C': /* Esc O 1 ; 5 C == Ctrl-Right on
|
||||
* Terminal. */
|
||||
retval = CONTROL_RIGHT;
|
||||
break;
|
||||
case 'D': /* Esc O 1 ; 5 D == Ctrl-Left on
|
||||
* Terminal. */
|
||||
retval = get_escape_seq_abcd(seq[4]);
|
||||
retval = CONTROL_LEFT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -806,10 +819,14 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
break;
|
||||
case 'a': /* Esc O a == Ctrl-Up on rxvt. */
|
||||
case 'b': /* Esc O b == Ctrl-Down on rxvt. */
|
||||
case 'c': /* Esc O c == Ctrl-Right on rxvt. */
|
||||
case 'd': /* Esc O d == Ctrl-Left on rxvt. */
|
||||
retval = get_escape_seq_abcd(seq[1]);
|
||||
break;
|
||||
case 'c': /* Esc O c == Ctrl-Right on rxvt. */
|
||||
retval = CONTROL_RIGHT;
|
||||
break;
|
||||
case 'd': /* Esc O d == Ctrl-Left on rxvt. */
|
||||
retval = CONTROL_LEFT;
|
||||
break;
|
||||
case 'j': /* Esc O j == '*' on numeric keypad with
|
||||
* NumLock off on VT100/VT220/VT320/xterm/
|
||||
* rxvt/Eterm/Terminal. */
|
||||
@@ -896,10 +913,14 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
switch (seq[1]) {
|
||||
case 'a': /* Esc o a == Ctrl-Up on Eterm. */
|
||||
case 'b': /* Esc o b == Ctrl-Down on Eterm. */
|
||||
case 'c': /* Esc o c == Ctrl-Right on Eterm. */
|
||||
case 'd': /* Esc o d == Ctrl-Left on Eterm. */
|
||||
retval = get_escape_seq_abcd(seq[1]);
|
||||
break;
|
||||
case 'c': /* Esc o c == Ctrl-Right on Eterm. */
|
||||
retval = CONTROL_RIGHT;
|
||||
break;
|
||||
case 'd': /* Esc o d == Ctrl-Left on Eterm. */
|
||||
retval = CONTROL_LEFT;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '[':
|
||||
@@ -968,11 +989,15 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
* xterm. */
|
||||
case 'B': /* Esc [ 1 ; 5 B == Ctrl-Down on
|
||||
* xterm. */
|
||||
retval = get_escape_seq_abcd(seq[4]);
|
||||
break;
|
||||
case 'C': /* Esc [ 1 ; 5 C == Ctrl-Right on
|
||||
* xterm. */
|
||||
retval = CONTROL_RIGHT;
|
||||
break;
|
||||
case 'D': /* Esc [ 1 ; 5 D == Ctrl-Left on
|
||||
* xterm. */
|
||||
retval = get_escape_seq_abcd(seq[4]);
|
||||
retval = CONTROL_LEFT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1053,7 +1078,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
|
||||
break;
|
||||
case '6': /* Esc [ 6 ~ == PageDown on VT220/VT320/
|
||||
* Linux console/xterm/Terminal;
|
||||
* Esc [ 6 ^ == PageDown on Eterm. */
|
||||
* Esc [ 6 ^ == PageDown on Eterm. */
|
||||
retval = sc_seq_or(do_page_down, 0);
|
||||
break;
|
||||
case '7': /* Esc [ 7 ~ == Home on rxvt. */
|
||||
@@ -1696,14 +1721,14 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||
/* Go through the list of functions to determine which
|
||||
* shortcut in the current menu we released/clicked on. */
|
||||
for (f = allfuncs; f != NULL; f = f->next) {
|
||||
if ((f->menus & currmenu) == 0)
|
||||
if ((f->menus & currmenu) == 0)
|
||||
continue;
|
||||
#ifndef DISABLE_HELP
|
||||
if (!f->help || strlen(f->help) == 0)
|
||||
continue;
|
||||
#endif
|
||||
if (first_sc_for(currmenu, f->scfunc) == NULL)
|
||||
continue;
|
||||
continue;
|
||||
/* Tick off an actually shown shortcut. */
|
||||
j -= 1;
|
||||
if (j == 0)
|
||||
@@ -1715,9 +1740,10 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||
|
||||
/* And put the corresponding key into the keyboard buffer. */
|
||||
if (f != NULL) {
|
||||
const sc *s = first_sc_for(currmenu, f->scfunc);
|
||||
unget_kbinput(s->seq, s->type == META, FALSE);
|
||||
const sc *s = first_sc_for(currmenu, f->scfunc);
|
||||
unget_kbinput(s->seq, s->type == META, s->type == FKEY);
|
||||
}
|
||||
return 1;
|
||||
} else
|
||||
/* Handle releases/clicks of the first mouse button that
|
||||
* aren't on the current shortcut list elsewhere. */
|
||||
@@ -1743,7 +1769,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||
* wheel is equivalent to moving down three lines. */
|
||||
for (i = 0; i < 3; i++)
|
||||
unget_kbinput((mevent.bstate & BUTTON4_PRESSED) ?
|
||||
sc_seq_or(do_up_void, 0) : sc_seq_or(do_down_void, 0),
|
||||
sc_seq_or(do_up_void, 0) : sc_seq_or(do_down_void, 0),
|
||||
FALSE, FALSE);
|
||||
|
||||
return 1;
|
||||
@@ -1764,51 +1790,31 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
|
||||
* key itself) and meta_key (whether the key is a meta sequence). The
|
||||
* returned shortcut will be the first in the list that corresponds to
|
||||
* the given sequence. */
|
||||
const sc *get_shortcut(int menu, int *kbinput, bool *meta_key)
|
||||
const sc *get_shortcut(int *kbinput)
|
||||
{
|
||||
sc *s;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "get_shortcut(): kbinput = %d, meta_key = %s -- ", *kbinput, *meta_key ? "TRUE" : "FALSE");
|
||||
fprintf(stderr, "get_shortcut(): kbinput = %d, meta_key = %s -- ", *kbinput, meta_key ? "TRUE" : "FALSE");
|
||||
#endif
|
||||
|
||||
/* Check for shortcuts. */
|
||||
for (s = sclist; s != NULL; s = s->next) {
|
||||
if ((menu & s->menu)
|
||||
&& ((s->type == META && *meta_key == TRUE && *kbinput == s->seq)
|
||||
|| (s->type != META && *kbinput == s->seq))) {
|
||||
if ((currmenu & s->menu) && *kbinput == s->seq
|
||||
&& meta_key == (s->type == META)) {
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "matched seq \"%s\", and btw meta was %d (menu is %x from %x)\n",
|
||||
s->keystr, *meta_key, menu, s->menu);
|
||||
s->keystr, meta_key, currmenu, s->menu);
|
||||
#endif
|
||||
return s;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf (stderr, "matched nothing, btw meta was %d\n", *meta_key);
|
||||
fprintf (stderr, "matched nothing, btw meta was %d\n", meta_key);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Try to get a function back from a window. Just a wrapper. */
|
||||
const subnfunc *getfuncfromkey(WINDOW *win)
|
||||
{
|
||||
int kbinput;
|
||||
bool func_key = FALSE, meta_key = FALSE;
|
||||
const sc *s;
|
||||
|
||||
kbinput = parse_kbinput(win, &meta_key, &func_key);
|
||||
if (kbinput == 0)
|
||||
return NULL;
|
||||
|
||||
s = get_shortcut(currmenu, &kbinput, &meta_key);
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
return sctofunc((sc *) s);
|
||||
}
|
||||
|
||||
/* Move to (x, y) in win, and display a line of n spaces with the
|
||||
* current attributes. */
|
||||
void blank_line(WINDOW *win, int y, int x, int n)
|
||||
@@ -2248,15 +2254,15 @@ void set_modified(void)
|
||||
titlebar(NULL);
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(LOCKING)) {
|
||||
if (!strcmp(openfile->filename, ""))
|
||||
if (openfile->filename[0] == '\0')
|
||||
return;
|
||||
else if (openfile->lock_filename == NULL) {
|
||||
/* TRANSLATORS: Try to keep this at most 76 characters. */
|
||||
statusbar(_("Warning: Modifying a file which is not locked, check directory permission?"));
|
||||
/* TRANSLATORS: Try to keep this at most 76 characters. */
|
||||
statusbar(_("Warning: Modifying a file which is not locked, check directory permission?"));
|
||||
} else {
|
||||
write_lockfile(openfile->lock_filename,
|
||||
get_full_path(openfile->filename), TRUE);
|
||||
}
|
||||
get_full_path(openfile->filename), TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2368,30 +2374,27 @@ void bottombars(int menu)
|
||||
for (f = allfuncs, i = 0; i < slen && f != NULL; f = f->next) {
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Checking menu items....");
|
||||
fprintf(stderr, "Checking menu items....");
|
||||
#endif
|
||||
if ((f->menus & menu) == 0)
|
||||
continue;
|
||||
|
||||
if (!f->desc || strlen(f->desc) == 0)
|
||||
if ((f->menus & menu) == 0)
|
||||
continue;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "found one! f->menus = %x, desc = \"%s\"\n", f->menus, f->desc);
|
||||
fprintf(stderr, "found one! f->menus = %x, desc = \"%s\"\n", f->menus, f->desc);
|
||||
#endif
|
||||
s = first_sc_for(menu, f->scfunc);
|
||||
if (s == NULL) {
|
||||
s = first_sc_for(menu, f->scfunc);
|
||||
if (s == NULL) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Whoops, guess not, no shortcut key found for func!\n");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
wmove(bottomwin, 1 + i % 2, (i / 2) * colwidth);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Calling onekey with keystr \"%s\" and desc \"%s\"\n", s->keystr, f->desc);
|
||||
fprintf(stderr, "Calling onekey with keystr \"%s\" and desc \"%s\"\n", s->keystr, f->desc);
|
||||
#endif
|
||||
onekey(s->keystr, _(f->desc), colwidth + (COLS % colwidth));
|
||||
i++;
|
||||
i++;
|
||||
}
|
||||
|
||||
wnoutrefresh(bottomwin);
|
||||
@@ -2447,17 +2450,20 @@ void reset_cursor(void)
|
||||
|
||||
xpt = xplustabs();
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
filestruct *tmp;
|
||||
openfile->current_y = 0;
|
||||
|
||||
for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next)
|
||||
openfile->current_y += 1 + strlenpt(tmp->data) / COLS;
|
||||
openfile->current_y += (strlenpt(tmp->data) / COLS) + 1;
|
||||
|
||||
openfile->current_y += xplustabs() / COLS;
|
||||
if (openfile->current_y < editwinrows)
|
||||
wmove(edit, openfile->current_y, xpt % COLS);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
openfile->current_y = openfile->current->lineno -
|
||||
openfile->edittop->lineno;
|
||||
|
||||
@@ -2495,10 +2501,11 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
/* First simply paint the line -- then we'll add colors or the
|
||||
* marking highlight on just the pieces that need it. */
|
||||
mvwaddstr(edit, line, 0, converted);
|
||||
/* Tell ncurses to really redraw the line without trying to optimize
|
||||
for what it thinks is already there, because it gets it wrong in
|
||||
the case of a wide character in column zero. See bug #31743. */
|
||||
|
||||
#ifndef USE_SLANG
|
||||
/* Tell ncurses to really redraw the line without trying to optimize
|
||||
* for what it thinks is already there, because it gets it wrong in
|
||||
* the case of a wide character in column zero. See bug #31743. */
|
||||
wredrawln(edit, line, 1);
|
||||
#endif
|
||||
|
||||
@@ -2508,13 +2515,15 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) {
|
||||
const colortype *tmpcolor = openfile->colorstrings;
|
||||
|
||||
/* Set up multi-line color data for this line if it's not yet calculated. */
|
||||
if (fileptr->multidata == NULL && openfile->syntax
|
||||
/* Set up multi-line color data for this line if it's not yet
|
||||
* calculated. */
|
||||
if (fileptr->multidata == NULL && openfile->syntax
|
||||
&& openfile->syntax->nmultis > 0) {
|
||||
int i;
|
||||
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
for (i = 0; i < openfile->syntax->nmultis; i++)
|
||||
fileptr->multidata[i] = -1; /* Assume this applies until we know otherwise. */
|
||||
fileptr->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
for (i = 0; i < openfile->syntax->nmultis; i++)
|
||||
/* Assume this applies until we know otherwise. */
|
||||
fileptr->multidata[i] = -1;
|
||||
}
|
||||
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
|
||||
int x_start;
|
||||
@@ -2601,7 +2610,8 @@ void edit_draw(filestruct *fileptr, const char *converted, int
|
||||
short md = fileptr->multidata[tmpcolor->id];
|
||||
|
||||
if (md == -1)
|
||||
fileptr->multidata[tmpcolor->id] = CNONE; /* until we find out otherwise */
|
||||
/* Assume this until we know otherwise. */
|
||||
fileptr->multidata[tmpcolor->id] = CNONE;
|
||||
else if (md == CNONE)
|
||||
goto end_of_loop;
|
||||
else if (md == CWHOLELINE) {
|
||||
@@ -2854,15 +2864,17 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
/* fileptr->data converted to have tabs and control characters
|
||||
* expanded. */
|
||||
size_t page_start;
|
||||
filestruct *tmp;
|
||||
|
||||
assert(fileptr != NULL);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP)) {
|
||||
for (tmp = openfile->edittop; tmp && tmp != fileptr; tmp = tmp->next) {
|
||||
line += 1 + (strlenpt(tmp->data) / COLS);
|
||||
}
|
||||
filestruct *tmp;
|
||||
|
||||
for (tmp = openfile->edittop; tmp && tmp != fileptr; tmp = tmp->next)
|
||||
line += (strlenpt(tmp->data) / COLS) + 1;
|
||||
} else
|
||||
#endif
|
||||
line = fileptr->lineno - openfile->edittop->lineno;
|
||||
|
||||
if (line < 0 || line >= editwinrows)
|
||||
@@ -2873,37 +2885,44 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
|
||||
/* Next, convert variables that index the line to their equivalent
|
||||
* positions in the expanded line. */
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP))
|
||||
index = 0;
|
||||
else
|
||||
#endif
|
||||
index = strnlenpt(fileptr->data, index);
|
||||
page_start = get_page_start(index);
|
||||
|
||||
/* Expand the line, replacing tabs with spaces, and control
|
||||
* characters with their displayed forms. */
|
||||
#ifdef NANO_TINY
|
||||
converted = display_string(fileptr->data, page_start, COLS, TRUE);
|
||||
#else
|
||||
converted = display_string(fileptr->data, page_start, COLS, !ISSET(SOFTWRAP));
|
||||
|
||||
#ifdef DEBUG
|
||||
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
|
||||
fprintf(stderr, "update_line(): converted(1) line = %s\n", converted);
|
||||
fprintf(stderr, "update_line(): converted(1) line = %s\n", converted);
|
||||
#endif
|
||||
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Paint the line. */
|
||||
edit_draw(fileptr, converted, line, page_start);
|
||||
free(converted);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (!ISSET(SOFTWRAP)) {
|
||||
#endif
|
||||
if (page_start > 0)
|
||||
mvwaddch(edit, line, 0, '$');
|
||||
if (strlenpt(fileptr->data) > page_start + COLS)
|
||||
mvwaddch(edit, line, COLS - 1, '$');
|
||||
#ifndef NANO_TINY
|
||||
} else {
|
||||
int full_length = strlenpt(fileptr->data);
|
||||
size_t full_length = strlenpt(fileptr->data);
|
||||
for (index += COLS; index <= full_length && line < editwinrows; index += COLS) {
|
||||
line++;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "update_line(): Softwrap code, moving to %d index %lu\n", line, (unsigned long) index);
|
||||
fprintf(stderr, "update_line(): softwrap code, moving to %d index %lu\n", line, (unsigned long)index);
|
||||
#endif
|
||||
blank_line(edit, line, 0, COLS);
|
||||
|
||||
@@ -2921,6 +2940,7 @@ int update_line(filestruct *fileptr, size_t index)
|
||||
extralinesused++;
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
return extralinesused;
|
||||
}
|
||||
|
||||
@@ -2973,14 +2993,14 @@ void compute_maxrows(void)
|
||||
maxrows += editwinrows - n;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "compute_maxrows(): maxrows = %i\n", maxrows);
|
||||
fprintf(stderr, "compute_maxrows(): maxrows = %d\n", maxrows);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Scroll the edit window in the given direction and the given number
|
||||
* of lines, and draw new lines on the blank lines left after the
|
||||
* scrolling. direction is the direction to scroll, either UP_DIR or
|
||||
* DOWN_DIR, and nlines is the number of lines to scroll. We change
|
||||
* scrolling. direction is the direction to scroll, either UPWARD or
|
||||
* DOWNWARD, and nlines is the number of lines to scroll. We change
|
||||
* edittop, and assume that current and current_x are up to date. We
|
||||
* also assume that scrollok(edit) is FALSE. */
|
||||
void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
@@ -3003,7 +3023,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
* value of direction) nlines lines, or as many lines as we can if
|
||||
* there are fewer than nlines lines available. */
|
||||
for (i = nlines; i > 0; i--) {
|
||||
if (direction == UP_DIR) {
|
||||
if (direction == UPWARD) {
|
||||
if (openfile->edittop == openfile->fileage)
|
||||
break;
|
||||
openfile->edittop = openfile->edittop->prev;
|
||||
@@ -3012,13 +3032,16 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
break;
|
||||
openfile->edittop = openfile->edittop->next;
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Don't over-scroll on long lines. */
|
||||
if (ISSET(SOFTWRAP) && (direction == UP_DIR)) {
|
||||
if (ISSET(SOFTWRAP) && direction == UPWARD) {
|
||||
ssize_t len = strlenpt(openfile->edittop->data) / COLS;
|
||||
i -= len;
|
||||
if (len > 0)
|
||||
do_redraw = TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Limit nlines to the number of lines we could scroll. */
|
||||
@@ -3036,7 +3059,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
/* Scroll the text of the edit window up or down nlines lines,
|
||||
* depending on the value of direction. */
|
||||
scrollok(edit, TRUE);
|
||||
wscrl(edit, (direction == UP_DIR) ? -nlines : nlines);
|
||||
wscrl(edit, (direction == UPWARD) ? -nlines : nlines);
|
||||
scrollok(edit, FALSE);
|
||||
|
||||
/* Part 2: nlines is the number of lines in the scrolled region of
|
||||
@@ -3044,8 +3067,8 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
|
||||
/* If the top or bottom line of the file is now visible in the edit
|
||||
* window, we need to draw the entire edit window. */
|
||||
if ((direction == UP_DIR && openfile->edittop ==
|
||||
openfile->fileage) || (direction == DOWN_DIR &&
|
||||
if ((direction == UPWARD && openfile->edittop ==
|
||||
openfile->fileage) || (direction == DOWNWARD &&
|
||||
openfile->edittop->lineno + editwinrows - 1 >=
|
||||
openfile->filebot->lineno))
|
||||
nlines = editwinrows;
|
||||
@@ -3066,7 +3089,7 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
|
||||
/* If we scrolled down, move down to the line before the scrolled
|
||||
* region. */
|
||||
if (direction == DOWN_DIR) {
|
||||
if (direction == DOWNWARD) {
|
||||
for (i = editwinrows - nlines; i > 0 && foo != NULL; i--)
|
||||
foo = foo->next;
|
||||
}
|
||||
@@ -3077,8 +3100,8 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
|
||||
* blank, so we don't need to draw it unless the mark is on or we're
|
||||
* not on the first page. */
|
||||
for (i = nlines; i > 0 && foo != NULL; i--) {
|
||||
if ((i == nlines && direction == DOWN_DIR) || (i == 1 &&
|
||||
direction == UP_DIR)) {
|
||||
if ((i == nlines && direction == DOWNWARD) || (i == 1 &&
|
||||
direction == UPWARD)) {
|
||||
if (do_redraw)
|
||||
update_line(foo, (foo == openfile->current) ?
|
||||
openfile->current_x : 0);
|
||||
@@ -3106,8 +3129,8 @@ void edit_redraw(filestruct *old_current, size_t pww_save)
|
||||
openfile->edittop->lineno || openfile->current->lineno >=
|
||||
openfile->edittop->lineno + maxrows) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_redraw(): line %d was offscreen, oldcurrent = %d edittop = %d",
|
||||
openfile->current->lineno, old_current->lineno, openfile->edittop->lineno);
|
||||
fprintf(stderr, "edit_redraw(): line %ld was offscreen, oldcurrent = %ld edittop = %ld",
|
||||
(long)openfile->current->lineno, (long)old_current->lineno, (long)openfile->edittop->lineno);
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
@@ -3201,9 +3224,9 @@ void edit_refresh(void)
|
||||
if (openfile->current->lineno < openfile->edittop->lineno ||
|
||||
openfile->current->lineno >= openfile->edittop->lineno +
|
||||
maxrows) {
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_refresh(): line = %d, edittop %d + maxrows %d\n", openfile->current->lineno, openfile->edittop->lineno, maxrows);
|
||||
fprintf(stderr, "edit_refresh(): line = %ld, edittop %ld + maxrows %d\n",
|
||||
(long)openfile->current->lineno, (long)openfile->edittop->lineno, maxrows);
|
||||
#endif
|
||||
|
||||
/* Put the top line of the edit window in range of the current
|
||||
@@ -3259,12 +3282,14 @@ void edit_update(update_type location)
|
||||
|
||||
for (; goal > 0 && foo->prev != NULL; goal--) {
|
||||
foo = foo->prev;
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(SOFTWRAP) && foo)
|
||||
goal -= strlenpt(foo->data) / COLS;
|
||||
#endif
|
||||
}
|
||||
openfile->edittop = foo;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "edit_udpate(), setting edittop to lineno %d\n", openfile->edittop->lineno);
|
||||
fprintf(stderr, "edit_update(): setting edittop to lineno %ld\n", (long)openfile->edittop->lineno);
|
||||
#endif
|
||||
compute_maxrows();
|
||||
edit_refresh_needed = TRUE;
|
||||
@@ -3365,14 +3390,14 @@ void do_cursorpos_void(void)
|
||||
|
||||
void enable_nodelay(void)
|
||||
{
|
||||
nodelay_mode = TRUE;
|
||||
nodelay(edit, TRUE);
|
||||
nodelay_mode = TRUE;
|
||||
nodelay(edit, TRUE);
|
||||
}
|
||||
|
||||
void disable_nodelay(void)
|
||||
{
|
||||
nodelay_mode = FALSE;
|
||||
nodelay(edit, FALSE);
|
||||
nodelay_mode = FALSE;
|
||||
nodelay(edit, FALSE);
|
||||
}
|
||||
|
||||
/* Highlight the current word being replaced or spell checked. We
|
||||
@@ -3496,7 +3521,7 @@ void do_credits(void)
|
||||
* Small Letter O with Diaresis) if applicable. */
|
||||
credits[16] =
|
||||
#ifdef ENABLE_UTF8
|
||||
using_utf8() ? "Florian K\xC3\xB6nig" :
|
||||
using_utf8() ? "Florian K\xC3\xB6nig" :
|
||||
#endif
|
||||
"Florian K\xF6nig";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user