Compare commits

...

113 Commits

Author SHA1 Message Date
Chris Allegretta
aa4593124d GNU nano 1.2.1 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1492 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-04-20 16:20:15 +00:00
Chris Allegretta
8151ba5a1a DLR's patch to change justify_mode to a flag
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1491 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-04-19 19:34:05 +00:00
Chris Allegretta
4b376a4982 latest fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1490 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-04-16 02:08:23 +00:00
Chris Allegretta
e1e0fd634b DLR and DB's latest fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1489 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-04-15 01:15:09 +00:00
Jordi Mallach
0f4a7dc53a French and Malay updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1488 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-04-12 00:29:16 +00:00
Jordi Mallach
e2a9e3c5fa Sigh. It's nanorc.sample...
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1487 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-03-24 13:09:26 +00:00
Jordi Mallach
db469d8666 Documentation updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1486 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-03-24 13:08:16 +00:00
Jordi Mallach
8f711b8d6b Malay translation update.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1485 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-03-17 21:53:57 +00:00
Chris Allegretta
d845193a1d DLR's cumulative patch, one minor configure.ac tweak
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1484 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-03-11 03:50:40 +00:00
Jordi Mallach
53c3b47bf9 Danish update.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1483 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-03-10 09:34:27 +00:00
Jordi Mallach
23f575628a Malay and Indonesian updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1482 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-03-06 14:09:24 +00:00
Jordi Mallach
723399a3a2 Dutch update.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1481 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-23 19:12:54 +00:00
Chris Allegretta
dbc3ec72e1 Back to CVS
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1480 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-20 03:14:37 +00:00
Chris Allegretta
2b4ead9cb8 GNU nano 1.2.0 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1478 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-20 01:56:02 +00:00
Chris Allegretta
a7a78decb6 - nano.c:justify_format() - Fix ugly behavior when wrapping spaces at the end of long words (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1477 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-19 22:27:53 +00:00
Jordi Mallach
593a0678b8 Finnish and Spanish update :)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1476 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-19 15:56:49 +00:00
Jordi Mallach
9658c4cd82 Updated German, Ukrainian and Russian translations.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1475 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-17 14:16:22 +00:00
Jordi Mallach
e0516f330f Galician & French update.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1474 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-16 16:10:02 +00:00
Chris Allegretta
33ac7b9181 - files.c:read_file() - If the file we're loading has already been detected as a DOS or Mac formatted file, don't turn on NOCONVERT if we find binary chars in it. This is because if it's detected as DOS/Mac format, at least one line has already been converted so setting NOCONVERT (which is supposed to signal that none of the file should be converted) makes no sense. (DLR)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1473 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-16 03:13:47 +00:00
Jordi Mallach
1aa8541c5c Updated French, Dutch, Swedish and Catalan translations.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1472 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-15 15:52:56 +00:00
Jordi Mallach
fc71eb5f72 nanorc.5 fixes from DB.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1471 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-15 13:34:03 +00:00
Jordi Mallach
07e2000094 Format fix for nanorc.5
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1470 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-14 22:10:14 +00:00
Chris Allegretta
3d3325129c Back to CVS
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1469 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-14 03:10:12 +00:00
Chris Allegretta
7ba3279073 GNU nano 1.1.99pre3 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1468 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-14 03:09:35 +00:00
Chris Allegretta
f717f98d07 Revert const char * strings as it gives warnings with -Wwrite-strings
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1467 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 22:25:01 +00:00
Chris Allegretta
d3c8f09d17 Use homenv variable instead of getenv(HOME) 3 times in do_rcfile
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1466 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 22:18:24 +00:00
Chris Allegretta
1debce2865 More getpwent changes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1465 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 22:00:19 +00:00
Jordi Mallach
5acbc8bb0d Updated Russian translation.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1464 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 15:58:20 +00:00
Jordi Mallach
aebfac8567 Add upgrading information for nano 1.0 users.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1463 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 12:50:53 +00:00
Chris Allegretta
fee360a06f Fix uneeded content type message from man pages
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1462 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 04:08:04 +00:00
Chris Allegretta
4f989faa6e - Moved nano.1 color and syntax sections to nanorc, pointed nano.1 to nanorc.5 for initialization file. Changed nanorc.5 variables to be italics to match nano.1. Added nanorc.5.html to CVS tree
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1461 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 04:01:49 +00:00
Chris Allegretta
2e39c1c283 - rcfile.c:do_rcfile() - Revert (somewhat) previous behavior of looking at /home/chrisa, and only run getpw* if it is NULL. Most *nix programs seem to only care about /home/chrisa, and at the user-level getpw* may not be reliable (and its slower)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1460 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 03:36:15 +00:00
Chris Allegretta
65f075d3a1 - Change resetpos function to be global (now called resetstatuspos. Fixes annoying but small odd problem with cursor placement when inserting a file. This needs to be done better in 1.3 (originally by David Lawrence Ramsey) Added this issue to TODO
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1459 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 03:03:49 +00:00
Chris Allegretta
bcc8688a3b - Remove do_preserve_msg, as using -p still gives Pico-style string behavior, so an annoying message every invocation is probably unneeded (all cheer)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1458 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 01:54:41 +00:00
Chris Allegretta
d0845df735 Oops, we should probably re-initialize keyhandled each iteration of the main loop ;-)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1457 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 00:56:57 +00:00
Chris Allegretta
fe1d0722d4 - nano.c:main() - Silence annoying compiler messages about clobbering and uninitialized variables by moving variable inits to the top of main() and re-initializing them after the sigsetjmp()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1456 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-13 00:52:49 +00:00
Chris Allegretta
a0449d92a0 - files.c: load_history() - Fix segfault on loading huge strings from history file (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1455 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-12 23:58:01 +00:00
Chris Allegretta
7641708cb6 - nano.c:do_suspend() - Fix untranslated message (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1454 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-12 23:54:34 +00:00
Chris Allegretta
e9b5c6fe90 - winio.c:browser_init(), striponedir(), do_browse_from() - Various memory leak fixes (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1453 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-12 23:49:56 +00:00
Chris Allegretta
d127c71ab3 - nano.c:do_wrap() - Fix isspace() call to operate on int
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1452 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-12 23:20:45 +00:00
Chris Allegretta
b2cd248d1c const char * fixes and defined(NCURSES_MOUSE_VERSION) additions to winio.c funcs that need them
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1451 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-12 23:18:19 +00:00
Chris Allegretta
428f620370 DB's justify fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1450 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-12 03:21:45 +00:00
Chris Allegretta
fdcb9e92d6 - Memory leak fixes for files.c:do_insertfile(),do_browser(), nano.c:do_spell(), and search.c:do_replace() (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1449 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-12 02:52:04 +00:00
Jordi Mallach
a4a9d1759f Added --keyword=P_:1,2 to XGETTEXT_OPTIONS.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1448 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-10 11:33:43 +00:00
Jordi Mallach
d16f9f66a1 Change ngettext macro to P_(), to avoid clash with C's __ identifier.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1447 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-10 11:30:11 +00:00
Jordi Mallach
65f998e429 Silly reformat.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1446 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-10 11:27:04 +00:00
Jordi Mallach
f16ca28efb Update, not doing Spanish anymore...
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1445 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-10 10:54:05 +00:00
Chris Allegretta
4640fe3f57 - nano.c:do_help () - Fix line lengths not being computed properly, causes display glitches most noticeable with < 20 rows. New function nano.c:line_len(). (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1444 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-10 03:10:03 +00:00
Chris Allegretta
a90d0cf214 DB's gotoline fix
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1443 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-10 02:55:03 +00:00
Chris Allegretta
f8f2d586dc DB's fill and window length fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1442 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-10 02:43:48 +00:00
Chris Allegretta
3a78406d56 - nano.c:help_init() - Fix crashing in do_help when COLS < 23 (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1441 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-10 02:32:58 +00:00
Jordi Mallach
2ddd75e705 Updated Finnish translation.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1440 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-09 23:51:17 +00:00
Jordi Mallach
e61be2dd6d Fix it better.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1439 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-09 23:50:42 +00:00
Chris Allegretta
992a25a69c * it.po: Fix broken format string in translation
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1438 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-09 03:33:51 +00:00
Jordi Mallach
a66a8f72a4 Add nanorc.5 manpage.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1437 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-09 01:28:40 +00:00
Jordi Mallach
ab5fec61a8 Spanish update.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1436 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-09 00:04:35 +00:00
Chris Allegretta
97e10b5d0d - nano.spec.in - Change default flags to --enable-all
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1435 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-08 22:05:50 +00:00
Jordi Mallach
588df68a8c Italian and Galician updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1434 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-08 22:02:17 +00:00
Chris Allegretta
bfc8b2ac4d - winio.c:nanogetstr() - Remove unnecessary reset of x since it is now handled elsewhere (David Lawrence Ramsey)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1433 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-08 21:49:13 +00:00
Chris Allegretta
bcaeeb4411 Add the ChangeLog entry for the 2nd half of DB's patch
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1432 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-08 02:03:26 +00:00
Chris Allegretta
3cdf6ff1de - files.c:input_tab() - Fix assumption that matches is null terminated (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1431 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-08 02:02:02 +00:00
Chris Allegretta
17ec14b9a5 Better fix hopefully for color issue
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1430 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-07 00:19:05 +00:00
Chris Allegretta
a3daf3a256 - nanorc.sample: - Make nanorc entry less tolerant of invalid colors
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1429 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-07 00:11:55 +00:00
Chris Allegretta
d6e84363d7 - rcfile.c:colortoint() - Don't bomb after invalid color and print bad color name (David Benbennick). And reset mcolor to -1.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1428 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-07 00:02:00 +00:00
Jordi Mallach
3083ff908c Polish and Swedish updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1427 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-06 02:01:57 +00:00
Chris Allegretta
201f1d976a - Fix globals and externs such that nano will compile with DISABLE_SPELLER (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1426 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-05 02:51:19 +00:00
Chris Allegretta
5ec68628ce - Fix nano not compiling with ENABLE_RCFILE BLE_TABCOMP (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1425 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-05 02:39:34 +00:00
Chris Allegretta
5ea694ebd1 - nano.1, nano.1.html: - Add initialization file comments, change some options from bracketed to underlined to emphasize that they are not optional
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1424 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-04 14:24:54 +00:00
Jordi Mallach
a577d5a8b8 Catalan, French, Ukrainian and German updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1423 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-04 14:13:36 +00:00
Chris Allegretta
cddbfd0988 Back to CVS
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1422 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 15:29:56 +00:00
Chris Allegretta
5c8c276622 GNU nano 1.1.99pre2 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1420 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 15:21:27 +00:00
Chris Allegretta
7dace110b0 Translate cancelled string in files.c (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1419 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 07:26:38 +00:00
Chris Allegretta
d89eb91e77 Apply the same regexp_init checks to using last|search in search_init()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1418 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 07:07:40 +00:00
Chris Allegretta
c45335782a - files.c:save_history() Fix off-by-one bug causing write to unallocated memory (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1417 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 05:04:09 +00:00
Chris Allegretta
434d686ee4 files.c:do_insertfile() - Add some more checks and fix recursion when toggling multibuffer (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1416 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 04:55:17 +00:00
Chris Allegretta
0eab236580 files.c:do_browser() - Even more checks and operating dir fixes (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1415 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 03:39:05 +00:00
Chris Allegretta
dbfc56cb8e Oops, now credit DB
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1414 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 03:33:04 +00:00
Chris Allegretta
a0d89977b7 - Fix screen getting trashed on signals nano can catch (TERM and HUP). New global variable curses_ended changes to winio.c:statubar() and nano.c:die()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1413 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 03:32:08 +00:00
Chris Allegretta
cff6e6f60f DB's justify patch
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1412 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 03:22:02 +00:00
Chris Allegretta
ce452fb880 DB's debug and multibuffer and regcomp fix to make nano less of a complete cpu hog
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1411 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-03 02:56:44 +00:00
Chris Allegretta
5c63f27721 Dlr's revert multibuffer and view mode patch
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1410 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-02-02 04:26:54 +00:00
Chris Allegretta
f80a59c7cc - files.c:do_browser() - Fix goto directory operating dir check and tilde expansion (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1409 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-30 00:57:33 +00:00
Chris Allegretta
858d9d90cb - files.c:do_browse_from() - Fix path checking to fix bad paths, escaping the operating directory, new function readable_dir() (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1408 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-30 00:53:32 +00:00
Chris Allegretta
2a7b8b24bb -nano.c:do_justify() - Unset KEEP_CUTBUFFER so nano won't crash with subsequent ^K cuts and justifies (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1407 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-30 00:42:20 +00:00
Chris Allegretta
5d71514f21 - Fix nano crashing when searching/replacing an invalid regex (try ^*). Changed regexp_init() to return 1 or 0 based on regcomp()'s return value and search_init to exit with an error message (sorry Jordi)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1406 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-29 04:18:37 +00:00
Chris Allegretta
e92a7bcb78 - nano.c:do_mouse() - Fix the mouse code to work with lines longer than COLS and with the proper positioning, including special characters (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1405 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-28 01:36:38 +00:00
Chris Allegretta
db28e96f2c - winio.c:do_yesno() - Fix mouse interaction bugs with yes/no prompt (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1404 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-28 01:23:40 +00:00
Chris Allegretta
d26ab913f1 - Fix constant curos updates from obliterating other system messages, and fix statusbar message length. Affects files.c:load_open_file(), nano.c:main(), search.c:findnextstr(), winio.c:statusbar() and do_cursorpos() (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1403 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-28 01:16:47 +00:00
Jordi Mallach
416896efcd Updated Spanish translation.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1402 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-27 13:06:51 +00:00
Chris Allegretta
b698c35f4b - files.c:do_browser() - Fix incorrect path check for check_operating_dir() (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1401 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 22:05:07 +00:00
Chris Allegretta
a340766790 - nano.c:do_char() - Remove unneeded check_statblank() (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1400 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 21:13:03 +00:00
Chris Allegretta
47fcfe5d78 - Fix cursor position being saved when escaping out of nanogetstr with keys like ^Y and ^V. New arg resetpos to nanogetstr(), added static int resetpos in statusq() (bug found by DLR)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1399 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 21:01:16 +00:00
Chris Allegretta
8a85aa0baa - search.c:do_search(), do_replace_loop() - Fix edit_update call to use CENTER instead of current_x (related to David Benbennick's fixes for spelling)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1398 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 20:02:15 +00:00
Chris Allegretta
64fc78c0f1 - nano.c:do_int_spell_fix(), do_int_speller() - Fix crashes with mark position, current_x position and edit_update args (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1397 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 19:57:44 +00:00
Chris Allegretta
63d0b48d5b - winio.c:edit_refresh() - Fix cursor being above as well as below the current screen (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1396 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 19:47:10 +00:00
Chris Allegretta
77e726d518 - files.c:save_history() - Fix nrealloc return value being ignored (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1395 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 19:36:08 +00:00
Jordi Mallach
fa1588608e Updated Polish translation from Wojciech Kotwica.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1394 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 13:08:38 +00:00
Chris Allegretta
9090f2e44b General - Fix subexpression replacement to work consistently. Affects search.c:replace_regexp() and utils.c:strstrwrapper() (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1393 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 04:45:05 +00:00
Chris Allegretta
1939c3590b - search.c:do_replace_loop() - Fix various bugs having to do with replace string length and positioning (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1392 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 04:26:25 +00:00
Chris Allegretta
1a128afdb2 - nano.c:window_init() - Fix leaking *WINDOWs (no pun intended) (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1391 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 04:15:56 +00:00
Chris Allegretta
54c1f7932c - files.c:open_file() - Fix FD leak with file load error (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1390 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 04:11:09 +00:00
Chris Allegretta
149781d827 - cut.c:do_cut_text() - Fix incorrect cursor location when cutting long lines (David Benbennick)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1389 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-26 03:54:00 +00:00
Jordi Mallach
beca0eb699 Updated Galician translation.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1388 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-25 18:20:26 +00:00
Chris Allegretta
0e86e60653 - Changed some translatable debug messages to use %s instead of the function name, and removed gettext from two strings that had no actual words in them that should be translated. Suggested originally by Christian Rose
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1387 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-23 04:27:23 +00:00
Chris Allegretta
f22e8bf775 - nanorc.sample: - Change comment to say magenta instead of purple
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1386 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-23 01:21:26 +00:00
Chris Allegretta
3bbc416a73 - winio.c:bottombars() - Change strcpy of gettext() Up string to strncpy of max width 8, to stop stupid strcpy crash
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1385 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-23 00:46:12 +00:00
Jordi Mallach
d66349963c Updated German translation (Michael Piefel).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1384 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-22 13:23:05 +00:00
Chris Allegretta
36fec72f6a nano.c:usage() - Revamp -H option message to fit in 80 column terminal
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1383 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-22 01:13:25 +00:00
Chris Allegretta
3d459ad83d nano.c:main() - Call load_file with arg 0 for insert, as we aren't really doing an insert, allows new_file() to run if we open a non-file at startup
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1382 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-22 01:09:40 +00:00
Jordi Mallach
73a7e7f450 Updated French, Malay and Ukrainian translations.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1381 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-21 12:54:43 +00:00
Jordi Mallach
eeb500428d i18n fixes.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1380 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-18 22:42:34 +00:00
Jordi Mallach
8495c71dd0 French, Swedish, Dutch and Catalan updates.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1379 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-18 15:45:49 +00:00
Chris Allegretta
f89d698293 Back to CVS
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1378 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2003-01-17 22:31:25 +00:00
56 changed files with 13798 additions and 13572 deletions

View File

@@ -8,7 +8,7 @@ Chris Allegretta <chrisa@asty.org>
Jordi Mallach <jordi@sindominio.net>
* Debian package maintainer, fellow bug squasher.
* Internationalization support head, es.po maintainer.
* Internationalization support head, ca.po maintainer.
Adam Rogoyski <rogoyski@cs.utexas.edu>
* New write_file() function, read_file() optimization, mouse

313
ChangeLog
View File

@@ -1,3 +1,316 @@
GNU nano 1.2.1 - 2003.04.19
- General:
- Translation updates (see po/ChangeLog for details).
- Work around broken regexec() on some systems that segfaults
when passed an empty string. New function regexec_safe().
(David Benbennick)
- Fix various bugs with search string history logging: don't
print a broken error message and freeze if ~/.nano_history is
unreadable, actually show an error message in save_history()
if ~/.nano_history is unwritable, and prevent ~/.nano_history
from being completely overwritten by save_history() if it's
unreadable but writable. (David Benbennick)
- Only unset KEEP_CUTBUFFER in main() when we do something other
than cut text in the main input loop, instead of unsetting it
all over the place (which, as written, didn't handle cases
like a cut followed by M-Space properly). Also, instead of
checking for keyhandled's not being set inside the for loops,
do it in if blocks surrounding the for loops to increase
efficiency. (David Benbennick) DLR: Also unset KEEP_CUTBUFFER
if we hit a shortcut key other than the one for cutting text.
- Make it so a marked cut immediately followed by an unmarked
cut tacks the latter's text onto the end of the former's text
instead of putting it on a new line, as Pico does. (DLR)
- Convert instances of "(char *)nrealloc()" to the macro
charealloc(), which does the same thing. (DLR)
- Change justify_mode from a boolean int to a flag (DLR).
- cut.c:
do_cut_text()
- Tweak where KEEP_CUTBUFFER is set so that a marked cut
immediately followed by an unmarked cut preserves the
cutbuffer between the two. (David Benbennick) DLR: Also
properly set KEEP_CUTBUFFER in tiny mode.
do_uncut_text()
- If we're about to uncut on the magicline, always make a new
magicline in advance, as Pico does. (DLR)
- global.c:
shortcut_init()
- Simplify the #ifdef used to enable file insertion in view mode
if multibuffer support has been compiled in. (DLR)
- nano.c:
justify_format()
- If we shave spaces off the end of the line, make sure totsize
is properly updated. (DLR; much simplified by David
Benbennick)
- nano.h:
- Simplify #ifdefs relating to HAVE_STRCASECMP and
HAVE_STRNCASECMP. (David Benbennick)
- search.c:
goto_abort()
- Removed, with all instances replaced with display_main_list(),
since with the removal of all the scattered calls to
SET(KEEP_CUTBUFFER), that function was all that was left of
it. (DLR)
do_find_bracket()
- If a matching bracket wasn't found, call update_line() after
setting current and current_x back to their original values,
in case current_x's original value is greater than the width
of the screen. (DLR)
- winio.c:
nanogetstr()
- Remove a few unnecessary breaks occurring immediately after
gotos, and properly interpret the up and down arrow keys when
ALT_KEYPAD is set. (DLR)
- configure.ac:
- Enable autodetection of broken regexec(). (DLR) Re-added
regex.h check to ensure compile under Debian w/autoconf 1.6.
- README:
- Update obsolete 1.1.x information.
- TODO:
- Fix typo. (David Benbennick)
- faq.html:
- Update RPM links for nano 1.2.x. (DLR)
GNU nano 1.2.0 - 2003.02.19
- General:
- Translation updates (see po/ChangeLog for details).
- files.c:
read_file()
- If the file we're loading has already been detected as a DOS
or Mac formatted file, don't turn on NOCONVERT if we find
binary chars in it. This is because if it's detected as
DOS/Mac format, at least one line has already been converted,
so setting NOCONVERT (which is supposed to signal that none
of the file should be converted) makes no sense. (DLR)
- nano.c:
justify_format()
- Fix ugly behavior when wrapping spaces at the end of long
words (David Benbennick).
- nanorc.5:
- Fix formatting error and update copyright year (Jordi).
- Several enhancements (David Benbennick).
GNU nano 1.1.99pre3 - 2003.02.13
- General:
- Translation updates (see po/ChangeLog for details).
- Fix globals and externs such that nano will compile with
DISABLE_SPELLER (David Benbennick).
- Fix unreasonable fill values by wrapping at length 0 instead
of erroring out, and don't start up if the window size is too
small but fill is set reasonably. Changes to
nano.c:global_init(), window_init(), and handle_sigwinch().
New macro MIN_EDITOR_COLS replaces MIN_FILL_LENGTH
(David Benbennick).
- Change ngettext macro to P_(), to avoid a clash with the
reserved C __ identifier (Jordi).
- Memory leak fixes for files.c:do_insertfile(),do_browser(),
nano.c:do_spell(), and search.c:do_replace() (David
Benbennick).
- Remove do_preserve_msg, as using -p still gives Pico-style
string behavior, so an annoying message every invocation is
probably unneeded (all cheer).
- Change resetpos function to be global (now called
resetstatuspos. Fixes annoying but small odd problem with
cursor placement when inserting a file. This needs to be done
better in 1.3 (originally by David Lawrence Ramsey). Added
this issue to TODO.
- files.c:
cwd_tab_completion()
- Memory leak fix (David Benbennick).
intput_tab()
- Fix assumption that matches is null terminated (David
Benbennick).
load_history()
- Fix segfault on loading huge strings from history file
(David Benbennick).
load_history(), save_history()
- Changed to look at $HOME before getpwuid(geteuid()), see
details in comment for rcfile.c:do_rcfile().
real_dir_from_tilde()
- Change check for the running user's home dir to use
getpwuid(geteuid()) rather than a getpwent() loop
(suggested by Jordi).
- nano.c:
breakable()
- Fix incorrect return value on short lines (David Benbennick).
do_help()
- Fix line lengths not being computed properly, causes display
glitches most noticeable with < 20 rows. New function
nano.c:line_len(). (David Benbennick).
do_justify()
- Add regfree() to quote regex (David Benbennick).
- Only copy previous indent if AUTOINDENT is set (David
Benbennick).
do_suspend()
- Fix untranslated message (David Benbennick).
do_wrap()
- Fix isspace() call to operate on int.
help_init()
- Fix crashing in do_help when COLS < 23 (David Benbennick).
main()
- Fix nano not compiling with ENABLE_RCFILE and DISABLE_TABCOMP
(David Benbennick).
- Silence annoying compiler messages about clobbering and
uninitialized variables by moving variable inits to the top
of main() and re-initializing them after the sigsetjmp().
- rcfile.c:
colortoint()
- Don't bomb after invalid color and print bad color name
(David Benbennick).
colortoint, parse_colors()
- Don't add strings with invalid fg colors at all.
do_rcfile()
- Revert (somewhat) previous behavior of looking at
$HOME, and only run getpw* if it is NULL. Most *nix programs
seem to only care about $HOME, and at the user-level
getpw* may not be reliable (and its slower).
- search.c:
do_gotoline()
- Only goto_abort() if we *didnt* abort the command, making
the function seem horribly misnamed ;-) (David Benbennick).
- winio.c:
browser_init(), striponedir(), do_browse_from()
- Various memory leak fixes (David Benbennick).
do_yesno(), do_help()
- Add defined(NCURSES_MOUSE_VERSION) to macro so systems that
don't understand MEVENT will compile.
nanogetstr()
- Remove unnecessary reset of x since it is now handled
elsewhere (David Lawrence Ramsey).
statusq()
- Always blank the statusbar on exit (David Benbennick).
- nano.1, nano.1.html:
- Add initialization file comments, change some options from
bracketed to underlined to emphasize that they are not
optional.
- Add SEE ALSO section (Jordi).
- Moved nano.1 color and syntax sections to nanorc, pointed
nano.1 to nanorc.5 for initialization file. Changed
nanorc.5 variables to be italics to match nano.1. Added
nanorc.5.html to CVS tree.
- nanorc.5:
- Add nanorc manpage, with descriptions of all available commands
(Jordi).
- nanorc.sample:
- Make nanorc entry less tolerant of invalid colors.
- nano.spec.in:
- Change default flags to --enable-all.
- THANKS:
- Add Kalle Kivimaa and Kalle Olavi Niemitalo, for Finnish (Jordi).
- UPGRADE:
- Add upgrading information document for 1.0 users (Jordi).
GNU nano 1.1.99pre2 - 2003.02.03
- General:
- Changed some translatable debug messages to use %s
instead of the function name, and removed gettext from
two strings that had no actual words in them that
should be translated. Suggested originally by
Christian Rose.
- Fix subexpression replacement to work consistently.
Affects search.c:replace_regexp() and
utils.c:strstrwrapper() (David Benbennick).
- Fix cursor position being saved when escaping out
of nanogetstr with keys like ^Y and ^V. New arg
resetpos to nanogetstr(), added static int
resetpos in statusq() (bug found by DLR).
- Fix constant curos updates from obliterating other
system messages, and fix statusbar message length.
Affects files.c:load_open_file(), nano.c:main(),
search.c:findnextstr(), winio.c:statusbar() and
do_cursorpos() (David Benbennick).
- Fix nano crashing when searching/replacing an invalid
regex (try "^*"). Changed regexp_init() to return
1 or 0 based on regcomp()'s return value and search_init
to exit with an error message (sorry Jordi!). Added
another check when using last_search instead of answer.
- Move regcomp into rcfile.c rather than each display refresh
of winio.c. New function rcfile.c:nregcomp().
This fixes much of nano's resource hogging behavior
in syntax higlighting. (David Benbennick).
- Fix justify failing for certain lines, new function
nano.c:breakable() (David Benbennick).
- Fix screen getting trashed on signals nano can catch
(TERM and HUP). New global variable curses_ended,
changes to winio.c:statubar() and nano.c:die()
(David Benbennick).
- cut.c:
do_cut_text()
- Fix incorrect cursor location when cutting long lines
(David Benbennick).
- files.c:
- Set a default PATH_MAX for getcwd() etc calls (David
Benbennick).
do_browse_from()
- Fix path checking to fix bad paths, escaping
the operating directory, new function readable_dir() (David
Benbennick).
do_browser()
- Fix incorrect path check for check_operating_dir()
(David Benbennick).
- Fix goto directory operating dir check and tilde expansion
(David Benbennick).
- Even more checks and operating dir fixes (David Benbennick).
do_insertfile()
- Add some more checks and fix recursion when toggling
multibuffer (David Benbennick).
open_file()
- Fix FD leak with file load error (David Benbennick).
add_open_file()
- Revert the fix for the supposed minor logic error from before;
it was keeping some updates from happening when they should,
which was leading to segfaults with both multibuffer and view
mode on. (DLR; found by David Benbennick)
save_history()
- Fix nrealloc return value being ignored (David Benbennick).
- Fix off-by-one bug causing write to unallocated memory
(David Benbennick).
- global.c:
thanks_for_all_the_fish()
- Fix compiling with DEBUG and multibuffer (David Benbennick).
- nano.c:
do_char()
- Remove unneeded check_statblank() (David Benbennick).
do_int_spell_fix(), do_int_speller()
- Fix crashes with mark position, current_x position,
and edit_update args (David Benbennick).
do_justify()
- Unset KEEP_CUTBUFFER so nano won't crash with subsequent
^K cuts and justifies (David Benbennick).
do_mouse()
- Fix the mouse code to work with lines longer than COLS and
with the proper positioning, including special characters
(David Benbennick).
do_preserve_msg():
- Unsplit error message into a single fprintf call (Jordi).
main()
- Call load_file with arg 0 for insert, as we aren't really
doing an insert, allows new_file() to run if we open a
non-file at startup.
usage()
- Remove gettext markings from -p/--preserve (Jordi).
- Revamp -H option message to fit in 80 column terminal.
window_init()
- Fix leaking *WINDOWs (no pun intended) (David Benbennick).
- search.c:
do_search(), do_replace_loop()
- Fix edit_update call to use CENTER instead of current_x
(related to David Benbennick's fixes for spelling).
do_replace_loop()
- Fix various bugs having to do with replace string length
and positioning (David Benbennick).
edit_refresh()
- Fix cursor being above as well as below the current screen
(David Benbennick).
- winio.c:
bottombars()
- Change strcpy of gettext() "Up" string to strncpy of max
width 8, to stop stupid strcpy crash.
do_yesno()
- Fix mouse interaction bugs with yes/no prompt (David Benbennick).
- nanorc.sample:
- Change comment to say magenta instead of purple.
GNU nano 1.1.99pre1 - 2003.01.17
- General:
- New date format for NEWS and ChangeLog.

View File

@@ -17,16 +17,16 @@ nano_SOURCES = color.c \
utils.c \
winio.c
man_MANS = nano.1
man_MANS = nano.1 nanorc.5
nano_LDADD = @GLIB_LIBS@ @LIBINTL@
info_TEXINFOS = nano.texi
MAKEINFO = makeinfo --no-split
EXTRA_DIST = ABOUT-NLS AUTHORS BUGS COPYING ChangeLog INSTALL NEWS \
README THANKS TODO config.rpath install-sh missing \
mkinstalldirs nano.1 nano.1.html faq.html nanorc.sample \
nano.spec
README THANKS TODO UPGRADE config.rpath install-sh missing \
mkinstalldirs nano.1.html nanorc.5.html faq.html \
nanorc.sample nano.spec $(man_MANS)
SUBDIRS = po m4

50
NEWS
View File

@@ -1,3 +1,53 @@
2003.04.19 - Happy Easter! GNU nano 1.2.1 is released. This release
features a new check for broken regexec()
implementations and some variable, function and macro
cleanups. Fixes are included for search history,
cutting marked text, alt keyboard mode, and the usual
translation and documentation updates.
2003.02.19 - GNU nano 1.2.0 is released. Few changes from pre3, just
some doc and translation updates, and bugfixes for
justify and file conversion. For those of you who
haven't kept up with the 1.1 unstable series, v1.2
brings nanorc support, color syntax highlighting,
multiple file buffers, search/replace history and much
much more. Please reade the UPGRADE file for details,
and enjoy GNU nano 1.2.0.
2003.02.13 - GNU nano 1.1.99pre3 "The last testing version, no
really!" is released. This release includes fixes for
wrapping (again), resizing, color syntax highlighting,
rcfile parsing, the mouse code, more memory leaks, and
some reversion of the code to get the user's home
directory (nano will now again rely on $HOME). There
are also translation updates, a new manual page for the
nanorc file, and an UPGRADE file detailing the changes
since version 1.0. Please submit reports for any bugs
you might find to the development team
(nano-devel@gnu.org), and enjoy nano almost-1.2.0 ;-)
2003.02.03 - GNU nano 1.1.99pre2 "bugs in my pockets, bugs in my
shoes" is released. There are, not suprisingly,
only bugfixes in this release as we move toward the
stable 1.2.0 release. Fixes are included for
translable string format, subexpression replacement,
constant cursor position, invalid search regexes,
justify, screen state on SIGHUP and SIGTERM, cutting
to end cuts with long lines, many file browser and
operating directory bugs, memory and file descriptor
leaks, marker code, spell checker, the mouse code
with long lines, multiple buffers and non-file
open errors, replacement string length, and a
silly but serious history message crash. There is
also a drastic improvement in CPU utliization for
the color regex code.
Depending on the number of bugs found in this
release, there may be a 1.1.99pre3 or RC1, or just
a 1.2.0 release. Most of the major bugs seem to have
been worked out, so if you are waiting for a good time
to test nano before the official 1.2.0 release, this
would be the one to use. Happy bug hunting!
2003.01.17 - GNU nano 1.1.99pre1 "enough already" has been released.
This release is, barring bug fixes and documentation
updates, what version 1.2.0 has looked like, feature

29
README
View File

@@ -56,32 +56,9 @@ Mailing List and Bug Reports
Current Status
This is the 1.1 or unstable branch of nano. New features
will be added and things will be changed around and basically
stability is not guaranteed. If this is not what you're
interested in, please use the latest 1.0.x release of nano.
New features in this branch include:
+ .nanorc file support (--enable-nanorc configure option,
see sample.nanorc file)
+ Negative -r value for "#cols from right", allows dynamic adjustment
of wrap margin based on window size.
+ Write marked text to separate file (^O after selecting with ^^).
+ Append to file (Meta-A at write file menu).
+ Multiple file buffers! (--enable-multibuffer configure option,
--multibuffer, -F cmdline flag, Meta-F toggle, then ^R to load).
+ Better compatibility with Pico. Mouse mode now supports clicking
shortcuts and files in browser, search toggles that are Pico
extensions moved to Meta keys so as to not interfere with Pico
control sequences.
+ Smooth scrolling through files, instead of the jerky half-page
down, half-page up method. This is available by using the
-S or --smooth switch, or the Meta-S toggle.
+ Better non-*nix file support. GNU nano now automatically
converts files from DOS format or Mac format to standard file
format. It can also write files in either format by using the
appropriate command line (-D, --dos or -M, --mac) or toggle
(Meta-D, Meta-O).
GNU nano has reaching its second major milestone, 1.2.x. Development
of new features will continue in the 1.3.x branch, while 1.2.x
versions will be dedicated to bugfixing and polishing.
Chris Allegretta (chrisa@asty.org)

2
THANKS
View File

@@ -13,11 +13,13 @@ Tedi Heriyanto <tedi_h@gmx.net> Indonesian translator
Václav Haisman <V.Haisman@sh.cvut.cz> Czech translator
Szabolcs Horvath <horvaths@janus.gimsz.sulinet.hu>
Hungarian translator
Kalle Kivimaa <kalle.kivimaa@iki.fi> Finnish Translator
Eivind Kjørstad <ekj@vestdata.no> Norwegian nynorsk translator
Florian König <floki@bigfoot.com> German translator
Wojciech Kotwica <wkotwica@post.pl> Polish translator
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
Michael Piefel <piefel@informatik.hu-berlin.de> German translator
Sergey A. Ribalchenko <fisher@obu.ck.ua> Russian, Ukrainian translator

6
TODO
View File

@@ -19,9 +19,13 @@ For version 1.4:
- UTF-8 support.
- Support for Pico's paragraph searching ability.
- Undo/Redo key?
- Remindable keys?
- Rebindable keys?
- Keystroke to implement "Add next sequence as raw" like vi's ^V.
- Spell check selected text only.
- Make "To line" (^W^T) and "Read from Command" (^R^X) re-enter their
parent menu when their keystroke is entered a second time (^W^T^T and
(^R^X^X)(requires figuring out when to keep cursor pos and when not to).
- Fix resetstatuspos global which we shouldn't have.
Old requests:

28
UPGRADE Normal file
View File

@@ -0,0 +1,28 @@
GNU nano upgrading information
==============================
Visible changes since 1.0
-------------------------
* Editor Features
- Complete Pico compatibility (--pico has been removed, and -p means
something else, see below).
- nanorc support (see nanorc.sample included in sources).
- Smooth scrolling (-S).
- Searching of matching brace/bracket/etc.
- Help for all editor features.
- Color syntax highlighting support.
- Quote string support, useful for mail agents, etc (-Q).
- Insertion of output of external commands.
- Optional enabling of XON and XOFF control characters (-p).
- Tons of bugfixes/enhancements for already existing features.
* File Handling
- Overwriting and appending or prepending to files.
- Writing marked text to separate files.
- Multiple file buffers (-F).
- Converting from and to DOS/Mac file format (-D/-M, -N to disable).
- Better control character handling.
- Creation of backup files (-B).
- Search/replace history (-H).
See the GNU nano manual for detailed information on each feature.

11
color.c
View File

@@ -91,8 +91,8 @@ void do_colorinit(void)
init_pair(tmpcolor->pairnum, tmpcolor->fg, background);
#ifdef DEBUG
fprintf(stderr, _("Running init_pair() with fg = %d and bg = %d\n"),
tmpcolor->fg, tmpcolor->bg);
fprintf(stderr, _("Running %s with fg = %d and bg = %d\n"),
"init_pair()", tmpcolor->fg, tmpcolor->bg);
#endif
}
}
@@ -108,15 +108,10 @@ void update_color(void)
const exttype *e;
for (e = tmpsyntax->extensions; e != NULL; e = e->next) {
regex_t syntaxfile_regexp;
regcomp(&syntaxfile_regexp, e->val, REG_EXTENDED | REG_NOSUB);
/* Set colorstrings if we matched the extension regex */
if (!regexec(&syntaxfile_regexp, filename, 0, NULL, 0))
if (!regexec(&e->val, filename, 0, NULL, 0))
colorstrings = tmpsyntax->color;
regfree(&syntaxfile_regexp);
if (colorstrings != NULL)
break;
}

View File

@@ -19,7 +19,7 @@
#
# $Id$
AC_INIT([GNU Nano], [1.1.99pre1], [nano-devel@gnu.org], [nano])
AC_INIT([GNU Nano], [1.2.1], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([nano.c])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER([config.h:config.h.in])
@@ -38,12 +38,22 @@ AM_GNU_GETTEXT([external], [need-ngettext])
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h getopt.h libintl.h limits.h regex.h termio.h termios.h unistd.h)
AC_CHECK_HEADER(regex.h,
AC_MSG_CHECKING([for broken regexec])
AC_TRY_RUN([
#include <sys/types.h>
#include <regex.h>
int main() { regex_t reg; size_t n; regmatch_t r; regcomp(&reg, ".", 0); regexec(&reg, "", n, &r, 0); return 0; }],
AC_MSG_RESULT(no),
AC_MSG_RESULT(yes); AC_DEFINE(BROKEN_REGEXEC, 1, [Define this if your regexec() function segfaults when passed an empty string.])
)
)
dnl options
AC_ARG_ENABLE(debug,
[ --enable-debug Enable debugging (disabled by default)],
[if test x$enableval = xyes; then
AC_DEFINE(DEBUG, 1, [Define this to enable nano debug messages and assert warnings.])
AC_DEFINE(DEBUG, 1, [Define this to enable nano debug messages and assert warnings.])
debug_support=yes
fi])
@@ -125,7 +135,6 @@ AC_ARG_ENABLE(wrapping-as-root,
AC_DEFINE(DISABLE_ROOTWRAP, 1, [Define this to disable wrapping as root by default.])
fi])
AC_ARG_ENABLE(color,
[ --enable-color Enable color and syntax highlighting],
[if test x$enableval = xyes; then

54
cut.c
View File

@@ -29,6 +29,12 @@
#include "nano.h"
static int marked_cut; /* Is the cutbuffer from a mark? */
#ifndef NANO_SMALL
static int concatenate_cut; /* Should we add this cut string to the
end of the last one? */
#endif
static filestruct *cutbottom = NULL;
/* Pointer to end of cutbuffer */
@@ -47,6 +53,15 @@ void add_to_cutbuffer(filestruct *inptr)
if (cutbuffer == NULL) {
cutbuffer = inptr;
inptr->prev = NULL;
#ifndef NANO_SMALL
} else if (concatenate_cut && !ISSET(JUSTIFY_MODE)) {
/* Just tack the text in inptr onto the text in cutbottom,
unless we're backing up lines while justifying text. */
cutbottom->data = charealloc(cutbottom->data,
strlen(cutbottom->data) + strlen(inptr->data) + 1);
strcat(cutbottom->data, inptr->data);
return;
#endif
} else {
cutbottom->next = inptr;
inptr->prev = cutbottom;
@@ -118,15 +133,13 @@ void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
move text from the end forward first. */
memmove(top->data + top_x, bot->data + bot_x,
newsize - top_x);
top->data = (char *)nrealloc(top->data,
sizeof(char) * newsize);
top->data = charealloc(top->data, newsize);
} else {
totsize -= bot_x + 1;
/* Here, the remainder line might get longer, so we
realloc() it first. */
top->data = (char *)nrealloc(top->data,
sizeof(char) * newsize);
top->data = charealloc(top->data, newsize);
memmove(top->data + top_x, bot->data + bot_x,
newsize - top_x);
}
@@ -172,6 +185,9 @@ void cut_marked_segment(filestruct *top, size_t top_x, filestruct *bot,
new_magicline();
}
}
#ifdef DEBUG
dump_buffer(cutbuffer);
#endif
}
#endif
@@ -190,6 +206,9 @@ int do_cut_text(void)
free_filestruct(cutbuffer);
cutbuffer = NULL;
marked_cut = 0;
#ifndef NANO_SMALL
concatenate_cut = 0;
#endif
#ifdef DEBUG
fprintf(stderr, _("Blew away cutbuffer =)\n"));
#endif
@@ -204,6 +223,8 @@ int do_cut_text(void)
)
return 0;
SET(KEEP_CUTBUFFER);
#ifndef NANO_SMALL
if (ISSET(CUT_TO_END) && !ISSET(MARK_ISSET)) {
assert(current_x >= 0 && current_x <= strlen(current->data));
@@ -223,12 +244,10 @@ int do_cut_text(void)
}
do_delete();
SET(KEEP_CUTBUFFER);
marked_cut = 2;
return 1;
} else {
SET(MARK_ISSET);
SET(KEEP_CUTBUFFER);
mark_beginx = strlen(current->data);
mark_beginbuf = current;
@@ -249,6 +268,11 @@ int do_cut_text(void)
placewewant = xplustabs();
UNSET(MARK_ISSET);
/* If we just did a marked cut of part of a line, we should add
the first line of any cut done immediately afterward to the
end of this cut, as Pico does. */
if (current == mark_beginbuf && current_x < strlen(current->data))
concatenate_cut = 1;
marked_cut = 1;
if (dontupdate)
edit_refresh();
@@ -279,13 +303,14 @@ int do_cut_text(void)
edittop = current;
renumber(current);
current_x = 0;
edit_refresh();
set_modified();
marked_cut = 0;
current_x = 0;
#ifndef NANO_SMALL
concatenate_cut = 0;
#endif
placewewant = 0;
reset_cursor();
SET(KEEP_CUTBUFFER);
return 1;
}
@@ -313,6 +338,11 @@ int do_uncut_text(void)
placewewant = 0;
}
/* If we're going to uncut on the magicline, always make a new
magicline in advance. */
if (current->next == NULL)
new_magicline();
if (marked_cut == 0 || cutbuffer->next != NULL)
{
newbuf = copy_filestruct(cutbuffer);
@@ -339,10 +369,6 @@ int do_uncut_text(void)
current_x += buf_len;
totsize += buf_len;
/* If we've uncut a line, make sure there's a magicline after
it */
if (current->next == NULL)
new_magicline();
placewewant = xplustabs();
update_cursor();
@@ -427,7 +453,6 @@ int do_uncut_text(void)
edit_update(current, CENTER);
else
edit_refresh();
UNSET(KEEP_CUTBUFFER);
return 0;
}
@@ -465,6 +490,5 @@ int do_uncut_text(void)
#endif
set_modified();
UNSET(KEEP_CUTBUFFER);
return 1;
}

View File

@@ -36,7 +36,7 @@
<a href="#4.3">4.3. Nano crashes when I resize my window. How can I fix that?</a><br>
<a href="#4.4">4.4. [version 1.1.12 and earlier] Why does nano show ^\ in the shortcut list instead of ^J?</a><br>
<a href="#4.5a">4.5a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!</a><br>
<a href="#4.5b">4.5b. [version 1.2.0 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?</a><br>
<a href="#4.5b">4.5b. [version 1.2.1 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?</a><br>
<a href="#4.6">4.6. I get the message &quot;NumLock glitch detected. Keypad will malfunction with NumLock off.&quot; What gives?</a><br>
<a href="#4.7">4.7. How do I make nano my default editor (in Pine, mutt, etc.)?</a></p></blockquote>
<h2><a href="#5">5. Internationalization</a></h2>
@@ -77,9 +77,9 @@
<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.1.99pre1. 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.2.1. 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.1/nano.1.html">here</a>.</p></blockquote>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="http://www.nano-editor.org/dist/v1.2/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
<h1><a name="2"></a>2. Where to get GNU nano.</h1>
<h2><a name="2.1"></a>2.1. FTP and WWW sites that carry nano.</h2>
@@ -93,8 +93,8 @@
<h2><a name="2.2"></a>2.2. RedHat and derivatives (.rpm) packages.</h2>
<blockquote>
<ul>
<li><a href="http://www.nano-editor.org/dist/v1.0/RPMS/">http://www.nano-editor.org/dist/v1.0/RPMS/</a></li>
<li><a href="http://www.ewtoo.org/~astyanax/nano/dist/v1.0/RPMS/">http://www.ewtoo.org/~astyanax/nano/dist/v1.0/RPMS/</a></li>
<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>
@@ -175,7 +175,7 @@
<a name="4.5"></a>
<h2><a name="4.5a"></a>4.5a. [version 1.1.12 and earlier] When I type in a search string, the string I last searched for is already in front of my cursor! What happened?!</h2>
<blockquote><p>In nano version 0.9.20, the default is to have a completely consistent user interface across all user input functions. This means that regardless of whether you're being asked for a filename to insert or write, or a string to search for, the previous value is already inserted before the cursor. If you prefer the old behavior, use the Pico emulation mode (-p or --pico) or just hit Meta-P while in nano (see the ^G help text for more details).</p></blockquote>
<h2><a name="4.5b"></a>4.5b. [version 1.2.0 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?</h2>
<h2><a name="4.5b"></a>4.5b. [version 1.2.1 and later] Hey, the search string behavior has reverted, it's now like Pico, what happened to the consistency?</h2>
<blockquote><p>It was decided that consistency was nice, but people are used to Pico's inconsistent behavior. Also, in version 1.1.99pre1, search and replace history was introduced. If you wish to edit your previous search/replace entry (or any previous entry), you can do so by hitting the up arrow to cycle through your history. This method allows the best of both worlds: You don't need to erase the previous string if you want to enter a new one, but you can with one keystroke recall previous entries for editing. Therefore there is now no "Pico mode", nano is and has always been a Pico <b>clone</b>, and clones by default should be compatible.</p></blockquote>
<h2><a name="4.6"></a>4.6. I get the message &quot;NumLock glitch detected. Keypad will malfunction with NumLock off.&quot; What gives?</h2>
<blockquote><p>Nano (and actually almost all console editors) has issues when cycling the NumLock key in certain X terminals (rxvt, aterm, wterm, etc...). When you switch NumLock from on to off, you put the terminal into an &quot;application mode&quot; that changes what sequences are sent by the keypad. These sequences vary sufficiently from terminal to terminal that it is nearly impossible to work around them from within nano.</p>
@@ -223,7 +223,7 @@
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<h2><a name="7.2"></a>7.2. I want to send the development team a big load of cash (or just a thank you).</h2>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="http://www.nano-editor.org/dist/v1.1/BUGS">bug</a> in the program or implement a <a href="http://www.nano-editor.org/dist/v1.1/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="http://www.nano-editor.org/dist/v1.2/BUGS">bug</a> in the program or implement a <a href="http://www.nano-editor.org/dist/v1.2/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<h2><a name="7.3"></a>7.3. How do I submit a patch?</h2>
<blockquote><p>See Section <a href="#7.2">7.2</a>.</p></blockquote>
<h2><a name="7.4"></a>7.4. How do I join the development team?</h2>
@@ -233,6 +233,7 @@
<h2><a name="8"></a>8. ChangeLog</h2>
<blockquote>
<p>
2003/02/23 - Updated RPM links for nano 1.2.x. (DLR).<br>
2003/01/16 - Split section 4.5 into 4.5a and 4.5b for search string behavior. Added --enable-all docs.<br>
2002/12/28 - More misc. fixes (David Benbennick, DLR).<br>
2002/10/25 - Misc. fixes and link updates (DLR).<br>

415
files.c
View File

@@ -38,6 +38,12 @@
#include "proto.h"
#include "nano.h"
/* Set a default value for PATH_MAX, so we can use it below in lines like
path = getcwd(NULL, PATH_MAX + 1); */
#ifndef PATH_MAX
#define PATH_MAX -1
#endif
#ifndef NANO_SMALL
static int fileformat = 0; /* 0 = *nix, 1 = DOS, 2 = Mac */
#endif
@@ -179,9 +185,11 @@ int read_file(FILE *f, const char *filename, int quiet)
input = (char)input_int;
#ifndef NANO_SMALL
/* If the file has binary chars in it, don't stupidly
assume it's a DOS or Mac formatted file! */
if (!ISSET(NO_CONVERT) && is_cntrl_char((int)input) != 0
&& input != '\t' && input != '\r' && input != '\n')
assume it's a DOS or Mac formatted file if it hasn't been
detected as one already! */
if (fileformat == 0 && !ISSET(NO_CONVERT)
&& is_cntrl_char((int)input) != 0 && input != '\t'
&& input != '\r' && input != '\n')
SET(NO_CONVERT);
#endif
@@ -306,16 +314,16 @@ int read_file(FILE *f, const char *filename, int quiet)
#ifndef NANO_SMALL
if (fileformat == 2)
statusbar(__("Read %d line (Converted from Mac format)",
statusbar(P_("Read %d line (Converted from Mac format)",
"Read %d lines (Converted from Mac format)",
num_lines), num_lines);
else if (fileformat == 1)
statusbar(__("Read %d line (Converted from DOS format)",
statusbar(P_("Read %d line (Converted from DOS format)",
"Read %d lines (Converted from DOS format)",
num_lines), num_lines);
else
#endif
statusbar(__("Read %d line", "Read %d lines", num_lines),
statusbar(P_("Read %d line", "Read %d lines", num_lines),
num_lines);
totlines += num_lines;
@@ -339,6 +347,14 @@ int open_file(const char *filename, int insert, int quiet)
statusbar(_("New File"));
new_file();
}
} else if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
S_ISBLK(fileinfo.st_mode)) {
/* Don't open character or block files. Sorry, /dev/sndstat! */
statusbar(S_ISDIR(fileinfo.st_mode) ? _("\"%s\" is a directory") :
_("File \"%s\" is a device file"), filename);
if (!insert)
new_file();
return -1;
} else if ((fd = open(filename, O_RDONLY)) == -1) {
/* If we're in multibuffer mode, don't be quiet when an error
occurs while opening a file */
@@ -352,23 +368,12 @@ int open_file(const char *filename, int insert, int quiet)
new_file();
return -1;
} else { /* File is A-OK */
if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
S_ISBLK(fileinfo.st_mode)) {
if (S_ISDIR(fileinfo.st_mode))
statusbar(_("\"%s\" is a directory"), filename);
else
/* Don't open character or block files. Sorry, /dev/sndstat! */
statusbar(_("File \"%s\" is a device file"), filename);
if (!insert)
new_file();
return -1;
}
if (!quiet)
statusbar(_("Reading File"));
f = fdopen(fd, "rb"); /* Binary for our own line-end munging */
if (f == NULL) {
nperror("fdopen");
close(fd);
return -1;
}
read_file(f, filename, quiet);
@@ -424,6 +429,10 @@ int do_insertfile(int loading_file)
wrap_reset();
#if !defined(DISABLE_BROWSER) || !defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER)
start_again: /* Goto here when the user cancels the file browser. */
#endif
#if !defined(DISABLE_BROWSER) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
currshortcut = insertfile_list;
#endif
@@ -470,55 +479,47 @@ int do_insertfile(int loading_file)
fprintf(stderr, _("filename is %s\n"), answer);
#endif
realname = real_dir_from_tilde(answer);
#ifndef DISABLE_BROWSER
if (i == NANO_TOFILES_KEY) {
char *tmp = do_browse_from(realname);
#if !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
currshortcut = insertfile_list;
#endif
#ifdef DISABLE_TABCOMP
realname = NULL;
#endif
if (tmp != NULL) {
free(realname);
realname = tmp;
} else
return do_insertfile(loading_file);
}
#endif
#ifndef DISABLE_OPERATINGDIR
if (operating_dir != NULL && check_operating_dir(realname, 0)) {
statusbar(_("Can't insert file from outside of %s"),
operating_dir);
return 0;
}
#endif
#ifndef NANO_SMALL
#ifdef ENABLE_MULTIBUFFER
if (i == TOGGLE_LOAD_KEY) {
/* don't allow toggling if we're in both view mode and
multibuffer mode now */
if (!ISSET(VIEW_MODE) || !ISSET(MULTIBUFFER))
/* Don't allow toggling if we're in view mode. */
if (!ISSET(VIEW_MODE))
TOGGLE(MULTIBUFFER);
return do_insertfile(ISSET(MULTIBUFFER));
loading_file = ISSET(MULTIBUFFER);
goto start_again;
}
#endif /* ENABLE_MULTIBUFFER */
if (i == NANO_EXTCMD_KEY) {
int ts;
ts = statusq(1, extcmd_list, "", 0, _("Command to execute "));
if (ts == -1 || answer == NULL || answer[0] == '\0') {
int ts = statusq(TRUE, extcmd_list, "", NULL,
_("Command to execute"));
if (ts == -1 || answer == NULL || answer[0] == '\0') {
statusbar(_("Cancelled"));
UNSET(KEEP_CUTBUFFER);
display_main_list();
return 0;
}
}
#endif /* !NANO_SMALL */
#ifndef DISABLE_BROWSER
if (i == NANO_TOFILES_KEY) {
char *tmp = do_browse_from(answer);
if (tmp != NULL) {
free(answer);
answer = tmp;
resetstatuspos = 1;
} else
goto start_again;
}
#endif
#ifndef DISABLE_OPERATINGDIR
if (i != NANO_EXTCMD_KEY && check_operating_dir(answer, FALSE)) {
statusbar(_("Can't insert file from outside of %s"),
operating_dir);
return 0;
}
#endif
#ifdef ENABLE_MULTIBUFFER
if (loading_file) {
@@ -533,11 +534,15 @@ int do_insertfile(int loading_file)
#endif
#ifndef NANO_SMALL
if (i == NANO_EXTCMD_KEY)
if (i == NANO_EXTCMD_KEY) {
realname = mallocstrcpy(realname, "");
i = open_pipe(answer);
else
} else
#endif /* NANO_SMALL */
{
realname = real_dir_from_tilde(answer);
i = open_file(realname, 1, loading_file);
}
#ifdef ENABLE_MULTIBUFFER
if (loading_file) {
@@ -612,7 +617,6 @@ int do_insertfile(int loading_file)
free(inspath);
inspath = NULL;
UNSET(KEEP_CUTBUFFER);
display_main_list();
return i;
}
@@ -697,12 +701,12 @@ void free_openfilestruct(openfilestruct *src)
src = src->next;
delete_opennode(src->prev);
#ifdef DEBUG
fprintf(stderr, _("delete_opennode(): free'd a node, YAY!\n"));
fprintf(stderr, _("%s: free'd a node, YAY!\n"), "delete_opennode()");
#endif
}
delete_opennode(src);
#ifdef DEBUG
fprintf(stderr, _("delete_opennode(): free'd last node.\n"));
fprintf(stderr, _("%s: free'd last node.\n"), "delete_opennode()");
#endif
}
}
@@ -777,10 +781,9 @@ int add_open_file(int update)
#endif
}
/* if we're in view mode and updating, the file contents won't
have changed, so we won't bother resaving the filestruct
then; otherwise, we will */
if (!(ISSET(VIEW_MODE) || !update)) {
/* if we're not in view mode and not updating, the file contents
might have changed, so save the filestruct; otherwise, don't */
if (!(ISSET(VIEW_MODE) && !update)) {
/* save current file buffer */
open_files->fileage = fileage;
open_files->filebot = filebot;
@@ -843,13 +846,6 @@ int load_open_file(void)
clearok(topwin, FALSE);
titlebar(NULL);
/* if we're constantly displaying the cursor position and
DISABLE_CURPOS isn't set, update it (and do so unconditionally,
in the rare case that the character count is the same but the
line count isn't) */
if (ISSET(CONSTUPDATE) && !ISSET(DISABLE_CURPOS))
do_cursorpos(0);
/* now we're done */
return 0;
}
@@ -1344,7 +1340,8 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
statusbar(_("Cancelled"));
return -1;
}
titlebar(NULL);
if (!tmp)
titlebar(NULL);
fileptr = fileage;
realname = real_dir_from_tilde(name);
@@ -1684,7 +1681,7 @@ int write_file(const char *name, int tmp, int append, int nonamechange)
/* Update originalfilestat to reference the file as it is now. */
stat(filename, &originalfilestat);
#endif
statusbar(__("Wrote %d line", "Wrote %d lines", lineswritten),
statusbar(P_("Wrote %d line", "Wrote %d lines", lineswritten),
lineswritten);
UNSET(MODIFIED);
titlebar(NULL);
@@ -1899,15 +1896,11 @@ char *real_dir_from_tilde(const char *buf)
for (i = 1; buf[i] != '/' && buf[i] != '\0'; i++)
;
if (i == 1) {
/* Determine home directory using getpwent(), don't rely on
$HOME */
uid_t euid = geteuid();
do {
userdata = getpwent();
} while (userdata != NULL && userdata->pw_uid != euid);
} else {
/* Determine home directory using getpwuid() or getpwent(),
don't rely on $HOME */
if (i == 1)
userdata = getpwuid(geteuid());
else {
do {
userdata = getpwent();
} while (userdata != NULL &&
@@ -2121,6 +2114,8 @@ char **cwd_tab_completion(char *buf, int *num_matches)
break;
}
}
closedir(dir);
free(dirname);
return matches;
}
@@ -2317,7 +2312,7 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list)
/* And if the next match isn't going to fit on the
line, move to the next one */
if (col > (COLS - longestname) && matches[i + 1] != NULL) {
if (col > COLS - longestname && i + 1 < num_matches) {
editline++;
wmove(edit, editline, 0);
if (editline == editwinrows - 1) {
@@ -2398,13 +2393,15 @@ void striponedir(char *foo)
{
char *tmp;
assert(foo != NULL);
/* Don't strip the root dir */
if (!strcmp(foo, "/"))
if (*foo == '\0' || strcmp(foo, "/") == 0)
return;
tmp = foo + strlen(foo);
tmp = foo + strlen(foo) - 1;
assert(tmp >= foo);
if (*tmp == '/')
tmp--;
*tmp = '\0';
while (*tmp != '/' && tmp != foo)
tmp--;
@@ -2418,6 +2415,16 @@ void striponedir(char *foo)
}
}
int readable_dir(const char *path)
{
DIR *dir = opendir(path);
/* If dir is NULL, don't do closedir(), since that changes errno. */
if (dir != NULL)
closedir(dir);
return dir != NULL;
}
/* Initialize the browser code, including the list of files in *path */
char **browser_init(const char *path, int *longest, int *numents)
{
@@ -2456,6 +2463,7 @@ char **browser_init(const char *path, int *longest, int *numents)
sprintf(filelist[i], "%s/%s", path, next->d_name);
i++;
}
closedir(dir);
if (*longest > COLS - 1)
*longest = COLS - 1;
@@ -2508,7 +2516,8 @@ char *do_browser(const char *inpath)
/* Loop invariant: Microsoft sucks. */
do {
DIR *test_dir;
char *new_path;
/* Used by the Go To Directory prompt. */
blank_statusbar_refresh();
@@ -2613,67 +2622,61 @@ char *do_browser(const char *inpath)
/* You can't cd up from / */
if (!strcmp(filelist[selected], "/..") && !strcmp(path, "/")) {
statusbar(_("Can't move up a directory"));
beep();
break;
}
path = mallocstrcpy(path, filelist[selected]);
#ifndef DISABLE_OPERATINGDIR
/* Note: The case of the user's being completely outside the
operating directory is handled elsewhere, before this
point */
if (operating_dir != NULL) {
if (check_operating_dir(path, 0)) {
statusbar(_("Can't visit parent in restricted mode"));
beep();
break;
}
/*
* Note: the selected file can be outside the operating
* directory if it is .. or if it is a symlink to a directory
* outside the opdir. */
if (check_operating_dir(filelist[selected], FALSE)) {
statusbar(_("Can't go outside of %s in restricted mode"), operating_dir);
beep();
break;
}
#endif
/* SPK for '.' path, get the current path via getcwd */
if (!strcmp(path, "./..")) {
free(path);
#ifdef PATH_MAX
path = getcwd(NULL, PATH_MAX + 1);
#else
path = getcwd(NULL, 0);
#endif
striponedir(path);
align(&path);
free_charptrarray(filelist, numents);
free(foo);
return do_browser(path);
if (stat(filelist[selected], &st) == -1) {
statusbar(_("Can't open \"%s\": %s"), filelist[selected], strerror(errno));
beep();
break;
}
st = filestat(path);
if (S_ISDIR(st.st_mode)) {
if ((test_dir = opendir(path)) == NULL) {
/* We can't open this dir for some reason. Complain */
statusbar(_("Can't open \"%s\": %s"), path, strerror(errno));
striponedir(path);
align(&path);
break;
}
closedir(test_dir);
if (!strcmp("..", tail(path))) {
/* They want to go up a level, so strip off .. and the
current dir */
striponedir(path);
striponedir(path);
align(&path);
}
/* Start over again with the new path value */
free_charptrarray(filelist, numents);
free(foo);
return do_browser(path);
} else {
retval = mallocstrcpy(retval, path);
if (!S_ISDIR(st.st_mode)) {
retval = mallocstrcpy(retval, filelist[selected]);
abort = 1;
break;
}
break;
new_path = mallocstrcpy(NULL, filelist[selected]);
if (strcmp("..", tail(new_path)) == 0) {
/* They want to go up a level, so strip off .. and the
current dir */
striponedir(new_path);
/* SPK for '.' path, get the current path via getcwd */
if (strcmp(new_path, ".") == 0) {
free(new_path);
new_path = getcwd(NULL, PATH_MAX + 1);
}
striponedir(new_path);
}
if (!readable_dir(new_path)) {
/* We can't open this dir for some reason. Complain */
statusbar(_("Can't open \"%s\": %s"), new_path, strerror(errno));
free(new_path);
break;
}
free_charptrarray(filelist, numents);
free(foo);
free(path);
path = new_path;
return do_browser(path);
/* Goto a specific directory */
case 'g': /* Pico compatibility */
case 'G':
@@ -2688,37 +2691,38 @@ char *do_browser(const char *inpath)
bottombars(browser_list);
curs_set(0);
#ifndef DISABLE_OPERATINGDIR
if (operating_dir != NULL) {
if (check_operating_dir(answer, 0)) {
statusbar(_("Can't go outside of %s in restricted mode"), operating_dir);
break;
}
}
#endif
if (j < 0) {
statusbar(_("Goto Cancelled"));
break;
}
if (answer[0] != '/') {
char *saveanswer = mallocstrcpy(NULL, answer);
new_path = real_dir_from_tilde(answer);
answer = nrealloc(answer, strlen(path) + strlen(saveanswer) + 2);
sprintf(answer, "%s/%s", path, saveanswer);
free(saveanswer);
if (new_path[0] != '/') {
new_path = charealloc(new_path, strlen(path) + strlen(answer) + 2);
sprintf(new_path, "%s/%s", path, answer);
}
if ((test_dir = opendir(answer)) == NULL) {
#ifndef DISABLE_OPERATINGDIR
if (check_operating_dir(new_path, FALSE)) {
statusbar(_("Can't go outside of %s in restricted mode"), operating_dir);
free(new_path);
break;
}
#endif
if (!readable_dir(new_path)) {
/* We can't open this dir for some reason. Complain */
statusbar(_("Can't open \"%s\": %s"), answer, strerror(errno));
free(new_path);
break;
}
closedir(test_dir);
}
/* Start over again with the new path value */
path = mallocstrcpy(path, answer);
free_charptrarray(filelist, numents);
free(foo);
free(path);
path = new_path;
return do_browser(path);
/* Stuff we want to abort the browser */
@@ -2820,34 +2824,41 @@ char *do_browser(const char *inpath)
char *do_browse_from(const char *inpath)
{
struct stat st;
char *tmp;
char *bob;
/* The result of do_browser; the selected file name. */
char *path;
/* inpath, tilde expanded. */
/* If there's no / in the string, we may as well start from . */
if (inpath == NULL || strchr(inpath, '/') == NULL) {
#ifdef PATH_MAX
char *from = getcwd(NULL, PATH_MAX + 1);
#else
char *from = getcwd(NULL, 0);
#endif
assert(inpath != NULL);
bob = do_browser(from != NULL ? from : "./");
free(from);
return bob;
path = real_dir_from_tilde(inpath);
/*
* Perhaps path is a directory. If so, we will pass that to
* do_browser. Otherwise, perhaps path is a directory / a file. So
* we try stripping off the last path element. If it still isn't a
* directory, just use the current directory. */
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
striponedir(path);
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
free(path);
path = getcwd(NULL, PATH_MAX + 1);
}
}
/* If the string is a directory, pass do_browser() that */
st = filestat(inpath);
if (S_ISDIR(st.st_mode))
return do_browser(inpath);
#ifndef DISABLE_OPERATINGDIR
/* If the resulting path isn't in the operating directory, use that. */
if (check_operating_dir(path, FALSE))
path = mallocstrcpy(path, operating_dir);
#endif
tmp = mallocstrcpy(NULL, inpath);
/* Okay, there's a dir in there, but not at the end of the string...
try stripping it off */
striponedir(tmp);
align(&tmp);
bob = do_browser(tmp);
free(tmp);
if (!readable_dir(path)) {
beep();
bob = NULL;
} else
bob = do_browser(path);
free(path);
return bob;
}
#endif /* !DISABLE_BROWSER */
@@ -2857,32 +2868,39 @@ char *do_browse_from(const char *inpath)
void load_history(void)
{
FILE *hist;
const struct passwd *userage;
uid_t euid = geteuid();
const struct passwd *userage = NULL;
static char *nanohist;
char *buf, *ptr;
char *homenv = getenv("HOME");
historyheadtype *history = &search_history;
do {
userage = getpwent();
} while (userage != NULL && userage->pw_uid != euid);
endpwent();
if (homenv != NULL) {
nanohist = nrealloc(nanohist, strlen(homenv) + 15);
sprintf(nanohist, "%s/.nano_history", homenv);
} else {
userage = getpwuid(geteuid());
endpwent();
nanohist = nrealloc(nanohist, strlen(userage->pw_dir) + 15);
sprintf(nanohist, "%s/.nano_history", userage->pw_dir);
}
/* assume do_rcfile has reported missing home dir */
if (userage != NULL) {
nanohist = nrealloc(nanohist, strlen(userage->pw_dir) + 15);
sprintf(nanohist, "%s/.nano_history", userage->pw_dir);
if (homenv != NULL || userage != NULL) {
hist = fopen(nanohist, "r");
if (!hist) {
if (errno != ENOENT)
if (errno != ENOENT) {
/* Don't save history when we quit. */
UNSET(HISTORYLOG);
rcfile_error(_("Unable to open ~/.nano_history file, %s"), strerror(errno));
}
free(nanohist);
} else {
buf = charalloc(1024);
while (fgets(buf, 1023, hist) != 0) {
ptr = buf;
while (*ptr != '\n')
while (*ptr != '\n' && *ptr != '\0' && ptr < buf + 1023)
ptr++;
*ptr = '\0';
if (strlen(buf))
@@ -2902,9 +2920,9 @@ void load_history(void)
void save_history(void)
{
FILE *hist;
const struct passwd *userage;
uid_t euid = geteuid();
const struct passwd *userage = NULL;
char *nanohist = NULL;
char *homenv = getenv("HOME");
historytype *h;
/* don't save unchanged or empty histories */
@@ -2912,14 +2930,17 @@ void save_history(void)
ISSET(HISTORY_CHANGED) && !ISSET(VIEW_MODE)))
return;
do {
userage = getpwent();
} while (userage != NULL && userage->pw_uid != euid);
endpwent();
if (userage != NULL) {
if (homenv != NULL) {
nanohist = nrealloc(nanohist, strlen(homenv) + 15);
sprintf(nanohist, "%s/.nano_history", homenv);
} else {
userage = getpwuid(geteuid());
endpwent();
nanohist = nrealloc(nanohist, strlen(userage->pw_dir) + 15);
sprintf(nanohist, "%s/.nano_history", userage->pw_dir);
}
if (homenv != NULL || userage != NULL) {
hist = fopen(nanohist, "wb");
if (!hist) {
rcfile_msg(_("Unable to write ~/.nano_history file, %s"), strerror(errno));
@@ -2928,7 +2949,7 @@ void save_history(void)
chmod(nanohist, S_IRUSR | S_IWUSR);
/* write oldest first */
for (h = search_history.tail ; h->prev ; h = h->prev) {
nrealloc(h->data, strlen(h->data) + 1);
h->data = nrealloc(h->data, strlen(h->data) + 2);
strcat(h->data, "\n");
if (fputs(h->data, hist) == EOF) {
rcfile_msg(_("Unable to write ~/.nano_history file, %s"), strerror(errno));
@@ -2940,7 +2961,7 @@ void save_history(void)
goto come_from;
}
for (h = replace_history.tail ; h->prev ; h = h->prev) {
nrealloc(h->data, strlen(h->data) + 1);
h->data = nrealloc(h->data, strlen(h->data) + 2);
strcat(h->data, "\n");
if (fputs(h->data, hist) == EOF) {
rcfile_msg(_("Unable to write ~/.nano_history file, %s"), strerror(errno));

View File

@@ -69,6 +69,8 @@ char *quotestr = NULL; /* Quote string. The default value is
set in main(). */
#endif
int resetstatuspos; /* Hack for resetting the status bar
cursor position */
char *answer = NULL; /* Answer str to many questions */
int totlines = 0; /* Total number of lines in the file */
long totsize = 0; /* Total number of bytes in the file */
@@ -105,7 +107,6 @@ shortcut *whereis_list = NULL;
shortcut *replace_list = NULL;
shortcut *replace_list_2 = NULL; /* 2nd half of replace dialog */
shortcut *goto_list = NULL;
shortcut *gotodir_list = NULL;
shortcut *writefile_list = NULL;
shortcut *insertfile_list = NULL;
#ifndef DISABLE_HELP
@@ -119,7 +120,9 @@ shortcut *extcmd_list = NULL;
#endif
#ifndef DISABLE_BROWSER
shortcut *browser_list = NULL;
shortcut *gotodir_list = NULL;
#endif
#ifdef ENABLE_COLOR
const colortype *colorstrings = NULL;
syntaxtype *syntaxes = NULL;
@@ -147,6 +150,11 @@ regmatch_t regmatches[10]; /* Match positions for parenthetical
subexpressions, max of 10 */
#endif
int curses_ended = FALSE; /* Indicates to statusbar() to simply
* write to stderr, since endwin() has
* ended curses mode. */
int length_of_list(const shortcut *s)
{
int i = 0;
@@ -431,16 +439,15 @@ void shortcut_init(int unjustify)
IFHELP(nano_justify_msg, 0), NANO_JUSTIFY_FKEY, 0,
NOVIEW, do_justify);
/* this is so we can view multiple files */
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
IFHELP(nano_insert_msg, 0), NANO_INSERTFILE_FKEY, 0,
#ifdef ENABLE_MULTIBUFFER
/* this is so we can view multiple files */
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
IFHELP(nano_insert_msg, 0),
NANO_INSERTFILE_FKEY, 0, VIEW, do_insertfile_void);
VIEW
#else
sc_init_one(&main_list, NANO_INSERTFILE_KEY, _("Read File"),
IFHELP(nano_insert_msg, 0),
NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
NOVIEW
#endif
, do_insertfile_void);
sc_init_one(&main_list, NANO_WHEREIS_KEY, _("Where Is"),
IFHELP(nano_whereis_msg, 0),
@@ -856,10 +863,12 @@ void thanks_for_all_the_fish(void)
#ifdef ENABLE_MULTIBUFFER
if (open_files != NULL) {
/* We free the memory associated with each open file. */
while (open_files->prev != NULL)
open_files = open_files->prev;
free_openfilestruct(open_files);
}
#else
if (fileage != NULL)
free_filestruct(fileage);
free_filestruct(fileage);
#endif
#ifdef ENABLE_COLOR
@@ -881,7 +890,8 @@ void thanks_for_all_the_fish(void)
syntaxes->color = bob->next;
regfree(&bob->start);
if (bob->end != NULL)
regfree(&bob->end);
regfree(bob->end);
free(bob->end);
free(bob);
}
syntaxes = syntaxes->next;

8
move.c
View File

@@ -30,7 +30,6 @@
int do_home(void)
{
UNSET(KEEP_CUTBUFFER);
current_x = 0;
placewewant = 0;
update_line(current, current_x);
@@ -39,7 +38,6 @@ int do_home(void)
int do_end(void)
{
UNSET(KEEP_CUTBUFFER);
current_x = strlen(current->data);
placewewant = xplustabs();
update_line(current, current_x);
@@ -89,7 +87,6 @@ int do_page_up(void)
edit_update(current, TOP);
update_cursor();
UNSET(KEEP_CUTBUFFER);
check_statblank();
return 1;
}
@@ -132,7 +129,6 @@ int do_page_down(void)
}
update_cursor();
UNSET(KEEP_CUTBUFFER);
check_statblank();
return 1;
}
@@ -151,7 +147,6 @@ int do_up(void)
update_line(current, current_x);
} else
page_up();
UNSET(KEEP_CUTBUFFER);
check_statblank();
}
return 1;
@@ -162,7 +157,6 @@ int do_up(void)
int do_down(void)
{
wrap_reset();
UNSET(KEEP_CUTBUFFER);
check_statblank();
if (current->next == NULL)
@@ -207,7 +201,6 @@ int do_left(void)
}
placewewant = xplustabs();
update_line(current, current_x);
UNSET(KEEP_CUTBUFFER);
check_statblank();
return 1;
}
@@ -224,7 +217,6 @@ int do_right(void)
}
placewewant = xplustabs();
update_line(current, current_x);
UNSET(KEEP_CUTBUFFER);
check_statblank();
return 1;
}

45
nano.1
View File

@@ -1,20 +1,23 @@
.\" Hey, EMACS: -*- nroff -*-
.\" nano.1 is copyright 1999-2002 by
.\" nano.1 is copyright (C) 1999, 2000, 2001, 2002, 2003 by
.\" Chris Allegretta <chrisa@asty.org>
.\"
.\" This is free documentation, see the latest version of the GNU General
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
.TH NANO 1 "November 1, 2002"
.TH NANO 1 "February 9, 2003"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
nano \- Nano's ANOther editor, an enhanced free Pico clone
.SH SYNOPSIS
.B nano
.I [\+LINE]\ [options]\ [file]
.br
.SH DESCRIPTION
This manual page documents briefly the \fBnano\fP command.
.PP
@@ -26,6 +29,7 @@ Pico, the default editor included in the non-free Pine package. Rather
than just copying Pico's look and feel, \fBnano\fP also implements some
missing (or disabled by default) features in Pico, such as "search and
replace" and "go to line number".
.SH OPTIONS
.TP
.B \+\fILINE\fP
@@ -60,7 +64,7 @@ Write file in Mac format.
.B \-N (\-\-noconvert)
Disable automatic conversion of files from DOS/Mac format.
.TP
.B \-Q \fI[str]\fP (\-\-quotestr=\fI[str]\fP)
.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.
@@ -73,13 +77,13 @@ Enable regular expression matching for search strings, as well as
Enable smooth scrolling. Text will scroll line-by-line, instead of the
usual chunk-by-chunk behavior.
.TP
.B \-T \fI[num]\fP (\-\-tabsize=\fI[num]\fP)
.B \-T \fInum\fP (\-\-tabsize=\fInum\fP)
Set the size (width) of a tab.
.TP
.B \-V (\-\-version)
Show the current version number and author.
.TP
.B \-Y \fI[str]\fP (\-\-syntax=\fI[str]\fP)
.B \-Y \fIstr\fP (\-\-syntax=\fIstr\fP)
Specify a specific syntax highlighting from the .nanorc to use, if
available.
.TP
@@ -103,7 +107,7 @@ a new file, do not follow it. Good for editing files in /tmp, perhaps?
.B \-m (\-\-mouse)
Enable mouse support (if available for your system).
.TP
.B \-o \fI[dir]\fP (\-\-operatingdir=\fI[dir]\fP)
.B \-o \fIdir\fP (\-\-operatingdir=\fIdir\fP)
Set operating directory. Makes nano set up something similar to a
chroot.
.TP
@@ -111,13 +115,13 @@ chroot.
Preserve the XON and XOFF sequences (^Q and ^S) so they will be
caught by the terminal.
.TP
.B \-r \fI[#cols]\fP (\-\-fill=\fI[#cols]\fP)
Wrap lines at column #cols. By default, this is the width of the
.B \-r \fIcols\fP (\-\-fill=\fIcols\fP)
Wrap lines at column \fIcols\fP. By default, this is the width of the
screen, less eight. If this value is negative, wrapping will occur at
#cols from the right of the screen, allowing it to vary along with the
screen width if the screen is resized.
\fIcols\fP columns from the right of the screen, allowing the wrap point
to vary along with the screen width if resized.
.TP
.B \-s \fI[prog]\fP (\-\-speller=\fI[prog]\fP)
.B \-s \fIprog\fP (\-\-speller=\fIprog\fP)
Enable alternative spell checker command.
.TP
.B \-t (\-\-tempfile)
@@ -137,6 +141,13 @@ Enable suspend ability.
.TP
.B \-a, \-b, \-e, \-f, \-g, \-j
Ignored, for compatibility with Pico.
.SH INITIALIZATION FILE
\fBnano\fP will read initialization files in the following
order: $SYSCONFDIR/nanorc, then ~/.nanorc. Please see nanorc(5) and
the example file \fBnanorc.sample\fP which should be provided with
\fBnano\fP.
.SH NOTES
\fBnano\fP will try to dump the buffer into an emergency file in some
cases. Mainly, this will happen if \fBnano\fP receives a SIGHUP or
@@ -147,6 +158,7 @@ name already exists in the current directory, ".save" and a number (e.g.
".save.1") will be suffixed to the current filename in order to make it
unique. In multibuffer mode, \fBnano\fP will write all the open buffers
to the respective emergency files.
.SH BUGS
Please send any comments or bug reports to
.br
@@ -157,8 +169,17 @@ The \fBnano\fP mailing list is available from
.B nano-devel@gnu.org.
To subscribe, email to nano-devel-request@gnu.org with a
subject of "subscribe".
.SH HOMEPAGE
http://www.nano-editor.org
http://www.nano-editor.org/
.SH SEE ALSO
.PD 0
.TP
\fBnanorc\fP(5)
.PP
\fI/usr/share/doc/nano/\fP (or equivalent on your system)
.SH AUTHOR
Chris Allegretta <chrisa@asty.org>, et al (see AUTHORS and THANKS for
details).

View File

@@ -1,17 +1,17 @@
Content-type: text/html
<HTML><HEAD><TITLE>Manpage of NANO</TITLE>
</HEAD><BODY>
<H1>NANO</H1>
Section: User Commands (1)<BR>Updated: November 1, 2002<BR><A HREF="#index">Index</A>
Section: User Commands (1)<BR>Updated: February 9, 2003<BR><A HREF="#index">Index</A>
<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<P>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
nano - Nano's ANOther editor, an enhanced free Pico clone
<P>
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
@@ -21,6 +21,7 @@ nano - Nano's ANOther editor, an enhanced free Pico clone
<BR>
<P>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
@@ -35,6 +36,7 @@ Pico, the default editor included in the non-free Pine package. Rather
than just copying Pico's look and feel, <B>nano</B> also implements some
missing (or disabled by default) features in Pico, such as &quot;search and
replace&quot; and &quot;go to line number&quot;.
<P>
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
@@ -80,7 +82,7 @@ Write file in Mac format.
<DD>
Disable automatic conversion of files from DOS/Mac format.
<DT><B>-Q </B><I>[str]</I> (--quotestr=<I>[str]</I>)
<DT><B>-Q </B><I>str</I> (--quotestr=<I>str</I>)
<DD>
Set the quoting string for justifying. The default is
@@ -96,7 +98,7 @@ Enable regular expression matching for search strings, as well as
<DD>
Enable smooth scrolling. Text will scroll line-by-line, instead of the
usual chunk-by-chunk behavior.
<DT><B>-T </B><I>[num]</I> (--tabsize=<I>[num]</I>)
<DT><B>-T </B><I>num</I> (--tabsize=<I>num</I>)
<DD>
Set the size (width) of a tab.
@@ -104,7 +106,7 @@ Set the size (width) of a tab.
<DD>
Show the current version number and author.
<DT><B>-Y </B><I>[str]</I> (--syntax=<I>[str]</I>)
<DT><B>-Y </B><I>str</I> (--syntax=<I>str</I>)
<DD>
Specify a specific syntax highlighting from the .nanorc to use, if
@@ -135,7 +137,7 @@ a new file, do not follow it. Good for editing files in /tmp, perhaps?
<DD>
Enable mouse support (if available for your system).
<DT><B>-o </B><I>[dir]</I> (--operatingdir=<I>[dir]</I>)
<DT><B>-o </B><I>dir</I> (--operatingdir=<I>dir</I>)
<DD>
Set operating directory. Makes nano set up something similar to a
@@ -145,14 +147,14 @@ chroot.
<DD>
Preserve the XON and XOFF sequences (^Q and ^S) so they will be
caught by the terminal.
<DT><B>-r </B><I>[#cols]</I> (--fill=<I>[#cols]</I>)
<DT><B>-r </B><I>cols</I> (--fill=<I>cols</I>)
<DD>
Wrap lines at column #cols. By default, this is the width of the
Wrap lines at column <I>cols</I>. By default, this is the width of the
screen, less eight. If this value is negative, wrapping will occur at
#cols from the right of the screen, allowing it to vary along with the
screen width if the screen is resized.
<DT><B>-s </B><I>[prog]</I> (--speller=<I>[prog]</I>)
<I>cols</I> columns from the right of the screen, allowing the wrap point
to vary along with the screen width if resized.
<DT><B>-s </B><I>prog</I> (--speller=<I>prog</I>)
<DD>
Enable alternative spell checker command.
@@ -180,8 +182,17 @@ Enable suspend ability.
<DD>
Ignored, for compatibility with Pico.
<P>
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>INITIALIZATION FILE</H2>
<B>nano</B> will read initialization files in the following
order: $SYSCONFDIR/nanorc, then ~/.nanorc. Please see <A HREF="http://localhost/cgi-bin/man/man2html?5+nanorc">nanorc</A>(5) and
the example file <B>nanorc.sample</B> which should be provided with
<B>nano</B>.
<P>
<A NAME="lbAG">&nbsp;</A>
<H2>NOTES</H2>
<B>nano</B> will try to dump the buffer into an emergency file in some
@@ -193,7 +204,8 @@ name already exists in the current directory, &quot;.save&quot; and a number (e.
&quot;.save.1&quot;) will be suffixed to the current filename in order to make it
unique. In multibuffer mode, <B>nano</B> will write all the open buffers
to the respective emergency files.
<A NAME="lbAG">&nbsp;</A>
<P>
<A NAME="lbAH">&nbsp;</A>
<H2>BUGS</H2>
Please send any comments or bug reports to
@@ -210,11 +222,24 @@ The <B>nano</B> mailing list is available from
To subscribe, email to <A HREF="mailto:nano-devel-request@gnu.org">nano-devel-request@gnu.org</A> with a
subject of &quot;subscribe&quot;.
<A NAME="lbAH">&nbsp;</A>
<P>
<A NAME="lbAI">&nbsp;</A>
<H2>HOMEPAGE</H2>
<A HREF="http://www.nano-editor.org">http://www.nano-editor.org</A>
<A NAME="lbAI">&nbsp;</A>
<A HREF="http://www.nano-editor.org/">http://www.nano-editor.org/</A>
<P>
<A NAME="lbAJ">&nbsp;</A>
<H2>SEE ALSO</H2>
<DL COMPACT>
<DT><B><A HREF="http://localhost/cgi-bin/man/man2html?5+nanorc">nanorc</A></B>(5)<DD>
</DL>
<P>
<I>/usr/share/doc/nano/</I> (or equivalent on your system)
<P>
<A NAME="lbAK">&nbsp;</A>
<H2>AUTHOR</H2>
Chris Allegretta &lt;<A HREF="mailto:chrisa@asty.org">chrisa@asty.org</A>&gt;, et al (see AUTHORS and THANKS for
@@ -231,15 +256,17 @@ used by others).
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT><A HREF="#lbAE">OPTIONS</A><DD>
<DT><A HREF="#lbAF">NOTES</A><DD>
<DT><A HREF="#lbAG">BUGS</A><DD>
<DT><A HREF="#lbAH">HOMEPAGE</A><DD>
<DT><A HREF="#lbAI">AUTHOR</A><DD>
<DT><A HREF="#lbAF">INITIALIZATION FILE</A><DD>
<DT><A HREF="#lbAG">NOTES</A><DD>
<DT><A HREF="#lbAH">BUGS</A><DD>
<DT><A HREF="#lbAI">HOMEPAGE</A><DD>
<DT><A HREF="#lbAJ">SEE ALSO</A><DD>
<DT><A HREF="#lbAK">AUTHOR</A><DD>
</DL>
<HR>
This document was created by
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 03:06:20 GMT, January 17, 2003
Time: 04:08:28 GMT, February 13, 2003
</BODY>
</HTML>

455
nano.c
View File

@@ -66,18 +66,6 @@ static sigjmp_buf jmpbuf; /* Used to return to mainloop after SIGWINCH */
/* What we do when we're all set to exit */
RETSIGTYPE finish(int sigage)
{
#ifndef NANO_SMALL
#ifdef ENABLE_NANORC
/* do here so errors about ./nano_history
don't confuse user */
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
save_history();
#endif
free_history(&search_history);
free_history(&replace_history);
#endif
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
@@ -93,6 +81,11 @@ RETSIGTYPE finish(int sigage)
/* Restore the old term settings */
tcsetattr(0, TCSANOW, &oldterm);
#if !defined(NANO_SMALL) && defined(ENABLE_NANORC)
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
save_history();
#endif
#ifdef DEBUG
thanks_for_all_the_fish();
#endif
@@ -105,14 +98,12 @@ void die(const char *msg, ...)
{
va_list ap;
endwin();
curses_ended = TRUE;
/* Restore the old term settings */
tcsetattr(0, TCSANOW, &oldterm);
clear();
refresh();
resetty();
endwin();
va_start(ap, msg);
vfprintf(stderr, msg, ap);
va_end(ap);
@@ -201,7 +192,8 @@ void global_init(int save_cutbuffer)
current_x = 0;
current_y = 0;
if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
editwinrows = LINES - 5 + no_help();
if (editwinrows < MIN_EDITOR_ROWS || COLS < MIN_EDITOR_COLS)
die_too_small();
fileage = NULL;
@@ -218,8 +210,8 @@ void global_init(int save_cutbuffer)
fill = wrap_at;
if (fill <= 0)
fill += COLS;
if (fill < MIN_FILL_LENGTH)
die_too_small();
if (fill < 0)
fill = 0;
#endif
hblank = charalloc(COLS + 1);
@@ -229,9 +221,17 @@ void global_init(int save_cutbuffer)
void window_init(void)
{
if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
editwinrows = LINES - 5 + no_help();
if (editwinrows < MIN_EDITOR_ROWS)
die_too_small();
if (edit != NULL)
delwin(edit);
if (topwin != NULL)
delwin(topwin);
if (bottomwin != NULL)
delwin(bottomwin);
/* Set up the main text window */
edit = newwin(editwinrows, COLS, 2, 0);
@@ -336,6 +336,7 @@ void help_init(void)
"complete the directory name.\n\n The following function "
"keys are available in Browser Go To Directory mode:\n\n");
#endif
#ifndef DISABLE_SPELLER
else if (currshortcut == spell_list)
ptr = _("Spell Check Help Text\n\n "
"The spell checker checks the spelling of all text "
@@ -345,6 +346,7 @@ void help_init(void)
"instance of the given misspelled word in the "
"current file.\n\n The following other functions are "
"available in Spell Check mode:\n\n");
#endif
#ifndef NANO_SMALL
else if (currshortcut == extcmd_list)
ptr = _("External Command Help Text\n\n "
@@ -382,9 +384,12 @@ void help_init(void)
/* If we're on the main list, we also count the toggle help text.
* Each line has "M-%c\t\t\t", which fills 24 columns, plus at most
* COLS - 24 characters, plus '\n'.*/
if (currshortcut == main_list)
if (currshortcut == main_list) {
size_t endislen = strlen(_("enable/disable"));
for (t = toggles; t != NULL; t = t->next)
allocsize += COLS - 17;
allocsize += 8 + strlen(t->desc) + endislen;
}
#endif /* !NANO_SMALL */
/* help_text has been freed and set to NULL unless the user resized
@@ -441,16 +446,16 @@ void help_init(void)
*(ptr++) = '\t';
assert(s->help != NULL);
ptr += sprintf(ptr, "%.*s\n", COLS - 24, s->help);
ptr += sprintf(ptr, "%.*s\n", COLS > 24 ? COLS - 24 : 0, s->help);
}
#ifndef NANO_SMALL
/* And the toggles... */
if (currshortcut == main_list)
for (t = toggles; t != NULL; t = t->next) {
ptr += sprintf(ptr, "M-%c\t\t\t", t->val - 32);
assert(t->desc != NULL);
ptr += sprintf(ptr, _("%.*s enable/disable\n"), COLS - 24, t->desc);
ptr += sprintf(ptr, "M-%c\t\t\t%s %s\n", t->val - 32, t->desc,
_("enable/disable"));
}
#endif /* !NANO_SMALL */
@@ -557,12 +562,12 @@ void free_filestruct(filestruct *src)
src = src->next;
delete_node(src->prev);
#ifdef DEBUG
fprintf(stderr, _("delete_node(): free'd a node, YAY!\n"));
fprintf(stderr, _("%s: free'd a node, YAY!\n"), "delete_node()");
#endif
}
delete_node(src);
#ifdef DEBUG
fprintf(stderr, _("delete_node(): free'd last node.\n"));
fprintf(stderr, _("%s: free'd last node.\n"), "delete_node()");
#endif
}
}
@@ -631,7 +636,7 @@ void usage(void)
print1opt("-F", "--multibuffer", _("Enable multiple file buffers"));
#endif
#ifdef ENABLE_NANORC
print1opt("-H", "--historylog", _("Log and read search/replace string history"));
print1opt("-H", "--historylog", _("Log & read search/replace string history"));
print1opt("-I", "--ignorercfiles", _("Don't look at nanorc files"));
#endif
print1opt("-K", "--keypad", _("Use alternate keypad routines"));
@@ -665,7 +670,7 @@ void usage(void)
#ifndef DISABLE_OPERATINGDIR
print1opt(_("-o [dir]"), _("--operatingdir=[dir]"), _("Set operating directory"));
#endif
print1opt(_("-p"), _("--preserve"), _("Preserve XON (^Q) and XOFF (^S) keys"));
print1opt("-p", "--preserve", _("Preserve XON (^Q) and XOFF (^S) keys"));
#ifndef DISABLE_WRAPJUSTIFY
print1opt(_("-r [#cols]"), _("--fill=[#cols]"), _("Set fill cols to (wrap lines at) #cols"));
#endif
@@ -768,15 +773,6 @@ void nano_disabled_msg(void)
}
#endif
void do_preserve_msg(void)
{
fprintf(stderr, _("\nThe -p flag now invokes the Pico \"preserve\" flag. The Pico\n"));
fprintf(stderr, _("compatibility flag has been removed as nano is now fully Pico\n"));
fprintf(stderr, _("compatible. Please see the nano FAQ for more info on this change...\n\n"));
fprintf(stderr, _("Press return to continue\n"));
while (getchar() != '\n');
}
#ifndef NANO_SMALL
static int pid; /* This is the PID of the newly forked process
* below. It must be global since the signal
@@ -902,49 +898,40 @@ void do_mouse(void)
return;
/* If mouse not in edit or bottom window, return */
if (wenclose(edit, mevent.y, mevent.x)) {
/* Don't let people screw with the marker when they're in a
* subfunction. */
if (currshortcut != main_list)
return;
if (wenclose(edit, mevent.y, mevent.x) && currshortcut == main_list) {
int sameline;
/* Did they click on the line with the cursor? If they
clicked on the cursor, we set the mark. */
size_t xcur;
/* The character they clicked on. */
/* Subtract out size of topwin. Perhaps we need a constant
* somewhere? */
mevent.y -= 2;
/* Selecting where the cursor is sets the mark. Selecting
* beyond the line length with the cursor at the end of the line
* sets the mark as well. */
if ((mevent.y == current_y) &&
((mevent.x == current_x) || (current_x == strlen(current->data)
&& (mevent.x >
strlen(current->data))))) {
sameline = mevent.y == current_y;
/* Move to where the click occurred. */
for(; current_y < mevent.y && current->next != NULL; current_y++)
current = current->next;
for(; current_y > mevent.y && current->prev != NULL; current_y--)
current = current->prev;
xcur = actual_x(current, get_page_start(xplustabs()) + mevent.x);
/* Selecting where the cursor is toggles the mark. As does
selecting beyond the line length with the cursor at the end of
the line. */
if (sameline && xcur == current_x) {
if (ISSET(VIEW_MODE)) {
print_view_warning();
return;
}
do_mark();
} else if (mevent.y > current_y) {
while (mevent.y > current_y) {
if (current->next != NULL)
current = current->next;
else
break;
current_y++;
}
} else if (mevent.y < current_y) {
while (mevent.y < current_y) {
if (current->prev != NULL)
current = current->prev;
else
break;
current_y--;
}
}
current_x = actual_x(current, mevent.x);
placewewant = current_x;
update_cursor();
current_x = xcur;
placewewant = xplustabs();
edit_refresh();
} else if (wenclose(bottomwin, mevent.y, mevent.x) && !ISSET(NO_HELP)) {
int i, k;
@@ -1031,9 +1018,6 @@ void do_char(char ch)
if (refresh)
edit_refresh();
#endif
check_statblank();
UNSET(KEEP_CUTBUFFER);
}
int do_backspace(void)
@@ -1107,7 +1091,6 @@ int do_backspace(void)
#ifdef DEBUG
fprintf(stderr, _("After, data = \"%s\"\n"), current->data);
#endif
UNSET(KEEP_CUTBUFFER);
refresh = 1;
}
@@ -1166,7 +1149,6 @@ int do_delete(void)
totsize--;
set_modified();
UNSET(KEEP_CUTBUFFER);
update_line(current, current_x);
if (refresh)
edit_refresh();
@@ -1527,7 +1509,7 @@ int do_wrap(filestruct *inptr)
* between after_break and wrap_line. If the line already ends
* in a tab or a space, we don't add a space and decrement
* totsize to account for that. */
if (!isspace(newline[strlen(newline) - 1]))
if (!isspace((int) newline[strlen(newline) - 1]))
strcat(newline, " ");
else
totsize--;
@@ -1597,32 +1579,29 @@ int do_wrap(filestruct *inptr)
#endif /* !DISABLE_WRAPPING */
#ifndef DISABLE_SPELLER
/* word is misspelled in the file. Let the user replace it. We return
False if the user cancels. */
int do_int_spell_fix(const char *word)
{
char *save_search;
char *save_replace;
filestruct *begin;
int i = 0, j = 0, beginx, beginx_top, reverse_search_set, case_sens_set;
filestruct *current_save = current;
int current_x_save = current_x;
filestruct *edittop_save = edittop;
/* Save where we are. */
int i = 0;
/* The return value. */
int reverse_search_set = ISSET(REVERSE_SEARCH);
#ifndef NANO_SMALL
int mark_set;
#endif
int case_sens_set = ISSET(CASE_SENSITIVE);
int mark_set = ISSET(MARK_ISSET);
/* save where we are */
begin = current;
beginx = current_x + 1;
/* Make sure Spell Check goes forward only */
reverse_search_set = ISSET(REVERSE_SEARCH);
UNSET(REVERSE_SEARCH);
case_sens_set = ISSET(CASE_SENSITIVE);
SET(CASE_SENSITIVE);
#ifndef NANO_SMALL
/* Make sure the marking highlight is off during Spell Check */
mark_set = ISSET(MARK_ISSET);
UNSET(MARK_ISSET);
#endif
/* Make sure Spell Check goes forward only */
UNSET(REVERSE_SEARCH);
/* save the current search/replace strings */
search_init_globals();
@@ -1635,69 +1614,60 @@ int do_int_spell_fix(const char *word)
/* start from the top of file */
current = fileage;
current_x = beginx_top = -1;
current_x = -1;
search_last_line = FALSE;
while (1) {
/* make sure word is still mis-spelt (i.e. when multi-errors) */
if (findnextstr(TRUE, FALSE, fileage, beginx_top, word)) {
/* We find the first whole-word occurrence of word. */
while (findnextstr(TRUE, TRUE, fileage, -1, word))
if (is_whole_word(current_x, current->data, word)) {
edit_refresh();
/* find whole words only */
if (!is_whole_word(current_x, current->data, word))
continue;
edit_update(current, current_x);
do_replace_highlight(TRUE, word);
/* allow replace word to be corrected */
i = statusq(0, spell_list, last_replace,
i = statusq(0, spell_list, word,
#ifndef NANO_SMALL
0,
NULL,
#endif
_("Edit a replacement"));
_("Edit a replacement"));
do_replace_highlight(FALSE, word);
/* start from the start of this line again */
current = fileage;
current_x = beginx_top;
if (i != -1 && strcmp(word, answer)) {
int j = 0;
search_last_line = FALSE;
if (strcmp(word, answer)) {
j = i;
do_replace_loop(word, fileage, &beginx_top, TRUE, &j);
search_last_line = FALSE;
current_x--;
do_replace_loop(word, current_save, &current_x_save, TRUE, &j);
}
break;
}
break;
}
/* restore the search/replace strings */
free(last_search); last_search=save_search;
free(last_replace); last_replace=save_replace;
/* restore where we were */
current = begin;
current_x = beginx - 1;
current = current_save;
current_x = current_x_save;
edittop = edittop_save;
/* restore Search/Replace direction */
if (reverse_search_set)
SET(REVERSE_SEARCH);
#ifndef NANO_SMALL
if (!case_sens_set)
UNSET(CASE_SENSITIVE);
#ifndef NANO_SMALL
/* restore marking highlight */
if (mark_set)
SET(MARK_ISSET);
#endif
if (i == -1)
return FALSE;
return TRUE;
return i != -1;
}
/* Integrated spell checking using 'spell' program. Return value: NULL
@@ -1854,7 +1824,7 @@ char *do_int_speller(char *tempfile_name)
free(read_buff);
replace_abort();
edit_update(current, current_x);
edit_refresh();
/* Process end of spell process */
@@ -1985,7 +1955,7 @@ int do_spell(void)
nano_disabled_msg();
return TRUE;
#else
char *temp, *spell_msg = _("Generic error");
char *temp, *spell_msg;
if ((temp = safe_tempnam(0, "nano.")) == NULL) {
statusbar(_("Could not create a temporary filename: %s"),
@@ -2010,17 +1980,15 @@ int do_spell(void)
else
spell_msg = do_int_speller(temp);
remove(temp);
free(temp);
if (spell_msg == NULL) {
statusbar(_("Finished checking spelling"));
return 1;
} else {
if (spell_msg != NULL) {
statusbar(_("Spell checking failed: %s"), spell_msg);
return 0;
}
free(temp);
statusbar(_("Finished checking spelling"));
return 1;
#endif
}
@@ -2063,12 +2031,12 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
/* These four asserts are assumptions about the input data. */
assert(line != NULL);
assert(line->data != NULL);
assert(skip <= strlen(line->data));
assert(skip < strlen(line->data));
assert(line->data[skip] != ' ' && line->data[skip] != '\t');
back = line->data + skip;
front = back;
for (; *front; front++) {
for (front = back; ; front++) {
int remove_space = 0;
/* Do we want to remove this space? */
@@ -2078,11 +2046,11 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
*front = ' ';
}
/* these tests are safe since line->data + skip is not a space */
if (*front == ' ' && *(front - 1) == ' ') {
if ((*front == '\0' || *front == ' ') && *(front - 1) == ' ') {
const char *bob = front - 2;
remove_space = 1;
for (bob = front - 2; bob >= line->data + skip; bob--) {
for (bob = back - 2; bob >= line->data + skip; bob--) {
if (strchr(punct, *bob) != NULL) {
remove_space = 0;
break;
@@ -2101,28 +2069,25 @@ int justify_format(int changes_allowed, filestruct *line, size_t skip)
if (mark_beginbuf == line && back - line->data < mark_beginx)
mark_beginx--;
#endif
if (*front == '\0')
*(back - 1) = '\0';
} else {
*back = *front;
back++;
}
if (*front == '\0')
break;
}
/* Remove spaces from the end of the line, except maintain 1 after a
* sentence punctuation. */
while (line->data < back && *(back - 1) == ' ')
back--;
if (line->data < back && *back == ' ' &&
strchr(punct, *(back - 1)) != NULL)
back++;
if (!changes_allowed && back != front)
return 1;
back--;
assert(*back == '\0' && *front == '\0');
/* This assert merely documents a fact about the loop above. */
assert(changes_allowed != 0 || back == front);
/* Now back is the new end of line->data. */
if (back != front) {
totsize += back - line->data - strlen(line->data);
totsize -= front - back;
null_at(&line->data, back - line->data);
#ifndef NANO_SMALL
if (mark_beginbuf == line && back - line->data < mark_beginx)
@@ -2224,6 +2189,23 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len,
return first_line;
}
/* Is it possible to break line at or before goal? */
int breakable(const char *line, int goal)
{
for(; *line != '\0' && goal >= 0; line++) {
if (*line == ' ' || *line == '\t')
return TRUE;
if (is_cntrl_char(*line) != 0)
goal -= 2;
else
goal -= 1;
}
/* If goal is not negative, the whole line (one word) was short
* enough. */
return goal >= 0;
}
/* We are trying to break a chunk off line. We find the last space such
* that the display length to there is at most goal + 1. If there is
* no such space, and force is not 0, then we find the first space.
@@ -2257,7 +2239,7 @@ int break_line(const char *line, int goal, int force)
/* No space found short enough. */
if (force)
for(; *line != '\0'; line++, cur_loc++)
if (*line == ' ' && *(line + 1) != ' ')
if (*line == ' ' && *(line + 1) != ' ' && *(line + 1) != '\0')
return cur_loc;
return -1;
}
@@ -2396,10 +2378,10 @@ int do_justify(void)
/* There is no next paragraph, so nothing to justify. */
if (current->next == NULL) {
placewewant = 0;
if (current_y > editwinrows - 1)
edit_update(current, CENTER);
else
edit_refresh();
edit_refresh();
#ifdef HAVE_REGEX_H
regfree(&qreg);
#endif
return 0;
}
current = current->next;
@@ -2442,6 +2424,7 @@ int do_justify(void)
/* Next step, we loop through the lines of this paragraph, justifying
* each one individually. */
SET(JUSTIFY_MODE);
for(; par_len > 0; current_y++, par_len--) {
size_t line_len;
size_t display_len;
@@ -2482,6 +2465,13 @@ int do_justify(void)
* line and copy text after break_pos into it. */
splice_node(current, make_new_node(current),
current->next);
/* In a non-quoted paragraph, we copy the indent only if
AUTOINDENT is turned on. */
if (quote_len == 0)
#ifndef NANO_SMALL
if (!ISSET(AUTOINDENT))
#endif
indent_len = 0;
current->next->data = charalloc(indent_len + line_len -
break_pos);
strncpy(current->next->data, current->data,
@@ -2498,9 +2488,8 @@ int do_justify(void)
indent_len = quote_len +
indent_length(current->next->data + quote_len);
current->next->data = (char *)nrealloc(current->next->data,
sizeof(char) * (next_line_len + line_len -
break_pos + 1));
current->next->data = charealloc(current->next->data,
next_line_len + line_len - break_pos + 1);
memmove(current->next->data + indent_len + line_len - break_pos,
current->next->data + indent_len,
@@ -2526,21 +2515,25 @@ int do_justify(void)
null_at(&current->data, break_pos);
current = current->next;
} else if (display_len < fill && par_len > 1) {
size_t next_line_len = strlen(current->next->data);
size_t next_line_len;
indent_len = quote_len +
indent_length(current->next->data + quote_len);
break_pos = break_line(current->next->data + indent_len,
fill - display_len - 1, 0);
if (break_pos == -1)
/* We can't pull a word from the next line up to this one,
* so just go on. */
/* If we can't pull a word from the next line up to this one,
* just go on. */
if (!breakable(current->next->data + indent_len,
fill - display_len - 1))
goto continue_loc;
/* If we haven't backed up the paragraph, do it now. */
if (first_mod_line == NULL)
first_mod_line = backup_lines(current, par_len, quote_len);
current->data = (char *)nrealloc(current->data,
break_pos = break_line(current->next->data + indent_len,
fill - display_len - 1, FALSE);
assert(break_pos != -1);
current->data = charealloc(current->data,
line_len + break_pos + 2);
current->data[line_len] = ' ';
strncpy(current->data + line_len + 1,
@@ -2558,6 +2551,7 @@ int do_justify(void)
mark_beginx -= break_pos + 1;
}
#endif
next_line_len = strlen(current->next->data);
if (indent_len + break_pos == next_line_len) {
line = current->next;
@@ -2582,6 +2576,8 @@ int do_justify(void)
continue_loc:
current = current->next;
}
UNSET(JUSTIFY_MODE);
/* We are now done justifying the paragraph. There are cleanup things to
* do, and we check for unjustify. */
@@ -2668,7 +2664,7 @@ int do_justify(void)
}
cutbuffer = cutbuffer_save;
blank_statusbar_refresh();
/* display shortcut list without UnCut */
/* display shortcut list with UnCut */
shortcut_init(0);
display_main_list();
@@ -2797,14 +2793,14 @@ void signal_init(void)
/* Handler for SIGHUP and SIGTERM */
RETSIGTYPE handle_hupterm(int signal)
{
die(_("Received SIGHUP or SIGTERM"));
die(_("Received SIGHUP or SIGTERM\n"));
}
/* What do we do when we catch the suspend signal */
RETSIGTYPE do_suspend(int signal)
{
endwin();
printf("\n\n\n\n\nUse \"fg\" to return to nano\n");
printf("\n\n\n\n\n%s\n", _("Use \"fg\" to return to nano"));
fflush(stdout);
/* Restore the terminal settings for the disabled keys */
@@ -2857,15 +2853,16 @@ void handle_sigwinch(int s)
* But not in all cases, argh. */
COLS = win.ws_col;
LINES = win.ws_row;
if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
editwinrows = LINES - 5 + no_help();
if (editwinrows < MIN_EDITOR_ROWS || COLS < MIN_EDITOR_COLS)
die_too_small();
#ifndef DISABLE_WRAPJUSTIFY
fill = wrap_at;
if (fill <= 0)
fill += COLS;
if (fill < MIN_FILL_LENGTH)
die_too_small();
if (fill < 0)
fill = 0;
#endif
hblank = nrealloc(hblank, COLS + 1);
@@ -2999,12 +2996,12 @@ int main(int argc, char *argv[])
{
int optchr;
int startline = 0; /* Line to try and start at */
int modify_control_seq;
int modify_control_seq = 0;
int fill_flag_used = 0; /* Was the fill option used? */
const shortcut *s;
#ifdef HAVE_GETOPT_LONG
int preserveopt = 0; /* Did the cmdline include --preserve? */
#endif
int keyhandled = 0; /* Have we handled the keystroke yet? */
int kbinput = -1; /* Input from keyboard */
#ifndef NANO_SMALL
const toggle *t;
#endif
@@ -3075,20 +3072,6 @@ int main(int argc, char *argv[])
textdomain(PACKAGE);
#endif
#ifdef HAVE_GETOPT_LONG
{
/* Check for the --preserve flag, and report error if people are
still using --pico. */
int i;
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--preserve"))
preserveopt = 1;
else if (!strcmp(argv[i], "--pico"))
do_preserve_msg();
}
}
#endif
#if !defined(ENABLE_NANORC) && defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING)
/* if we don't have rcfile support, we're root, and
--disable-wrapping-as-root is used, turn wrapping off */
@@ -3214,8 +3197,6 @@ int main(int argc, char *argv[])
case 'p':
SET(PRESERVE);
#ifdef HAVE_GETOPT_LONG
if (!preserveopt)
do_preserve_msg();
#endif
break;
#ifndef DISABLE_WRAPJUSTIFY
@@ -3282,9 +3263,15 @@ int main(int argc, char *argv[])
int tabsize_cpy = tabsize;
long flags_cpy = flags;
#ifndef DISABLE_OPERATINGDIR
operating_dir = NULL;
#endif
#ifndef DISABLE_JUSTIFY
quotestr = NULL;
#endif
#ifndef DISABLE_SPELLER
alt_speller = NULL;
#endif
do_rcfile();
@@ -3320,6 +3307,14 @@ int main(int argc, char *argv[])
#endif
#endif /* ENABLE_NANORC */
#ifndef NANO_SMALL
history_init();
#ifdef ENABLE_NANORC
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
load_history();
#endif
#endif
#ifndef DISABLE_OPERATINGDIR
/* Set up the operating directory. This entails chdir()ing there,
so that file reads and writes will be based there. */
@@ -3399,17 +3394,6 @@ int main(int argc, char *argv[])
keypad(bottomwin, TRUE);
}
#ifndef NANO_SMALL
history_init();
#ifdef ENABLE_NANORC
if (!ISSET(NO_RCFILE) && ISSET(HISTORYLOG))
load_history();
#endif
#endif
#ifdef DEBUG
fprintf(stderr, _("Main: bottom win\n"));
#endif
@@ -3420,7 +3404,7 @@ int main(int argc, char *argv[])
fprintf(stderr, _("Main: open file\n"));
#endif
open_file(filename, 1, 1);
open_file(filename, 0, 1);
#ifdef ENABLE_MULTIBUFFER
/* If we're using multibuffers and more than one file is specified
on the command line, load them all and switch to the first one
@@ -3445,6 +3429,11 @@ int main(int argc, char *argv[])
/* Return here after a sigwinch */
sigsetjmp(jmpbuf, 1);
/* SHUT UP GCC! */
startline = 0;
fill_flag_used = 0;
keyhandled = 0;
/* This variable should be initialized after the sigsetjmp(), so we
can't do Esc-Esc then quickly resize and muck things up. */
modify_control_seq = 0;
@@ -3453,8 +3442,10 @@ int main(int argc, char *argv[])
reset_cursor();
while (1) {
int keyhandled = 0; /* Have we handled the keystroke yet? */
int kbinput; /* Input from keyboard */
keyhandled = 0;
if (ISSET(CONSTUPDATE))
do_cursorpos(1);
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
currshortcut = main_list;
@@ -3638,20 +3629,25 @@ int main(int argc, char *argv[])
kbinput <= 'Z' && kbinput == s->altval - 32)) {
if (ISSET(VIEW_MODE) && !s->viewok)
print_view_warning();
else
else {
if (s->func != do_cut_text)
UNSET(KEEP_CUTBUFFER);
s->func();
}
keyhandled = 1;
break;
}
#ifndef NANO_SMALL
/* And for toggle switches */
for (t = toggles; t != NULL && !keyhandled; t = t->next)
if (kbinput == t->val || (t->val >= 'a' &&
t->val <= 'z' && kbinput == t->val - 32)) {
do_toggle(t);
keyhandled = 1;
break;
}
if (!keyhandled)
/* And for toggle switches */
for (t = toggles; t != NULL; t = t->next)
if (kbinput == t->val || (t->val >= 'a' &&
t->val <= 'z' && kbinput == t->val - 32)) {
UNSET(KEEP_CUTBUFFER);
do_toggle(t);
keyhandled = 1;
break;
}
#endif
#ifdef DEBUG
fprintf(stderr, _("I got Alt-%c! (%d)\n"), kbinput,
@@ -3681,25 +3677,33 @@ int main(int argc, char *argv[])
/* Look through the main shortcut list to see if we've hit a
shortcut key */
if (!keyhandled)
#if !defined(DISABLE_BROWSER) || !defined (DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
for (s = currshortcut; s != NULL && !keyhandled; s = s->next) {
for (s = currshortcut; s != NULL && !keyhandled; s = s->next) {
#else
for (s = main_list; s != NULL && !keyhandled; s = s->next) {
for (s = main_list; s != NULL && !keyhandled; s = s->next) {
#endif
if (kbinput == s->val ||
(s->misc1 && kbinput == s->misc1) ||
(s->misc2 && kbinput == s->misc2)) {
if (ISSET(VIEW_MODE) && !s->viewok)
print_view_warning();
else
s->func();
keyhandled = 1;
/* Rarely, the value of s can change after s->func(),
leading to problems; get around this by breaking out
explicitly once we successfully handle a shortcut */
break;
if (kbinput == s->val ||
(s->misc1 && kbinput == s->misc1) ||
(s->misc2 && kbinput == s->misc2)) {
if (ISSET(VIEW_MODE) && !s->viewok)
print_view_warning();
else {
if (s->func != do_cut_text)
UNSET(KEEP_CUTBUFFER);
s->func();
}
keyhandled = 1;
/* Rarely, the value of s can change after
s->func(), leading to problems; get around this
by breaking out explicitly once we successfully
handle a shortcut */
break;
}
}
}
if (!keyhandled)
UNSET(KEEP_CUTBUFFER);
#ifdef _POSIX_VDISABLE
/* Don't even think about changing this string */
@@ -3756,11 +3760,6 @@ int main(int argc, char *argv[])
do_char(kbinput);
}
if (ISSET(DISABLE_CURPOS))
UNSET(DISABLE_CURPOS);
else if (ISSET(CONSTUPDATE))
do_cursorpos(1);
reset_cursor();
wrefresh(edit);
}

35
nano.h
View File

@@ -34,6 +34,10 @@
/* Define charalloc as a macro rather than duplicating code */
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, (howmuch) * sizeof(char))
#ifdef BROKEN_REGEXEC
#define regexec(preg, string, nmatch, pmatch, eflags) regexec_safe(preg, string, nmatch, pmatch, eflags)
#endif
#ifndef NANO_SMALL
/* For the backup file copy ... */
@@ -55,10 +59,10 @@
# include <libintl.h>
# endif
# define _(string) gettext(string)
# define __(singular, plural, number) ngettext(singular, plural, number)
# define P_(singular, plural, number) ngettext(singular, plural, number)
#else
# define _(string) (string)
# define __(singular, plural, number) (number == 1 ? singular : plural)
# define P_(singular, plural, number) (number == 1 ? singular : plural)
#endif
#include <sys/types.h>
@@ -75,13 +79,12 @@
# endif
#endif
#if !defined(HAVE_STRCASECMP) || !defined(HAVE_STRNCASECMP)
# ifndef HAVE_STRCASECMP
# define strcasecmp strcmp
# endif
# ifndef HAVE_STRNCASECMP
# define strncasecmp strncmp
# endif
#ifndef HAVE_STRCASECMP
#define strcasecmp strcmp
#endif
#ifndef HAVE_STRNCASECMP
#define strncasecmp strncmp
#endif
/* HP-UX 10 & 11 do not seem to support KEY_HOME and KEY_END */
@@ -181,13 +184,13 @@ typedef struct colortype {
int bg; /* bg color */
int bright; /* Is this color A_BOLD? */
int pairnum; /* Color pair number used for this fg/bg */
char *start; /* Start (or all) of the regex string */
char *end; /* End of the regex string */
regex_t start; /* Start (or all) of the regex string */
regex_t *end; /* End of the regex string */
struct colortype *next;
} colortype;
typedef struct exttype {
char *val;
regex_t val; /* The extensions that match this syntax. */
struct exttype *next;
} exttype;
@@ -249,6 +252,7 @@ typedef struct historyheadtype {
#define PRESERVE (1<<28)
#define HISTORY_CHANGED (1<<29)
#define HISTORYLOG (1<<30)
#define JUSTIFY_MODE (1<<31)
/* Control key sequences, changing these would be very very bad */
@@ -416,14 +420,13 @@ typedef enum {
/* Minimum editor window rows required for nano to work correctly */
#define MIN_EDITOR_ROWS 3
/* Minimum editor window cols required for nano to work correctly */
#define MIN_EDITOR_COLS 10
/* Default number of characters from end-of-line where text wrapping
occurs */
#define CHARS_FROM_EOL 8
/* Minimum fill length (space available for text before wrapping
occurs) */
#define MIN_FILL_LENGTH 10
/* Maximum number of search history strings saved, same value used for
replace history */
#define MAX_SEARCH_HISTORY 100

View File

@@ -9,7 +9,7 @@ Release : %{rel}
Copyright : GPL
Group : Console/Editors
URL : http://www.nano-editor.org
Source : http://www.nano-editor.org/dist/v1.1/%{name}-%{ver}.tar.gz
Source : http://www.nano-editor.org/dist/v1.2/%{name}-%{ver}.tar.gz
BuildRoot : /var/tmp/%{name}-buildroot
Requires : ncurses
@@ -21,7 +21,7 @@ text editor while also offering a few enhancements.
%setup -q
%build
%configure --enable-extra
%configure --enable-all
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
%install

View File

@@ -8,7 +8,7 @@
@c Run `makeinfo' rather than `texinfo-format-buffer'.
@smallbook
@set EDITION 0.1
@set VERSION 1.1.99pre1
@set VERSION 1.2.1
@set UPDATED 17 Jan 2003
@dircategory Editors
@@ -23,7 +23,7 @@
@titlepage
@title GNU @code{nano}
@subtitle a small and friendly text editor.
@subtitle version 1.1.99pre1
@subtitle version 1.2.1
@author Chris Allegretta
@page
@@ -387,7 +387,7 @@ are certain differences between the editors:
@table @code
@item Search and Replace History
As of version 1.1.99pre1 of @code{nano}, text entered as search or replace
As of version 1.2.1 of @code{nano}, text entered as search or replace
strings will be stored and can be accessed with the up/down
arrow keys. Previously, @code{nano} offered a more consistent, but incompatible
with Pico, method for entering search and replace strings. In the old
@@ -425,7 +425,7 @@ replace it. The @code{nano} implementation will stop at each search
string found and query whether to replace this instance or not. The
internal spell checker operates similarly. Note that these is no way
to force these functions to behave in the Pico fashion. As of
version 1.1.99pre1, misspelled words are sorted and trimmed for
version 1.2.1, misspelled words are sorted and trimmed for
uniqueness in the internal spell checker such that the words 'apple'
and 'Apple' will be prompted for correction separately.
@end table

154
nanorc.5 Normal file
View File

@@ -0,0 +1,154 @@
.\" Hey, EMACS: -*- nroff -*-
.\" nanorc.5 is Copyright (C) 2003 Free Software Foundation, Inc.
.\"
.\" This is free documentation, see the latest version of the GNU General
.\" Public License for copying conditions. There is NO warranty.
.\"
.\" $Id$
.TH NANORC 5 "February 14, 2003"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH NAME
nanorc \- GNU nano's rcfile
.SH SYNOPSIS
.B /etc/nanorc
.br
.B $HOME/.nanorc
.br
.SH DESCRIPTION
This manual page documents GNU \fBnano\fP's rcfile.
.PP
\fBnano\fP is a small, free and friendly editor which aims to replace
Pico, the default editor included in the non-free Pine package. Rather
than just copying Pico's look and feel, \fBnano\fP also implements some
missing (or disabled by default) features in Pico, such as "search and
replace" and "go to line number".
.SH OPTIONS
The configuration file accepts a series of "set" and "unset" commands,
which can be used to configure nano on startup without using the
command-line options. Additionally, the "syntax" and "color" keywords
are used to define syntax highlighting rules for different text patterns.
GNU nano will read one command per line.
Options in rcfiles take precedence over nano's defaults, and command line
options override rcfile settings.
Options are unset by default, except for options that take an argument.
The supported commands and arguments are:
.TP 3
\fBset/unset autoindent\fP
Use auto-indentation.
.TP
\fBset/unset backup\fP
Create backup files in filename~.
.TP
\fBset/unset const\fP
Constantly display the cursor position in the status bar.
.TP
\fBset/unset cut\fP
Use cut to end of line with ^K by default.
.TP
\fBset fill \fIn\fP\fP
Wrap lines at column number \fIn\fP. If \fIn\fP is 0 or less, the line
length will be the screen width less \fIn\fP. The default value is -8.
.TP
\fBset/unset keypad\fP
Use alternate keypad routines.
.TP
\fBset/unset multibuffer\fP
Allow inserting files into their own buffers.
.TP
\fBset/unset noconvert\fP
Don't convert files from DOS/Mac format.
.TP
\fBset/unset nofollow\fP
Don't follow symlinks when writing files.
.TP
\fBset/unset nohelp\fP
Don't display the help lists at the bottom of the screen.
.TP
\fBset/unset nowrap\fP
Don't wrap text at all.
.TP
\fBset operatingdir "\fIdirectory\fP"\fP
\fBnano\fP will only read and write files inside \fIdirectory\fP and its
subdirectories. Also, the current directory is changed to here, so files
are inserted from this dir. By default the operating directory feature is
turned off.
.TP
\fBset/unset preserve\fP
Preserve the XON and XOFF keys (^Q and ^S).
.TP
\fBset quotestr "\fIstring\fP"\fP
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.
.TP
\fBset/unset regexp\fP
Do regular expression searches by default.
.TP
\fBset/unset smooth\fP
Use smooth scrolling by default.
.TP
\fBset speller \fIspellprog\fP\fP
Use spelling checker \fIspellprog\fP instead of the built-in one, which
calls \fIspell\fP.
.TP
\fBset/unset suspend\fP
Allow nano to be suspended with ^Z.
.TP
\fBset tabsize \fIn\fP\fP
Use a tab size of \fIn\fP instead of the default (8); must be greater
than 0.
.TP
\fBset/unset tempfile\fP
Save automatically on exit, don't prompt.
.TP
\fBset/unset historylog\fP
Enable ~/.nano_history for saving and reading search/replace strings.
.TP
\fBset/unset view\fP
Disallow file modification.
.TP
.B syntax "\fIstr\fP" ["\fIfileregex\fP" ... ]
Defines a syntax named \fIstr\fP which can be activated via the
\fB-Y\fP flag, or will be automatically activated if the current
filename matches \fIfileregex\fP. All following \fBcolor\fP statements
will apply to \fIsyntax\fP until a new syntax is defined.
.TP
.B color \fIfgcolor\fP[,\fIbgcolor\fP] "\fIregex\fP" ...
For the currently defined syntax, display all expressions matching
\fIregex\fP with foreground color \fIfgcolor\fP and optional background
color \fIbgcolor\fP. Legal colors for foreground and background color are:
white, black, red, blue, green, yellow, magenta, and cyan. You may use
the prefix "bright" to force a stronger color highlight. If your
terminal supports transparency, not specifying a \fIbgcolor\fP tells
\fBnano\fP to attempt to use a transparent background.
.TP
.B color \fIfgcolor\fP[,\fIbgcolor\fP] start="\fIsr\fP" end="\fIer\fP"
Display expressions which start with \fIsr\fP and end with \fIer\fP
with foreground color \fIfgcolor\fP and optional
background color \fIbgcolor\fP. This allows syntax highlighting to span
multiple lines. Note that all subsequent instances of \fIsr\fP after
an initial \fIsr\fP is found will be highlighted until the first
instance of \fIer\fP.
\fI
.SH SEE ALSO
.PD 0
.TP
\fBnano\fP(1)
.PP
\fI/usr/share/doc/nano/examples/nanorc.sample\fP (or equivalent on your system)
.SH AUTHOR
Chris Allegretta <chrisa@asty.org>, et al (see AUTHORS and THANKS for
details).
This manual page was written by Jordi Mallach <jordi@gnu.org>.

160
nanorc.5.html Normal file
View File

@@ -0,0 +1,160 @@
<HTML><HEAD><TITLE>Manpage of NANORC</TITLE>
</HEAD><BODY>
<H1>NANORC</H1>
Section: File Formats (5)<BR>Updated: February 9, 2003<BR><A HREF="#index">Index</A>
<A HREF="http://localhost/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
nanorc - GNU nano's rcfile
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>/etc/nanorc</B>
<B>$HOME/.nanorc</B>
<BR>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
This manual page documents GNU <B>nano</B>'s rcfile.
<P>
<B>nano</B> is a small, free and friendly editor which aims to replace
Pico, the default editor included in the non-free Pine package. Rather
than just copying Pico's look and feel, <B>nano</B> also implements some
missing (or disabled by default) features in Pico, such as &quot;search and
replace&quot; and &quot;go to line number&quot;.
<P>
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
The configuration file accepts a series of &quot;set&quot; and &quot;unset&quot; commands,
which can be used to configure nano on startup without using the
command-line options. Additionally, the &quot;syntax&quot; and &quot;color&quot; keywords
are used to define syntax highlighting rules for different text patterns.
GNU nano will read one command per line.
<P>
Options in rcfiles take precedence over nano's defaults, and command line
options override rcfile settings.
<P>
The supported commands and arguments are:
<P>
<DL COMPACT>
<DT><B>set/unset autoindent</B><DD>
Use auto-indentation.
<DT><B>set/unset backup</B><DD>
Create backup files in filename~.
<DT><B>set/unset const</B><DD>
Constantly update the cursor position.
<DT><B>set/unset cut</B><DD>
Use cut to end of line with ^K by default.
<DT><B>set fill </B><I>n</I><DD>
Set the column where lines will be wrapped at to <I>n</I>.
<DT><B>set/unset keypad</B><DD>
Use alternate keypad routines.
<DT><B>set/unset multibuffer</B><DD>
Allow inserting files into their own buffers.
<DT><B>set/unset noconvert</B><DD>
Don't convert files from DOS/Mac format.
<DT><B>set/unset nofollow</B><DD>
Don't follow symlinks when writing files.
<DT><B>set/unset nohelp</B><DD>
Don't display the help lists at the bottom of the screen.
<DT><B>set/unset nowrap</B><DD>
Don't wrap text at all.
<DT><B>set operatingdir &quot;</B><I>directory</I>&quot;<DD>
Set operating directory (chroots the user to <I>directory</I> and below).
<DT><B>set/unset preserve</B><DD>
Preserve the XON and XOFF keys (^Q and ^S).
<DT><B>set quotestr &quot;</B><I>string</I>&quot;<DD>
The email-quote string. This is a &quot;regular expression&quot; if your
system supports them, otherwise a literal string.
Default value is set quotestr &quot;^([ ]*[|&gt;:}#])+&quot; if you have regexps,
otherwise set quotestr &quot;&gt; &quot;.
<DT><B>set/unset regexp</B><DD>
Do regular expression searches by default.
<DT><B>set/unset smooth</B><DD>
Use smooth scrolling by default.
<DT><B>set speller </B><I>spellprog</I><DD>
Use spelling checker <I>spellprog</I> instead of the default (spell).
<DT><B>set/unset suspend</B><DD>
Allow nano to be suspended with ^Z.
<DT><B>set tabsize </B><I>n</I><DD>
Use a tab size of <I>n</I> instead of the default (8); must be greater
than 0.
<DT><B>set/unset tempfile</B><DD>
Save automatically on exit, don't prompt.
<DT><B>set/unset historylog</B><DD>
Enable ~/.nano_history for saving and reading search/replace strings.
<DT><B>set/unset view</B><DD>
Disallow file modification.
<DT><B>syntax </B><I>str</I> [<I>fileregex</I> ... ]
<DD>
Defines a syntax named <I>str</I> which can be activated via the
<B>-Y</B> flag, or will be automatically activated if the current
filename matches <I>fileregex</I>. All following <B>color</B> statements
will apply to <I>syntax</I> until a new syntax is defined.
<DT><B>color </B><I>fgcolor</I>[,<I>bgcolor</I>] <I>regex</I> ...
<DD>
For the currently defined syntax, display all expressions matching
<I>regex</I> with foreground color <I>fgcolor</I> and optional background
color <I>bgcolor</I>. Legal colors for foreground and background color are:
white, black, red, blue, green, yellow, magenta, and cyan. You may use
the prefix &quot;bright&quot; to force a stronger color highlight. If your
terminal supports transparency, not specifying a <I>bgcolor</I> tells
<B>nano</B> to attempt to use a transparent background.
<DT><B>color </B><I>fgcolor</I>[,<I>bgcolor</I>] start=<I>sr</I> end=<I>er</I>
<DD>
Display expressions which start with <I>sr</I> and end with <I>er</I>
with foreground color <I>fgcolor</I> and optional
background color <I>bgcolor</I>. This allows syntax highlighting to span
multiple lines. Note that all subsequent instances of <I>sr</I> after
an initial <I>sr</I> is found will be highlighted until the first
instance of <I>er</I>.
<I>
<P>
</DL>
</I><A NAME="lbAF">&nbsp;</A>
<H2>SEE ALSO</H2>
<DL COMPACT>
<DT><B><A HREF="http://localhost/cgi-bin/man/man2html?1+nano">nano</A></B>(1)<DD>
</DL>
<P>
<I>/usr/share/doc/nano/examples/nanorc.sample</I> (or equivalent on your system)
<A NAME="lbAG">&nbsp;</A>
<H2>AUTHOR</H2>
Chris Allegretta &lt;<A HREF="mailto:chrisa@asty.org">chrisa@asty.org</A>&gt;, et al (see AUTHORS and THANKS for
details).
This manual page was written by Jordi Mallach &lt;<A HREF="mailto:jordi@gnu.org">jordi@gnu.org</A>&gt;.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT><A HREF="#lbAB">NAME</A><DD>
<DT><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT><A HREF="#lbAE">OPTIONS</A><DD>
<DT><A HREF="#lbAF">SEE ALSO</A><DD>
<DT><A HREF="#lbAG">AUTHOR</A><DD>
</DL>
<HR>
This document was created by
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 04:08:33 GMT, February 13, 2003
</BODY>
</HTML>

View File

@@ -84,7 +84,7 @@
## syntax "short description" ["filename regex" ...]
## color foreground,background "regex" ["regex"...]
##
## Legal colors are: white, black, red, blue, green, yellow, purple,
## Legal colors are: white, black, red, blue, green, yellow, magenta,
## cyan. You may use the prefix "bright" to mean a stronger color
## highlight.
##
@@ -172,6 +172,6 @@
#color brightwhite "^ *syntax [^ ]*"
#color brightblue "^ *set\>" "^ *unset\>" "^ *syntax\>"
#color white "^ *color\>.*"
#color yellow "^ *color [^ ]*"
#color yellow "^ *color (bright)?(white|black|red|blue|green|yellow|magenta|cyan)\>"
#color magenta "^ *color\>"
#color green "^#.*$"

View File

@@ -1,3 +1,119 @@
2003-04-12 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-04-04 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-03-17 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-03-10 Jordi Mallach <jordi@gnu.org>
* da.po: Updated Danish translation by Keld Simonsen.
2003-03-06 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
* id.po: Updated Indonesian translation by Tedi Heriyanto.
2003-02-23 Jordi Mallach <jordi@gnu.org>
* nl.po: Updated Dutch translation by Guus Sliepen.
2003-02-19 Jordi Mallach <jordi@gnu.org>
* fi.po: Updated Finnish translation by Kalle Olavi Niemitalo.
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
Medina.
2003-02-17 Jordi Mallach <jordi@gnu.org>
* de.po: Updated German translation by Michael Piefel.
* ru.po: Updated Russian translation by Sergey A. Ribalchenko.
* uk.po: Updated Ukrainian translation by Sergey A. Ribalchenko.
2003-02-16 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated Galician translation by Jacobo Tarrío.
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-02-15 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
* nl.po: Updated Dutch translation by Guus Sliepen.
* sv.po: Updated Swedish translation by Christian Rose.
* ca.po: Updated Catalan translation.
2003-02-13 Jordi Mallach <jordi@gnu.org>
* ru.po: Updated Russian translation from Sergey A. Ribalchenko.
2003-02-10 Jordi Mallach <jordi@gnu.org>
* Makevars (XGETTEXT_OPTIONS): Added --keyword=P_:1,2.
* update.pl: likewise.
* fi.po: Added Plural-Forms: header.
2003-02-10 Jordi Mallach <jordi@gnu.org>
* fi.po: Updated Finnish translation by Kalle Kivimaa and
Kalle Olavi Niemitalo.
2003-02-08 Chris Allegretta <chrisa@asty.org>
* it.po: Fix broken format string in translation.
2003-02-08 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by Marco Colombo.
* gl.po: Updated Galician translation by Jacobo Tarrío.
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
Medina.
2003-02-06 Jordi Mallach <jordi@gnu.org>
* pl.po: Updated Polish translation by Wojciech Kotwica.
* sv.po: Updated Swedish translation by Christian Rose.
2003-02-04 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* uk.po: Updated Ukrainian translation by Sergey A. Ribalchenko.
* de.po: Updated German translation by Michael Piefel.
2003-01-27 Jordi Mallach <jordi@gnu.org>
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
2002-01-26 Jordi Mallach <jordi@gnu.org>
* pl.po: Updated translation by Wojciech Kotwica.
2002-01-25 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated translation by Jacobo Tarrío.
2002-01-22 Jordi Mallach <jordi@gnu.org>
* de.po: Updated translation by Michael Piefel.
2003-01-21 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated translation by Jean-Philippe Guérard.
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
* uk.po: Updated translation by Sergey A. Ribalchenko.
2003-01-18 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated translation by Jean-Philippe Guérard.
* sv.po: Updated translation by Christian Rose.
* nl.po: Updated translation by Guus Sliepen.
* ca.po: Updated translation.
2003-01-15 Jordi Mallach <jordi@gnu.org>
* Makefile.in.in: Removed, generated by autopoint.

View File

@@ -1,23 +1,2 @@
# List of available languages.
es
de
fr
it
id
fi
hu
ca
cs
gl
uk
ru
sv
nn
nl
da
pl
nb
ms
pt_BR
tr
eu
es de fr it id fi hu ca cs gl uk ru sv nn nl da pl nb ms pt_BR tr eu

View File

@@ -8,7 +8,7 @@ subdir = po
top_builddir = ..
# These options get passed to xgettext.
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ --keyword=P_:1,2
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding

1019
po/ca.po

File diff suppressed because it is too large Load Diff

1023
po/cs.po

File diff suppressed because it is too large Load Diff

971
po/da.po

File diff suppressed because it is too large Load Diff

1014
po/de.po

File diff suppressed because it is too large Load Diff

1030
po/es.po

File diff suppressed because it is too large Load Diff

998
po/eu.po

File diff suppressed because it is too large Load Diff

1694
po/fi.po

File diff suppressed because it is too large Load Diff

1021
po/fr.po

File diff suppressed because it is too large Load Diff

1027
po/gl.po

File diff suppressed because it is too large Load Diff

1017
po/hu.po

File diff suppressed because it is too large Load Diff

975
po/id.po

File diff suppressed because it is too large Load Diff

1041
po/it.po

File diff suppressed because it is too large Load Diff

989
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1017
po/nb.po

File diff suppressed because it is too large Load Diff

1349
po/nl.po

File diff suppressed because it is too large Load Diff

1017
po/nn.po

File diff suppressed because it is too large Load Diff

1036
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1433
po/ru.po

File diff suppressed because it is too large Load Diff

1049
po/sv.po

File diff suppressed because it is too large Load Diff

881
po/tr.po

File diff suppressed because it is too large Load Diff

1068
po/uk.po

File diff suppressed because it is too large Load Diff

View File

@@ -293,7 +293,7 @@ sub GeneratePot{
close INFILE;
$GETTEXT ="xgettext --default-domain\=$PACKAGE --directory\=\.\."
." --add-comments --keyword\=\_ --keyword\=N\_"
." --add-comments --keyword\=\_ --keyword\=N\_ --keyword\=P_\:1,2"
." --files-from\=\.\/POTFILES\.in ";
$GTEST ="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot "
."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)";

26
proto.h
View File

@@ -65,6 +65,7 @@ extern char *full_operating_dir;
extern char *alt_speller;
#endif
extern int resetstatuspos;
extern struct stat fileinfo;
extern filestruct *current, *fileage, *edittop, *editbot, *filebot;
extern filestruct *cutbuffer;
@@ -86,18 +87,25 @@ extern shortcut *shortcut_list;
extern shortcut *main_list, *whereis_list;
extern shortcut *replace_list, *goto_list;
extern shortcut *writefile_list, *insertfile_list;
extern shortcut *spell_list, *replace_list_2;
extern shortcut *replace_list_2;
#ifndef NANO_SMALL
extern shortcut *extcmd_list;
#endif
#ifndef DISABLE_HELP
extern shortcut *help_list;
#endif
#ifndef DISABLE_SPELLER
extern shortcut *spell_list;
#endif
#ifndef DISABLE_BROWSER
extern shortcut *browser_list, *gotodir_list;
#endif
#if !defined(DISABLE_BROWSER) || !defined(DISABLE_HELP) || (!defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION))
extern const shortcut *currshortcut;
#endif
#ifdef HAVE_REGEX_H
extern int use_regexp, regexp_compiled;
extern regex_t search_regexp;
extern regmatch_t regmatches[10];
#ifdef ENABLE_COLOR
@@ -115,6 +123,8 @@ extern historyheadtype search_history;
extern historyheadtype replace_history;
#endif
extern int curses_ended;
/* Functions we want available */
/* Public functions in color.c */
@@ -182,6 +192,7 @@ int diralphasort(const void *va, const void *vb);
void free_charptrarray(char **array, int len);
const char *tail(const char *foo);
void striponedir(char *foo);
int readable_dir(const char *path);
char **browser_init(const char *path, int *longest, int *numents);
char *do_browser(const char *inpath);
char *do_browse_from(const char *inpath);
@@ -250,7 +261,6 @@ int no_help(void);
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || defined(DISABLE_HELP) || defined(NANO_SMALL)
void nano_disabled_msg(void);
#endif
void do_preserve_msg(void);
#ifndef NANO_SMALL
RETSIGTYPE cancel_fork(int signal);
int open_pipe(const char *command);
@@ -299,6 +309,7 @@ size_t indents_match(const char *a_line, size_t a_indent,
const char *b_line, size_t b_indent);
filestruct *backup_lines(filestruct *first_line, size_t par_len,
size_t quote_len);
int breakable(const char *line, int goal);
int break_line(const char *line, int goal, int force);
#endif /* !DISABLE_JUSTIFY */
int do_justify(void);
@@ -325,6 +336,7 @@ char *parse_argument(char *ptr);
#ifdef ENABLE_COLOR
int colortoint(const char *colorname, int *bright);
char *parse_next_regex(char *ptr);
int nregcomp(regex_t *preg, const char *regex, int flags);
void parse_syntax(char *ptr);
void parse_colors(char *ptr);
#endif /* ENABLE_COLOR */
@@ -334,7 +346,7 @@ void do_rcfile(void);
/* Public functions in search.c */
#ifdef HAVE_REGEX_H
void regexp_init(const char *regexp);
int regexp_init(const char *regexp);
void regexp_cleanup(void);
#endif
void not_found_msg(const char *str);
@@ -354,7 +366,6 @@ char *replace_line(void);
int do_replace_loop(const char *prevanswer, const filestruct *begin,
int *beginx, int wholewords, int *i);
int do_replace(void);
void goto_abort(void);
int do_gotoline(int line, int save_pos);
int do_gotoline_void(void);
#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_SPELLER)
@@ -378,6 +389,10 @@ void save_history(void);
#endif
/* Public functions in utils.c */
#ifdef BROKEN_REGEXEC
int regexec_safe(const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags);
#endif
int is_cntrl_char(int c);
int num_of_digits(int n);
void align(char **strp);
@@ -459,6 +474,7 @@ void display_main_list(void);
void statusbar(const char *msg, ...);
int do_cursorpos(int constant);
int do_cursorpos_void(void);
int line_len(const char *ptr);
int do_help(void);
int keypad_on(WINDOW *win, int newval);
void do_replace_highlight(int highlight_flag, const char *word);

170
rcfile.c
View File

@@ -215,10 +215,10 @@ int colortoint(const char *colorname, int *bright)
rcfile_error(_("color %s not understood.\n"
"Valid colors are \"green\", \"red\", \"blue\", \n"
"\"white\", \"yellow\", \"cyan\", \"magenta\" and \n"
"\"black\", with the optional prefix \"bright\".\n"));
exit(1);
"\"black\", with the optional prefix \"bright\".\n"),
colorname);
mcolor = -1;
}
return mcolor;
}
@@ -240,11 +240,29 @@ char *parse_next_regex(char *ptr)
return ptr;
}
/* Compile the regular expression regex to preg. Returns FALSE on success,
TRUE if the expression is invalid. */
int nregcomp(regex_t *preg, const char *regex, int flags)
{
int rc = regcomp(preg, regex, REG_EXTENDED | flags);
if (rc != 0) {
size_t len = regerror(rc, preg, NULL, 0);
char *str = charalloc(len);
regerror(rc, preg, str, len);
rcfile_error(_("Bad regex \"%s\": %s"), regex, str);
free(str);
}
return rc != 0;
}
void parse_syntax(char *ptr)
{
syntaxtype *tmpsyntax = NULL;
const char *fileregptr = NULL, *nameptr = NULL;
exttype *exttmp = NULL;
exttype *endext = NULL;
/* The end of the extensions list for this syntax. */
while (*ptr == ' ')
ptr++;
@@ -291,6 +309,9 @@ void parse_syntax(char *ptr)
/* Now load in the extensions to their part of the struct */
while (*ptr != '\n' && *ptr != '\0') {
exttype *newext;
/* The new extension structure. */
while (*ptr != '"' && *ptr != '\n' && *ptr != '\0')
ptr++;
@@ -301,17 +322,17 @@ void parse_syntax(char *ptr)
fileregptr = ptr;
ptr = parse_next_regex(ptr);
if (tmpsyntax->extensions == NULL) {
tmpsyntax->extensions = (exttype *)nmalloc(sizeof(exttype));
exttmp = tmpsyntax->extensions;
} else {
for (exttmp = tmpsyntax->extensions; exttmp->next != NULL;
exttmp = exttmp->next);
exttmp->next = (exttype *)nmalloc(sizeof(exttype));
exttmp = exttmp->next;
newext = (exttype *)nmalloc(sizeof(exttype));
if (nregcomp(&newext->val, fileregptr, REG_NOSUB))
free(newext);
else {
if (endext == NULL)
tmpsyntax->extensions = newext;
else
endext->next = newext;
endext = newext;
endext->next = NULL;
}
exttmp->val = mallocstrcpy(NULL, fileregptr);
exttmp->next = NULL;
}
}
@@ -340,6 +361,10 @@ void parse_colors(char *ptr)
fg = colortoint(fgstr, &bright);
/* Don't try and parse screwed up fg colors */
if (fg == -1)
return;
if (syntaxes == NULL) {
rcfile_error(_("Cannot add a color directive without a syntax line"));
return;
@@ -353,6 +378,11 @@ void parse_colors(char *ptr)
in the colorstrings array, woo! */
while (*ptr != '\0') {
colortype *newcolor;
/* The new color structure. */
int cancelled = 0;
/* The start expression was bad. */
while (*ptr == ' ')
ptr++;
@@ -371,37 +401,37 @@ void parse_colors(char *ptr)
}
ptr++;
if (tmpsyntax->color == NULL) {
tmpsyntax->color = nmalloc(sizeof(colortype));
tmpcolor = tmpsyntax->color;
#ifdef DEBUG
fprintf(stderr, _("Starting a new colorstring for fg %d bg %d\n"),
fg, bg);
#endif
} else {
for (tmpcolor = tmpsyntax->color;
tmpcolor->next != NULL; tmpcolor = tmpcolor->next);
#ifdef DEBUG
fprintf(stderr, _("Adding new entry for fg %d bg %d\n"), fg, bg);
#endif
tmpcolor->next = nmalloc(sizeof(colortype));
tmpcolor = tmpcolor->next;
}
tmpcolor->fg = fg;
tmpcolor->bg = bg;
tmpcolor->bright = bright;
tmpcolor->next = NULL;
tmpcolor->start = ptr;
newcolor = (colortype *)nmalloc(sizeof(colortype));
fgstr = ptr;
ptr = parse_next_regex(ptr);
tmpcolor->start = mallocstrcpy(NULL, tmpcolor->start);
#ifdef DEBUG
fprintf(stderr, _("string val=%s\n"), tmpcolor->start);
#endif
if (nregcomp(&newcolor->start, fgstr, 0)) {
free(newcolor);
cancelled = 1;
} else {
newcolor->fg = fg;
newcolor->bg = bg;
newcolor->bright = bright;
newcolor->next = NULL;
newcolor->end = NULL;
if (!expectend)
tmpcolor->end = NULL;
else {
if (tmpsyntax->color == NULL) {
tmpsyntax->color = newcolor;
#ifdef DEBUG
fprintf(stderr, _("Starting a new colorstring for fg %d bg %d\n"),
fg, bg);
#endif
} else {
for (tmpcolor = tmpsyntax->color; tmpcolor->next != NULL;
tmpcolor = tmpcolor->next)
;
#ifdef DEBUG
fprintf(stderr, _("Adding new entry for fg %d bg %d\n"), fg, bg);
#endif
tmpcolor->next = newcolor;
}
}
if (expectend) {
if (ptr == NULL || strncasecmp(ptr, "end=", 4)) {
rcfile_error(_
("\"start=\" requires a corresponding \"end=\""));
@@ -417,13 +447,18 @@ void parse_colors(char *ptr)
}
ptr++;
tmpcolor->end = ptr;
fgstr = ptr;
ptr = parse_next_regex(ptr);
tmpcolor->end = mallocstrcpy(NULL, tmpcolor->end);
#ifdef DEBUG
fprintf(stderr, _("For end part, beginning = \"%s\"\n"),
tmpcolor->end);
#endif
/* If the start regex was invalid, skip past the end regex to
* stay in sync. */
if (cancelled)
continue;
newcolor->end = (regex_t *)nmalloc(sizeof(regex_t));
if (nregcomp(newcolor->end, fgstr, 0)) {
free(newcolor->end);
newcolor->end = NULL;
}
}
}
}
@@ -448,7 +483,7 @@ void parse_rcfile(FILE *rcstream)
if (*ptr == '#') {
#ifdef DEBUG
fprintf(stderr, _("parse_rcfile: Read a comment\n"));
fprintf(stderr, _("%s: Read a comment\n"), "parse_rcfile()");
#endif
continue; /* Skip past commented lines */
}
@@ -483,8 +518,8 @@ void parse_rcfile(FILE *rcstream)
for (i = 0; rcopts[i].name != NULL; i++) {
if (!strcasecmp(option, rcopts[i].name)) {
#ifdef DEBUG
fprintf(stderr, _("parse_rcfile: Parsing option %s\n"),
rcopts[i].name);
fprintf(stderr, _("%s: Parsing option %s\n"),
"parse_rcfile()", rcopts[i].name);
#endif
if (set == 1) {
if (!strcasecmp(rcopts[i].name, "tabsize")
@@ -587,6 +622,7 @@ void do_rcfile(void)
FILE *rcstream;
const struct passwd *userage;
uid_t euid = geteuid();
char *homenv = getenv("HOME");
#ifdef SYSCONFDIR
assert(sizeof(SYSCONFDIR) == strlen(SYSCONFDIR) + 1);
@@ -600,20 +636,27 @@ void do_rcfile(void)
}
#endif
/* Determine home directory using getpwent(), don't rely on $HOME */
do {
userage = getpwent();
} while (userage != NULL && userage->pw_uid != euid);
endpwent();
lineno = 0;
if (userage == NULL) {
rcfile_error(_("I can't find my home directory! Wah!"));
SET(NO_RCFILE);
/* Rely on $HOME, fall back on getpwuid() */
if (homenv != NULL) {
nanorc = nrealloc(nanorc, strlen(homenv) + 10);
sprintf(nanorc, "%s/.nanorc", homenv);
} else {
nanorc = nrealloc(nanorc, strlen(userage->pw_dir) + 9);
sprintf(nanorc, "%s/.nanorc", userage->pw_dir);
userage = getpwuid(euid);
endpwent();
if (userage == NULL) {
rcfile_error(_("I can't find my home directory! Wah!"));
SET(NO_RCFILE);
} else {
nanorc = nrealloc(nanorc, strlen(userage->pw_dir) + 9);
sprintf(nanorc, "%s/.nanorc", userage->pw_dir);
}
}
if (!ISSET(NO_RCFILE)) {
#if defined(DISABLE_ROOTWRAP) && !defined(DISABLE_WRAPPING)
/* If we've already read $SYSCONFDIR/nanorc (if it's there), we're
@@ -633,6 +676,7 @@ void do_rcfile(void)
fclose(rcstream);
}
}
lineno = 0;
free(nanorc);
#ifdef ENABLE_COLOR

149
search.c
View File

@@ -34,10 +34,15 @@
/* Regular expression helper functions */
#ifdef HAVE_REGEX_H
void regexp_init(const char *regexp)
int regexp_init(const char *regexp)
{
regcomp(&search_regexp, regexp, (ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE) | REG_EXTENDED);
/* Hmm, perhaps we should check for whether regcomp returns successfully */
if (regcomp(&search_regexp, regexp, (ISSET(CASE_SENSITIVE) ? 0 : REG_ICASE)
| REG_EXTENDED) != 0)
return 0;
SET(REGEXP_COMPILED);
return 1;
}
void regexp_cleanup(void)
@@ -62,7 +67,6 @@ void not_found_msg(const char *str)
void search_abort(void)
{
UNSET(KEEP_CUTBUFFER);
display_main_list();
wrefresh(bottomwin);
if (ISSET(MARK_ISSET))
@@ -97,6 +101,9 @@ int search_init(int replacing)
int i = 0;
char *buf;
static char *backupstring = NULL;
#ifdef HAVE_REGEX_H
const char *regex_error = _("Invalid regex \"%s\"");
#endif /* HAVE_REGEX_H */
search_init_globals();
@@ -159,13 +166,28 @@ int search_init(int replacing)
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
/* If answer is "", use last_search! */
regexp_init(last_search);
if (regexp_init(last_search) == 0) {
statusbar(regex_error, last_search);
reset_cursor();
free(backupstring);
backupstring = NULL;
return -3;
}
#endif
break;
case 0: /* They entered something new */
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
regexp_init(answer);
if (regexp_init(answer) == 0) {
statusbar(regex_error, answer);
reset_cursor();
free(backupstring);
backupstring = NULL;
#ifndef NANO_SMALL
search_history.current = search_history.next;
#endif
return -3;
}
#endif
free(backupstring);
backupstring = NULL;
@@ -270,10 +292,8 @@ filestruct *findnextstr(int quiet, int bracket_mode,
return NULL;
fileptr = fileage;
search_offscreen = 1;
if (!quiet) {
if (!quiet)
statusbar(_("Search Wrapped"));
SET(DISABLE_CURPOS);
}
}
/* Original start line reached */
@@ -324,10 +344,8 @@ filestruct *findnextstr(int quiet, int bracket_mode,
return NULL;
fileptr = filebot;
search_offscreen = 1;
if (!quiet) {
if (!quiet)
statusbar(_("Search Wrapped"));
SET(DISABLE_CURPOS);
}
}
/* Original start line reached */
if (fileptr == begin)
@@ -405,7 +423,7 @@ int do_search(void)
statusbar(_("This is the only occurrence"));
else if (current->lineno <= edittop->lineno
|| current->lineno >= editbot->lineno)
edit_update(current, current_x);
edit_update(current, CENTER);
search_abort();
@@ -445,10 +463,10 @@ int replace_regexp(char *string, int create_flag)
c++;
new_size++;
} else {
int num = (int)(*(c + 1) - '0');
int num = (int) *(c + 1) - (int) '0';
if (num >= 1 && num <= 9) {
int i = regmatches[num].rm_so;
int i = regmatches[num].rm_eo - regmatches[num].rm_so;
if (num > search_regexp.re_nsub) {
/* Ugh, they specified a subexpression that doesn't
@@ -460,12 +478,15 @@ int replace_regexp(char *string, int create_flag)
c += 2;
/* But add the length of the subexpression to new_size */
new_size += regmatches[num].rm_eo - regmatches[num].rm_so;
new_size += i;
/* And if create_flag is set, append the result of the
* subexpression match to the new line */
while (create_flag && i < regmatches[num].rm_eo)
*string++ = *(current->data + i++);
if (create_flag) {
strncpy(string, current->data + current_x +
regmatches[num].rm_so, i);
string += i;
}
} else {
if (create_flag)
@@ -572,7 +593,7 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
if (current->lineno <= edittop->lineno
|| current->lineno >= editbot->lineno)
edit_update(current, current_x);
edit_update(current, CENTER);
/* No more matches. Done! */
if (fileptr == NULL)
@@ -597,6 +618,9 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
}
if (*i > 0 || replaceall) { /* Yes, replace it!!!! */
long length_change;
size_t match_len;
if (*i == 2)
replaceall = 1;
@@ -607,38 +631,43 @@ int do_replace_loop(const char *prevanswer, const filestruct *begin,
return 0;
}
length_change = strlen(copy) - strlen(current->data);
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP))
match_len = regmatches[0].rm_eo - regmatches[0].rm_so;
else
#endif
match_len = strlen(prevanswer);
#ifndef NANO_SMALL
if (current == mark_beginbuf && mark_beginx > current_x) {
if (mark_beginx < current_x + match_len)
mark_beginx = current_x;
else
mark_beginx += length_change;
}
#endif
assert(0 <= match_len + length_change);
if (current == begin && current_x <= *beginx) {
if (*beginx < current_x + match_len)
*beginx = current_x + match_len;
*beginx += length_change;
}
/* Set the cursor at the last character of the replacement
* text, so searching will resume after the replacement text.
* Note that current_x might be set to -1 here. */
#ifndef NANO_SMALL
if (!ISSET(REVERSE_SEARCH))
#endif
current_x += match_len + length_change - 1;
/* Cleanup */
totsize -= strlen(current->data);
totsize += length_change;
free(current->data);
current->data = copy;
totsize += strlen(current->data);
if (!ISSET(REVERSE_SEARCH)) {
/* Stop bug where we replace a substring of the
replacement text */
current_x += strlen(last_replace) - 1;
/* Adjust the original cursor position - COULD BE IMPROVED */
if (search_last_line) {
*beginx += strlen(last_replace) - strlen(last_search);
/* For strings that cross the search start/end boundary */
/* Don't go outside of allocated memory */
if (*beginx < 1)
*beginx = 1;
}
} else {
if (current_x > 1)
current_x--;
if (search_last_line) {
*beginx += strlen(last_replace) - strlen(last_search);
if (*beginx > strlen(current->data))
*beginx = strlen(current->data);
}
}
edit_refresh();
set_modified();
@@ -728,31 +757,30 @@ int do_replace(void)
edit_update(current, CENTER);
if (numreplaced >= 0)
statusbar(__("Replaced %d occurrence", "Replaced %d occurrences",
statusbar(P_("Replaced %d occurrence", "Replaced %d occurrences",
numreplaced), numreplaced);
else
not_found_msg(prevanswer);
free(prevanswer);
replace_abort();
return 1;
}
void goto_abort(void)
{
UNSET(KEEP_CUTBUFFER);
display_main_list();
}
int do_gotoline(int line, int save_pos)
{
if (line <= 0) { /* Ask for it */
if (statusq(0, goto_list, (line ? answer : ""),
int st = statusq(FALSE, goto_list, line != 0 ? answer : "",
#ifndef NANO_SMALL
0,
NULL,
#endif
_("Enter line number"))) {
_("Enter line number"));
/* Cancel, or Enter with blank string. */
if (st == -1 || st == -2)
statusbar(_("Aborted"));
goto_abort();
if (st != 0) {
display_main_list();
return 0;
}
@@ -761,7 +789,7 @@ int do_gotoline(int line, int save_pos)
/* Bounds check */
if (line <= 0) {
statusbar(_("Come on, be reasonable"));
goto_abort();
display_main_list();
return 0;
}
}
@@ -778,7 +806,7 @@ int do_gotoline(int line, int save_pos)
else
edit_update(current, CENTER);
placewewant = 0;
goto_abort();
display_main_list();
return 1;
}
@@ -874,6 +902,7 @@ int do_find_bracket(void)
statusbar(_("No matching bracket"));
current_x = current_x_save;
current = current_save;
update_line(current, current_x);
break;
}
}

78
utils.c
View File

@@ -30,6 +30,18 @@
#include "proto.h"
#include "nano.h"
#ifdef BROKEN_REGEXEC
#undef regexec
int regexec_safe(const regex_t *preg, const char *string, size_t nmatch,
regmatch_t pmatch[], int eflags)
{
if (string != NULL && *string != '\0')
return regexec(preg, string, nmatch, pmatch, eflags);
return REG_NOMATCH;
}
#define regexec(preg, string, nmatch, pmatch, eflags) regexec_safe(preg, string, nmatch, pmatch, eflags)
#endif
int is_cntrl_char(int c)
{
return (-128 <= c && c < -96) || (0 <= c && c < 32) ||
@@ -62,7 +74,7 @@ void align(char **strp)
void null_at(char **data, size_t index)
{
assert(data != NULL);
*data = (char *)nrealloc(*data, sizeof(char) * (index + 1));
*data = charealloc(*data, index + 1);
(*data)[index] = '\0';
}
@@ -138,50 +150,58 @@ const char *stristr(const char *haystack, const char *needle)
return NULL;
}
/* If we are searching backwards, we will find the last match
* that starts no later than rev_start. If we are doing a regexp search,
* then line_pos should be 0 if haystack starts at the beginning of a
* line, and positive otherwise. In the regexp case, we fill in the
* global variable regmatches with at most 9 subexpression matches. Also,
* all .rm_so elements are relative to the start of the whole match, so
* regmatches[0].rm_so == 0. */
const char *strstrwrapper(const char *haystack, const char *needle,
const char *rev_start, int line_pos)
{
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
if (!ISSET(REVERSE_SEARCH)) {
if (!regexec(&search_regexp, haystack, 10, regmatches, (line_pos > 0) ? REG_NOTBOL : 0))
return haystack + regmatches[0].rm_so;
}
#ifndef NANO_SMALL
else {
const char *i, *j;
if (ISSET(REVERSE_SEARCH)) {
/* When doing a backwards search, haystack is a whole line. */
if (!regexec(&search_regexp, haystack, 1, regmatches, 0) &&
haystack + regmatches[0].rm_so <= rev_start) {
const char *retval = haystack + regmatches[0].rm_so;
/* do a quick search forward first */
if (!regexec(&search_regexp, haystack, 10, regmatches, 0)) {
/* there's a match somewhere in the line - now search for it backwards, much slower */
for (i = rev_start; i >= haystack; --i) {
if (!regexec(&search_regexp, i, 10, regmatches, (i > haystack) ? REG_NOTBOL : 0)) {
j = i + regmatches[0].rm_so;
if (j <= rev_start)
return j;
}
}
/* Search forward until there is no more match. */
while (!regexec(&search_regexp, retval + 1, 1, regmatches,
REG_NOTBOL) &&
retval + 1 + regmatches[0].rm_so <= rev_start)
retval += 1 + regmatches[0].rm_so;
/* Finally, put the subexpression matches in global
* variable regmatches. The REG_NOTBOL flag doesn't
* matter now. */
regexec(&search_regexp, retval, 10, regmatches, 0);
return retval;
}
} else
#endif /* !NANO_SMALL */
if (!regexec(&search_regexp, haystack, 10, regmatches,
line_pos > 0 ? REG_NOTBOL : 0)) {
const char *retval = haystack + regmatches[0].rm_so;
regexec(&search_regexp, retval, 10, regmatches, 0);
return retval;
}
#endif
return 0;
return NULL;
}
#endif
#endif /* HAVE_REGEX_H */
#ifndef NANO_SMALL
if (ISSET(CASE_SENSITIVE)) {
if (ISSET(REVERSE_SEARCH))
return revstrstr(haystack, needle, rev_start);
else
return strstr(haystack, needle);
} else {
if (ISSET(REVERSE_SEARCH))
return revstristr(haystack, needle, rev_start);
else
return strstr(haystack, needle);
} else if (ISSET(REVERSE_SEARCH))
return revstristr(haystack, needle, rev_start);
#endif
return stristr(haystack, needle);
#ifndef NANO_SMALL
}
#endif
return stristr(haystack, needle);
}
/* This is a wrapper for the perror function. The wrapper takes care of

352
winio.c
View File

@@ -218,10 +218,10 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
it would be past the end of the string as it is. Otherwise,
leave it alone. This is so the cursor position stays at the same
place if a prompt-changing toggle is pressed. */
if (x == -1 || x > xend)
if (x == -1 || x > xend || resetstatuspos)
x = xend;
answer = (char *)nrealloc(answer, xend + 1);
answer = charealloc(answer, xend + 1);
if (xend > 0)
strcpy(answer, def);
else
@@ -256,10 +256,6 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
}
#endif
/* We canceled putting in an answer; reset x */
if (kbinput == NANO_CANCEL_KEY)
x = -1;
return t->val;
}
}
@@ -362,6 +358,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
case KEY_UP:
case NANO_UP_KEY:
#ifndef NANO_SMALL
do_upkey:
if (history_list != NULL) {
/* If there's no previous temp holder, or if we already
@@ -387,6 +384,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
case KEY_DOWN:
case NANO_DOWN_KEY:
#ifndef NANO_SMALL
do_downkey:
if (history_list != NULL) {
/* get newer search from the history list */
if ((history = get_history_newer(history_list)) != NULL) {
@@ -425,6 +423,18 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
break;
case '[':
switch (kbinput = wgetch(edit)) {
case 'A':
#ifndef NANO_SMALL
goto do_upkey;
#else
break;
#endif
case 'B':
#ifndef NANO_SMALL
goto do_downkey;
#else
break;
#endif
case 'C':
if (x < xend)
x++;
@@ -564,7 +574,7 @@ void titlebar(const char *path)
void bottombars(const shortcut *s)
{
int i, j, numcols;
char keystr[4];
char keystr[9];
int slen;
if (ISSET(NO_HELP))
@@ -591,7 +601,7 @@ void bottombars(const shortcut *s)
strcpy(keystr, "^ ");
#ifndef NANO_SMALL
else if (s->val == KEY_UP)
strcpy(keystr, _("Up"));
strncpy(keystr, _("Up"), 8);
#endif /* NANO_SMALL */
else if (s->val > 0) {
if (s->val < 64)
@@ -708,12 +718,9 @@ void edit_add(const filestruct *fileptr, int yval, int start
int paintlen;
/* number of chars to paint on this line. There are COLS
* characters on a whole line. */
regex_t start_regexp; /* Compiled search regexp */
regmatch_t startmatch; /* match position for start_regexp*/
regmatch_t endmatch; /* match position for end_regexp*/
regcomp(&start_regexp, tmpcolor->start, REG_EXTENDED);
if (tmpcolor->bright)
wattron(edit, A_BOLD);
wattron(edit, COLOR_PAIR(tmpcolor->pairnum));
@@ -734,7 +741,7 @@ void edit_add(const filestruct *fileptr, int yval, int start
* match the beginning-of-line character unless
* k == 0. If regexec returns nonzero, there are no
* more matches in the line. */
if (regexec(&start_regexp, &fileptr->data[k], 1,
if (regexec(&tmpcolor->start, &fileptr->data[k], 1,
&startmatch, k == 0 ? 0 : REG_NOTBOL))
break;
/* Translate the match to the beginning of the line. */
@@ -771,7 +778,6 @@ void edit_add(const filestruct *fileptr, int yval, int start
* after start_line matching the end. If that line is not
* before fileptr, then paint the beginning of this line. */
regex_t end_regexp; /* Compiled search regexp */
const filestruct *start_line = fileptr->prev;
/* the first line before fileptr matching start*/
regoff_t start_col;
@@ -781,14 +787,12 @@ void edit_add(const filestruct *fileptr, int yval, int start
/* Used in step 2. Have we looked for an end on
* lines after fileptr? */
regcomp(&end_regexp, tmpcolor->end, REG_EXTENDED);
while (start_line != NULL &&
regexec(&start_regexp, start_line->data, 1,
regexec(&tmpcolor->start, start_line->data, 1,
&startmatch, 0)) {
/* If there is an end on this line, there is no need
* to look for starts on earlier lines. */
if (!regexec(&end_regexp, start_line->data, 1,
if (!regexec(tmpcolor->end, start_line->data, 1,
&endmatch, 0))
goto step_two;
start_line = start_line->prev;
@@ -804,14 +808,14 @@ void edit_add(const filestruct *fileptr, int yval, int start
while (1) {
start_col += startmatch.rm_so;
startmatch.rm_eo -= startmatch.rm_so;
if (regexec(&end_regexp,
if (regexec(tmpcolor->end,
start_line->data + start_col + startmatch.rm_eo,
1, &endmatch,
start_col + startmatch.rm_eo == 0 ? 0 : REG_NOTBOL))
/* No end found after this start */
break;
start_col++;
if (regexec(&start_regexp,
if (regexec(&tmpcolor->start,
start_line->data + start_col, 1, &startmatch,
REG_NOTBOL))
/* No later start on this line. */
@@ -824,8 +828,8 @@ void edit_add(const filestruct *fileptr, int yval, int start
* fileptr and after the start. Is there an end after
* the start at all? We don't paint unterminated starts. */
end_line = fileptr;
while (end_line != NULL && regexec(&end_regexp, end_line->data,
1, &endmatch, 0))
while (end_line != NULL &&
regexec(tmpcolor->end, end_line->data, 1, &endmatch, 0))
end_line = end_line->next;
/* No end found, or it is too early. */
@@ -846,11 +850,10 @@ void edit_add(const filestruct *fileptr, int yval, int start
if (paintlen == COLS)
goto skip_step_two;
step_two: /* Second step, we look for starts on this line. */
start_col = 0;
while (start_col < start + COLS) {
if (regexec(&start_regexp, fileptr->data + start_col, 1,
if (regexec(&tmpcolor->start, fileptr->data + start_col, 1,
&startmatch, start_col == 0 ? 0 : REG_NOTBOL)
|| start_col + startmatch.rm_so >= start + COLS)
/* No more starts on this line. */
@@ -865,7 +868,7 @@ void edit_add(const filestruct *fileptr, int yval, int start
x_start = 0;
startmatch.rm_so = start;
}
if (!regexec(&end_regexp, fileptr->data + startmatch.rm_eo,
if (!regexec(tmpcolor->end, fileptr->data + startmatch.rm_eo,
1, &endmatch,
startmatch.rm_eo == 0 ? 0 : REG_NOTBOL)) {
/* Translate the end match to be relative to the
@@ -891,7 +894,7 @@ void edit_add(const filestruct *fileptr, int yval, int start
/* There is no end on this line. But we haven't
* yet looked for one on later lines. */
end_line = fileptr->next;
while (end_line != NULL && regexec(&end_regexp,
while (end_line != NULL && regexec(tmpcolor->end,
end_line->data, 1, &endmatch, 0))
end_line = end_line->next;
if (end_line != NULL) {
@@ -906,12 +909,9 @@ void edit_add(const filestruct *fileptr, int yval, int start
}
start_col = startmatch.rm_so + 1;
} /* while start_col < start + COLS */
skip_step_two:
regfree(&end_regexp);
} /* if (tmp_color->end != NULL) */
regfree(&start_regexp);
skip_step_two:
wattroff(edit, A_BOLD);
wattroff(edit, COLOR_PAIR(tmpcolor->pairnum));
} /* for tmpcolor in colorstrings */
@@ -1072,7 +1072,7 @@ void update_cursor(void)
}
#ifdef DEBUG
fprintf(stderr, _("current->data = \"%s\"\n"), current->data);
fprintf(stderr, "current->data = \"%s\"\n", current->data);
#endif
}
@@ -1093,7 +1093,8 @@ void edit_refresh(void)
if (edittop == NULL)
edittop = current;
if (current->lineno >= edittop->lineno + editwinrows)
if (current->lineno < edittop->lineno ||
current->lineno >= edittop->lineno + editwinrows)
/* Note that edit_update() changes edittop so that
* current->lineno = edittop->lineno + editwinrows / 2. Thus
* when it then calls edit_refresh(), there is no danger of
@@ -1192,20 +1193,23 @@ int statusq(int tabs, const shortcut *s, const char *def,
#endif
);
free(foo);
resetstatuspos = 0;
switch (ret) {
case NANO_FIRSTLINE_KEY:
do_first_line();
resetstatuspos = 1;
break;
case NANO_LASTLINE_KEY:
do_last_line();
resetstatuspos = 1;
break;
case NANO_CANCEL_KEY:
ret = -1;
resetstatuspos = 1;
break;
default:
blank_statusbar();
}
blank_statusbar();
#ifdef DEBUG
fprintf(stderr, _("I got \"%s\"\n"), answer);
@@ -1230,14 +1234,11 @@ int statusq(int tabs, const shortcut *s, const char *def,
int do_yesno(int all, int leavecursor, const char *msg, ...)
{
va_list ap;
char foo[133];
int kbinput, ok = -1, i;
char *foo;
int ok = -2;
const char *yesstr; /* String of yes characters accepted */
const char *nostr; /* Same for no */
const char *allstr; /* And all, surprise! */
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
MEVENT mevent;
#endif
/* Yes, no and all are strings of any length. Each string consists of
all characters accepted as a valid character for that value.
@@ -1246,112 +1247,89 @@ int do_yesno(int all, int leavecursor, const char *msg, ...)
nostr = _("Nn");
allstr = _("Aa");
/* Write the bottom of the screen */
blank_bottomwin();
/* Remove gettext call for keybindings until we clear the thing up */
if (!ISSET(NO_HELP)) {
char shortstr[3]; /* Temp string for Y, N, A */
wmove(bottomwin, 1, 0);
/* Write the bottom of the screen */
blank_bottombars();
sprintf(shortstr, " %c", yesstr[0]);
wmove(bottomwin, 1, 0);
onekey(shortstr, _("Yes"), 16);
if (all) {
wmove(bottomwin, 1, 16);
shortstr[1] = allstr[0];
onekey(shortstr, _("All"), 16);
}
wmove(bottomwin, 2, 0);
wmove(bottomwin, 2, 0);
shortstr[1] = nostr[0];
onekey(shortstr, _("No"), 16);
wmove(bottomwin, 2, 16);
onekey("^C", _("Cancel"), 16);
}
foo = charalloc(COLS);
va_start(ap, msg);
vsnprintf(foo, 132, msg, ap);
vsnprintf(foo, COLS, msg, ap);
va_end(ap);
foo[COLS - 1] = '\0';
wattron(bottomwin, A_REVERSE);
blank_statusbar();
mvwaddstr(bottomwin, 0, 0, foo);
free(foo);
wattroff(bottomwin, A_REVERSE);
wrefresh(bottomwin);
if (leavecursor == 1)
reset_cursor();
while (ok == -1) {
kbinput = wgetch(edit);
switch (kbinput) {
do {
int kbinput = wgetch(edit);
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
case KEY_MOUSE:
/* Look ma! We get to duplicate lots of code from do_mouse!! */
if (getmouse(&mevent) == ERR)
break;
if (!wenclose(bottomwin, mevent.y, mevent.x) || ISSET(NO_HELP))
break;
mevent.y -= editwinrows + 3;
if (mevent.y < 0)
break;
else {
/* Rather than a bunch of if statements, set up a matrix
of possible return keystrokes based on the x and y
values */
char yesnosquare[2][2];
yesnosquare[0][0] = yesstr[0];
if (all)
yesnosquare[0][1] = allstr[0];
else
yesnosquare[0][1] = '\0';
yesnosquare[1][0] = nostr[0];
yesnosquare[1][1] = NANO_CONTROL_C;
ungetch(yesnosquare[mevent.y][mevent.x / (COLS / 6)]);
}
break;
MEVENT mevent;
#endif
case NANO_CONTROL_C:
ok = -2;
break;
default:
/* Look for the kbinput in the yes, no and (optimally) all str */
for (i = 0; yesstr[i] != 0 && yesstr[i] != kbinput; i++);
if (yesstr[i] != 0) {
ok = 1;
break;
}
if (kbinput == NANO_CONTROL_C)
ok = -1;
#if !defined(DISABLE_MOUSE) && defined(NCURSES_MOUSE_VERSION)
/* Look ma! We get to duplicate lots of code from do_mouse!! */
else if (kbinput == KEY_MOUSE && getmouse(&mevent) != ERR &&
wenclose(bottomwin, mevent.y, mevent.x) &&
!ISSET(NO_HELP) && mevent.x < 32 &&
mevent.y >= editwinrows + 3) {
int x = mevent.x /= 16;
/* Did we click in the first column of shortcuts, or the
second? */
int y = mevent.y - editwinrows - 3;
/* Did we click in the first row of shortcuts? */
for (i = 0; nostr[i] != 0 && nostr[i] != kbinput; i++);
if (nostr[i] != 0) {
ok = 0;
break;
}
assert(0 <= x && x <= 1 && 0 <= y && y <= 1);
/* x = 0 means they clicked Yes or No.
y = 0 means Yes or All. */
ok = -2 * x * y + x - y + 1;
if (all) {
for (i = 0; allstr[i] != 0 && allstr[i] != kbinput; i++);
if (allstr[i] != 0) {
ok = 2;
break;
}
}
if (ok == 2 && !all)
ok = -2;
}
}
#endif
/* Look for the kbinput in the yes, no and (optionally) all str */
else if (strchr(yesstr, kbinput) != NULL)
ok = 1;
else if (strchr(nostr, kbinput) != NULL)
ok = 0;
else if (all && strchr(allstr, kbinput) != NULL)
ok = 2;
} while (ok == -2);
/* Then blank the screen */
/* Then blank the statusbar. */
blank_statusbar_refresh();
if (ok == -2)
return -1;
else
return ok;
return ok;
}
int total_refresh(void)
@@ -1383,10 +1361,19 @@ void statusbar(const char *msg, ...)
int start_x = 0;
size_t foo_len;
va_start(ap, msg);
/* Curses mode is turned off. If we use wmove() now, it will muck up
the terminal settings. So we just use vfprintf(). */
if (curses_ended) {
vfprintf(stderr, msg, ap);
va_end(ap);
return;
}
assert(COLS >= 4);
foo = charalloc(COLS - 3);
va_start(ap, msg);
vsnprintf(foo, COLS - 3, msg, ap);
va_end(ap);
@@ -1410,67 +1397,66 @@ void statusbar(const char *msg, ...)
wrefresh(bottomwin);
if (ISSET(CONSTUPDATE))
statblank = 1;
else
statblank = 25;
SET(DISABLE_CURPOS);
statblank = 26;
}
/*
* If constant is false, the user typed ^C so we unconditionally display
* the cursor position. Otherwise, we display it only if the character
* position changed, and DISABLE_CURPOS is not set.
*
* If constant and DISABLE_CURPOS is set, we unset it and update old_i and
* old_totsize. That way, we leave the current statusbar alone, but next
* time we will display. */
int do_cursorpos(int constant)
{
filestruct *fileptr;
float linepct = 0.0, bytepct = 0.0, colpct = 0.0;
long i = 0, j = 0;
static long old_i = -1, old_totsize = -1;
const filestruct *fileptr;
unsigned long i = 0;
static unsigned long old_i = 0;
static long old_totsize = -1;
if (current == NULL || fileage == NULL)
return 0;
if (old_i == -1)
old_i = i;
assert(current != NULL && fileage != NULL && totlines != 0);
if (old_totsize == -1)
old_totsize = totsize;
colpct = 100 * (xplustabs() + 1) / (strlenpt(current->data) + 1);
for (fileptr = fileage; fileptr != current && fileptr != NULL;
fileptr = fileptr->next)
for (fileptr = fileage; fileptr != current; fileptr = fileptr->next) {
assert(fileptr != NULL);
i += strlen(fileptr->data) + 1;
if (fileptr == NULL)
return -1;
}
i += current_x;
j = totsize;
if (constant && ISSET(DISABLE_CURPOS)) {
UNSET(DISABLE_CURPOS);
old_i = i;
old_totsize = totsize;
return 0;
}
if (totsize > 0)
bytepct = 100 * i / totsize;
if (totlines > 0)
linepct = 100 * current->lineno / totlines;
#ifdef DEBUG
fprintf(stderr, _("do_cursorpos: linepct = %f, bytepct = %f\n"),
linepct, bytepct);
#endif
/* if constant is zero, display the position on the statusbar
/* if constant is false, display the position on the statusbar
unconditionally; otherwise, only display the position when the
character values have changed */
if (!constant || (old_i != i || old_totsize != totsize)) {
statusbar(_
("line %d/%d (%.0f%%), col %ld/%ld (%.0f%%), char %ld/%ld (%.0f%%)"),
current->lineno, totlines, linepct, xplustabs() + 1,
strlenpt(current->data) + 1, colpct, i, j, bytepct);
if (!constant || old_i != i || old_totsize != totsize) {
unsigned long xpt = xplustabs() + 1;
unsigned long cur_len = strlenpt(current->data) + 1;
int linepct = 100 * current->lineno / totlines;
int colpct = 100 * xpt / cur_len;
int bytepct = totsize == 0 ? 0 : 100 * i / totsize;
statusbar(
_("line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%ld (%d%%)"),
current->lineno, totlines, linepct,
xpt, cur_len, colpct,
i, totsize, bytepct);
UNSET(DISABLE_CURPOS);
}
old_i = i;
old_totsize = totsize;
reset_cursor();
return 1;
return 0;
}
int do_cursorpos_void(void)
@@ -1478,12 +1464,38 @@ int do_cursorpos_void(void)
return do_cursorpos(0);
}
/* Calculate the next line of help_text, starting at ptr. */
int line_len(const char *ptr)
{
int j = 0;
while (*ptr != '\n' && *ptr != '\0' && j < COLS - 5) {
ptr++;
j++;
}
if (j == COLS - 5) {
/* Don't wrap at the first of two spaces following a period. */
if (*ptr == ' ' && *(ptr + 1) == ' ')
j++;
/* Don't print half a word if we've run out of space */
while (*ptr != ' ' && j > 0) {
ptr--;
j--;
}
/* Word longer than COLS - 5 chars just gets broken */
if (j == 0)
j = COLS - 5;
}
assert(j >= 0 && j <= COLS - 4 && (j > 0 || *ptr == '\n'));
return j;
}
/* Our shortcut-list-compliant help function, which is
* better than nothing, and dynamic! */
int do_help(void)
{
#ifndef DISABLE_HELP
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0, kp, kp2;
int i, page = 0, kbinput = 0, no_more = 0, kp, kp2;
int no_help_flag = 0;
const shortcut *oldshortcut;
@@ -1533,19 +1545,15 @@ int do_help(void)
case '5': /* Alt-[-5 = Page Up */
wgetch(edit);
goto do_pageupkey;
break;
case 'V': /* Alt-[-V = Page Up in Hurd Console */
case 'I': /* Alt-[-I = Page Up - FreeBSD Console */
goto do_pageupkey;
break;
case '6': /* Alt-[-6 = Page Down */
wgetch(edit);
goto do_pagedownkey;
break;
case 'U': /* Alt-[-U = Page Down in Hurd Console */
case 'G': /* Alt-[-G = Page Down - FreeBSD Console */
goto do_pagedownkey;
break;
}
break;
}
@@ -1563,7 +1571,7 @@ int do_help(void)
case NANO_PREVPAGE_FKEY:
case KEY_PPAGE:
do_pageupkey:
if (page > 1) {
if (page > 0) {
no_more = 0;
blank_edit();
page--;
@@ -1572,43 +1580,21 @@ int do_help(void)
}
/* Calculate where in the text we should be, based on the page */
for (i = 1; i < page; i++) {
row = 0;
j = 0;
while (row < editwinrows - 2 && *ptr != '\0') {
if (*ptr == '\n' || j == COLS - 5) {
j = 0;
row++;
}
for (i = 1; i < page * (editwinrows - 1); i++) {
ptr += line_len(ptr);
if (*ptr == '\n')
ptr++;
j++;
}
}
i = 0;
j = 0;
while (i < editwinrows && *ptr != '\0') {
const char *end = ptr;
while (*end != '\n' && *end != '\0' && j != COLS - 5) {
end++;
j++;
}
if (j == COLS - 5) {
for (i = 0; i < editwinrows && *ptr != '\0'; i++) {
int j = line_len(ptr);
/* Don't print half a word if we've run out of space */
while (*end != ' ' && *end != '\0') {
end--;
j--;
}
}
mvwaddnstr(edit, i, 0, ptr, j);
j = 0;
i++;
if (*end == '\n')
end++;
ptr = end;
ptr += j;
if (*ptr == '\n')
ptr++;
}
if (*ptr == '\0') {
no_more = 1;
continue;