Compare commits
248 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b29550e58d | ||
|
|
8816760ea1 | ||
|
|
da13f0b45c | ||
|
|
1bd0ce2832 | ||
|
|
7b36c52efc | ||
|
|
b5bb24c949 | ||
|
|
71e464034d | ||
|
|
21e3c28af2 | ||
|
|
fb62f73a9a | ||
|
|
928a7f535c | ||
|
|
fb2226a9ae | ||
|
|
37f627f2f8 | ||
|
|
07f9ee059f | ||
|
|
908805a2e8 | ||
|
|
20c131cf67 | ||
|
|
5982849325 | ||
|
|
4a938e137a | ||
|
|
d2cd65c967 | ||
|
|
90941714d2 | ||
|
|
cb7fa25d3d | ||
|
|
fedd724086 | ||
|
|
d87b34121f | ||
|
|
b998483369 | ||
|
|
9756d62d93 | ||
|
|
581bc60d0c | ||
|
|
d7ad75adb3 | ||
|
|
9ee2a0d0bc | ||
|
|
ac139dd6a6 | ||
|
|
f7ee9e6996 | ||
|
|
3ea0a8f1d6 | ||
|
|
8c36f8876c | ||
|
|
3dbb2783d3 | ||
|
|
331fc7a6f4 | ||
|
|
c5174aaef3 | ||
|
|
e7a5893245 | ||
|
|
9e2934fd27 | ||
|
|
4eb7aa04f3 | ||
|
|
ff269f8873 | ||
|
|
09a8084943 | ||
|
|
56b24b5909 | ||
|
|
7262358381 | ||
|
|
28fdf444e5 | ||
|
|
d00e6dfacd | ||
|
|
75155dff51 | ||
|
|
9200544269 | ||
|
|
acf2ac244d | ||
|
|
556b3a0028 | ||
|
|
24ccaf1e0f | ||
|
|
2ddb841940 | ||
|
|
ce478115e4 | ||
|
|
40a24b7372 | ||
|
|
90b780b5d7 | ||
|
|
19ed700690 | ||
|
|
2773184d92 | ||
|
|
184e1a6a4e | ||
|
|
8be8ce2086 | ||
|
|
7e0e29d3bb | ||
|
|
8a646adec4 | ||
|
|
984b5366cd | ||
|
|
4a9c8589b2 | ||
|
|
0779835ce4 | ||
|
|
d022eace15 | ||
|
|
2ff25693f3 | ||
|
|
9149e610b3 | ||
|
|
24946bd77a | ||
|
|
35788ff48c | ||
|
|
9956e530d0 | ||
|
|
7ffc01f00c | ||
|
|
e106a87841 | ||
|
|
7cd9f74b51 | ||
|
|
150c50d512 | ||
|
|
a131c7c029 | ||
|
|
8b4ca4a30b | ||
|
|
25f4e58ff4 | ||
|
|
d819a4cf06 | ||
|
|
04fec91362 | ||
|
|
8a0de3bb3f | ||
|
|
650e8a406b | ||
|
|
0f5dfef8b0 | ||
|
|
be77c6119f | ||
|
|
1866609311 | ||
|
|
ca7a21d358 | ||
|
|
71366cd21a | ||
|
|
6c5781ba10 | ||
|
|
c793c43e95 | ||
|
|
31c76660ed | ||
|
|
f26bca74d0 | ||
|
|
9fc5facab2 | ||
|
|
1cc29f626d | ||
|
|
d466ab7be0 | ||
|
|
ef601bbe08 | ||
|
|
aaabe1f865 | ||
|
|
ac0e63aa89 | ||
|
|
6da149adf9 | ||
|
|
3ebac1c886 | ||
|
|
42004f0831 | ||
|
|
47ddfaf44f | ||
|
|
44b52ca67b | ||
|
|
d25385b090 | ||
|
|
258ac42140 | ||
|
|
63a89d386b | ||
|
|
6e8ed7128e | ||
|
|
bf9a8cc23d | ||
|
|
5b1faac336 | ||
|
|
5bf51d3872 | ||
|
|
cbb0f8bde2 | ||
|
|
2c9752291d | ||
|
|
b5b89aeb93 | ||
|
|
022b96f941 | ||
|
|
442f2c5156 | ||
|
|
0468612b4d | ||
|
|
271e972ff0 | ||
|
|
a60e02c950 | ||
|
|
85b19e9110 | ||
|
|
24dd8d6532 | ||
|
|
24342437c7 | ||
|
|
e118acc068 | ||
|
|
7d97ce7baf | ||
|
|
b684805da7 | ||
|
|
7da4e9f28b | ||
|
|
7586495813 | ||
|
|
3b0d14444f | ||
|
|
ec58a99326 | ||
|
|
04d848e6d9 | ||
|
|
27eb13f0fa | ||
|
|
71844ba03a | ||
|
|
67574f483e | ||
|
|
0bd807782a | ||
|
|
1cc0b7fdca | ||
|
|
90594e268a | ||
|
|
0d1e8d66e4 | ||
|
|
92d2bab3ef | ||
|
|
f5deac3d0f | ||
|
|
31925e4517 | ||
|
|
e7a647c343 | ||
|
|
b46df990ad | ||
|
|
dd5328ccbb | ||
|
|
4d29be19c8 | ||
|
|
e364740aea | ||
|
|
86f8b3a163 | ||
|
|
105da33276 | ||
|
|
f754eaadd2 | ||
|
|
0ae0dcd580 | ||
|
|
9c371a24e3 | ||
|
|
462a1997e9 | ||
|
|
810632d666 | ||
|
|
69fbef6e76 | ||
|
|
bd9e7c3c36 | ||
|
|
a0e957bc0d | ||
|
|
f9b6c9b398 | ||
|
|
d7934d4c85 | ||
|
|
de8f833989 | ||
|
|
70e82f3084 | ||
|
|
35d90259ed | ||
|
|
07e97d61c0 | ||
|
|
71348eeb1f | ||
|
|
9e7efa3202 | ||
|
|
df3afdce0d | ||
|
|
66989d6ece | ||
|
|
7c44b68e05 | ||
|
|
ad1daccecc | ||
|
|
4aacee6627 | ||
|
|
629edad237 | ||
|
|
834a69d5a4 | ||
|
|
f45c18daa0 | ||
|
|
0b88ce08cb | ||
|
|
c9f147aba3 | ||
|
|
e7034c6087 | ||
|
|
90bd712c88 | ||
|
|
9c35eb0def | ||
|
|
92c9dd255c | ||
|
|
2a42af1d62 | ||
|
|
16e4168993 | ||
|
|
d0dbb40ef6 | ||
|
|
91d392cd2b | ||
|
|
b9bfc9bc4f | ||
|
|
2dc0f6b2bf | ||
|
|
44e73dfc96 | ||
|
|
9239d742d6 | ||
|
|
43932bd17b | ||
|
|
805c26d1a6 | ||
|
|
d746d90cc3 | ||
|
|
429a5518ea | ||
|
|
bf9da287a0 | ||
|
|
423cbfd743 | ||
|
|
5577aec4e8 | ||
|
|
18f8be0058 | ||
|
|
f8163dc2e7 | ||
|
|
f0f63a82fb | ||
|
|
a547fd1e0e | ||
|
|
6306a11ad6 | ||
|
|
9541f2a1d3 | ||
|
|
d56bd79daf | ||
|
|
e49f123cc0 | ||
|
|
4c780be883 | ||
|
|
220e7fb132 | ||
|
|
756f220a26 | ||
|
|
cf7c9936ad | ||
|
|
9babaf3b38 | ||
|
|
340d6e50c2 | ||
|
|
dabc3cb0df | ||
|
|
e10debd14b | ||
|
|
f1d33d30ce | ||
|
|
8c81d23a7e | ||
|
|
8d458043d1 | ||
|
|
5286ccbaf9 | ||
|
|
ba96f7afac | ||
|
|
a2efc36799 | ||
|
|
e5935973f9 | ||
|
|
13415991e8 | ||
|
|
b7ea9d45bb | ||
|
|
0286ba436e | ||
|
|
c86f714a15 | ||
|
|
9b45ff54ac | ||
|
|
2b78429248 | ||
|
|
c87a411624 | ||
|
|
141c1274c4 | ||
|
|
11b0011b1f | ||
|
|
b4dc9e0944 | ||
|
|
81b1eea10f | ||
|
|
7dc14e81d7 | ||
|
|
4dbcc3cd9e | ||
|
|
1f2a072e33 | ||
|
|
0bf4e146a0 | ||
|
|
bbd96ea838 | ||
|
|
5027a18c2c | ||
|
|
99bf73fe66 | ||
|
|
d7c31c1123 | ||
|
|
6d690a39dc | ||
|
|
ed02216378 | ||
|
|
55d5455abd | ||
|
|
5d8f6250de | ||
|
|
7a6f0d9868 | ||
|
|
145a0450ea | ||
|
|
da721be17a | ||
|
|
234a34d273 | ||
|
|
84ff479b24 | ||
|
|
3206ab4fe0 | ||
|
|
f5d7a8b4fd | ||
|
|
d069ac02d1 | ||
|
|
d63d11be58 | ||
|
|
1a471392c5 | ||
|
|
f6a6b5aa86 | ||
|
|
95b0b5249a | ||
|
|
29d9025381 | ||
|
|
6925bbd360 | ||
|
|
18bd029981 | ||
|
|
7975ed86a7 |
8
.cvsignore
Normal file
8
.cvsignore
Normal file
@@ -0,0 +1,8 @@
|
||||
Makefile
|
||||
confdefs.h
|
||||
config.cache
|
||||
config.h
|
||||
config.log
|
||||
config.status
|
||||
nano
|
||||
stamp-h
|
||||
@@ -224,3 +224,4 @@ distribution.
|
||||
If December 1997 seems to be old, you may fetch a more recent copy
|
||||
of this `ABOUT-NLS' file on most GNU archive sites.
|
||||
|
||||
$Id$
|
||||
|
||||
6
AUTHORS
6
AUTHORS
@@ -1,3 +1,4 @@
|
||||
$Id$
|
||||
This file lists people who have made significant contribution to the nano
|
||||
editor. Please see the ChangeLog for specific changes by author.
|
||||
-------------------------------------------------------------------------
|
||||
@@ -18,3 +19,8 @@ Robert Siemborski <rjs3@andrew.cmu.edu>
|
||||
* Miscellaneous cut, display, replace, and other bug fixes,
|
||||
original and new "magic line" code, read_line() function, new
|
||||
edit display routines.
|
||||
|
||||
Rocco Corsi <rocco.corsi@sympatico.ca>
|
||||
* Internal spelling code, many optimizations and bug fixes for
|
||||
findnextstr and search-related functions, various display and
|
||||
file handling fixes.
|
||||
|
||||
49
BUGS
49
BUGS
@@ -2,6 +2,9 @@
|
||||
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)
|
||||
@@ -11,6 +14,8 @@
|
||||
(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:
|
||||
@@ -38,21 +43,45 @@
|
||||
- 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]
|
||||
- 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 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 exist on one line multiple times will
|
||||
fail after finding the last occurance (discovered by Ken Tyler) (40). [FIXED]
|
||||
- Alt-Z is current 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 Kev 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 serahc or replace and hitting CASE_SENSITVE
|
||||
or the other search string, the current string edit is blown away in
|
||||
favor of the last stored search (47) [FIXED]
|
||||
|
||||
** Open 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) { Is this an issue? compare to pico 3.5 }
|
||||
- no way to do a replace with the empty string. (11)
|
||||
- Spelling support is not elegant like pico's integration of the 'spell'
|
||||
program. Nano only uses ispell (for now) (12)
|
||||
- Cutting a file with marked text and both marker ends on the same line
|
||||
causes a random segfault (16)
|
||||
- In search/replace code there is too much refreshing in bottomwin (26)
|
||||
- In replace, there is no way to accept the default replace string. (27)
|
||||
- totsize problems still abound in do_justify (33)
|
||||
- Using -k cut text is not pasted properly. (34) [FIXED, mostly].
|
||||
- Using -k pasted text is not updated properly if it goes beyond editbot. (35)
|
||||
- totsize problems still abound in do_justify (33).
|
||||
|
||||
$Id$
|
||||
|
||||
396
ChangeLog
396
ChangeLog
@@ -1,3 +1,397 @@
|
||||
nano 0.9.23 - 12/08/2000
|
||||
General
|
||||
- Changed --disable-spell to --disable speller. The term is
|
||||
"speller" for -s, so it should be --disable-speller.
|
||||
- files.c:
|
||||
write_file()
|
||||
- Added tmp check to TMP_OPT section (how apropriate).
|
||||
- Added new consistency checking code from securityfocus
|
||||
article by Oliver Friedrichs, and use O_EXCL if tmp == 1.
|
||||
- We now run check on result of lstat(), not stat(), to be
|
||||
safer. New variable anyexists, we use still use realexists
|
||||
later in the program.
|
||||
- OOPS, line up link/unlink/rename check if conditional with
|
||||
top if conditional. Option -l has been broken for 9 versions,
|
||||
no one noticed?!
|
||||
- Added saving perms at end of link so we can apply them to the
|
||||
new file if --nofollow is used.
|
||||
- winio.c:
|
||||
edit_add()
|
||||
- Off by one display error (fix by Rocco Corsi).
|
||||
do_replace_highlight()
|
||||
- New code to handle being past COLS (Roco Corsi).
|
||||
- Moved from search.c, as it's definitely a winio function now =)
|
||||
update_line()
|
||||
- More '$' display fixes (Rocco Corsi).
|
||||
|
||||
nano 0.9.22 - 12/02/2000
|
||||
- General
|
||||
- Username tab completion code, and cleaned up existing tabcomp
|
||||
code. New functions real_dir_from_tide(), append_slash_if_dir(),
|
||||
username_tab_completion is more than a stub now =-).
|
||||
- Ignore key sequence 543 & 545, right control and alt keys in
|
||||
windows. Affects main() and winio.c:nanogetstr().
|
||||
- Took out help from spell_list and changed SPELL_LIST_LEN to 1.
|
||||
Is using a spell checker THAT difficult? =-)
|
||||
- New function nano_disabled_msg(), to alert that certain
|
||||
functions have been disabled, similaer to nano_tiny feature.
|
||||
- New configure options:
|
||||
- Added configure argument --disable-tabcomp. Affects
|
||||
bottom of files.c and write_file, utils.c:check_wildcard_match()
|
||||
and winio.c:nanogettsr().
|
||||
- New options --enable-extra. New code in nano.c:version() to
|
||||
print out various options from ./configure, function do_credits().
|
||||
- Added --disable-spell option for those who want to just disable
|
||||
the spell check feature. Affects the spellinf fucntions
|
||||
do_spell, do_int_speller and do_alt_speller.
|
||||
- Added --disable-justify to get rid of the justify function.
|
||||
Affects do_justify() (not surprisingly).
|
||||
- files.c:
|
||||
write_file()
|
||||
- Unsetting modified on temp files bug fixed (Rocco Corsi).
|
||||
- Okay, if tmp == 1 and the file exists, we abort.
|
||||
do_insertfile()
|
||||
- Added call to real_name_from tilde, oops. Added check for
|
||||
DISABLE_TABCOMP.
|
||||
read_file()
|
||||
- Added check for fileptr == NULL.
|
||||
- global.c:
|
||||
shortcut_init()
|
||||
- Now takes an argument as to whether to display the unjustify
|
||||
shortcut or the normal uncut text one. Needed to accomodate
|
||||
the klugey unjustify code.
|
||||
- nano.1, nano.1.html:
|
||||
- Updated date on pages because of -p changes.
|
||||
- Added "NOTES" section, where I explain what nano.save & friends
|
||||
are.
|
||||
- Added a copyright notice for the manpage, under the GPL.
|
||||
- Other minor changes.
|
||||
- nano.c:
|
||||
do_justify()
|
||||
- Wrote unjustify code. Borrows cutbuffer and stores the unjustified
|
||||
text there, then grabs the next keystroke and, if the unjustify
|
||||
key, gets rid of the justified text and calls do_uncut_text.
|
||||
Added macro NANO_UNJUSTIFY_KEY.
|
||||
do_int_spell*
|
||||
- Various fixes (Rocco Corsi).
|
||||
- Changed abort of program to aborting based on value of "edit a
|
||||
replacement" question, and not caring about the replace loop
|
||||
return value. That way the user can get out of the replace loop
|
||||
and continue spell checking (very important to me anyway).
|
||||
version()
|
||||
- Took out huge check for the various --disabled macros,
|
||||
eventually there will be too many to reasonably check for.
|
||||
nano_small_msg(), nano_disabled_msg()
|
||||
- Added checks for disabled functions to see whether or not to
|
||||
declare them.
|
||||
do_next_word()
|
||||
- Update the previous line as well as the current one in case we
|
||||
have moved beyond COLS or back from COLS, patch submitted
|
||||
by Ryan Krebs.
|
||||
die()
|
||||
- Now creates .save file using variable-length strings. Also
|
||||
calls write_file with tmp == 1, which happens to do exactly what
|
||||
we want (abort on save file exists and use mode 0600).
|
||||
handle_sighup()
|
||||
- Now calls die instead of writing on its own and exiting normally.
|
||||
- search.c:
|
||||
do_replace_hilight()
|
||||
- New function, displays the currently selected word as hilighted
|
||||
in the spell check. Called from do_replace_loop (Rocco Corsi).
|
||||
- Added calls to curs_set(0) and (1) to diable the cursor when
|
||||
hilighting, looks much better.
|
||||
- es.po:
|
||||
- Traditional Spanish strings updates.
|
||||
|
||||
nano 0.9.21 - 11/23/2000
|
||||
- AUTHORS
|
||||
- Added Rocco Corsi.
|
||||
- nano.c:
|
||||
main()
|
||||
- Changed check for argc == 1 to argv[optind] == NULL to decide
|
||||
whether or not to display "New File" in the statusbar.
|
||||
- search.c:
|
||||
findnextstr()
|
||||
- Fix curent_x increment bug by using another variable (Rocco Corsi).
|
||||
search_init()
|
||||
- Silly typo in our "one simple call" of statusq. Stopped
|
||||
previous search string from being displayed.
|
||||
do_replace()
|
||||
- Copy back the previous value of last_replace into answer if
|
||||
using PICO_MODE and answer == ""
|
||||
- winio.c:
|
||||
do_up()
|
||||
- Deleted first update_line() call, screws up display when marker is set.
|
||||
- nano.1, nano.1.html
|
||||
- Updated man page for new -p definition.
|
||||
|
||||
nano 0.9.20 - 11/18/2000
|
||||
- General
|
||||
- Ran source through indent -kr again. Make everything pretty.
|
||||
- Changed behavior of "search" and "replace" prompts to make all
|
||||
previous values editable. This change was made so that you can
|
||||
replace with the null string without needing a special key for it.
|
||||
changed code in search_init(), do_replace(), nanogetstr (see
|
||||
below).
|
||||
- Added some missing gettext calls here and there (Jordi).
|
||||
- Revamped nanogetsr() and calls to it to use variable length strings.
|
||||
MANY changes in nanogetstr(), many chances in search.c, new
|
||||
function mallocstrcpy which is sure to be a programmatic
|
||||
nightmare, changed last_search, last_replace, answer to
|
||||
pointers. New function not_found_msg in search.c for displaying
|
||||
truncated strings in satusbar when the string is not found
|
||||
(-pedantic fixes by Rocco Corsi). We disable this feature when
|
||||
using PICO_MODE (-p).
|
||||
- New spelling code by Rocco Corsi. New functions
|
||||
do_int_speller, do_alt_speller, changes to do_spell in nano.c,
|
||||
New functions search_init_globals and do_replace_loop, changes
|
||||
to search_init(), do_replace, findnextstr, moved last_search and
|
||||
last_replace back to nano.c (*shrug*).
|
||||
- New tab completion code. Used check_wildcard_match, input_tab,
|
||||
cwd_tab_completion, username_tab_completion from busybox,
|
||||
hacked them a lot, changes to nanogetstr(). nanogetstr() and
|
||||
statusq() now take an arg for whether or not to allow tab
|
||||
completion.
|
||||
- Fixed value being input in statusbar during a search or replace
|
||||
and CASE_SENSITIVE or the other search is called and the
|
||||
string being typed in is blown away. Reported by Ken Tyler.
|
||||
- Changed PICO_MSGS flag to PICO_MODE, changed help strings
|
||||
accordingly.
|
||||
- files.c:
|
||||
do_writeout()
|
||||
- Change strcpy to answer to mallocstrcpy.
|
||||
- global.c
|
||||
- New global replace_list_2, for 2nd half of the replace dialog
|
||||
("Replace with:"), has fewer options than first half because
|
||||
they were inapropriate.
|
||||
toggle_init()
|
||||
- Added #ifdef around toggle_regex_msg to get rid of compiler
|
||||
warning.
|
||||
|
||||
- nano.c:
|
||||
keypad_on()
|
||||
- New function, toggles turning the keypad on and off in edit and
|
||||
bottomwin(). Added call to this in finish(), fixes bug #45.
|
||||
- search.c
|
||||
findnexstr()
|
||||
- New arg for begin_x variable, basically a rewrite that
|
||||
makes a little more sense and isn't quite as messy (Rocco Corsi).
|
||||
- Update the line we're checking if not the whole screen, because
|
||||
it's quite possible the search team could exist somewhere way
|
||||
to the right on the same line, for example.
|
||||
replace_abort()
|
||||
- Add reset of placewewant, stops cursor from jumping when moving
|
||||
cursor after a replace.
|
||||
do_replace()
|
||||
- Added code for Gotoline key after entering the search term.
|
||||
Fixes bug #46.
|
||||
- Removed redundant code involving processing replacemenet string.
|
||||
Converted if statements to switch statements.
|
||||
- Optimizations by Rocco Corsi.
|
||||
- Removed code for deleted shortcuts from in replace_list_2.
|
||||
do_search()
|
||||
- Converted if statements to one switch statement.
|
||||
- winio.c
|
||||
nanogetstr()
|
||||
- Added check for 343 in while loop to get rid of getting "locked"
|
||||
into statusbar" bug in odd $TERMs like iris-ansi.
|
||||
- Changed check to return -2 on "enter" from answer == ""
|
||||
to answer == def.
|
||||
- Fixed fallthrough code because there was no break. Make much
|
||||
more sense now.
|
||||
- Added check for ASCII 54[124] when using PDCURSES, ignore them
|
||||
if noticed.
|
||||
nanoget_repaint()
|
||||
- New function, removes about 30 lines of duplicate code in
|
||||
nanogetstr().
|
||||
- Black magic code to make $ appear in prompt if we're past
|
||||
COLS.
|
||||
blank_edit()
|
||||
- Removed wrefresh() call, much less choppy now. If there's a need
|
||||
for a wrefresh after a specific call, let me know.
|
||||
- es.po:
|
||||
- Updated translation for 0.9.20 (Jordi).
|
||||
|
||||
nano 0.9.19 - 10/02/2000
|
||||
- General
|
||||
- Added PDCurses support under cygwin, which allows building
|
||||
a nice stand-alone nano.exe for those poor Windows users.
|
||||
Extra check in configure.in for initscr() in -lcurses (as
|
||||
PDcurses has no tgetent), some #ifdef PDCURSES statements
|
||||
in main().
|
||||
- Changed web site and email to new nano-editor.org domain.
|
||||
- nano.c
|
||||
- Added (int) casts to remove compile warnings with -Wall.
|
||||
main()
|
||||
- Added check for _POSIX_VDISABLE around term variable definition.
|
||||
- search.c
|
||||
- Added initializations for last_search and last_replace (Rocco Corsi)
|
||||
|
||||
nano 0.9.18 - 09/18/2000
|
||||
- General
|
||||
- Changed _POSIX_VERSION checks in regex code to HAVE_REGEX_H,
|
||||
added check for regex.h in configure.in.
|
||||
- configure.in:
|
||||
- Added default case for cross-compiling to get rid of annoying
|
||||
AC_TRY_RUN warning.
|
||||
- cut.c:
|
||||
do_cut_text()
|
||||
- Don't immediately abort if we're on filebot and the marker is
|
||||
set (fixes bug #42).
|
||||
- files.c:
|
||||
open_file()
|
||||
- Fix for bug #44 (Rocco Corsi).
|
||||
- global.c:
|
||||
shortcut_init()
|
||||
- Added in FKEYs that for some reason were left out. *boggle*
|
||||
- nano.c:
|
||||
main()
|
||||
- Added check for _POSIX_VDISABLE and use raw mode if not
|
||||
available, allows nano to work with cygwin.
|
||||
- Added gettext calls to enable/disable strings (Jordi).
|
||||
- Revamped a great deal of the F-key and keypad key handling,
|
||||
because we not longer use keypad() (see below).
|
||||
- Removed keypad() call because nano was not working with the
|
||||
keypad in many terms, which is very bad.
|
||||
- Made insert key call do_insertfile().
|
||||
do_toggle()
|
||||
- Rewrote function to allow NOHELP toggle to wotk on systems
|
||||
without a working resizewin(). New function window_init().
|
||||
mouse_init()
|
||||
- Add keypad only if mouse support is on, otherwise mouse doesn't
|
||||
work. I guess you have to choose between having the mouse and
|
||||
having a working keypad for the time being (thank god for Meta-m).
|
||||
- winio.c:
|
||||
total_refresh()
|
||||
- Added titlebar() call.
|
||||
onekey()
|
||||
- Off by one error fix fix ;-) (Rocco Corsi).
|
||||
|
||||
- search.c:
|
||||
findnextstr()
|
||||
- Reset starting at current for search instead of begin.
|
||||
- es.po:
|
||||
- Translated new strings and minor updates (Jordi).
|
||||
- de.po
|
||||
- Revised translations by floki@bigfoot.com
|
||||
|
||||
nano-0.9.17 - 09/04/2000
|
||||
- General
|
||||
- New shortcuts to toggle certain options that are normally only
|
||||
flags via Alt/Meta. See Alt-C,E,I,K,M,P,X,Z. New struct called
|
||||
toggles in nano.h, toggle_init(), toggle_init_one() in global.c
|
||||
called from shortcut_init(), and do_toggle in nano.c. Also
|
||||
moved the signal code into a separate function in nano.c called
|
||||
signal_init(). Moved "struct sigaction act"into a static in
|
||||
nano.c.
|
||||
- Changed from Alt-key symbol (@) which is completely nonstandard
|
||||
to the *nix "Meta" symbol (M-). Changed help_init to show
|
||||
the M-key usage and the help text to explain keys whcih generate
|
||||
Meta. Moved the toggle Meta keystrokes to the first column
|
||||
instead of the third as they are the primary keystrokes for the
|
||||
functions. Thanks Mini editor team :->
|
||||
- Changed last_search and last_replace vars to statically
|
||||
allocated (hence nulled) and moved to search.c (Matt Kraai).
|
||||
- global.c:
|
||||
toggle_init()
|
||||
- Changed "No auto wrap" and "No help mode" to "Auto wrap" and
|
||||
"Help mode". See the change to do_toggle() below.
|
||||
- nano.c:
|
||||
do_mouse()
|
||||
- Patch for handling lines w/tabs and mouse better (Ben Roberts).
|
||||
do_wrap()
|
||||
- Made wrapping code less ambitious.
|
||||
do_toggle()
|
||||
- Added checks for no help and no wrap mode, and print opposite
|
||||
enable/disable message.
|
||||
do_suspend(), do_cont():
|
||||
- New functions, handle suspend signal in a Pico-like manner and
|
||||
work with Meta-Z.
|
||||
- winio.c:
|
||||
total_refresh()
|
||||
- Added edit_refresh() call to actually update the screen if messy.
|
||||
edit_refresh_clearok()
|
||||
- New function, does a total update for edit refresh, needed to fix
|
||||
lack of reversed text on searching with MARK_ISSET.
|
||||
onekey()
|
||||
- Off by one error fix (Rocco Corsi).
|
||||
|
||||
update_line()
|
||||
- Added check for binary data >= 1 and <= 26, and use ^+letter
|
||||
to display it. Should fix editing text files with binary
|
||||
data in them. Placing of the cursor seems to be a bit screwed
|
||||
though...
|
||||
- search.c:
|
||||
search_abort()
|
||||
- Now calls edit_refresh_clearok when MARK_ISSET to handle screen
|
||||
ugliness bug (reported by Ken Tyler).
|
||||
findnextstr():
|
||||
- Added reset for placewewant (Ben Roberts).
|
||||
- Fixed check for string that only occurs on the same line failing
|
||||
(discovered by Ken Tyler).
|
||||
|
||||
nano-0.9.16 - 08/09/2000
|
||||
- cut.c:
|
||||
do_cut_text()
|
||||
- Fixed getting locked into cutbuffer on cutting first line of file.
|
||||
- Added check_statblank().
|
||||
- Check for fileptr == filebot, if so return, we shouldn't bother
|
||||
cutting the magic line.
|
||||
do_uncut_text()
|
||||
- Added check_statblank().
|
||||
- nano.c:
|
||||
main()
|
||||
- Changed tabsize long arg to actually accept an argument *sigh*.
|
||||
- po/Makefile.in.in:
|
||||
- Patch to handle $DESTDIR (orig by Dan Harnett contributed by
|
||||
Christian Weisgerber)
|
||||
- configure.in:
|
||||
- New (and severally revised =) slang test code (Albert Chin-A-Young)
|
||||
|
||||
nano-0.9.15 - 08/03/2000
|
||||
- Changed edit_update call to take arguments TOP, CENTER or BOTTOM.
|
||||
Affects many many functions. Removed functions edit_update_top and
|
||||
edit_update_bot.
|
||||
- Added global variable tabsize, we no longer screw with the curses
|
||||
library in order to implement -T (suggested by Christian Weisgerber).
|
||||
- configure.in:
|
||||
- Finally fixed check for slang to report "no" if not called
|
||||
with --with-slang or --without-slang
|
||||
- nano.c:
|
||||
splice_node()
|
||||
- New function, abstracts linking in nodes. Fixes bug #36.
|
||||
null_at()
|
||||
- New function, nulls a string at a given index and realigns it.
|
||||
delete_buffer()
|
||||
- Removed, same as free_filestruct().
|
||||
do_backspace()
|
||||
- Now calls page_up_center instead of page_up (as it should?)
|
||||
do_enter()
|
||||
- Fixed typo (?) in check for inptr->next. Caused lots of
|
||||
grief for editing lines at filebot.
|
||||
main()
|
||||
- Removed now useless usrtabsize variable (Christian Weisgerber).
|
||||
- search.c:
|
||||
replace_abort()
|
||||
- redundant, now just calls search abort until it does something
|
||||
different.
|
||||
- winio.c:
|
||||
edit_refresh()
|
||||
- Added check for current line "running" off the screen.
|
||||
Hopefully this will not cause any recursive lockups.
|
||||
(Who am I kidding, of course it will!)
|
||||
- Added check to stop infinite loop calling edit_update.
|
||||
edit_update()
|
||||
- Rewritten, hopefully this will remove a lot of the
|
||||
scrolling the cursor back and forth needlessly.
|
||||
- move.c:
|
||||
page_down()
|
||||
- do an edit_update() at last case. Made function more like
|
||||
Pico's version, only move down to two lines before editbot.
|
||||
page_up()
|
||||
- Made function more like Pico's version, only move down to two
|
||||
lines after edittop.
|
||||
|
||||
nano-0.9.14 - 07/27/2000
|
||||
- nano.h:
|
||||
- Set CUT_TO_END to a different bit than TEMP_OPT. Fixes bug #32.
|
||||
@@ -840,3 +1234,5 @@ nano 0.7.6 - 01/15/2000
|
||||
0.2 Read in data to buffer, bound keystrokes to stub functions,
|
||||
initial cursor movement on screen. Initial autoconf support.
|
||||
0.1 Initial program setup w/ncurses
|
||||
|
||||
$Id$
|
||||
|
||||
2
INSTALL
2
INSTALL
@@ -180,3 +180,5 @@ operates.
|
||||
script, and exit.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options.
|
||||
|
||||
$Id$
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
## $Id$
|
||||
bin_PROGRAMS = nano
|
||||
nano_SOURCES = cut.c \
|
||||
files.c \
|
||||
|
||||
88
NEWS
88
NEWS
@@ -1,3 +1,89 @@
|
||||
12/08/2000 - Nano 0.9.23 is the "race conditions bite" release. The
|
||||
main reason for this release is the less-than-optimal
|
||||
fix for the security issue in nano with following symbolic
|
||||
links. Hopefully this will fix the probelm permanently.
|
||||
The --nofollow option also works again for those who
|
||||
are real security nuts. There are also some display and
|
||||
search fixes, and the --disable-spell function was renamed
|
||||
to --disable-speller to be in line with nano and pico's
|
||||
"speller" term.
|
||||
|
||||
12/02/2000 - Nano 0.9.22 is released, with many more changes and
|
||||
additions than imaginable. The most important change is
|
||||
a fix for unsafe handling of symbolic links which could
|
||||
lead to symlink attacks if nano were to exit because
|
||||
of an error or signal. Also there are better checks when
|
||||
saving files.
|
||||
As for new features, username tab completion is
|
||||
now working well, the internal spell checker code has been
|
||||
tweaked, you can now unjustify if you don't like how the
|
||||
justify formatted your text, and there are more
|
||||
options for configure, including --disable-spell and
|
||||
--disable-justify and --enable-extra (for those who like
|
||||
surprises). All in all, a whole lot of changes in
|
||||
a little over a week.
|
||||
|
||||
11/23/2000 - Happy Thanksgiving! Nano 0.9.21 is our "last version was
|
||||
a big turkey" release. It fixes several bugs introduced
|
||||
by the previous version, as well as a few long-
|
||||
standing display bugs. All 0.9.20 users are strongly
|
||||
encouraged to upgrade to this release.
|
||||
|
||||
11/18/2000 - Nano 0.9.20 is finally out the door. Probably the biggest
|
||||
change is the brand new way nano displays previous search
|
||||
and replace strings (they are now editable!) This is a
|
||||
break from Pico's (inconsistent) interface, so if you
|
||||
don't like the new way, "Pico" mode (-p on the command
|
||||
line or Meta-P within nano) still works the "old"
|
||||
way.
|
||||
Other new features include being able to deal with
|
||||
search strings of any length, a new internal spell feature
|
||||
(courtesy of Mr. Rocco Corsi) and tab completion when
|
||||
reading in or writing out files! There's also the usual
|
||||
billion or so bug fixes. Feedback on this release is
|
||||
welcome because so much much has changed, especially with
|
||||
the previous string display in search and replace. Email
|
||||
-> nano@nano-editor.org <-. If you like something, don't
|
||||
like something, or just want to order a pizza, let us know!
|
||||
|
||||
10/02/2000 - Nano 0.9.19 is the "Chris is getting married in less than
|
||||
a week and needs a distraction" release. There are only
|
||||
a few actual code changes, mainly portability and compiler
|
||||
warning fixes. Nano now also supports PDCurses, which
|
||||
enables easily-built nano executables for Windows NT
|
||||
and 95/98 for the brave. The official nano site has
|
||||
changed (again) as well, check out www.nano-editor.org for
|
||||
all the latest nano schtuff.
|
||||
|
||||
09/18/2000 - Nano 0.9.18 is unleashed. It has some new keyboard
|
||||
handling code, cygwin support out of the box, and
|
||||
a more portable handler for the NOHELP toggle. There
|
||||
is also a fix for a somewhat serious bug whereby trying
|
||||
to insert a directory instead of a normal file would
|
||||
destroy the contents of the editor. A must-see. Four
|
||||
stars.
|
||||
|
||||
09/04/2000 - Nano 0.9.17, the Labor Day release, is released after a
|
||||
quiet spell (almost an entire month since last release!)
|
||||
New features include better (not yet perfect) binary
|
||||
display support and toggle support for most of the program
|
||||
flags (M-c, M-i, M-z, M-x, M-p, M-w, M-m, M-k and M-e for
|
||||
-c, -i, -x, -p, -w, -k, and -R).
|
||||
|
||||
08/09/2000 - Nano 0.9.16, after some struggling, is release. This release
|
||||
should fix a few of the holes that 0.9.15 dug. The
|
||||
"cutting text on the first line" bug is fixed, as is the
|
||||
"cutting text on the last line" bug. Nice symmetry there
|
||||
huh? Also the --tabsize argument should now work as well
|
||||
as by using -T.
|
||||
|
||||
08/03/2000 - Nano 0.9.15 is the "I cant think of a release description"
|
||||
release. There are the usual gala of display bugfixes,
|
||||
a for the the nasty bug in -k mode that could create a
|
||||
loop in the file being edited, and some other code
|
||||
cleanup. Also, the -T option should now work regardless
|
||||
of the curses library used. Yay.
|
||||
|
||||
07/27/2000 - Nano 0.9.14 is officially the "13 is so unlucky it should
|
||||
be skipped as a version number" release. One typo
|
||||
caused unending problems (calling nano with either -t or
|
||||
@@ -243,3 +329,5 @@
|
||||
http://faculty.plattsburgh.edu/astyanax/nano. Please
|
||||
update your bookmarks, tell your friends, and all that
|
||||
jazz.
|
||||
|
||||
$Id$
|
||||
|
||||
6
README
6
README
@@ -39,7 +39,7 @@ How to compile and install nano
|
||||
|
||||
Web Page
|
||||
|
||||
http://www.asty.org/nano
|
||||
http://www.nano-editor.org
|
||||
|
||||
Mailing List and Bug Reports
|
||||
|
||||
@@ -54,7 +54,7 @@ Mailing List and Bug Reports
|
||||
with a subject of "subscribe", where <name> is the list you want to
|
||||
subscribe to.
|
||||
For general bug reports, send a description of the problem to
|
||||
nano@asty.org or directly to the development list.
|
||||
nano@nano-editor.org or directly to the development list.
|
||||
|
||||
Current Status
|
||||
|
||||
@@ -80,3 +80,5 @@ Current Status
|
||||
can guess, I'm not much of an emacs fan ;)
|
||||
|
||||
Chris Allegretta (chrisa@asty.org)
|
||||
|
||||
$Id$
|
||||
|
||||
10
TODO
10
TODO
@@ -2,7 +2,7 @@ TODO file (? means the feature may be implemented, but not definitely)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Current Version:
|
||||
- Implement Spelling [DONE, mostly...]
|
||||
- Implement Spelling [DONE]
|
||||
- Implement Help [DONE]
|
||||
- Internationalization [In progress, translators welcome!]
|
||||
- Allow nano to be resized in X. [DONE]
|
||||
@@ -11,9 +11,17 @@ Current Version:
|
||||
- Rewrite edit_refresh, if at all possible [DONE]
|
||||
- Implement justify function [DONE]
|
||||
- Cut to end of line [DONE]
|
||||
- Built-in speller command [needed for version 1.0] [DONE]
|
||||
- Better statusbar interaction (scrolling, tab completion for filename)
|
||||
[needed for version 1.0] [DONE]
|
||||
- Now do username completion [DONE].
|
||||
- Unjustify command (^U after ^J) [DONE =-].
|
||||
- Username completion (~user) [DONE =-].
|
||||
|
||||
For Next Version:
|
||||
- Undo/Redo key?
|
||||
- single line scroll up/down?
|
||||
- Color syntax highlighting? (certainly seems like there's a demand for it.)
|
||||
- .nanorc ?????
|
||||
|
||||
$Id$
|
||||
|
||||
17
acconfig.h
17
acconfig.h
@@ -1,3 +1,5 @@
|
||||
/* $Id$ */
|
||||
|
||||
/* Define this if you have the wresize function in your ncurses-type library */
|
||||
#undef HAVE_WRESIZE
|
||||
|
||||
@@ -22,5 +24,16 @@
|
||||
/* Define to use the slang wrappers for curses instead of native curses */
|
||||
#undef USE_SLANG
|
||||
|
||||
/* Define this if you have a behaving TABSIZE global in your curses lib */
|
||||
#undef HAVE_TABSIZE
|
||||
/* Define this to enable the extra stuff */
|
||||
#undef NANO_EXTRA
|
||||
|
||||
/* Define to disable the tab completion code Chris worked so hard on! */
|
||||
#undef DISABLE_TABCOMP
|
||||
|
||||
/* Define this to disable the justify routine */
|
||||
#undef DISABLE_JUSTIFY
|
||||
|
||||
/* Define this to disable the use(full|less) spelling functions */
|
||||
#undef DISABLE_SPELLER
|
||||
|
||||
|
||||
|
||||
16
config.h.in
16
config.h.in
@@ -76,8 +76,17 @@
|
||||
/* Define to use the slang wrappers for curses instead of native curses */
|
||||
#undef USE_SLANG
|
||||
|
||||
/* Define this if you have a behaving TABSIZE global in your curses lib */
|
||||
#undef HAVE_TABSIZE
|
||||
/* Define this to enable the extra stuff */
|
||||
#undef NANO_EXTRA
|
||||
|
||||
/* Define to disable the tab completion code Chris worked so hard on! */
|
||||
#undef DISABLE_TABCOMP
|
||||
|
||||
/* Define this to disable the justify routine */
|
||||
#undef DISABLE_JUSTIFY
|
||||
|
||||
/* Define this to disable the use(full|less) spelling functions */
|
||||
#undef DISABLE_SPELLER
|
||||
|
||||
/* Define if you have the __argz_count function. */
|
||||
#undef HAVE___ARGZ_COUNT
|
||||
@@ -157,6 +166,9 @@
|
||||
/* Define if you have the <nl_types.h> header file. */
|
||||
#undef HAVE_NL_TYPES_H
|
||||
|
||||
/* Define if you have the <regex.h> header file. */
|
||||
#undef HAVE_REGEX_H
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
|
||||
141
configure.in
141
configure.in
@@ -1,6 +1,7 @@
|
||||
# $Id$
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(nano.c)
|
||||
AM_INIT_AUTOMAKE(nano, 0.9.14)
|
||||
AM_INIT_AUTOMAKE(nano, 0.9.23)
|
||||
AM_CONFIG_HEADER(config.h:config.h.in)
|
||||
ALL_LINGUAS="es de fr it id fi"
|
||||
|
||||
@@ -10,7 +11,7 @@ AC_ISC_POSIX
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(fcntl.h unistd.h malloc.h termios.h termio.h limits.h getopt.h)
|
||||
AC_CHECK_HEADERS(fcntl.h unistd.h malloc.h termios.h termio.h limits.h getopt.h regex.h)
|
||||
|
||||
dnl options
|
||||
AC_ARG_ENABLE(tiny,
|
||||
@@ -20,49 +21,107 @@ AC_ARG_ENABLE(tiny,
|
||||
AC_DEFINE(NANO_SMALL) tiny_support=yes
|
||||
fi])
|
||||
|
||||
AC_ARG_ENABLE(extra,
|
||||
[ --enable-extra Enable extra (optional) functions, including easter eggs],
|
||||
[if test x$enableval = xyes; then
|
||||
AC_DEFINE(NANO_EXTRA) extra_support=yes
|
||||
fi])
|
||||
|
||||
AC_ARG_ENABLE(tabcomp,
|
||||
[ --disable-tabcomp Disables tab completion code for a smaller binary],
|
||||
[if test x$enableval != xyes; then
|
||||
AC_DEFINE(DISABLE_TABCOMP)
|
||||
fi])
|
||||
|
||||
AC_ARG_ENABLE(justify,
|
||||
[ --disable-justify Disable justify/unjustify function],
|
||||
[if test x$enableval != xyes; then
|
||||
AC_DEFINE(DISABLE_JUSTIFY)
|
||||
fi])
|
||||
|
||||
AC_ARG_ENABLE(speller,
|
||||
[ --disable-speller Disables spell checker function],
|
||||
[if test x$enableval != xyes; then
|
||||
AC_DEFINE(DISABLE_SPELLER)
|
||||
fi])
|
||||
|
||||
AC_MSG_CHECKING(whether to use slang)
|
||||
CURSES_LIB_NAME=""
|
||||
AC_ARG_WITH(slang,
|
||||
[ --with-slang[=DIR] Use the slang library instead of curses],
|
||||
[ case "$with_slang" in
|
||||
yes)
|
||||
AC_MSG_RESULT(yes)
|
||||
|
||||
AC_CHECK_HEADER(slcurses.h,
|
||||
AC_CHECK_LIB(slang, SLcurses_newwin,
|
||||
[AC_DEFINE(USE_SLANG) slang_support=yes
|
||||
CURSES_LIB="-lslang" CURSES_LIB_NAME=slang]),
|
||||
AC_MSG_ERROR([
|
||||
*** The header file slcurses.h was not found. If you wish to use
|
||||
*** slang support this header file is required. Please either
|
||||
*** install a version of slang that includes the slcurses.h file or
|
||||
*** do not call the configure script with --with-slang
|
||||
]))
|
||||
;;
|
||||
no)
|
||||
AC_MSG_RESULT(no)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(yes)
|
||||
|
||||
# Needed for AC_CHECK_HEADERS and AC_CHECK_LIB to look at
|
||||
# alternate readline path
|
||||
_ldflags=${LDFLAGS}
|
||||
_cppflags=${CPPFLAGS}
|
||||
|
||||
# Add additional search path
|
||||
LDFLAGS="-L$with_slang/lib $LDFLAGS"
|
||||
CPPFLAGS="-I$with_slang/include $CPPFLAGS"
|
||||
if test "$with_slang" != "yes"; then
|
||||
# Add additional search path
|
||||
LDFLAGS="-L$with_slang/lib $LDFLAGS"
|
||||
CPPFLAGS="-I$with_slang/include $CPPFLAGS"
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADER(slcurses.h,
|
||||
AC_CHECK_LIB(slang, SLcurses_newwin,
|
||||
[AC_DEFINE(USE_SLANG) slang_support=yes
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang"
|
||||
CURSES_LIB_NAME=slang],
|
||||
AC_MSG_ERROR([
|
||||
*** The slang library was not found or the version you have installed
|
||||
*** is incorrect.
|
||||
])),
|
||||
AC_MSG_CHECKING(for SLtt_initialize in -lslang)
|
||||
_libs=$LIBS
|
||||
LIBS="$LIBS -lslang"
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <slcurses.h>
|
||||
int main () { SLtt_initialize (NULL); return 0; }],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG)
|
||||
slang_support=yes
|
||||
if test "$with_slang" != "yes"; then
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang"
|
||||
else
|
||||
CURSES_LIB="-lslang"
|
||||
fi
|
||||
CURSES_LIB_NAME=slang], [
|
||||
AC_MSG_RESULT(no)
|
||||
# We might need the term library
|
||||
for termlib in ncurses curses termcap terminfo termlib; do
|
||||
AC_CHECK_LIB(${termlib}, tputs, [tcap="-l$termlib"])
|
||||
test -n "$tcap" && break
|
||||
done
|
||||
|
||||
AC_MSG_CHECKING(for SLtt_initialize in -lslang $tcap)
|
||||
LIBS="$LIBS $tcap"
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <slcurses.h>
|
||||
int main () { SLtt_initialize (NULL); return 0; }],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG)
|
||||
slang_support=yes
|
||||
if test "$with_slang" != "yes"; then
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
|
||||
else
|
||||
CURSES_LIB="-lslang $tcap"
|
||||
fi
|
||||
CURSES_LIB_NAME=slang], [
|
||||
AC_MSG_RESULT(no)
|
||||
# We might need the math library
|
||||
AC_MSG_CHECKING(for SLtt_initialize in -lslang $tcap -lm)
|
||||
LIBS="$LIBS -lm"
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
#include <slcurses.h>
|
||||
int main () { SLtt_initialize (NULL); return 0; }],
|
||||
[AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(USE_SLANG)
|
||||
slang_support=yes
|
||||
if test "$with_slang" != "yes"; then
|
||||
CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
|
||||
else
|
||||
CURSES_LIB="-lslang $tcap -lm"
|
||||
fi
|
||||
CURSES_LIB_NAME=slang],
|
||||
[AC_MSG_RESULT(no)],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
|
||||
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
|
||||
AC_MSG_ERROR([
|
||||
*** The header file slcurses.h was not found. If you wish to use
|
||||
*** slang support this header file is required. Please either
|
||||
@@ -70,9 +129,13 @@ AC_ARG_WITH(slang,
|
||||
*** do not call the configure script with --with-slang
|
||||
]))
|
||||
|
||||
LDFLAGS=${_ldflags}
|
||||
test "${_libs+set}" = "set" && LIBS=$_libs
|
||||
|
||||
if test "$with_slang" != "yes"; then
|
||||
LDFLAGS=${_ldflags}
|
||||
fi
|
||||
;;
|
||||
esac])
|
||||
esac], AC_MSG_RESULT(no))
|
||||
|
||||
dnl Checks for functions
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf)
|
||||
@@ -101,9 +164,7 @@ dnl Checks for libraries.
|
||||
if eval "test x$CURSES_LIB_NAME = x"
|
||||
then
|
||||
AC_CHECK_HEADERS(curses.h ncurses.h)
|
||||
AC_CHECK_LIB(ncurses, tgetent,[CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses
|
||||
dnl Only ncurses seems to have a working TABSIZE function.
|
||||
AC_DEFINE(HAVE_TABSIZE)])
|
||||
AC_CHECK_LIB(ncurses, tgetent,CURSES_LIB="-lncurses" CURSES_LIB_NAME=ncurses)
|
||||
fi
|
||||
|
||||
if eval "test x$CURSES_LIB_NAME = x"
|
||||
@@ -111,6 +172,12 @@ then
|
||||
AC_CHECK_LIB(curses, tgetent, CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses)
|
||||
fi
|
||||
|
||||
# Fallback for PDCurses and less useful curses libs...
|
||||
if eval "test x$CURSES_LIB_NAME = x"
|
||||
then
|
||||
AC_CHECK_LIB(curses, initscr, CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses)
|
||||
fi
|
||||
|
||||
if eval "test x$CURSES_LIB_NAME = x"
|
||||
then
|
||||
AC_CHECK_LIB(termcap, tgetent, CURSES_LIB="-ltermcap" CURSES_LIB_NAME=termcap)
|
||||
|
||||
53
cut.c
53
cut.c
@@ -1,3 +1,4 @@
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* cut.c *
|
||||
* *
|
||||
@@ -97,8 +98,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
|
||||
free(top->data);
|
||||
top->data = tmpstr;
|
||||
|
||||
bot->data[bot_x] = 0;
|
||||
align(&bot->data);
|
||||
null_at(bot->data, bot_x);
|
||||
next = bot->next;
|
||||
|
||||
/* We explicitly don't decrement totlines here because we don't snarf
|
||||
@@ -124,7 +124,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
|
||||
}
|
||||
}
|
||||
if (top->lineno < edittop->lineno)
|
||||
edit_update(top);
|
||||
edit_update(top, CENTER);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -136,6 +136,7 @@ int do_cut_text(void)
|
||||
int newsize, cuttingtoend = 0;
|
||||
#endif
|
||||
|
||||
check_statblank();
|
||||
if (fileptr == NULL || fileptr->data == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -149,17 +150,19 @@ int do_cut_text(void)
|
||||
fprintf(stderr, _("Blew away cutbuffer =)\n"));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Must let cutbuffer get blown away first before we do this... */
|
||||
if (fileptr == filebot && !ISSET(MARK_ISSET))
|
||||
return 0;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) {
|
||||
if (current_x == strlen(current->data))
|
||||
{
|
||||
if (current_x == strlen(current->data)) {
|
||||
do_delete();
|
||||
SET(KEEP_CUTBUFFER);
|
||||
marked_cut = 2;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
SET(MARK_ISSET);
|
||||
SET(KEEP_CUTBUFFER);
|
||||
|
||||
@@ -208,7 +211,7 @@ int do_cut_text(void)
|
||||
if (cuttingtoend)
|
||||
edit_refresh();
|
||||
else
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
|
||||
return 1;
|
||||
#else
|
||||
@@ -221,11 +224,11 @@ int do_cut_text(void)
|
||||
tmp = fileptr;
|
||||
fileage = fileptr;
|
||||
add_to_cutbuffer(fileptr->prev);
|
||||
totsize--; /* get the newline */
|
||||
totsize--; /* get the newline */
|
||||
totlines--;
|
||||
fileptr->prev = NULL;
|
||||
edit_update(fileage);
|
||||
current = fileptr;
|
||||
edit_update(fileage, CENTER);
|
||||
} else {
|
||||
add_to_cutbuffer(fileptr);
|
||||
fileage = make_new_node(NULL);
|
||||
@@ -241,20 +244,10 @@ int do_cut_text(void)
|
||||
(fileptr->next)->prev = fileptr->prev;
|
||||
current = fileptr->next;
|
||||
totlines--;
|
||||
totsize--; /* get the newline */
|
||||
} else {
|
||||
/* we're deleteing the last line
|
||||
and replacing it with a dummy line,
|
||||
so totlines is the same */
|
||||
tmp = fileptr->prev;
|
||||
tmp->next = make_new_node(tmp);
|
||||
tmp = tmp->next;
|
||||
tmp->data = nmalloc(1);
|
||||
strcpy(tmp->data, "");
|
||||
current = tmp;
|
||||
filebot = tmp;
|
||||
totsize--; /* get the newline */
|
||||
}
|
||||
|
||||
/* No longer an else here, because we never get here anymore...
|
||||
No need to cut the magic line, as it's empty */
|
||||
add_to_cutbuffer(fileptr);
|
||||
}
|
||||
|
||||
@@ -285,6 +278,7 @@ int do_uncut_text(void)
|
||||
int i;
|
||||
|
||||
wrap_reset();
|
||||
check_statblank();
|
||||
if (cutbuffer == NULL || fileptr == NULL)
|
||||
return 0; /* AIEEEEEEEEEEEE */
|
||||
|
||||
@@ -356,7 +350,7 @@ int do_uncut_text(void)
|
||||
|
||||
current = newend;
|
||||
if (i <= newend->lineno)
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
}
|
||||
|
||||
/* If marked cut == 2, that means that we're doing a cut to end
|
||||
@@ -368,11 +362,8 @@ int do_uncut_text(void)
|
||||
tmp = make_new_node(current);
|
||||
tmp->data = nmalloc(strlen(¤t->data[current_x]) + 1);
|
||||
strcpy(tmp->data, ¤t->data[current_x]);
|
||||
tmp->next = current->next;
|
||||
current->next = tmp;
|
||||
tmp->prev = current;
|
||||
current->data[current_x] = 0;
|
||||
current->data = nrealloc(current->data, strlen(current->data) + 1);
|
||||
splice_node(current, tmp, current->next);
|
||||
null_at(current->data, current_x);
|
||||
current = current->next;
|
||||
current_x = 0;
|
||||
placewewant = 0;
|
||||
@@ -411,7 +402,7 @@ int do_uncut_text(void)
|
||||
i = editbot->lineno;
|
||||
renumber(newbuf);
|
||||
if (i < newend->lineno)
|
||||
edit_update(fileptr);
|
||||
edit_update(fileptr, CENTER);
|
||||
|
||||
dump_buffer_reverse(fileptr);
|
||||
|
||||
|
||||
77
faq.html
77
faq.html
@@ -46,7 +46,9 @@ THE HECK DO I DO NOW?</a></font>
|
||||
<br><font color="#330000"><a href="#3.2">3.3. Why does everything go into
|
||||
/usr/local?</a></font>
|
||||
<br><font color="#330000"><a href="#3.4">3.4. I get errors about 'bindtextdomain',
|
||||
'gettext' and/or 'gettextdomain'. What can I do about it?</a></font></blockquote>
|
||||
'gettext' and/or 'gettextdomain'. What can I do about it?</a></font>
|
||||
<br><font color="#330000"><a href="#3.5">3.5. Nano should automatically
|
||||
run strip on the binary when installing it!</a></font></blockquote>
|
||||
|
||||
<h2>
|
||||
<font color="#330000"><a href="#4">4. Running</a></font></h2>
|
||||
@@ -59,8 +61,11 @@ bucky/meta key doesn't seem to work! What can I do?</a></font>
|
||||
my window. How can I fix that?</a></font>
|
||||
<br><font color="#330000"><a href="#4.4">4.4. Why does nano show ^\ and
|
||||
^_ in the shortcut list instead of ^G and ^J?</a></font>
|
||||
<br><a href="#4.5">4.5 How do I make nano my default editor (in Pine, mutt,
|
||||
etc.)?</a></blockquote>
|
||||
<br><font color="#330000"><a href="#4.5">4.5. When I type in a
|
||||
search string, the string I last searched for is already in front of
|
||||
my cursor! !What happened?!</a></font>
|
||||
<br><a href="#4.6">4.6 How do I make nano my default editor (in Pine,
|
||||
mutt, etc.)?</a></blockquote>
|
||||
|
||||
<h2>
|
||||
<font color="#330000"><a href="#5">5. Internationalization</a></font></h2>
|
||||
@@ -118,7 +123,8 @@ will volunteer to maintain this FAQ someday, who knows...</font></blockquote>
|
||||
<a NAME="1.2"></a><font color="#330000">1.2. How do I contribute to it?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">Your best bet is to send it to the nano
|
||||
email address, <a href="mailto:nano@asty.org">nano@asty.org</a> and if
|
||||
email address, <a
|
||||
href="mailto:nano@nano-editor.org">nano@nano-editor.org</a> and if
|
||||
it is useful enough it will be included in future versions.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -183,7 +189,7 @@ nano was developed).</font></blockquote>
|
||||
of nano?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">The current version of nano *should*
|
||||
be 0.9.14. Of course you should always check the nano hompage to
|
||||
be 0.9.23. Of course you should always check the nano hompage to
|
||||
see what the latest and greatest version is.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -191,7 +197,7 @@ see what the latest and greatest version is.</font></blockquote>
|
||||
without having to download the program!</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">Jeez, demanding, aren't we?
|
||||
Okay, look <a href="http://www.asty.org/nano/dist/nano.1.html">here</a>.</font></blockquote>
|
||||
Okay, look <a href="http://www.nano-editor.org/dist/nano.1.html">here</a>.</font></blockquote>
|
||||
|
||||
<hr WIDTH="100%">
|
||||
<h1>
|
||||
@@ -205,13 +211,13 @@ nano.</font></h2>
|
||||
at the following fine web and ftp sites:</font>
|
||||
<ul>
|
||||
<li>
|
||||
<font color="#330000"><a href="http://www.asty.org/nano/dist">http://www.asty.org/nano/dist</a></font></li>
|
||||
<font color="#330000"><a href="http://www.nano-editor.org/dist">http://www.nano-editor.org/dist</a></font></li>
|
||||
|
||||
<li>
|
||||
<font color="#330000"><a href="http://www.ewtoo.org/~astyanax/nano/dist">http://www.ewtoo.org/~astyanax/nano/dist</a></font></li>
|
||||
|
||||
<li>
|
||||
<font color="#330000"><a href="ftp://ftp.asty.org/pub/nano">ftp://ftp.asty.org/pub/nano</a></font></li>
|
||||
<font color="#330000"><a href="ftp://ftp.nano-editor.org/pub/nano">ftp://ftp.nano-editor.org/pub/nano</a></font></li>
|
||||
|
||||
<li>
|
||||
<font color="#330000"><a href="ftp://nano.sourceforge.net/pub/nano/">ftp://nano.sourceforge.net/pub/nano</a></font></li>
|
||||
@@ -225,13 +231,13 @@ packages.</font></h2>
|
||||
<blockquote>
|
||||
<ul>
|
||||
<li>
|
||||
<font color="#330000"><a href="http://www.asty.org/nano/dist/RPMS">http://www.asty.org/nano/dist/RPMS</a></font></li>
|
||||
<font color="#330000"><a href="http://www.nano-editor.org/dist/RPMS">http://www.nano-editor.org/dist/RPMS</a></font></li>
|
||||
|
||||
<li>
|
||||
<font color="#330000"><a href="http://www.ewtoo.org/~astyanax/nano/dist/RPMS">http://www.ewtoo.org/~astyanax/nano/dist/RPMS</a></font></li>
|
||||
|
||||
<li>
|
||||
<font color="#330000"><a href="ftp://ftp.asty.org/pub/nano/RPMS">ftp://ftp.asty.org/pub/nano/RPMS</a></font></li>
|
||||
<font color="#330000"><a href="ftp://ftp.nano-editor.org/pub/nano/RPMS">ftp://ftp.nano-editor.org/pub/nano/RPMS</a></font></li>
|
||||
|
||||
<li>
|
||||
<font color="#330000"><a href="ftp://nano.sourceforge.net/pub/nano/RPMS">ftp://nano.sourceforge.net/pub/nano/RPMS</a></font></li>
|
||||
@@ -254,14 +260,14 @@ at:</font>
|
||||
current nano packages for:</font>
|
||||
<ul>
|
||||
<li>
|
||||
<font color="#330000"><a href="http://www.debian.org/Packages/frozen/editors/nano.html">frozen</a></font></li>
|
||||
<font color="#330000"><a href="http://www.debian.org/Packages/stable/editors/nano.html">stable</a></font></li>
|
||||
|
||||
<li>
|
||||
<font color="#330000"><a href="http://www.debian.org/Packages/unstable/editors/nano.html">unstable</a></font></li>
|
||||
</ul>
|
||||
<font color="#330000">Note that versions < 0.9.10 are probably not for
|
||||
those wanting to get serious work done, so until the frozen/stable distributions
|
||||
have an updated version of nano, you are best off using the one in unstable
|
||||
those wanting to get serious work done, so until the stable distribution
|
||||
has an updated version of nano, you are best off using the one in unstable
|
||||
for now.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -300,7 +306,7 @@ isn't hard. Unpack the nano source with a command like:</font>
|
||||
<p><b><font color="#330000">tar -zxvf nano-x.y.z.tar.gz</font></b>
|
||||
<p><font color="#330000">If you get error messages about the -z option,
|
||||
try this:</font>
|
||||
<p><b><font color="#330000">gunzip -d nano-x.y.z.tar.gz | tar xvf -</font></b>
|
||||
<p><b><font color="#330000">gzip -dc nano-x.y.z.tar.gz | tar xvf -</font></b>
|
||||
<p><font color="#330000">(again, where x.y.z is the version number in question).
|
||||
Then you need to run configure with any options you might want (if any).</font>
|
||||
<p><font color="#330000">The average case is this:</font>
|
||||
@@ -326,6 +332,14 @@ install</b>.</font></blockquote>
|
||||
and see if that solves your problem. You make need to do a <b>make
|
||||
clean ; make</b> to get it to work fully.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="3.5"></a><font color="#330000">3.5. Nano should automatically
|
||||
run strip on the binary when installing it!</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">Actually, it does, but you have to use
|
||||
<b>make install-strip</b>. The default make install does not, and will
|
||||
not, run strip automatically.</font></blockquote>
|
||||
|
||||
<hr WIDTH="100%">
|
||||
<h1>
|
||||
<a NAME="4"></a><font color="#330000">4. Running</font></h1>
|
||||
@@ -347,7 +361,7 @@ keystroke here>!</font></h2>
|
||||
<blockquote><font color="#330000">If you aren't trying some bizarre keystroke
|
||||
combination with some bizarre $TERM entry, chances are you have found a
|
||||
bug. You are welcome to submit it to the nano-devel list or
|
||||
to <a href="mailto:nano@asty.org">nano@asty.org</a>.</font></blockquote>
|
||||
to <a href="mailto:nano@nano-editor.org">nano@nano-editor.org</a>.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="4.3"></a><font color="#330000">4.3. Nano crashes when I resize
|
||||
@@ -368,8 +382,22 @@ shortcut list. If you use the <b>-p</b> option to nano you
|
||||
will get the same shortcuts at the bottom as Pico.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="4.5"></a>4.5 How do I make nano my default editor (in Pine, mutt,
|
||||
etc)?</h2>
|
||||
<a name="4.5"><font color="#330000">4.5. When I type in a search
|
||||
string, the string I last searched for is already in front of my
|
||||
cursor! !What happened?!</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">In nano version 0.9.20, the default is
|
||||
to have a completely consistent user interface across all user input
|
||||
functions. This means that regardless of whether you're being asked for
|
||||
a filename to insert or write, or a string to search for, the
|
||||
previous value is already inserted before the cursor. If you prefer the
|
||||
old behavior, use the pico emulation mode (-p or --pico) or just hit
|
||||
Meta-P while in nano (see the ^G help text for more
|
||||
details).</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="4.6"></a>4.6. How do I make nano my default editor (in Pine,
|
||||
mutt, etc)?</h2>
|
||||
|
||||
<blockquote>You need to make nano your $EDITOR. If you want this
|
||||
to be saved, you should put a line like this in your <b>.bashrc</b> if
|
||||
@@ -406,7 +434,7 @@ my language!</font></h2>
|
||||
language to write one =-). Just grab the <b>nano.pot</b> file from
|
||||
the latest and greatest nano distribution (it's in the <b>po/</b> directory)
|
||||
and translate each line into your native language on the <b>msgstr</b>
|
||||
line. Then send it to the nano devel list or <a href="mailto:nano@asty.org">nano@asty.org</a>.</font></blockquote>
|
||||
line. Then send it to the nano devel list or <a href="mailto:nano@nano-editor.org">nano@nano-editor.org</a>.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="5.2"></a><font color="#330000">5.2. I don't like the translation
|
||||
@@ -426,14 +454,14 @@ or the devel list.</font></blockquote>
|
||||
of Pico?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">There are many reasons to use nano instead
|
||||
of Pico, a more complete list can be found at the <a href="http://www.asty.org/nano">nano
|
||||
of Pico, a more complete list can be found at the <a href="http://www.nano-edior.org">nano
|
||||
homepage</a>.</font></blockquote>
|
||||
|
||||
<h2>
|
||||
<a NAME="6.2"></a><font color="#330000">6.2. Why should I use Pico instead
|
||||
of nano?</font></h2>
|
||||
|
||||
<blockquote>Again, check out the <a href="http://www.asty.org/nano">nano
|
||||
<blockquote>Again, check out the <a href="http://www.nano-editor.org">nano
|
||||
homepage</a> for a good summary of reasons. It really is a matter
|
||||
of personal preference as to which editor you should use. If you're
|
||||
the type of person who likes using the original version of a program, then
|
||||
@@ -473,7 +501,7 @@ also licensed under the GPL.</font></blockquote>
|
||||
their license?</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">You're really not asking the right person
|
||||
here. I (Chris) waited along time to see if UW would change their
|
||||
here. I (Chris) waited a long time to see if UW would change their
|
||||
license because of the amount of high quality software being released and
|
||||
developed under the GPL without being taken advantage of by malicious corporate
|
||||
entities or other baddies, but no such luck so far.</font></blockquote>
|
||||
@@ -510,8 +538,8 @@ a given list:</font><font color="#330000"></font>
|
||||
team a big load of cash (or just a thank you).</font></h2>
|
||||
|
||||
<blockquote><font color="#330000">That's fine. Send it <a href="mailto:nano-devel@lists.sourceforge.net">our
|
||||
way</a>! Better yet, fix a <a href="http://www.asty.org/nano/dist/BUGS">bug</a>
|
||||
in the program or implement a <a href="http://www.asty.org/nano/dist/TODO">cool
|
||||
way</a>! Better yet, fix a <a href="http://www.nano-editor.org/dist/BUGS">bug</a>
|
||||
in the program or implement a <a href="http://www.nano-editor.org/dist/TODO">cool
|
||||
feature</a> and send us that instead (though cash is fine too).</font></blockquote>
|
||||
|
||||
<h2>
|
||||
@@ -541,6 +569,7 @@ and you should know the answer.</font></blockquote>
|
||||
<a NAME="8"></a>8. ChangeLog</h1>
|
||||
|
||||
<blockquote>06/31/2000 - Initial framework.</blockquote>
|
||||
|
||||
<P>
|
||||
$Id$
|
||||
</body>
|
||||
</html>
|
||||
|
||||
696
files.c
696
files.c
@@ -1,3 +1,4 @@
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* files.c *
|
||||
* *
|
||||
@@ -26,6 +27,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "proto.h"
|
||||
@@ -176,7 +179,7 @@ int read_file(int fd, char *filename)
|
||||
buf[0] = 0;
|
||||
}
|
||||
/* Did we even GET a file? */
|
||||
if (totsize == 0) {
|
||||
if (totsize == 0 || fileptr == NULL) {
|
||||
new_file();
|
||||
statusbar(_("Read %d lines"), num_lines);
|
||||
return 1;
|
||||
@@ -227,7 +230,8 @@ int open_file(char *filename, int insert, int quiet)
|
||||
} else { /* File is A-OK */
|
||||
if (S_ISDIR(fileinfo.st_mode)) {
|
||||
statusbar(_("File \"%s\" is a directory"), filename);
|
||||
new_file();
|
||||
if (!insert)
|
||||
new_file();
|
||||
return -1;
|
||||
}
|
||||
if (!quiet)
|
||||
@@ -241,9 +245,10 @@ int open_file(char *filename, int insert, int quiet)
|
||||
int do_insertfile(void)
|
||||
{
|
||||
int i;
|
||||
char *realname = NULL;
|
||||
|
||||
wrap_reset();
|
||||
i = statusq(writefile_list, WRITEFILE_LIST_LEN, "",
|
||||
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, "",
|
||||
_("File to insert [from ./] "));
|
||||
if (i != -1) {
|
||||
|
||||
@@ -251,7 +256,14 @@ int do_insertfile(void)
|
||||
fprintf(stderr, "filename is %s", answer);
|
||||
#endif
|
||||
|
||||
i = open_file(answer, 1, 0);
|
||||
#ifndef DISABLE_TABCOMP
|
||||
realname = real_dir_from_tilde(answer);
|
||||
#else
|
||||
realname = mallocstrcpy(realname, answer);
|
||||
#endif
|
||||
|
||||
i = open_file(realname, 1, 0);
|
||||
free(realname);
|
||||
|
||||
dump_buffer(fileage);
|
||||
set_modified();
|
||||
@@ -261,7 +273,7 @@ int do_insertfile(void)
|
||||
|
||||
/* If we've gone off the bottom, recenter, otherwise just redraw */
|
||||
if (current->lineno > editbot->lineno)
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
else
|
||||
edit_refresh();
|
||||
|
||||
@@ -281,16 +293,17 @@ int do_insertfile(void)
|
||||
* we don't set the global variable filename to it's name, and don't
|
||||
* print out how many lines we wrote on the statusbar.
|
||||
*
|
||||
* Note that tmp is only set to 1 for storing temporary files internal
|
||||
* to the editor, and is completely different from TEMP_OPT.
|
||||
* tmp means we are writing a tmp file in a secute fashion. We use
|
||||
* it when spell checking or dumping the file on an error.
|
||||
*/
|
||||
int write_file(char *name, int tmp)
|
||||
{
|
||||
long size, lineswritten = 0;
|
||||
char buf[PATH_MAX + 1];
|
||||
filestruct *fileptr;
|
||||
int fd, mask = 0;
|
||||
struct stat st;
|
||||
int fd, mask = 0, realexists, anyexists;
|
||||
struct stat st, lst, st2;
|
||||
static char *realname = NULL;
|
||||
|
||||
if (!strcmp(name, "")) {
|
||||
statusbar(_("Cancelled"));
|
||||
@@ -299,18 +312,71 @@ int write_file(char *name, int tmp)
|
||||
titlebar();
|
||||
fileptr = fileage;
|
||||
|
||||
if (realname != NULL)
|
||||
free(realname);
|
||||
|
||||
/* Check to see if the file is a regular file and FOLLOW_SYMLINKS is
|
||||
set. If so then don't do the delete and recreate code which would
|
||||
cause unexpected behavior */
|
||||
lstat(name, &st);
|
||||
#ifndef DISABLE_TABCOMP
|
||||
realname = real_dir_from_tilde(name);
|
||||
#else
|
||||
realname = mallocstrcpy(realname, name);
|
||||
#endif
|
||||
|
||||
/* Open the file and truncate it. Trust the symlink. */
|
||||
if ((ISSET(FOLLOW_SYMLINKS) || !S_ISLNK(st.st_mode)) && !tmp) {
|
||||
/* Save the state of file at the end of the symlink (if there is one) */
|
||||
realexists = stat(realname, &st);
|
||||
|
||||
if ((fd = open(name, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
|
||||
S_IWOTH)) == -1) {
|
||||
/* Stat the link itself for the check... */
|
||||
anyexists = lstat(realname, &lst);
|
||||
|
||||
/* New case: if the file exists, just give up */
|
||||
if (tmp && anyexists != -1)
|
||||
return -1;
|
||||
/* NOTE: If you change this statement, you MUST CHANGE the if
|
||||
statement below (that starts "if ((!ISSET(FOLLOW_SYMLINKS)...")
|
||||
to reflect whether or not to link/unlink/rename the file */
|
||||
else if (ISSET(FOLLOW_SYMLINKS) || !S_ISLNK(lst.st_mode) || tmp) {
|
||||
|
||||
/* Use O_EXCL if tmp == 1, I suppose */
|
||||
if (tmp)
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
|
||||
S_IWOTH);
|
||||
else
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
|
||||
S_IWOTH);
|
||||
|
||||
/* First, just give up if we couldn't even open the file */
|
||||
if (fd == -1) {
|
||||
if (!tmp && ISSET(TEMP_OPT)) {
|
||||
UNSET(TEMP_OPT);
|
||||
return do_writeout(1);
|
||||
}
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
free(realname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Now we fstat() the file, to make sure it's the same file still!
|
||||
Thanks to Oliver Friedrichs(?) for this code from securityfocus */
|
||||
|
||||
if (fstat(fd, &st2) != 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
/* Don't follow symlink. Create new file. */
|
||||
else {
|
||||
if (strlen(realname) > (PATH_MAX - 7)) {
|
||||
statusbar(_("Could not open file: Path length exceeded."));
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(buf, 0x00, PATH_MAX + 1);
|
||||
strcat(buf, realname);
|
||||
strcat(buf, ".XXXXXX");
|
||||
if ((fd = mkstemp(buf)) == -1) {
|
||||
if (ISSET(TEMP_OPT)) {
|
||||
UNSET(TEMP_OPT);
|
||||
return do_writeout(1);
|
||||
@@ -320,31 +386,12 @@ int write_file(char *name, int tmp)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* Don't follow symlink. Create new file. */
|
||||
else {
|
||||
if (strlen(name) > (PATH_MAX - 7)) {
|
||||
statusbar(_("Could not open file: Path length exceeded."));
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(buf, 0x00, PATH_MAX + 1);
|
||||
strcat(buf, name);
|
||||
strcat(buf, ".XXXXXX");
|
||||
if ((fd = mkstemp(buf)) == -1) {
|
||||
if (ISSET(TEMP_OPT)) {
|
||||
UNSET(TEMP_OPT);
|
||||
return do_writeout(1);
|
||||
}
|
||||
statusbar(_("Could not open file for writing: %s"),
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
dump_buffer(fileage);
|
||||
while (fileptr != NULL && fileptr->next != NULL) {
|
||||
/* Next line is so we discount the "magic line" */
|
||||
if(filebot == fileptr && fileptr->data[0] == '\0') break;
|
||||
if (filebot == fileptr && fileptr->data[0] == '\0')
|
||||
break;
|
||||
|
||||
size = write(fd, fileptr->data, strlen(fileptr->data));
|
||||
if (size == -1) {
|
||||
@@ -380,78 +427,77 @@ int write_file(char *name, int tmp)
|
||||
|
||||
|
||||
if (close(fd) == -1) {
|
||||
statusbar(_("Could not close %s: %s"), name, strerror(errno));
|
||||
statusbar(_("Could not close %s: %s"), realname, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ISSET(FOLLOW_SYMLINKS) || tmp) {
|
||||
if (stat(name, &st) == -1) {
|
||||
/* Use default umask as file permisions if file is a new file. */
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
if (realexists == -1 || tmp ||
|
||||
(!ISSET(FOLLOW_SYMLINKS) && S_ISLNK(lst.st_mode))) {
|
||||
|
||||
if (tmp) /* We don't want anyone reading our temporary file! */
|
||||
mask = 0600;
|
||||
else
|
||||
mask = 0666 & ~mask;
|
||||
/* Use default umask as file permisions if file is a new file. */
|
||||
mask = umask(0);
|
||||
umask(mask);
|
||||
|
||||
} else {
|
||||
/* Use permissions from file we are overwriting. */
|
||||
mask = st.st_mode;
|
||||
if (unlink(name) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
name, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
}
|
||||
if (tmp) /* We don't want anyone reading our temporary file! */
|
||||
mask = 0600;
|
||||
else
|
||||
mask = 0666 & ~mask;
|
||||
} else
|
||||
/* Use permissions from file we are overwriting. */
|
||||
mask = st.st_mode;
|
||||
|
||||
if (!tmp && (!ISSET(FOLLOW_SYMLINKS) && S_ISLNK(lst.st_mode))) {
|
||||
if (unlink(realname) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
realname, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (link(buf, name) != -1)
|
||||
if (link(buf, realname) != -1)
|
||||
unlink(buf);
|
||||
else if (errno != EPERM) {
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
name, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
} else if (rename(buf, name) == -1) { /* Try a rename?? */
|
||||
} else if (rename(buf, realname) == -1) { /* Try a rename?? */
|
||||
statusbar(_("Could not open %s for writing: %s"),
|
||||
name, strerror(errno));
|
||||
realname, strerror(errno));
|
||||
unlink(buf);
|
||||
return -1;
|
||||
}
|
||||
if (chmod(name, mask) == -1) {
|
||||
statusbar(_("Could not set permissions %o on %s: %s"),
|
||||
mask, name, strerror(errno));
|
||||
}
|
||||
}
|
||||
if (chmod(realname, mask) == -1)
|
||||
statusbar(_("Could not set permissions %o on %s: %s"),
|
||||
mask, realname, strerror(errno));
|
||||
|
||||
}
|
||||
if (!tmp) {
|
||||
strncpy(filename, name, 132);
|
||||
strncpy(filename, realname, 132);
|
||||
statusbar(_("Wrote %d lines"), lineswritten);
|
||||
UNSET(MODIFIED);
|
||||
titlebar();
|
||||
}
|
||||
UNSET(MODIFIED);
|
||||
titlebar();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_writeout(int exiting)
|
||||
{
|
||||
int i = 0;
|
||||
#ifdef NANO_EXTRA
|
||||
static int did_cred = 0;
|
||||
#endif
|
||||
|
||||
strncpy(answer, filename, 132);
|
||||
answer = mallocstrcpy(answer, filename);
|
||||
|
||||
if ((exiting) && (ISSET(TEMP_OPT))) {
|
||||
if (filename[0])
|
||||
{
|
||||
if (filename[0]) {
|
||||
i = write_file(answer, 0);
|
||||
display_main_list();
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
UNSET(TEMP_OPT);
|
||||
do_exit();
|
||||
|
||||
@@ -461,7 +507,7 @@ int do_writeout(int exiting)
|
||||
}
|
||||
|
||||
while (1) {
|
||||
i = statusq(writefile_list, WRITEFILE_LIST_LEN, answer,
|
||||
i = statusq(1, writefile_list, WRITEFILE_LIST_LEN, answer,
|
||||
_("File Name to write"));
|
||||
|
||||
if (i != -1) {
|
||||
@@ -469,7 +515,16 @@ int do_writeout(int exiting)
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("filename is %s"), answer);
|
||||
#endif
|
||||
if (strncmp(answer, filename, 132)) {
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
if (exiting && !ISSET(TEMP_OPT) && !strcasecmp(answer, "zzy")
|
||||
&& !did_cred) {
|
||||
do_credits();
|
||||
did_cred = 1;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
if (strcmp(answer, filename)) {
|
||||
struct stat st;
|
||||
if (!stat(answer, &st)) {
|
||||
i = do_yesno(0, 0, _("File exists, OVERWRITE ?"));
|
||||
@@ -494,3 +549,486 @@ int do_writeout_void(void)
|
||||
{
|
||||
return do_writeout(0);
|
||||
}
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
static char **homedirs;
|
||||
|
||||
/* Return a malloc()ed string containing the actual directory, used
|
||||
* to convert ~user and ~/ notation...
|
||||
*/
|
||||
char *real_dir_from_tilde(char *buf)
|
||||
{
|
||||
char *dirtmp = NULL, *line = NULL, byte[1], *lineptr;
|
||||
int fd, i, status, searchctr = 1;
|
||||
|
||||
if (buf[0] == '~') {
|
||||
if (buf[1] == '~')
|
||||
goto abort; /* Handle ~~ without segfaulting =) */
|
||||
else if (buf[1] == '/') {
|
||||
if (getenv("HOME") != NULL) {
|
||||
dirtmp = nmalloc(strlen(buf) + 2 + strlen(getenv("HOME")));
|
||||
|
||||
sprintf(dirtmp, "%s/%s", getenv("HOME"), &buf[2]);
|
||||
}
|
||||
} else if (buf[1] != 0) {
|
||||
|
||||
if ((fd = open("/etc/passwd", O_RDONLY)) == -1)
|
||||
goto abort;
|
||||
|
||||
/* Figure how how much of of the str we need to compare */
|
||||
for (searchctr = 1; buf[searchctr] != '/' &&
|
||||
buf[searchctr] != 0; searchctr++);
|
||||
|
||||
do {
|
||||
i = 0;
|
||||
line = nmalloc(1);
|
||||
while ((status = read(fd, byte, 1)) != 0
|
||||
&& byte[0] != '\n') {
|
||||
|
||||
line[i] = byte[0];
|
||||
i++;
|
||||
line = nrealloc(line, i + 1);
|
||||
}
|
||||
line[i] = 0;
|
||||
|
||||
if (i == 0)
|
||||
goto abort;
|
||||
|
||||
line[i] = 0;
|
||||
lineptr = strtok(line, ":");
|
||||
|
||||
if (!strncmp(lineptr, &buf[1], searchctr - 1)) {
|
||||
|
||||
/* Okay, skip to the password portion now */
|
||||
for (i = 0; i <= 4 && lineptr != NULL; i++)
|
||||
lineptr = strtok(NULL, ":");
|
||||
|
||||
if (lineptr == NULL)
|
||||
goto abort;
|
||||
|
||||
/* Else copy the new string into the new buf */
|
||||
dirtmp = nmalloc(strlen(buf) + 2 + strlen(lineptr));
|
||||
|
||||
sprintf(dirtmp, "%s%s", lineptr, &buf[searchctr]);
|
||||
free(line);
|
||||
break;
|
||||
}
|
||||
|
||||
free(line);
|
||||
|
||||
} while (status != 0);
|
||||
}
|
||||
} else
|
||||
dirtmp = mallocstrcpy(dirtmp, buf);
|
||||
|
||||
return dirtmp;
|
||||
|
||||
abort:
|
||||
dirtmp = mallocstrcpy(dirtmp, buf);
|
||||
return dirtmp;
|
||||
}
|
||||
|
||||
/* Tack a slash onto the string we're completing if it's a directory */
|
||||
int append_slash_if_dir(char *buf, int *lastWasTab, int *place)
|
||||
{
|
||||
char *dirptr;
|
||||
struct stat fileinfo;
|
||||
int ret = 0;
|
||||
|
||||
dirptr = real_dir_from_tilde(buf);
|
||||
|
||||
if (stat(dirptr, &fileinfo) == -1)
|
||||
ret = 0;
|
||||
else if (S_ISDIR(fileinfo.st_mode)) {
|
||||
strncat(buf, "/", 1);
|
||||
*place += 1;
|
||||
/* now we start over again with # of tabs so far */
|
||||
*lastWasTab = 0;
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
if (dirptr != buf)
|
||||
free(dirptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions (username_tab_completion, cwd_tab_completion, and
|
||||
* input_tab were taken from busybox 0.46 (cmdedit.c). Here is the notice
|
||||
* from that file:
|
||||
*
|
||||
* Termios command line History and Editting, originally
|
||||
* intended for NetBSD sh (ash)
|
||||
* Copyright (c) 1999
|
||||
* Main code: Adam Rogoyski <rogoyski@cs.utexas.edu>
|
||||
* Etc: Dave Cinege <dcinege@psychosis.com>
|
||||
* Majorly adjusted/re-written for busybox:
|
||||
* Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* You may use this code as you wish, so long as the original author(s)
|
||||
* are attributed in any redistributions of the source code.
|
||||
* This code is 'as is' with no warranty.
|
||||
* This code may safely be consumed by a BSD or GPL license.
|
||||
*/
|
||||
|
||||
char **username_tab_completion(char *buf, int *num_matches)
|
||||
{
|
||||
char **matches = (char **) NULL, *line = NULL, *lineptr;
|
||||
char *matchline = NULL, *matchdir = NULL;
|
||||
|
||||
int fd, i = 0, status = 1;
|
||||
char byte[1];
|
||||
|
||||
if ((fd = open("/etc/passwd", O_RDONLY)) == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (homedirs != NULL) {
|
||||
for (i = 0; i < *num_matches; i++)
|
||||
free(homedirs[i]);
|
||||
free(homedirs);
|
||||
homedirs = (char **) NULL;
|
||||
*num_matches = 0;
|
||||
}
|
||||
matches = nmalloc(BUFSIZ);
|
||||
homedirs = nmalloc(BUFSIZ);
|
||||
strcat(buf, "*");
|
||||
do {
|
||||
i = 0;
|
||||
line = nmalloc(1);
|
||||
while ((status = read(fd, byte, 1)) != 0 && byte[0] != '\n') {
|
||||
|
||||
line[i] = byte[0];
|
||||
i++;
|
||||
line = nrealloc(line, i + 1);
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
break;
|
||||
|
||||
line[i] = 0;
|
||||
lineptr = strtok(line, ":");
|
||||
|
||||
if (check_wildcard_match(line, &buf[1]) == TRUE) {
|
||||
|
||||
if (*num_matches == BUFSIZ)
|
||||
break;
|
||||
|
||||
/* Cool, found a match. Add it to the list
|
||||
* This makes a lot more sense to me (Chris) this way...
|
||||
*/
|
||||
matchline = nmalloc(strlen(line) + 2);
|
||||
sprintf(matchline, "~%s", line);
|
||||
|
||||
for (i = 0; i <= 4 && lineptr != NULL; i++)
|
||||
lineptr = strtok(NULL, ":");
|
||||
|
||||
if (lineptr == NULL)
|
||||
break;
|
||||
|
||||
matchdir = mallocstrcpy(matchdir, lineptr);
|
||||
homedirs[*num_matches] = matchdir;
|
||||
matches[*num_matches] = matchline;
|
||||
|
||||
++*num_matches;
|
||||
|
||||
/* If there's no more room, bail out */
|
||||
if (*num_matches == BUFSIZ)
|
||||
break;
|
||||
}
|
||||
|
||||
free(line);
|
||||
|
||||
} while (status != 0);
|
||||
|
||||
close(fd);
|
||||
return matches;
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "\nin username_tab_completion\n");
|
||||
#endif
|
||||
return (matches);
|
||||
}
|
||||
|
||||
/* This was originally called exe_n_cwd_tab_completion, but we're not
|
||||
worried about executables, only filenames :> */
|
||||
|
||||
char **cwd_tab_completion(char *buf, int *num_matches)
|
||||
{
|
||||
char *dirName, *dirtmp = NULL, *tmp = NULL, *tmp2 = NULL;
|
||||
char **matches = (char **) NULL;
|
||||
DIR *dir;
|
||||
struct dirent *next;
|
||||
|
||||
matches = nmalloc(BUFSIZ);
|
||||
|
||||
/* Stick a wildcard onto the buf, for later use */
|
||||
strcat(buf, "*");
|
||||
|
||||
/* Okie, if there's a / in the buffer, strip out the directory part */
|
||||
if (strcmp(buf, "") && strstr(buf, "/")) {
|
||||
dirName = malloc(strlen(buf) + 1);
|
||||
tmp = buf + strlen(buf);
|
||||
while (*tmp != '/' && tmp != buf)
|
||||
tmp--;
|
||||
|
||||
tmp++;
|
||||
|
||||
strncpy(dirName, buf, tmp - buf + 1);
|
||||
dirName[tmp - buf] = 0;
|
||||
|
||||
} else {
|
||||
if ((dirName = getcwd(NULL, 0)) == NULL)
|
||||
return matches;
|
||||
else
|
||||
tmp = buf;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "\nDir = %s\n", dirName);
|
||||
fprintf(stderr, "\nbuf = %s\n", buf);
|
||||
fprintf(stderr, "\ntmp = %s\n", tmp);
|
||||
#endif
|
||||
|
||||
dirtmp = real_dir_from_tilde(dirName);
|
||||
free(dirName);
|
||||
dirName = dirtmp;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "\nDir = %s\n", dirName);
|
||||
fprintf(stderr, "\nbuf = %s\n", buf);
|
||||
fprintf(stderr, "\ntmp = %s\n", tmp);
|
||||
#endif
|
||||
|
||||
|
||||
dir = opendir(dirName);
|
||||
if (!dir) {
|
||||
/* Don't print an error, just shut up and return */
|
||||
*num_matches = 0;
|
||||
beep();
|
||||
return (matches);
|
||||
}
|
||||
while ((next = readdir(dir)) != NULL) {
|
||||
|
||||
/* Some quick sanity checks */
|
||||
if ((strcmp(next->d_name, "..") == 0)
|
||||
|| (strcmp(next->d_name, ".") == 0)) {
|
||||
continue;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Comparing \'%s\'\n", next->d_name);
|
||||
#endif
|
||||
/* See if this matches */
|
||||
if (check_wildcard_match(next->d_name, tmp) == TRUE) {
|
||||
|
||||
/* Cool, found a match. Add it to the list
|
||||
* This makes a lot more sense to me (Chris) this way...
|
||||
*/
|
||||
tmp2 = NULL;
|
||||
tmp2 = nmalloc(strlen(next->d_name) + 1);
|
||||
strcpy(tmp2, next->d_name);
|
||||
matches[*num_matches] = tmp2;
|
||||
++*num_matches;
|
||||
|
||||
/* If there's no more room, bail out */
|
||||
if (*num_matches == BUFSIZ)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (matches);
|
||||
}
|
||||
|
||||
/* This function now has an arg which refers to how much the
|
||||
* statusbar (place) should be advanced, i.e. the new cursor pos.
|
||||
*/
|
||||
char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
|
||||
{
|
||||
/* Do TAB completion */
|
||||
static int num_matches = 0, match_matches = 0;
|
||||
static char **matches = (char **) NULL;
|
||||
int pos = place, i = 0, col = 0, editline = 0;
|
||||
int longestname = 0, is_dir = 0;
|
||||
char *foo;
|
||||
|
||||
if (*lastWasTab == FALSE) {
|
||||
char *tmp, *copyto, *matchBuf;
|
||||
|
||||
*lastWasTab = 1;
|
||||
|
||||
/* Make a local copy of the string -- up to the position of the
|
||||
cursor */
|
||||
matchBuf = (char *) calloc(strlen(buf) + 2, sizeof(char));
|
||||
|
||||
strncpy(matchBuf, buf, place);
|
||||
tmp = matchBuf;
|
||||
|
||||
/* skip any leading white space */
|
||||
while (*tmp && isspace((int) *tmp))
|
||||
++tmp;
|
||||
|
||||
/* Free up any memory already allocated */
|
||||
if (matches != NULL) {
|
||||
for (i = i; i < num_matches; i++)
|
||||
free(matches[i]);
|
||||
free(matches);
|
||||
matches = (char **) NULL;
|
||||
num_matches = 0;
|
||||
}
|
||||
|
||||
/* If the word starts with `~' and there is no slash in the word,
|
||||
* then try completing this word as a username. */
|
||||
|
||||
/* FIXME -- this check is broken! */
|
||||
if (*tmp == '~' && !strchr(tmp, '/'))
|
||||
matches = username_tab_completion(tmp, &num_matches);
|
||||
|
||||
/* Try to match everything in the current working directory that
|
||||
* matches. */
|
||||
if (!matches)
|
||||
matches = cwd_tab_completion(tmp, &num_matches);
|
||||
|
||||
/* Don't leak memory */
|
||||
free(matchBuf);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "%d matches found...\n", num_matches);
|
||||
#endif
|
||||
/* Did we find exactly one match? */
|
||||
switch (num_matches) {
|
||||
case 0:
|
||||
blank_edit();
|
||||
wrefresh(edit);
|
||||
break;
|
||||
case 1:
|
||||
|
||||
buf = nrealloc(buf, strlen(buf) + strlen(matches[0]) + 1);
|
||||
|
||||
if (strcmp(buf, "") && strstr(buf, "/")) {
|
||||
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf;
|
||||
tmp--);
|
||||
tmp++;
|
||||
} else
|
||||
tmp = buf;
|
||||
|
||||
if (!strcmp(tmp, matches[0]))
|
||||
is_dir = append_slash_if_dir(buf, lastWasTab, newplace);
|
||||
|
||||
if (is_dir)
|
||||
break;
|
||||
|
||||
copyto = tmp;
|
||||
for (pos = 0; *tmp == matches[0][pos] &&
|
||||
pos <= strlen(matches[0]); pos++)
|
||||
tmp++;
|
||||
|
||||
/* write out the matched name */
|
||||
strncpy(copyto, matches[0], strlen(matches[0]) + 1);
|
||||
*newplace += strlen(matches[0]) - pos;
|
||||
|
||||
/* Is it a directory? */
|
||||
append_slash_if_dir(buf, lastWasTab, newplace);
|
||||
|
||||
break;
|
||||
default:
|
||||
/* Check to see if all matches share a beginning, and if so
|
||||
tack it onto buf and then beep */
|
||||
|
||||
if (strcmp(buf, "") && strstr(buf, "/")) {
|
||||
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf;
|
||||
tmp--);
|
||||
tmp++;
|
||||
} else
|
||||
tmp = buf;
|
||||
|
||||
for (pos = 0; *tmp == matches[0][pos] && *tmp != 0 &&
|
||||
pos <= strlen(matches[0]); pos++)
|
||||
tmp++;
|
||||
|
||||
while (1) {
|
||||
match_matches = 0;
|
||||
|
||||
for (i = 0; i < num_matches; i++) {
|
||||
if (matches[i][pos] == 0)
|
||||
break;
|
||||
else if (matches[i][pos] == matches[0][pos])
|
||||
match_matches++;
|
||||
}
|
||||
if (match_matches == num_matches &&
|
||||
(i == num_matches || matches[i] != 0)) {
|
||||
/* All the matches have the same character at pos+1,
|
||||
so paste it into buf... */
|
||||
buf = nrealloc(buf, strlen(buf) + 2);
|
||||
strncat(buf, matches[0] + pos, 1);
|
||||
*newplace += 1;
|
||||
pos++;
|
||||
} else {
|
||||
beep();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Ok -- the last char was a TAB. Since they
|
||||
* just hit TAB again, print a list of all the
|
||||
* available choices... */
|
||||
if (matches && num_matches > 0) {
|
||||
|
||||
/* Blank the edit window, and print the matches out there */
|
||||
blank_edit();
|
||||
wmove(edit, 0, 0);
|
||||
|
||||
editline = 0;
|
||||
|
||||
/* Figure out the length of the longest filename */
|
||||
for (i = 0; i < num_matches; i++)
|
||||
if (strlen(matches[i]) > longestname)
|
||||
longestname = strlen(matches[i]);
|
||||
|
||||
if (longestname > COLS - 1)
|
||||
longestname = COLS - 1;
|
||||
|
||||
foo = nmalloc(longestname + 5);
|
||||
|
||||
/* Print the list of matches */
|
||||
for (i = 0, col = 0; i < num_matches; i++) {
|
||||
|
||||
/* make each filename shown be the same length as the longest
|
||||
filename, with two spaces at the end */
|
||||
snprintf(foo, longestname + 1, matches[i]);
|
||||
while (strlen(foo) < longestname)
|
||||
strcat(foo, " ");
|
||||
|
||||
strcat(foo, " ");
|
||||
|
||||
/* Disable el cursor */
|
||||
curs_set(0);
|
||||
/* now, put the match on the screen */
|
||||
waddnstr(edit, foo, strlen(foo));
|
||||
col += strlen(foo);
|
||||
|
||||
/* And if the next match isn't going to fit on the
|
||||
line, move to the next one */
|
||||
if (col > (COLS - longestname) && matches[i + 1] != NULL) {
|
||||
editline++;
|
||||
wmove(edit, editline, 0);
|
||||
if (editline == editwinrows - 1) {
|
||||
waddstr(edit, _("(more)"));
|
||||
break;
|
||||
}
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
free(foo);
|
||||
wrefresh(edit);
|
||||
} else
|
||||
beep();
|
||||
|
||||
}
|
||||
|
||||
edit_refresh();
|
||||
curs_set(1);
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
129
global.c
129
global.c
@@ -1,3 +1,4 @@
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* global.c *
|
||||
* *
|
||||
@@ -38,7 +39,7 @@ int center_x = 0, center_y = 0; /* Center of screen */
|
||||
WINDOW *edit; /* The file portion of the editor */
|
||||
WINDOW *topwin; /* Top line of screen */
|
||||
WINDOW *bottomwin; /* Bottom buffer */
|
||||
char *filename; /* Name of the file */
|
||||
char filename[PATH_MAX]; /* Name of the file */
|
||||
int editwinrows = 0; /* How many rows long is the edit
|
||||
window? */
|
||||
filestruct *current; /* Current buffer pointer */
|
||||
@@ -53,13 +54,15 @@ filestruct *editbot = NULL; /* Same for the bottom */
|
||||
filestruct *filebot = NULL; /* Last node in the file struct */
|
||||
filestruct *cutbuffer = NULL; /* A place to store cut text */
|
||||
|
||||
char *answer; /* Answer str to many questions */
|
||||
char *answer = NULL; /* Answer str to many questions */
|
||||
int totlines = 0; /* Total number of lines in the file */
|
||||
int totsize = 0; /* Total number of bytes in the file */
|
||||
int placewewant = 0; /* The collum we'd like the cursor
|
||||
to jump to when we go to the
|
||||
next or previous line */
|
||||
|
||||
int tabsize = 8; /* Our internal tabsize variable */
|
||||
|
||||
char *hblank; /* A horizontal blank line */
|
||||
char *help_text; /* The text in the help window */
|
||||
|
||||
@@ -71,16 +74,20 @@ int mark_beginx; /* X value in the string to start */
|
||||
shortcut main_list[MAIN_LIST_LEN];
|
||||
shortcut whereis_list[WHEREIS_LIST_LEN];
|
||||
shortcut replace_list[REPLACE_LIST_LEN];
|
||||
shortcut replace_list_2[REPLACE_LIST_LEN]; /* 2nd half of replace dialog */
|
||||
shortcut goto_list[GOTO_LIST_LEN];
|
||||
shortcut writefile_list[WRITEFILE_LIST_LEN];
|
||||
shortcut help_list[HELP_LIST_LEN];
|
||||
shortcut spell_list[SPELL_LIST_LEN];
|
||||
toggle toggles[TOGGLE_LEN];
|
||||
|
||||
/* Regular expressions */
|
||||
|
||||
regex_t search_regexp; /* Global to store compiled search regexp */
|
||||
regmatch_t regmatches[10]; /* Match positions for parenthetical
|
||||
subexpressions, max of 10 */
|
||||
#ifdef HAVE_REGEX_H
|
||||
regex_t search_regexp; /* Global to store compiled search regexp */
|
||||
regmatch_t regmatches[10]; /* Match positions for parenthetical
|
||||
subexpressions, max of 10 */
|
||||
#endif
|
||||
|
||||
/* Initialize a struct *without* our lovely braces =( */
|
||||
void sc_init_one(shortcut * s, int key, char *desc, char *help, int alt,
|
||||
@@ -96,7 +103,60 @@ void sc_init_one(shortcut * s, int key, char *desc, char *help, int alt,
|
||||
s->func = func;
|
||||
}
|
||||
|
||||
void shortcut_init(void)
|
||||
/* Initialize the toggles in the same manner */
|
||||
void toggle_init_one(toggle * t, int val, char *desc, int flag)
|
||||
{
|
||||
t->val = val;
|
||||
t->desc = desc;
|
||||
t->flag = flag;
|
||||
}
|
||||
|
||||
void toggle_init(void)
|
||||
{
|
||||
#ifndef NANO_SMALL
|
||||
char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
|
||||
*toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg,
|
||||
*toggle_cuttoend_msg, *toggle_wrap_msg;
|
||||
#ifdef HAVE_REGEX_H
|
||||
char *toggle_regexp_msg;
|
||||
#endif
|
||||
|
||||
toggle_const_msg = _("Constant cursor position");
|
||||
toggle_autoindent_msg = _("Auto indent");
|
||||
toggle_suspend_msg = _("Suspend");
|
||||
toggle_nohelp_msg = _("Help mode");
|
||||
toggle_picomode_msg = _("Pico mode");
|
||||
toggle_mouse_msg = _("Mouse support");
|
||||
toggle_cuttoend_msg = _("Cut to end");
|
||||
#ifdef HAVE_REGEX_H
|
||||
toggle_regexp_msg = _("Regular expressions");
|
||||
#endif
|
||||
toggle_wrap_msg = _("Auto wrap");
|
||||
|
||||
toggle_init_one(&toggles[0], TOGGLE_CONST_KEY, toggle_const_msg,
|
||||
CONSTUPDATE);
|
||||
toggle_init_one(&toggles[1], TOGGLE_AUTOINDENT_KEY,
|
||||
toggle_autoindent_msg, AUTOINDENT);
|
||||
toggle_init_one(&toggles[2], TOGGLE_SUSPEND_KEY, toggle_suspend_msg,
|
||||
SUSPEND);
|
||||
toggle_init_one(&toggles[3], TOGGLE_NOHELP_KEY, toggle_nohelp_msg,
|
||||
NO_HELP);
|
||||
toggle_init_one(&toggles[4], TOGGLE_PICOMODE_KEY, toggle_picomode_msg,
|
||||
PICO_MODE);
|
||||
toggle_init_one(&toggles[5], TOGGLE_WRAP_KEY, toggle_wrap_msg,
|
||||
NO_WRAP);
|
||||
toggle_init_one(&toggles[6], TOGGLE_MOUSE_KEY, toggle_mouse_msg,
|
||||
USE_MOUSE);
|
||||
toggle_init_one(&toggles[7], TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg,
|
||||
CUT_TO_END);
|
||||
#ifdef HAVE_REGEX_H
|
||||
toggle_init_one(&toggles[8], TOGGLE_REGEXP_KEY, toggle_regexp_msg,
|
||||
USE_REGEXP);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void shortcut_init(int unjustify)
|
||||
{
|
||||
char *nano_help_msg = "", *nano_writeout_msg = "", *nano_exit_msg = "",
|
||||
*nano_goto_msg = "", *nano_justify_msg = "", *nano_replace_msg =
|
||||
@@ -110,7 +170,7 @@ void shortcut_init(void)
|
||||
"", *nano_mark_msg = "", *nano_delete_msg =
|
||||
"", *nano_backspace_msg = "", *nano_tab_msg =
|
||||
"", *nano_enter_msg = "", *nano_case_msg =
|
||||
"", *nano_cancel_msg = "";
|
||||
"", *nano_cancel_msg = "", *nano_unjustify_msg;
|
||||
|
||||
#ifndef NANO_SMALL
|
||||
nano_help_msg = _("Invoke the help menu");
|
||||
@@ -118,6 +178,7 @@ void shortcut_init(void)
|
||||
nano_exit_msg = _("Exit from nano");
|
||||
nano_goto_msg = _("Goto a specific line number");
|
||||
nano_justify_msg = _("Justify the current paragraph");
|
||||
nano_unjustify_msg = _("Unjustify after a justify");
|
||||
nano_replace_msg = _("Replace text within the editor");
|
||||
nano_insert_msg = _("Insert another file into the current one");
|
||||
nano_whereis_msg = _("Search for text within the editor");
|
||||
@@ -147,10 +208,9 @@ void shortcut_init(void)
|
||||
nano_cancel_msg = _("Cancel the current function");
|
||||
#endif
|
||||
|
||||
|
||||
if (ISSET(PICO_MSGS))
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[0], NANO_HELP_KEY, _("Get Help"),
|
||||
nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help);
|
||||
else
|
||||
sc_init_one(&main_list[0], NANO_WRITEOUT_KEY, _("WriteOut"),
|
||||
nano_writeout_msg,
|
||||
@@ -159,7 +219,7 @@ void shortcut_init(void)
|
||||
sc_init_one(&main_list[1], NANO_EXIT_KEY, _("Exit"),
|
||||
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
|
||||
|
||||
if (ISSET(PICO_MSGS))
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[2], NANO_WRITEOUT_KEY, _("WriteOut"),
|
||||
nano_writeout_msg,
|
||||
0, NANO_WRITEOUT_FKEY, 0, NOVIEW, do_writeout_void);
|
||||
@@ -168,9 +228,10 @@ void shortcut_init(void)
|
||||
nano_goto_msg,
|
||||
NANO_ALT_G, NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void);
|
||||
|
||||
if (ISSET(PICO_MSGS))
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[3], NANO_JUSTIFY_KEY, _("Justify"),
|
||||
nano_justify_msg, 0, 0, 0, NOVIEW, do_justify);
|
||||
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
|
||||
NOVIEW, do_justify);
|
||||
else
|
||||
sc_init_one(&main_list[3], NANO_REPLACE_KEY, _("Replace"),
|
||||
nano_replace_msg,
|
||||
@@ -195,7 +256,11 @@ void shortcut_init(void)
|
||||
sc_init_one(&main_list[8], NANO_CUT_KEY, _("Cut Text"),
|
||||
nano_cut_msg, 0, NANO_CUT_FKEY, 0, NOVIEW, do_cut_text);
|
||||
|
||||
sc_init_one(&main_list[9], NANO_UNCUT_KEY, _("UnCut Txt"),
|
||||
if (unjustify)
|
||||
sc_init_one(&main_list[9], NANO_UNJUSTIFY_KEY, _("UnJustify"),
|
||||
nano_unjustify_msg, 0, 0, 0, NOVIEW, do_uncut_text);
|
||||
else
|
||||
sc_init_one(&main_list[9], NANO_UNCUT_KEY, _("UnCut Txt"),
|
||||
nano_uncut_msg,
|
||||
0, NANO_UNCUT_FKEY, 0, NOVIEW, do_uncut_text);
|
||||
|
||||
@@ -242,25 +307,26 @@ void shortcut_init(void)
|
||||
sc_init_one(&main_list[22], NANO_TAB_KEY, _("Tab"),
|
||||
nano_tab_msg, 0, 0, 0, NOVIEW, do_tab);
|
||||
|
||||
if (ISSET(PICO_MSGS))
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[23], NANO_REPLACE_KEY, _("Replace"),
|
||||
nano_replace_msg,
|
||||
NANO_ALT_R, NANO_REPLACE_FKEY, 0, NOVIEW, do_replace);
|
||||
else
|
||||
sc_init_one(&main_list[23], NANO_JUSTIFY_KEY, _("Justify"),
|
||||
nano_justify_msg, 0, 0, 0, NOVIEW, do_justify);
|
||||
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
|
||||
NOVIEW, do_justify);
|
||||
|
||||
sc_init_one(&main_list[24], NANO_ENTER_KEY, _("Enter"),
|
||||
nano_enter_msg,
|
||||
0, KEY_ENTER, NANO_CONTROL_M, NOVIEW, do_enter_void);
|
||||
|
||||
if (ISSET(PICO_MSGS))
|
||||
if (ISSET(PICO_MODE))
|
||||
sc_init_one(&main_list[25], NANO_GOTO_KEY, _("Goto Line"),
|
||||
nano_goto_msg,
|
||||
NANO_ALT_G, NANO_GOTO_FKEY, 0, VIEW, do_gotoline_void);
|
||||
else
|
||||
sc_init_one(&main_list[25], NANO_HELP_KEY, _("Get Help"),
|
||||
nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help);
|
||||
|
||||
|
||||
sc_init_one(&whereis_list[0], NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
@@ -276,8 +342,9 @@ void shortcut_init(void)
|
||||
sc_init_one(&whereis_list[3], NANO_OTHERSEARCH_KEY, _("Replace"),
|
||||
nano_replace_msg, 0, 0, 0, VIEW, do_replace);
|
||||
|
||||
sc_init_one(&whereis_list[4], NANO_FROMSEARCHTOGOTO_KEY, _("Goto Line"),
|
||||
nano_goto_msg, 0, 0, 0, VIEW, do_gotoline_void);
|
||||
sc_init_one(&whereis_list[4], NANO_FROMSEARCHTOGOTO_KEY,
|
||||
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
|
||||
do_gotoline_void);
|
||||
|
||||
sc_init_one(&whereis_list[5], NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
@@ -295,13 +362,25 @@ void shortcut_init(void)
|
||||
sc_init_one(&replace_list[3], NANO_OTHERSEARCH_KEY, _("No Replace"),
|
||||
nano_whereis_msg, 0, 0, 0, VIEW, do_search);
|
||||
|
||||
sc_init_one(&replace_list[4], NANO_FROMSEARCHTOGOTO_KEY, _("Goto Line"),
|
||||
nano_goto_msg, 0, 0, 0, VIEW, do_gotoline_void);
|
||||
sc_init_one(&replace_list[4], NANO_FROMSEARCHTOGOTO_KEY,
|
||||
_("Goto Line"), nano_goto_msg, 0, 0, 0, VIEW,
|
||||
do_gotoline_void);
|
||||
|
||||
sc_init_one(&replace_list[5], NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
|
||||
|
||||
sc_init_one(&replace_list_2[0], NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
nano_firstline_msg, 0, 0, 0, VIEW, do_first_line);
|
||||
|
||||
sc_init_one(&replace_list_2[1], NANO_LASTLINE_KEY, _("Last Line"),
|
||||
nano_lastline_msg, 0, 0, 0, VIEW, do_last_line);
|
||||
|
||||
sc_init_one(&replace_list_2[2], NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
|
||||
sc_init_one(&goto_list[0], NANO_FIRSTLINE_KEY, _("First Line"),
|
||||
nano_firstline_msg, 0, 0, 0, VIEW, &do_first_line);
|
||||
|
||||
@@ -331,10 +410,8 @@ void shortcut_init(void)
|
||||
sc_init_one(&writefile_list[0], NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
sc_init_one(&spell_list[0], NANO_HELP_KEY, _("Get Help"),
|
||||
nano_help_msg, 0, 0, 0, VIEW, do_help);
|
||||
|
||||
sc_init_one(&spell_list[1], NANO_CANCEL_KEY, _("Cancel"),
|
||||
sc_init_one(&spell_list[0], NANO_CANCEL_KEY, _("Cancel"),
|
||||
nano_cancel_msg, 0, 0, 0, VIEW, 0);
|
||||
|
||||
toggle_init();
|
||||
}
|
||||
|
||||
3
intl/.cvsignore
Normal file
3
intl/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
Makefile
|
||||
libintl.h
|
||||
po2tbl.sed
|
||||
31
move.c
31
move.c
@@ -1,3 +1,4 @@
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* move.c *
|
||||
* *
|
||||
@@ -35,12 +36,12 @@
|
||||
void page_down_center(void)
|
||||
{
|
||||
if (editbot != filebot) {
|
||||
edit_update(editbot->next);
|
||||
edit_update(editbot->next, CENTER);
|
||||
center_cursor();
|
||||
} else {
|
||||
while (current != filebot)
|
||||
current = current->next;
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
}
|
||||
update_cursor();
|
||||
}
|
||||
@@ -54,15 +55,22 @@ int page_down(void)
|
||||
if (current == filebot)
|
||||
return 0;
|
||||
|
||||
if (editbot != filebot) {
|
||||
if (editbot != filebot || edittop == fileage) {
|
||||
current_y = 0;
|
||||
current = editbot;
|
||||
edit_update_top(current);
|
||||
} else
|
||||
|
||||
if (current->prev != NULL)
|
||||
current = current->prev;
|
||||
if (current->prev != NULL)
|
||||
current = current->prev;
|
||||
edit_update(current, TOP);
|
||||
} else {
|
||||
while (current != filebot) {
|
||||
current = current->next;
|
||||
current_y++;
|
||||
}
|
||||
edit_update(edittop, TOP);
|
||||
}
|
||||
|
||||
update_cursor();
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
@@ -121,7 +129,7 @@ int do_down(void)
|
||||
void page_up_center(void)
|
||||
{
|
||||
if (edittop != fileage) {
|
||||
edit_update(edittop);
|
||||
edit_update(edittop, CENTER);
|
||||
center_cursor();
|
||||
} else
|
||||
current_y = 0;
|
||||
@@ -132,6 +140,7 @@ void page_up_center(void)
|
||||
|
||||
int page_up(void)
|
||||
{
|
||||
filestruct *fileptr = edittop;
|
||||
wrap_reset();
|
||||
current_x = 0;
|
||||
placewewant = 0;
|
||||
@@ -140,7 +149,13 @@ int page_up(void)
|
||||
return 0;
|
||||
|
||||
current_y = 0;
|
||||
edit_update_bot(edittop);
|
||||
if (fileptr->next != NULL)
|
||||
fileptr = fileptr->next;
|
||||
if (fileptr->next != NULL)
|
||||
fileptr = fileptr->next;
|
||||
|
||||
current = edittop;
|
||||
edit_update(fileptr, BOTTOM);
|
||||
update_cursor();
|
||||
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
@@ -153,8 +168,6 @@ int do_up(void)
|
||||
{
|
||||
wrap_reset();
|
||||
if (current->prev != NULL) {
|
||||
update_line(current, 0);
|
||||
|
||||
if (placewewant > 0)
|
||||
current_x = actual_x(current->prev, placewewant);
|
||||
|
||||
|
||||
60
nano.1
60
nano.1
@@ -1,20 +1,16 @@
|
||||
.\" Hey, EMACS: -*- nroff -*-
|
||||
.\" Hey, EMACS: -*- nroff -*-
|
||||
.\" nano.1 is copyright 1999-2000 by
|
||||
.\" Chris Allegretta <chrisa@asty.org>
|
||||
.\"
|
||||
.\" This is free documentation, see the latest version of the GNU General
|
||||
.\" Public License for copying conditions. There is NO warranty.
|
||||
.\"
|
||||
.\" First parameter, NAME, should be all caps
|
||||
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||
.\" other parameters are allowed: see man(7), man(1)
|
||||
.TH NANO 1 "January 4, 2000"
|
||||
.TH NANO 1 "December 2, 2000"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.\" Some roff macros, for reference:
|
||||
.\" .nh disable hyphenation
|
||||
.\" .hy enable hyphenation
|
||||
.\" .ad l left justify
|
||||
.\" .ad b justify to both left and right margins
|
||||
.\" .nf disable filling
|
||||
.\" .fi enable filling
|
||||
.\" .br insert line break
|
||||
.\" .sp <n> insert n+1 empty lines
|
||||
.\" for manpage-specific macros, see man(7)
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, an enhanced free Pico Clone
|
||||
.SH SYNOPSIS
|
||||
@@ -29,18 +25,16 @@ command.
|
||||
.\" TeX users may be more comfortable with the \fB<whatever>\fP and
|
||||
.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
|
||||
.\" respectively.
|
||||
\fBnano\fP was originally known as TIP (TIP Isn't Pico). It is a small,
|
||||
free and friendly editor which aims to replace Pico, the default editor
|
||||
included in the non-free Pine package. Rather than just copying Pico's
|
||||
look and feel,
|
||||
\fBnano\fP is a small, free and friendly editor which aims to replace
|
||||
Pico, the default editor included in the non-free Pine package. Rather
|
||||
than just copying Pico's look and feel,
|
||||
.B nano
|
||||
also implements some missing (or disabled by
|
||||
default) features in Pico, such as "search and replace" and "goto line
|
||||
number".
|
||||
also implements some missing (or disabled by default) features in Pico,
|
||||
such as "search and replace" and "goto line number".
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B \-T (\-\-tabsize)
|
||||
Set the size (width) of a tab, if supported by your curses library.
|
||||
Set the size (width) of a tab.
|
||||
.TP
|
||||
.B \-R (\-\-regexp)
|
||||
Enable regular expression matching for search strings, as well as
|
||||
@@ -55,6 +49,9 @@ Display a summary of commandline options.
|
||||
.B \-c (\-\-const)
|
||||
Constantly show the cursor position.
|
||||
.TP
|
||||
.B \-k (\-\-cut)
|
||||
Enable cut from cursor to end of line with ^K.
|
||||
.TP
|
||||
.B \-i (\-\-autoindent)
|
||||
Indent new lines to the previous line's indentation. Useful when editing
|
||||
source code.
|
||||
@@ -67,7 +64,7 @@ a new file, do not follow it. Good for editing files in /tmp perhaps?
|
||||
Enable mouse support (if available for your system).
|
||||
.TP
|
||||
.B \-p (\-\-pico)
|
||||
Display the same shortcut lists as Pico does.
|
||||
Emulate Pico as closely as possible.
|
||||
.TP
|
||||
.B \-s (\-\-speller)
|
||||
Enable alternative spell checker command.
|
||||
@@ -89,16 +86,27 @@ Enable suspend ability.
|
||||
.TP
|
||||
.B \+LINE
|
||||
Places cursor at LINE on startup.
|
||||
.SH NOTES
|
||||
Nano will try to dump the buffer into an emergency file in some cases.
|
||||
Mainly, this will happen if Nano recieves a SIGHUP or runs out of
|
||||
memory, when it will write the buffer into a file named "nano.save" if the
|
||||
buffer didn't have a name already, or will add a ".save" suffix to the
|
||||
current finename. Nano will \fBnot\fP write this file if a previous one
|
||||
exists in the current directory.
|
||||
.SH BUGS
|
||||
Please send any comments or bug reports to
|
||||
.B nano@asty.org.
|
||||
.br
|
||||
.B nano@nano-editor.org.
|
||||
.br
|
||||
The nano mailing list is available from
|
||||
.br
|
||||
.B nano-devel@lists.sourceforge.net.
|
||||
To subscribe, email to nano-devel-request@lists.sourceforge.net with a
|
||||
subject of "subscribe".
|
||||
.SH HOMEPAGE
|
||||
http://www.asty.org/nano
|
||||
http://www.nano-editor.org
|
||||
.SH AUTHOR
|
||||
Chris Allegretta <chrisa@asty.org>, et al. This manual page was
|
||||
originally written by Jordi Mallach <jordi@sindominio.net>, for the Debian
|
||||
GNU/Linux system (but may be used by others).
|
||||
Chris Allegretta <chrisa@asty.org>, et al (see AUTHORS for details).
|
||||
This manual page was originally written by Jordi Mallach
|
||||
<jordi@sindominio.net>, for the Debian GNU/Linux system (but may be
|
||||
used by others).
|
||||
|
||||
71
nano.1.html
71
nano.1.html
@@ -3,21 +3,11 @@ Content-type: text/html
|
||||
<HTML><HEAD><TITLE>Manpage of NANO</TITLE>
|
||||
</HEAD><BODY>
|
||||
<H1>NANO</H1>
|
||||
Section: User Commands (1)<BR>Updated: January 4, 2000<BR><A HREF="#index">Index</A>
|
||||
Section: User Commands (1)<BR>Updated: December 2, 2000<BR><A HREF="#index">Index</A>
|
||||
<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<A NAME="lbAB"> </A>
|
||||
<H2>NAME</H2>
|
||||
|
||||
@@ -43,15 +33,13 @@ command.
|
||||
|
||||
|
||||
|
||||
<B>nano</B> was originally known as TIP (TIP Isn't Pico). It is a small,
|
||||
free and friendly editor which aims to replace Pico, the default editor
|
||||
included in the non-free Pine package. Rather than just copying Pico's
|
||||
look and feel,
|
||||
<B>nano</B> is a small, free and friendly editor which aims to replace
|
||||
Pico, the default editor included in the non-free Pine package. Rather
|
||||
than just copying Pico's look and feel,
|
||||
<B>nano</B>
|
||||
|
||||
also implements some missing (or disabled by
|
||||
default) features in Pico, such as "search and replace" and "goto line
|
||||
number".
|
||||
also implements some missing (or disabled by default) features in Pico,
|
||||
such as "search and replace" and "goto line number".
|
||||
<A NAME="lbAE"> </A>
|
||||
<H2>OPTIONS</H2>
|
||||
|
||||
@@ -59,7 +47,7 @@ number".
|
||||
<DT><B>-T (--tabsize)</B>
|
||||
|
||||
<DD>
|
||||
Set the size (width) of a tab, if supported by your curses library.
|
||||
Set the size (width) of a tab.
|
||||
<DT><B>-R (--regexp)</B>
|
||||
|
||||
<DD>
|
||||
@@ -77,6 +65,10 @@ Display a summary of commandline options.
|
||||
|
||||
<DD>
|
||||
Constantly show the cursor position.
|
||||
<DT><B>-k (--cut)</B>
|
||||
|
||||
<DD>
|
||||
Enable cut from cursor to end of line with ^K.
|
||||
<DT><B>-i (--autoindent)</B>
|
||||
|
||||
<DD>
|
||||
@@ -94,7 +86,7 @@ Enable mouse support (if available for your system).
|
||||
<DT><B>-p (--pico)</B>
|
||||
|
||||
<DD>
|
||||
Display the same shortcut lists as Pico does.
|
||||
Emulate Pico as closely as possible.
|
||||
<DT><B>-s (--speller)</B>
|
||||
|
||||
<DD>
|
||||
@@ -125,26 +117,42 @@ Enable suspend ability.
|
||||
Places cursor at LINE on startup.
|
||||
</DL>
|
||||
<A NAME="lbAF"> </A>
|
||||
<H2>NOTES</H2>
|
||||
|
||||
Nano will try to dump the buffer into an emergency file in some cases.
|
||||
Mainly, this will happen if Nano recieves a SIGHUP or runs out of
|
||||
memory, when it will write the buffer into a file named "nano.save" if the
|
||||
buffer didn't have a name already, or will add a ".save" suffix to the
|
||||
current finename. Nano will <B>not</B> write this file if a previous one
|
||||
exists in the current directory.
|
||||
<A NAME="lbAG"> </A>
|
||||
<H2>BUGS</H2>
|
||||
|
||||
Please send any comments or bug reports to
|
||||
<B><A HREF="mailto:nano@asty.org">nano@asty.org</A>.</B>
|
||||
<BR>
|
||||
|
||||
<B><A HREF="mailto:nano@nano-editor.org">nano@nano-editor.org</A>.</B>
|
||||
|
||||
<BR>
|
||||
|
||||
The nano mailing list is available from
|
||||
<BR>
|
||||
|
||||
<B><A HREF="mailto:nano-devel@lists.sourceforge.net">nano-devel@lists.sourceforge.net</A>.</B>
|
||||
|
||||
To subscribe, email to <A HREF="mailto:nano-devel-request@lists.sourceforge.net">nano-devel-request@lists.sourceforge.net</A> with a
|
||||
subject of "subscribe".
|
||||
<A NAME="lbAG"> </A>
|
||||
<A NAME="lbAH"> </A>
|
||||
<H2>HOMEPAGE</H2>
|
||||
|
||||
<A HREF="http://www.asty.org/nano">http://www.asty.org/nano</A>
|
||||
<A NAME="lbAH"> </A>
|
||||
<A HREF="http://www.nano-editor.org">http://www.nano-editor.org</A>
|
||||
<A NAME="lbAI"> </A>
|
||||
<H2>AUTHOR</H2>
|
||||
|
||||
Chris Allegretta <<A HREF="mailto:chrisa@asty.org">chrisa@asty.org</A>>, et al. This manual page was
|
||||
originally written by Jordi Mallach <<A HREF="mailto:jordi@sindominio.net">jordi@sindominio.net</A>>, for the Debian
|
||||
GNU/Linux system (but may be used by others).
|
||||
Chris Allegretta <<A HREF="mailto:chrisa@asty.org">chrisa@asty.org</A>>, et al (see AUTHORS for details).
|
||||
This manual page was originally written by Jordi Mallach
|
||||
<<A HREF="mailto:jordi@sindominio.net">jordi@sindominio.net</A>>, for the Debian GNU/Linux system (but may be
|
||||
used by others).
|
||||
<P>
|
||||
|
||||
<HR>
|
||||
@@ -154,14 +162,15 @@ GNU/Linux system (but may be used by others).
|
||||
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
|
||||
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
|
||||
<DT><A HREF="#lbAE">OPTIONS</A><DD>
|
||||
<DT><A HREF="#lbAF">BUGS</A><DD>
|
||||
<DT><A HREF="#lbAG">HOMEPAGE</A><DD>
|
||||
<DT><A HREF="#lbAH">AUTHOR</A><DD>
|
||||
<DT><A HREF="#lbAF">NOTES</A><DD>
|
||||
<DT><A HREF="#lbAG">BUGS</A><DD>
|
||||
<DT><A HREF="#lbAH">HOMEPAGE</A><DD>
|
||||
<DT><A HREF="#lbAI">AUTHOR</A><DD>
|
||||
</DL>
|
||||
<HR>
|
||||
This document was created by
|
||||
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
|
||||
using the manual pages.<BR>
|
||||
Time: 04:20:00 GMT, July 07, 2000
|
||||
Time: 04:21:24 GMT, December 03, 2000
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
||||
40
nano.h
40
nano.h
@@ -1,3 +1,4 @@
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* nano.h *
|
||||
* *
|
||||
@@ -44,11 +45,6 @@
|
||||
#include <curses.h>
|
||||
#endif /* CURSES_H */
|
||||
|
||||
#ifndef HAVE_TABSIZE
|
||||
static int TABSIZE = 8;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_LIBINTL_H
|
||||
#include <libintl.h>
|
||||
#endif
|
||||
@@ -86,6 +82,14 @@ typedef struct shortcut {
|
||||
char *help; /* Help file entry text */
|
||||
} shortcut;
|
||||
|
||||
typedef struct toggle {
|
||||
int val; /* Sequence to toggle the key. Should only need 1 */
|
||||
char *desc; /* Description for when toggle is, uh, toggled,
|
||||
e.g. "Pico Messages", we'll append Enabled or
|
||||
Disabled */
|
||||
int flag; /* What flag actually gets toggled */
|
||||
} toggle;
|
||||
|
||||
/* Bitwise flags so we can save space (or more correctly, not waste it) */
|
||||
|
||||
#define MODIFIED (1<<0)
|
||||
@@ -94,7 +98,7 @@ typedef struct shortcut {
|
||||
#define MARK_ISSET (1<<3)
|
||||
#define CONSTUPDATE (1<<4)
|
||||
#define NO_HELP (1<<5)
|
||||
#define PICO_MSGS (1<<6)
|
||||
#define PICO_MODE (1<<6)
|
||||
#define FOLLOW_SYMLINKS (1<<7)
|
||||
#define SUSPEND (1<<8)
|
||||
#define NO_WRAP (1<<9)
|
||||
@@ -106,6 +110,7 @@ typedef struct shortcut {
|
||||
#define REGEXP_COMPILED (1<<15)
|
||||
#define TEMP_OPT (1<<16)
|
||||
#define CUT_TO_END (1<<17)
|
||||
#define DISABLE_CURPOS (1<<18)
|
||||
|
||||
/* Control key sequences, chaning these would be very very bad */
|
||||
|
||||
@@ -207,6 +212,7 @@ know what you're doing */
|
||||
#define NANO_REFRESH_KEY NANO_CONTROL_L
|
||||
#define NANO_JUSTIFY_KEY NANO_CONTROL_J
|
||||
#define NANO_JUSTIFY_FKEY KEY_F(4)
|
||||
#define NANO_UNJUSTIFY_KEY NANO_CONTROL_U
|
||||
#define NANO_UP_KEY NANO_CONTROL_P
|
||||
#define NANO_DOWN_KEY NANO_CONTROL_N
|
||||
#define NANO_FORWARD_KEY NANO_CONTROL_F
|
||||
@@ -221,16 +227,36 @@ know what you're doing */
|
||||
#define NANO_ENTER_KEY NANO_CONTROL_M
|
||||
#define NANO_FROMSEARCHTOGOTO_KEY NANO_CONTROL_T
|
||||
|
||||
#define TOGGLE_CONST_KEY NANO_ALT_C
|
||||
#define TOGGLE_AUTOINDENT_KEY NANO_ALT_I
|
||||
#define TOGGLE_SUSPEND_KEY NANO_ALT_Z
|
||||
#define TOGGLE_NOHELP_KEY NANO_ALT_X
|
||||
#define TOGGLE_PICOMODE_KEY NANO_ALT_P
|
||||
#define TOGGLE_MOUSE_KEY NANO_ALT_M
|
||||
#define TOGGLE_CUTTOEND_KEY NANO_ALT_K
|
||||
#define TOGGLE_REGEXP_KEY NANO_ALT_E
|
||||
#define TOGGLE_WRAP_KEY NANO_ALT_W
|
||||
|
||||
#define MAIN_LIST_LEN 26
|
||||
#define MAIN_VISIBLE 12
|
||||
#define WHEREIS_LIST_LEN 6
|
||||
#define REPLACE_LIST_LEN 6
|
||||
#define REPLACE_LIST_2_LEN 3
|
||||
#define GOTO_LIST_LEN 3
|
||||
#define WRITEFILE_LIST_LEN 1
|
||||
#define HELP_LIST_LEN 3
|
||||
#define SPELL_LIST_LEN 3
|
||||
#define SPELL_LIST_LEN 1
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
#define TOGGLE_LEN 9
|
||||
#else
|
||||
#define TOGGLE_LEN 8
|
||||
#endif
|
||||
|
||||
#define VIEW 1
|
||||
#define NOVIEW 0
|
||||
|
||||
#define TOP 2
|
||||
#define CENTER 1
|
||||
#define BOTTOM 0
|
||||
#endif
|
||||
|
||||
7
po/.cvsignore
Normal file
7
po/.cvsignore
Normal file
@@ -0,0 +1,7 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
POTFILES
|
||||
*.gmo
|
||||
*.pot
|
||||
cat-id*
|
||||
stamp-cat*
|
||||
@@ -0,0 +1 @@
|
||||
$Id$
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# Makefile for program source directory in GNU NLS utilities package.
|
||||
# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
|
||||
#
|
||||
@@ -111,9 +112,9 @@ install-data: install-data-@USE_NLS@
|
||||
install-data-no: all
|
||||
install-data-yes: all
|
||||
if test -r "$(MKINSTALLDIRS)"; then \
|
||||
$(MKINSTALLDIRS) $(datadir); \
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
|
||||
else \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(datadir); \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
|
||||
fi
|
||||
@catalogs='$(CATALOGS)'; \
|
||||
for cat in $$catalogs; do \
|
||||
@@ -125,27 +126,30 @@ install-data-yes: all
|
||||
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
|
||||
dir=$$destdir/$$lang/LC_MESSAGES; \
|
||||
if test -r "$(MKINSTALLDIRS)"; then \
|
||||
$(MKINSTALLDIRS) $$dir; \
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$$dir; \
|
||||
else \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$$dir; \
|
||||
fi; \
|
||||
if test -r $$cat; then \
|
||||
$(INSTALL_DATA) $$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
|
||||
echo "installing $$cat as $$dir/$(PACKAGE)$(INSTOBJEXT)"; \
|
||||
$(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE)$(INSTOBJEXT); \
|
||||
echo "installing $$cat as" \
|
||||
"$(DESTDIR)$$dir/$(PACKAGE)$(INSTOBJEXT)"; \
|
||||
else \
|
||||
$(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(PACKAGE)$(INSTOBJEXT); \
|
||||
$(INSTALL_DATA) $(srcdir)/$$cat \
|
||||
$(DESTDIR)$$dir/$(PACKAGE)$(INSTOBJEXT); \
|
||||
echo "installing $(srcdir)/$$cat as" \
|
||||
"$$dir/$(PACKAGE)$(INSTOBJEXT)"; \
|
||||
"$(DESTDIR)$$dir/$(PACKAGE)$(INSTOBJEXT)"; \
|
||||
fi; \
|
||||
if test -r $$cat.m; then \
|
||||
$(INSTALL_DATA) $$cat.m $$dir/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
echo "installing $$cat.m as $$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
|
||||
$(INSTALL_DATA) $$cat.m $(DESTDIR)$$dir/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
echo "installing $$cat.m as" \
|
||||
"$(DESTDIR)$$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
|
||||
else \
|
||||
if test -r $(srcdir)/$$cat.m ; then \
|
||||
$(INSTALL_DATA) $(srcdir)/$$cat.m \
|
||||
$$dir/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
$(DESTDIR)$$dir/$(PACKAGE)$(INSTOBJEXT).m; \
|
||||
echo "installing $(srcdir)/$$cat as" \
|
||||
"$$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
|
||||
"$(DESTDIR)$$dir/$(PACKAGE)$(INSTOBJEXT).m"; \
|
||||
else \
|
||||
true; \
|
||||
fi; \
|
||||
@@ -153,12 +157,12 @@ install-data-yes: all
|
||||
done
|
||||
if test "$(PACKAGE)" = "gettext"; then \
|
||||
if test -r "$(MKINSTALLDIRS)"; then \
|
||||
$(MKINSTALLDIRS) $(gettextsrcdir); \
|
||||
$(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
|
||||
else \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(gettextsrcdir); \
|
||||
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
|
||||
fi; \
|
||||
$(INSTALL_DATA) $(srcdir)/Makefile.in.in \
|
||||
$(gettextsrcdir)/Makefile.in.in; \
|
||||
$(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
|
||||
else \
|
||||
: ; \
|
||||
fi
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# $Id$
|
||||
# List of source files containing translatable strings.
|
||||
|
||||
# Package source files
|
||||
|
||||
218
po/cat-id-tbl.c
218
po/cat-id-tbl.c
@@ -1,218 +0,0 @@
|
||||
/* Automatically generated by po2tbl.sed from nano.pot. */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "libgettext.h"
|
||||
|
||||
const struct _msg_ent _msg_tbl[] = {
|
||||
{"", 1},
|
||||
{"add_to_cutbuffer called with inptr->data = %s\n", 2},
|
||||
{"Blew away cutbuffer =)\n", 3},
|
||||
{"read_line: not on first line and prev is NULL", 4},
|
||||
{"Read %d lines", 5},
|
||||
{"\"%s\" not found", 6},
|
||||
{"New File", 7},
|
||||
{"File \"%s\" is a directory", 8},
|
||||
{"Reading File", 9},
|
||||
{"File to insert [from ./] ", 10},
|
||||
{"Cancelled", 11},
|
||||
{"Could not open file for writing: %s", 12},
|
||||
{"Could not open file: Path length exceeded.", 13},
|
||||
{"Wrote >%s\n", 14},
|
||||
{"Could not close %s: %s", 15},
|
||||
{"Could not open %s for writing: %s", 16},
|
||||
{"Could not set permissions %o on %s: %s", 17},
|
||||
{"Wrote %d lines", 18},
|
||||
{"File Name to write", 19},
|
||||
{"filename is %s", 20},
|
||||
{"File exists, OVERWRITE ?", 21},
|
||||
{"Invoke the help menu", 22},
|
||||
{"Write the current file to disk", 23},
|
||||
{"Exit from nano", 24},
|
||||
{"Goto a specific line number", 25},
|
||||
{"Justify the current paragraph", 26},
|
||||
{"Replace text within the editor", 27},
|
||||
{"Insert another file into the current one", 28},
|
||||
{"Search for text within the editor", 29},
|
||||
{"Move to the previous screen", 30},
|
||||
{"Move to the next screen", 31},
|
||||
{"Cut the current line and store it in the cutbuffer", 32},
|
||||
{"Uncut from the cutbuffer into the current line", 33},
|
||||
{"Show the posititon of the cursor", 34},
|
||||
{"Invoke the spell checker (if available)", 35},
|
||||
{"Move up one line", 36},
|
||||
{"Move down one line", 37},
|
||||
{"Move forward one character", 38},
|
||||
{"Move back one character", 39},
|
||||
{"Move to the beginning of the current line", 40},
|
||||
{"Move to the end of the current line", 41},
|
||||
{"Go to the first line of the file", 42},
|
||||
{"Go to the last line of the file", 43},
|
||||
{"Refresh (redraw) the current screen", 44},
|
||||
{"Mark text at the current cursor location", 45},
|
||||
{"Delete the character under the cursor", 46},
|
||||
{"Delete the character to the left of the cursor", 47},
|
||||
{"Insert a tab character", 48},
|
||||
{"Insert a carriage return at the cursor position", 49},
|
||||
{"Make the current search or replace case (in)sensitive", 50},
|
||||
{"Cancel the current function", 51},
|
||||
{"Get Help", 52},
|
||||
{"WriteOut", 53},
|
||||
{"Exit", 54},
|
||||
{"Goto Line", 55},
|
||||
{"Justify", 56},
|
||||
{"Replace", 57},
|
||||
{"Read File", 58},
|
||||
{"Where Is", 59},
|
||||
{"Prev Page", 60},
|
||||
{"Next Page", 61},
|
||||
{"Cut Text", 62},
|
||||
{"UnCut Txt", 63},
|
||||
{"Cur Pos", 64},
|
||||
{"To Spell", 65},
|
||||
{"Up", 66},
|
||||
{"Down", 67},
|
||||
{"Forward", 68},
|
||||
{"Back", 69},
|
||||
{"Home", 70},
|
||||
{"End", 71},
|
||||
{"Refresh", 72},
|
||||
{"Mark Text", 73},
|
||||
{"Delete", 74},
|
||||
{"Backspace", 75},
|
||||
{"Tab", 76},
|
||||
{"Enter", 77},
|
||||
{"First Line", 78},
|
||||
{"Last Line", 79},
|
||||
{"Case Sens", 80},
|
||||
{"Cancel", 81},
|
||||
{"No Replace", 82},
|
||||
{"\
|
||||
\n\
|
||||
Buffer written to 'nano.save'\n", 83},
|
||||
{"Key illegal in VIEW mode", 84},
|
||||
{"\
|
||||
nano help text\n\
|
||||
\n\
|
||||
The nano editor is designed to emulate the functionality and ease-of-use of \
|
||||
the UW Pico text editor. There are four main sections of the editor: The \
|
||||
top line shows the program version, the current filename being edited, and \
|
||||
whether or not the file has been modified. Next is the main editor window \
|
||||
showing the file being edited. The status line is the third line from the \
|
||||
bottom and shows important messages. The bottom two lines show the most \
|
||||
commonly used shortcuts in the editor.\n\
|
||||
\n\
|
||||
The notation for shortcuts is as follows: Control-key sequences are notated \
|
||||
with a caret (^) symbol. Alt-key sequences are notated with an at (@) \
|
||||
symbol. The following keystrokes are available in the main editor window. \
|
||||
Optional keys are shown in parentheses:\n\
|
||||
\n", 85},
|
||||
{"free_node(): free'd a node, YAY!\n", 86},
|
||||
{"free_node(): free'd last node.\n", 87},
|
||||
{"\
|
||||
Usage: nano [GNU long option] [option] +LINE <file>\n\
|
||||
\n", 88},
|
||||
{"Option\t\tLong option\t\tMeaning\n", 89},
|
||||
{" -T \t\t--tabsize=[num]\t\tSet width of a tab to num\n", 90},
|
||||
{" -R\t\t--regexp\t\tUse regular expressions for search\n", 91},
|
||||
{" -V \t\t--version\t\tPrint version information and exit\n", 92},
|
||||
{" -c \t\t--const\t\t\tConstantly show cursor position\n", 93},
|
||||
{" -h \t\t--help\t\t\tShow this message\n", 94},
|
||||
{" -k \t\t--cut\t\t\tLet ^K cut from cursor to end of line\n", 95},
|
||||
{" -i \t\t--autoindent\t\tAutomatically indent new lines\n", 96},
|
||||
{" -l \t\t--nofollow\t\tDon't follow symbolic links, overwrite.\n", 97},
|
||||
{" -m \t\t--mouse\t\t\tEnable mouse\n", 98},
|
||||
{"\
|
||||
-r [#cols] \t--fill=[#cols]\t\tSet fill cols to (wrap lines at) #cols\n", 99},
|
||||
{" -p\t \t--pico\t\t\tMake bottom 2 lines more Pico-like\n", 100},
|
||||
{" -s [prog] \t--speller=[prog]\tEnable alternate speller\n", 101},
|
||||
{" -t \t\t--tempfile\t\tAuto save on exit, don't prompt\n", 102},
|
||||
{" -v \t\t--view\t\t\tView (read only) mode\n", 103},
|
||||
{" -w \t\t--nowrap\t\tDon't wrap long lines\n", 104},
|
||||
{" -x \t\t--nohelp\t\tDon't show help window\n", 105},
|
||||
{" -z \t\t--suspend\t\tEnable suspend\n", 106},
|
||||
{" +LINE\t\t\t\t\tStart at line number LINE\n", 107},
|
||||
{"\
|
||||
Usage: nano [option] +LINE <file>\n\
|
||||
\n", 108},
|
||||
{"Option\t\tMeaning\n", 109},
|
||||
{" -T [num]\tSet width of a tab to num\n", 110},
|
||||
{" -R\t\tUse regular expressions for search\n", 111},
|
||||
{" -V \t\tPrint version information and exit\n", 112},
|
||||
{" -c \t\tConstantly show cursor position\n", 113},
|
||||
{" -h \t\tShow this message\n", 114},
|
||||
{" -k \t\tLet ^K cut from cursor to end of line\n", 115},
|
||||
{" -i \t\tAutomatically indent new lines\n", 116},
|
||||
{" -l \t\tDon't follow symbolic links, overwrite.\n", 117},
|
||||
{" -m \t\tEnable mouse\n", 118},
|
||||
{" -r [#cols] \tSet fill cols to (wrap lines at) #cols\n", 119},
|
||||
{" -s [prog] \tEnable alternate speller\n", 120},
|
||||
{" -p \t\tMake bottom 2 lines more Pico-like\n", 121},
|
||||
{" -t \t\tAuto save on exit, don't prompt\n", 122},
|
||||
{" -v \t\tView (read only) mode\n", 123},
|
||||
{" -w \t\tDon't wrap long lines\n", 124},
|
||||
{" -x \t\tDon't show help window\n", 125},
|
||||
{" -z \t\tEnable suspend\n", 126},
|
||||
{" +LINE\t\tStart at line number LINE\n", 127},
|
||||
{" nano version %s by Chris Allegretta (compiled %s, %s)\n", 128},
|
||||
{" Email: nano@asty.org\tWeb: http://www.asty.org/nano\n", 129},
|
||||
{"Mark Set", 130},
|
||||
{"Mark UNset", 131},
|
||||
{"check_wrap called with inptr->data=\"%s\"\n", 132},
|
||||
{"current->data now = \"%s\"\n", 133},
|
||||
{"After, data = \"%s\"\n", 134},
|
||||
{"Error deleting tempfile, ack!", 135},
|
||||
{"Could not create a temporary filename: %s", 136},
|
||||
{"Could not invoke spell program \"%s\"", 137},
|
||||
{"Could not invoke \"ispell\"", 138},
|
||||
{"Finished checking spelling", 139},
|
||||
{"Save modified buffer (ANSWERING \"No\" WILL DESTROY CHANGES) ? ", 140},
|
||||
{"Cannot resize top win", 141},
|
||||
{"Cannot move top win", 142},
|
||||
{"Cannot resize edit win", 143},
|
||||
{"Cannot move edit win", 144},
|
||||
{"Cannot resize bottom win", 145},
|
||||
{"Cannot move bottom win", 146},
|
||||
{"Main: set up windows\n", 147},
|
||||
{"Main: bottom win\n", 148},
|
||||
{"Main: open file\n", 149},
|
||||
{"I got Alt-[-%c! (%d)\n", 150},
|
||||
{"I got Alt-%c! (%d)\n", 151},
|
||||
{"Case Sensitive Regexp Search%s%s", 152},
|
||||
{"Regexp Search%s%s", 153},
|
||||
{"Case Sensitive Search%s%s", 154},
|
||||
{"Search%s%s", 155},
|
||||
{" (to replace)", 156},
|
||||
{"Search Cancelled", 157},
|
||||
{"Search Wrapped", 158},
|
||||
{"Replaced %d occurences", 159},
|
||||
{"Replaced 1 occurence", 160},
|
||||
{"Replace Cancelled", 161},
|
||||
{"Replace with [%s]", 162},
|
||||
{"Replace with", 163},
|
||||
{"Replace this instance?", 164},
|
||||
{"Enter line number", 165},
|
||||
{"Aborted", 166},
|
||||
{"Come on, be reasonable", 167},
|
||||
{"Only %d lines available, skipping to last line", 168},
|
||||
{"actual_x_from_start for xplus=%d returned %d\n", 169},
|
||||
{"input '%c' (%d)\n", 170},
|
||||
{"New Buffer", 171},
|
||||
{" File: ...", 172},
|
||||
{"Modified", 173},
|
||||
{"Moved to (%d, %d) in edit buffer\n", 174},
|
||||
{"current->data = \"%s\"\n", 175},
|
||||
{"I got \"%s\"\n", 176},
|
||||
{"Yes", 177},
|
||||
{"All", 178},
|
||||
{"No", 179},
|
||||
{"do_cursorpos: linepct = %f, bytepct = %f\n", 180},
|
||||
{"line %d of %d (%.0f%%), character %d of %d (%.0f%%)", 181},
|
||||
{"Dumping file buffer to stderr...\n", 182},
|
||||
{"Dumping cutbuffer to stderr...\n", 183},
|
||||
{"Dumping a buffer to stderr...\n", 184},
|
||||
};
|
||||
|
||||
int _msg_tbl_length = 184;
|
||||
695
po/nano.pot
695
po/nano.pot
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
timestamp
|
||||
49
proto.h
49
proto.h
@@ -1,3 +1,4 @@
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* proto.h *
|
||||
* *
|
||||
@@ -21,7 +22,11 @@
|
||||
/* Externs */
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
#include <regex.h>
|
||||
#endif
|
||||
|
||||
#include "nano.h"
|
||||
|
||||
extern int center_x, center_y, editwinrows;
|
||||
@@ -29,11 +34,15 @@ extern int current_x, current_y, posible_max, totlines;
|
||||
extern int placewewant;
|
||||
extern int mark_beginx, samelinewrap;
|
||||
extern int totsize, temp_opt;
|
||||
extern int fill, flags;
|
||||
extern int fill, flags,tabsize;
|
||||
extern int search_last_line;
|
||||
|
||||
extern WINDOW *edit, *topwin, *bottomwin;
|
||||
extern char *filename, *answer, *last_search, *last_replace;
|
||||
extern char filename[PATH_MAX];
|
||||
extern char *answer;
|
||||
extern char *hblank, *help_text;
|
||||
extern char *last_search;
|
||||
extern char *last_replace;
|
||||
extern struct stat fileinfo;
|
||||
extern filestruct *current, *fileage, *edittop, *editbot, *filebot;
|
||||
extern filestruct *cutbuffer, *mark_beginbuf;
|
||||
@@ -41,10 +50,15 @@ extern shortcut *shortcut_list;
|
||||
extern shortcut main_list[MAIN_LIST_LEN], whereis_list[WHEREIS_LIST_LEN];
|
||||
extern shortcut replace_list[REPLACE_LIST_LEN], goto_list[GOTO_LIST_LEN];
|
||||
extern shortcut writefile_list[WRITEFILE_LIST_LEN], help_list[HELP_LIST_LEN];
|
||||
extern shortcut spell_list[SPELL_LIST_LEN];
|
||||
extern shortcut spell_list[SPELL_LIST_LEN], replace_list_2[REPLACE_LIST_LEN];
|
||||
|
||||
#ifdef HAVE_REGEX_H
|
||||
extern int use_regexp, regexp_compiled;
|
||||
extern regex_t search_regexp;
|
||||
extern regmatch_t regmatches[10];
|
||||
#endif
|
||||
|
||||
extern toggle toggles[TOGGLE_LEN];
|
||||
|
||||
/* Programs we want available */
|
||||
|
||||
@@ -57,7 +71,7 @@ int xplustabs(void);
|
||||
int do_yesno(int all, int leavecursor, char *msg, ...);
|
||||
int actual_x(filestruct * fileptr, int xplus);
|
||||
int strlenpt(char *buf);
|
||||
int statusq(shortcut s[], int slen, char *def, char *msg, ...);
|
||||
int statusq(int allowtabs, shortcut s[], int slen, char *def, char *msg, ...);
|
||||
int write_file(char *name, int tmpfile);
|
||||
int do_cut_text(void);
|
||||
int do_uncut_text(void);
|
||||
@@ -66,23 +80,26 @@ int renumber_all(void);
|
||||
int open_file(char *filename, int insert, int quiet);
|
||||
int do_writeout(int exiting);
|
||||
int do_gotoline(long defline);
|
||||
int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
||||
int wholewords, int *i);
|
||||
/* Now in move.c */
|
||||
int do_up(void);
|
||||
int do_down(void);
|
||||
int do_left(void);
|
||||
int do_right(void);
|
||||
int check_wildcard_match(const char *text, const char *pattern);
|
||||
|
||||
char *input_tab(char *buf, int place, int *lastWasTab, int *newplace);
|
||||
char *real_dir_from_tilde(char *buf);
|
||||
|
||||
void shortcut_init(void);
|
||||
void shortcut_init(int unjustify);
|
||||
void lowercase(char *src);
|
||||
void blank_bottombars(void);
|
||||
void check_wrap(filestruct * inptr, char ch);
|
||||
void dump_buffer(filestruct * inptr);
|
||||
void align(char **strp);
|
||||
void edit_refresh(void);
|
||||
void edit_update(filestruct * fileptr);
|
||||
void edit_update_top(filestruct * fileptr);
|
||||
void edit_update_bot(filestruct * fileptr);
|
||||
void edit_refresh(void), edit_refresh_clearok(void);
|
||||
void edit_update(filestruct * fileptr, int topmidbot);
|
||||
void update_cursor(void);
|
||||
void delete_node(filestruct * fileptr);
|
||||
void set_modified(void);
|
||||
@@ -98,6 +115,7 @@ void center_cursor(void);
|
||||
void bottombars(shortcut s[], int slen);
|
||||
void blank_statusbar_refresh(void);
|
||||
void *nmalloc (size_t howmuch);
|
||||
void *mallocstrcpy(void *dest, void *src);
|
||||
void wrap_reset(void);
|
||||
void display_main_list(void);
|
||||
void nano_small_msg(void);
|
||||
@@ -107,6 +125,17 @@ void *nrealloc(void *ptr, size_t howmuch);
|
||||
void die(char *msg, ...);
|
||||
void new_file(void);
|
||||
void new_magicline(void);
|
||||
void splice_node(filestruct *begin, filestruct *new, filestruct *end);
|
||||
void null_at(char *data, int index);
|
||||
void page_up_center(void);
|
||||
void blank_edit(void);
|
||||
void search_init_globals(void);
|
||||
void replace_abort(void);
|
||||
void add_to_cutbuffer(filestruct * inptr);
|
||||
void do_replace_highlight(int highlight_flag, char *word);
|
||||
#ifdef NANO_EXTRA
|
||||
void do_credits(void);
|
||||
#endif
|
||||
|
||||
int do_writeout_void(void), do_exit(void), do_gotoline_void(void);
|
||||
int do_insertfile(void), do_search(void), page_up(void), page_down(void);
|
||||
@@ -120,3 +149,5 @@ int do_replace(void), do_help(void), do_enter_void(void);
|
||||
filestruct *copy_node(filestruct * src);
|
||||
filestruct *copy_filestruct(filestruct * src);
|
||||
filestruct *make_new_node(filestruct * prevnode);
|
||||
filestruct *findnextstr(int quiet, filestruct * begin,
|
||||
int beginx, char *needle);
|
||||
|
||||
618
search.c
618
search.c
@@ -1,3 +1,4 @@
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* search.c *
|
||||
* *
|
||||
@@ -22,6 +23,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include "config.h"
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
@@ -35,7 +37,7 @@
|
||||
|
||||
/* Regular expression helper functions */
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
#ifdef HAVE_REGEX_H
|
||||
void regexp_init(const char *regexp)
|
||||
{
|
||||
regcomp(&search_regexp, regexp, ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE);
|
||||
@@ -49,6 +51,18 @@ void regexp_cleanup()
|
||||
}
|
||||
#endif
|
||||
|
||||
void search_init_globals(void)
|
||||
{
|
||||
if (last_search == NULL) {
|
||||
last_search = nmalloc(1);
|
||||
last_search[0] = 0;
|
||||
}
|
||||
if (last_replace == NULL) {
|
||||
last_replace = nmalloc(1);
|
||||
last_replace[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up the system variables for a search or replace. Returns -1 on
|
||||
abort, 0 on success, and 1 on rerun calling program
|
||||
Return -2 to run opposite program (searchg -> replace, replace -> search)
|
||||
@@ -57,54 +71,93 @@ void regexp_cleanup()
|
||||
*/
|
||||
int search_init(int replacing)
|
||||
{
|
||||
int i;
|
||||
char buf[BUFSIZ];
|
||||
int i = 0;
|
||||
char *buf;
|
||||
char *prompt, *reprompt = "";
|
||||
|
||||
if (last_search[0]) {
|
||||
snprintf(buf, BUFSIZ, " [%s]", last_search);
|
||||
} else {
|
||||
buf[0] = '\0';
|
||||
static char *backupstring = NULL;
|
||||
|
||||
search_init_globals();
|
||||
|
||||
buf = nmalloc(strlen(last_search) + 5);
|
||||
buf[0] = 0;
|
||||
|
||||
|
||||
/* Okay, fun time. backupstring is our holder for what is being
|
||||
returned from the statusq call. Using answer for this would be tricky.
|
||||
Here, if we're using PICO_MODE, we only want nano to put the
|
||||
old string back up as editable if it's not the same as last_search.
|
||||
|
||||
Otherwise, if we don't already have a backupstring, set it to
|
||||
last_search. */
|
||||
|
||||
if (ISSET(PICO_MODE)) {
|
||||
if (backupstring == NULL || !strcmp(backupstring, last_search))
|
||||
backupstring = mallocstrcpy(backupstring, "");
|
||||
}
|
||||
else if (backupstring == NULL)
|
||||
backupstring = mallocstrcpy(backupstring, last_search);
|
||||
|
||||
/* If using Pico messages, we do things the old fashioned way... */
|
||||
if (ISSET(PICO_MODE)) {
|
||||
if (last_search[0]) {
|
||||
|
||||
/* We use COLS / 3 here because we need to see more on the line */
|
||||
if (strlen(last_search) > COLS / 3) {
|
||||
snprintf(buf, COLS / 3 + 3, " [%s", last_search);
|
||||
sprintf(&buf[COLS / 3 + 2], "...]");
|
||||
} else
|
||||
sprintf(buf, " [%s]", last_search);
|
||||
} else {
|
||||
buf[0] = '\0';
|
||||
}
|
||||
}
|
||||
else
|
||||
strcpy(buf, "");
|
||||
|
||||
if (ISSET(USE_REGEXP) && ISSET(CASE_SENSITIVE))
|
||||
prompt = _("Case Sensitive Regexp Search%s%s");
|
||||
prompt = _("Case Sensitive Regexp Search%s%s");
|
||||
else if (ISSET(USE_REGEXP))
|
||||
prompt = _("Regexp Search%s%s");
|
||||
else
|
||||
if (ISSET(CASE_SENSITIVE))
|
||||
prompt = _("Case Sensitive Search%s%s");
|
||||
prompt = _("Regexp Search%s%s");
|
||||
else if (ISSET(CASE_SENSITIVE))
|
||||
prompt = _("Case Sensitive Search%s%s");
|
||||
else
|
||||
prompt = _("Search%s%s");
|
||||
prompt = _("Search%s%s");
|
||||
|
||||
if (replacing)
|
||||
reprompt = _(" (to replace)");
|
||||
|
||||
i = statusq(replacing ? replace_list : whereis_list,
|
||||
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, "",
|
||||
prompt, reprompt, buf);
|
||||
|
||||
/* This is now one simple call. It just does a lot */
|
||||
i = statusq(0, replacing ? replace_list : whereis_list,
|
||||
replacing ? REPLACE_LIST_LEN : WHEREIS_LIST_LEN, backupstring,
|
||||
prompt, reprompt, buf);
|
||||
|
||||
/* Cancel any search, or just return with no previous search */
|
||||
if ((i == -1) || (i < 0 && !last_search[0])) {
|
||||
statusbar(_("Search Cancelled"));
|
||||
reset_cursor();
|
||||
free(backupstring);
|
||||
backupstring = NULL;
|
||||
return -1;
|
||||
} else if (i == -2) { /* Same string */
|
||||
strncpy(answer, last_search, 132);
|
||||
#ifdef _POSIX_VERSION
|
||||
if (ISSET(USE_REGEXP))
|
||||
regexp_init(answer);
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
regexp_init(answer);
|
||||
#else
|
||||
;
|
||||
#endif
|
||||
} else if (i == 0) { /* They entered something new */
|
||||
strncpy(last_search, answer, 132);
|
||||
#ifdef _POSIX_VERSION
|
||||
if (ISSET(USE_REGEXP))
|
||||
regexp_init(answer);
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP))
|
||||
regexp_init(answer);
|
||||
#endif
|
||||
/* Blow away last_replace because they entered a new search
|
||||
string....uh, right? =) */
|
||||
free(backupstring);
|
||||
backupstring = NULL;
|
||||
last_replace[0] = '\0';
|
||||
} else if (i == NANO_CASE_KEY) { /* They want it case sensitive */
|
||||
free(backupstring);
|
||||
backupstring = NULL;
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
|
||||
if (ISSET(CASE_SENSITIVE))
|
||||
UNSET(CASE_SENSITIVE);
|
||||
else
|
||||
@@ -112,86 +165,115 @@ int search_init(int replacing)
|
||||
|
||||
return 1;
|
||||
} else if (i == NANO_OTHERSEARCH_KEY) {
|
||||
backupstring = mallocstrcpy(backupstring, answer);
|
||||
return -2; /* Call the opposite search function */
|
||||
} else if (i == NANO_FROMSEARCHTOGOTO_KEY) {
|
||||
free(backupstring);
|
||||
backupstring = NULL;
|
||||
do_gotoline_void();
|
||||
return -3;
|
||||
} else { /* First line key, etc. */
|
||||
do_early_abort();
|
||||
free(backupstring);
|
||||
backupstring = NULL;
|
||||
return -3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
filestruct *findnextstr(int quiet, filestruct * begin, char *needle)
|
||||
void not_found_msg(char *str)
|
||||
{
|
||||
if (strlen(str) <= COLS / 2)
|
||||
statusbar(_("\"%s\" not found"), str);
|
||||
else {
|
||||
char *foo = NULL;
|
||||
|
||||
foo = mallocstrcpy(foo, str);
|
||||
foo[COLS / 2] = 0;
|
||||
statusbar(_("\"%s...\" not found"), foo);
|
||||
|
||||
free(foo);
|
||||
}
|
||||
}
|
||||
|
||||
filestruct *findnextstr(int quiet, filestruct * begin, int beginx,
|
||||
char *needle)
|
||||
{
|
||||
filestruct *fileptr;
|
||||
char *searchstr, *found = NULL, *tmp;
|
||||
int past_editbot = 0;
|
||||
int past_editbot = 0, current_x_find;
|
||||
|
||||
fileptr = current;
|
||||
|
||||
searchstr = ¤t->data[current_x + 1];
|
||||
/* Look for searchstr until EOF */
|
||||
while (fileptr != NULL &&
|
||||
(found = strstrwrapper(searchstr, needle)) == NULL) {
|
||||
current_x_find = current_x + 1;
|
||||
|
||||
/* Are we searching the last line? (i.e. the line where search started) */
|
||||
if ((fileptr == begin) && (current_x_find < beginx))
|
||||
search_last_line = 1;
|
||||
|
||||
/* Make sure we haven't passed the end of the string */
|
||||
if (strlen(fileptr->data) < current_x_find)
|
||||
current_x_find--;
|
||||
|
||||
searchstr = &fileptr->data[current_x_find];
|
||||
|
||||
/* Look for needle in searchstr */
|
||||
while ((found = strstrwrapper(searchstr, needle)) == NULL) {
|
||||
|
||||
/* finished processing file, get out */
|
||||
if (search_last_line) {
|
||||
if (!quiet)
|
||||
not_found_msg(needle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fileptr = fileptr->next;
|
||||
|
||||
if (!past_editbot && (fileptr == editbot))
|
||||
past_editbot = 1;
|
||||
|
||||
if (fileptr == begin)
|
||||
return NULL;
|
||||
/* EOF reached, wrap around once */
|
||||
if (fileptr == NULL) {
|
||||
fileptr = fileage;
|
||||
|
||||
if (fileptr != NULL)
|
||||
searchstr = fileptr->data;
|
||||
}
|
||||
|
||||
/* If we're not at EOF, we found an instance */
|
||||
if (fileptr != NULL) {
|
||||
current = fileptr;
|
||||
current_x = 0;
|
||||
for (tmp = fileptr->data; tmp != found; tmp++)
|
||||
current_x++;
|
||||
|
||||
if (past_editbot)
|
||||
edit_update(current);
|
||||
reset_cursor();
|
||||
} else { /* We're at EOF, go back to the top, once */
|
||||
|
||||
fileptr = fileage;
|
||||
|
||||
while (fileptr != current && fileptr != begin &&
|
||||
(found = strstrwrapper(fileptr->data, needle)) == NULL)
|
||||
fileptr = fileptr->next;
|
||||
|
||||
if (fileptr == begin) {
|
||||
if (!quiet)
|
||||
statusbar(_("\"%s\" not found"), needle);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
if (fileptr != current) { /* We found something */
|
||||
current = fileptr;
|
||||
current_x = 0;
|
||||
for (tmp = fileptr->data; tmp != found; tmp++)
|
||||
current_x++;
|
||||
|
||||
edit_update(current);
|
||||
reset_cursor();
|
||||
past_editbot = 1;
|
||||
|
||||
if (!quiet)
|
||||
statusbar(_("Search Wrapped"));
|
||||
} else { /* Nada */
|
||||
|
||||
if (!quiet)
|
||||
statusbar(_("\"%s\" not found"), needle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Original start line reached */
|
||||
if (fileptr == begin)
|
||||
search_last_line = 1;
|
||||
|
||||
searchstr = fileptr->data;
|
||||
}
|
||||
|
||||
/* We found an instance */
|
||||
current_x_find = 0;
|
||||
for (tmp = fileptr->data; tmp != found; tmp++)
|
||||
current_x_find++;
|
||||
|
||||
/* Ensure we haven't wrap around again! */
|
||||
if ((search_last_line) && (current_x_find >= beginx)) {
|
||||
if (!quiet)
|
||||
not_found_msg(needle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set globals now that we are sure we found something */
|
||||
current = fileptr;
|
||||
current_x = current_x_find;
|
||||
|
||||
if (past_editbot)
|
||||
edit_update(fileptr, CENTER);
|
||||
else
|
||||
update_line(current, current_x);
|
||||
|
||||
placewewant = xplustabs();
|
||||
reset_cursor();
|
||||
|
||||
return fileptr;
|
||||
}
|
||||
|
||||
@@ -200,10 +282,12 @@ void search_abort(void)
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
display_main_list();
|
||||
wrefresh(bottomwin);
|
||||
if (ISSET(MARK_ISSET))
|
||||
edit_refresh_clearok();
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(REGEXP_COMPILED))
|
||||
regexp_cleanup();
|
||||
regexp_cleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -214,22 +298,41 @@ int do_search(void)
|
||||
filestruct *fileptr = current;
|
||||
|
||||
wrap_reset();
|
||||
if ((i = search_init(0)) == -1) {
|
||||
i = search_init(0);
|
||||
switch (i) {
|
||||
case -1:
|
||||
current = fileptr;
|
||||
search_abort();
|
||||
return 0;
|
||||
} else if (i == -3) {
|
||||
case -3:
|
||||
search_abort();
|
||||
return 0;
|
||||
} else if (i == -2) {
|
||||
case -2:
|
||||
do_replace();
|
||||
return 0;
|
||||
} else if (i == 1) {
|
||||
case 1:
|
||||
do_search();
|
||||
search_abort();
|
||||
return 1;
|
||||
}
|
||||
findnextstr(0, current, answer);
|
||||
|
||||
/* The sneaky user deleted the previous search string */
|
||||
if (!ISSET(PICO_MODE) && !strcmp(answer, "")) {
|
||||
statusbar(_("Search Cancelled"));
|
||||
search_abort();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If answer is now == "", then PICO_MODE is set. So, copy
|
||||
last_search into answer... */
|
||||
|
||||
if (!strcmp(answer, ""))
|
||||
answer = mallocstrcpy(answer, last_search);
|
||||
else
|
||||
last_search = mallocstrcpy(last_search, answer);
|
||||
|
||||
search_last_line = 0;
|
||||
findnextstr(0, current, current_x, answer);
|
||||
search_abort();
|
||||
return 1;
|
||||
}
|
||||
@@ -244,17 +347,14 @@ void print_replaced(int num)
|
||||
|
||||
void replace_abort(void)
|
||||
{
|
||||
UNSET(KEEP_CUTBUFFER);
|
||||
display_main_list();
|
||||
reset_cursor();
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
if (ISSET(REGEXP_COMPILED))
|
||||
regexp_cleanup();
|
||||
#endif
|
||||
/* Identicle to search_abort, so we'll call it here. If it
|
||||
does something different later, we can change it back. For now
|
||||
it's just a waste to duplicat code */
|
||||
search_abort();
|
||||
placewewant = xplustabs();
|
||||
}
|
||||
|
||||
#ifdef _POSIX_VERSION
|
||||
#ifdef HAVE_REGEX_H
|
||||
int replace_regexp(char *string, int create_flag)
|
||||
{
|
||||
/* split personality here - if create_flag is null, just calculate
|
||||
@@ -263,8 +363,7 @@ int replace_regexp(char *string, int create_flag)
|
||||
|
||||
char *c;
|
||||
int new_size = strlen(current->data) + 1;
|
||||
int search_match_count = regmatches[0].rm_eo -
|
||||
regmatches[0].rm_so;
|
||||
int search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||
|
||||
new_size -= search_match_count;
|
||||
|
||||
@@ -273,75 +372,74 @@ int replace_regexp(char *string, int create_flag)
|
||||
|
||||
c = last_replace;
|
||||
while (*c) {
|
||||
if (*c != '\\') {
|
||||
if (create_flag)
|
||||
*string++=*c;
|
||||
c++;
|
||||
new_size++;
|
||||
} else {
|
||||
int num = (int)*(c+1) - (int)'0';
|
||||
if (num >= 1 && num <= 9) {
|
||||
if (*c != '\\') {
|
||||
if (create_flag)
|
||||
*string++ = *c;
|
||||
c++;
|
||||
new_size++;
|
||||
} else {
|
||||
int num = (int) *(c + 1) - (int) '0';
|
||||
if (num >= 1 && num <= 9) {
|
||||
|
||||
int i = regmatches[num].rm_so;
|
||||
int i = regmatches[num].rm_so;
|
||||
|
||||
if (num > search_regexp.re_nsub) {
|
||||
/* Ugh, they specified a subexpression that doesn't
|
||||
exist. */
|
||||
return -1;
|
||||
}
|
||||
if (num > search_regexp.re_nsub) {
|
||||
/* Ugh, they specified a subexpression that doesn't
|
||||
exist. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Skip over the replacement expression */
|
||||
c+=2;
|
||||
/* Skip over the replacement expression */
|
||||
c += 2;
|
||||
|
||||
/* But add the length of the subexpression to new_size */
|
||||
new_size += regmatches[num].rm_eo - regmatches[num].rm_so;
|
||||
/* But add the length of the subexpression to new_size */
|
||||
new_size += regmatches[num].rm_eo - regmatches[num].rm_so;
|
||||
|
||||
/* And if create_flag is set, append the result of the
|
||||
* subexpression match to the new line */
|
||||
while (create_flag && i < regmatches[num].rm_eo )
|
||||
*string++=*(current->data + i++);
|
||||
|
||||
} else {
|
||||
if (create_flag)
|
||||
*string++=*c;
|
||||
c++;
|
||||
new_size++;
|
||||
}
|
||||
}
|
||||
/* And if create_flag is set, append the result of the
|
||||
* subexpression match to the new line */
|
||||
while (create_flag && i < regmatches[num].rm_eo)
|
||||
*string++ = *(current->data + i++);
|
||||
|
||||
} else {
|
||||
if (create_flag)
|
||||
*string++ = *c;
|
||||
c++;
|
||||
new_size++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (create_flag)
|
||||
*string = 0;
|
||||
*string = 0;
|
||||
|
||||
return new_size;
|
||||
}
|
||||
#endif
|
||||
|
||||
char *replace_line()
|
||||
|
||||
char *replace_line(void)
|
||||
{
|
||||
char *copy, *tmp;
|
||||
int new_line_size;
|
||||
int search_match_count;
|
||||
|
||||
/* Calculate size of new line */
|
||||
#ifdef _POSIX_VERSION
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
search_match_count = regmatches[0].rm_eo -
|
||||
regmatches[0].rm_so;
|
||||
new_line_size = replace_regexp(NULL, 0);
|
||||
/* If they specified an invalid subexpression in the replace
|
||||
* text, return NULL indicating an error */
|
||||
if (new_line_size < 0)
|
||||
return NULL;
|
||||
search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
|
||||
new_line_size = replace_regexp(NULL, 0);
|
||||
/* If they specified an invalid subexpression in the replace
|
||||
* text, return NULL indicating an error */
|
||||
if (new_line_size < 0)
|
||||
return NULL;
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
search_match_count = strlen(last_search);
|
||||
new_line_size = strlen(current->data) - strlen(last_search) +
|
||||
strlen(last_replace) + 1;
|
||||
search_match_count = strlen(last_search);
|
||||
new_line_size = strlen(current->data) - strlen(last_search) +
|
||||
strlen(last_replace) + 1;
|
||||
}
|
||||
|
||||
|
||||
/* Create buffer */
|
||||
copy = nmalloc(new_line_size);
|
||||
|
||||
@@ -351,10 +449,10 @@ char *replace_line()
|
||||
|
||||
/* Replacement Text */
|
||||
if (!ISSET(USE_REGEXP))
|
||||
strcat(copy, last_replace);
|
||||
#ifdef _POSIX_VERSION
|
||||
strcat(copy, last_replace);
|
||||
#ifdef HAVE_REGEX_H
|
||||
else
|
||||
(void)replace_regexp(copy + current_x, 1);
|
||||
(void) replace_regexp(copy + current_x, 1);
|
||||
#endif
|
||||
|
||||
/* The tail of the original line */
|
||||
@@ -370,109 +468,84 @@ char *replace_line()
|
||||
return copy;
|
||||
}
|
||||
|
||||
/* Replace a string */
|
||||
int do_replace(void)
|
||||
/* step through each replace word and prompt user before replacing word */
|
||||
int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
||||
int wholewords, int *i)
|
||||
{
|
||||
int i, replaceall = 0, numreplaced = 0, beginx;
|
||||
filestruct *fileptr, *begin;
|
||||
char *copy, prevanswer[132] = "";
|
||||
int replaceall = 0, numreplaced = 0;
|
||||
filestruct *fileptr;
|
||||
char *copy;
|
||||
|
||||
if ((i = search_init(1)) == -1) {
|
||||
switch (*i) {
|
||||
case -1: /* Aborted enter */
|
||||
if (strcmp(last_replace, ""))
|
||||
answer = mallocstrcpy(answer, last_replace);
|
||||
statusbar(_("Replace Cancelled"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
} else if (i == 1) {
|
||||
do_replace();
|
||||
return 1;
|
||||
} else if (i == -2) {
|
||||
do_search();
|
||||
return 0;
|
||||
} else if (i == -3) {
|
||||
replace_abort();
|
||||
return 0;
|
||||
}
|
||||
strncpy(prevanswer, answer, 132);
|
||||
|
||||
if (strcmp(last_replace, "")) { /* There's a previous replace str */
|
||||
i = statusq(replace_list, REPLACE_LIST_LEN, "",
|
||||
_("Replace with [%s]"), last_replace);
|
||||
|
||||
if (i == -1) { /* Aborted enter */
|
||||
strncpy(answer, last_replace, 132);
|
||||
statusbar(_("Replace Cancelled"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
} else if (i == 0) /* They actually entered something */
|
||||
strncpy(last_replace, answer, 132);
|
||||
else if (i == NANO_CASE_KEY) { /* They asked for case sensitivity */
|
||||
if (ISSET(CASE_SENSITIVE))
|
||||
UNSET(CASE_SENSITIVE);
|
||||
else
|
||||
SET(CASE_SENSITIVE);
|
||||
|
||||
do_replace();
|
||||
return 0;
|
||||
} else if (i != -2 ) { /* First page, last page, for example could get here */
|
||||
|
||||
case 0: /* They actually entered something */
|
||||
break;
|
||||
default:
|
||||
if (*i != -2) { /* First page, last page, for example
|
||||
could get here */
|
||||
do_early_abort();
|
||||
replace_abort();
|
||||
return 0;
|
||||
}
|
||||
} else { /* last_search is empty */
|
||||
|
||||
i = statusq(replace_list, REPLACE_LIST_LEN, "", _("Replace with"));
|
||||
if (i == -1) {
|
||||
statusbar(_("Replace Cancelled"));
|
||||
reset_cursor();
|
||||
replace_abort();
|
||||
return 0;
|
||||
} else if (i == 0) /* They entered something new */
|
||||
strncpy(last_replace, answer, 132);
|
||||
else if (i == NANO_CASE_KEY) { /* They want it case sensitive */
|
||||
if (ISSET(CASE_SENSITIVE))
|
||||
UNSET(CASE_SENSITIVE);
|
||||
else
|
||||
SET(CASE_SENSITIVE);
|
||||
|
||||
do_replace();
|
||||
return 1;
|
||||
} else { /* First line key, etc. */
|
||||
|
||||
do_early_abort();
|
||||
replace_abort();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* save where we are */
|
||||
begin = current;
|
||||
beginx = current_x;
|
||||
if (ISSET(PICO_MODE) && !strcmp(answer, ""))
|
||||
answer = mallocstrcpy(answer, last_replace);
|
||||
|
||||
last_replace = mallocstrcpy(last_replace, answer);
|
||||
while (1) {
|
||||
|
||||
if (replaceall)
|
||||
fileptr = findnextstr(1, begin, prevanswer);
|
||||
else
|
||||
fileptr = findnextstr(0, begin, prevanswer);
|
||||
/* Sweet optimization by Rocco here */
|
||||
fileptr = findnextstr(replaceall, begin, *beginx, prevanswer);
|
||||
|
||||
/* No more matches. Done! */
|
||||
if (!fileptr)
|
||||
break;
|
||||
|
||||
/* If we're here, we've found the search string */
|
||||
if (!replaceall)
|
||||
i = do_yesno(1, 1, _("Replace this instance?"));
|
||||
/* Make sure only wholewords are found */
|
||||
if (wholewords)
|
||||
{
|
||||
/* start of line or previous character not a letter */
|
||||
if ((current_x == 0) || (!isalpha((int) fileptr->data[current_x-1])))
|
||||
{
|
||||
/* end of line or next character not a letter */
|
||||
if (((current_x + strlen(prevanswer)) == strlen(fileptr->data))
|
||||
|| (!isalpha((int) fileptr->data[current_x + strlen(prevanswer)])))
|
||||
;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i > 0 || replaceall) { /* Yes, replace it!!!! */
|
||||
if (i == 2)
|
||||
/* If we're here, we've found the search string */
|
||||
if (!replaceall) {
|
||||
|
||||
curs_set(0);
|
||||
do_replace_highlight(TRUE, prevanswer);
|
||||
|
||||
*i = do_yesno(1, 1, _("Replace this instance?"));
|
||||
|
||||
do_replace_highlight(FALSE, prevanswer);
|
||||
curs_set(1);
|
||||
}
|
||||
|
||||
if (*i > 0 || replaceall) { /* Yes, replace it!!!! */
|
||||
if (*i == 2)
|
||||
replaceall = 1;
|
||||
|
||||
copy = replace_line();
|
||||
if (!copy) {
|
||||
statusbar("Replace failed: unknown subexpression!");
|
||||
replace_abort();
|
||||
copy = replace_line();
|
||||
if (!copy) {
|
||||
statusbar(_("Replace failed: unknown subexpression!"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
free(current->data);
|
||||
@@ -481,17 +554,100 @@ int do_replace(void)
|
||||
/* Stop bug where we replace a substring of the replacement text */
|
||||
current_x += strlen(last_replace) - 1;
|
||||
|
||||
/* Adjust the original cursor position - COULD BE IMPROVED */
|
||||
if (search_last_line) {
|
||||
*beginx += strlen(last_replace) - strlen(last_search);
|
||||
|
||||
/* For strings that cross the search start/end boundary */
|
||||
/* Don't go outside of allocated memory */
|
||||
if (*beginx < 1)
|
||||
*beginx = 1;
|
||||
}
|
||||
|
||||
edit_refresh();
|
||||
set_modified();
|
||||
numreplaced++;
|
||||
} else if (i == -1) /* Abort, else do nothing and continue loop */
|
||||
} else if (*i == -1) /* Abort, else do nothing and continue loop */
|
||||
break;
|
||||
}
|
||||
|
||||
return numreplaced;
|
||||
}
|
||||
|
||||
/* Replace a string */
|
||||
int do_replace(void)
|
||||
{
|
||||
int i, numreplaced, beginx;
|
||||
filestruct *begin;
|
||||
char *prevanswer = NULL, *buf = NULL;
|
||||
|
||||
i = search_init(1);
|
||||
switch (i) {
|
||||
case -1:
|
||||
statusbar(_("Replace Cancelled"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
case 1:
|
||||
do_replace();
|
||||
return 1;
|
||||
case -2:
|
||||
do_search();
|
||||
return 0;
|
||||
case -3:
|
||||
replace_abort();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Again, there was a previous string but they deleted it and hit enter */
|
||||
if (!ISSET(PICO_MODE) && !strcmp(answer, "")) {
|
||||
statusbar(_("Replace Cancelled"));
|
||||
replace_abort();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If answer is now == "", then PICO_MODE is set. So, copy
|
||||
last_search into answer (and prevanswer)... */
|
||||
if (!strcmp(answer, "")) {
|
||||
answer = mallocstrcpy(answer, last_search);
|
||||
prevanswer = mallocstrcpy(prevanswer, last_search);
|
||||
} else {
|
||||
last_search = mallocstrcpy(last_search, answer);
|
||||
prevanswer = mallocstrcpy(prevanswer, answer);
|
||||
}
|
||||
|
||||
if (ISSET(PICO_MODE)) {
|
||||
buf = nmalloc(strlen(last_replace) + 5);
|
||||
if (strcmp(last_replace, "")) {
|
||||
if (strlen(last_replace) > (COLS / 3)) {
|
||||
strncpy(buf, last_replace, COLS / 3);
|
||||
sprintf(&buf[COLS / 3 - 1], "...");
|
||||
} else
|
||||
sprintf(buf, "%s", last_replace);
|
||||
|
||||
i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, "",
|
||||
_("Replace with [%s]"), buf);
|
||||
}
|
||||
else
|
||||
i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, "",
|
||||
_("Replace with"));
|
||||
}
|
||||
else
|
||||
i = statusq(0, replace_list_2, REPLACE_LIST_2_LEN, last_replace,
|
||||
_("Replace with"));
|
||||
|
||||
/* save where we are */
|
||||
begin = current;
|
||||
beginx = current_x + 1;
|
||||
|
||||
search_last_line = 0;
|
||||
|
||||
numreplaced = do_replace_loop(prevanswer, begin, &beginx, FALSE, &i);
|
||||
|
||||
/* restore where we were */
|
||||
current = begin;
|
||||
current_x = beginx;
|
||||
current_x = beginx - 1;
|
||||
renumber_all();
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
print_replaced(numreplaced);
|
||||
replace_abort();
|
||||
return 1;
|
||||
@@ -512,7 +668,7 @@ int do_gotoline(long defline)
|
||||
line = defline;
|
||||
else { /* Ask for it */
|
||||
|
||||
j = statusq(goto_list, GOTO_LIST_LEN, "", _("Enter line number"));
|
||||
j = statusq(0, goto_list, GOTO_LIST_LEN, "", _("Enter line number"));
|
||||
if (j == -1) {
|
||||
statusbar(_("Aborted"));
|
||||
goto_abort();
|
||||
@@ -525,7 +681,7 @@ int do_gotoline(long defline)
|
||||
if (!strcmp(answer, "$")) {
|
||||
current = filebot;
|
||||
current_x = 0;
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
goto_abort();
|
||||
return 1;
|
||||
}
|
||||
@@ -543,14 +699,14 @@ int do_gotoline(long defline)
|
||||
filebot->lineno);
|
||||
current = filebot;
|
||||
current_x = 0;
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
} else {
|
||||
for (fileptr = fileage; fileptr != NULL && i < line; i++)
|
||||
fileptr = fileptr->next;
|
||||
|
||||
current = fileptr;
|
||||
current_x = 0;
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
}
|
||||
|
||||
goto_abort();
|
||||
|
||||
142
utils.c
142
utils.c
@@ -1,3 +1,4 @@
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* utils.c *
|
||||
* *
|
||||
@@ -81,13 +82,13 @@ char *strcasestr(char *haystack, char *needle)
|
||||
|
||||
char *strstrwrapper(char *haystack, char *needle)
|
||||
{
|
||||
#ifdef _POSIX_VERSION
|
||||
#ifdef HAVE_REGEX_H
|
||||
if (ISSET(USE_REGEXP)) {
|
||||
int result=regexec(&search_regexp, haystack, 10, regmatches, 0);
|
||||
if (!result)
|
||||
return haystack+regmatches[0].rm_so;
|
||||
return 0;
|
||||
}
|
||||
int result = regexec(&search_regexp, haystack, 10, regmatches, 0);
|
||||
if (!result)
|
||||
return haystack + regmatches[0].rm_so;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
if (ISSET(CASE_SENSITIVE))
|
||||
return strstr(haystack, needle);
|
||||
@@ -113,13 +114,36 @@ void *nrealloc(void *ptr, size_t howmuch)
|
||||
void *r;
|
||||
|
||||
if (!(r = realloc(ptr, howmuch)))
|
||||
die("nano: realloc: out of memory!");
|
||||
die(_("nano: realloc: out of memory!"));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Copy one malloced string to another pointer.
|
||||
|
||||
Should be used as dest = mallocstrcpy(dest, src);
|
||||
*/
|
||||
void *mallocstrcpy(void *dest, void *src)
|
||||
{
|
||||
|
||||
if (dest != NULL)
|
||||
free(dest);
|
||||
|
||||
if (src == NULL) {
|
||||
dest = NULL;
|
||||
return(dest);
|
||||
}
|
||||
|
||||
dest = nmalloc(strlen(src) + 1);
|
||||
strcpy(dest, src);
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/* Append a new magic-line to filebot */
|
||||
void new_magicline(void) {
|
||||
void new_magicline(void)
|
||||
{
|
||||
filebot->next = nmalloc(sizeof(filestruct));
|
||||
filebot->next->data = nmalloc(1);
|
||||
filebot->next->data[0] = '\0';
|
||||
@@ -129,3 +153,105 @@ void new_magicline(void) {
|
||||
filebot = filebot->next;
|
||||
totlines++;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
/*
|
||||
* Routine to see if a text string is matched by a wildcard pattern.
|
||||
* Returns TRUE if the text is matched, or FALSE if it is not matched
|
||||
* or if the pattern is invalid.
|
||||
* * matches zero or more characters
|
||||
* ? matches a single character
|
||||
* [abc] matches 'a', 'b' or 'c'
|
||||
* \c quotes character c
|
||||
* Adapted from code written by Ingo Wilken, and
|
||||
* then taken from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
* Permission to distribute this code under the GPL has been granted.
|
||||
*/
|
||||
int check_wildcard_match(const char *text, const char *pattern)
|
||||
{
|
||||
const char *retryPat;
|
||||
const char *retryText;
|
||||
int ch;
|
||||
int found;
|
||||
int len;
|
||||
|
||||
retryPat = NULL;
|
||||
retryText = NULL;
|
||||
|
||||
while (*text || *pattern) {
|
||||
ch = *pattern++;
|
||||
|
||||
switch (ch) {
|
||||
case '*':
|
||||
retryPat = pattern;
|
||||
retryText = text;
|
||||
break;
|
||||
|
||||
case '[':
|
||||
found = FALSE;
|
||||
|
||||
while ((ch = *pattern++) != ']') {
|
||||
if (ch == '\\')
|
||||
ch = *pattern++;
|
||||
|
||||
if (ch == '\0')
|
||||
return FALSE;
|
||||
|
||||
if (*text == ch)
|
||||
found = TRUE;
|
||||
}
|
||||
len = strlen(text);
|
||||
if (found == FALSE && len != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
if (found == TRUE) {
|
||||
if (strlen(pattern) == 0 && len == 1) {
|
||||
return TRUE;
|
||||
}
|
||||
if (len != 0) {
|
||||
text++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* fall into next case */
|
||||
|
||||
case '?':
|
||||
if (*text++ == '\0')
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
ch = *pattern++;
|
||||
|
||||
if (ch == '\0')
|
||||
return FALSE;
|
||||
|
||||
/* fall into next case */
|
||||
|
||||
default:
|
||||
if (*text == ch) {
|
||||
if (*text)
|
||||
text++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (*text) {
|
||||
pattern = retryPat;
|
||||
text = ++retryText;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pattern == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
599
winio.c
599
winio.c
@@ -1,3 +1,4 @@
|
||||
/* $Id$ */
|
||||
/**************************************************************************
|
||||
* winio.c *
|
||||
* *
|
||||
@@ -21,6 +22,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "config.h"
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
@@ -48,7 +50,7 @@ int do_first_line(void)
|
||||
current = fileage;
|
||||
placewewant = 0;
|
||||
current_x = 0;
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -57,7 +59,7 @@ int do_last_line(void)
|
||||
current = filebot;
|
||||
placewewant = 0;
|
||||
current_x = 0;
|
||||
edit_update(current);
|
||||
edit_update(current, CENTER);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -73,9 +75,9 @@ int xpt(filestruct * fileptr, int index)
|
||||
tabs++;
|
||||
|
||||
if (fileptr->data[i] == NANO_CONTROL_I) {
|
||||
if (tabs % TABSIZE == 0);
|
||||
if (tabs % tabsize == 0);
|
||||
else
|
||||
tabs += TABSIZE - (tabs % TABSIZE);
|
||||
tabs += tabsize - (tabs % tabsize);
|
||||
} else if (fileptr->data[i] & 0x80)
|
||||
/* Make 8 bit chars only 1 collumn! */
|
||||
;
|
||||
@@ -106,10 +108,10 @@ int actual_x_from_start(filestruct * fileptr, int xplus, int start)
|
||||
|
||||
for (i = start; tot <= xplus && fileptr->data[i] != 0; i++, tot++)
|
||||
if (fileptr->data[i] == NANO_CONTROL_I) {
|
||||
if (tot % TABSIZE == 0)
|
||||
if (tot % tabsize == 0)
|
||||
tot++;
|
||||
else
|
||||
tot += TABSIZE - (tot % TABSIZE);
|
||||
tot += tabsize - (tot % tabsize);
|
||||
} else if (fileptr->data[i] & 0x80)
|
||||
tot++; /* Make 8 bit chars only 1 column (again) */
|
||||
else if (fileptr->data[i] < 32)
|
||||
@@ -140,9 +142,9 @@ int strlenpt(char *buf)
|
||||
tabs++;
|
||||
|
||||
if (buf[i] == NANO_CONTROL_I) {
|
||||
if (tabs % TABSIZE == 0);
|
||||
if (tabs % tabsize == 0);
|
||||
else
|
||||
tabs += TABSIZE - (tabs % TABSIZE);
|
||||
tabs += tabsize - (tabs % tabsize);
|
||||
} else if (buf[i] & 0x80)
|
||||
/* Make 8 bit chars only 1 collumn! */
|
||||
;
|
||||
@@ -191,7 +193,6 @@ void blank_edit(void)
|
||||
int i;
|
||||
for (i = 0; i <= editwinrows - 1; i++)
|
||||
mvwaddstr(edit, i, 0, hblank);
|
||||
wrefresh(edit);
|
||||
}
|
||||
|
||||
|
||||
@@ -217,51 +218,94 @@ void check_statblank(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the input from the kb, this should only be called from statusq */
|
||||
int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
|
||||
/* Repaint the statusbar when getting a character in nanogetstr */
|
||||
void nanoget_repaint(char *buf, char *inputbuf, int x)
|
||||
{
|
||||
int kbinput = 0, j = 0, x = 0, xend;
|
||||
int x_left = 0;
|
||||
char inputstr[132], inputbuf[132] = "";
|
||||
int len = strlen(buf);
|
||||
int wid = COLS - len;
|
||||
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
if (strlen(def) > 0)
|
||||
waddstr(bottomwin, def);
|
||||
wrefresh(bottomwin);
|
||||
if (x <= COLS - 1) {
|
||||
/* Black magic */
|
||||
buf[len - 1] = ' ';
|
||||
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddnstr(bottomwin, inputbuf, wid);
|
||||
wmove(bottomwin, 0, (x % COLS));
|
||||
}
|
||||
else {
|
||||
/* Black magic */
|
||||
buf[len - 1] = '$';
|
||||
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddnstr(bottomwin, &inputbuf[wid * ((x - len) / (wid))], wid);
|
||||
wmove(bottomwin, 0, ((x - len) % wid) + len);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the input from the kb, this should only be called from statusq */
|
||||
int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
int start_x)
|
||||
{
|
||||
int kbinput = 0, j = 0, x = 0, xend;
|
||||
int x_left = 0, inputlen, tabbed = 0;
|
||||
char *inputbuf;
|
||||
#ifndef DISABLE_TABCOMP
|
||||
int shift = 0;
|
||||
#endif
|
||||
|
||||
inputbuf = nmalloc(strlen(def) + 1);
|
||||
inputbuf[0] = 0;
|
||||
|
||||
x_left = strlen(buf);
|
||||
x = strlen(def) + x_left;
|
||||
|
||||
/* Get the input! */
|
||||
if (strlen(def) > 0) {
|
||||
strcpy(answer, def);
|
||||
if (strlen(def) > 0)
|
||||
strcpy(inputbuf, def);
|
||||
}
|
||||
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
|
||||
/* Make sure any editor screen updates are displayed before getting input */
|
||||
wrefresh(edit);
|
||||
|
||||
while ((kbinput = wgetch(bottomwin)) != 13) {
|
||||
for (j = 0; j <= slen - 1; j++) {
|
||||
if (kbinput == s[j].val) {
|
||||
strcpy(answer, "");
|
||||
|
||||
/* We shouldn't discard the answer it gave, just because
|
||||
we hit a keystroke, GEEZ! */
|
||||
answer = mallocstrcpy(answer, inputbuf);
|
||||
free(inputbuf);
|
||||
return s[j].val;
|
||||
}
|
||||
}
|
||||
xend = strlen(buf) + strlen(inputbuf);
|
||||
|
||||
if (kbinput != '\t')
|
||||
tabbed = 0;
|
||||
|
||||
switch (kbinput) {
|
||||
/* Stuff we want to equate with <enter>, ASCII 13 */
|
||||
case 343:
|
||||
ungetch(13); /* Enter on iris-ansi $TERM, sometimes */
|
||||
break;
|
||||
/* Stuff we want to ignore */
|
||||
#ifdef PDCURSES
|
||||
case 541:
|
||||
case 542:
|
||||
case 543: /* Right ctrl again */
|
||||
case 544:
|
||||
case 545: /* Right alt again */
|
||||
#endif
|
||||
break;
|
||||
case KEY_HOME:
|
||||
x = x_left;
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
break;
|
||||
case KEY_END:
|
||||
x = x_left + strlen(inputbuf);
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
|
||||
@@ -276,19 +320,13 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
|
||||
strlen(inputbuf) - (x - x_left) - 1);
|
||||
inputbuf[strlen(inputbuf) - 1] = 0;
|
||||
}
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
break;
|
||||
case NANO_CONTROL_K:
|
||||
case NANO_CONTROL_U:
|
||||
*inputbuf = 0;
|
||||
x = x_left;
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
break;
|
||||
case KEY_BACKSPACE:
|
||||
case KEY_DC:
|
||||
@@ -304,9 +342,21 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
|
||||
inputbuf[strlen(inputbuf) - 1] = 0;
|
||||
}
|
||||
}
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
if (x > strlen(buf))
|
||||
x--;
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
break;
|
||||
#ifndef DISABLE_TABCOMP
|
||||
case NANO_CONTROL_I:
|
||||
if (allowtabs) {
|
||||
shift = 0;
|
||||
inputbuf = input_tab(inputbuf, (x - x_left),
|
||||
&tabbed, &shift);
|
||||
x += shift;
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case KEY_LEFT:
|
||||
if (x > strlen(buf))
|
||||
x--;
|
||||
@@ -322,17 +372,11 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
|
||||
switch (kbinput = wgetch(edit)) {
|
||||
case 70:
|
||||
x = x_left + strlen(inputbuf);
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
break;
|
||||
case 72:
|
||||
x = x_left;
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -350,10 +394,7 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
|
||||
break;
|
||||
case 49:
|
||||
x = x_left;
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
goto skip_126;
|
||||
case 51:
|
||||
if (strlen(inputbuf) > 0
|
||||
@@ -363,17 +404,11 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
|
||||
strlen(inputbuf) - (x - x_left) - 1);
|
||||
inputbuf[strlen(inputbuf) - 1] = 0;
|
||||
}
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
goto skip_126;
|
||||
case 52:
|
||||
x = x_left + strlen(inputbuf);
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
goto skip_126;
|
||||
skip_126:
|
||||
nodelay(edit, TRUE);
|
||||
@@ -384,27 +419,24 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
|
||||
break;
|
||||
}
|
||||
}
|
||||
blank_statusbar();
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
if (kbinput < 32)
|
||||
break;
|
||||
strcpy(inputstr, inputbuf);
|
||||
inputstr[x - strlen(buf)] = kbinput;
|
||||
strcpy(&inputstr[x - strlen(buf) + 1],
|
||||
&inputbuf[x - strlen(buf)]);
|
||||
strcpy(inputbuf, inputstr);
|
||||
|
||||
inputlen = strlen(inputbuf);
|
||||
inputbuf = nrealloc(inputbuf, inputlen + 2);
|
||||
|
||||
memmove(&inputbuf[x - x_left + 1],
|
||||
&inputbuf[x - x_left],
|
||||
inputlen - (x - x_left) + 1);
|
||||
inputbuf[x - x_left] = kbinput;
|
||||
|
||||
x++;
|
||||
|
||||
mvwaddstr(bottomwin, 0, 0, buf);
|
||||
waddstr(bottomwin, inputbuf);
|
||||
wmove(bottomwin, 0, x);
|
||||
|
||||
nanoget_repaint(buf, inputbuf, x);
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("input \'%c\' (%d)\n"), kbinput, kbinput);
|
||||
#endif
|
||||
@@ -412,9 +444,13 @@ int nanogetstr(char *buf, char *def, shortcut s[], int slen, int start_x)
|
||||
wrefresh(bottomwin);
|
||||
}
|
||||
|
||||
strncpy(answer, inputbuf, 132);
|
||||
answer = mallocstrcpy(answer, inputbuf);
|
||||
free(inputbuf);
|
||||
|
||||
if (!strcmp(answer, ""))
|
||||
/* Now that the text is editable instead of bracketed, we have to
|
||||
check for answer == def, instead of answer == "" */
|
||||
if (((ISSET(PICO_MODE)) && !strcmp(answer, "")) ||
|
||||
((!ISSET(PICO_MODE)) && !strcmp(answer, def)))
|
||||
return -2;
|
||||
else
|
||||
return 0;
|
||||
@@ -461,7 +497,7 @@ void onekey(char *keystroke, char *desc)
|
||||
{
|
||||
char description[80];
|
||||
|
||||
snprintf(description, 12, " %-11s", desc);
|
||||
snprintf(description, 12, " %-10s", desc);
|
||||
wattron(bottomwin, A_REVERSE);
|
||||
waddstr(bottomwin, keystroke);
|
||||
wattroff(bottomwin, A_REVERSE);
|
||||
@@ -624,112 +660,108 @@ void edit_add(filestruct * fileptr, int yval, int start, int virt_cur_x,
|
||||
#ifndef NANO_SMALL
|
||||
/* There are quite a few cases that could take place, we'll deal
|
||||
* with them each in turn */
|
||||
if (ISSET(MARK_ISSET)
|
||||
if (ISSET(MARK_ISSET)
|
||||
&& !((fileptr->lineno > mark_beginbuf->lineno
|
||||
&& fileptr->lineno > current->lineno)
|
||||
|| (fileptr->lineno < mark_beginbuf->lineno
|
||||
&& fileptr->lineno < current->lineno)))
|
||||
{
|
||||
/* If we get here we are on a line that is atleast
|
||||
* partially selected. The lineno checks above determined
|
||||
* that */
|
||||
if (fileptr != mark_beginbuf && fileptr != current) {
|
||||
/* We are on a completely marked line, paint it all
|
||||
* inverse */
|
||||
&& fileptr->lineno > current->lineno)
|
||||
|| (fileptr->lineno < mark_beginbuf->lineno
|
||||
&& fileptr->lineno < current->lineno))) {
|
||||
/* If we get here we are on a line that is atleast
|
||||
* partially selected. The lineno checks above determined
|
||||
* that */
|
||||
if (fileptr != mark_beginbuf && fileptr != current) {
|
||||
/* We are on a completely marked line, paint it all
|
||||
* inverse */
|
||||
wattron(edit, A_REVERSE);
|
||||
mvwaddnstr(edit, yval, 0, fileptr->data, COLS);
|
||||
wattroff(edit, A_REVERSE);
|
||||
} else if (fileptr == mark_beginbuf && fileptr == current) {
|
||||
/* Special case, we're still on the same line we started
|
||||
* marking -- so we call our helper function */
|
||||
if (virt_cur_x < virt_mark_beginx) {
|
||||
/* To the right of us is marked */
|
||||
add_marked_sameline(virt_cur_x, virt_mark_beginx,
|
||||
fileptr, yval, virt_cur_x, this_page);
|
||||
} else {
|
||||
/* To the left of us is marked */
|
||||
add_marked_sameline(virt_mark_beginx, virt_cur_x,
|
||||
fileptr, yval, virt_cur_x, this_page);
|
||||
}
|
||||
} else if (fileptr == mark_beginbuf) {
|
||||
/*
|
||||
* we're updating the line that was first marked
|
||||
* but we're not currently on it. So we want to
|
||||
* figur out which half to invert based on our
|
||||
* relative line numbers.
|
||||
*
|
||||
* i.e. If we're above the "beginbuf" line, we want to
|
||||
* mark the left side. Otherwise we're below, so we
|
||||
* mark the right
|
||||
*/
|
||||
int target;
|
||||
|
||||
if (mark_beginbuf->lineno > current->lineno)
|
||||
wattron(edit, A_REVERSE);
|
||||
mvwaddnstr(edit, yval, 0, fileptr->data, COLS);
|
||||
|
||||
target =
|
||||
(virt_mark_beginx <
|
||||
COLS - 1) ? virt_mark_beginx : COLS - 1;
|
||||
|
||||
mvwaddnstr(edit, yval, 0, fileptr->data, target);
|
||||
|
||||
if (mark_beginbuf->lineno < current->lineno)
|
||||
wattron(edit, A_REVERSE);
|
||||
else
|
||||
wattroff(edit, A_REVERSE);
|
||||
} else if (fileptr == mark_beginbuf && fileptr == current) {
|
||||
/* Special case, we're still on the same line we started
|
||||
* marking -- so we call our helper function */
|
||||
if (virt_cur_x < virt_mark_beginx) {
|
||||
/* To the right of us is marked */
|
||||
add_marked_sameline(virt_cur_x, virt_mark_beginx,
|
||||
fileptr, yval, virt_cur_x,
|
||||
this_page);
|
||||
} else {
|
||||
/* To the left of us is marked */
|
||||
add_marked_sameline(virt_mark_beginx, virt_cur_x,
|
||||
fileptr, yval, virt_cur_x,
|
||||
this_page);
|
||||
}
|
||||
} else if (fileptr == mark_beginbuf) {
|
||||
/*
|
||||
* we're updating the line that was first marked
|
||||
* but we're not currently on it. So we want to
|
||||
* figur out which half to invert based on our
|
||||
* relative line numbers.
|
||||
*
|
||||
* i.e. If we're above the "beginbuf" line, we want to
|
||||
* mark the left side. Otherwise we're below, so we
|
||||
* mark the right
|
||||
*/
|
||||
int target;
|
||||
|
||||
if (mark_beginbuf->lineno > current->lineno)
|
||||
wattron(edit, A_REVERSE);
|
||||
target = (COLS - 1) - virt_mark_beginx;
|
||||
if (target < 0)
|
||||
target = 0;
|
||||
|
||||
target =
|
||||
(virt_mark_beginx <
|
||||
COLS - 1) ? virt_mark_beginx : COLS - 1;
|
||||
mvwaddnstr(edit, yval, virt_mark_beginx,
|
||||
&fileptr->data[virt_mark_beginx], target);
|
||||
|
||||
mvwaddnstr(edit, yval, 0, fileptr->data, target);
|
||||
if (mark_beginbuf->lineno < current->lineno)
|
||||
wattroff(edit, A_REVERSE);
|
||||
|
||||
if (mark_beginbuf->lineno < current->lineno)
|
||||
wattron(edit, A_REVERSE);
|
||||
else
|
||||
wattroff(edit, A_REVERSE);
|
||||
} else if (fileptr == current) {
|
||||
/* we're on the cursors line, but it's not the first
|
||||
* one we marked. Similar to the previous logic. */
|
||||
int this_page_start = get_page_start_virtual(this_page),
|
||||
this_page_end = get_page_end_virtual(this_page);
|
||||
|
||||
target = (COLS - 1) - virt_mark_beginx;
|
||||
if (target < 0)
|
||||
target = 0;
|
||||
if (mark_beginbuf->lineno < current->lineno)
|
||||
wattron(edit, A_REVERSE);
|
||||
|
||||
mvwaddnstr(edit, yval, virt_mark_beginx,
|
||||
&fileptr->data[virt_mark_beginx], target);
|
||||
if (virt_cur_x > COLS - 2) {
|
||||
mvwaddnstr(edit, yval, 0,
|
||||
&fileptr->data[this_page_start],
|
||||
virt_cur_x - this_page_start);
|
||||
} else {
|
||||
mvwaddnstr(edit, yval, 0, fileptr->data, virt_cur_x);
|
||||
}
|
||||
|
||||
if (mark_beginbuf->lineno < current->lineno)
|
||||
wattroff(edit, A_REVERSE);
|
||||
if (mark_beginbuf->lineno > current->lineno)
|
||||
wattron(edit, A_REVERSE);
|
||||
else
|
||||
wattroff(edit, A_REVERSE);
|
||||
|
||||
} else if (fileptr == current) {
|
||||
/* we're on the cursors line, but it's not the first
|
||||
* one we marked. Similar to the previous logic. */
|
||||
int this_page_start = get_page_start_virtual(this_page),
|
||||
this_page_end = get_page_end_virtual(this_page);
|
||||
if (virt_cur_x > COLS - 2)
|
||||
mvwaddnstr(edit, yval, virt_cur_x - this_page_start,
|
||||
&fileptr->data[virt_cur_x],
|
||||
this_page_end - virt_cur_x);
|
||||
else
|
||||
mvwaddnstr(edit, yval, virt_cur_x,
|
||||
&fileptr->data[virt_cur_x], COLS - virt_cur_x);
|
||||
|
||||
if (mark_beginbuf->lineno < current->lineno)
|
||||
wattron(edit, A_REVERSE);
|
||||
|
||||
if (virt_cur_x > COLS - 2) {
|
||||
mvwaddnstr(edit, yval, 0,
|
||||
&fileptr->data[this_page_start],
|
||||
virt_cur_x - this_page_start);
|
||||
} else {
|
||||
mvwaddnstr(edit, yval, 0, fileptr->data, virt_cur_x);
|
||||
}
|
||||
|
||||
if (mark_beginbuf->lineno > current->lineno)
|
||||
wattron(edit, A_REVERSE);
|
||||
else
|
||||
wattroff(edit, A_REVERSE);
|
||||
|
||||
if (virt_cur_x > COLS - 2)
|
||||
mvwaddnstr(edit, yval, virt_cur_x - this_page_start,
|
||||
&fileptr->data[virt_cur_x],
|
||||
this_page_end - virt_cur_x);
|
||||
else
|
||||
mvwaddnstr(edit, yval, virt_cur_x,
|
||||
&fileptr->data[virt_cur_x],
|
||||
COLS - virt_cur_x);
|
||||
|
||||
if (mark_beginbuf->lineno > current->lineno)
|
||||
wattroff(edit, A_REVERSE);
|
||||
if (mark_beginbuf->lineno > current->lineno)
|
||||
wattroff(edit, A_REVERSE);
|
||||
}
|
||||
|
||||
} else
|
||||
#endif
|
||||
/* Just paint the string (no mark on this line) */
|
||||
/* Just paint the string (no mark on this line) */
|
||||
mvwaddnstr(edit, yval, 0, &fileptr->data[start],
|
||||
get_page_end_virtual(this_page) - start);
|
||||
get_page_end_virtual(this_page) - start + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -773,12 +805,16 @@ void update_line(filestruct * fileptr, int index)
|
||||
virt_cur_x++;
|
||||
if (i < mark_beginx)
|
||||
virt_mark_beginx++;
|
||||
} while (pos % TABSIZE);
|
||||
} while (pos % tabsize);
|
||||
/* must decrement once to account for tab-is-one-character */
|
||||
if (i < current_x)
|
||||
virt_cur_x--;
|
||||
if (i < mark_beginx)
|
||||
virt_mark_beginx--;
|
||||
} else if (realdata[i] >= 1 && realdata[i] <= 26) {
|
||||
/* Treat control characters as ^letter */
|
||||
fileptr->data[pos++] = '^';
|
||||
fileptr->data[pos++] = realdata[i] + 64;
|
||||
} else {
|
||||
fileptr->data[pos++] = realdata[i];
|
||||
}
|
||||
@@ -796,7 +832,7 @@ void update_line(filestruct * fileptr, int index)
|
||||
edit_add(filetmp, line, col, virt_cur_x, virt_mark_beginx, page);
|
||||
mvwaddch(edit, line, 0, '$');
|
||||
|
||||
if (strlenpt(fileptr->data) > get_page_end_virtual(page))
|
||||
if (strlenpt(fileptr->data) > get_page_end_virtual(page) + 1)
|
||||
mvwaddch(edit, line, COLS - 1, '$');
|
||||
} else {
|
||||
/* It's not the current line means that it's at x=0 and page=1 */
|
||||
@@ -822,7 +858,8 @@ void center_cursor(void)
|
||||
/* Refresh the screen without changing the position of lines */
|
||||
void edit_refresh(void)
|
||||
{
|
||||
int lines = 0, i = 0;
|
||||
static int noloop = 0;
|
||||
int lines = 0, i = 0, currentcheck = 0;
|
||||
filestruct *temp, *hold = current;
|
||||
|
||||
if (current == NULL)
|
||||
@@ -833,9 +870,19 @@ void edit_refresh(void)
|
||||
while (lines <= editwinrows - 1 && lines <= totlines && temp != NULL) {
|
||||
hold = temp;
|
||||
update_line(temp, current_x);
|
||||
if (temp == current)
|
||||
currentcheck = 1;
|
||||
|
||||
temp = temp->next;
|
||||
lines++;
|
||||
}
|
||||
/* If noloop == 1, then we already did an edit_update without finishing
|
||||
this function. So we don't run edit_update again */
|
||||
if (!currentcheck && !noloop) { /* Then current has run off the screen... */
|
||||
edit_update(current, CENTER);
|
||||
noloop = 1;
|
||||
} else if (noloop)
|
||||
noloop = 0;
|
||||
|
||||
if (lines <= editwinrows - 1)
|
||||
while (lines <= editwinrows - 1) {
|
||||
@@ -848,11 +895,21 @@ void edit_refresh(void)
|
||||
editbot = temp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Same as above, but touch the window first so everything is redrawn.
|
||||
*/
|
||||
void edit_refresh_clearok(void)
|
||||
{
|
||||
clearok(edit, TRUE);
|
||||
edit_refresh();
|
||||
clearok(edit, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Nice generic routine to update the edit buffer given a pointer to the
|
||||
* file struct =)
|
||||
*/
|
||||
void edit_update(filestruct * fileptr)
|
||||
void edit_update(filestruct * fileptr, int topmidbot)
|
||||
{
|
||||
int i = 0;
|
||||
filestruct *temp;
|
||||
@@ -861,10 +918,13 @@ void edit_update(filestruct * fileptr)
|
||||
return;
|
||||
|
||||
temp = fileptr;
|
||||
while (i <= editwinrows / 2 && temp->prev != NULL) {
|
||||
i++;
|
||||
temp = temp->prev;
|
||||
}
|
||||
if (topmidbot == 2);
|
||||
else if (topmidbot == 0)
|
||||
for (i = 0; i <= editwinrows - 1 && temp->prev != NULL; i++)
|
||||
temp = temp->prev;
|
||||
else
|
||||
for (i = 0; i <= editwinrows / 2 && temp->prev != NULL; i++)
|
||||
temp = temp->prev;
|
||||
|
||||
edittop = temp;
|
||||
fix_editbot();
|
||||
@@ -872,37 +932,6 @@ void edit_update(filestruct * fileptr)
|
||||
edit_refresh();
|
||||
}
|
||||
|
||||
/* Now we want to update the screen using this struct as the top of the edit buffer */
|
||||
void edit_update_top(filestruct * fileptr)
|
||||
{
|
||||
int i;
|
||||
filestruct *temp = fileptr;
|
||||
|
||||
if (fileptr == NULL)
|
||||
return;
|
||||
|
||||
i = 0;
|
||||
while (i <= editwinrows / 2 && temp->next != NULL) {
|
||||
i++;
|
||||
temp = temp->next;
|
||||
}
|
||||
edit_update(temp);
|
||||
}
|
||||
|
||||
/* And also for the bottom... */
|
||||
void edit_update_bot(filestruct * fileptr)
|
||||
{
|
||||
int i;
|
||||
filestruct *temp = fileptr;
|
||||
|
||||
i = 0;
|
||||
while (i <= editwinrows / 2 - 1 && temp->prev != NULL) {
|
||||
i++;
|
||||
temp = temp->prev;
|
||||
}
|
||||
edit_update(temp);
|
||||
}
|
||||
|
||||
/* This function updates current based on where current_y is, reset_cursor
|
||||
does the opposite */
|
||||
void update_cursor(void)
|
||||
@@ -931,8 +960,10 @@ void update_cursor(void)
|
||||
* global. Returns -1 on aborted enter, -2 on a blank string, and 0
|
||||
* otherwise, the valid shortcut key caught, Def is any editable text we
|
||||
* want to put up by default.
|
||||
*
|
||||
* New arg tabs tells whether or not to allow tab completion.
|
||||
*/
|
||||
int statusq(shortcut s[], int slen, char *def, char *msg, ...)
|
||||
int statusq(int tabs, shortcut s[], int slen, char *def, char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char foo[133];
|
||||
@@ -946,7 +977,7 @@ int statusq(shortcut s[], int slen, char *def, char *msg, ...)
|
||||
strncat(foo, ": ", 132);
|
||||
|
||||
wattron(bottomwin, A_REVERSE);
|
||||
ret = nanogetstr(foo, def, s, slen, (strlen(foo) + 3));
|
||||
ret = nanogetstr(tabs, foo, def, s, slen, (strlen(foo) + 3));
|
||||
wattroff(bottomwin, A_REVERSE);
|
||||
|
||||
switch (ret) {
|
||||
@@ -960,7 +991,7 @@ int statusq(shortcut s[], int slen, char *def, char *msg, ...)
|
||||
case NANO_CANCEL_KEY:
|
||||
return -1;
|
||||
default:
|
||||
blank_statusbar_refresh();
|
||||
blank_statusbar();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -1087,7 +1118,8 @@ int total_refresh(void)
|
||||
clearok(edit, FALSE);
|
||||
clearok(topwin, FALSE);
|
||||
clearok(bottomwin, FALSE);
|
||||
|
||||
edit_refresh();
|
||||
titlebar();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1191,7 +1223,8 @@ int do_help(void)
|
||||
for (i = 1; i < page; i++) {
|
||||
row = 0;
|
||||
j = 0;
|
||||
while (row < editwinrows && *ptr != '\0') {
|
||||
|
||||
while (row < editwinrows - 2 && *ptr != '\0') {
|
||||
if (*ptr == '\n' || j == COLS - 5) {
|
||||
j = 0;
|
||||
row++;
|
||||
@@ -1201,6 +1234,10 @@ int do_help(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (i > 1) {
|
||||
|
||||
}
|
||||
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (i < editwinrows && *ptr != '\0') {
|
||||
@@ -1229,7 +1266,6 @@ int do_help(void)
|
||||
continue;
|
||||
}
|
||||
} while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY);
|
||||
|
||||
if (no_help_flag) {
|
||||
werase(bottomwin);
|
||||
wrefresh(bottomwin);
|
||||
@@ -1287,10 +1323,143 @@ void dump_buffer_reverse(filestruct * inptr)
|
||||
}
|
||||
|
||||
/* Fix editbot based on the assumption that edittop is correct */
|
||||
void fix_editbot(void) {
|
||||
void fix_editbot(void)
|
||||
{
|
||||
int i;
|
||||
editbot = edittop;
|
||||
for(i = 0; (i <= editwinrows - 1) && (editbot->next != NULL)
|
||||
&& (editbot != filebot); i++, editbot = editbot->next);
|
||||
for (i = 0; (i <= editwinrows - 1) && (editbot->next != NULL)
|
||||
&& (editbot != filebot); i++, editbot = editbot->next);
|
||||
}
|
||||
|
||||
/* highlight the current word being replaced or spell checked */
|
||||
void do_replace_highlight(int highlight_flag, char *word)
|
||||
{
|
||||
char *highlight_word = NULL;
|
||||
int x, y;
|
||||
|
||||
highlight_word = mallocstrcpy(highlight_word, ¤t->data[current_x]);
|
||||
highlight_word[strlen(word)] = '\0';
|
||||
|
||||
/* adjust output when word extends beyond screen*/
|
||||
|
||||
x = xplustabs();
|
||||
y = get_page_end_virtual(get_page_from_virtual(x)) + 1;
|
||||
|
||||
if ((COLS - (y - x) + strlen(word)) > COLS) {
|
||||
highlight_word[y - x - 1] = '$';
|
||||
highlight_word[y - x] = '\0';
|
||||
}
|
||||
|
||||
/* OK display the output */
|
||||
|
||||
reset_cursor();
|
||||
|
||||
if (highlight_flag)
|
||||
wattron(edit, A_REVERSE);
|
||||
|
||||
waddstr(edit, highlight_word);
|
||||
|
||||
if (highlight_flag)
|
||||
wattroff(edit, A_REVERSE);
|
||||
|
||||
free(highlight_word);
|
||||
}
|
||||
|
||||
#ifdef NANO_EXTRA
|
||||
#define CREDIT_LEN 45
|
||||
void do_credits(void)
|
||||
{
|
||||
int i, j = 0, k, place = 0, start_x;
|
||||
char *what;
|
||||
|
||||
char *nanotext = _("The nano text editor");
|
||||
char *version = _("version ");
|
||||
char *brought = _("Brought to you by:");
|
||||
char *specialthx = _("Special thanks to:");
|
||||
char *fsf = _("The Free Software Foundation");
|
||||
char *ncurses = _("Pavel Curtis, Zeyd Ben-Halim and Eric S. Raymond for ncurses");
|
||||
char *anyonelse = _("and anyone else we forgot...");
|
||||
char *thankyou = _("Thank you for using nano!\n");
|
||||
|
||||
char *credits[CREDIT_LEN] = {nanotext,
|
||||
version,
|
||||
VERSION,
|
||||
"",
|
||||
brought,
|
||||
"Chris Allegretta",
|
||||
"Jordi Mallach",
|
||||
"Adam Rogoyski",
|
||||
"Rob Siemborski",
|
||||
"Rocco Corsi",
|
||||
"Ken Tyler",
|
||||
"Sven Guckes",
|
||||
"Florian König",
|
||||
"Pauli Virtanen",
|
||||
"Daniele Medri",
|
||||
"Clement Laforet",
|
||||
"Tedi Heriyanto",
|
||||
"Bill Soudan",
|
||||
"Christian Weisgerber",
|
||||
"Erik Anderson",
|
||||
"Big Gaute",
|
||||
"Joshua Jensen",
|
||||
"",
|
||||
specialthx,
|
||||
"Plattsburgh State University",
|
||||
"Benet Laboratories",
|
||||
"Amy Allegretta",
|
||||
"Linda Young",
|
||||
"Jeremy Robichaud",
|
||||
"Richard Kolb II",
|
||||
fsf,
|
||||
"Linus Torvalds",
|
||||
ncurses,
|
||||
anyonelse,
|
||||
thankyou,
|
||||
"", "", "", "",
|
||||
"(c) 2000 Chris Allegretta",
|
||||
"", "", "", "",
|
||||
"www.nano-editor.org"
|
||||
};
|
||||
|
||||
curs_set(0);
|
||||
nodelay(edit, TRUE);
|
||||
blank_bottombars();
|
||||
mvwaddstr(topwin, 0, 0, hblank);
|
||||
blank_edit();
|
||||
wrefresh(edit);
|
||||
wrefresh(bottomwin);
|
||||
wrefresh(topwin);
|
||||
|
||||
while (wgetch(edit) == ERR) {
|
||||
for (k = 0; k <= 1; k++) {
|
||||
blank_edit();
|
||||
for (i = editwinrows / 2 - 1; i >= (editwinrows / 2 - 1 - j); i--) {
|
||||
mvwaddstr(edit, i * 2 - k, 0, hblank);
|
||||
|
||||
if (place - (editwinrows / 2 - 1 - i) < CREDIT_LEN)
|
||||
what = credits[place - (editwinrows / 2 - 1 - i)];
|
||||
else
|
||||
what = "";
|
||||
|
||||
start_x = center_x - strlen(what) / 2 - 1;
|
||||
mvwaddstr(edit, i * 2 - k, start_x, what);
|
||||
}
|
||||
usleep(700000);
|
||||
wrefresh(edit);
|
||||
}
|
||||
if (j < editwinrows / 2 - 1)
|
||||
j++;
|
||||
|
||||
place++;
|
||||
|
||||
if (place >= CREDIT_LEN + editwinrows / 2)
|
||||
break;
|
||||
}
|
||||
|
||||
nodelay(edit, FALSE);
|
||||
curs_set(1);
|
||||
display_main_list();
|
||||
total_refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user