Compare commits

...

115 Commits

Author SHA1 Message Date
Chris Allegretta
34318edba2 Nano 0.9.99pre2 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@512 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-31 23:22:36 +00:00
Chris Allegretta
90e040455d Update NEWS for upcoming release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@511 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-31 18:01:24 +00:00
Chris Allegretta
4e90c40e72 Fix cursor not on after resize
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@510 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-29 23:40:43 +00:00
Chris Allegretta
08020889d3 Fix for resizing the window in modes other than normal edit mode Changes to handle_sigwinch(), main(). Fixes bug #52 (Rocco)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@509 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-29 23:37:54 +00:00
Chris Allegretta
e434b45148 do_alt_speller and nanogetstr fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@508 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-27 19:25:00 +00:00
Robert Siemborski
221a46e271 updated bugs as discussed on the list
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@507 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-26 16:23:39 +00:00
Chris Allegretta
169ee8498e Fixed Bug #53
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@506 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-26 01:57:32 +00:00
Chris Allegretta
12de5ca7cf Added bug #53
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@505 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-25 22:16:12 +00:00
Chris Allegretta
a711f7e638 username_tab_completion() - Removed redundant conditional (Rocco)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@504 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-23 04:16:31 +00:00
Chris Allegretta
2c2c5f2156 username_tab_completion: rewritten using getpwent
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@503 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-23 03:27:31 +00:00
Chris Allegretta
e5e4d49316 Rocco's groovy fixes to real_dir_from_tilde
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@502 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-23 03:09:15 +00:00
Chris Allegretta
0a06e07831 replace for loop for hline init with memset in init functions
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@501 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-23 02:35:04 +00:00
Chris Allegretta
17276e506e Oops, Rob not Rocco :>
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@500 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-23 01:22:32 +00:00
Chris Allegretta
d4ddd014a3 Oops, center_x and y, not current. Thx Rocco
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@499 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-23 01:17:07 +00:00
Chris Allegretta
ee733e6d4c real_dir_from_tilde() - Rewritten using getpwent (suggected by Adam)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@498 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-22 22:17:08 +00:00
Robert Siemborski
60cd6aa04f totsize fix in do_justify
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@497 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-21 23:23:48 +00:00
Chris Allegretta
7f7ce56e4e Oops, make that usage()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@496 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-21 16:35:49 +00:00
Chris Allegretta
e9a2d03497 version() - Add arg to -T help (Rocco).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@495 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-21 16:08:21 +00:00
Chris Allegretta
9d6f3f3f60 Removed - from version in NEWS and ChangeLog
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@494 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-21 02:35:03 +00:00
Chris Allegretta
f0b26df170 global.c: Don't define toggles global or toggle_init_one if using --tiny
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@493 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-20 22:18:18 +00:00
Chris Allegretta
17dcb7212f Get rid of center_x and center_y, removed redundant free_node, added restore of totsize when unjustifying
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@492 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-20 21:40:07 +00:00
Chris Allegretta
8d9b11a847 username_tab_completion(): - Optimization and removal of useless vars (Rocco).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@491 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-19 04:17:24 +00:00
Chris Allegretta
0fc2b81df8 write_file(): Don't free() realname on write error
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@490 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-18 15:04:20 +00:00
Chris Allegretta
76745fbe5f Back to CVS version
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@489 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-18 04:40:06 +00:00
Chris Allegretta
9faa3f13e2 Nano 0.9.99pre1 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@487 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-18 04:37:09 +00:00
Chris Allegretta
3c10ec016c Added bug #51
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@486 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-17 19:27:55 +00:00
Robert Siemborski
c2eeb4e585 small fix for do_justify totsize calculations
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@485 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-17 03:29:02 +00:00
Chris Allegretta
4058709e0b input_tab(): Added memset() to matchBuf to ensure sanity (Rocco, Adam).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@484 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-16 04:45:38 +00:00
Chris Allegretta
51dd32fb4e Changed null out at end of matchBuf from NULL to 0
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@483 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-16 04:20:08 +00:00
Chris Allegretta
ae4318dab0 Get rid of unneeded call to usage() in main() when calling a flag for a function that hasn't been compiled in (Rocco)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@482 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-16 04:18:26 +00:00
Chris Allegretta
3693944492 main(): Initialized kbinput to get around stupid compiler warning.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@481 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-15 20:26:38 +00:00
Chris Allegretta
4097379a26 Changed 'without NumLock on' to 'with NumLock off', more easy to understand?
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@480 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-15 20:25:24 +00:00
Chris Allegretta
b4c43683a5 input_tab(): - Added null end of matchBuf for sanity (Rocco).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@479 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-15 17:22:27 +00:00
Chris Allegretta
a35ec048d7 files.c:cwd_tab_completion(), input_tab(): Changed bare malloc/calloc calls to nmalloc (found by Rocco).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@478 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-15 02:26:12 +00:00
Chris Allegretta
2be96d00b9 Oops, forgot to credit Rocco in one place
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@477 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-14 05:22:43 +00:00
Chris Allegretta
e61e830010 Rocco's source code cleanups and #defines for magic values in global_init(). Added die_too_small() function
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@476 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-14 05:18:27 +00:00
Chris Allegretta
201d9bf467 Added print_numlock_warning(), code to figure out when numlock makes the keypad go bad.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@475 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-14 03:17:53 +00:00
Chris Allegretta
1748cd1d0f Added function ABCD(), better support for default settings
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@474 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-13 17:22:54 +00:00
Chris Allegretta
d9742c69c0 fi.po updates by Pauli Virtanen
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@473 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-12 15:51:53 +00:00
Rocco Corsi
af5c302b48 Move #ifndef cleanups. Some HELP and SPELLER #ifndef additions.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@472 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-12 07:51:05 +00:00
Chris Allegretta
4ee0b41b41 Moved ChangeLog entries for configure.in to configure.in section
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@471 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-11 15:11:00 +00:00
Chris Allegretta
cd6f12d53e Moved code to define all disabled when --tiny is used from nano.h to configure.in
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@470 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-11 15:08:06 +00:00
Rocco Corsi
06aca1cc9e Rolled back DISABLE_TABCOMP and NANO_SMALL changes from earlier today
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@469 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-11 05:30:31 +00:00
Chris Allegretta
a4d6d1df37 Add check for tiny option in #ifdefs for DISABLE_TABCOMP code
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@468 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-10 23:44:10 +00:00
Chris Allegretta
7db63a5b65 Change Linux to GNU/Linux in the faq
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@467 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-10 22:05:40 +00:00
Chris Allegretta
2c4feca17f faq.html: Added section 3.6, reducing binary size
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@466 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-09 17:40:56 +00:00
Chris Allegretta
bbebec6871 configure.in: - Fix for _use_keypad check breaking slang support (Christian Weisgerber)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@465 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-09 00:37:32 +00:00
Chris Allegretta
8eac3b5069 do_browser() - added space and - keys for page down and up
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@464 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-08 21:14:04 +00:00
Chris Allegretta
bf69261597 real_dir_from_tilde(): ops, fix case where buf =~, silly crash
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@463 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-08 16:59:19 +00:00
Chris Allegretta
7e08082ffe Back to CVS ver
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@462 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-08 02:31:03 +00:00
Chris Allegretta
4ca160f784 0.9.25 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@460 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-08 02:29:20 +00:00
Chris Allegretta
155d620a14 Add and fix Bug #51 :-)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@459 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-08 01:50:37 +00:00
Chris Allegretta
2a2e2be0c4 Added and fixed bug #50
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@458 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-08 01:32:58 +00:00
Chris Allegretta
7044489c76 do_help: Do the bottom window the right wrong way if NO_HELP is set
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@457 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-07 23:02:02 +00:00
Chris Allegretta
1699144136 Update docs for upcoming 0.9.25 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@456 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-07 22:06:11 +00:00
Chris Allegretta
19b9e2be94 Oops, restore keypad() call when using PDCURSES
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@455 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-07 07:31:12 +00:00
Chris Allegretta
3f583165c4 Oops, take out my debugging code
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@454 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-07 05:51:28 +00:00
Chris Allegretta
e1ebaf3821 do_writeout() takes an arg now, and mallocstrcpy now gives up if src == dest
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@453 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-07 05:50:36 +00:00
Chris Allegretta
c08f50d9de Back to the drawing board, old keypad code, dont slightly better
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@452 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-06 18:12:43 +00:00
Chris Allegretta
816a165b4b Fixes for dir crash by rocco and exit called on insert file
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@451 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-06 17:43:56 +00:00
Chris Allegretta
150469a646 Added do_browse_from(), called from do_writeout and do_insert, changed mallocstrcpy to *char
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@450 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-05 21:13:14 +00:00
Chris Allegretta
544347c08a Oops, stop freeing stuff we can't necessarily free
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@449 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-05 14:31:52 +00:00
Chris Allegretta
6636dc3181 Changed ENABLE_BROWSER to DISABLE_BROWSER, tiny build now doesn't build browser either
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@448 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-05 05:41:07 +00:00
Chris Allegretta
90661b2def Updated README with snazzy one line desc of nano
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@447 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 23:25:18 +00:00
Chris Allegretta
123e5e66d3 Don't free realname when exiting do_browser in insert_file
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@446 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 22:05:47 +00:00
Chris Allegretta
f4f7e04c5b Work around gnome-terminal, I'm tired of this
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@445 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 16:56:15 +00:00
Jordi Mallach
75ef81bc42 Browser Spanish translations
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@444 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 16:48:59 +00:00
Chris Allegretta
ba8edea860 Accept s and S silently to selected a file/dir
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@443 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 05:22:46 +00:00
Chris Allegretta
b0f5282de2 Fix segfault when width == 0
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@442 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 05:20:23 +00:00
Chris Allegretta
fe41584102 Make functions return themselves when do_browser() aborts
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@441 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 05:08:37 +00:00
Chris Allegretta
0e9d3c6c28 Commented file browser code
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@440 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 04:59:17 +00:00
Chris Allegretta
6e82741931 Added fkey equivs to browser
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@439 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 04:41:08 +00:00
Chris Allegretta
f0999a18f0 use lstat instead of stat in filestat, so we can check for if the file is a symlink in the browser
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@438 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 02:49:56 +00:00
Chris Allegretta
63c8ab94fb Tadaa. Keypad issue fixed. It was the stupid timeout(0) call. UGH
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@437 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-04 02:33:52 +00:00
Chris Allegretta
85b444137b Added --enable-browser to version()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@436 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-03 20:13:28 +00:00
Chris Allegretta
425a266a92 Some better page up/down fixes, added keypad_on() call for now
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@435 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-03 15:09:27 +00:00
Chris Allegretta
f4b9601c1b First try at browser
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@434 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-03 07:11:47 +00:00
Chris Allegretta
827b15fdc0 credits spelling fix
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@433 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-03 02:09:04 +00:00
Rocco Corsi
8b6cccc5cc TAB-TAB completion segfaulting with more than 2048 files fixed. (Rocco)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@432 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2001-01-02 06:21:07 +00:00
Chris Allegretta
ee289d7a2b Don't skip . and .. in cwd_tab_completion()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@431 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-27 16:12:47 +00:00
Chris Allegretta
1e6fb08d15 Finally got rid of TIP from README and updated the Overview which people always quote from
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@430 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-27 15:46:22 +00:00
Chris Allegretta
66795ecbe1 do_cursorpos cleanups
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@429 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-27 04:47:28 +00:00
Chris Allegretta
d55655f23a Reordered --help usage listing by alpha
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@428 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-27 03:36:47 +00:00
Jordi Mallach
e34f96dec2 Add request for backup saves.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@427 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-20 01:06:39 +00:00
Jordi Mallach
5b89a14514 Added configure and Makefile.in. Yell at me :)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@426 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-19 23:01:24 +00:00
Jordi Mallach
56e6d72282 Corrected some typos and small errors in the faq.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@425 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-19 22:59:55 +00:00
Jordi Mallach
79ea7dd883 Corrected some typos and small errors.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@424 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-19 22:58:00 +00:00
Chris Allegretta
e47e4edf7f Back to CVS version
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@423 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-19 03:01:00 +00:00
Chris Allegretta
c7ccb873f1 nano 0.9.24 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@421 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-19 02:59:43 +00:00
Chris Allegretta
66149e7aee Update docs for .24 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@420 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-19 02:51:06 +00:00
Chris Allegretta
07b9c2b90c Give the read file error segfault a bug # in BUGS
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@419 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 20:18:37 +00:00
Chris Allegretta
651216388c Fix lots of compiler warnings
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@418 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 07:05:27 +00:00
Chris Allegretta
b7d00efd6d Added --disable-help string to version()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@417 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 05:36:51 +00:00
Chris Allegretta
d1627cffd0 Fix help menu keypad issues
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@416 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 05:03:16 +00:00
Chris Allegretta
7492cecc27 main(): - Added --view option to getopt_long()call . Bug discovered by Rocco Corsi.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@415 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 04:55:21 +00:00
Chris Allegretta
affeda817e do_toggle(): - Added fix_editbot() call to fix improper redisplay of edit window when using nohelp toggle (bug discovered by Rocco Corsi).
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@414 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 04:03:48 +00:00
Chris Allegretta
92325e74b9 Oops, credit Rocco
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@413 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 03:44:22 +00:00
Chris Allegretta
220ba692e6 help_init(): - Fix off by one error that was making ^G help in normal mode and ^_ in pico mode not be displayed in the help.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@412 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 03:40:00 +00:00
Chris Allegretta
51b3eec536 Added -b, -e and -f compatibility flags, updated man pages, added Alt-Alt-x functionality
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@411 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 02:23:50 +00:00
Chris Allegretta
3a7c0bee6b Fix segfault when read_file encounters an error opening the file
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@410 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-18 01:09:07 +00:00
Chris Allegretta
1a6e904583 Rid nano of PATH_MAX\!
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@409 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-14 13:56:28 +00:00
Chris Allegretta
b04a98dc86 Use MAX_PATH in write_file strncpy (for now) instead of 132
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@408 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-14 13:24:08 +00:00
Chris Allegretta
7960dcf919 Removed unneeded st2 var, don't open device files in open_file()
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@407 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-13 15:01:29 +00:00
Chris Allegretta
544d9b0210 Update comment in write_file
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@406 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-11 02:47:13 +00:00
Chris Allegretta
1cd506612d Remove useless fstat call
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@405 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-11 02:47:12 +00:00
Chris Allegretta
3bc8c72c8b Added --disable-help, moved hold pointer declaration
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@404 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-10 17:03:25 +00:00
Chris Allegretta
c130297a79 More totsize :P
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@403 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-10 06:07:01 +00:00
Chris Allegretta
321590a59d More totsize fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@402 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-10 06:03:40 +00:00
Chris Allegretta
e51c95fa7b uncutting at filebot magic line fix and new_magicline totsize increment
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@401 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-10 05:54:27 +00:00
Chris Allegretta
5146fec04c Cut and renumber fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@400 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-10 05:44:02 +00:00
Chris Allegretta
ef12311948 Update ChangeLog
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@399 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-10 00:04:13 +00:00
Chris Allegretta
f597777323 Remove the append check we just added :>
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@398 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-09 23:58:41 +00:00
Chris Allegretta
d62614cbc4 Let's just copy joe word for word and just change the name to nano!!!!
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@397 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-09 23:37:00 +00:00
Chris Allegretta
33084397dd More fun security crap
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@396 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-09 22:50:38 +00:00
Chris Allegretta
38552ee7a8 Back to CVS version
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@395 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2000-12-09 03:35:49 +00:00
28 changed files with 3155 additions and 1933 deletions

View File

@@ -1,8 +1,10 @@
Makefile
Makefile.in
confdefs.h
config.cache
config.h
config.log
config.status
configure
nano
stamp-h

23
BUGS
View File

@@ -1,3 +1,6 @@
- Marked cutting sometimes leaves a newline in the file unintelligently,
such as when all of a line is selected but the mark doesn't proceed to
the new line. (8) [FIXED/IRRELEVANT]
- Certains are not lined up properly when there are tabs in them at
certain col values. (9) [FIXED]
- edit_refresh() and update_line() do not handle selecting text when the
@@ -49,6 +52,7 @@
[FIXED]
- Using nano -t, user can not exit until a filename is given via ^O. (30)
[FIXED]
- totsize problems still abound in do_justify (33) [FIXED]
- Using -k cut text is not pasted properly. (34) [FIXED].
- Using -k pasted text is not updated properly if it goes beyond editbot. (35)
[FIXED]
@@ -76,12 +80,21 @@
- When typing in a string in serahc or replace and hitting CASE_SENSITVE
or the other search string, the current string edit is blown away in
favor of the last stored search (47) [FIXED]
- If nano fails to open a file when it starts up,doing almost anything
causes a segfault (discovered by Ben Roberts) (48). [FIXED]
- In certain terminals, nano would not work properly with keypad().
Turned out to be the silly timeout(0) call which is completely
unneeded anyway. (49) [FIXED]
- With less than a page of text, doing a page down will move the
current line to the top of the screen, which it shouldn't do. (50)
[FIXED]
- with PDCURSES, running meta-X turns off the keypad. (51) [FIXED]
- Resizing the window completely screws up the display if in any other
mode than normal editing (help screen, search and replace, file
browser..) (52) [FIXED]
- Alt speller argument (-s, --speller) does not take a string argument of
more than one word. (53) [FIXED].
** Open BUGS **
- Marked cutting sometimes leaves a newline in the file unintelligently,
such as when all of a line is selected but the mark doesn't proceed to
the new line. (8) { Is this an issue? compare to pico 3.5 }
- totsize problems still abound in do_justify (33).
$Id$

218
ChangeLog
View File

@@ -1,3 +1,221 @@
nano-0.9.99pre2 - 01/31/2001
General
- Removed center_x and center_y globals. center_y was
completely unused and center_x was only used a few places,
easily replaced with COLS / 2 (oops, not current_x & y (Rob)).
- Deleted free_node, duplicate of delete_node, and changed all
free_node calls to delete_node.
- Fix for resizing the window in modes other than normal edit mode
Changes to handle_sigwinch(), main(). Fixes bug #52 (Rocco).
- files.c:
write_file()
- Don't free() realname on error, if it needs to be free()d later
it will be (fixes crash on successful write after failed write,
discovered by David Sobon).
username_tab_completion()
- Optimization and removal of useless vars (Rocco).
- Rewritten using getpwent (suggested by Rocco).
- Removed redundant conditional (Rocco).
real_dir_from_tilde()
- Rewritten using getpwent (suggested by Adam, much optimized by Rocco).
- global.c:
- Don't define toggles global or toggle_init_one if using --tiny.
- nano.c:
do_justify()
- Added restoration of totsize after unjustify command.
usage()
- Add arg to -T help (Rocco).
global_init(), handle_sigwinch()
- Messy loops replaced with memset calls (Rocco).
do_alt_speller()
- Added code to parse multi-word alt_speller strings.
- Fix initialization before fork() (Rocco).
- proto.h:
- Fix do_credits() proto (oops!)
- winio.c:
nanogetstr()
- Sanity check for x overrunning the string buffer len.
nano 0.9.99pre1 - 01/17/2001
General
- Changed #ifdefs to check for both DISABLE_TABCOMP and
NANO_SMALL, makes tiny option leave out tab completion, which
should be left out in that circumstance. Saves at least 5k.
- Previous change to #ifdefs DISABLE_TABCOMP and NANO_SMALL rolled
back. (Rocco)
- Various #ifdef & #ifndef cleanups. (Rocco)
- Added message for when keypad goes awry. Added code in main and
function print_numlock_warning() to notify user, and added an
apropriate section in the faq to refer to this brokenness.
- Added macros in nano.h for magic values that might be unclear in
nano.c:global_init(). (Rocco)
- configure.in:
- Fix for _use_keypad check breaking slang support (Christian
Weisgerber).
- Changed to automatically define the 5 DISABLE varibles when
NANO_SMALL (enable-tiny) is requested at configure.
- faq.html:
- Added some info on making the binary smaller with the configure
script.
- Added section on keypad bugginess.
- files.c:
real_dir_from_tilde()
- Oops, fix case where buf ="~", silly crash (bug discovered by
Neil Parks).
do_browser()
- Added space and - keys to do page up and down.
cwd_tab_completion(), input_tab()
- Changed bare malloc/calloc calls to nmalloc (found by Rocco).
- Added memset() to matchBuf to ensure sanity (Rocco, Adam).
- nano.c:
ABCD()
- New function, figures out what kbinput to return given
input common to several switch statements, allows us to
support the default Konsole key settings.
main()
- Alternate speller option no longer valid if DISABLE_SPELLER is
active. (Rocco)
- Removed direct calls to usage() (#else) for -k (cut) or -s (speller)
options when these have been disabled. (Rocco)
- Initialized kbinput to get around stupid compiler warning.
nano_small_msg()
- This function has been removed. All references now call
nano_disabled_msg. (Rocco)
version()
- When NANO_SMALL (enable-tiny) is defined, the 5 main DISABLE
variables (SPELLER, HELP, JUSTIFY, BROWSER, TABCOMP) are not
reported as enabled when Nano is called with -V (--version)
command-line option. (Rocco)
usage()
- Alternate speller option no longer valid if DISABLE_SPELLER is
active. (Rocco)
window_init(), handle_sigwinch()
- Added check for not having enough LINES to do anything useful,
if so die with an error. (Rocco)
die_too_small()
- Function to print the window too small error message, avoids
repeated string defs and globals.
do_justify()
- Small fix for totsize calculation (Rob)
- fi.po:
- Update by Pauli Virtanen.
nano 0.9.25 - 01/07/2001
General -
- New file browser code. New functions in files.c:do_browser(),
helper functions browser_init(), tail(), striponedir(),
filestat(). New shortcut list browser_list. Some new
strings to translate. Added function do_browse_from().
- Keypad code has been changed slightly. Now checks for
_use_keypad flag in window to see whether or not to turn
the keypad() back off when finished (taken from aumix). Moved
to winio.c where it should probably be anyway. New confgure
check for _use_keypad in window sstruct. This will have to do
for now.
- Moved keypad() calls for PDCURSES from main() to window_init()
so the keypad continues to work after a Meta-X, for example.
Fixed bug #51.
- faq.html:
- Fix typos and small mistakes (Jordi).
- files.c:
username_tab_completion()
- Added the (char *) sizeof when allocating memory for the filename
array (Rocco).
cwd_tab_completion()
- removed skipping . and .. when tabulating matches.
- Added the (char *) sizeof when allocating memory for the filename
array (Rocco).
do_writeout()
- Now takes an argument so the string typed in can be retained
when calling the browser.
do_browser()
- Don't decrement longest by the length of path. Fixes crashes
on entering various dirs (Rocco).
- Don't ungetch() the exit key, unneeded, fixes inerting a file
causes exit code.
- move.c:
page_down()
- Don't do an edit_update when there is only one page of text
(fileage == edittop && filebot == editbot). Fixes Bug #50.
- nano.c:
main()
- Reorder the getopt options to be more or less alphabetical
(suggested by Sven Guckes).
- winio.c:
do_cursorpos()
- Optimizations and cleanups by Rocco Corsi.
do_credits()
- Spell Erik Andersen's name right.
titlebar()
- Now takes an arg, needed for browser function.
do_help()
- Changed way of temporarily bringing up shortcuts at the
bottom in the help screen (actually works).
- utils.c:
mallocstrcpy()
- Takes char pointers now instead of void (makes debugging a
helluva lot easier)
- Duh, don't do anything if src == dest!
- es.po:
- Updates for file browser (Jordi).
nano 0.9.24 - 12/18/2000
General
- Added --disable-help option, affects acconfig.h, configure(.in),
winio.c:do_help, nano.c:help_init,help_text_init,version.
- Changed filename to no longer use PATH_MAX, so it can work on the
HURD. Changes in files.c:write_file(), new function
nano.c:clear_filename(), many changed in main(), a few other
places. Please test this!
- Added -b, -e, and -f flags, which we ignore as nano provides
their functionality already.
- cut.c:
do_uncut_text()
- Fix renumbering bug when uncutting marked text at filebot.
- Fix screen not being displayed when we are uncutting marked
text at editbot (Bug discovered by Ken Tyler).
- Fix magic line not getting created when (you guessed it)
uncutting marked text at filebot (Ryan Krebs).
- files.c:
read_file()
- If we encounter an error and insert is not set, run new_file().
(bug discovered by Ben Roberts).
write_file()
- Change open call flags, basically copy joe's way of doing it so
a more recent version will actually be included in (un)stable.
- Remove useless fstat call.
open_file()
- Added check for S_ISBLK and S_ISCHR, don't open device files!
- nano.c:
renumber()
- Dont stupidly assign the value of prev->lineno if prev == NULL!
main()
- Added code to check for Alt-Alt (27-27) keystrokes and set the
next keystroke as a control sequence. New variable
modify_control_key. Removed #ifdef _POSIX_VDISABLE check
around Control-S,Q,Z handlers because we need it now for
the Alt-Alt-x code.
- Added --view option to getopt_long()call . Bug discovered
by Rocco Corsi.
help_init()
- Fix off by one error that was making ^G help in normal mode and
^_ in pico mode not be displayed in the help (bug discovered by
Rocco Corsi).
do_toggle()
- Added fix_editbot() call to fix improper redisplay of edit
window when using nohelp toggle (bug discovered by Rocco Corsi).
- nano.1, nano.1.html:
- Updated man page for -b, -e, -f and expanded explanation for -p.
- winio.c
do_help()
- Force keypad on so F-keys and PageUp/Down will work properly.
Added check for NANO_EXIT_FKEY to loop.
- utils.c:
new_magicline()
- Increment totsize!! We decrement it when we've read a file,
everywhere else it should automatically be incremented
nano 0.9.23 - 12/08/2000
General
- Changed --disable-spell to --disable speller. The term is

42
NEWS
View File

@@ -1,3 +1,45 @@
01/31/2001 - Nano 0.9.99pre2 is released. Not surprisingly, all that is
new is bugfixes, bugfixes, bugfixes. There were a few
cleanups in unneeded global variables and duplicate
functions, but most is just fixing. Specifically, there
is now a preliminary (read: needs testing) fix for
resizing the editor in any mode other than normal edit
mode. Other fixes include some more tab completion
segfaults, and an silly segfault that occurred when
successfully writing a file on the 2nd try (i.e. after an
initial write error). Slowly but surely, on toward 1.0 we
travel.
01/17/2001 - Nano 0.9.99pre1 is released. This is the first pre-1.0
release of nano, and is also the first release since the
code freeze for nano 1.0. Don't expect (or request) any
new features between now and nano 1.0, only bugfixes,
optimizations and doc/translation updates. For fixes, a
nasty segfault when trying to insert one's home directory
(~), some checks for the NumLock key making the keypad
go awry, window size sanity checks, many autoconf fixes,
and support for the KDE konsole keypad layout. Have fun.
01/07/2001 - Nano 0.9.25 is the "Just one more feature I swear!" release.
It includes one new feature that Pico has had forever, a
built-in file browser. Since not everyone may want this
option, there is a --disable-browser option to the
configure script as well. Other changes include slightly
different keypad handling, and a bugfix for crashes when
tab completion in certain instances. Have fun and Happy
New Year!
12/18/2000 - Nano 0.9.24 is released. This versions contains the last of
the security fixes for writing files, as well as for a
nasty segfault when nano is unable to open a file for
reading, among other fixes. Nano also now cowardly
refuses to open device files, to stop silly things like
trying to open /dev/zero. New features include being
Able to use Meta-Meta-<key> as Control-<key>, better
HURD support, and some new flags have been added for Pico
compatibility. Upgrading to this version is highly
recommended.
12/08/2000 - Nano 0.9.23 is the "race conditions bite" release. The
main reason for this release is the less-than-optimal
fix for the security issue in nano with following symbolic

32
README
View File

@@ -1,26 +1,18 @@
The nano editor (Nano's ANOther editor) by Chris Allegretta
nano - a GPLed, enhanced clone of the Pico text editor.
Manifesto
Overview
The nano project was started because of a few "problems" with the
wonderfully easy-to-use and friendly Pico text editor.
First and foremost is its license: the Pine suite does not use the
GPL or a GPL-friendly license, and has unclear restrictions on
redistribution. Because of this, Pine and Pico are not included with
many GNU/Linux distributions. Also, other features (like goto line
number or search and replace) were unavailable until recently or
require a command-line flag. Yuck.
Nano is the editor formerly known as TIP (TIP Isn't Pico).
The nano project was started because of three main problems with the
wonderfully easy-to-use and friendly Pico text editor:
- It's license is not the GNU GPL, and hence some Linux
distributions, including Debian (my favorite) don't always
include it/don't include binaries. This is not necessarily a
problem, but an issue nonetheless.
- Until recently, it had no ability to go to a line # from within
the editor. There was the +number command line option, but who wants
to exit a file to go to a specific line number? When I want to go to
a line, since I have to exit anyway, I just call up vi temporarily.
- No search and replace feature. Well, apparently there is a flag
that lets you do a search and replace (-b in newer versions) but,
well, I still dont like it.
nano aims to solve these problems by emulating the functionality of
Pico as closely as possible while adressing the problems above and
perhaps providing other extra functionality.

3
TODO
View File

@@ -20,8 +20,9 @@ Current Version:
For Next Version:
- Undo/Redo key?
- single line scroll up/down?
- Single line scroll up/down?
- Color syntax highlighting? (certainly seems like there's a demand for it.)
- .nanorc ?????
- Backup making (filename~)?
$Id$

View File

@@ -3,6 +3,9 @@
/* Define this if you have the wresize function in your ncurses-type library */
#undef HAVE_WRESIZE
/* Define this if your curses lib has the _use_keypad flag */
#undef HAVE_USEKEYPAD
/* Define this if you have NLS */
#undef ENABLE_NLS
@@ -36,4 +39,8 @@
/* Define this to disable the use(full|less) spelling functions */
#undef DISABLE_SPELLER
/* Define this to disable the ^G help menu */
#undef DISABLE_HELP
/* Define this to disable the built-in (crappy) file browser */
#undef DISABLE_BROWSER

View File

@@ -55,6 +55,9 @@
/* Define this if you have the wresize function in your ncurses-type library */
#undef HAVE_WRESIZE
/* Define this if your curses lib has the _use_keypad flag */
#undef HAVE_USEKEYPAD
/* Define this if you have NLS */
#undef ENABLE_NLS
@@ -88,6 +91,12 @@
/* Define this to disable the use(full|less) spelling functions */
#undef DISABLE_SPELLER
/* Define this to disable the ^G help menu */
#undef DISABLE_HELP
/* Define this to disable the built-in (crappy) file browser */
#undef DISABLE_BROWSER
/* Define if you have the __argz_count function. */
#undef HAVE___ARGZ_COUNT

449
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
# $Id$
dnl Process this file with autoconf to produce a configure script.
AC_INIT(nano.c)
AM_INIT_AUTOMAKE(nano, 0.9.23)
AM_INIT_AUTOMAKE(nano, 0.9.99pre2)
AM_CONFIG_HEADER(config.h:config.h.in)
ALL_LINGUAS="es de fr it id fi"
@@ -19,6 +19,11 @@ AC_ARG_ENABLE(tiny,
(currently disables detailed help and i18n)],
[if test x$enableval = xyes; then
AC_DEFINE(NANO_SMALL) tiny_support=yes
AC_DEFINE(DISABLE_TABCOMP)
AC_DEFINE(DISABLE_SPELLER)
AC_DEFINE(DISABLE_HELP)
AC_DEFINE(DISABLE_JUSTIFY)
AC_DEFINE(DISABLE_BROWSER)
fi])
AC_ARG_ENABLE(extra,
@@ -45,6 +50,18 @@ AC_ARG_ENABLE(speller,
AC_DEFINE(DISABLE_SPELLER)
fi])
AC_ARG_ENABLE(help,
[ --disable-help Disables help function (^G)],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_HELP)
fi])
AC_ARG_ENABLE(browser,
[ --disable-browser Disables mini file browser],
[if test x$enableval != xyes; then
AC_DEFINE(DISABLE_BROWSER)
fi])
AC_MSG_CHECKING(whether to use slang)
CURSES_LIB_NAME=""
AC_ARG_WITH(slang,
@@ -194,7 +211,23 @@ else
fi
AC_CHECK_LIB($CURSES_LIB_NAME, wresize, AC_DEFINE(HAVE_WRESIZE))
if test x$slang_support != xyes; then
AC_CHECK_LIB($CURSES_LIB_NAME, wresize, AC_DEFINE(HAVE_WRESIZE))
# Taken from aumix (can't tell form the variable name?)
AC_CACHE_CHECK(for private member _use_keypad in WINDOW,
aumix_cv_struct_window_usekeypad,
[AC_TRY_COMPILE([#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#else
#include <curses.h>
#endif], [WINDOW w; w._use_keypad;],
aumix_cv_struct_window_usekeypad=yes, aumix_cv_struct_window_usekeypad=no)])
if test $aumix_cv_struct_window_usekeypad = yes; then
AC_DEFINE(HAVE_USEKEYPAD)
fi
fi
dnl Parse any configure options

12
cut.c
View File

@@ -274,6 +274,7 @@ int do_uncut_text(void)
filestruct *tmp = current, *fileptr = current, *newbuf, *newend;
#ifndef NANO_SMALL
char *tmpstr, *tmpstr2;
filestruct *hold = current;
#endif
int i;
@@ -339,8 +340,13 @@ int do_uncut_text(void)
if (tmp != NULL)
tmp->prev = newend;
else
else {
/* Fix the editbot pointer too */
if (editbot == filebot)
editbot = newend;
filebot = newend;
new_magicline();
}
/* Now why don't we update the totsize also */
for (tmp = current->next; tmp != newend; tmp = tmp->next)
@@ -368,7 +374,9 @@ int do_uncut_text(void)
current_x = 0;
placewewant = 0;
}
renumber(current->prev);
/* Renumber from BEFORE where we pasted ;) */
renumber(hold);
dump_buffer(fileage);
dump_buffer(cutbuffer);
set_modified();

View File

@@ -1,5 +1,6 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<title>The nano editor FAQ</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.73 [en] (X11; U; Linux 2.2.16 i586) [Netscape]">
@@ -21,7 +22,7 @@
nano?</a></font>
<br><font color="#330000"><a href="#1.5">1.5. Why the name change from
TIP?</a></font>
<br><font color="#330000"><a href="#1.6">1.6 What is the current version
<br><font color="#330000"><a href="#1.6">1.6. What is the current version
of nano?</a></font>
<br><font color="#330000"><a href="#1.7">1.7. I want to read the man page
without having to download the program!</a></font></blockquote>
@@ -48,7 +49,9 @@ THE HECK DO I DO NOW?</a></font>
<br><font color="#330000"><a href="#3.4">3.4. I get errors about 'bindtextdomain',
'gettext' and/or 'gettextdomain'.&nbsp; What can I do about it?</a></font>
<br><font color="#330000"><a href="#3.5">3.5. Nano should automatically
run strip on the binary when installing it!</a></font></blockquote>
run strip on the binary when installing it!</a></font>
<br><font color="#330000"><a href="#3.6">3.6. How can I make the
executable smaller? This is too bloated!</a></font></blockquote>
<h2>
<font color="#330000"><a href="#4">4. Running</a></font></h2>
@@ -64,8 +67,11 @@ my window.&nbsp;&nbsp; How can I fix that?</a></font>
<br><font color="#330000"><a href="#4.5">4.5. When I type in a
search string, the string I last searched for is already in front of
my cursor! !What happened?!</a></font>
<br><a href="#4.6">4.6 How do I make nano my default editor (in Pine,
mutt, etc.)?</a></blockquote>
<br><font color="#330000"><a href="#4.6">4.6. I get the message "NumLock
glitch detected. Keypad will malfunction with NumLock off." What
gives?</a></font>
<br><font color="#330000"><a href="#4.7">4.7. How do I make nano my
default editor (in Pine, mutt, etc.)?</a></font></blockquote>
<h2>
<font color="#330000"><a href="#5">5. Internationalization</a></font></h2>
@@ -146,7 +152,7 @@ nano?</font></h2>
on a Unix system.&nbsp; The Pico text editor is the portion of the program
one would use to compose his or her mail messages.&nbsp; Many beginners
to Unix flocked to Pico and Pine because of their well organized, easy
to use interfaces.&nbsp; With the proliferation of Linux in the mid to
to use interfaces.&nbsp; With the proliferation of GNU/Linux in the mid to
late 90's, many University students became intimately familiar with the
strengths (and weaknesses) of Pine and Pico.</font>
<p><b><font color="#330000">Then came debian...</font></b>
@@ -181,7 +187,7 @@ renamed to nano because of a namespace conflict with another program called
'tip'.&nbsp; The original 'tip' program "establishes a full duplex terminal
connection to a remote host", 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 Linux distributions (where
there is no 'tip' utility included with most GNU/Linux distributions (where
nano was developed).</font></blockquote>
<h2>
@@ -189,7 +195,7 @@ nano was developed).</font></blockquote>
of nano?</font></h2>
<blockquote><font color="#330000">The current version of nano *should*
be 0.9.23.&nbsp; Of course you should always check the nano hompage to
be 0.9.99pre2.&nbsp; Of course you should always check the nano hompage to
see what the latest and greatest version is.</font></blockquote>
<h2>
@@ -294,7 +300,7 @@ DEB package?</font></h2>
<b>dpkg
-i nano_x.y.z-1.deb</b> if you have a Debian-ish system, where
<b>x.y.z</b>
is the release of nano.&nbsp; There are other programs to install programs,
is the release of nano.&nbsp; There are other programs to install packages,
and if you wish to use those, knock yourself out.</font></blockquote>
<h2>
@@ -310,7 +316,8 @@ try this:</font>
<p><font color="#330000">(again, where x.y.z is the version number in question).&nbsp;
Then you need to run configure with any options you might want (if any).</font>
<p><font color="#330000">The average case is this:</font>
<p><b><font color="#330000">./configure</font></b>
<p><b><font color="#330000">cd nano-x.y.z/</font></b>
<br><b><font color="#330000">./configure</font></b>
<br><b><font color="#330000">make</font></b>
<br><font color="#330000"><b>make install </b>(as root, of course)</font></blockquote>
@@ -340,8 +347,31 @@ run strip on the binary when installing it!</font></h2>
<b>make install-strip</b>. The default make install does not, and will
not, run strip automatically.</font></blockquote>
<hr WIDTH="100%">
<h1>
<h2>
<a NAME="3.6"></a><font color="#330000">
3.6. How can I make the executable smaller? This is too
bloated!</font></h2>
<blockquote><font color="#330000">Actually, there are several parts of the
editor that can be disabled. You can pass arguments to the
<b>configure</b> script that disable certain features. Here's a brief
list:
<pre>
<b>--disable-tabcomp</b> Disables tab completion code for a smaller binary
<b>--disable-justify</b> Disable justify/unjustify function
<b>--disable-speller</b> Disables spell checker function
<b>--disable-help</b> Disables help function (^G)
<b>--disable-browser</b> Disables mini file browser
</pre><br>
There's also the <b>--enable-tiny</b> option which disabled everything
above, as well as some larger chunks of the program (like the marker code
that you use Control-^ to select with). Also, if you know you aren't
going to be using other languages you can use <b>--disable-nls</b> to
disable internationalization and save a few K to a few dozen K depending
on if you have locale support on your system. And finally there's always
good old <b>strip</b> to strip all debugging code and code that exists in
libraries on your system.
</font></blockquote> <hr WIDTH="100%"> <h1>
<a NAME="4"></a><font color="#330000">4. Running</font></h1>
<h2>
@@ -368,8 +398,8 @@ to <a href="mailto:nano@nano-editor.org">nano@nano-editor.org</a>.</font></block
my window.&nbsp;&nbsp; How can I fix that?</font></h2>
<blockquote><font color="#330000">Older versions of nano had this problem,
please upgrade to a newer version (at least 0.9.9 would be great, 0.9.
12 is recommended).</font></blockquote>
please upgrade to a newer version (at least 0.9.9 would be great, 0.9.12
is recommended).</font></blockquote>
<h2>
<a NAME="4.4"></a><font color="#330000">4.4. Why does nano show ^\ and
@@ -396,7 +426,26 @@ Meta-P while in nano (see the ^G help text for more
details).</font></blockquote>
<h2>
<a NAME="4.6"></a>4.6. How do I make nano my default editor (in Pine,
<a NAME="4.6"></a>I get the message "NumLock glitch detected. Keypad
will malfunction with NumLock off." What gives?</h2>
<blockquote>
Nano (actually almost all console editors do) has issues when cycling
the NumLock key in certain X terminals (rxvt, aterm, wterm, etc...). When
you switch NumLock on to off, you put the terminal into an "application
mode" 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.
<br><br>
In a nutshell, if you want to be able to use the keypad with the arrow and
page up/down functionality, you have to exit nano and reset your terminal
(presumably with "reset" or "stty sane" or similar) and then run nano
again with NumLock off. If you know an easier way to restore "normal
mode", please mail <A href="nano@nano-editor.org">nano@nano-editor.org</A>.
<br>&nbsp;</blockquote>
<h2>
<a NAME="4.7"></a>4.7. How do I make nano my default editor (in Pine,
mutt, etc)?</h2>
<blockquote>You need to make nano your $EDITOR.&nbsp; If you want this
@@ -526,7 +575,7 @@ any changes in the past few years in a positive direction.</font></blockquote>
<blockquote><font color="#330000">There are two mailing lists for nano
hosted at <a href="http://www.sourceforge.net">SourceForge</a>, nano-announce
and nano-devel.&nbsp; Nano-announce is a very low traffic list where new
versions of nano are announced (surprise!)&nbsp; Nano-devel is a sometimes
versions of nano are announced (surprise!)&nbsp; Nano-devel is a normally
low, sometimes very high traffic list for dicussing the present and future
development of nano.&nbsp; Here are links to where you can sign up for
a given list:</font><font color="#330000"></font>

640
files.c
View File

@@ -29,6 +29,7 @@
#include <errno.h>
#include <ctype.h>
#include <dirent.h>
#include <pwd.h>
#include "config.h"
#include "proto.h"
@@ -194,6 +195,7 @@ int read_file(int fd, char *filename)
} else if (fileptr->next == NULL) {
filebot = fileptr;
new_magicline();
totsize--;
/* Update the edit buffer */
load_file();
@@ -226,10 +228,18 @@ int open_file(char *filename, int insert, int quiet)
} else if ((fd = open(filename, O_RDONLY)) == -1) {
if (!quiet)
statusbar("%s: %s", strerror(errno), filename);
if (!insert)
new_file();
return -1;
} else { /* File is A-OK */
if (S_ISDIR(fileinfo.st_mode)) {
statusbar(_("File \"%s\" is a directory"), filename);
if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
S_ISBLK(fileinfo.st_mode)) {
if (S_ISDIR(fileinfo.st_mode))
statusbar(_("File \"%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;
@@ -262,6 +272,21 @@ int do_insertfile(void)
realname = mallocstrcpy(realname, answer);
#endif
#ifndef DISABLE_BROWSER
if (i == NANO_TOFILES_KEY) {
char *tmp = do_browse_from(realname);
#ifdef DISABLE_TABCOMP
realname = NULL;
#endif
if (tmp != NULL)
realname = mallocstrcpy(realname, tmp);
else
return do_insertfile();
}
#endif
i = open_file(realname, 1, 0);
free(realname);
@@ -299,22 +324,25 @@ int do_insertfile(void)
int write_file(char *name, int tmp)
{
long size, lineswritten = 0;
char buf[PATH_MAX + 1];
static char *buf = NULL;
filestruct *fileptr;
int fd, mask = 0, realexists, anyexists;
struct stat st, lst, st2;
struct stat st, lst;
static char *realname = NULL;
if (!strcmp(name, "")) {
statusbar(_("Cancelled"));
return -1;
}
titlebar();
titlebar(NULL);
fileptr = fileage;
if (realname != NULL)
free(realname);
if (buf != NULL)
free(buf);
#ifndef DISABLE_TABCOMP
realname = real_dir_from_tilde(name);
#else
@@ -331,55 +359,39 @@ int write_file(char *name, int tmp)
if (tmp && anyexists != -1)
return -1;
/* NOTE: If you change this statement, you MUST CHANGE the if
statement below (that starts "if ((!ISSET(FOLLOW_SYMLINKS)...")
statement below (that says:
if (realexists == -1 || tmp || (!ISSET(FOLLOW_SYMLINKS) &&
S_ISLNK(lst.st_mode))) {
to reflect whether or not to link/unlink/rename the file */
else if (ISSET(FOLLOW_SYMLINKS) || !S_ISLNK(lst.st_mode) || tmp) {
/* Use O_EXCL if tmp == 1, I suppose */
/* Use O_EXCL if tmp == 1. This is now copied from joe, because
wiggy says so *shrug*. */
if (tmp)
fd = open(realname, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
S_IWOTH);
fd = open(realname, O_WRONLY | O_CREAT | O_EXCL, (S_IRUSR|S_IWUSR));
else
fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
S_IWOTH);
fd = open(realname, O_WRONLY | O_CREAT | O_TRUNC, (S_IRUSR|S_IWUSR));
/* First, just give up if we couldn't even open the file */
if (fd == -1) {
if (!tmp && ISSET(TEMP_OPT)) {
UNSET(TEMP_OPT);
return do_writeout(1);
return do_writeout(filename, 1);
}
statusbar(_("Could not open file for writing: %s"),
strerror(errno));
free(realname);
return -1;
}
/* Now we fstat() the file, to make sure it's the same file still!
Thanks to Oliver Friedrichs(?) for this code from securityfocus */
if (fstat(fd, &st2) != 0) {
close(fd);
return -1;
}
}
/* Don't follow symlink. Create new file. */
else {
if (strlen(realname) > (PATH_MAX - 7)) {
statusbar(_("Could not open file: Path length exceeded."));
return -1;
}
memset(buf, 0x00, PATH_MAX + 1);
strcat(buf, realname);
buf = nmalloc(strlen(realname) + 8);
strncpy(buf, realname, strlen(realname)+1);
strcat(buf, ".XXXXXX");
if ((fd = mkstemp(buf)) == -1) {
if (ISSET(TEMP_OPT)) {
UNSET(TEMP_OPT);
return do_writeout(1);
return do_writeout(filename, 1);
}
statusbar(_("Could not open file for writing: %s"),
strerror(errno));
@@ -475,22 +487,23 @@ int write_file(char *name, int tmp)
mask, realname, strerror(errno));
if (!tmp) {
strncpy(filename, realname, 132);
filename = mallocstrcpy(filename, realname);
statusbar(_("Wrote %d lines"), lineswritten);
UNSET(MODIFIED);
titlebar();
titlebar(NULL);
}
return 1;
}
int do_writeout(int exiting)
int do_writeout(char *path, int exiting)
{
int i = 0;
#ifdef NANO_EXTRA
static int did_cred = 0;
#endif
answer = mallocstrcpy(answer, filename);
answer = mallocstrcpy(answer, path);
if ((exiting) && (ISSET(TEMP_OPT))) {
if (filename[0]) {
@@ -512,6 +525,18 @@ int do_writeout(int exiting)
if (i != -1) {
#ifndef DISABLE_BROWSER
if (i == NANO_TOFILES_KEY) {
char *tmp = do_browse_from(answer);
if (tmp != NULL)
answer = mallocstrcpy(answer, tmp);
else
return do_writeout(answer, exiting);
}
#endif
#ifdef DEBUG
fprintf(stderr, _("filename is %s"), answer);
#endif
@@ -547,85 +572,62 @@ int do_writeout(int exiting)
int do_writeout_void(void)
{
return do_writeout(0);
return do_writeout(filename, 0);
}
#ifndef DISABLE_TABCOMP
static char **homedirs;
/* Return a malloc()ed string containing the actual directory, used
* to convert ~user and ~/ notation...
*/
char *real_dir_from_tilde(char *buf)
{
char *dirtmp = NULL, *line = NULL, byte[1], *lineptr;
int fd, i, status, searchctr = 1;
char *dirtmp = NULL, *find_user = NULL;
int i = 1;
struct passwd *userdata;
/* set a default value for dirtmp, in the case user home dir not found */
dirtmp = mallocstrcpy(dirtmp, buf);
if (buf[0] == '~') {
if (buf[1] == '~')
goto abort; /* Handle ~~ without segfaulting =) */
else if (buf[1] == '/') {
if (buf[1] == 0 || buf[1] == '/') {
if (getenv("HOME") != NULL) {
free(dirtmp);
dirtmp = nmalloc(strlen(buf) + 2 + strlen(getenv("HOME")));
sprintf(dirtmp, "%s/%s", getenv("HOME"), &buf[2]);
}
} else if (buf[1] != 0) {
sprintf(dirtmp, "%s%s", getenv("HOME"), &buf[1]);
if ((fd = open("/etc/passwd", O_RDONLY)) == -1)
goto abort;
}
}
else {
/* Figure how how much of of the str we need to compare */
for (searchctr = 1; buf[searchctr] != '/' &&
buf[searchctr] != 0; searchctr++);
for (i = 1; buf[i] != '/' && buf[i] != 0; i++)
;
do {
i = 0;
line = nmalloc(1);
while ((status = read(fd, byte, 1)) != 0
&& byte[0] != '\n') {
find_user = mallocstrcpy(find_user, &buf[1]);
find_user[i - 1] = 0;
line[i] = byte[0];
i++;
line = nrealloc(line, i + 1);
}
line[i] = 0;
for (userdata = getpwent(); userdata != NULL &&
strcmp(userdata->pw_name, find_user);
userdata = getpwent());
if (i == 0)
goto abort;
free(find_user);
line[i] = 0;
lineptr = strtok(line, ":");
if (userdata != NULL) { /* User found */
if (!strncmp(lineptr, &buf[1], searchctr - 1)) {
free(dirtmp);
dirtmp = nmalloc(strlen(buf) + 2 + strlen(userdata->pw_dir));
sprintf(dirtmp, "%s%s", userdata->pw_dir, &buf[i]);
/* Okay, skip to the password portion now */
for (i = 0; i <= 4 && lineptr != NULL; i++)
lineptr = strtok(NULL, ":");
}
if (lineptr == NULL)
goto abort;
/* Else copy the new string into the new buf */
dirtmp = nmalloc(strlen(buf) + 2 + strlen(lineptr));
sprintf(dirtmp, "%s%s", lineptr, &buf[searchctr]);
free(line);
break;
}
free(line);
} while (status != 0);
endpwent();
}
} else
dirtmp = mallocstrcpy(dirtmp, buf);
}
return dirtmp;
abort:
dirtmp = mallocstrcpy(dirtmp, buf);
return dirtmp;
}
/* Tack a slash onto the string we're completing if it's a directory */
@@ -674,79 +676,35 @@ int append_slash_if_dir(char *buf, int *lastWasTab, int *place)
char **username_tab_completion(char *buf, int *num_matches)
{
char **matches = (char **) NULL, *line = NULL, *lineptr;
char *matchline = NULL, *matchdir = NULL;
char **matches = (char **) NULL;
char *matchline = NULL;
struct passwd *userdata;
int fd, i = 0, status = 1;
char byte[1];
*num_matches = 0;
matches = nmalloc(BUFSIZ * sizeof(char *));
if ((fd = open("/etc/passwd", O_RDONLY)) == -1) {
return NULL;
}
if (homedirs != NULL) {
for (i = 0; i < *num_matches; i++)
free(homedirs[i]);
free(homedirs);
homedirs = (char **) NULL;
*num_matches = 0;
}
matches = nmalloc(BUFSIZ);
homedirs = nmalloc(BUFSIZ);
strcat(buf, "*");
do {
i = 0;
line = nmalloc(1);
while ((status = read(fd, byte, 1)) != 0 && byte[0] != '\n') {
line[i] = byte[0];
i++;
line = nrealloc(line, i + 1);
}
while ((userdata = getpwent()) != NULL) {
if (i == 0)
break;
line[i] = 0;
lineptr = strtok(line, ":");
if (check_wildcard_match(line, &buf[1]) == TRUE) {
if (*num_matches == BUFSIZ)
break;
if (check_wildcard_match(userdata->pw_name, &buf[1]) == TRUE) {
/* Cool, found a match. Add it to the list
* This makes a lot more sense to me (Chris) this way...
*/
matchline = nmalloc(strlen(line) + 2);
sprintf(matchline, "~%s", line);
for (i = 0; i <= 4 && lineptr != NULL; i++)
lineptr = strtok(NULL, ":");
if (lineptr == NULL)
break;
matchdir = mallocstrcpy(matchdir, lineptr);
homedirs[*num_matches] = matchdir;
matchline = nmalloc(strlen(userdata->pw_name) + 2);
sprintf(matchline, "~%s", userdata->pw_name);
matches[*num_matches] = matchline;
++*num_matches;
/* If there's no more room, bail out */
if (*num_matches == BUFSIZ)
break;
}
}
endpwent();
free(line);
} while (status != 0);
close(fd);
return matches;
#ifdef DEBUG
fprintf(stderr, "\nin username_tab_completion\n");
#endif
return (matches);
}
@@ -760,14 +718,14 @@ char **cwd_tab_completion(char *buf, int *num_matches)
DIR *dir;
struct dirent *next;
matches = nmalloc(BUFSIZ);
matches = nmalloc(BUFSIZ * sizeof(char *));
/* Stick a wildcard onto the buf, for later use */
strcat(buf, "*");
/* Okie, if there's a / in the buffer, strip out the directory part */
if (strcmp(buf, "") && strstr(buf, "/")) {
dirName = malloc(strlen(buf) + 1);
dirName = nmalloc(strlen(buf) + 1);
tmp = buf + strlen(buf);
while (*tmp != '/' && tmp != buf)
tmp--;
@@ -810,11 +768,6 @@ char **cwd_tab_completion(char *buf, int *num_matches)
}
while ((next = readdir(dir)) != NULL) {
/* Some quick sanity checks */
if ((strcmp(next->d_name, "..") == 0)
|| (strcmp(next->d_name, ".") == 0)) {
continue;
}
#ifdef DEBUG
fprintf(stderr, "Comparing \'%s\'\n", next->d_name);
#endif
@@ -858,7 +811,8 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
/* Make a local copy of the string -- up to the position of the
cursor */
matchBuf = (char *) calloc(strlen(buf) + 2, sizeof(char));
matchBuf = (char *) nmalloc((strlen(buf) + 2) * sizeof(char));
memset(matchBuf, '\0', (strlen(buf) + 2));
strncpy(matchBuf, buf, place);
tmp = matchBuf;
@@ -1032,3 +986,387 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
return buf;
}
#endif
#ifndef DISABLE_BROWSER
/* Return the stat of the file pointed to by path */
struct stat filestat(const char *path) {
struct stat st;
lstat(path, &st);
return st;
}
/* Our sort routine for file listings - sort directories before
* files, and then alphabetically
*/
int diralphasort(const void *va, const void *vb) {
struct stat file1info, file2info;
char *a = *(char **)va, *b = *(char **)vb;
int answer = 0;
if (stat(a, &file1info) == -1)
answer = 1;
else if (stat(b, &file2info) == -1)
answer = 1;
else {
/* If is a is a dir and b isn't, return -1.
Else if b is a dir and a isn't, return 0.
Else return a < b */
if (S_ISDIR(file1info.st_mode) && !S_ISDIR(file2info.st_mode))
return -1;
else if (!S_ISDIR(file1info.st_mode) && S_ISDIR(file2info.st_mode))
return 1;
else
answer = strcmp(a, b);
}
return(answer);
}
/* Initialize the browser code, including the list of files in *path */
char **browser_init(char *path, int *longest, int *numents)
{
DIR *dir;
struct dirent *next;
char **filelist = (char **) NULL;
int i = 0;
dir = opendir(path);
if (!dir)
return NULL;
*numents = 0;
while ((next = readdir(dir)) != NULL) {
if (!strcmp(next->d_name, "."))
continue;
(*numents)++;
if (strlen(next->d_name) > *longest)
*longest = strlen(next->d_name);
}
rewinddir(dir);
*longest += 10;
filelist = nmalloc(*numents * sizeof (char *));
while ((next = readdir(dir)) != NULL) {
if (!strcmp(next->d_name, "."))
continue;
filelist[i] = nmalloc(strlen(next->d_name) + strlen(path) + 2);
if (!strcmp(path, "/"))
snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 1,
"%s%s", path, next->d_name);
else
snprintf(filelist[i], strlen(next->d_name) + strlen(path) + 2,
"%s/%s", path, next->d_name);
i++;
}
if (*longest > COLS - 1)
*longest = COLS - 1;
return filelist;
}
/* Free our malloced memory */
void free_charptrarray(char **array, int len)
{
int i;
for (i = 0; i < len - 1; i++)
free(array[i]);
free(array);
}
/* only print the last part of a path, isn't there a shell
command for this? */
char *tail(char *foo)
{
char *tmp = NULL;
tmp = foo + strlen(foo);
while (*tmp != '/' && tmp != foo)
tmp--;
tmp++;
return tmp;
}
/* Strip one dir from the end of a string */
void striponedir(char *foo)
{
char *tmp = NULL;
/* Don't strip the root dir */
if (!strcmp(foo, "/"))
return;
tmp = foo + strlen(foo);
if (*tmp == '/')
tmp--;
while (*tmp != '/' && tmp != foo)
tmp--;
if (tmp != foo)
*tmp = 0;
else
*(tmp+1) = 0;
return;
}
/* Our browser function. inpath is the path to start browsing from */
char *do_browser(char *inpath)
{
struct stat st;
char *foo, *retval = NULL;
static char *path = NULL;
int numents = 0, i = 0, j = 0, kbinput = 0, longest = 0, abort = 0;
int col = 0, selected = 0, editline = 0, width = 0, filecols = 0;
int lineno = 0, kb;
char **filelist = (char **) NULL;
/* If path isn't the same as inpath, we are being passed a new
dir as an arg. We free it here so it will be copied from
inpath below */
if (path != NULL && strcmp(path, inpath)) {
free(path);
path = NULL;
}
/* if path doesn't exist, make it so */
if (path == NULL)
path = mallocstrcpy(path, inpath);
filelist = browser_init(path, &longest, &numents);
foo = nmalloc(longest + 8);
/* Sort the list by directory first then alphabetically */
qsort(filelist, numents, sizeof(char *), diralphasort);
kb = keypad_on(edit, 1);
titlebar(path);
bottombars(browser_list, BROWSER_LIST_LEN);
curs_set(0);
wmove(edit, 0, 0);
i = 0;
width = 0;
filecols = 0;
/* Loop invariant: Microsoft sucks. */
do {
blank_edit();
blank_statusbar();
editline = 0;
col = 0;
/* Compute line number we're on now so we don't divide by zero later */
if (width == 0)
lineno = selected;
else
lineno = selected / width;
switch (kbinput) {
case KEY_UP:
case 'u':
if (selected - width >= 0)
selected -= width;
break;
case KEY_LEFT:
case 'l':
if (selected > 0)
selected--;
break;
case KEY_DOWN:
case 'd':
if (selected + width <= numents - 1)
selected += width;
break;
case KEY_RIGHT:
case 'r':
if (selected < numents - 1)
selected++;
break;
case NANO_PREVPAGE_KEY:
case NANO_PREVPAGE_FKEY:
case KEY_PPAGE:
case '-':
if (lineno % editwinrows == 0) {
if (selected - (editwinrows * width) >= 0)
selected -= editwinrows * width;
else
selected = 0;
}
else if (selected - (editwinrows +
lineno % editwinrows) * width >= 0)
selected -= (editwinrows + lineno % editwinrows) * width;
else
selected = 0;
break;
case NANO_NEXTPAGE_KEY:
case NANO_NEXTPAGE_FKEY:
case KEY_NPAGE:
case ' ':
if (lineno % editwinrows == 0) {
if (selected + (editwinrows * width) <= numents - 1)
selected += editwinrows * width;
else
selected = numents - 1;
}
else if (selected + (editwinrows -
lineno % editwinrows) * width <= numents - 1)
selected += (editwinrows - lineno % editwinrows) * width;
else
selected = numents - 1;
break;
case KEY_ENTER:
case NANO_CONTROL_M:
case 's': /* More Pico compatibility */
case 'S':
/* You can't cd up from / */
if (!strcmp(filelist[selected], "/..") && !strcmp(path, "/"))
statusbar(_("Can't move up a directory"));
else
path = mallocstrcpy(path, filelist[selected]);
st = filestat(path);
if (S_ISDIR(st.st_mode)) {
if (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;
}
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 */
return do_browser(path);
} else {
retval = path;
abort = 1;
}
break;
/* Stuff we want to abort the browser */
case 'q':
case 'Q':
case 'e': /* Pico compatibility, yeech */
case 'E':
case NANO_EXIT_FKEY:
abort = 1;
break;
}
if (abort)
break;
if (width)
i = width * editwinrows * ((selected / width) / editwinrows);
else
i = 0;
wmove(edit, 0, 0);
for (j = i; j < numents && editline <= editwinrows - 1; j++) {
filecols++;
strncpy(foo, tail(filelist[j]), strlen(tail(filelist[j])) + 1);
while (strlen(foo) < longest)
strcat(foo, " ");
col += strlen(foo);
/* Put file info in the string also */
st = filestat(filelist[j]);
if (S_ISDIR(st.st_mode))
strcpy(foo + longest - 5, "(dir)");
else {
if (S_ISLNK(st.st_mode))
strcpy(foo + longest - 2, "--");
else if (st.st_size < 1024) /* less than 1 K */
sprintf(foo + longest - 7, "%4d B", (int) st.st_size);
else if (st.st_size > 1073741824) /* at least 1 gig */
sprintf(foo + longest - 7, "%4d GB", (int) st.st_size / 1073741824);
else if (st.st_size > 1048576) /* at least 1 meg */
sprintf(foo + longest - 7, "%4d MB", (int) st.st_size / 1048576);
else /* Its more than 1 k and less than a meg */
sprintf(foo + longest - 7, "%4d KB", (int) st.st_size / 1024);
}
/* Hilight the currently selected file/dir */
if (j == selected)
wattron(edit, A_REVERSE);
waddnstr(edit, foo, strlen(foo));
if (j == selected)
wattroff(edit, A_REVERSE);
/* And add some space between the cols */
waddstr(edit, " ");
col += 2;
/* And if the next entry isn't going to fit on the
line, move to the next one */
if (col > (COLS - longest)) {
editline++;
wmove(edit, editline, 0);
col = 0;
if (width == 0)
width = filecols;
}
}
wrefresh(edit);
} while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY);
curs_set(1);
blank_edit();
titlebar(NULL);
edit_refresh();
kb = keypad_on(edit, kb);
/* cleanup */
free_charptrarray(filelist, numents);
free(foo);
return retval;
}
/* Browser fron't end, checks to see if inpath has a dir in it and if so
starts do_browser from there, else from the current dir */
char *do_browse_from(char *inpath)
{
struct stat st;
char *tmp = NULL;
tmp = mallocstrcpy(tmp, inpath);
/* If there's no / in the string, we may was well start from . */
if (tmp == NULL || !strstr(tmp, "/"))
return do_browser(getcwd(NULL, 0));
/* If the string is a directory, pass do_browser that */
st = filestat(tmp);
if (S_ISDIR(st.st_mode))
return do_browser(tmp);
/* Okay, there's a dir in there, but not at the end of the string...
try stripping it off */
striponedir(tmp);
align(&tmp);
return do_browser(tmp);
}
#endif

View File

@@ -35,11 +35,10 @@
* Global variables
*/
int flags = 0; /* Our new flag containig many options */
int center_x = 0, center_y = 0; /* Center of screen */
WINDOW *edit; /* The file portion of the editor */
WINDOW *topwin; /* Top line of screen */
WINDOW *bottomwin; /* Bottom buffer */
char filename[PATH_MAX]; /* Name of the file */
char *filename = NULL; /* Name of the file */
int editwinrows = 0; /* How many rows long is the edit
window? */
filestruct *current; /* Current buffer pointer */
@@ -79,7 +78,13 @@ shortcut goto_list[GOTO_LIST_LEN];
shortcut writefile_list[WRITEFILE_LIST_LEN];
shortcut help_list[HELP_LIST_LEN];
shortcut spell_list[SPELL_LIST_LEN];
#ifndef DISABLE_BROWSER
shortcut browser_list[BROWSER_LIST_LEN];
#endif
#ifndef NANO_SMALL
toggle toggles[TOGGLE_LEN];
#endif
/* Regular expressions */
@@ -103,6 +108,7 @@ void sc_init_one(shortcut * s, int key, char *desc, char *help, int alt,
s->func = func;
}
#ifndef NANO_SMALL
/* Initialize the toggles in the same manner */
void toggle_init_one(toggle * t, int val, char *desc, int flag)
{
@@ -110,6 +116,7 @@ void toggle_init_one(toggle * t, int val, char *desc, int flag)
t->desc = desc;
t->flag = flag;
}
#endif
void toggle_init(void)
{
@@ -170,9 +177,11 @@ void shortcut_init(int unjustify)
"", *nano_mark_msg = "", *nano_delete_msg =
"", *nano_backspace_msg = "", *nano_tab_msg =
"", *nano_enter_msg = "", *nano_case_msg =
"", *nano_cancel_msg = "", *nano_unjustify_msg;
"", *nano_cancel_msg = "", *nano_unjustify_msg = "";
#ifndef NANO_SMALL
char *nano_tofiles_msg = "";
nano_help_msg = _("Invoke the help menu");
nano_writeout_msg = _("Write the current file to disk");
nano_exit_msg = _("Exit from nano");
@@ -205,6 +214,7 @@ void shortcut_init(int unjustify)
nano_enter_msg = _("Insert a carriage return at the cursor position");
nano_case_msg =
_("Make the current search or replace case (in)sensitive");
nano_tofiles_msg = _("Go to file browser");
nano_cancel_msg = _("Cancel the current function");
#endif
@@ -403,15 +413,31 @@ void shortcut_init(int unjustify)
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, do_exit);
sc_init_one(&writefile_list[0], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
#ifndef DISABLE_BROWSER
sc_init_one(&writefile_list[0], NANO_TOFILES_KEY, _("To Files"),
nano_tofiles_msg, 0, 0, 0, NOVIEW, 0);
#endif
sc_init_one(&writefile_list[0], NANO_CANCEL_KEY, _("Cancel"),
sc_init_one(&writefile_list[WRITEFILE_LIST_LEN - 1], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
sc_init_one(&spell_list[0], NANO_CANCEL_KEY, _("Cancel"),
nano_cancel_msg, 0, 0, 0, VIEW, 0);
#ifndef DISABLE_BROWSER
sc_init_one(&browser_list[0], NANO_PREVPAGE_KEY, _("Prev Page"),
nano_prevpage_msg,
0, NANO_PREVPAGE_FKEY, KEY_PPAGE, VIEW, 0);
sc_init_one(&browser_list[1], NANO_NEXTPAGE_KEY, _("Next Page"),
nano_nextpage_msg,
0, NANO_NEXTPAGE_FKEY, KEY_NPAGE, VIEW, 0);
sc_init_one(&browser_list[2], NANO_EXIT_KEY, _("Exit"),
nano_exit_msg, 0, NANO_EXIT_FKEY, 0, VIEW, 0);
#endif
toggle_init();
}

7
move.c
View File

@@ -55,7 +55,12 @@ int page_down(void)
if (current == filebot)
return 0;
if (editbot != filebot || edittop == fileage) {
/* AHEM, if we only have a screen or less of text, DONT do an
edit_update, just move the cursor to editbot! */
if (edittop == fileage && editbot == filebot) {
current = editbot;
reset_cursor();
} else if (editbot != filebot || edittop == fileage) {
current_y = 0;
current = editbot;

7
nano.1
View File

@@ -64,7 +64,9 @@ a new file, do not follow it. Good for editing files in /tmp perhaps?
Enable mouse support (if available for your system).
.TP
.B \-p (\-\-pico)
Emulate Pico as closely as possible.
Emulate Pico as closely as possible. This affects both the "shortcut list"
at the bottom of the screen, as well as the display and entry of previous
search and replace strings.
.TP
.B \-s (\-\-speller)
Enable alternative spell checker command.
@@ -84,6 +86,9 @@ Disable help screen at bottom of editor.
.B \-z (\-\-suspend)
Enable suspend ability.
.TP
.B \-b, \-e, \-f
Ignored, for compatibility with Pico.
.TP
.B \+LINE
Places cursor at LINE on startup.
.SH NOTES

View File

@@ -86,7 +86,9 @@ Enable mouse support (if available for your system).
<DT><B>-p (--pico)</B>
<DD>
Emulate Pico as closely as possible.
Emulate Pico as closely as possible. This affects both the &quot;shortcut list&quot;
at the bottom of the screen, as well as the display and entry of previous
search and replace strings.
<DT><B>-s (--speller)</B>
<DD>
@@ -111,6 +113,10 @@ Disable help screen at bottom of editor.
<DD>
Enable suspend ability.
<DT><B>-b, -e, -f</B>
<DD>
Ignored, for compatibility with Pico.
<DT><B>+LINE</B>
<DD>
@@ -171,6 +177,6 @@ used by others).
This document was created by
<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 04:21:24 GMT, December 03, 2000
Time: 02:16:52 GMT, December 18, 2000
</BODY>
</HTML>

404
nano.c
View File

@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <signal.h>
#include <setjmp.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
@@ -62,35 +63,37 @@
/* Former globals, now static */
int fill = 0; /* Fill - where to wrap lines, basically */
#ifndef DISABLE_SPELLER
static char *alt_speller; /* Alternative spell command */
#endif
struct termios oldterm; /* The user's original term settings */
static char *help_text_init = "";
/* Initial message, not including shortcuts */
static struct sigaction act; /* For all out fun signal handlers */
#ifndef DISABLE_HELP
static char *help_text_init = ""; /* Initial message, not including shortcuts */
#endif
char *last_search = NULL; /* Last string we searched for */
char *last_replace = NULL; /* Last replacement string */
int search_last_line; /* Is this the last search line? */
void keypad_on(int yesno)
{
keypad(edit, yesno);
keypad(bottomwin, yesno);
}
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)
{
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
if (!ISSET(NO_HELP)) {
mvwaddstr(bottomwin, 1, 0, hblank);
mvwaddstr(bottomwin, 2, 0, hblank);
} else
mvwaddstr(bottomwin, 0, 0, hblank);
/* Apparently you REALLY can't get away with not calling keypad()
or your window looks awful when it exits. so we just call it right
before we exit, muhaha :-) */
keypad_on(TRUE);
wrefresh(bottomwin);
endwin();
@@ -141,22 +144,38 @@ void die(char *msg, ...)
exit(1); /* We have a problem: exit w/ errorlevel(1) */
}
/* Die with an error message that the screen was too small if, well, the
screen is too small */
void die_too_small(void)
{
char *too_small_msg = _("Window size is too small for Nano...");
die(too_small_msg);
}
void print_view_warning(void)
{
statusbar(_("Key illegal in VIEW mode"));
}
void clear_filename(void)
{
if (filename != NULL)
free(filename);
filename = nmalloc(1);
filename[0] = 0;
}
/* Initialize global variables - no better way for now */
void global_init(void)
{
int i;
center_x = COLS / 2;
center_y = LINES / 2;
current_x = 0;
current_y = 0;
editwinrows = LINES - 5 + no_help();
if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
die_too_small();
fileage = NULL;
cutbuffer = NULL;
current = NULL;
@@ -164,21 +183,22 @@ void global_init(void)
editbot = NULL;
totlines = 0;
placewewant = 0;
if (!fill)
fill = COLS - 8;
hblank = nmalloc(COLS + 1);
/* Thanks BG for this bit... */
for (i = 0; i <= COLS - 1; i++)
hblank[i] = ' ';
hblank[i] = 0;
if (!fill)
fill = COLS - CHARS_FROM_EOL;
if (fill < MIN_FILL_LENGTH)
die_too_small();
hblank = nmalloc(COLS + 1);
memset(hblank, ' ', COLS);
hblank[COLS] = 0;
}
#ifndef DISABLE_HELP
void init_help_msg(void)
{
#ifndef NANO_SMALL
help_text_init =
_(" nano help text\n\n "
"The nano editor is designed to emulate the functionality and "
@@ -197,9 +217,9 @@ void init_help_msg(void)
"Esc, Alt or Meta key depending on your keyboard setup. The "
"following keystrokes are available in the main editor window. "
"Optional keys are shown in parentheses:\n\n");
#endif
}
#endif
/* Make a copy of a node to a pointer (space will be malloc()ed) */
filestruct *copy_node(filestruct * src)
@@ -230,8 +250,11 @@ void unlink_node(filestruct * fileptr)
void delete_node(filestruct * fileptr)
{
if (fileptr == NULL)
return;
if (fileptr->data != NULL)
free(fileptr->data);
free(fileptr->data);
free(fileptr);
}
@@ -259,18 +282,6 @@ filestruct *copy_filestruct(filestruct * src)
return head;
}
/* Free() a single node */
int free_node(filestruct * src)
{
if (src == NULL)
return 0;
if (src->next != NULL)
free(src->data);
free(src);
return 1;
}
int free_filestruct(filestruct * src)
{
filestruct *fileptr = src;
@@ -280,15 +291,15 @@ int free_filestruct(filestruct * src)
while (fileptr->next != NULL) {
fileptr = fileptr->next;
free_node(fileptr->prev);
delete_node(fileptr->prev);
#ifdef DEBUG
fprintf(stderr, _("free_node(): free'd a node, YAY!\n"));
fprintf(stderr, _("delete_node(): free'd a node, YAY!\n"));
#endif
}
free_node(fileptr);
delete_node(fileptr);
#ifdef DEBUG
fprintf(stderr, _("free_node(): free'd last node.\n"));
fprintf(stderr, _("delete_node(): free'd last node.\n"));
#endif
return 1;
@@ -315,7 +326,10 @@ int renumber(filestruct * fileptr)
return 0;
}
for (temp = fileptr; temp != NULL; temp = temp->next) {
temp->lineno = temp->prev->lineno + 1;
if (temp->prev != NULL)
temp->lineno = temp->prev->lineno + 1;
else
temp->lineno = 1;
}
return 0;
@@ -343,7 +357,7 @@ void usage(void)
printf(_("Usage: nano [GNU long option] [option] +LINE <file>\n\n"));
printf(_("Option Long option Meaning\n"));
printf(_
(" -T --tabsize=[num] Set width of a tab to num\n"));
(" -T [num] --tabsize=[num] Set width of a tab to num\n"));
#ifdef HAVE_REGEX_H
printf(_
(" -R --regexp Use regular expressions for search\n"));
@@ -355,12 +369,12 @@ void usage(void)
(" -c --const Constantly show cursor position\n"));
printf(_
(" -h --help Show this message\n"));
printf(_
(" -i --autoindent Automatically indent new lines\n"));
#ifndef NANO_SMALL
printf(_
(" -k --cut Let ^K cut from cursor to end of line\n"));
#endif
printf(_
(" -i --autoindent Automatically indent new lines\n"));
printf(_
(" -l --nofollow Don't follow symbolic links, overwrite\n"));
#ifndef NANO_SMALL
@@ -368,13 +382,15 @@ void usage(void)
printf(_(" -m --mouse Enable mouse\n"));
#endif
#endif
printf(_
(" -p --pico Emulate Pico as closely as possible\n"));
printf
(_
(" -r [#cols] --fill=[#cols] Set fill cols to (wrap lines at) #cols\n"));
printf(_
(" -p --pico Emulate Pico as closely as possible\n"));
#ifndef DISABLE_SPELLER
printf(_
(" -s [prog] --speller=[prog] Enable alternate speller\n"));
#endif
printf(_
(" -t --tempfile Auto save on exit, don't prompt\n"));
printf(_
@@ -395,10 +411,10 @@ void usage(void)
printf(_(" -V Print version information and exit\n"));
printf(_(" -c Constantly show cursor position\n"));
printf(_(" -h Show this message\n"));
printf(_(" -i Automatically indent new lines\n"));
#ifndef NANO_SMALL
printf(_(" -k Let ^K cut from cursor to end of line\n"));
#endif
printf(_(" -i Automatically indent new lines\n"));
printf(_
(" -l Don't follow symbolic links, overwrite\n"));
#ifndef NANO_SMALL
@@ -406,10 +422,11 @@ void usage(void)
printf(_(" -m Enable mouse\n"));
#endif
#endif
printf(_
(" -r [#cols] Set fill cols to (wrap lines at) #cols\n"));
printf(_(" -s [prog] Enable alternate speller\n"));
printf(_(" -p Emulate Pico as closely as possible\n"));
printf(_(" -r [#cols] Set fill cols to (wrap lines at) #cols\n"));
#ifndef DISABLE_SPELLER
printf(_(" -s [prog] Enable alternate speller\n"));
#endif
printf(_(" -t Auto save on exit, don't prompt\n"));
printf(_(" -v View (read only) mode\n"));
printf(_(" -w Don't wrap long lines\n"));
@@ -428,21 +445,30 @@ void version(void)
(" Email: nano@nano-editor.org Web: http://www.nano-editor.org"));
printf(_("\n Compiled options:"));
#ifdef NANO_SMALL
printf(" --enable-tiny");
#endif
#ifdef NANO_EXTRA
printf(" --enable-extra");
#endif
#ifdef DISABLE_TABCOMP
#ifdef NANO_SMALL
printf(" --enable-tiny");
#else
#ifdef DISABLE_BROWSER
printf(" --disable-browser");
#endif
#ifdef DISABLE_TABCOMP
printf(" --disable-tabcomp");
#endif
#ifdef DISABLE_JUSTIFY
#endif
#ifdef DISABLE_JUSTIFY
printf(" --disable-justify");
#endif
#ifdef DISABLE_SPELLER
#endif
#ifdef DISABLE_SPELLER
printf(" --disable-speller");
#endif
#ifdef DISABLE_HELP
printf(" --disable-help");
#endif
#endif
#ifdef USE_SLANG
printf(" --with-slang");
#endif
@@ -479,7 +505,7 @@ void splice_node(filestruct * begin, filestruct * new, filestruct * end)
int do_mark()
{
#ifdef NANO_SMALL
nano_small_msg();
nano_disabled_msg();
#else
if (!ISSET(MARK_ISSET)) {
statusbar(_("Mark Set"));
@@ -507,14 +533,7 @@ int no_help(void)
return 0;
}
#ifdef NANO_SMALL
void nano_small_msg(void)
{
statusbar("Sorry, this function not available with nano-tiny option");
}
#endif
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER)
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || defined(DISABLE_HELP)
void nano_disabled_msg(void)
{
statusbar("Sorry, support for this function has been disabled");
@@ -1030,7 +1049,6 @@ int do_backspace(void)
if (strcmp(current->data, "")) {
new_magicline();
fix_editbot();
totsize++;
}
}
@@ -1102,7 +1120,7 @@ void wrap_reset(void)
UNSET(SAMELINEWRAP);
}
#if !defined(NANO_SMALL) && !defined(DISABLE_SPELLER)
#ifndef DISABLE_SPELLER
int do_int_spell_fix(char *word)
{
@@ -1168,9 +1186,6 @@ int do_int_spell_fix(char *word)
return TRUE;
}
#endif
#if !defined(NANO_SMALL) && !defined(DISABLE_SPELLER)
/* Integrated spell checking using 'spell' program */
int do_int_speller(char *tempfile_name)
@@ -1298,24 +1313,37 @@ int do_int_speller(char *tempfile_name)
return TRUE;
}
#endif
#if !defined(NANO_SMALL) && !defined(DISABLE_SPELLER)
/* External spell checking */
int do_alt_speller(char *file_name)
{
int alt_spell_status;
pid_t pid_spell;
char *ptr;
static int arglen = 3;
static char **spellargs = (char **) NULL;
endwin();
/* Start a new process for the alternate speller */
/* Set up an argument list to pass the execvp function */
if (spellargs == NULL) {
spellargs = nmalloc(arglen * sizeof(char *));
spellargs[0] = strtok(alt_speller, " ");
while ((ptr = strtok(NULL, " ")) != NULL) {
arglen++;
spellargs = nrealloc(spellargs, arglen * sizeof(char *));
spellargs[arglen - 3] = ptr;
}
spellargs[arglen - 1] = NULL;
}
spellargs[arglen - 2] = file_name;
/* Start a new process for the alternate speller */
if ( (pid_spell = fork()) == 0) {
/* Start alternate spell program, we are using the PATH here!?!? */
execlp(alt_speller, alt_speller, file_name, NULL);
execvp(spellargs[0], spellargs);
/* Should not be reached, if alternate speller is found!!! */
@@ -1352,10 +1380,7 @@ int do_alt_speller(char *file_name)
int do_spell(void)
{
#if defined(NANO_SMALL)
nano_small_msg();
return (TRUE);
#elif defined(DISABLE_SPELLER)
#ifdef DISABLE_SPELLER
nano_disabled_msg();
return (TRUE);
#else
@@ -1411,7 +1436,7 @@ int do_exit(void)
#endif
if (i == 1) {
if (do_writeout(1) > 0)
if (do_writeout(filename, 1) > 0)
finish(0);
} else if (i == 0)
finish(0);
@@ -1532,7 +1557,6 @@ void handle_sigwinch(int s)
char *tty = NULL;
int fd = 0;
int result = 0;
int i = 0;
struct winsize win;
tty = ttyname(0);
@@ -1549,17 +1573,15 @@ void handle_sigwinch(int s)
COLS = win.ws_col;
LINES = win.ws_row;
center_x = COLS / 2;
center_y = LINES / 2;
editwinrows = LINES - 5 + no_help();
fill = COLS - 8;
if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
die_too_small();
free(hblank);
hblank = nmalloc(COLS + 1);
if ((fill = COLS - CHARS_FROM_EOL) < MIN_FILL_LENGTH)
die_too_small();
for (i = 0; i <= COLS - 1; i++)
hblank[i] = ' ';
hblank[i] = 0;
hblank = nrealloc(hblank, COLS + 1);
memset(hblank, ' ', COLS);
hblank[COLS] = 0;
#ifdef HAVE_NCURSES_H
resizeterm(LINES, COLS);
@@ -1588,10 +1610,18 @@ void handle_sigwinch(int s)
/* Do these b/c width may have changed... */
refresh();
titlebar();
titlebar(NULL);
edit_refresh();
display_main_list();
blank_statusbar();
total_refresh();
/* Turn cursor back on for sure */
curs_set(1);
/* Jump back to mainloop */
siglongjmp(jmpbuf, 1);
#endif
}
@@ -1625,7 +1655,8 @@ void signal_init(void)
void window_init(void)
{
editwinrows = LINES - 5 + no_help();
if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS)
die_too_small();
/* Setup up the main text window */
edit = newwin(editwinrows, COLS, 2, 0);
@@ -1633,6 +1664,14 @@ void window_init(void)
/* And the other windows */
topwin = newwin(2, COLS, 0, 0);
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
#ifdef PDCURSES
/* Oops, I guess we need this again.
Moved here so the keypad still works after a Meta-X, for example */
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
#endif
}
void mouse_init(void)
@@ -1640,15 +1679,14 @@ void mouse_init(void)
#ifndef NANO_SMALL
#ifdef NCURSES_MOUSE_VERSION
if (ISSET(USE_MOUSE)) {
keypad_on(TRUE);
keypad_on(edit, 1);
mousemask(BUTTON1_RELEASED, NULL);
mouseinterval(50);
} else {
} else
mousemask(0, NULL);
keypad_on(FALSE);
}
#endif
#endif
@@ -1660,7 +1698,7 @@ int do_tab(void)
return 1;
}
#if !defined(NANO_SMALL) && !defined(DISABLE_JUSTIFY)
#ifndef DISABLE_JUSTIFY
int empty_line(const char *data)
{
while (*data) {
@@ -1712,15 +1750,12 @@ void justify_format(char *data)
int do_justify(void)
{
#ifdef NANO_SMALL
nano_small_msg();
return 1;
#elif defined(DISABLE_JUSTIFY)
#ifdef DISABLE_JUSTIFY
nano_disabled_msg();
return 1;
#else
int slen = 0; /* length of combined lines on one line. */
int initial_y, kbinput;
int initial_y, kbinput = 0, totbak;
filestruct *initial = NULL, *tmpjust = NULL, *cutbak, *tmptop, *tmpbot;
if (empty_line(current->data)) {
@@ -1760,11 +1795,15 @@ int do_justify(void)
set_modified();
cutbak = cutbuffer; /* Got to like cutbak ;) */
totbak = totsize;
cutbuffer = NULL;
tmptop = current;
tmpjust = copy_node(current);
/* This is annoying because it mucks with totsize */
add_to_cutbuffer(tmpjust);
/* Put the whole paragraph into one big line. */
while (current->next && !isspace((int) current->next->data[0])
&& current->next->data[0]) {
@@ -1776,6 +1815,9 @@ int do_justify(void)
tmpjust = copy_node(current->next);
add_to_cutbuffer(tmpjust);
/* Wiping out a newline */
totsize--;
/* length of both strings plus space between strings and ending \0. */
current->data = nrealloc(current->data, len + len2 + 2);
current->data[len++] = ' ';
@@ -1787,8 +1829,6 @@ int do_justify(void)
delete_node(tmpnode);
}
totsize -= strlen(current->data);
justify_format(current->data);
slen = strlen(current->data);
@@ -1808,12 +1848,14 @@ int do_justify(void)
i = fill;
else
i = slen;
for (; i > 0; i--) {
if (isspace((int) current->data[i]) &&
((strlenpt(current->data) - strlen(current->data + i))
<= fill))
break;
}
if (!i)
break;
@@ -1886,6 +1928,8 @@ int do_justify(void)
if (tmptop->prev == NULL)
edit_refresh();
/* Restore totsize from befure justify */
totsize = totbak;
free_filestruct(tmptop);
blank_statusbar_refresh();
}
@@ -1898,16 +1942,16 @@ int do_justify(void)
#endif
}
#ifndef DISABLE_HELP
void help_init(void)
{
int i, sofar = 0;
long allocsize = 1; /* How much space we're gonna need for the help text */
char buf[BUFSIZ];
char buf[BUFSIZ] = "";
/* Compute the space needed for the shortcut lists - we add 15 to
have room for the shortcut abbrev and its possible alternate keys */
for (i = 0; i < MAIN_LIST_LEN; i++)
for (i = 0; i <= MAIN_LIST_LEN - 1; i++)
if (main_list[i].help != NULL)
allocsize += strlen(main_list[i].help) + 15;
@@ -1928,7 +1972,7 @@ void help_init(void)
strcpy(help_text, help_text_init);
/* Now add our shortcut info */
for (i = 0; i < MAIN_LIST_LEN - 1; i++) {
for (i = 0; i <= MAIN_LIST_LEN - 1; i++) {
sofar = snprintf(buf, BUFSIZ, "^%c ", main_list[i].val + 64);
if (main_list[i].misc1 > KEY_F0 && main_list[i].misc1 <= KEY_F(64))
@@ -1966,10 +2010,13 @@ void help_init(void)
}
}
#endif
void do_toggle(int which)
{
#ifndef NANO_SMALL
#ifdef NANO_SMALL
nano_disabled_msg();
#else
char *enabled = _("enabled");
char *disabled = _("disabled");
@@ -1993,6 +2040,7 @@ void do_toggle(int which)
wclear(bottomwin);
wrefresh(bottomwin);
window_init();
fix_editbot();
edit_refresh();
display_main_list();
break;
@@ -2013,18 +2061,47 @@ void do_toggle(int which)
}
SET(DISABLE_CURPOS);
#else
nano_small_msg();
#endif
}
/* If the NumLock key has made the keypad gone awry, print an error
message, hopefully we can address it later. */
void print_numlock_warning(void)
{
static int didmsg = 0;
if (!didmsg) {
statusbar(_("NumLock glitch detected. Keypad will malfunction with NumLock off"));
didmsg = 1;
}
}
/* This function returns the correct keystroke, given the A,B,C or D
input key. This is a common sequence of many terms which send
Esc-O-[A-D] or Esc-[-[A-D]. */
int ABCD(int input)
{
switch(input)
{
case 'A':
return(KEY_UP);
case 'B':
return(KEY_DOWN);
case 'C':
return(KEY_RIGHT);
case 'D':
return(KEY_LEFT);
default:
return 0;
}
}
int main(int argc, char *argv[])
{
int optchr;
int kbinput; /* Input from keyboard */
long startline = 0; /* Line to try and start at */
int keyhandled = 0; /* Have we handled the keystroke yet? */
int i;
int keyhandled; /* Have we handled the keystroke yet? */
int i, modify_control_seq;
char *argv0;
#ifdef _POSIX_VDISABLE
struct termios term;
@@ -2042,12 +2119,15 @@ int main(int argc, char *argv[])
{"nowrap", 0, 0, 'w'},
{"nohelp", 0, 0, 'x'},
{"help", 0, 0, 'h'},
{"view", 0, 0, 'v'},
#ifndef NANO_SMALL
{"cut", 0, 0, 'k'},
#endif
{"autoindent", 0, 0, 'i'},
{"tempfile", 0, 0, 't'},
#ifndef DISABLE_SPELLER
{"speller", 1, 0, 's'},
#endif
{"fill", 1, 0, 'r'},
{"mouse", 0, 0, 'm'},
{"pico", 0, 0, 'p'},
@@ -2067,10 +2147,10 @@ int main(int argc, char *argv[])
#endif
#ifdef HAVE_GETOPT_LONG
while ((optchr = getopt_long(argc, argv, "?T:RVchiklmpr:s:tvwxz",
while ((optchr = getopt_long(argc, argv, "?T:RVbcefhiklmpr:s:tvwxz",
long_options, &option_index)) != EOF) {
#else
while ((optchr = getopt(argc, argv, "h?T:RVciklmpr:s:tvwxz")) != EOF) {
while ((optchr = getopt(argc, argv, "h?T:RVbcefiklmpr:s:tvwxz")) != EOF) {
#endif
switch (optchr) {
@@ -2089,6 +2169,11 @@ int main(int argc, char *argv[])
case 'V':
version();
exit(0);
case 'b':
case 'e':
case 'f':
/* Pico compatibility flags */
break;
case 'c':
SET(CONSTUPDATE);
break;
@@ -2103,10 +2188,6 @@ int main(int argc, char *argv[])
case 'k':
SET(CUT_TO_END);
break;
#else
case 'k':
usage(); /* Oops! You dont really have that option */
finish(1);
#endif
case 'l':
UNSET(FOLLOW_SYMLINKS);
@@ -2124,10 +2205,12 @@ int main(int argc, char *argv[])
finish(1);
}
break;
#ifndef DISABLE_SPELLER
case 's':
alt_speller = nmalloc(strlen(optarg) + 1);
strcpy(alt_speller, optarg);
break;
#endif
case 't':
SET(TEMP_OPT);
break;
@@ -2158,19 +2241,19 @@ int main(int argc, char *argv[])
/* See if there's a non-option in argv (first non-option is the
filename, if +LINE is not given) */
if (argc == 1 || argc <= optind)
strcpy(filename, "");
clear_filename();
else {
/* Look for the +line flag... */
if (argv[optind][0] == '+') {
startline = atoi(&argv[optind][1]);
optind++;
if (argc == 1 || argc <= optind)
strcpy(filename, "");
clear_filename();
else
strncpy(filename, argv[optind], 132);
} else
strncpy(filename, argv[optind], 132);
filename = mallocstrcpy(filename, argv[optind]);
} else
filename = mallocstrcpy(filename, argv[optind]);
}
@@ -2191,13 +2274,14 @@ int main(int argc, char *argv[])
nonl();
cbreak();
noecho();
timeout(0);
/* Set up some global variables */
global_init();
shortcut_init(0);
#ifndef DISABLE_HELP
init_help_msg();
help_init();
#endif
signal_init();
#ifdef DEBUG
@@ -2207,12 +2291,6 @@ int main(int argc, char *argv[])
window_init();
mouse_init();
#ifdef PDCURSES
/* Must have this for the arrow, et al, keys to even work in
PDCurses+cygwin under Windows */
keypad_on(TRUE);
#endif
#ifdef DEBUG
fprintf(stderr, _("Main: bottom win\n"));
#endif
@@ -2223,7 +2301,7 @@ int main(int argc, char *argv[])
fprintf(stderr, _("Main: open file\n"));
#endif
titlebar();
titlebar(NULL);
/* Now we check to see if argv[optind] is non-null to determine if
we're dealing with a new file or not, not argc == 1... */
@@ -2237,6 +2315,14 @@ int main(int argc, char *argv[])
else
edit_update(fileage, CENTER);
/* return here after a sigwinch */
sigsetjmp(jmpbuf,1);
/* Fix clobber-age */
kbinput = 0;
keyhandled = 0;
modify_control_seq = 0;
edit_refresh();
reset_cursor();
@@ -2248,12 +2334,19 @@ int main(int argc, char *argv[])
#endif
kbinput = wgetch(edit);
#ifdef DEBUG
fprintf(stderr, "AHA! %c (%d)\n", kbinput, kbinput);
#endif
if (kbinput == 27) { /* Grab Alt-key stuff first */
switch (kbinput = wgetch(edit)) {
/* Alt-O, suddenly very important ;) */
case 79:
kbinput = wgetch(edit);
if (kbinput <= 'S' && kbinput >= 'P')
if (kbinput <= 'D' && kbinput >= 'A')
kbinput = ABCD(kbinput);
else if (kbinput <= 'z' && kbinput >= 'j')
print_numlock_warning();
else if (kbinput <= 'S' && kbinput >= 'P')
kbinput = KEY_F(kbinput - 79);
#ifdef DEBUG
else {
@@ -2263,8 +2356,13 @@ int main(int argc, char *argv[])
}
#endif
break;
case 27:
/* If we get Alt-Alt, the next keystroke should be the same as a
control sequence */
modify_control_seq = 1;
keyhandled = 1;
break;
case 91:
switch (kbinput = wgetch(edit)) {
case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */
kbinput = wgetch(edit);
@@ -2341,16 +2439,10 @@ int main(int argc, char *argv[])
kbinput = KEY_F(kbinput - 64);
break;
case 'A':
kbinput = KEY_UP;
break;
case 'B':
kbinput = KEY_DOWN;
break;
case 'C':
kbinput = KEY_RIGHT;
break;
case 'D':
kbinput = KEY_LEFT;
kbinput = ABCD(kbinput);
break;
case 'H':
kbinput = KEY_HOME;
@@ -2392,6 +2484,18 @@ int main(int argc, char *argv[])
break;
}
}
/* If the modify_control_seq is set, we received an Alt-Alt
sequence before this, so we make this key a control sequence
by subtracting 64 or 96, depending on its value. */
if (!keyhandled && modify_control_seq) {
if (kbinput >= 'A' && kbinput < 'a')
kbinput -= 64;
else if (kbinput >= 'a' && kbinput <= 'z')
kbinput -= 96;
modify_control_seq = 0;
}
/* Look through the main shortcut list to see if we've hit a
shortcut key */
for (i = 0; i < MAIN_LIST_LEN && !keyhandled; i++) {
@@ -2405,18 +2509,17 @@ int main(int argc, char *argv[])
keyhandled = 1;
}
}
#ifndef _POSIX_VDISABLE
/* Since we're in raw mode, we have to catch ^Q and ^S */
/* If we're in raw mode or using Alt-Alt-x, we have to catch
Control-S and Control-Q */
if (kbinput == 17 || kbinput == 19)
keyhandled = 1;
/* And catch ^Z by hand when triggered */
/* Catch ^Z by hand when triggered also */
if (kbinput == 26) {
if (ISSET(SUSPEND))
do_suspend(0);
keyhandled = 1;
}
#endif
/* Last gasp, stuff that's not in the main lists */
if (!keyhandled)
@@ -2431,6 +2534,7 @@ int main(int argc, char *argv[])
case 0: /* Erg */
do_next_word();
break;
case 331: /* Stuff that we don't want to do squat */
case -1:
case 410: /* Must ignore this, it gets sent when we resize */

21
nano.h
View File

@@ -226,6 +226,7 @@ know what you're doing */
#define NANO_SUSPEND_KEY NANO_CONTROL_Z
#define NANO_ENTER_KEY NANO_CONTROL_M
#define NANO_FROMSEARCHTOGOTO_KEY NANO_CONTROL_T
#define NANO_TOFILES_KEY NANO_CONTROL_T
#define TOGGLE_CONST_KEY NANO_ALT_C
#define TOGGLE_AUTOINDENT_KEY NANO_ALT_I
@@ -243,10 +244,16 @@ know what you're doing */
#define REPLACE_LIST_LEN 6
#define REPLACE_LIST_2_LEN 3
#define GOTO_LIST_LEN 3
#define WRITEFILE_LIST_LEN 1
#define HELP_LIST_LEN 3
#define SPELL_LIST_LEN 1
#ifndef DISABLE_BROWSER
#define WRITEFILE_LIST_LEN 2
#define BROWSER_LIST_LEN 3
#else
#define WRITEFILE_LIST_LEN 1
#endif
#ifdef HAVE_REGEX_H
#define TOGGLE_LEN 9
#else
@@ -259,4 +266,14 @@ know what you're doing */
#define TOP 2
#define CENTER 1
#define BOTTOM 0
#endif
/* Minimum editor window rows required for Nano to work correctly */
#define MIN_EDITOR_ROWS 3
/* 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
#endif /* ifndef NANO_H */

472
po/de.po

File diff suppressed because it is too large Load Diff

498
po/es.po

File diff suppressed because it is too large Load Diff

502
po/fi.po

File diff suppressed because it is too large Load Diff

467
po/fr.po

File diff suppressed because it is too large Load Diff

474
po/id.po

File diff suppressed because it is too large Load Diff

491
po/it.po

File diff suppressed because it is too large Load Diff

26
proto.h
View File

@@ -29,7 +29,7 @@
#include "nano.h"
extern int center_x, center_y, editwinrows;
extern int editwinrows;
extern int current_x, current_y, posible_max, totlines;
extern int placewewant;
extern int mark_beginx, samelinewrap;
@@ -38,7 +38,7 @@ extern int fill, flags,tabsize;
extern int search_last_line;
extern WINDOW *edit, *topwin, *bottomwin;
extern char filename[PATH_MAX];
extern char *filename;
extern char *answer;
extern char *hblank, *help_text;
extern char *last_search;
@@ -51,6 +51,9 @@ extern shortcut main_list[MAIN_LIST_LEN], whereis_list[WHEREIS_LIST_LEN];
extern shortcut replace_list[REPLACE_LIST_LEN], goto_list[GOTO_LIST_LEN];
extern shortcut writefile_list[WRITEFILE_LIST_LEN], help_list[HELP_LIST_LEN];
extern shortcut spell_list[SPELL_LIST_LEN], replace_list_2[REPLACE_LIST_LEN];
#ifndef DISABLE_BROWSER
extern shortcut browser_list[BROWSER_LIST_LEN];
#endif
#ifdef HAVE_REGEX_H
extern int use_regexp, regexp_compiled;
@@ -78,7 +81,7 @@ int do_uncut_text(void);
int no_help(void);
int renumber_all(void);
int open_file(char *filename, int insert, int quiet);
int do_writeout(int exiting);
int do_writeout(char *path, int exiting);
int do_gotoline(long defline);
int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
int wholewords, int *i);
@@ -109,16 +112,18 @@ void check_statblank(void);
void update_line(filestruct * fileptr, int index);
void fix_editbot(void);
void statusbar(char *msg, ...);
void titlebar(void);
void blank_statusbar(void);
void titlebar(char *path);
void previous_line(void);
void center_cursor(void);
void bottombars(shortcut s[], int slen);
void blank_statusbar_refresh(void);
void *nmalloc (size_t howmuch);
void *mallocstrcpy(void *dest, void *src);
void *mallocstrcpy(char *dest, char *src);
void wrap_reset(void);
void display_main_list(void);
void nano_small_msg(void);
void nano_disable_msg(void);
void do_early_abort(void);
void *nmalloc(size_t howmuch);
void *nrealloc(void *ptr, size_t howmuch);
@@ -133,6 +138,8 @@ void search_init_globals(void);
void replace_abort(void);
void add_to_cutbuffer(filestruct * inptr);
void do_replace_highlight(int highlight_flag, char *word);
void nano_disabled_msg(void);
void window_init(void);
#ifdef NANO_EXTRA
void do_credits(void);
#endif
@@ -145,6 +152,15 @@ int do_home(void), do_end(void), total_refresh(void), do_mark(void);
int do_delete(void), do_backspace(void), do_tab(void), do_justify(void);
int do_first_line(void), do_last_line(void);
int do_replace(void), do_help(void), do_enter_void(void);
int keypad_on(WINDOW * win, int new);
#ifndef DISABLE_BROWSER
char *do_browser(char *path);
struct stat filestat(const char *path);
char *do_browse_from(char *inpath);
#endif
RETSIGTYPE main_loop (int junk);
filestruct *copy_node(filestruct * src);
filestruct *copy_filestruct(filestruct * src);

View File

@@ -123,9 +123,13 @@ void *nrealloc(void *ptr, size_t howmuch)
Should be used as dest = mallocstrcpy(dest, src);
*/
void *mallocstrcpy(void *dest, void *src)
void *mallocstrcpy(char *dest, char *src)
{
if (src == dest)
return src;
if (dest != NULL)
free(dest);
@@ -152,6 +156,7 @@ void new_magicline(void)
filebot->next->lineno = filebot->lineno + 1;
filebot = filebot->next;
totlines++;
totsize++;
}
#ifndef DISABLE_TABCOMP

109
winio.c
View File

@@ -353,6 +353,8 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
inputbuf = input_tab(inputbuf, (x - x_left),
&tabbed, &shift);
x += shift;
if (x - x_left > strlen(inputbuf))
x = strlen(inputbuf) + x_left;
nanoget_repaint(buf, inputbuf, x);
}
break;
@@ -463,9 +465,13 @@ void horizbar(WINDOW * win, int y)
wattroff(win, A_REVERSE);
}
void titlebar(void)
void titlebar(char *path)
{
int namelen, space;
char *what = path;
if (path == NULL)
what = filename;
horizbar(topwin, 0);
wattron(topwin, A_REVERSE);
@@ -473,17 +479,23 @@ void titlebar(void)
space = COLS - strlen(VERMSG) - strlen(VERSION) - 21;
namelen = strlen(filename);
namelen = strlen(what);
if (!strcmp(filename, ""))
mvwaddstr(topwin, 0, center_x - 6, _("New Buffer"));
if (!strcmp(what, ""))
mvwaddstr(topwin, 0, COLS / 2 - 6, _("New Buffer"));
else {
if (namelen > space) {
waddstr(topwin, _(" File: ..."));
waddstr(topwin, &filename[namelen - space]);
if (path == NULL)
waddstr(topwin, _(" File: ..."));
else
waddstr(topwin, _(" DIR: ..."));
waddstr(topwin, &what[namelen - space]);
} else {
mvwaddstr(topwin, 0, center_x - (namelen / 2 + 1), "File: ");
waddstr(topwin, filename);
if (path == NULL)
mvwaddstr(topwin, 0, COLS / 2 - (namelen / 2 + 1), "File: ");
else
mvwaddstr(topwin, 0, COLS / 2 - (namelen / 2 + 1), " DIR: ");
waddstr(topwin, what);
}
}
if (ISSET(MODIFIED))
@@ -552,7 +564,7 @@ void set_modified(void)
{
if (!ISSET(MODIFIED)) {
SET(MODIFIED);
titlebar();
titlebar(NULL);
wrefresh(topwin);
}
}
@@ -1080,7 +1092,7 @@ void statusbar(char *msg, ...)
vsnprintf(foo, 132, msg, ap);
va_end(ap);
start_x = center_x - strlen(foo) / 2 - 1;
start_x = COLS / 2 - strlen(foo) / 2 - 1;
/* Blank out line */
blank_statusbar();
@@ -1119,7 +1131,7 @@ int total_refresh(void)
clearok(topwin, FALSE);
clearok(bottomwin, FALSE);
edit_refresh();
titlebar();
titlebar(NULL);
return 1;
}
@@ -1132,33 +1144,26 @@ void previous_line(void)
int do_cursorpos(void)
{
filestruct *fileptr;
float linepct, bytepct;
int i, tot = 0;
float linepct = 0.0, bytepct = 0.0;
int i = 0;
if (current == NULL || fileage == NULL)
return 0;
for (fileptr = fileage; fileptr != current && fileptr != NULL;
fileptr = fileptr->next)
tot += strlen(fileptr->data) + 1;
i += strlen(fileptr->data) + 1;
if (fileptr == NULL)
return -1;
i = tot + current_x;;
for (fileptr = current->next; fileptr != NULL; fileptr = fileptr->next)
tot += strlen(fileptr->data) + 1;
i += current_x;
if (totlines > 0)
linepct = 100 * current->lineno / totlines;
else
linepct = 0;
if (totsize > 0)
bytepct = 100 * i / totsize;
else
bytepct = 0;
#ifdef DEBUG
fprintf(stderr, _("do_cursorpos: linepct = %f, bytepct = %f\n"),
@@ -1175,25 +1180,26 @@ int do_cursorpos(void)
But hey, it's better than nothing, and it's dynamic! */
int do_help(void)
{
#ifndef NANO_SMALL
#ifndef DISABLE_HELP
char *ptr = help_text, *end;
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0;
int i, j, row = 0, page = 1, kbinput = 0, no_more = 0, kp;
int no_help_flag = 0;
blank_edit();
curs_set(0);
blank_statusbar();
kp = keypad_on(edit, 1);
if (ISSET(NO_HELP)) {
/* Well if we're going to do this, we should at least
do it the right way */
no_help_flag = 1;
delwin(bottomwin);
bottomwin = newwin(3, COLS, LINES - 3, 0);
keypad(bottomwin, TRUE);
editwinrows -= no_help();
UNSET(NO_HELP);
window_init();
bottombars(help_list, HELP_LIST_LEN);
} else
bottombars(help_list, HELP_LIST_LEN);
@@ -1265,22 +1271,23 @@ int do_help(void)
no_more = 1;
continue;
}
} while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY);
} while ((kbinput = wgetch(edit)) != NANO_EXIT_KEY &&
kbinput != NANO_EXIT_FKEY);
if (no_help_flag) {
werase(bottomwin);
blank_bottombars();
wrefresh(bottomwin);
delwin(bottomwin);
SET(NO_HELP);
bottomwin = newwin(3 - no_help(), COLS, LINES - 3 + no_help(), 0);
keypad(bottomwin, TRUE);
editwinrows += no_help();
} else
display_main_list();
window_init();
}
display_main_list();
curs_set(1);
edit_refresh();
#else
nano_small_msg();
kp = keypad_on(edit, kp);
#elif defined(DISABLE_HELP)
nano_disabled_msg();
#endif
return 1;
@@ -1400,7 +1407,7 @@ void do_credits(void)
"Tedi Heriyanto",
"Bill Soudan",
"Christian Weisgerber",
"Erik Anderson",
"Erik Andersen",
"Big Gaute",
"Joshua Jensen",
"",
@@ -1442,7 +1449,7 @@ void do_credits(void)
else
what = "";
start_x = center_x - strlen(what) / 2 - 1;
start_x = COLS / 2 - strlen(what) / 2 - 1;
mvwaddstr(edit, i * 2 - k, start_x, what);
}
usleep(700000);
@@ -1463,3 +1470,23 @@ void do_credits(void)
total_refresh();
}
#endif
int keypad_on(WINDOW * win, int new)
{
/* This is taken right from aumix. Don't sue me */
#ifdef HAVE_USEKEYPAD
int old;
old = win->_use_keypad;
keypad(win, new);
return old;
#else
keypad(win, new);
return 1;
#endif /* HAVE_USEKEYPAD */
}