Compare commits

...

79 Commits

Author SHA1 Message Date
David Lawrence Ramsey
fb7a6bde7b GNU nano 1.3.11, with the version number fixed
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3330 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-30 06:37:00 +00:00
David Lawrence Ramsey
1856ec4425 GNU nano 1.3.11
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3328 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-30 06:34:43 +00:00
David Lawrence Ramsey
3c43d3d688 replace VERMSG #define with PACKAGE_STRING #define (as defined by
autoconf)


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3327 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-30 01:18:29 +00:00
David Lawrence Ramsey
1f479ee9fc more formatting fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3326 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-29 19:58:49 +00:00
David Lawrence Ramsey
804e107474 yet more cosmetic fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3325 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-29 19:43:32 +00:00
David Lawrence Ramsey
81bfd8244b typo fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3324 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-26 17:41:47 +00:00
David Lawrence Ramsey
12c08ddf6e more cosmetic fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3323 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-25 15:56:40 +00:00
David Lawrence Ramsey
e006c5131d cosmetic fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3322 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-25 15:23:55 +00:00
David Lawrence Ramsey
354597f0c2 in get_get_buffer(), die gracefully if input fails MAX_BUF_SIZE times,
not (MAX_BUF_SIZE + 1) times


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3321 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-24 16:04:44 +00:00
David Lawrence Ramsey
b8d9fb551b remove unneeded #include
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3320 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-24 15:55:34 +00:00
David Lawrence Ramsey
04716301e0 comment fix
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3319 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-24 15:32:52 +00:00
David Lawrence Ramsey
9efbdea09c fix breakage
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3318 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-24 05:36:16 +00:00
David Lawrence Ramsey
017dde2c81 formatting fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3317 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-24 05:28:03 +00:00
David Lawrence Ramsey
572207da79 formatting fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3316 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-24 04:22:45 +00:00
David Lawrence Ramsey
231158d61a in do_browser(), make old_selected a size_t too, to match selected
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3315 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-23 23:17:27 +00:00
David Lawrence Ramsey
20323a82be comment fix
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3314 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-23 22:14:40 +00:00
David Lawrence Ramsey
e6958d517d cosmetic fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3313 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-23 21:25:04 +00:00
David Lawrence Ramsey
27ad0cdb37 in do_browser(), make fileline and the static selected size_t's, since
the latter can hold the value of the former, and the former can be that
large


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3312 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-23 20:36:29 +00:00
David Lawrence Ramsey
9b33d51774 in get_key_buffer(), simplify the check for a lost input source, since
the errno check is unreliable


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3311 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-20 04:46:48 +00:00
David Lawrence Ramsey
ec8a055ffd cosmetic fix
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3310 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-19 19:26:52 +00:00
David Lawrence Ramsey
9149325400 in get_key_buffer(), if we fail to get a character over MAX_BUF_SIZE
times in a row, hang up regardless of the value of errno; this fixes a
problem where nano doesn't terminate properly under xterm if the user
su's to root, runs nano, and then closes the terminal window


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3309 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-19 19:25:29 +00:00
David Lawrence Ramsey
1ec74ee30c remove unneeded blank line
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3308 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-19 19:14:30 +00:00
David Lawrence Ramsey
7a27f68c5c preemptively update the version number
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3307 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-16 19:31:18 +00:00
David Lawrence Ramsey
5115fa6767 in faq.html, change the character set to UTF-8, and remove broken links
to contributed RedHat nano packages


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3306 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-16 19:30:52 +00:00
David Lawrence Ramsey
167a4b7f9c in faq.html, update the Free Translation Project's address
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3305 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-16 19:16:28 +00:00
David Lawrence Ramsey
7369c75828 remove erroneous assert
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3304 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-16 17:45:12 +00:00
Jordi Mallach
6ac73c9408 Update Swedish credits.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3303 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-15 22:44:43 +00:00
Jordi Mallach
20494f514c Update Swedish from the TP.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3302 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-15 22:40:01 +00:00
David Lawrence Ramsey
ee150506d8 cosmetic fix
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3301 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-12 19:47:48 +00:00
David Lawrence Ramsey
05454cfb75 preemptively update the version numbers of all manpages, and remove
unneeded comments from rnano.1


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3300 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-12 19:34:22 +00:00
David Lawrence Ramsey
3e7821006d mention that quotes inside string parameters don't need to be escaped
with backslashes in nanorc.5 and nanorc.sample


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3299 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-12 19:27:32 +00:00
Jordi Mallach
535dc9cd13 Updated Vietnamese translation by Phan Vinh Thinh.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3298 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-03-06 17:59:32 +00:00
David Lawrence Ramsey
ac0361df6e in do_writeout(), remove unneeded setting of currshortcut
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3297 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-24 19:38:20 +00:00
David Lawrence Ramsey
6816007242 make sure browser_refresh() is used when refreshing or doing tab
completion at the prompt in the file browser


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3296 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-18 21:32:29 +00:00
David Lawrence Ramsey
1f907c7413 rename browser_draw() to browser_refresh() for consistency
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3295 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-10 19:02:30 +00:00
David Lawrence Ramsey
d83af2fea7 fix file browser breakage
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3294 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-10 03:27:48 +00:00
David Lawrence Ramsey
d4bae13d8d move the browser drawing routines to a separate function, browser_draw()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3293 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-09 23:26:26 +00:00
David Lawrence Ramsey
a8a9050083 really fix input parsing in the file browser
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3292 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-09 22:53:54 +00:00
David Lawrence Ramsey
8326254643 go back to using a while loop in get_prompt_string(), as it's simpler
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3291 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-09 22:42:14 +00:00
David Lawrence Ramsey
162ed2af24 in get_prompt_string(), initialize finished to FALSE so that the
do/while loop works properly


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3290 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-09 22:35:04 +00:00
David Lawrence Ramsey
3326603341 in get_prompt_string(), redraw the prompt and set finished to FALSE when
NANO_HELP_KEY is pressed, so that we don't leave the prompt, enter the
help browser, and restart the prompt after leaving it; this will
properly preserve the cursor position after doing the last of these


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3289 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-09 21:43:14 +00:00
David Lawrence Ramsey
08f4974093 in shortcut_init(), remove erroneous handling of the "Get Help" shortcut
in the file browser shortcut list


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3288 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-08 20:33:45 +00:00
David Lawrence Ramsey
591c409f3f in get_prompt_string(), use a do/while loop instead of a while loop, for
consistency


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3287 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-08 20:14:49 +00:00
David Lawrence Ramsey
c0dcdf43c6 in do_browser(), properly restore the file list display after returning
from the help browser at the "Go To Directory" prompt, and rename
variable j to i, for consistency


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3286 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-08 19:27:02 +00:00
David Lawrence Ramsey
47d917eea7 remove redundant code
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3285 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-08 05:16:32 +00:00
David Lawrence Ramsey
8a1a886fbe add another missing blank line
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3284 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-08 05:01:58 +00:00
David Lawrence Ramsey
5443b46241 add missing blank lines
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3283 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-08 04:02:30 +00:00
David Lawrence Ramsey
9b268c2ebf fix compilation problem
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3282 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-07 21:16:46 +00:00
David Lawrence Ramsey
33f2a08b5c update copyright years
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3281 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-07 21:11:49 +00:00
David Lawrence Ramsey
9d8c284135 allow tab completion of directories at the "Go To Directory" prompt
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3280 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-07 21:11:05 +00:00
David Lawrence Ramsey
ef9dc83a4b fix file browser breakage
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3279 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-07 20:10:28 +00:00
David Lawrence Ramsey
3d8d29d08a another formatting fix
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3278 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-07 18:35:26 +00:00
David Lawrence Ramsey
fc8e5cb0f2 cosmetic and formatting fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3277 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-07 18:32:22 +00:00
David Lawrence Ramsey
24e0a465c1 in do_browser(), properly set currshortcut back to the file browser
shortcut list after a "Go To Directory" prompt


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3276 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-07 05:14:55 +00:00
David Lawrence Ramsey
91a2a69c4f rework input parsing in the file browser to be more flexible
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3275 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-07 04:41:44 +00:00
David Lawrence Ramsey
9ffe78aa57 update copyright years
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3274 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-03 18:59:17 +00:00
David Lawrence Ramsey
99e3733fc6 fix changelog entry
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3273 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-03 04:02:25 +00:00
David Lawrence Ramsey
114cfb63f4 in display_string(), fix memory corruption problems caused by not
allocating enough space for converted when a line ends in a tab(s) and
we're not in UTF-8 mode


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3272 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-03 03:58:49 +00:00
David Lawrence Ramsey
1f104f8079 fix a comment in nano.h and a minor memory leak in display_string()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3271 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-03 03:51:51 +00:00
David Lawrence Ramsey
66d3ebf6a6 fix potential infinite loop in mbrevstrpbrk()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3270 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-02-02 22:30:40 +00:00
David Lawrence Ramsey
3a5e6f9317 handle Shift-Delete properly when the -d option is used
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3266 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-30 21:23:51 +00:00
David Lawrence Ramsey
475c402b65 in parse_kbinput(), interpret Shift-Begin, Shift-Delete, Shift-End,
Shift-Home, Shift-Insert, and Shift-Suspend as Begin, Delete, End, Home,
Insert, and Suspend, respectively, regardless of whether --rebindkeypad
is used


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3265 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-30 01:32:41 +00:00
David Lawrence Ramsey
4a2e0000f7 fix more bracket matching breakage
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3264 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-28 06:04:59 +00:00
David Lawrence Ramsey
a6eb8480ea really fix the previous display problem with searches that move the
cursor offscreen and from a page other than the first one onto a
different page by reverting the erroneous change to edit_scroll() and
adding the proper fix to edit_redraw()


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3263 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-10 07:51:49 +00:00
David Lawrence Ramsey
76f9485b02 in ngetdelim(), do sanity checks manually again instead of in an assert,
and set errno to EINVAL as well as return -1 if they fail; this matches
the manual page


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3262 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-09 03:23:29 +00:00
David Lawrence Ramsey
db2dc81cee fix multibyte bracket search breakage, and add documentation fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3261 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-06 22:35:52 +00:00
David Lawrence Ramsey
1a16df9284 fix "matchbrackets" breakage
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3260 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-06 22:04:38 +00:00
David Lawrence Ramsey
d89617fb17 allow specifying matching bracket characters other than the default via
the "matchbrackets" rcfile option


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3259 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-06 21:51:10 +00:00
David Lawrence Ramsey
a248863b43 rework the bracket searching code to handle multibyte bracket characters
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3258 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-06 07:10:30 +00:00
David Lawrence Ramsey
5978f9b11d in mbstrchr(), make parameter c const
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3257 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-06 05:54:44 +00:00
David Lawrence Ramsey
5329f23345 sort the default strings for brackets and punct, and the "or" atom in
the default regex string for quotestr, in order according to ASCII, and
add minor related documentation updates


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3256 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-03 04:53:41 +00:00
David Lawrence Ramsey
cb475886b1 clarify another comment
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3255 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-02 17:09:35 +00:00
David Lawrence Ramsey
47cfd197b8 in edit_scroll(), redraw the lines before and after the scrolled region
even if the scrolled region was only one line; this fixes a display
problem that occurs after doing a search that scrolls the screen down
one line and leaves the cursor on the last line of the screen, in which
case we need to update the line after the scrolled region


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3254 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2006-01-02 04:30:33 +00:00
David Lawrence Ramsey
5b7b3e3c9c cosmetic fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3253 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2005-12-31 21:22:54 +00:00
David Lawrence Ramsey
30bdadd4d5 revert previous erroneous change, and clarify comments
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3252 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2005-12-31 21:08:10 +00:00
David Lawrence Ramsey
89b6e6b9dd in justify_format(), remove redundant character parsing
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3251 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2005-12-31 20:37:56 +00:00
David Lawrence Ramsey
ce029f2b11 remove unnecessary #ifdef around termios.h #include in nano.c
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3250 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2005-12-28 05:01:00 +00:00
David Lawrence Ramsey
1e73bcfe29 fix inaccurate comment
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3249 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2005-12-23 20:18:06 +00:00
David Lawrence Ramsey
da959919fc Back to CVS
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3248 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2005-12-23 16:15:34 +00:00
27 changed files with 2811 additions and 2350 deletions

120
ChangeLog
View File

@@ -1,3 +1,118 @@
GNU nano 1.3.11 - 2006.03.30
- General:
- Miscellaneous comment fixes. (DLR)
- Remove unnecessary #ifdef around termios.h #include in nano.c.
(DLR)
- Sort the default strings for brackets and punct, and the "or"
atom in the default regex string for quotestr, according to
ASCII. Changes to main(), nano.1, nanorc.5, and
nanorc.sample. (DLR)
- Rework the bracket searching code to handle multibyte bracket
characters, and allow specifying matching bracket characters
other than the default via the "matchbrackets" rcfile option.
New functions mbstrpbrk() and mbrevstrpbrk(); changes to
find_statusbar_bracket_match(), do_statusbar_find_bracket(),
find_bracket_match(), do_find_bracket(), main(),
parse_rcfile(), nanorc.5, and nanorc.sample. (DLR)
- Rework input parsing in the file browser to be more flexible.
New function parse_browser_input(); changes to do_browser().
(DLR)
- Allow tab completion of directories at the "Go To Directory"
prompt. Also, move the browser drawing routines to a separate
function, and make sure it's used when refreshing or doing tab
completion at the prompt in the file browser. New function
browser_refresh(); changes to do_browser(), browser_init(),
do_insertfile(), do_writeout(), cwd_tab_completion(),
input_tab(), do_statusbar_input(), get_prompt_string(),
do_prompt(), search_init(), do_replace(), do_gotolinecolumn(),
and do_int_spell_fix(). (DLR)
- browser.c:
do_browser()
- Properly set currshortcut back to the file browser shortcut
list after a "Go To Directory" prompt, and properly restore
the file list display after returning from the help browser at
the "Go To Directory" prompt. (DLR)
- Rename variable j to i, for consistency. (DLR)
- Make fileline, old_selected, and the static selected size_t's,
since the first and second can hold the value of the third,
and the first can be that large. (DLR)
- chars.c:
mbstrchr()
- Make parameter c const. (DLR)
- files.c:
do_writeout()
- Remove unneeded setting of currshortcut. (DLR)
is_dir()
- Rename parameter ret to retval, for consistency. (DLR)
- global.c:
shortcut_init()
- Remove erroneous handling of the "Get Help" shortcut in the
file browser shortcut list. (DLR)
- nano.h:
- Remove now-unneeded VERMSG #define. (DLR)
- prompt.c:
get_prompt_string()
- Redraw the prompt and set finished to FALSE when NANO_HELP_KEY
is pressed, so that we don't leave the prompt, enter the help
browser, and restart the prompt after leaving it. This will
properly preserve the cursor position after doing the last of
these. (DLR)
- utils.c:
ngetdelim()
- Do sanity checks manually again instead of in an assert, and
set errno to EINVAL as well as return -1 if they fail. This
matches the manual page. (DLR)
- winio.c:
get_key_buffer()
- If we fail to get a character MAX_BUF_SIZE times in a row,
hang up regardless of the value of errno. This fixes a
problem where nano doesn't terminate properly under xterm if
the user su's to root, runs nano, and then closes the terminal
window. errno isn't set properly to EIO then. (DLR, found by
John <acocaracha@gmail.com>)
parse_kbinput()
- Interpret Shift-Begin, Shift-Delete, Shift-End, Shift-Home,
Shift-Insert, and Shift-Suspend as Begin, Delete, End, Home,
Insert, and Suspend, respectively, regardless of whether
--rebindkeypad is used. (DLR, found by David Benbennick)
titlebar()
- Use PACKAGE_STRING, as defined by autoconf, instead of VERMSG.
(DLR)
edit_redraw()
- If either current or old_current is offscreen, we're not on
the first page, and/or we're not on the same page as before,
update old_current before scrolling the edit window. This
fixes a potential display problem when a search moves the
cursor offscreen and onto a different page. (DLR, found by
Mike Frysinger)
display_string()
- Fix minor memory leak. (DLR)
- Fix memory corruption problems caused by not allocating enough
space for converted when a line ends in a tab(s) and we're not
in UTF-8 mode. (DLR, found by Duncan Geoffry Doyle, Nick
Warne, and Mike Frysinger)
- doc/faq.html:
- Update the Free Translation Project's address, change the
character set to UTF-8, and remove broken links to contributed
RedHat nano packages. (DLR)
- doc/nano.1:
- Better display the default values for quotestr. (DLR)
- doc/nanorc.5:
- Give the default values for the brackets and punct options,
and better display the default values for quotestr. (DLR)
- Mention that quotes inside string parameters don't need to be
escaped with backslashes. (John M. Gabriele, minor tweaks by
DLR)
- doc/rnano.1:
- Remove unneeded comments. (DLR)
- doc/nanorc.sample:
- Remove unneeded comment. (DLR)
- Mention that quotes inside string parameters don't need to be
escaped with backslashes. (John M. Gabriele, minor tweaks by
DLR)
- THANKS:
- Add new Swedish translator.
GNU nano 1.3.10 - 2005.12.23
- General:
- Miscellaneous comment fixes. (DLR)
@@ -2135,7 +2250,8 @@ GNU nano 1.3.5 - 2004.11.22
glib 2.x on systems that may not have it installed. (DLR,
suggested by Jordi)
- src/Makefile.am:
- Don't use DEFS to define things. Use INCLUDES instead. (Jordi)
- Don't use DEFS to define things. Use INCLUDES instead.
(Jordi)
GNU nano 1.3.4 - 2004.08.17
- General:
@@ -4920,7 +5036,7 @@ GNU nano 1.1.7 - 03/05/2002
- Preliminary quoting support for justify. New arg -Q, --quotestr,
changes to do_justify(), global variable quotestr().
- Makefile.am:
- Add SYSCONFDIR to DEFS, so we can have an $SYSCONFDIR/nanorc.
- Add SYSCONFDIR to DEFS, so we can have a $SYSCONFDIR/nanorc.
- Change localedir line to 1.0's version.
- Moved m4/ stuff to its own m4/Makefile.am.
- m4/aclocal_inc.m4:

16
NEWS
View File

@@ -1,3 +1,17 @@
2006.03.30 - GNU nano 1.3.11 awakens from its fever dream. This release
focuses mostly on bugfixes, which include better
handling of the cursor at the statusbar prompt, support
for certain combinations of Shift and keyboard keys in
both normal and --rebind-keypad mode, a fix for a minor
display problem after some searches, a real fix for a
long-standing segfault when displaying overly long
lines, and a real fix for nano's not hanging up properly
in xterm under certain circumstances. There are also
several new features, such as the ability to set the
characters used as brackets when searching for matching
brackets, and tab completion of directories at the "Go
To Directory" prompt. Have fun.
2005.12.23 - GNU nano 1.3.10 rises to the surface. This release
contains several new features as well as fixes for
several longstanding bugs. The former include the
@@ -361,7 +375,7 @@
shows column as well as character position, and
multibuffer allows duplicate files, even unnamed ones.
Also, the static shortcut and toggle lengths are
history, nano now reads $SYSCONFDIR/nanorc if rc file
history, nano now reads SYSCONFDIR/nanorc if rc file
support is enabled, and nano is now built with (and
requires for rebuilding) autoconf 2.5.
This release also includes fixes for some memory

1
THANKS
View File

@@ -26,6 +26,7 @@ Clement Laforet <clem_laf@wanadoo.fr> French translator
Gergely Nagy <algernon@debian.org> Hungarian translator
Kalle Olavi Niemitalo <kon@iki.fi> Finnish Translator
Claudio Neves <cneves@nextis.com> Brazilian Portuguese translator
Daniel Nylander <po@danielnylander.se> Swedish Translator
Michael Piefel <piefel@informatik.hu-berlin.de> German translator
Sergey A. Ribalchenko <fisher@obu.ck.ua> Russian, Ukrainian translator
Michel Robitaille <robitail@IRO.UMontreal.CA> French translator

View File

@@ -19,7 +19,7 @@
#
# $Id$
AC_INIT([GNU nano], [1.3.10], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [1.3.11], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_TARGET([])
AM_INIT_AUTOMAKE

View File

@@ -2,7 +2,7 @@
<html>
<head>
<title>The GNU nano editor FAQ</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
<h1>The GNU nano editor FAQ</h1>
@@ -82,7 +82,7 @@
<h2><a name="1.5"></a>1.5. Why the name change from TIP?</h2>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h2><a name="1.6"></a>1.6. What is the current version of nano?</h2>
<blockquote><p>The current version of nano *should* be 1.3.10. Of course you should always check the nano homepage to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano *should* be 1.3.11. Of course you should always check the nano homepage to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.7"></a>1.7. I want to read the man page without having to download the program!</h2>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="http://www.nano-editor.org/dist/v1.3/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
@@ -101,11 +101,6 @@
<li><a href="http://www.nano-editor.org/dist/v1.2/RPMS/">http://www.nano-editor.org/dist/v1.2/RPMS/</a></li>
<li><a href="http://www.ewtoo.org/~astyanax/nano/dist/v1.2/RPMS/">http://www.ewtoo.org/~astyanax/nano/dist/v1.2/RPMS/</a></li>
</ul>
<p>Additionally, check out the RedHat contribs section at:</p>
<ul>
<li><a href="http://distro.ibiblio.org/pub/Linux/distributions/redhat/contrib/libc6/i386/">http://distro.ibiblio.org/pub/Linux/distributions/redhat/contrib/libc6/i386/</a></li>
<li><a href="ftp://distro.ibiblio.org/pub/Linux/distributions/redhat/contrib/libc6/i386/">ftp://distro.ibiblio.org/pub/Linux/distributions/redhat/contrib/libc6/i386/</a></li>
</ul>
</blockquote>
<h2><a name="2.3"></a>2.3. Debian (.deb) packages.</h2>
<blockquote><p>Debian users can check out the current nano packages for:</p>
@@ -217,8 +212,8 @@
<hr width="100%">
<h1><a name="5"></a>5. Internationalization</h1>
<h2><a name="5.1"></a>5.1. There's no translation for my language!</h2>
<blockquote><p>On June of 2001, GNU nano entered the <a href="http://www.iro.umontreal.ca/contrib/po/HTML/">Free Translation Project</a> and since then, translations should be managed from there.</p>
<p>If there isn't a translation for your language, you could ask <a href="http://www.iro.umontreal.ca/contrib/po/HTML/teams.html">your language team</a> to translate nano, or better still, join your team and do it yourself. Joining a team is easy. You just need to ask the <a href="mailto:translation@iro.umontreal.ca">TP coordinator</a> to add you to your team, and send a <a href="http://www.iro.umontreal.ca/contrib/po/HTML/disclaim.html">translation disclaimer to the FSF</a> (this is necessary as nano is an official GNU package, but it does <b>not</b> mean that you transfer the rights of your work to the FSF, it's just so the FSF can legally manage them).</p>
<blockquote><p>On June of 2001, GNU nano entered the <a href="http://www.iro.umontreal.ca/translation/HTML/">Free Translation Project</a> and since then, translations should be managed from there.</p>
<p>If there isn't a translation for your language, you could ask <a href="http://www.iro.umontreal.ca/translation/HTML/teams.html">your language team</a> to translate nano, or better still, join your team and do it yourself. Joining a team is easy. You just need to ask the <a href="mailto:translation@iro.umontreal.ca">TP coordinator</a> to add you to your team, and send a <a href="http://www.iro.umontreal.ca/translation/HTML/disclaim.html">translation disclaimer to the FSF</a> (this is necessary as nano is an official GNU package, but it does <b>not</b> mean that you transfer the rights of your work to the FSF, it's just so the FSF can legally manage them).</p>
<p>In any case, translating nano is very easy. 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. When you're done, you should send it to the TP's central po repository.</p></blockquote>
<h2><a name="5.2"></a>5.2. I don't like the translation for &lt;x&gt; in my language. How can I fix it?</h2>
<blockquote><p>The best way would probably be to e-mail the person listed in the <code>Last-Translator:</code> field in the <b>&lt;your_language&gt;.po</b> file with your suggested corrections and they can make the changes reach the nano-devel list.</p></blockquote>
@@ -255,7 +250,8 @@
<blockquote><p>Re-read Section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
<h2><a name="8"></a>8. ChangeLog</h2>
<blockquote>
<p>2005/11/21 - Clarify section 5.3 to better explain how to enable Unicode support, and remove the mention of quirks, since they turned out to not be a nano problem. (Mike Frysinger and DLR)<br>
<p>2006/03/16 - Update the Free Translation Project's address, change the character set to UTF-8, and remove broken links to contributed RedHat nano packages. (DLR)<br>
2005/11/21 - Clarify section 5.3 to better explain how to enable Unicode support, and remove the mention of quirks, since they turned out to not be a nano problem. (Mike Frysinger and DLR)<br>
2005/11/19 - Add a new section 5.3 to explain the status of nano's Unicode support. (Mike Frysinger, minor tweaks by DLR)<br>
2005/08/27 - Update email address. (DLR)<br>
2005/08/10 - Add a new section 4.3, and move all section 4 entries after it down one number, to explain how to deal with numeric keypad problems. (DLR)<br>

View File

@@ -6,7 +6,7 @@
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
.TH NANO 1 "version 1.3.10" "November 21, 2005"
.TH NANO 1 "version 1.3.11" "March 12, 2006"
.\" Please adjust this date whenever revising the manpage.
.\"
@@ -84,8 +84,8 @@ Use the blank line below the titlebar as extra editing space.
.TP
.B \-Q \fIstr\fP (\-\-quotestr=\fIstr\fP)
Set the quoting string for justifying. The default is
"^([\ \\t]*[|>:}#])+" if regular expression support is available, or
">\ " otherwise.
"\fI^([\ \\t]*[#:>\\|}])+\fP" if regular expression support is
available, or "\fI>\ \fP" otherwise.
.TP
.B \-R (\-\-restricted)
Restricted mode: Don't read or write to any file not specified on the

View File

@@ -6,7 +6,7 @@
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
.TH NANORC 5 "version 1.3.10" "November 21, 2005"
.TH NANORC 5 "version 1.3.11" "March 12, 2006"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
@@ -37,6 +37,11 @@ line options override rcfile settings.
Options are unset by default, except for options that take an argument.
Quotes inside string parameters don't have to be escaped with
backslashes. The last double quote in the string will be treated as its
end. For example, for the brackets option, "\fI"')>]}\fP" will match
\fI"\fP, \fI'\fP, \fI)\fP, \fI>\fP, \fI]\fP, and \fI}\fP.
The supported commands and arguments are:
.TP 3
@@ -56,7 +61,8 @@ Do backwards searches by default.
.B set brackets "\fIstring\fP"
Set the characters treated as closing brackets. They cannot contain
blank characters. Only closing punctuation, optionally followed by
closing brackets, can end sentences.
closing brackets, can end sentences. The default value is
"\fI"')>]}\fP".
.TP
.B set/unset casesensitive
Do case sensitive searches by default.
@@ -76,6 +82,12 @@ default value is -8.
Enable \fI~/.nano_history\fP for saving and reading search/replace
strings.
.TP
.B set matchbrackets "\fIstring\fP"
Set the opening and closing brackets that can be found by bracket
searches. They cannot contain blank characters. The former set must
come before the latter set, and both must be in the same order. The
default value is "\fI(<[{)>]}\fP".
.TP
.B set/unset morespace
Allow use of the blank line below the titlebar as extra editing space.
.TP
@@ -113,7 +125,7 @@ Preserve the XON and XOFF keys (^Q and ^S).
.B set punct "\fIstring\fP"
Set the characters treated as closing punctuation. They cannot contain
blank characters. Only closing punctuation, optionally followed by
closing brackets, can end sentences.
closing brackets, can end sentences. The default value is "\fI!.?\fP".
.TP
.B set/unset quickblank
Do quick statusbar blanking. Statusbar messages will disappear after 1
@@ -123,11 +135,8 @@ keystroke instead of 25.
The email-quote string, used to justify email-quoted paragraphs. This
is an "extended regular expression" if your system supports them,
otherwise a literal string. The default value is
set quotestr "^([\ \\t]*[|>:}#])+"
if you have regexps, otherwise set quotestr ">\ ". Note that '\\t'
above stands for a literal Tab character.
"\fI^([\ \\t]*[#:>\\|}])+\fP" if you have regexps, or "\fI>\ \fP"
otherwise. Note that '\\t' stands for a literal Tab character.
.TP
.B set/unset rebinddelete
Interpret the Delete key differently so that both Backspace and Delete

View File

@@ -6,11 +6,8 @@
.\" 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)
.\" $Id$
.TH RNANO 1 "version 1.3.10" "November 23, 2005"
.TH RNANO 1 "version 1.3.11" "March 12, 2005"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME

View File

@@ -1,4 +1,5 @@
## Sample initialization file for GNU nano
## Sample initialization file for GNU nano.
##
## Please note that you must have configured nano with --enable-nanorc
## for this file to be read! Also note that characters specially
## interpreted by the shell should not be escaped here.
@@ -7,6 +8,11 @@
##
## For the options that take parameters, the default value is given.
## Other options are unset by default.
##
## Quotes inside string parameters don't have to be escaped with
## backslashes. The last double quote in the string will be treated as
## its end. For example, for the brackets option, ""')>]}" will match
## ", ', ), >, ], and }.
## Use auto-indentation.
# set autoindent
@@ -24,7 +30,7 @@
## blank characters. Only closing punctuation, optionally followed by
## closing brackets, can end sentences.
##
# set brackets "'")}]>"
# set brackets ""')>]}"
## Do case sensitive searches by default.
# set casesensitive
@@ -45,6 +51,12 @@
## Enable ~/.nano_history for saving and reading search/replace strings.
# set historylog
## The opening and closing brackets that can be found by bracket
## searches. They cannot contain blank characters. The former set must
## come before the latter set, and both must be in the same order.
##
# set matchbrackets "(<[{)>]}"
## Use the blank line below the titlebar as extra editing space.
# set morespace
@@ -87,7 +99,7 @@
## blank characters. Only closing punctuation, optionally followed by
## closing brackets, can end sentences.
##
# set punct ".?!"
# set punct "!.?"
## Do quick statusbar blanking. Statusbar messages will disappear after
## 1 keystroke instead of 25. Note that "const" cancels this out.
@@ -97,11 +109,9 @@
## The email-quote string, used to justify email-quoted paragraphs.
## This is an extended regular expression if your system supports them,
## otherwise a literal string. Default:
# set quotestr "^([ ]*[\|>:}#])+"
# set quotestr "^([ ]*[#:>\|}])+"
## if you have regexps, otherwise:
# set quotestr "> "
## You can get old nano quoted-justify behavior via:
# set quotestr "(> )+"
## Fix Backspace/Delete confusion problem.
# set rebinddelete
@@ -333,7 +343,7 @@
## highlight possible errors and parameters
# icolor brightwhite "^[[:space:]]*(set|unset|syntax|i?color).*$"
## set, unset and syntax
# icolor cyan "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|brackets|casesensitive|const|cut|fill|historylog|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct|quickblank)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace|wordbounds)\>"
# icolor cyan "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct|quickblank)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace|wordbounds)\>"
# icolor green "^[[:space:]]*(set|unset|syntax)\>"
## colors
# icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"

View File

@@ -1,3 +1,12 @@
2005-03-15 Jordi Mallach <jordi@gnu.org>
* sv.po: Updated Swedish translation by Daniel Nylander.
2005-03-06 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Vietnamese translation by
Phan Vinh Thinh.
2005-12-21 Jordi Mallach <jordi@gnu.org>
* bg.po: Updated Bulgarian translation by Anton Zinoviev.

1692
po/sv.po

File diff suppressed because it is too large Load Diff

1725
po/vi.po

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
* browser.c *
* *
* Copyright (C) 2001-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -30,25 +30,35 @@
#ifndef DISABLE_BROWSER
static char **filelist = NULL;
/* The list of files to display in the browser. */
static size_t filelist_len = 0;
/* The number of files in the list. */
static int width = 0;
/* The number of columns to display the list in. */
static int longest = 0;
/* The number of columns in the longest filename in the list. */
static size_t selected = 0;
/* The currently selected filename in the list. */
/* Our browser function. path is the path to start browsing from.
* Assume path has already been tilde-expanded. */
char *do_browser(char *path, DIR *dir)
{
int kbinput, longest, selected, width;
bool meta_key, func_key, old_const_update = ISSET(CONST_UPDATE);
size_t numents;
char **filelist, *retval = NULL;
int kbinput;
bool meta_key, func_key;
bool old_const_update = ISSET(CONST_UPDATE);
char *ans = mallocstrcpy(NULL, "");
/* The last answer the user typed on the statusbar. */
char *retval = NULL;
curs_set(0);
blank_statusbar();
bottombars(browser_list);
wnoutrefresh(bottomwin);
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
/* Set currshortcut so the user can click in the shortcut area, and
* so the browser help screen will come up. */
currshortcut = browser_list;
#endif
bottombars(browser_list);
wnoutrefresh(bottomwin);
UNSET(CONST_UPDATE);
@@ -56,8 +66,10 @@ char *do_browser(char *path, DIR *dir)
/* We go here after the user selects a new directory. */
kbinput = ERR;
selected = 0;
meta_key = FALSE;
func_key = FALSE;
width = 0;
selected = 0;
path = mallocstrassn(path, get_full_path(path));
@@ -65,22 +77,20 @@ char *do_browser(char *path, DIR *dir)
assert(path != NULL && path[strlen(path) - 1] == '/');
/* Get the list of files. */
filelist = browser_init(path, &longest, &numents, dir);
browser_init(path, dir);
assert(filelist != NULL);
/* Sort the list. */
qsort(filelist, numents, sizeof(char *), diralphasort);
qsort(filelist, filelist_len, sizeof(char *), diralphasort);
titlebar(path);
do {
bool abort = FALSE;
int j, col = 0, editline = 0, fileline;
int filecols = 0;
/* Used only if width == 0, to calculate the number of files
* per row below. */
struct stat st;
int i;
size_t fileline;
char *new_path;
/* Used by the "Go To Directory" prompt. */
#ifndef DISABLE_MOUSE
@@ -90,7 +100,7 @@ char *do_browser(char *path, DIR *dir)
check_statusblank();
/* Compute the line number we're on now, so that we don't divide
* by zero later. */
* by 0. */
fileline = selected;
if (width != 0)
fileline /= width;
@@ -104,16 +114,16 @@ char *do_browser(char *path, DIR *dir)
/* If we clicked in the edit window, we probably clicked
* on a file. */
if (wenclose(edit, mevent.y, mevent.x)) {
int old_selected = selected;
size_t old_selected = selected;
/* Subtract out the size of topwin. */
mevent.y -= 2 - no_more_space();
/* longest is the width of each column. There are
* two spaces between each column. */
selected = (fileline / editwinrows) * editwinrows *
width + mevent.y * width + mevent.x /
(longest + 2);
selected = (fileline / editwinrows) * (editwinrows *
width) + (mevent.y * width) + (mevent.x /
(longest + 2));
/* If they clicked beyond the end of a row, select
* the end of that row. */
@@ -123,10 +133,11 @@ char *do_browser(char *path, DIR *dir)
/* If we're off the screen, reset to the last item.
* If we clicked the same place as last time, select
* this name! */
if (selected > numents - 1)
selected = numents - 1;
if (selected > filelist_len - 1)
selected = filelist_len - 1;
else if (old_selected == selected)
/* Put back the 'select' key. */
/* Put back the "Select" key, so that the file
* is selected. */
unget_kbinput(NANO_ENTER_KEY, FALSE, FALSE);
} else {
/* We must have clicked a shortcut. Put back the
@@ -137,25 +148,28 @@ char *do_browser(char *path, DIR *dir)
break;
#endif
case NANO_PREVLINE_KEY:
if (selected >= width)
selected -= width;
break;
case NANO_BACK_KEY:
if (selected > 0)
selected--;
break;
case NANO_NEXTLINE_KEY:
if (selected + width <= numents - 1)
if (selected + width <= filelist_len - 1)
selected += width;
break;
case NANO_FORWARD_KEY:
if (selected < numents - 1)
if (selected < filelist_len - 1)
selected++;
break;
case NANO_PREVPAGE_KEY:
case NANO_PREVPAGE_FKEY:
case '-': /* Pico compatibility. */
if (selected >= (editwinrows + fileline % editwinrows) *
width)
selected -= (editwinrows + fileline % editwinrows) *
@@ -163,17 +177,15 @@ char *do_browser(char *path, DIR *dir)
else
selected = 0;
break;
case NANO_NEXTPAGE_KEY:
case NANO_NEXTPAGE_FKEY:
case ' ': /* Pico compatibility. */
selected += (editwinrows - fileline % editwinrows) *
width;
if (selected >= numents)
selected = numents - 1;
if (selected >= filelist_len)
selected = filelist_len - 1;
break;
case NANO_HELP_KEY:
case NANO_HELP_FKEY:
case '?': /* Pico compatibility. */
#ifndef DISABLE_HELP
do_help();
curs_set(0);
@@ -181,9 +193,8 @@ char *do_browser(char *path, DIR *dir)
nano_disabled_msg();
#endif
break;
case NANO_ENTER_KEY:
case 'S': /* Pico compatibility. */
case 's':
/* You can't move up from "/". */
if (strcmp(filelist[selected], "/..") == 0) {
statusbar(_("Can't move up a directory"));
@@ -232,7 +243,7 @@ char *do_browser(char *path, DIR *dir)
path = mallocstrcpy(path, filelist[selected]);
/* Start over again with the new path value. */
free_chararray(filelist, numents);
free_chararray(filelist, filelist_len);
goto change_browser_directory;
/* Redraw the screen. */
@@ -242,25 +253,44 @@ char *do_browser(char *path, DIR *dir)
/* Go to a specific directory. */
case NANO_GOTOLINE_KEY:
case NANO_GOTOLINE_FKEY:
case 'G': /* Pico compatibility. */
case 'g':
curs_set(1);
j = do_prompt(FALSE, gotodir_list, "",
i = do_prompt(TRUE,
#ifndef DISABLE_TABCOMP
FALSE,
#endif
gotodir_list, ans,
#ifndef NANO_TINY
NULL,
#endif
_("Go To Directory"));
browser_refresh, _("Go To Directory"));
curs_set(0);
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
currshortcut = browser_list;
#endif
bottombars(browser_list);
if (j < 0) {
if (i < 0) {
/* We canceled. Indicate that on the statusbar, and
* blank out ans, since we're done with it. */
statusbar(_("Cancelled"));
ans = mallocstrcpy(ans, "");
break;
} else if (i != 0) {
/* Put back the "Go to Directory" key and save
* answer in ans, so that the file list is displayed
* again, the prompt is displayed again, and what we
* typed before at the prompt is displayed again. */
unget_kbinput(NANO_GOTOLINE_KEY, FALSE, FALSE);
ans = mallocstrcpy(ans, answer);
break;
}
/* We have a directory. Blank out ans, since we're done
* with it. */
ans = mallocstrcpy(ans, "");
new_path = real_dir_from_tilde(answer);
if (new_path[0] != '/') {
@@ -293,14 +323,11 @@ char *do_browser(char *path, DIR *dir)
/* Start over again with the new path value. */
free(path);
path = new_path;
free_chararray(filelist, numents);
free_chararray(filelist, filelist_len);
goto change_browser_directory;
/* Abort the browser. */
case NANO_EXIT_KEY:
case NANO_EXIT_FKEY:
case 'E': /* Pico compatibility. */
case 'e':
abort = TRUE;
break;
}
@@ -308,89 +335,11 @@ char *do_browser(char *path, DIR *dir)
if (abort)
break;
blank_edit();
browser_refresh();
j = (width != 0) ? width * editwinrows * ((selected / width) /
editwinrows) : 0;
wmove(edit, 0, 0);
{
size_t foo_len = mb_cur_max() * 7;
char *foo = charalloc(foo_len + 1);
for (; j < numents && editline <= editwinrows - 1; j++) {
char *disp = display_string(tail(filelist[j]), 0,
longest, FALSE);
/* Highlight the currently selected file/dir. */
if (j == selected)
wattron(edit, A_REVERSE);
blank_line(edit, editline, col, longest);
mvwaddstr(edit, editline, col, disp);
free(disp);
col += longest;
filecols++;
/* Show file info also. We don't want to report file
* sizes for links, so we use lstat(). Also, stat() and
* lstat() return an error if, for example, the file is
* deleted while the file browser is open. In that
* case, we report "--" as the file info. */
if (lstat(filelist[j], &st) == -1 ||
S_ISLNK(st.st_mode)) {
/* Aha! It's a symlink! Now, is it a dir? If so,
* mark it as such. */
if (stat(filelist[j], &st) == 0 &&
S_ISDIR(st.st_mode)) {
strncpy(foo, _("(dir)"), foo_len);
foo[foo_len] = '\0';
} else
strcpy(foo, "--");
} else if (S_ISDIR(st.st_mode)) {
strncpy(foo, _("(dir)"), foo_len);
foo[foo_len] = '\0';
} else if (st.st_size < (1 << 10)) /* less than 1 k. */
sprintf(foo, "%4u B", (unsigned int)st.st_size);
else if (st.st_size < (1 << 20)) /* less than 1 meg. */
sprintf(foo, "%4u KB",
(unsigned int)(st.st_size >> 10));
else if (st.st_size < (1 << 30)) /* less than 1 gig. */
sprintf(foo, "%4u MB",
(unsigned int)(st.st_size >> 20));
else
sprintf(foo, "%4u GB",
(unsigned int)(st.st_size >> 30));
mvwaddnstr(edit, editline, col - strlen(foo), foo,
foo_len);
if (j == selected)
wattroff(edit, A_REVERSE);
/* Add some space between the columns. */
col += 2;
/* If the next entry isn't going to fit on the line,
* move to the next line. */
if (col > COLS - longest) {
editline++;
col = 0;
if (width == 0)
width = filecols;
}
wmove(edit, editline, col);
}
free(foo);
}
wnoutrefresh(edit);
} while ((kbinput = get_kbinput(edit, &meta_key, &func_key)) !=
NANO_EXIT_KEY && kbinput != NANO_EXIT_FKEY);
kbinput = get_kbinput(edit, &meta_key, &func_key);
parse_browser_input(&kbinput, &meta_key, &func_key);
} while (kbinput != NANO_EXIT_KEY);
blank_edit();
titlebar(NULL);
@@ -400,74 +349,13 @@ char *do_browser(char *path, DIR *dir)
SET(CONST_UPDATE);
/* Clean up. */
free_chararray(filelist, numents);
free(path);
free(ans);
free_chararray(filelist, filelist_len);
return retval;
}
/* Return a list of files contained in the directory path. *longest is
* the maximum display length of a file, up to COLS - 1 (but at least
* 7). *numents is the number of files. We assume path exists and is a
* directory. If neither is true, we return NULL. */
char **browser_init(const char *path, int *longest, size_t *numents, DIR
*dir)
{
const struct dirent *nextdir;
char **filelist;
size_t i = 0, path_len;
assert(dir != NULL);
*longest = 0;
while ((nextdir = readdir(dir)) != NULL) {
size_t dlen;
/* Don't show the "." entry. */
if (strcmp(nextdir->d_name, ".") == 0)
continue;
i++;
dlen = strlenpt(nextdir->d_name);
if (dlen > *longest)
*longest = (dlen > COLS - 1) ? COLS - 1 : dlen;
}
*numents = i;
rewinddir(dir);
*longest += 10;
filelist = (char **)nmalloc(*numents * sizeof(char *));
path_len = strlen(path);
i = 0;
while ((nextdir = readdir(dir)) != NULL && i < *numents) {
/* Don't show the "." entry. */
if (strcmp(nextdir->d_name, ".") == 0)
continue;
filelist[i] = charalloc(path_len + strlen(nextdir->d_name) + 1);
sprintf(filelist[i], "%s%s", path, nextdir->d_name);
i++;
}
/* Maybe the number of files in the directory changed between the
* first time we scanned and the second. i is the actual length of
* filelist, so record it. */
*numents = i;
closedir(dir);
if (*longest > COLS - 1)
*longest = COLS - 1;
if (*longest < 7)
*longest = 7;
return filelist;
}
/* The file browser front end. We check to see if inpath has a dir in
* it. If it does, we start do_browser() from there. Otherwise, we
* start do_browser() from the current directory. */
@@ -523,6 +411,187 @@ char *do_browse_from(const char *inpath)
return do_browser(path, dir);
}
/* Set filelist to the list of files contained in the directory path,
* set filelist_len to the number of files in that list, and set longest
* to the width in columns of the longest filename in that list, up to
* COLS - 1 (but at least 7). Assume path exists and is a directory. */
void browser_init(const char *path, DIR *dir)
{
const struct dirent *nextdir;
size_t i = 0, path_len;
assert(dir != NULL);
longest = 0;
while ((nextdir = readdir(dir)) != NULL) {
size_t d_len;
/* Don't show the "." entry. */
if (strcmp(nextdir->d_name, ".") == 0)
continue;
i++;
d_len = strlenpt(nextdir->d_name);
if (d_len > longest)
longest = (d_len > COLS - 1) ? COLS - 1 : d_len;
}
filelist_len = i;
rewinddir(dir);
longest += 10;
filelist = (char **)nmalloc(filelist_len * sizeof(char *));
path_len = strlen(path);
i = 0;
while ((nextdir = readdir(dir)) != NULL && i < filelist_len) {
/* Don't show the "." entry. */
if (strcmp(nextdir->d_name, ".") == 0)
continue;
filelist[i] = charalloc(path_len + strlen(nextdir->d_name) + 1);
sprintf(filelist[i], "%s%s", path, nextdir->d_name);
i++;
}
/* Maybe the number of files in the directory changed between the
* first time we scanned and the second. i is the actual length of
* filelist, so record it. */
filelist_len = i;
closedir(dir);
if (longest > COLS - 1)
longest = COLS - 1;
if (longest < 7)
longest = 7;
}
/* Determine the shortcut key corresponding to the values of kbinput
* (the key itself), meta_key (whether the key is a meta sequence), and
* func_key (whether the key is a function key), if any. In the
* process, convert certain non-shortcut keys used by Pico's file
* browser into their corresponding shortcut keys. */
void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key)
{
get_shortcut(browser_list, kbinput, meta_key, func_key);
/* Pico compatibility. */
if (*meta_key == FALSE && *func_key == FALSE) {
switch (*kbinput) {
case ' ':
*kbinput = NANO_NEXTPAGE_KEY;
break;
case '-':
*kbinput = NANO_PREVPAGE_KEY;
break;
case '?':
*kbinput = NANO_HELP_KEY;
break;
case 'E':
case 'e':
*kbinput = NANO_EXIT_KEY;
break;
case 'G':
case 'g':
*kbinput = NANO_GOTOLINE_KEY;
break;
case 'S':
case 's':
*kbinput = NANO_ENTER_KEY;
break;
}
}
}
/* Calculate the number of columns needed to display the list of files
* in the array filelist, if necessary, and then display the list of
* files. */
void browser_refresh(void)
{
struct stat st;
int i;
int col = 0, filecols = 0, editline = 0;
size_t foo_len = mb_cur_max() * 7;
char *foo = charalloc(foo_len + 1);
i = (width != 0) ? width * editwinrows * ((selected / width) /
editwinrows) : 0;
blank_edit();
wmove(edit, 0, 0);
for (; i < filelist_len && editline <= editwinrows - 1; i++) {
char *disp = display_string(tail(filelist[i]), 0, longest,
FALSE);
/* Highlight the currently selected file/dir. */
if (i == selected)
wattron(edit, A_REVERSE);
blank_line(edit, editline, col, longest);
mvwaddstr(edit, editline, col, disp);
free(disp);
col += longest;
filecols++;
/* Show file info also. We don't want to report file sizes for
* links, so we use lstat(). Also, stat() and lstat() return an
* error if, for example, the file is deleted while the file
* browser is open. In that case, we report "--" as the file
* info. */
if (lstat(filelist[i], &st) == -1 || S_ISLNK(st.st_mode)) {
/* Aha! It's a symlink! Now, is it a dir? If so, mark it
* as such. */
if (stat(filelist[i], &st) == 0 && S_ISDIR(st.st_mode)) {
strncpy(foo, _("(dir)"), foo_len);
foo[foo_len] = '\0';
} else
strcpy(foo, "--");
} else if (S_ISDIR(st.st_mode)) {
strncpy(foo, _("(dir)"), foo_len);
foo[foo_len] = '\0';
} else if (st.st_size < (1 << 10)) /* less than 1 k. */
sprintf(foo, "%4u B", (unsigned int)st.st_size);
else if (st.st_size < (1 << 20)) /* less than 1 meg. */
sprintf(foo, "%4u KB", (unsigned int)(st.st_size >> 10));
else if (st.st_size < (1 << 30)) /* less than 1 gig. */
sprintf(foo, "%4u MB", (unsigned int)(st.st_size >> 20));
else
sprintf(foo, "%4u GB", (unsigned int)(st.st_size >> 30));
mvwaddnstr(edit, editline, col - strlen(foo), foo, foo_len);
if (i == selected)
wattroff(edit, A_REVERSE);
/* Add some space between the columns. */
col += 2;
/* If the next entry isn't going to fit on the line,
* move to the next line. */
if (col > COLS - longest) {
editline++;
col = 0;
/* Set the number of columns to display the list in, if
* necessary, so that we don't divide by 0. */
if (width == 0)
width = filecols;
}
wmove(edit, editline, col);
}
free(foo);
wnoutrefresh(edit);
}
/* Strip one directory from the end of path. */
void striponedir(char *path)
{

View File

@@ -3,7 +3,7 @@
* chars.c *
* *
* Copyright (C) 2001-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -813,29 +813,9 @@ size_t mbstrnlen(const char *s, size_t maxlen)
return strnlen(s, maxlen);
}
#ifndef NANO_TINY
/* This function is equivalent to strpbrk(), except in that it scans the
* string in reverse, starting at rev_start. */
char *revstrpbrk(const char *s, const char *accept, const char
*rev_start)
{
assert(s != NULL && accept != NULL && rev_start != NULL);
for (; rev_start >= s; rev_start--) {
const char *q = (*rev_start == '\0') ? NULL : strchr(accept,
*rev_start);
if (q != NULL)
return (char *)rev_start;
}
return NULL;
}
#endif /* !NANO_TINY */
#ifndef DISABLE_JUSTIFY
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
/* This function is equivalent to strchr() for multibyte strings. */
char *mbstrchr(const char *s, char *c)
char *mbstrchr(const char *s, const char *c)
{
assert(s != NULL && c != NULL);
@@ -879,8 +859,80 @@ char *mbstrchr(const char *s, char *c)
#endif
return strchr(s, *c);
}
#endif /* !NANO_TINY || !DISABLE_JUSTIFY */
#ifdef ENABLE_NANORC
#ifndef NANO_TINY
/* This function is equivalent to strpbrk() for multibyte strings. */
char *mbstrpbrk(const char *s, const char *accept)
{
assert(s != NULL && accept != NULL);
#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
while (*s != '\0') {
if (mbstrchr(accept, s) != NULL)
return (char *)s;
s += move_mbright(s, 0);
}
return NULL;
} else
#endif
return strpbrk(s, accept);
}
/* This function is equivalent to strpbrk(), except in that it scans the
* string in reverse, starting at rev_start. */
char *revstrpbrk(const char *s, const char *accept, const char
*rev_start)
{
assert(s != NULL && accept != NULL && rev_start != NULL);
for (; rev_start >= s; rev_start--) {
const char *q = (*rev_start == '\0') ? NULL : strchr(accept,
*rev_start);
if (q != NULL)
return (char *)rev_start;
}
return NULL;
}
/* This function is equivalent to strpbrk() for multibyte strings,
* except in that it scans the string in reverse, starting at
* rev_start. */
char *mbrevstrpbrk(const char *s, const char *accept, const char
*rev_start)
{
assert(s != NULL && accept != NULL && rev_start != NULL);
#ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) {
bool begin_line = FALSE;
while (!begin_line) {
const char *q = (*rev_start == '\0') ? NULL :
mbstrchr(accept, rev_start);
if (q != NULL)
return (char *)rev_start;
if (rev_start == s)
begin_line = TRUE;
else
rev_start = s + move_mbleft(s, rev_start - s);
}
return NULL;
} else
#endif
return revstrpbrk(s, accept, rev_start);
}
#endif /* !NANO_TINY */
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
/* Return TRUE if the string s contains one or more blank characters,
* and FALSE otherwise. */
bool has_blank_chars(const char *s)
@@ -926,8 +978,7 @@ bool has_blank_mbchars(const char *s)
#endif
return has_blank_chars(s);
}
#endif /* ENABLE_NANORC */
#endif /* !DISABLE_JUSTIFY */
#endif /* ENABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */

View File

@@ -3,7 +3,7 @@
* color.c *
* *
* Copyright (C) 2001-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -72,7 +72,7 @@ void color_init(void)
start_color();
#ifdef HAVE_USE_DEFAULT_COLORS
/* Add in colors, if available. */
/* Use the default colors, if available. */
defok = (use_default_colors() != ERR);
#endif

View File

@@ -3,7 +3,7 @@
* files.c *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -713,6 +713,9 @@ void do_insertfile(
#endif
i = do_prompt(TRUE,
#ifndef DISABLE_TABCOMP
TRUE,
#endif
#ifndef NANO_TINY
execute ? extcmd_list :
#endif
@@ -720,7 +723,7 @@ void do_insertfile(
#ifndef NANO_TINY
NULL,
#endif
_(msg),
edit_refresh, _(msg),
#ifndef DISABLE_OPERATINGDIR
operating_dir != NULL && strcmp(operating_dir, ".") != 0 ?
operating_dir :
@@ -1752,11 +1755,19 @@ int do_writeout(bool exiting)
* and we're at the "Write File" prompt, disable tab
* completion. */
i = do_prompt(!ISSET(RESTRICTED) ||
openfile->filename[0] == '\0', writefile_list, ans,
openfile->filename[0] == '\0',
#ifndef DISABLE_TABCOMP
TRUE,
#endif
writefile_list, ans,
#ifndef NANO_TINY
NULL, "%s%s%s", _(msg), formatstr, backupstr
NULL,
#endif
edit_refresh, "%s%s%s", _(msg),
#ifndef NANO_TINY
formatstr, backupstr
#else
"%s", _(msg)
"", ""
#endif
);
@@ -1771,8 +1782,6 @@ int do_writeout(bool exiting)
if (i == NANO_TOFILES_KEY) {
char *tmp = do_browse_from(answer);
currshortcut = writefile_list;
if (tmp == NULL)
continue;
@@ -1954,15 +1963,14 @@ int is_dir(const char *buf)
{
char *dirptr = real_dir_from_tilde(buf);
struct stat fileinfo;
int ret = (stat(dirptr, &fileinfo) != -1 &&
int retval = (stat(dirptr, &fileinfo) != -1 &&
S_ISDIR(fileinfo.st_mode));
assert(buf != NULL && dirptr != buf);
free(dirptr);
return ret;
return retval;
}
/* These functions, username_tab_completion(), cwd_tab_completion()
@@ -2007,8 +2015,8 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
continue;
#endif
matches = (char **)nrealloc(matches,
(*num_matches + 1) * sizeof(char *));
matches = (char **)nrealloc(matches, (*num_matches + 1) *
sizeof(char *));
matches[*num_matches] =
charalloc(strlen(userdata->pw_name) + 2);
sprintf(matches[*num_matches], "~%s", userdata->pw_name);
@@ -2022,8 +2030,8 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
/* We consider the first buflen characters of buf for filename tab
* completion. */
char **cwd_tab_completion(const char *buf, size_t *num_matches, size_t
buflen)
char **cwd_tab_completion(const char *buf, bool allow_files, size_t
*num_matches, size_t buflen)
{
char *dirname = mallocstrcpy(NULL, buf), *filename;
#ifndef DISABLE_OPERATINGDIR
@@ -2073,36 +2081,41 @@ char **cwd_tab_completion(const char *buf, size_t *num_matches, size_t
filenamelen = strlen(filename);
while ((nextdir = readdir(dir)) != NULL) {
bool skip_match = FALSE;
#ifdef DEBUG
fprintf(stderr, "Comparing \'%s\'\n", nextdir->d_name);
#endif
/* See if this matches. */
if (strncmp(nextdir->d_name, filename, filenamelen) == 0 &&
(*filename == '.' ||
(strcmp(nextdir->d_name, ".") != 0 &&
strcmp(nextdir->d_name, "..") != 0))) {
(*filename == '.' || (strcmp(nextdir->d_name, ".") !=
0 && strcmp(nextdir->d_name, "..") != 0))) {
/* Cool, found a match. Add it to the list. This makes a
* lot more sense to me (Chris) this way... */
char *tmp = charalloc(strlen(dirname) +
strlen(nextdir->d_name) + 1);
sprintf(tmp, "%s%s", dirname, nextdir->d_name);
#ifndef DISABLE_OPERATINGDIR
/* ...unless the match exists outside the operating
* directory, in which case just go to the next match. To
* properly do operating directory checking, we have to add
* the directory name to the beginning of the proposed match
* before we check it. */
char *tmp2 = charalloc(strlen(dirname) +
strlen(nextdir->d_name) + 1);
sprintf(tmp2, "%s%s", dirname, nextdir->d_name);
if (check_operating_dir(tmp2, TRUE)) {
free(tmp2);
continue;
}
free(tmp2);
* directory, in which case just go to the next match. */
if (check_operating_dir(tmp, TRUE))
skip_match = TRUE;
#endif
matches = (char **)nrealloc(matches,
(*num_matches + 1) * sizeof(char *));
/* ...or unless the match isn't a directory and allow_files
* isn't set, in which case just go to the next match. */
if (!allow_files && !is_dir(tmp))
skip_match = TRUE;
free(tmp);
if (skip_match)
continue;
matches = (char **)nrealloc(matches, (*num_matches + 1) *
sizeof(char *));
matches[*num_matches] = mallocstrcpy(NULL, nextdir->d_name);
++(*num_matches);
}
@@ -2116,13 +2129,15 @@ char **cwd_tab_completion(const char *buf, size_t *num_matches, size_t
}
/* Do tab completion. place refers to how much the statusbar cursor
* position should be advanced. */
char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list)
* position should be advanced. refresh_func is the function we will
* call to refresh the edit window. */
char *input_tab(char *buf, bool allow_files, size_t *place, bool
*lastwastab, void (*refresh_func)(void), bool *list)
{
size_t num_matches = 0;
char **matches = NULL;
assert(buf != NULL && place != NULL && *place <= strlen(buf) && lastwastab != NULL && list != NULL);
assert(buf != NULL && place != NULL && *place <= strlen(buf) && lastwastab != NULL && refresh_func != NULL && list != NULL);
*list = FALSE;
@@ -2138,7 +2153,8 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list)
/* Match against files relative to the current working directory. */
if (matches == NULL)
matches = cwd_tab_completion(buf, &num_matches, *place);
matches = cwd_tab_completion(buf, allow_files, &num_matches,
*place);
if (num_matches <= 0)
beep();
@@ -2279,7 +2295,7 @@ char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list)
/* Only refresh the edit window if we don't have a list of filename
* matches on it. */
if (*list == FALSE)
edit_refresh();
refresh_func();
/* Enable el cursor. */
curs_set(1);

View File

@@ -3,7 +3,7 @@
* global.c *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -65,6 +65,12 @@ partition *filepart = NULL;
openfilestruct *openfile = NULL;
/* The list of all open file buffers. */
#ifndef NANO_TINY
char *matchbrackets = NULL;
/* The opening and closing brackets that can be found by bracket
* searches. */
#endif
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
char *whitespace = NULL;
/* The characters used when displaying the first characters of
@@ -246,16 +252,16 @@ void sc_init_one(shortcut **shortcutage, int ctrlval, const char *desc,
* Uncut shortcut in the main shortcut list with UnJustify. */
void shortcut_init(bool unjustify)
{
const char *cancel_msg = N_("Cancel");
const char *get_help_msg = N_("Get Help");
const char *exit_msg = N_("Exit");
const char *prev_page_msg = N_("Prev Page");
const char *next_page_msg = N_("Next Page");
const char *replace_msg = N_("Replace");
const char *go_to_line_msg = N_("Go To Line");
const char *cancel_msg = N_("Cancel");
const char *replace_msg = N_("Replace");
const char *refresh_msg = N_("Refresh");
const char *first_line_msg = N_("First Line");
const char *last_line_msg = N_("Last Line");
const char *refresh_msg = N_("Refresh");
#ifndef NANO_TINY
const char *cut_till_end_msg = N_("CutTillEnd");
#endif
@@ -281,6 +287,7 @@ void shortcut_init(bool unjustify)
const char *to_files_msg = N_("To Files");
#endif
#ifndef DISABLE_HELP
const char *nano_cancel_msg = N_("Cancel the current function");
const char *nano_help_msg = N_("Invoke the help menu");
const char *nano_exit_msg =
#ifdef ENABLE_MULTIBUFFER
@@ -363,7 +370,6 @@ void shortcut_init(bool unjustify)
#ifndef NANO_TINY
const char *nano_bracket_msg = N_("Find matching bracket");
#endif
const char *nano_cancel_msg = N_("Cancel the current function");
const char *nano_firstline_msg =
N_("Go to the first line of the file");
const char *nano_lastline_msg =
@@ -417,20 +423,19 @@ void shortcut_init(bool unjustify)
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_EXIT_KEY,
#ifdef ENABLE_MULTIBUFFER
openfile != NULL && openfile != openfile->next ?
N_("Close") :
openfile != NULL && openfile != openfile->next ? N_("Close") :
#endif
exit_msg, IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
NANO_NO_KEY, VIEW, do_exit);
@@ -442,14 +447,14 @@ void shortcut_init(bool unjustify)
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_JUSTIFY_KEY, N_("Justify"),
IFHELP(nano_justify_msg, NANO_NO_KEY),
NANO_JUSTIFY_FKEY, NANO_NO_KEY, NOVIEW,
IFHELP(nano_justify_msg, NANO_NO_KEY), NANO_JUSTIFY_FKEY,
NANO_NO_KEY, NOVIEW,
#ifndef DISABLE_JUSTIFY
do_justify_void
do_justify_void
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
/* We allow inserting files in view mode if multibuffers are
* available, so that we can view multiple files. If we're using
@@ -462,12 +467,11 @@ void shortcut_init(bool unjustify)
IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_INSERTFILE_FKEY,
NANO_NO_KEY,
#ifdef ENABLE_MULTIBUFFER
VIEW
VIEW
#else
NOVIEW
NOVIEW
#endif
, !ISSET(RESTRICTED) ? do_insertfile_void :
nano_disabled_msg);
, !ISSET(RESTRICTED) ? do_insertfile_void : nano_disabled_msg);
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_WHEREIS_KEY, N_("Where Is"),
@@ -486,8 +490,8 @@ void shortcut_init(bool unjustify)
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_CUT_KEY, N_("Cut Text"),
IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY,
NANO_NO_KEY, NOVIEW, do_cut_text);
IFHELP(nano_cut_msg, NANO_NO_KEY), NANO_CUT_FKEY, NANO_NO_KEY,
NOVIEW, do_cut_text);
if (unjustify)
/* Translators: try to keep this string under 10 characters long. */
@@ -510,12 +514,12 @@ void shortcut_init(bool unjustify)
* on the command line. */
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&main_list, NANO_SPELL_KEY, N_("To Spell"),
IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
NANO_NO_KEY, NOVIEW,
IFHELP(nano_spell_msg, NANO_NO_KEY), NANO_SPELL_FKEY,
NANO_NO_KEY, NOVIEW,
#ifndef DISABLE_SPELLER
!ISSET(RESTRICTED) ? do_spell :
!ISSET(RESTRICTED) ? do_spell :
#endif
nano_disabled_msg);
nano_disabled_msg);
sc_init_one(&main_list, NANO_GOTOLINE_KEY, go_to_line_msg,
IFHELP(nano_gotoline_msg, NANO_GOTOLINE_ALTKEY),
@@ -545,40 +549,40 @@ void shortcut_init(bool unjustify)
NANO_NO_KEY, VIEW, do_down);
sc_init_one(&main_list, NANO_FORWARD_KEY, N_("Forward"),
IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, do_right);
IFHELP(nano_forward_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, do_right);
sc_init_one(&main_list, NANO_BACK_KEY, N_("Back"),
IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, do_left);
IFHELP(nano_back_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, do_left);
sc_init_one(&main_list, NANO_HOME_KEY, N_("Home"),
IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, do_home);
IFHELP(nano_home_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, do_home);
sc_init_one(&main_list, NANO_END_KEY, N_("End"),
IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, do_end);
IFHELP(nano_end_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, do_end);
sc_init_one(&main_list, NANO_REFRESH_KEY, refresh_msg,
IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, total_refresh);
IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, total_refresh);
sc_init_one(&main_list, NANO_DELETE_KEY, N_("Delete"),
IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, do_delete);
IFHELP(nano_delete_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
NOVIEW, do_delete);
sc_init_one(&main_list, NANO_BACKSPACE_KEY, N_("Backspace"),
IFHELP(nano_backspace_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, do_backspace);
sc_init_one(&main_list, NANO_TAB_KEY, N_("Tab"),
IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, do_tab);
IFHELP(nano_tab_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
NOVIEW, do_tab);
sc_init_one(&main_list, NANO_ENTER_KEY, N_("Enter"),
IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, NOVIEW, do_enter);
IFHELP(nano_enter_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
NOVIEW, do_enter);
#ifndef NANO_TINY
sc_init_one(&main_list, NANO_NEXTWORD_KEY, N_("Next Word"),
@@ -651,19 +655,19 @@ void shortcut_init(bool unjustify)
free_shortcutage(&whereis_list);
sc_init_one(&whereis_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_FIRSTLINE_KEY, first_line_msg,
@@ -719,8 +723,8 @@ void shortcut_init(bool unjustify)
#ifndef NANO_TINY
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_PREVLINE_KEY, history_msg,
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
/* Translators: try to keep this string under 10 characters long. */
sc_init_one(&whereis_list, NANO_CUTTILLEND_KEY, cut_till_end_msg,
@@ -738,18 +742,18 @@ void shortcut_init(bool unjustify)
free_shortcutage(&replace_list);
sc_init_one(&replace_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
sc_init_one(&replace_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
sc_init_one(&replace_list, NANO_FIRSTLINE_KEY, first_line_msg,
IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_FIRSTLINE_FKEY,
@@ -786,25 +790,25 @@ void shortcut_init(bool unjustify)
#ifndef NANO_TINY
sc_init_one(&replace_list, NANO_PREVLINE_KEY, history_msg,
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
#endif
free_shortcutage(&replace_list_2);
sc_init_one(&replace_list_2, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
sc_init_one(&replace_list_2, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
sc_init_one(&replace_list_2, NANO_FIRSTLINE_KEY, first_line_msg,
IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
@@ -816,25 +820,25 @@ void shortcut_init(bool unjustify)
#ifndef NANO_TINY
sc_init_one(&replace_list_2, NANO_PREVLINE_KEY, history_msg,
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_history_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
#endif
free_shortcutage(&gotoline_list);
sc_init_one(&gotoline_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
sc_init_one(&gotoline_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
sc_init_one(&gotoline_list, NANO_FIRSTLINE_KEY, first_line_msg,
IFHELP(nano_firstline_msg, NANO_NO_KEY), NANO_NO_KEY,
@@ -851,18 +855,18 @@ void shortcut_init(bool unjustify)
free_shortcutage(&writefile_list);
sc_init_one(&writefile_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
sc_init_one(&writefile_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
#ifndef DISABLE_BROWSER
/* If we're using restricted mode, the file browser is disabled.
@@ -919,18 +923,18 @@ void shortcut_init(bool unjustify)
free_shortcutage(&insertfile_list);
sc_init_one(&insertfile_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
sc_init_one(&insertfile_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
#ifndef DISABLE_BROWSER
/* If we're using restricted mode, the file browser is disabled.
@@ -967,18 +971,18 @@ void shortcut_init(bool unjustify)
free_shortcutage(&extcmd_list);
sc_init_one(&extcmd_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
sc_init_one(&extcmd_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
sc_init_one(&extcmd_list, NANO_TOOTHERINSERT_KEY, N_("Insert File"),
IFHELP(nano_insert_msg, NANO_NO_KEY), NANO_NO_KEY,
@@ -995,12 +999,12 @@ void shortcut_init(bool unjustify)
free_shortcutage(&help_list);
sc_init_one(&help_list, NANO_REFRESH_KEY, refresh_msg,
IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_refresh_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
sc_init_one(&help_list, NANO_EXIT_KEY, exit_msg,
IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_exit_msg, NANO_NO_KEY), NANO_EXIT_FKEY, NANO_NO_KEY,
VIEW, NULL);
sc_init_one(&help_list, NANO_PREVPAGE_KEY, prev_page_msg,
IFHELP(nano_prevpage_msg, NANO_NO_KEY), NANO_PREVPAGE_FKEY,
@@ -1023,32 +1027,26 @@ void shortcut_init(bool unjustify)
free_shortcutage(&spell_list);
sc_init_one(&spell_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
sc_init_one(&spell_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
#endif
#ifndef DISABLE_BROWSER
free_shortcutage(&browser_list);
sc_init_one(&browser_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
#ifndef DISABLE_HELP
do_help
#else
nano_disabled_msg
#endif
);
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW, NULL);
sc_init_one(&browser_list, NANO_EXIT_KEY, exit_msg,
IFHELP(nano_exitbrowser_msg, NANO_NO_KEY), NANO_EXIT_FKEY,
@@ -1070,18 +1068,18 @@ void shortcut_init(bool unjustify)
free_shortcutage(&gotodir_list);
sc_init_one(&gotodir_list, NANO_HELP_KEY, get_help_msg,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY,
NANO_NO_KEY, VIEW,
IFHELP(nano_help_msg, NANO_NO_KEY), NANO_HELP_FKEY, NANO_NO_KEY,
VIEW,
#ifndef DISABLE_HELP
do_help
do_help
#else
nano_disabled_msg
nano_disabled_msg
#endif
);
);
sc_init_one(&gotodir_list, NANO_CANCEL_KEY, cancel_msg,
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY,
NANO_NO_KEY, VIEW, NULL);
IFHELP(nano_cancel_msg, NANO_NO_KEY), NANO_NO_KEY, NANO_NO_KEY,
VIEW, NULL);
#endif
currshortcut = main_list;

View File

@@ -3,7 +3,7 @@
* help.c *
* *
* Copyright (C) 2000-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -267,7 +267,7 @@ void help_init(void)
htx[1] = NULL;
htx[2] = NULL;
}
#endif
#endif /* !DISABLE_BROWSER */
#ifndef DISABLE_SPELLER
else if (currshortcut == spell_list) {
htx[0] = N_("Spell Check Help Text\n\n "
@@ -282,7 +282,7 @@ void help_init(void)
htx[1] = NULL;
htx[2] = NULL;
}
#endif
#endif /* !DISABLE_SPELLER */
#ifndef NANO_TINY
else if (currshortcut == extcmd_list) {
htx[0] = N_("Execute Command Help Text\n\n "
@@ -295,7 +295,7 @@ void help_init(void)
htx[1] = NULL;
htx[2] = NULL;
}
#endif
#endif /* !NANO_TINY */
else {
/* Default to the main help list. */
htx[0] = N_(" nano help text\n\n "
@@ -471,7 +471,6 @@ void help_init(void)
/* And the toggles... */
if (currshortcut == main_list) {
for (t = toggles; t != NULL; t = t->next) {
assert(t->desc != NULL);
ptr += sprintf(ptr, "M-%c\t\t\t%s %s\n", toupper(t->val),

View File

@@ -3,7 +3,7 @@
* nano.c *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -34,15 +34,12 @@
#include <errno.h>
#include <ctype.h>
#include <locale.h>
#include <termios.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
#ifndef NANO_TINY
#include <setjmp.h>
#endif
@@ -1047,10 +1044,10 @@ RETSIGTYPE handle_sigwinch(int signal)
if (result == -1)
return;
/* Could check whether the COLS or LINES changed, and return
* otherwise. EXCEPT, that COLS and LINES are ncurses global
* variables, and in some cases ncurses has already updated them.
* But not in all cases, argh. */
/* We could check whether the COLS or LINES changed, and return
* otherwise. However, COLS and LINES are curses global variables,
* and in some cases curses has already updated them. But not in
* all cases. Argh. */
COLS = win.ws_col;
LINES = win.ws_row;
@@ -1958,16 +1955,19 @@ int main(int argc, char **argv)
#endif
#ifndef DISABLE_JUSTIFY
/* If punct wasn't specified, set its default value. */
if (punct == NULL)
punct = mallocstrcpy(NULL, ".?!");
punct = mallocstrcpy(NULL, "!.?");
/* If brackets wasn't specified, set its default value. */
if (brackets == NULL)
brackets = mallocstrcpy(NULL, "'\")}]>");
brackets = mallocstrcpy(NULL, "\"')>]}");
/* If quotestr wasn't specified, set its default value. */
if (quotestr == NULL)
quotestr = mallocstrcpy(NULL,
#ifdef HAVE_REGEX_H
"^([ \t]*[|>:}#])+"
"^([ \t]*[#:>|}])+"
#else
"> "
#endif
@@ -2003,6 +2003,12 @@ int main(int argc, char **argv)
}
#endif
#ifndef NANO_TINY
/* If matchbrackets wasn't specified, set its default value. */
if (matchbrackets == NULL)
matchbrackets = mallocstrcpy(NULL, "(<[{)>]}");
#endif
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
/* If whitespace wasn't specified, set its default value. */
if (whitespace == NULL) {

View File

@@ -3,7 +3,7 @@
* nano.h *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -136,8 +136,6 @@
#define getline ngetline
#endif
#define VERMSG "GNU nano " VERSION
/* If we don't have regex support, turn the color support off, as it
* depends on the use of regexes. */
#ifndef HAVE_REGEX_H
@@ -502,8 +500,8 @@ typedef struct rcoption {
#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_UNCUT_KEY /* Same key as UnCut. */
#define NANO_UNJUSTIFY_FKEY NANO_UNCUT_FKEY /* Same key as UnCut. */
#define NANO_UNJUSTIFY_KEY NANO_UNCUT_KEY
#define NANO_UNJUSTIFY_FKEY NANO_UNCUT_FKEY
#define NANO_PREVLINE_KEY NANO_CONTROL_P
#define NANO_NEXTLINE_KEY NANO_CONTROL_N
#define NANO_FORWARD_KEY NANO_CONTROL_F
@@ -590,7 +588,7 @@ typedef struct rcoption {
* counting the blank lines at their ends. */
#define MAX_SEARCH_HISTORY 100
/* The maximum number of bytes we read from a file at one time. */
/* The maximum number of bytes buffered at one time. */
#define MAX_BUF_SIZE 128
#endif /* !NANO_H */

View File

@@ -3,7 +3,7 @@
* prompt.c *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -46,9 +46,11 @@ static bool reset_statusbar_x = FALSE;
* shortcut key, and set finished to TRUE if we're done after running
* or trying to run a function associated with a shortcut key. If
* allow_funcs is FALSE, don't actually run any functions associated
* with shortcut keys. */
* with shortcut keys. refresh_func is the function we will call to
* refresh the edit window. */
int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
bool *ran_func, bool *finished, bool allow_funcs)
bool *ran_func, bool *finished, bool allow_funcs, void
(*refresh_func)(void))
{
int input;
/* The character we read in. */
@@ -153,7 +155,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
switch (input) {
/* Handle the "universal" statusbar prompt shortcuts. */
case NANO_REFRESH_KEY:
total_refresh();
refresh_func();
break;
case NANO_HOME_KEY:
do_statusbar_home();
@@ -672,7 +674,7 @@ bool find_statusbar_bracket_match(bool reverse, const char
{
const char *rev_start = NULL, *found = NULL;
assert(strlen(bracket_set) == 2);
assert(mbstrlen(bracket_set) == 2);
/* rev_start might end up 1 character before the start or after the
* end of the line. This won't be a problem because we'll skip over
@@ -687,8 +689,8 @@ bool find_statusbar_bracket_match(bool reverse, const char
* is found. */
found = ((rev_start > answer && *(rev_start - 1) == '\0') ||
rev_start < answer) ? NULL : (reverse ?
revstrpbrk(answer, bracket_set, rev_start) :
strpbrk(rev_start, bracket_set));
mbrevstrpbrk(answer, bracket_set, rev_start) :
mbstrpbrk(rev_start, bracket_set));
/* We've found a potential match. */
if (found != NULL)
@@ -711,48 +713,91 @@ bool find_statusbar_bracket_match(bool reverse, const char
void do_statusbar_find_bracket(void)
{
size_t statusbar_x_save, pww_save;
const char *bracket_list = "()<>[]{}";
/* The list of brackets we can find matches to. */
const char *pos;
/* The location in bracket_list of the bracket at the current
const char *ch;
/* The location in matchbrackets of the bracket at the current
* cursor position. */
char ch;
/* The bracket at the current cursor position. */
char wanted_ch;
/* The bracket complementing the bracket at the current cursor
* position. */
char bracket_set[3];
int ch_len;
/* The length of ch in bytes. */
const char *wanted_ch;
/* The location in matchbrackets of the bracket complementing
* the bracket at the current cursor position. */
int wanted_ch_len;
/* The length of wanted_ch in bytes. */
char *bracket_set;
/* The pair of characters in ch and wanted_ch. */
size_t i;
/* Generic loop variable. */
size_t matchhalf;
/* The number of single-byte characters in one half of
* matchbrackets. */
size_t mbmatchhalf;
/* The number of multibyte characters in one half of
* matchbrackets. */
size_t count = 1;
/* The initial bracket count. */
bool reverse;
/* The direction we search. */
char *found_ch;
/* The character we find. */
assert(strlen(bracket_list) % 2 == 0);
assert(mbstrlen(matchbrackets) % 2 == 0);
ch = answer[statusbar_x];
ch = answer + statusbar_x;
if (ch == '\0' || (pos = strchr(bracket_list, ch)) == NULL)
if (ch == '\0' || (ch = mbstrchr(matchbrackets, ch)) == NULL)
return;
/* Save where we are. */
statusbar_x_save = statusbar_x;
pww_save = statusbar_pww;
/* If we're on an opening bracket, we want to search forwards for a
* closing bracket, and if we're on a closing bracket, we want to
* search backwards for an opening bracket. */
reverse = ((pos - bracket_list) % 2 != 0);
wanted_ch = reverse ? *(pos - 1) : *(pos + 1);
bracket_set[0] = ch;
bracket_set[1] = wanted_ch;
bracket_set[2] = '\0';
/* If we're on an opening bracket, which must be in the first half
* of matchbrackets, we want to search forwards for a closing
* bracket. If we're on a closing bracket, which must be in the
* second half of matchbrackets, we want to search backwards for an
* opening bracket. */
matchhalf = 0;
mbmatchhalf = mbstrlen(matchbrackets) / 2;
for (i = 0; i < mbmatchhalf; i++)
matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL,
NULL);
reverse = ((ch - matchbrackets) >= matchhalf);
/* If we're on an opening bracket, set wanted_ch to the character
* that's matchhalf characters after ch. If we're on a closing
* bracket, set wanted_ch to the character that's matchhalf
* characters before ch. */
wanted_ch = ch;
while (mbmatchhalf > 0) {
if (reverse)
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
wanted_ch - matchbrackets);
else
wanted_ch += move_mbright(wanted_ch, 0);
mbmatchhalf--;
}
ch_len = parse_mbchar(ch, NULL, NULL);
wanted_ch_len = parse_mbchar(wanted_ch, NULL, NULL);
/* Fill bracket_set in with the values of ch and wanted_ch. */
bracket_set = charalloc((mb_cur_max() * 2) + 1);
strncpy(bracket_set, ch, ch_len);
strncpy(bracket_set + ch_len, wanted_ch, wanted_ch_len);
null_at(&bracket_set, ch_len + wanted_ch_len);
found_ch = charalloc(mb_cur_max() + 1);
while (TRUE) {
if (find_statusbar_bracket_match(reverse, bracket_set)) {
/* If we found an identical bracket, increment count. If we
* found a complementary bracket, decrement it. */
count += (answer[statusbar_x] == ch) ? 1 : -1;
parse_mbchar(answer + statusbar_x, found_ch, NULL);
count += (strncmp(found_ch, ch, ch_len) == 0) ? 1 : -1;
/* If count is zero, we've found a matching bracket. Update
* the statusbar prompt and get out. */
@@ -769,6 +814,10 @@ void do_statusbar_find_bracket(void)
break;
}
}
/* Clean up. */
free(bracket_set);
free(found_ch);
}
#endif /* !NANO_TINY */
@@ -850,17 +899,21 @@ bool need_statusbar_horizontal_update(size_t old_pww)
/* Get a string of input at the statusbar prompt. This should only be
* called from do_prompt(). */
int get_prompt_string(bool allow_tabs, const char *curranswer,
int get_prompt_string(bool allow_tabs,
#ifndef DISABLE_TABCOMP
bool allow_files,
#endif
const char *curranswer,
#ifndef NANO_TINY
filestruct **history_list,
#endif
const shortcut *s
void (*refresh_func)(void), const shortcut *s
#ifndef DISABLE_TABCOMP
, bool *list
#endif
)
{
int kbinput;
int kbinput = ERR;
bool meta_key, func_key, s_or_t, ran_func, finished;
size_t curranswer_len;
#ifndef DISABLE_TABCOMP
@@ -910,10 +963,9 @@ int get_prompt_string(bool allow_tabs, const char *curranswer,
* to files not specified on the command line. In this case,
* disable all keys that would change the text if the filename isn't
* blank and we're at the "Write File" prompt. */
while ((kbinput = do_statusbar_input(&meta_key, &func_key,
&s_or_t, &ran_func, &finished, TRUE)) != NANO_CANCEL_KEY &&
while ((kbinput = do_statusbar_input(&meta_key, &func_key, &s_or_t,
&ran_func, &finished, TRUE, refresh_func)) != NANO_CANCEL_KEY &&
kbinput != NANO_ENTER_KEY) {
assert(statusbar_x <= strlen(answer));
#ifndef DISABLE_TABCOMP
@@ -938,8 +990,8 @@ int get_prompt_string(bool allow_tabs, const char *curranswer,
} else
#endif /* !NANO_TINY */
if (allow_tabs)
answer = input_tab(answer, &statusbar_x, &tabbed,
list);
answer = input_tab(answer, allow_files,
&statusbar_x, &tabbed, refresh_func, list);
update_statusbar_line(answer, statusbar_x);
break;
@@ -999,6 +1051,17 @@ int get_prompt_string(bool allow_tabs, const char *curranswer,
}
break;
#endif /* !NANO_TINY */
#ifndef DISABLE_HELP
case NANO_HELP_KEY:
update_statusbar_line(answer, statusbar_x);
/* This key has a shortcut list entry when it's used to
* to go to the help browser, which means that finished
* has been set to TRUE. Set it back to FALSE here, so
* that we aren't kicked out of the statusbar prompt. */
finished = FALSE;
break;
#endif /* !DISABLE_HELP */
}
/* If we have a shortcut with an associated function, break out
@@ -1040,16 +1103,23 @@ int get_prompt_string(bool allow_tabs, const char *curranswer,
* static prompt, which should be NULL initially, and the answer will be
* stored in the answer global. Returns -1 on aborted enter, -2 on a
* blank string, and 0 otherwise, the valid shortcut key caught.
* curranswer is any editable text that we want to put up by default.
* curranswer is any editable text that we want to put up by default,
* and refresh_func is the function we want to call to refresh the edit
* window.
*
* The allow_tabs parameter indicates whether we should allow tabs to be
* interpreted. */
int do_prompt(bool allow_tabs, const shortcut *s, const char
*curranswer,
* interpreted. The allow_files parameter indicates whether we should
* allow all files (as opposed to just directories) to be tab
* completed. */
int do_prompt(bool allow_tabs,
#ifndef DISABLE_TABCOMP
bool allow_files,
#endif
const shortcut *s, const char *curranswer,
#ifndef NANO_TINY
filestruct **history_list,
#endif
const char *msg, ...)
void (*refresh_func)(void), const char *msg, ...)
{
va_list ap;
int retval;
@@ -1071,15 +1141,19 @@ int do_prompt(bool allow_tabs, const shortcut *s, const char
va_end(ap);
null_at(&prompt, actual_x(prompt, COLS - 4));
retval = get_prompt_string(allow_tabs, curranswer,
#ifndef NANO_TINY
history_list,
#endif
s
retval = get_prompt_string(allow_tabs,
#ifndef DISABLE_TABCOMP
, &list
allow_files,
#endif
);
curranswer,
#ifndef NANO_TINY
history_list,
#endif
refresh_func, s
#ifndef DISABLE_TABCOMP
, &list
#endif
);
free(prompt);
prompt = NULL;
@@ -1109,7 +1183,7 @@ int do_prompt(bool allow_tabs, const shortcut *s, const char
* matches on the edit window at this point. Make sure that they're
* cleared off. */
if (list)
edit_refresh();
refresh_func();
#endif
return retval;

View File

@@ -3,7 +3,7 @@
* proto.h *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -48,6 +48,10 @@ extern filestruct *jusbuffer;
extern partition *filepart;
extern openfilestruct *openfile;
#ifndef NANO_TINY
extern char *matchbrackets;
#endif
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
extern char *whitespace;
extern int whitespace_len[2];
@@ -134,9 +138,10 @@ extern char *homedir;
/* Public functions in browser.c. */
#ifndef DISABLE_BROWSER
char *do_browser(char *path, DIR *dir);
char **browser_init(const char *path, int *longest, size_t *numents, DIR
*dir);
char *do_browse_from(const char *inpath);
void browser_init(const char *path, DIR *dir);
void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key);
void browser_refresh(void);
void striponedir(char *path);
#endif
@@ -196,17 +201,20 @@ size_t mbstrlen(const char *s);
size_t nstrnlen(const char *s, size_t maxlen);
#endif
size_t mbstrnlen(const char *s, size_t maxlen);
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
char *mbstrchr(const char *s, const char *c);
#endif
#ifndef NANO_TINY
char *mbstrpbrk(const char *s, const char *accept);
char *revstrpbrk(const char *s, const char *accept, const char
*rev_start);
char *mbrevstrpbrk(const char *s, const char *accept, const char
*rev_start);
#endif
#ifndef DISABLE_JUSTIFY
char *mbstrchr(const char *s, char *c);
#ifdef ENABLE_NANORC
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
bool has_blank_chars(const char *s);
bool has_blank_mbchars(const char *s);
#endif
#endif
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
@@ -289,9 +297,10 @@ void free_chararray(char **array, size_t len);
#ifndef DISABLE_TABCOMP
char **username_tab_completion(const char *buf, size_t *num_matches,
size_t buflen);
char **cwd_tab_completion(const char *buf, size_t *num_matches, size_t
buflen);
char *input_tab(char *buf, size_t *place, bool *lastwastab, bool *list);
char **cwd_tab_completion(const char *buf, bool allow_files, size_t
*num_matches, size_t buflen);
char *input_tab(char *buf, bool allow_files, size_t *place, bool
*lastwastab, void (*refresh_func)(void), bool *list);
#endif
const char *tail(const char *foo);
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
@@ -427,7 +436,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls);
/* Public functions in prompt.c. */
int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
bool *ran_func, bool *finished, bool allow_funcs);
bool *ran_func, bool *finished, bool allow_funcs, void
(*refresh_func)(void));
#ifndef DISABLE_MOUSE
bool do_statusbar_mouse(void);
#endif
@@ -455,21 +465,28 @@ size_t get_statusbar_page_start(size_t start_col, size_t column);
void update_statusbar_line(const char *curranswer, size_t index);
void reset_statusbar_cursor(void);
bool need_statusbar_horizontal_update(size_t old_pww);
int get_prompt_string(bool allow_tabs, const char *curranswer,
int get_prompt_string(bool allow_tabs,
#ifndef DISABLE_TABCOMP
bool allow_files,
#endif
const char *curranswer,
#ifndef NANO_TINY
filestruct **history_list,
#endif
const shortcut *s
void (*refresh_func)(void), const shortcut *s
#ifndef DISABLE_TABCOMP
, bool *list
#endif
);
int do_prompt(bool allow_tabs, const shortcut *s, const char
*curranswer,
int do_prompt(bool allow_tabs,
#ifndef DISABLE_TABCOMP
bool allow_files,
#endif
const shortcut *s, const char *curranswer,
#ifndef NANO_TINY
filestruct **history_list,
#endif
const char *msg, ...);
void (*refresh_func)(void), const char *msg, ...);
void do_prompt_abort(void);
int do_yesno_prompt(bool all, const char *msg);

View File

@@ -3,7 +3,7 @@
* rcfile.c *
* *
* Copyright (C) 2001-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -81,6 +81,7 @@ const static rcoption rcopts[] = {
{"casesensitive", CASE_SENSITIVE},
{"cut", CUT_TO_END},
{"historylog", HISTORYLOG},
{"matchbrackets", 0},
{"noconvert", NO_CONVERT},
{"quickblank", QUICK_BLANK},
{"smarthome", SMART_HOME},
@@ -144,13 +145,10 @@ char *parse_next_word(char *ptr)
return ptr;
}
/* The keywords operatingdir, backupdir, fill, tabsize, speller, punct,
* brackets, quotestr, and whitespace take an argument when set. Among
* these, operatingdir, backupdir, speller, punct, brackets, quotestr,
* and whitespace have to allow tabs and spaces in the argument. Thus,
* if the next word starts with a ", we say it ends with the last " of
* the line. Otherwise, the word is interpreted as usual. That is so
* the arguments can contain "s too. */
/* Parse an argument, with optional quotes, after a keyword that takes
* one. If the next word starts with a ", we say that it ends with the
* last " of the line. Otherwise, we interpret it as usual, so that the
* arguments can contain "'s too. */
char *parse_argument(char *ptr)
{
const char *ptr_bak = ptr;
@@ -649,7 +647,17 @@ void parse_rcfile(FILE *rcstream)
} else
#endif
#ifndef NANO_TINY
if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
if (strcasecmp(rcopts[i].name,
"matchbrackets") == 0) {
matchbrackets = option;
if (has_blank_mbchars(matchbrackets)) {
rcfile_error(
N_("Non-blank characters required"));
free(matchbrackets);
matchbrackets = NULL;
}
} else if (strcasecmp(rcopts[i].name,
"whitespace") == 0) {
whitespace = option;
if (mbstrlen(whitespace) != 2 ||
strlenpt(whitespace) != 2) {

View File

@@ -3,7 +3,7 @@
* search.c *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -123,11 +123,11 @@ void search_init_globals(void)
}
/* Set up the system variables for a search or replace. If use_answer
* is TRUE, only set backupstring to answer. Return -2 to run opposite
* program (search -> replace, replace -> search), return -1 if the
* search should be canceled (due to Cancel, Go to Line, or a failed
* regcomp()), return 0 on success, and return 1 on rerun calling
* program.
* is TRUE, only set backupstring to answer. Return -2 to run the
* opposite program (search -> replace, replace -> search), return -1 if
* the search should be canceled (due to Cancel, a blank search string,
* Go to Line, or a failed regcomp()), return 0 on success, and return 1
* on rerun calling program.
*
* replacing is TRUE if we call from do_replace(), and FALSE if called
* from do_search(). */
@@ -168,41 +168,37 @@ int search_init(bool replacing, bool use_answer)
buf = mallocstrcpy(NULL, "");
/* This is now one simple call. It just does a lot. */
i = do_prompt(FALSE, replacing ? replace_list : whereis_list,
backupstring,
i = do_prompt(FALSE,
#ifndef DISABLE_TABCOMP
TRUE,
#endif
replacing ? replace_list : whereis_list, backupstring,
#ifndef NANO_TINY
&search_history,
#endif
"%s%s%s%s%s%s", _("Search"),
edit_refresh, "%s%s%s%s%s%s", _("Search"),
#ifndef NANO_TINY
/* This string is just a modifier for the search prompt; no
* grammar is implied. */
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") :
#endif
"",
"",
#ifdef HAVE_REGEX_H
/* This string is just a modifier for the search prompt; no
* grammar is implied. */
ISSET(USE_REGEXP) ? _(" [Regexp]") :
#endif
"",
"",
#ifndef NANO_TINY
/* This string is just a modifier for the search prompt; no
* grammar is implied. */
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") :
#endif
"",
replacing ?
"", replacing ?
#ifndef NANO_TINY
openfile->mark_set ? _(" (to replace) in selection") :
openfile->mark_set ? _(" (to replace) in selection") :
#endif
_(" (to replace)") : "",
buf);
_(" (to replace)") : "", buf);
/* Release buf now that we don't need it anymore. */
free(buf);
@@ -273,25 +269,25 @@ bool findnextstr(
bool no_sameline, const filestruct *begin, size_t begin_x, const
char *needle, size_t *needle_len)
{
filestruct *fileptr = openfile->current;
const char *rev_start = NULL, *found = NULL;
size_t found_len;
/* The length of the match we found. */
/* The length of the match we find. */
size_t current_x_find = 0;
/* The location in the current line of the match we found. */
/* The location in the current line of the match we find. */
ssize_t current_y_find = openfile->current_y;
filestruct *fileptr = openfile->current;
const char *rev_start = fileptr->data, *found = NULL;
/* rev_start might end up 1 character before the start or after the
* end of the line. This won't be a problem because strstrwrapper()
* will return immediately and say that no match was found, and
* rev_start will be properly set when the search continues on the
* previous or next line. */
rev_start =
rev_start +=
#ifndef NANO_TINY
ISSET(BACKWARDS_SEARCH) ?
fileptr->data + (openfile->current_x - 1) :
openfile->current_x - 1 :
#endif
fileptr->data + (openfile->current_x + 1);
openfile->current_x + 1;
/* Look for needle in the current line we're searching. */
while (TRUE) {
@@ -343,6 +339,7 @@ bool findnextstr(
return FALSE;
}
/* Move to the previous or next line in the file. */
#ifndef NANO_TINY
if (ISSET(BACKWARDS_SEARCH)) {
fileptr = fileptr->prev;
@@ -916,11 +913,15 @@ void do_replace(void)
last_replace = mallocstrcpy(last_replace, "");
i = do_prompt(FALSE, replace_list_2, last_replace,
i = do_prompt(FALSE,
#ifndef DISABLE_TABCOMP
TRUE,
#endif
replace_list_2, last_replace,
#ifndef NANO_TINY
&replace_history,
#endif
_("Replace with"));
edit_refresh, _("Replace with"));
#ifndef NANO_TINY
/* Add this replace string to the replace history list. i == 0
@@ -980,11 +981,15 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
char *ans = mallocstrcpy(NULL, answer);
/* Ask for it. */
int i = do_prompt(FALSE, gotoline_list, use_answer ? ans : "",
int i = do_prompt(FALSE,
#ifndef DISABLE_TABCOMP
TRUE,
#endif
gotoline_list, use_answer ? ans : "",
#ifndef NANO_TINY
NULL,
#endif
_("Enter line number, column number"));
edit_refresh, _("Enter line number, column number"));
free(ans);
@@ -1076,7 +1081,7 @@ bool find_bracket_match(bool reverse, const char *bracket_set)
const char *rev_start = NULL, *found = NULL;
ssize_t current_y_find = openfile->current_y;
assert(strlen(bracket_set) == 2);
assert(mbstrlen(bracket_set) == 2);
/* rev_start might end up 1 character before the start or after the
* end of the line. This won't be a problem because we'll skip over
@@ -1091,8 +1096,8 @@ bool find_bracket_match(bool reverse, const char *bracket_set)
while (TRUE) {
found = ((rev_start > fileptr->data && *(rev_start - 1) ==
'\0') || rev_start < fileptr->data) ? NULL : (reverse ?
revstrpbrk(fileptr->data, bracket_set, rev_start) :
strpbrk(rev_start, bracket_set));
mbrevstrpbrk(fileptr->data, bracket_set, rev_start) :
mbstrpbrk(rev_start, bracket_set));
/* We've found a potential match. */
if (found != NULL)
@@ -1130,28 +1135,38 @@ void do_find_bracket(void)
{
filestruct *current_save;
size_t current_x_save, pww_save;
const char *bracket_list = "()<>[]{}";
/* The list of brackets we can find matches to. */
const char *pos;
/* The location in bracket_list of the bracket at the current
const char *ch;
/* The location in matchbrackets of the bracket at the current
* cursor position. */
char ch;
/* The bracket at the current cursor position. */
char wanted_ch;
/* The bracket complementing the bracket at the current cursor
* position. */
char bracket_set[3];
int ch_len;
/* The length of ch in bytes. */
const char *wanted_ch;
/* The location in matchbrackets of the bracket complementing
* the bracket at the current cursor position. */
int wanted_ch_len;
/* The length of wanted_ch in bytes. */
char *bracket_set;
/* The pair of characters in ch and wanted_ch. */
size_t i;
/* Generic loop variable. */
size_t matchhalf;
/* The number of single-byte characters in one half of
* matchbrackets. */
size_t mbmatchhalf;
/* The number of multibyte characters in one half of
* matchbrackets. */
size_t count = 1;
/* The initial bracket count. */
bool reverse;
/* The direction we search. */
char *found_ch;
/* The character we find. */
assert(strlen(bracket_list) % 2 == 0);
assert(mbstrlen(matchbrackets) % 2 == 0);
ch = openfile->current->data[openfile->current_x];
ch = openfile->current->data + openfile->current_x;
if (ch == '\0' || (pos = strchr(bracket_list, ch)) == NULL) {
if (ch == '\0' || (ch = mbstrchr(matchbrackets, ch)) == NULL) {
statusbar(_("Not a bracket"));
return;
}
@@ -1161,21 +1176,54 @@ void do_find_bracket(void)
current_x_save = openfile->current_x;
pww_save = openfile->placewewant;
/* If we're on an opening bracket, we want to search forwards for a
* closing bracket, and if we're on a closing bracket, we want to
* search backwards for an opening bracket. */
reverse = ((pos - bracket_list) % 2 != 0);
wanted_ch = reverse ? *(pos - 1) : *(pos + 1);
bracket_set[0] = ch;
bracket_set[1] = wanted_ch;
bracket_set[2] = '\0';
/* If we're on an opening bracket, which must be in the first half
* of matchbrackets, we want to search forwards for a closing
* bracket. If we're on a closing bracket, which must be in the
* second half of matchbrackets, we want to search backwards for an
* opening bracket. */
matchhalf = 0;
mbmatchhalf = mbstrlen(matchbrackets) / 2;
for (i = 0; i < mbmatchhalf; i++)
matchhalf += parse_mbchar(matchbrackets + matchhalf, NULL,
NULL);
reverse = ((ch - matchbrackets) >= matchhalf);
/* If we're on an opening bracket, set wanted_ch to the character
* that's matchhalf characters after ch. If we're on a closing
* bracket, set wanted_ch to the character that's matchhalf
* characters before ch. */
wanted_ch = ch;
while (mbmatchhalf > 0) {
if (reverse)
wanted_ch = matchbrackets + move_mbleft(matchbrackets,
wanted_ch - matchbrackets);
else
wanted_ch += move_mbright(wanted_ch, 0);
mbmatchhalf--;
}
ch_len = parse_mbchar(ch, NULL, NULL);
wanted_ch_len = parse_mbchar(wanted_ch, NULL, NULL);
/* Fill bracket_set in with the values of ch and wanted_ch. */
bracket_set = charalloc((mb_cur_max() * 2) + 1);
strncpy(bracket_set, ch, ch_len);
strncpy(bracket_set + ch_len, wanted_ch, wanted_ch_len);
null_at(&bracket_set, ch_len + wanted_ch_len);
found_ch = charalloc(mb_cur_max() + 1);
while (TRUE) {
if (find_bracket_match(reverse, bracket_set)) {
/* If we found an identical bracket, increment count. If we
* found a complementary bracket, decrement it. */
count += (openfile->current->data[openfile->current_x] ==
ch) ? 1 : -1;
parse_mbchar(openfile->current->data + openfile->current_x,
found_ch, NULL);
count += (strncmp(found_ch, ch, ch_len) == 0) ? 1 : -1;
/* If count is zero, we've found a matching bracket. Update
* the screen and get out. */
@@ -1193,6 +1241,10 @@ void do_find_bracket(void)
break;
}
}
/* Clean up. */
free(bracket_set);
free(found_ch);
}
#ifdef ENABLE_NANORC

View File

@@ -3,7 +3,7 @@
* text.c *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -152,7 +152,8 @@ void do_delete(void)
update_line(openfile->current, openfile->current_x);
}
/* Backspace over one character. */
/* Backspace over one character. That is, move the cursor left one
* character, and then delete the character there. */
void do_backspace(void)
{
if (openfile->current != openfile->fileage ||
@@ -746,8 +747,8 @@ void justify_format(filestruct *paragraph, size_t skip)
while (*end != '\0') {
int end_len;
/* If this character is blank, make sure that it's a space with
* no blanks after it. */
/* If this character is blank, change it to a space if
* necessary, and skip over all blanks after it. */
if (is_blank_mbchar(end)) {
end_len = parse_mbchar(end, NULL, NULL);
@@ -770,9 +771,9 @@ void justify_format(filestruct *paragraph, size_t skip)
#endif
}
/* If this character is punctuation optionally followed by a
* bracket and then followed by blanks, make sure there are no
* more than two blanks after it, and make sure that the blanks
* are spaces. */
* bracket and then followed by blanks, change no more than two
* of the blanks to spaces if necessary, and skip over all
* blanks after them. */
} else if (mbstrchr(punct, end) != NULL) {
end_len = parse_mbchar(end, NULL, NULL);
@@ -825,7 +826,7 @@ void justify_format(filestruct *paragraph, size_t skip)
#endif
}
/* If this character is neither blank nor punctuation, leave it
* alone. */
* unchanged. */
} else {
end_len = parse_mbchar(end, NULL, NULL);
@@ -842,7 +843,7 @@ void justify_format(filestruct *paragraph, size_t skip)
*new_end = *end;
/* Make sure that there are no spaces at the end of the line. */
/* If there are spaces at the end of the line, remove them. */
while (new_end > new_paragraph_data + skip &&
*(new_end - 1) == ' ') {
new_end--;
@@ -1667,11 +1668,15 @@ bool do_int_spell_fix(const char *word)
do_replace_highlight(TRUE, exp_word);
/* Allow all instances of the word to be corrected. */
canceled = (do_prompt(FALSE, spell_list, word,
#ifndef NANO_TINY
NULL,
canceled = (do_prompt(FALSE,
#ifndef DISABLE_TABCOMP
TRUE,
#endif
_("Edit a replacement")) == -1);
spell_list, word,
#ifndef NANO_TINY
NULL,
#endif
edit_refresh, _("Edit a replacement")) == -1);
do_replace_highlight(FALSE, exp_word);

View File

@@ -3,7 +3,7 @@
* utils.c *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -81,9 +81,9 @@ bool parse_num(const char *str, ssize_t *val)
return TRUE;
}
/* Read an int and a ssize_t, separated by a comma, from str, and store
* them in *line and *column (if they're not both NULL). On error, we
* return FALSE. Otherwise, we return TRUE. */
/* Read two ssize_t's, separated by a comma, from str, and store them in
* *line and *column (if they're not both NULL). Return FALSE on error,
* or TRUE otherwise. */
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
{
bool retval = TRUE;
@@ -197,7 +197,10 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream)
int c;
/* Sanity checks. */
assert(lineptr != NULL && n != NULL && stream != NULL);
if (lineptr == NULL || n == NULL || stream == NULL) {
errno = EINVAL;
return -1;
}
/* Allocate the line the first time. */
if (*lineptr == NULL) {

View File

@@ -3,7 +3,7 @@
* winio.c *
* *
* Copyright (C) 1999-2004 Chris Allegretta *
* Copyright (C) 2005 David Lawrence Ramsey *
* Copyright (C) 2005-2006 David Lawrence Ramsey *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2, or (at your option) *
@@ -27,7 +27,6 @@
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
static int *key_buffer = NULL;
@@ -123,6 +122,7 @@ void reset_kbinput(void)
void get_key_buffer(WINDOW *win)
{
int input;
size_t errcount;
/* If the keystroke buffer isn't empty, get out. */
if (key_buffer != NULL)
@@ -137,14 +137,19 @@ void get_key_buffer(WINDOW *win)
* screen updates. */
doupdate();
errcount = 0;
while ((input = wgetch(win)) == ERR) {
/* If errno is EIO, it means that the input source that we were
* using is gone, so die gracefully. */
if (errno == EIO)
errcount++;
/* If we've failed to get a character MAX_BUF_SIZE times in a
* row, assume that the input source we were using is gone and
* die gracefully. We could check if errno is set to EIO
* ("Input/output error") and die gracefully in that case, but
* it's not always set properly. Argh. */
if (errcount == MAX_BUF_SIZE)
handle_hupterm(0);
}
#ifndef NANO_TINY
allow_pending_sigwinch(FALSE);
#endif
@@ -469,10 +474,36 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key
retval = NANO_END_KEY;
break;
#endif
#ifdef KEY_SUSPEND
/* Slang doesn't support KEY_SUSPEND. */
case KEY_SUSPEND:
retval = NANO_SUSPEND_KEY;
#ifdef KEY_SBEG
/* Slang doesn't support KEY_SBEG. */
case KEY_SBEG: /* Center (5) on numeric keypad
* with NumLock off. */
break;
#endif
#ifdef KEY_SDC
/* Slang doesn't support KEY_SDC. */
case KEY_SDC:
retval = ISSET(REBIND_DELETE) ?
NANO_BACKSPACE_KEY : NANO_DELETE_KEY;
break;
#endif
#ifdef KEY_SEND
/* HP-UX 10 and 11 don't support KEY_SEND. */
case KEY_SEND:
retval = NANO_END_KEY;
break;
#endif
#ifdef KEY_SHOME
/* HP-UX 10 and 11 and Slang don't support
* KEY_SHOME. */
case KEY_SHOME:
retval = NANO_HOME_KEY;
break;
#endif
#ifdef KEY_SIC
/* Slang doesn't support KEY_SIC. */
case KEY_SIC:
retval = NANO_INSERTFILE_KEY;
break;
#endif
#ifdef KEY_SLEFT
@@ -486,6 +517,18 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key
case KEY_SRIGHT:
retval = NANO_FORWARD_KEY;
break;
#endif
#ifdef KEY_SSUSPEND
/* Slang doesn't support KEY_SSUSPEND. */
case KEY_SSUSPEND:
retval = NANO_SUSPEND_KEY;
break;
#endif
#ifdef KEY_SUSPEND
/* Slang doesn't support KEY_SUSPEND. */
case KEY_SUSPEND:
retval = NANO_SUSPEND_KEY;
break;
#endif
default:
retval = *kbinput;
@@ -1753,8 +1796,7 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
/* The string we return. */
size_t index;
/* Current position in converted. */
char *buf_mb = charalloc(mb_cur_max());
char *buf_mb;
int buf_mb_len;
/* If dollars is TRUE, make room for the "$" at the end of the
@@ -1765,15 +1807,29 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
if (len == 0)
return mallocstrcpy(NULL, "");
buf_mb = charalloc(mb_cur_max());
start_index = actual_x(buf, start_col);
column = strnlenpt(buf, start_index);
assert(column <= start_col);
/* Allocate enough space for the entire line. */
alloc_len = (mb_cur_max() * (COLS + 1));
/* Make sure there's enough room for the initial character, whether
* it's a multibyte control character, a non-control multibyte
* character, a tab character, or a null terminator. Rationale:
*
* multibyte control character followed by a null terminator:
* 1 byte ('^') + mb_cur_max() bytes + 1 byte ('\0')
* multibyte non-control character followed by a null terminator:
* mb_cur_max() bytes + 1 byte ('\0')
* tab character followed by a null terminator:
* mb_cur_max() bytes + (tabsize - 1) bytes + 1 byte ('\0')
*
* Since tabsize has a minimum value of 1, it can substitute for 1
* byte above. */
alloc_len = (mb_cur_max() + tabsize + 1) * MAX_BUF_SIZE;
converted = charalloc(alloc_len);
converted = charalloc(alloc_len + 1);
index = 0;
if (buf[start_index] != '\t' && (column < start_col || (dollars &&
@@ -1810,9 +1866,17 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
#endif
}
while (index < alloc_len - 1 && buf[start_index] != '\0') {
while (buf[start_index] != '\0') {
buf_mb_len = parse_mbchar(buf + start_index, buf_mb, NULL);
/* Make sure there's enough room for the next character, whether
* it's a multibyte control character, a non-control multibyte
* character, a tab character, or a null terminator. */
if (index + mb_cur_max() + tabsize + 1 >= alloc_len - 1) {
alloc_len += (mb_cur_max() + tabsize + 1) * MAX_BUF_SIZE;
converted = charealloc(converted, alloc_len);
}
/* If buf contains a tab character, interpret it. */
if (*buf_mb == '\t') {
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
@@ -1884,8 +1948,10 @@ char *display_string(const char *buf, size_t start_col, size_t len, bool
free(buf_mb);
if (index < alloc_len - 1)
converted[index] = '\0';
assert(alloc_len >= index + 1);
/* Null terminate converted. */
converted[index] = '\0';
/* Make sure converted takes up no more than len columns. */
index = actual_x(converted, len);
@@ -1904,7 +1970,7 @@ void titlebar(const char *path)
{
int space = COLS;
/* The space we have available for display. */
size_t verlen = strlenpt(VERMSG) + 1;
size_t verlen = strlenpt(PACKAGE_STRING) + 1;
/* The length of the version message in columns, plus one for
* padding. */
const char *prefix;
@@ -1944,7 +2010,8 @@ void titlebar(const char *path)
if (space >= 4) {
/* Add a space after the version message, and account for both
* it and the two spaces before it. */
mvwaddnstr(topwin, 0, 2, VERMSG, actual_x(VERMSG, verlen));
mvwaddnstr(topwin, 0, 2, PACKAGE_STRING,
actual_x(PACKAGE_STRING, verlen));
verlen += 3;
/* Account for the full length of the version message. */
@@ -2772,6 +2839,11 @@ void edit_redraw(const filestruct *old_current, size_t old_pww)
openfile->edittop = old_edittop;
/* Update old_current if we're not on the first page and/or
* we're not on the same page as before. */
if (do_redraw)
update_line(old_current, 0);
/* Scroll the edit window up or down until edittop is in range
* of current. */
if (nlines < 0)