Compare commits

...

215 Commits

Author SHA1 Message Date
Chris Allegretta
9b1c868326 GNU nano 2.2.5 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4513 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-08-06 01:20:51 +00:00
Chris Allegretta
14d7c5de2a 2010-08-04 Lauri Kasanen <curaga@operamail.comcuraga@operamail.com>
* doc/syntax/mgp.nanorc: New Magicpoint syntax highlighting definition



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4512 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-08-04 13:47:23 +00:00
Chris Allegretta
7a1b1ff5be 2010-08-04 Peter <exodus@savannah>
* doc/syntax/tex.nanorc: No longer highlight escaped comments



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4511 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-08-04 13:37:48 +00:00
Chris Allegretta
461519cce7 Add more inseure backup checks to that strange cases like with ACLs will work with allow_insecure_backup.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4509 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-06-24 14:47:00 +00:00
Chris Allegretta
0acca27ac7 2010-06-20 Chris Allegretta <chrisa@asty.org>
* New option allow_insecure_backup, allows the previous security
          fixes for backup files to be overridden if you're really positive
          you want to.  Fixes Savannah bug 29732 by Brian Szymanski <skibrianski>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4508 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-06-21 03:10:10 +00:00
Chris Allegretta
86be3af75f 2010-05-23 Chris Allegretta <chrisa@asty.org>
* files.c (write_file): Don't even try to chown() the backup
          file unless we're root, since it's probably going to fail if
          we're editing a file we don't own.  Fixes Savannah bug
          29514: [nano 2.2.2] backup should ignore chown errors.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4507 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-05-23 04:30:23 +00:00
Chris Allegretta
0dcfa1d7f7 Back to svn!
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4506 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-05-23 04:26:22 +00:00
Chris Allegretta
a2c5172db3 GNU nano 2.2.4
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4503 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-15 07:40:41 +00:00
Chris Allegretta
29e2012267 2010-04-07 Chris Allegretta <chrisa@asty.org>
* doc/man/nano.1,nanorc.5: Remove the backup file warnings now
          that a sufficient security fix exists for the backup file code.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4502 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-14 21:55:39 +00:00
Chris Allegretta
c859049041 Add CVE information for the fixes in this release.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4501 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-14 21:53:59 +00:00
Chris Allegretta
db9d983646 2010-04-14 Chris Allegretta <chrisa@asty.org>
* files.c (wirte_file): Don't set current_stat when tmp == TRUE, check
          whether current_stat is set when trying to use it, and don't do the
          modification check if the filename changed, since we have no way
          of knowing about it in that case.  Fixes Savannah bug 29392, reported
          by Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4500 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-14 06:03:12 +00:00
Chris Allegretta
181c4a999b 2010-04-09 Chris Allegretta <chrisa@asty.org>
* text.c (do_alt_speller): Skip invoking the alt speller if the file size
          is 0 bytes.  Fixes Savannah bug 29393 reported by Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4499 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-14 03:14:40 +00:00
Chris Allegretta
053fabd4e1 2010-04-13 Felipe Bugno <necron@bol.com.br>
* doc/syntax/cmake.nanorc: Added cmake syntax highlighting file.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4498 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-14 02:38:56 +00:00
Chris Allegretta
ad8476eb7d Sigh, left out O_EXCL from Dan's patch
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4497 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-09 15:31:00 +00:00
Chris Allegretta
7f61a6cb79 2010-04-09 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Better security fixes for backup file writing, 
          mangled from submission by Dan Rosenberg <dan.j.rosenberg at gmail>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4496 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-09 15:01:51 +00:00
Chris Allegretta
dbbf9a052f Okay maybe make it crash EVEN less.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4495 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-08 04:07:14 +00:00
Chris Allegretta
83a0e9013e 2010-04-02 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Previous fixes should not cause a crash
          when saving a new file.  Discovered by Mike Frysinger <vapier@gentoo.org>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4494 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-08 02:22:53 +00:00
Chris Allegretta
e68616b799 2010-04-07 Chris Allegretta <chrisa@asty.org>
* doc/man/nano.1,nanorc.5: Add warnings about using backup 
          mode as root due to the Dan Rosenberg security analysis.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4493 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-07 06:20:55 +00:00
Chris Allegretta
9e73aeb10f Fix that wording cause it's the file owner we care about
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4492 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-07 05:53:41 +00:00
Chris Allegretta
0d1381adf9 * files.c (do_writeout): Also abort on writing a backup
file when its owner doesn't match the edited file.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4491 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-07 05:48:24 +00:00
Chris Allegretta
cdb5b16198 2010-04-02 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Expand modification check to include both the
          original file's device ID and inode number as reasons to warn the
          user that the file has been modified.  Based on security article on nano
          by Dan Rosenberg.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4490 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-04-03 02:39:18 +00:00
Chris Allegretta
35b5976e69 2010-03-21 Chris Allegretta <chrisa@asty.org>
* nano.c (page_stdin et al): Don't attempt to reset/reopen the terminal
          settings when reading stdin if it was aborted with SIGINT.  May fix Savannah
          bug 29114 reported by  Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4489 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-03-21 05:31:43 +00:00
Chris Allegretta
fe2042da8a 2010-03-21 Mike Frysinger <vapier@gentoo.org>
* doc/syntax/c.nanorc: Add additional support for #include_next and #pragma



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4488 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-03-21 05:04:03 +00:00
Chris Allegretta
091d5f3b0a Fix ChangeLog to reflect previosu commit.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4487 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-03-21 04:57:14 +00:00
Chris Allegretta
08273aa1b2 Make previous fix more succinct and fix page down also.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4486 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-03-21 04:56:37 +00:00
Chris Allegretta
b5e7647028 * move.c (do_page_up): Explicitly set current_y to 0 when paging up when not in
smooth scroll mode, as previous fixes would otherwise cause the cursor to not
	  really be moved to the stop of the screen.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4485 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-03-21 04:35:17 +00:00
Chris Allegretta
42bd871af3 2010-03-07 Chris Allegretta <chrisa@asty.org>
* configure.ac, nano.c (handle_sigwinch): Create check for whether LINES and
          COLS can safely be redefined.  Fixes compilation issues with cygwin, and likely
          with newer versions of ncurses, fixes Savannah bug 28984 repoted by Andy Koppe
          and Eric Oliver via mailing list.
        * winio.c (get_mouseinput) - fix stray semicolon in code, also reported in
          bug 28984.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4484 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-03-07 19:35:46 +00:00
Chris Allegretta
f81d6fe8d3 GNU nano 2.2.3 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4482 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-02-11 06:13:55 +00:00
Chris Allegretta
1456a10ace 2010-01-28 Chris Allegretta <chrisa@asty.org>
* move.c (do_page_up, do_page_down): Fix for smooth mode not preserving cusor
          position.  Part one of fix for Savannah bug 21178 by Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4481 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-29 03:40:58 +00:00
Chris Allegretta
8ff7f33c52 Back to SVN
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4480 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-19 00:05:49 +00:00
Chris Allegretta
3eacb857a1 GNU nano 2.2.2 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4478 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-18 03:47:40 +00:00
Chris Allegretta
2466d933c9 Compile fix with current_stat. Not sure how I missed that.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4477 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-18 03:43:24 +00:00
Chris Allegretta
4e621b5f6b Missed ChangeLog entry frm previous, must have been from wrong cwd
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4476 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-18 00:24:09 +00:00
Chris Allegretta
b916f5cd8b 2010-01-17 Chris Allegretta <chrisa@asty.org>
* nano.c (main), prompt.c (do_statusbar_input): Handle problems with an unmapped 
          function due to key rebinding, fixes crashes on FreeBSD repoted by Eitan 
          Adler <eitanadlerlist@gmail.com>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4475 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-17 05:30:22 +00:00
Chris Allegretta
6cf05d487f 2010-01-14 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Fix for crash / incorrect external modification warning
          due to earlier fix in r4467.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4474 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-14 06:32:37 +00:00
Chris Allegretta
1a7a91b779 2010-01-12 Chris Allegretta <chrisa@asty.org>
* move.c (do_page_up, do_page_down): Fix issues with not enough scrolling down/up
          and cursor centering.
        * winio.c (edit_scroll): Remove lots of needless checking of line length for
          soft wrapping code.
        * winio.c (edit_update) - Remove extra code for when updating with old_current outside
          of the new buffer boundary and centering issues.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4473 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-13 03:21:19 +00:00
Chris Allegretta
df8c3debc8 2010-01-05 Tito <farmatito@tiscali.it>
* search.c (update_history) - Fix bad length check causing search crash on armel platform.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4472 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-05 23:35:50 +00:00
Chris Allegretta
374216fe22 2010-01-04 Chris Allegretta <chrisa@asty.org>
* winio.c: edit_update, edit_redraw - Fix search not scrolling to the middle of the screen 
          (reported by alpha@qzx.com) and places where we rely on maxrows but should not.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4471 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2010-01-04 19:00:55 +00:00
Jordi Mallach
fc6ef3e1e8 doc/man/nano.1: Avoid a groff warning by prepending a zero-width space to a line starting with '.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4470 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-26 01:58:50 +00:00
Chris Allegretta
8d41fb8c3e 2009-12-22 Chris Allegretta <chrisa@asty.org>
* files.c (write_file): Fix compatibility with previous stat fix and tiny mode.

2009-12-22 David Lawrence Ramsey <pooka109@gmail.com>
        * global.c: Add new strings for forward/back in the file browser.  New variables
          nano_forwardfile_msg and nano_backfile_msg.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4469 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-23 05:03:09 +00:00
Chris Allegretta
3c7dda6e7e 2009-12-20 Chris Allegretta <chrisa@asty.org>
* files.c (is_file_writable): remove assert check for f, since it's not
          initialized at the time.  Fixes Savannah bug 28309, reported by Zoltan Kovacs.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4468 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-20 05:55:41 +00:00
Chris Allegretta
869aca4392 2009-12-20 Brian Szymanski <skibrianski via Savannah>
* src/files.c (write_file): Check stat struct exists, and if not use just obtained stat data.    
          Fixes Ubuntu bug 471568, "reproducible crash in nano on trying to save to a file 
          different than the one specified on the command line".



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4467 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-20 05:46:35 +00:00
Chris Allegretta
d9be86f45b 2009-12-15 Chris Allegretta <chrisa@asty.org>
* doc/nanorc.sample.in - Remove erroneous 'set suspendenable' as it's actually a 
          key binding (e.g. 'bind M-Z suspendenable all') and not a settable flag.  Fixes
          Savannah bug 28299 reported by Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4466 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-15 18:07:17 +00:00
Chris Allegretta
9c0716a73a Oh snap, back to SVN.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4465 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-13 05:03:24 +00:00
Chris Allegretta
560a8cd0ec GNU nano 2.2.1 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4463 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-13 03:31:00 +00:00
Chris Allegretta
a8bc492b8a 2009-12-12 Chris Allegretta <chrisa@asty.org>
* text.c (do_delete), nano.c (do_output): Add check for length of current line
          before and after adding/deleting text, and do full refresh if it is now
          a different multiple of COLS.  Also get rid of superfluous do_refresh
          vars now that we have edit_refresh_needed.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4462 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-12 22:21:20 +00:00
Chris Allegretta
f387f33083 2009-12-07 David Lawrence Ramsey <pooka109@gmail.com>
* global.c (shortcut_init), browser.c (do_browser): Fix M-W not being bound to 
          research in either main menu or browser.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4461 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-09 17:09:37 +00:00
Chris Allegretta
2c7b506fbc 2009-12-09 Chris Allegretta <chrisa@asty.org>
* files.c (read_file) - Add parameter for whether we should even try to check
          file writability, as the message is useless when we're inserting into an
          existing buffer.  Fixes Savannah bug 28219.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4460 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-09 16:51:43 +00:00
Chris Allegretta
5b25e07744 2009-12-07 David Lawrence Ramsey <pooka109@gmail.com>
* global.c (shortcut_init): Many fixes for keybindings code oversights, including
          restore page up/down and GotoDir to browser,
        * browser.c (do_browser): Fix breaking out of a submenu (e.g. gotodir) breaks out
          of browser altogether.
        * doc/nanorc.sample.in: Add missing entries for fortran/ObjC/OCaml entries.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4459 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-07 12:34:23 +00:00
Chris Allegretta
b27b3a18a9 2009-12-03 David Lawrence Ramsey <pooka109@gmail.com>
* global.c (shortcut_init) - Remove help shortcut from help shortcut list :-)  Tweaked
          to reorder exit shortcut to end of list to not mess up prev/next shortcut symmetry.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4458 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-04 04:29:55 +00:00
Chris Allegretta
96466166f1 2009-12-03 Eitan Adler <eitanadlerlist@gmail.com>
* doc/syntax/makefile.nanorc - Fix poor regex for all alpha characters which sometimes leads to
          error messages, reported by gibboris@gmail.com.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4457 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-04 03:46:04 +00:00
Chris Allegretta
671b2d974c Add --disable-wrapping to nano-regress
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4456 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-03 03:20:24 +00:00
Chris Allegretta
c9f0799791 2009-12-02 Chris Allegretta <chrisa@asty.org>
* text.c (add_undo, do_undo, do_redo) - Do not execute cases for SPLIT when DISABLE_WRAPPING
          is defined.  Fixes Savannah bug 28151 (anon).



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4455 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-03 03:12:00 +00:00
Jordi Mallach
42a390416e Fix escaping of hyphens for the -$ option.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4454 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-02 22:47:57 +00:00
Chris Allegretta
8a07a96eef 2009-12-01 David Lawrence Ramsey <pooka109@gmail.com>
* Update documentation for 2.2 features including sample nanorc file, texinfo
          file, man pages, UPGRADE file, and update copyright noticed for the current year.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4453 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-02 03:36:22 +00:00
Chris Allegretta
a97cb819f2 2009-12-01 Kamil Dudka <kdudka@redhat.com>
* chars.c, file.c - Better handle unused results for things like mbtowc(), new
          macro IGNORE_CALL_RESULT.

2009-12-01 Chris Allegretta <chrisa@asty.org>
        * global.c (shortcut_init) - Remove redundant entries for ^Y/^V reported by
          Christian Weisgerber.
        * doc/man/nanorc.5 - Fix typo in Meta documentation, reported by gibboris@gmail.com.

2009-11-29 David Lawrence Ramsey <pooka109@gmail.com>
        * global.c (shortcut_init) - Add support for ^P and ^N in the help menu.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4452 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-12-02 03:24:18 +00:00
Chris Allegretta
cb9a5bed8e GNU nano 2.2.0 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4450 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-30 05:26:30 +00:00
Chris Allegretta
b43f6912f3 2009-11-29 David Lawrence Ramsey <pooka109@gmail.com>
* global.c: Fix replace and insert file initializations for proper compilation options.
        * nano.c (do_suspend): Update comments to reflect actual code path, bad Chris and thanks for 
          noticing Jordi.   
        * configure.ac: Fix typos



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4449 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-29 06:24:10 +00:00
Chris Allegretta
5a018f0d3a 2009-11-29 Chris Allegretta <chrisa@asty.org>
* prompt.c (get_prompt_string) - Universally handle help key when is disabled.  Fixes Savannah
          bug 28117 by David Lawrence Ramsey <pooka109@gmail.com>.
        * chars.c, files.c: Add junk vars to silence the compiler.  Sigh.

2009-11-29 David Lawrence Ramsey <pooka109@gmail.com>
        * Change several *chars to const char, additional cleanups and casts to make compilers happier.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4448 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-29 06:13:22 +00:00
Chris Allegretta
752830573a * doc/dyntax/makefile.nanorc - Sample Makefile highlighting based on wiki.linuxhelp.net version.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4447 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-28 04:11:04 +00:00
Chris Allegretta
daaf468c93 2009-11-27 Chris Allegretta <chrisa@asty.org>
* nano.c (do_suspend): Don't clear the screen but do move the cursor down to the last line
          first in an effort to not corrupt the screen, which contradicts Pico but is consistent
          with almost all other text editors.  Fixes Savannah bug 28110/Debian bug 460510
          reported by Tim Connors <reportbug@rather.puzzling.org>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4446 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-28 03:01:30 +00:00
Chris Allegretta
dcf5cbbf6a * rcfile.c (parse_rcfile), initialize size argument to getline(), fixes crash on FreeBSD
reported by Eitan Adler <eitanadlerlist@gmail.com>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4445 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-27 05:09:56 +00:00
Chris Allegretta
3b830ee194 2009-11-26 Chris Allegretta <chrisa@asty.org>
* winio.c (edit_scroll): Adjust for long lines when scrolling.                    



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4444 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-27 03:04:59 +00:00
Chris Allegretta
d753efdb55 2009-11-26 Jordi Mallach <jordi@gnu.org>
* doc/man/*: Update all man pages to escape unescapred hyphens.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4443 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-27 02:50:12 +00:00
Chris Allegretta
c9199e9e9a Simplify logic in do_down() since we now have maxrows to rely on.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4442 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-26 18:23:00 +00:00
Chris Allegretta
e2df2c899d 2009-11-24 Chris Allegretta <chrisa@asty.org>
* move.c (do_page_up, do_page_down): Make these functions work better with soft
          line wrapping. 
        * winio.c (compute_maxrows): Make maxrows calculation more accurate when all lines are > COLS.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4441 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-24 17:15:53 +00:00
Chris Allegretta
c82f038855 Part 2 of David's fixes for David's bug 71 fix
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4440 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-22 23:23:31 +00:00
Chris Allegretta
8b6f6fcc1b 2009-11-22 Chris Allegretta <chrisa@asty.org>
* nano.c (main): Allow edit_refresh_needed to take effect when using --enable-tiny
          (fixes Savannah bug 28076 reported by David Lawrence Ramsey).

2009-11-22 David Lawrence Ramsey <pooka109@gmail.com>
        * nano.c (move_to_filestruct): Fix bug 71 (cut at top of line recenters)
        * Fix compilation with --enable-tiny



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4439 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-22 21:35:56 +00:00
Chris Allegretta
0bff84ef9c 2009-11-22 Mike Frysinger <vapier@gentoo.org>
* doc/syntax/gentoo.nanorc: Tweak comment highlighting.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4438 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-22 16:36:53 +00:00
Chris Allegretta
6277f59d24 Back to SVN!
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4437 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-22 02:52:23 +00:00
Chris Allegretta
6c3d886424 GNU nano 2.1.99pre2 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4435 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-22 02:49:39 +00:00
Chris Allegretta
879dfbaf40 * prompt.c (update_statusbar_line): Set statusbar_pww when updating the line.
Fixes Savannah bug 24957 by Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4434 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-21 17:12:28 +00:00
Chris Allegretta
e9dee887a9 2009-11-21 Chris Allegretta <chrisa@asty.org>
* rcfile.c: Add unbinding keyword, fixes Savannah bug 22852 reported by frankd.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4433 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-21 16:26:59 +00:00
Chris Allegretta
123110c5dc 2009-11-19 Chris Allegretta <chrisa@asty.org>
* nano.c (die_save_file) Try nd match the permissions of the file we were
          editing but only make a minimal effort to do so. Fixes Savannah bug 27273     
          reported by Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4432 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-20 05:09:12 +00:00
Chris Allegretta
cbba77558e Typo fix part 2, noticed by j.mader@gmail.com.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4431 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-18 22:10:13 +00:00
Chris Allegretta
e350d7a52a Back to svn, oops.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4430 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-18 21:34:09 +00:00
Chris Allegretta
16e07d5878 2009-11-18 Adrian Bunk <bunk via Savannah>
* nano.c (main) - Allow --fill and --nowrap to override nanorc entries and each other
          on the command line.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4429 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-18 12:39:47 +00:00
Chris Allegretta
8c1edd17e3 Further fixes, also fix some page/up down issues where we go way off course.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4428 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-16 04:28:40 +00:00
Chris Allegretta
fc48347fb8 2009-11-15 Chris Allegretta <chrisa@asty.org>
* winio.c (edit_refresh): Always computer maxsize regardless of whether smooth scrolling
          is enabled.  Fixes Savannah bug 28024 by Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4427 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-16 00:15:45 +00:00
Chris Allegretta
2cd2d4b9ae GNU nano 2.1.99pre1 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4425 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-15 06:20:21 +00:00
Chris Allegretta
533b9fa827 * files.c (do_writeout) - Only mention file modification if we're writing the same
file we originally opened.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4424 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-14 20:06:24 +00:00
Chris Allegretta
f9d4fd3755 2009-11-14 Chris Allegretta <chrisa@asty.org>
* move.c (do_first_line, do_last_line): Just set edit_refresh_needed rather than 
          get messy.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4423 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-14 19:57:38 +00:00
Chris Allegretta
f55ada727e * nano.c (do_mouse): Fix mouse support not working with soft wrapping. Fixes
Savannah bug 27549 reported by Hannes Schueller.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4422 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-13 20:38:32 +00:00
Chris Allegretta
99c8d40db1 2009-11-13 Chris Allegretta <chrisa@asty.org>
* winio.c: Add new static maxsize to be able to easier calculation with
          softwrap.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4421 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-13 13:48:56 +00:00
Chris Allegretta
6f08332741 2009-11-11 Chris Allegretta <chrisa@asty.org>
* winio.c: Large tweaking of cursor and text display based on COLS not COLS - 1,
          due to finally understanding that display_string wasn't being called properly
          when softwrap was enabled.  Fixes Savnnah bug 27603, Return key doesn't scroll
          viewport reported by Hannes Schueller.
        * - Fix size_t formatting issues with -pedantic by converting vals to long unsigned
          for printing.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4420 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-11 06:00:33 +00:00
Chris Allegretta
a60910cc54 Better fix, remove unneeded closecode variable and update bug credit.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4419 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-10 03:44:12 +00:00
Chris Allegretta
7be32046b0 2009-11-09 Chris Allegretta <chrisa@asty.org>
* files.c (read_file): - Remove debugging messages from file load  



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4418 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-10 02:46:17 +00:00
Chris Allegretta
795be590d5 2009-11-07 Chris Allegretta <chrisa@asty.org>
* nano.h - Add bogus value at begin of flags enumeration because it
          causes casesens rcfile option to misbehave, reported by Helmut 
          Jarausch <jarausch@igpm.rwth-aachen.de>



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4417 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-07 16:56:17 +00:00
Chris Allegretta
3aad8ab9aa * rcfile.c - Add in specific check for UNDOABLE and fix declaration as
to what flag it toggles.  Fixes undo mode being able to be called from
          the rc file, reported by Helmut Jarausch <jarausch@igpm.rwth-aachen.de>



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4416 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-03 19:31:17 +00:00
Chris Allegretta
1d461475ce 2009-11-03 Chris Allegretta <chrisa@asty.org>
* nano.h - Fix comma at end of enumerator list which angers -pedantic.

2009-11-03 Mike Frysinger <vapier@gentoo.org>
        * files.c - Move up is_file_writable() to stop implicit definition complaints.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4415 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-11-03 18:47:39 +00:00
Chris Allegretta
a535cecd77 2009-10-27 Chris Allegretta <chrisa@asty.org>
* browser.c (browser_init): Set column width to something sane when 
          initializing in a directory with no file entries.  Fixes Savannah
          bug 24163 found (and initial patch) by Paul Wise.  



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4414 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-10-27 04:09:27 +00:00
Chris Allegretta
d233e7e240 back to svn, and:
* winio.c: Clean up some unused variables from the soft wrapping code.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4413 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-09-15 04:51:09 +00:00
Chris Allegretta
1f218fa859 GNU nano 2.1.11 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4411 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-09-15 03:50:17 +00:00
Chris Allegretta
91e05e64a0 Add softwrap and undo into the sample .nanorc.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4410 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-09-14 21:38:53 +00:00
Chris Allegretta
35afab5eba 2009-09-12 Chris Allegretta <chrisa@asty.org>
* winio.c (edit_update) - properly update edittop when using soft wrapping.
          Fixes lack of centering for searching for off-screen answers, found by
          Hannes <mr_creosote@mutantwatch.de>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4409 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-09-13 04:50:44 +00:00
Chris Allegretta
bce7d404d9 2009-09-03 Chris Allegretta <chrisa@asty.org>
* global.c (shortcut_init): Fix up/down keys not responding in the file browser,
          discovered by Hannes <mr_creosote@mutantwatch.de>.
        * move.c (do_up) - Fix another scrolling issue with softwrap when the
          cursor is beyond COLS, discovered by Hannes <mr_creosote@mutantwatch.de>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4408 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-09-03 23:29:14 +00:00
Chris Allegretta
f8f9027295 2009-09-02 Chris Allegretta <chrisa@asty.org>
* Attempt to check file writability and emit a warning on the status bar
          if nano doesn't think the file can be written to.  Feature originally
          requested by Damien Jolders <madamien@skullsquad.com> et al.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4407 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-09-03 05:45:13 +00:00
Chris Allegretta
5687c3dfa6 Fix regular scrolling with softwrap enabled too. Stop trying to be clever and just
figure out if we need to bail and call edit_refresh().



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4406 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-09-03 02:48:35 +00:00
Chris Allegretta
139934a236 2009-08-29 Chris Allegretta <chrisa@asty.org>
* Fix more soft wrapping issues, particularly with soft scrolling,
          discovered by Hannes <mr_creosote@mutantwatch.de>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4405 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-08-30 03:50:16 +00:00
Chris Allegretta
3de025f8f4 2009-08-19 Chris Allegretta <chrisa@asty.org>
* Fix issue with soft wrapping not displaying the last character of each line,
	  fixed bug discovered by Hannes <mr_creosote@mutantwatch.de>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4404 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-08-19 05:38:07 +00:00
Chris Allegretta
308a7b029d 2009-08-17 Mike Frysinger <vapier@gentoo.org>
* doc/syntax/(gentoo|sh|tcl).nanorc: Fix problems with empty regexes on POSIX.
	  Fixes Savannah bug 27175.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4403 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-08-18 02:55:22 +00:00
Chris Allegretta
05417a2444 2009-08-17 Chris Allegretta <chrisa@asty.org>
* Initial soft line wrapping implementation.  Command line flags
          -$ or --softwrap.
        * nano.c, text.c: Clean up some fprintf warnings in debug mode due to printing
          a size_t without using the zd specifier.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4402 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-08-17 07:52:10 +00:00
Chris Allegretta
13dde2bda4 Back to SVN version
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4401 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-08-15 02:54:35 +00:00
Chris Allegretta
a48507d32a 2009-08-13 Chris Allegretta <chrisa@asty.org>
* New global flag implementation courtesy of Adam Wysocki <gophi@arcabit.pl>, allows
 	  previous undo flag to be implemented consistent with other flags.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4400 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-08-14 03:18:29 +00:00
Chris Allegretta
7f38820fba GNU nano 2.1.10 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4398 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-07-28 05:08:35 +00:00
Chris Allegretta
42726f74cc 2009-07-27 Chris Allegretta <chrisa@asty.org>
* text.c (undo_cut, redo_cut): Don't actually try and undo/redo an empty cut, i.e. the magicline. 
	  Fixes crash on cutting last line discovered by Eitan Adler <eitanadlerlist@gmail.com>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4397 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-07-27 04:16:44 +00:00
Chris Allegretta
0a10e20eec Add in rcfile support for undo since it would be bad to overly punish the masochists who want to try it out and hopefully submit bug reports.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4396 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-07-12 06:13:36 +00:00
Chris Allegretta
ad37e67dd2 2009-07-11 Chris Allegretta <chrisa@asty.org>
* nano-regress: Small tweaks
	* Change undo code to off unless unabled via a command line option (-u/--undo).  Until this code
	  stabilizes this is the only responsible way to treat it.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4395 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-07-12 03:36:58 +00:00
Chris Allegretta
a4c2b99e40 More wrapping redo fixes. Just make do-wrap() undo aware.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4394 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-04-29 22:34:27 +00:00
Chris Allegretta
8b9fb360c2 Comimt point for roll-back of latest undo/redo of split changes.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4393 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-04-29 04:43:58 +00:00
Chris Allegretta
e061a0d604 Add undoing check for do_enter so redo doesn't blow up.
Hate to piecemeal these fixed but system unstability is teh suck.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4392 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-04-25 03:31:30 +00:00
Chris Allegretta
b843a51b79 Add undo for line break via enter, separate from line wrap
Change message for line split to line wrap, since split ~= break



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4391 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-04-21 05:34:08 +00:00
Chris Allegretta
df543e78df - Remove a debug line I left in
- Fix undo line split uglyness.  Still not perfect but switching work envs.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4390 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-04-12 06:13:16 +00:00
Chris Allegretta
12ba55732f First pass at fixing the line splitting undo since it's currently broken beyond belief.
I believe more is broken but committing will motivate me to get closer to a real fix :)



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4389 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-03-26 01:01:48 +00:00
Chris Allegretta
55ca1028ac 2009-03-08 Chris Allegretta <chrisa@asty.org>
* TODO - Break out some targets for various features into 2.2
          and 2.4 series for things which are feasible.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4388 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-03-09 02:04:40 +00:00
Chris Allegretta
5a3464b57b 2009-02-28 Chris Allegretta <chrisa@asty.org>
* configure.ac: Add check for whether _XOPEN_SOURCE_EXTENDED is needed for 
          curses to work w/color.  Fixes compilation on HP-UX with older GCC, 
          reported by jay.krell@cornell.edu.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4387 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-03-01 00:50:19 +00:00
Chris Allegretta
fb6446d826 2009-02-23 Eitan Adler <eitanadlerlist@gmail.com>
* doc/man/Makefile.am: Fix make variable substitution to be more portable

2009-02-23 Chris Allegretta <chrisa@asty.org>
	* doc/man/fr/Makefile.am: Add groff check fix to fr files.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4386 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-25 05:06:05 +00:00
Chris Allegretta
f86fa86089 2009-02-23 Chris Allegretta <chrisa@asty.org>
* rcfile.c (parse_keybinding) - Define a var before tryung to use it.  Whoops!
	* fix some redefinitions causing compiler warnings, from Eitan Adler.  Other
	  (hopefully) fixes for uncasted malloc()s, reported by the same.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4385 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-25 04:32:15 +00:00
Chris Allegretta
5ba7a93b1a back to SVN, and add header on ChangeLog since I forgot (and its not worth fixing for the release)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4384 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-17 04:31:04 +00:00
Chris Allegretta
fbdc8b9b92 GNU nano 2.1.9 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4382 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-17 04:10:37 +00:00
Chris Allegretta
97ba02d4f1 Fixes for nano-regress and regress fix on nano.c for compilation with slang
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4381 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-17 03:05:17 +00:00
Chris Allegretta
86988b5026 Oh, reset multi data in search.c;do_replace_loop() too.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4380 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-17 02:01:03 +00:00
Chris Allegretta
b71cf301da Okay that will not work. Revert forcing reset_multis on !viewok as it's too expensive
for things like deleting text.  Will have to go back and force inside functions.
Add check in reset_multis for CNONE type since that's slowing us down and is dumb
to leave out.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4379 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-16 23:06:09 +00:00
Chris Allegretta
9555e1d118 2009-02-16 Chris Allegretta <chrisa@asty.org>
* Add new argument to reset_multis for force redraws without attempting to
          guess whether we need to, force updates when running a non-viewok function.
          New utility function color.c:reset_multis_for_id().  Fixes e.g. incorrect
          highlighting when cutting text.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4378 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-16 21:04:00 +00:00
Chris Allegretta
7aec392993 2009-02-15 Chris Allegretta <chrisa@asty.org>
* configure.ac, doc/man/Makefile.am - Add check for HTML output support in GNU
          groff.  Fixes Savannah bug #24461: build traps on groff.  Also, add installation
          of html-ized man pages to $datadir/nano/man-html, since we should probably
          install files we went to all the trouble of generating.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4377 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-15 19:16:18 +00:00
Chris Allegretta
e027fc2edd 2009-02-14 Chris Allegretta <chrisa@asty.org>
* nano.c (precalc_multicolorinfo) - Add debugging so we have a better clue if further
          issues arise.   Also start at the beginning of later lines when trying to match the
          end of a multi-line regex.  Fixes more overly aggressive highlighting found by 
          Mike Frysinger.  Finally, advance to the match end for performance.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4376 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-15 02:40:16 +00:00
Chris Allegretta
8257bf145e 2009-02-11 Chris Allegretta <chrisa@asty.org>
* nanorc.c (parse_include): Do call real_dir_from_tilde() on included
          files in .nanorc, but still avoiding bug #25297.  Fixes ~ and ~user
          specifications for nanorc include files, as reported by Eitan Adler.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4375 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-11 05:45:57 +00:00
Chris Allegretta
a30eb78006 2009-02-09 Chris Allegretta <chrisa@asty.org>
* New option -q, --quiet, rcfile option "quiet" implemented.  Skips printing
          errors about the rcfile and asking user to press enter.  Also, nano should
          now only ask for one enter press when there is an error when not using -q.
          Based on discussion between Eitan Adler and Mike Frysinger.
        * rcfile.c (parse_keybinding) -  Significant cleanups and fixes for
          detecting and reporting errors in key bindings code.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4374 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-09 04:03:20 +00:00
Chris Allegretta
35686daf9d * Make reset_multidata reset more lines, since contrary to previous problems the
syntax highlting is now too *un*ambitious, causing display glitches when
          deleting a regex boundary.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4373 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-08 18:00:44 +00:00
Chris Allegretta
04fbfaae51 2009-02-08 Chris Allegretta <chrisa@asty.org>
* Add more multidata initliazers for new buffers and 'magic lines'.  Fixes segfaults
          with syntax highlighting in new buffers, initially reported by Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4372 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-08 17:45:21 +00:00
Chris Allegretta
5b695cef46 back to SVN
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4371 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-08 05:12:26 +00:00
Chris Allegretta
1658d4d14f GNU nano 2.1.8 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4369 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-08 04:12:07 +00:00
Chris Allegretta
5cf95c45d3 Mark bug 80 as fixed
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4368 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-07 15:24:45 +00:00
Chris Allegretta
56a295bc90 Renumber multidataflags to not start at 0 in case it confuses alloc_multidata_if_needed().
Add alloc_multidata_if_needed() call in edit_draw as the last defense against a crash.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4367 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-07 14:48:30 +00:00
Chris Allegretta
803379c52c Add shortcut for CBEGINBEFORE case to edit_draw()
Added bug 80 to document segfault when editing near COLS



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4366 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-07 07:09:31 +00:00
Chris Allegretta
4522ca2d1b 2009-02-06 Chris Allegretta <chrisa@asty.org>
* rcfile.c (parse_include): Abort on being unable to open an included rcfile.  Fixes
          Savannah bug 25490, nanorc: "include"ing a file which doesn't exist causes nano to segfault.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4365 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-07 00:01:40 +00:00
Chris Allegretta
fd265af15a 2009-02-05 Chris Allegretta <chrisa@asty.org>
* More color syntax speedups:  Determine in reset_multis() whether we really need to call
          edit_refresh().  Additional global var edit_refresh_needed() to hopefully reduce  
          repeated calls to the function.  New helper funcs reset_multis_before() and 
          reset_multis_after().



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4364 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-06 03:41:02 +00:00
Chris Allegretta
58a802fa63 Fix for precalc_multicolorinfo: make sure we malloc for all the lines we're precalculating, duh.
New utility func alloc_multidata_if_needed().



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4363 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-04 19:50:23 +00:00
Chris Allegretta
364763f4d1 2009-02-02 Chris Allegretta <chrisa@asty.org>
* New color precalculation code for mult-line regexes.  New function precalc_multicolorinfo(),
          new structure multidata for keeping track of where regexes start/stop.  More 
          performance improvements forthcoming.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4362 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-03 05:05:58 +00:00
Chris Allegretta
ecc245ccca Fix comiplation issues with --enable-tiny --enable-nanorc (?!)
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4361 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-02-01 00:04:42 +00:00
Chris Allegretta
61f5c55f7b 2009-01-29 Chris Allegretta <chrisa@asty.org>
* nano.c (move_to_filestruct) - properky initialize new fileage for multiswatching, sigh.
	  Fix cut sefaults discovered by Mike Frysinger.
		 


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4360 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-31 23:36:00 +00:00
Chris Allegretta
30f278f4a8 - Fix compliation breakage with --disable-justify, reported by Mike Frysinger
- Add --disable-justify to nano-regress so I stop missing that



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4359 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-31 16:13:03 +00:00
Chris Allegretta
75dfa8ad42 Make changelog message less harsh as terminal state shoudl now be fine on exit.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4358 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-30 17:38:23 +00:00
Chris Allegretta
b0f0b7f471 Pull stdin reading out into a function, add ^c interrupt message on stderr.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4357 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-30 17:37:44 +00:00
Chris Allegretta
25d459aa64 2009-01-29 Chris Allegretta <chrisa@asty.org>
* nano.c (main): Add support for nano acting like a pager when invoked with - as first   
          file argument.  Not yet perfect (garbles screen state on exit) but it's something. 



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4356 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-30 08:34:27 +00:00
Chris Allegretta
2d90cf324e 2009-01-28 Davide Pesavento <davidepesa@gmail.com>
* doc/syntax/gentoo.nanorc: Updates from David and Mike Frysinger.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4355 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-28 18:32:33 +00:00
Chris Allegretta
2d1bdd0dd6 Fix regression bugs introduced with other recent bugs disguised as features.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4354 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-28 05:11:57 +00:00
Chris Allegretta
2823c99e72 2009-01-25 Chris Allegretta <chrisa@asty.org>
* files.c (open_file), nanorc.c (parse_include): Don't get_full_path on     
          included rc files, due to it potentially impacting the ability
          to read files in nano's cwd().  Fixes Savnanah bug #25297 reported by Mike 
          Frysinger)



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4353 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-26 08:48:22 +00:00
Chris Allegretta
019998a877 Fix reset_multis undefined call when not using color.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4352 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-26 07:55:01 +00:00
Chris Allegretta
d47d8cd450 * First pass at some caching of caching color info. Right now it's only for
multi-line regexes but this may not be enough to increase performance.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4351 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-25 07:25:17 +00:00
Chris Allegretta
0dc26dcd09 2009-01-24 Chris Allegretta <chrisa@asty.org>
* Add interruptability to search functions.  New functions enable_nodelay and
          disable_nodelay and changes to the routines to handle checking for pending
          searches.  Fixes Savnnah bug 24946: Need interrrupt for search.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4350 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-24 22:40:41 +00:00
Chris Allegretta
a117163a4c 2009-01-19 Chris Allegretta <chrisa@asty.org>
* Change funcion definitions to shorts instead of (void *)s.  New mapping function
          iso_me_harder_funcmap().  Fixes compilation complaints with -pedantic, 
          reported by Eitan Adler <eitanadlerlist@gmail.com>.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4349 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2009-01-19 19:10:39 +00:00
Chris Allegretta
4630102f5b Change vesion back to SVN. How did I forget to do that during release. Tisk.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4348 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-12-29 19:42:57 +00:00
Chris Allegretta
2f2f4d3ca9 GNU nano 2.1.7 release.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4346 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-11-10 06:33:12 +00:00
Chris Allegretta
2d189ae46d Add tiny check around new mtime check code. Fixes certain compile time options.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4345 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-22 22:11:46 +00:00
Chris Allegretta
95add8dabe 2008-10-20 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Add check for file modification when saving
          the file so the user can at least know they may be blowing away changes.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4344 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-21 10:20:07 +00:00
Chris Allegretta
973addcde8 * global.c (shortcut_init), search.c (search_init): Fix add_to_sclist for ^W^T so
invalid messages will display properly.  Fixes Savannah bug 24507.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4343 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-15 01:25:25 +00:00
Chris Allegretta
4e12cb8455 Get rid of some unused variables with -Wall
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4342 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-14 19:55:34 +00:00
Chris Allegretta
2a044ee3ea 2008-10-14 Chris Allegretta <chrisa@asty.org>
* nanorc.5: Fix redo man page entry and update explanation, reported by
          Eitan Adler <eitanadlerlist@gmail.com>



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4341 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-14 16:46:58 +00:00
Chris Allegretta
c81cf52cf2 Eliminate linescut variable from undo structure as its an unneeded pain in the ass.
Also initialize to_end, because for some reason it seems to be not getting set even when
type == CUT in add_undo (?!)



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4340 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-14 04:34:56 +00:00
Chris Allegretta
c84e765b8e 2008-10-13 Chris Allegretta <chrisa@asty.org>
* Remove CUTTOEND as an undo type as it's unneeded, fix u->to_end logic in undo struct.
        * undo.c (update_undo): Don't free cutbuffer if NULL, fix for Savannah bug #24499



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4339 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-14 01:14:12 +00:00
Chris Allegretta
5c1c143ed2 2008-10-04 Chris Allegretta <chrisa@asty.org>
* cut.c (Add_undo): Save last cut undo information so it can be used for next uncut, fixes
          Savannah bug 24183.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4338 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-04 11:10:11 +00:00
Chris Allegretta
3c4e99137d Back to SVN
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4337 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-03 22:35:17 +00:00
Chris Allegretta
8f0a921fc1 GNU nano 2.1.6 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4335 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-03 22:20:43 +00:00
Chris Allegretta
513157dfa0 2008-10-03 Pascal Gentil <pascal.gentil@univ-rennes1.fr>
* fortran.nanorc: Sample python syntax highlighting file



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4334 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-03 21:00:35 +00:00
Chris Allegretta
fa195e6d5d 2009-09-30 Dirkjan Ochtman <dirkjan@ochtman.nl>
* python.nanorc: Small python syntax update



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4333 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-01 00:55:13 +00:00
Chris Allegretta
215eb3645e 2008-09-30 <bluestorm_dylc@hotmail.com>
* ocaml.nanorc: Sample OCaml syntax highlighting file

2008-09-30 Dave Geering <dgeering@toshiba-tap.com>
       * objc.nanorc: Sample Objective-C Syntax Hightlighting file



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4332 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-10-01 00:49:19 +00:00
Chris Allegretta
83c3f951f6 make --enable-tiny disable the new enabled-by-default options as that's presumably the expected behavior
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4331 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-09-30 16:47:57 +00:00
Chris Allegretta
025548ad29 * configure.ac: Change extra, multibuffer, color and rcfile to default to enabled
I'm sure no one will complain about this :-P



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4330 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-09-30 15:30:51 +00:00
Chris Allegretta
8227d419bb 2008-09-30 Chris Allegretta <chrisa@asty.org>
* python.nanorc, ruby.nanorc: Add header lines for python and ruby as well



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4329 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-09-30 14:30:33 +00:00
Chris Allegretta
f30c1390c7 2008-09-21 Chris Allegretta <chrisa@asty.org>
* rcfile.c, color.c, nano.h: Add new capability for matching a syntax type by the "header" (1st line)
          of a file being edited.  Based on Savannah bug 24197 and inital proof of concept by Dave Geering
          <dgeering@toshiba-tap.com>



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4328 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-09-21 23:02:30 +00:00
Chris Allegretta
b549f3761a 2008-09-16 Chris Allegretta <chrisa@asty.org>
* text.c: Add support for undoing a text uncut.  Split out the undo and redo of a text cut
          in order to avoid code duplication.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4327 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-09-16 21:35:19 +00:00
Chris Allegretta
e137f12e5e * nano.c: Do call disable_signals at startup regardless, since under cygwin we can't generate
^C without it.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4326 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-09-06 06:52:47 +00:00
Chris Allegretta
86cab67339 Back to svn!
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4321 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-30 21:59:23 +00:00
Chris Allegretta
566635ec16 GNU nano 2.1.5 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4319 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-30 21:40:33 +00:00
Chris Allegretta
95a9de0d3f Move the wordbounds check down so it will happen if either --enable-all or --enable-color
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4318 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-30 21:32:55 +00:00
Chris Allegretta
1d77823f79 * global.c, help.c, browser.c, files.c, proto.h: Fix several compipation and programmatic
issues with --disable-help, especially that do-writeout was treating ^G the same as ^M.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4317 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-30 21:00:00 +00:00
Chris Allegretta
874969be81 * nano-regress: New perl script to check for some of the more obvious issues with compilation
issues with certain configure options.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4316 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-30 20:33:32 +00:00
Chris Allegretta
6b83e5290c 2008-08-29 Chris Allegretta <chrisa@asty.org>
* configure.ac, color.c, rcfile.c, utils.c: 1st attempt at supporting systems which don't support
          GNU-style word boundaries.  New function fixbounds() to translate from GNU-style to
          BSD-style, autoconf option GNU_WORDBOUNDS.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4315 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-30 05:16:20 +00:00
Chris Allegretta
faeeb5bd7e 2008-08-28 Chris Allegretta <chrisa@asty.org>
* configure.ac, rcfile.c:  Add support for an alternate rcfilename at configure time.  Maybe this
          should become a command line option some day, but I don't see the need currently.  Start of   
          fix for Savannah bug #24128: Add nanorc support to win32 platform.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4314 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-28 06:13:05 +00:00
Chris Allegretta
dc7136a082 * text.c (do_enter): Fix issue when compiled with --enable-debug, fixes Savannah bug 24092.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4309 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-21 04:24:25 +00:00
Chris Allegretta
77bf1b5197 2008-08-21 Chris Allegretta <chrisa@asty.org>
* text.c: Change error messages where we may possibly get into a bad state and urge
          the user to save when this happens.  Originally by Benno Schulenberg <bensberg@justemail.net>



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4308 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-21 04:21:06 +00:00
Chris Allegretta
90ad8e20b9 2008-08-08 Magnus Granberg <zorry@ume.nu> / Adam Conrad <?>
* files.c: (write_file): Add needed flags to open() calls when writing out files.  Fixes Savannah bug
          #23827: Compilation fails with -D_FORTIFY_SOURCE=2



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4306 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-17 16:25:40 +00:00
Chris Allegretta
2cc58882f6 * files.c (write_file): Check exit code of fclose(), since in certain out of space conditions the OS will
happily report successful fwrite()s until you try and close the file.  Fix for Savannah bug
	  #24000: no free space on partition - nano claims successful write - file empty 



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4304 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-16 23:54:15 +00:00
Chris Allegretta
93f2ea1194 Back to svn.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4303 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-09 19:50:34 +00:00
Chris Allegretta
d2780eca94 GNU nano 2.1.4 release.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4301 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-09 10:25:22 +00:00
Chris Allegretta
80ea9c5de9 * text.c (add_undo): Fix check for multi-line cut check skips adding other new legit events.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4300 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-09 10:08:33 +00:00
Chris Allegretta
b08b38680d Re-add the skip_backup label since we do still need it in one case.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4299 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-09 09:31:33 +00:00
Chris Allegretta
5c27d723c9 * text.c (do_redo): Fix improperly restoring the text when redoing a line split.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4298 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-09 09:28:07 +00:00
Chris Allegretta
447f1b4b75 * files.c: Do not go on and attempt to write the main file if writing the backup file failed,
related to Savannah bug 24000.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4297 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-09 03:39:10 +00:00
Chris Allegretta
6f681c1be2 * text.c: Reset openfile-> to OTHER after an undo or redo so we don't mistakenly
mistakenly think this is an update when it's really an add.  Also
          Fix an extra ; after an if statement which makes nano try to free a struct which
          may be NULL 



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4296 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-08 03:02:03 +00:00
Chris Allegretta
a50d0e35f7 Back to SVN version
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4295 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-05 02:38:40 +00:00
Chris Allegretta
599c559b3c GNU nano 2.1.3 release
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4293 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-05 01:35:42 +00:00
Chris Allegretta
ea577874ef - Add redo of an insert
- Fix bug in fsfromlineno
- Tiny cleanups in undo



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4292 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-03 20:19:42 +00:00
Chris Allegretta
14c8620e0b - Change add_undo and current_undo to only take action arg, as openfilestruct arg is always openfile
- Add ability to undo a file/cmd insert, needed to add undoable flag to read_file and open_buffer as a result



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4291 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-03 04:48:05 +00:00
Chris Allegretta
3c1131a5b3 - Add very basic undo for text replace.
- Fix lots of warnings whe using -Wall
- Fix some comments



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4290 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-02 22:31:01 +00:00
Chris Allegretta
015c74093a Allow current undo code to compile with NANO_TINY
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4289 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-02 14:39:42 +00:00
Chris Allegretta
d31ddb789f Allow basic multi-^K cuts to be redone properly. Code getting uglier by the second.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4288 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-01 07:29:06 +00:00
Chris Allegretta
8f76112084 - When undoing a cut, set cutbuffer to NULL after freeing the current one
- When updating a normal consecutive ^K cut, bail from add_undo since it's not an add, and in update_undo free the old cutbuffer before copying it again.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4287 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-01 06:52:15 +00:00
Chris Allegretta
1f37c4514d When redoing a text add, actually copy the beginning of the line back!
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4286 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-01 04:11:57 +00:00
Chris Allegretta
91a1862eed Add undoing argument to do_cut_text as we don't want to be messing around with the undo contents when we're in the
middle of an undo.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4285 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-08-01 03:50:20 +00:00
Chris Allegretta
e418b694b6 * configure.ac: Add ncursesw dir to include path if lib detected
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4284 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-31 17:01:47 +00:00
Chris Allegretta
12dc8cae80 Commit back some undo/redo rewrites
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4283 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-31 04:24:04 +00:00
Chris Allegretta
0b499d465b Add xflags to undo struct so we can add extra info to the undo process (e.g. backspace vs delete)
Fix redo of a line join.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4282 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-14 07:18:22 +00:00
Chris Allegretta
fa406949ec Allow backspace to be bound to keys in .nanorc
Allow kdel to be rebound
Add note about rebinding kdel to backspace for those using OSX or PuTTY to connect to remote Linux machines in nanorc.sample.in

When undoing text deletes, move current_x to proper location



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4281 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-13 16:44:19 +00:00
Chris Allegretta
70859f4a5b Add ability to rebind the (still unfinished) undo and redo functions in case anyone is interested in testing it out early.
Add to nanorc.5 also.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4280 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-13 01:36:06 +00:00
Chris Allegretta
9fb13fb8f0 2008-07-11 Mike Frysinger <vapier@gentoo.org>
* doc/nanorc.sample.in: Include the updates files in the default sample nanorc.



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4279 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-12 02:52:08 +00:00
Chris Allegretta
274142cb10 Clean up some unused variables from old undo implementation.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4278 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-12 02:48:20 +00:00
Chris Allegretta
b8576780bf 2008-07-11 Fabian Groffen <grobian@gentoo.org>
* nano.c: Don't include langinfo.h if not using ENABLE_UTF8
          (Savannah patch 6565)



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4277 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-12 02:32:19 +00:00
Chris Allegretta
a9dea9859d 2008-07-11 Michael Haubenwallner <michael.haubenwallner@salomon.at>
* global.c: include proto.h earlier in file to fix AIX compilation
          (Savannah patch 6559)



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4275 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-12 02:20:16 +00:00
Chris Allegretta
a855fa2acc 2008-07-11 Michael Haubenwallner <michael.haubenwallner@salomon.at>
* global.c: include proto.h earlier in file to fix AIX compilation
          (Savannah patch 6559)



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4274 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-12 02:13:22 +00:00
Chris Allegretta
09b8124859 Savannah bug 23751: Segfault when viewing help using Japanese locale
Fix break_line crashing when using certain locales from Mitsuya Shibata



git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4272 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-12 01:54:49 +00:00
Chris Allegretta
07fcc4c973 Add beginning undo feature, since I want to start fixing bugs from savannah and don't want to manager another checking, and the code basically works for some operations.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4271 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-07-10 20:13:04 +00:00
Chris Allegretta
1347f22c95 Fix for 23733: search history broken with nano-2.1.1+
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4270 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-06-29 06:22:31 +00:00
Chris Allegretta
9015f187a5 Back to SVN
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4269 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
2008-06-25 03:42:28 +00:00
80 changed files with 27071 additions and 18830 deletions

6
BUGS
View File

@@ -1,6 +1,4 @@
** Open BUGS **
- Cutting the line at the top of the screen recenters to center (71)
- Many menu items are probably missing from the new backend (73)
** Fixed BUGS **
- Marked cutting sometimes leaves a newline in the file unintelligently,
@@ -143,6 +141,7 @@
- Trying to insert a file of 0 bytes will hang nano (70) [FIXED].
- Meta-space and ^Space are not yet handled in new backend code (77) [FIXED]
- F-keys do not work with new shortcut backend (72) [FIXED]
- Many menu items are probably missing from the new backend (73) [FIXED]
- Need a 'check-vitals-mapped' function to check that the end used didn't
unbind all the keys for exit or cancel before starting up the editor (74) [FIXED]
- Browser and prompt code still implement old switch on raw key input instead
@@ -154,6 +153,9 @@
page up/down, insert, and unbinds all other control and F keys for it,
nano will do the wrong thing when reading the key which is normally
assigned to it (79 - may not be worth fixing) [FIXED]
- Segfault editing at COLS presumably due to new color syntax
highlighting (80) [FIXED]
- Cutting the line at the top of the screen recenters to center (71) [FIXED]
$Id$

559
ChangeLog
View File

@@ -1,3 +1,562 @@
GNU nano 2.2.5 - 2010.08.05
2010-08-04 Lauri Kasanen <curaga@operamail.comcuraga@operamail.com>
* doc/syntax/mgp.nanorc: New Magicpoint syntax highlighting definition
2010-08-04 Peter <exodus@savannah>
* doc/syntax/tex.nanorc: No longer highlight escaped comments
2010-06-20 Chris Allegretta <chrisa@asty.org>
* New rc file option allow_insecure_backup, allows the previous security
fixes for backup files to be overridden if you're really positive
you want to. Fixes Savannah bug 29732 by Brian Szymanski <skibrianski>.
2010-05-23 Chris Allegretta <chrisa@asty.org>
* files.c (write_file): Don't even try to chown() the backup
file unless we're root, since it's probably going to fail if
we're editing a file we don't own. Fixes Savannah bug
29514: [nano 2.2.2] backup should ignore chown errors.
GNU nano 2.2.4 - 2010.04.15
2010-04-07 Chris Allegretta <chrisa@asty.org>
* doc/man/nano.1,nanorc.5: Remove the backup file warnings now
that a sufficient security fix exists for the backup file code.
2010-04-14 Chris Allegretta <chrisa@asty.org>
* text.c (do_alt_speller): Skip invoking the alt speller if the file size
is 0 bytes. Fixes Savannah bug 29393 reported by Mike Frysinger.
* files.c (wirte_file): Don't set current_stat when tmp == TRUE, check
whether current_stat is set when trying to use it, and don't do the
modification check if the filename changed, since we have no way
of knowing about it in that case. Fixes Savannah bug 29392, reported
by Mike Frysinger. [CVE-2010-1160]
2010-04-13 Felipe Bugno <necron@bol.com.br>
* doc/syntax/cmake.nanorc: Added cmake syntax highlighting file.
2010-04-09 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Better security fixes for backup file writing,
mangled from submission by Dan Rosenberg <dan.j.rosenberg at gmail>
[CVE-2010-1161]
2010-04-08 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Previous fixes should not cause a crash
when saving a new file. Discovered by Mike Frysinger <vapier@gentoo.org>.
2010-04-07 Chris Allegretta <chrisa@asty.org>
* doc/man/nano.1,nanorc.5: Add warnings about using backup
mode as root due to the Dan Rosenberg security analysis.
2010-04-02 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Expand modification check to include both the
original file's device ID and inode number as reasons to warn the
user that the file has been modified. Also abort on writing a backup
file when its owner doesn't match the edited file. Based on security
analysis on nano by Dan Rosenberg. [CVE-2010-1160]
2010-03-21 Chris Allegretta <chrisa@asty.org>
* nano.c (page_stdin et al): Don't attempt to reset/reopen the terminal
settings when reading stdin if it was aborted with SIGINT. May fix Savannah
bug 29114 reported by Mike Frysinger.
2010-03-21 Mike Frysinger <vapier@gentoo.org>
* doc/syntax/c.nanorc: Add additional support for #include_next and #pragma
2010-03-21 Chris Allegretta <chrisa@asty.org>
* move.c (do_page_up, do_page_down()): Explicitly set current_y to 0 when paging
up when not in smooth scroll mode, as previous fixes would otherwise cause
the cursor to not really be moved to the stop of the screen.
2010-03-07 Chris Allegretta <chrisa@asty.org>
* configure.ac, nano.c (handle_sigwinch): Create check for whether LINES and
COLS can safely be redefined. Fixes compilation issues with cygwin, and likely
with newer versions of ncurses, fixes Savannah bug 28984 repoted by Andy Koppe
and Eric Oliver via mailing list.
* winio.c (get_mouseinput) - fix stray semicolon in code, also reported in
bug 28984.
GNU nano 2.2.3 - 2010.02.11
2010-01-28 Chris Allegretta <chrisa@asty.org>
* move.c (do_page_up, do_page_down): Fix for smooth mode not preserving cusor
position. Part one of fix for Savannah bug 21178 by Mike Frysinger.
GNU nano 2.2.2 - 2010.01.17
2010-01-17 Chris Allegretta <chrisa@asty.org>
* nano.c (main), prompt.c (do_statusbar_input): Handle problems with an unmapped
function due to key rebinding, fixes crashes on FreeBSD repoted by Eitan
Adler <eitanadlerlist@gmail.com>.
2010-01-14 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Fix for crash / incorrect external modification warning
due to earlier fix in r4467.
2010-01-12 Chris Allegretta <chrisa@asty.org>
* move.c (do_page_up, do_page_down): Fix issues with not enough scrolling down/up
and cursor centering.
* winio.c (edit_scroll): Remove lots of needless checking of line length for
soft wrapping code.
* winio.c (edit_update) - Remove extra code for when updating with old_current outside
of the new buffer boundary and centering issues.
2010-01-05 Tito <farmatito@tiscali.it>
* search.c (update_history): Fix bad length check causing search crash on armel platform.
2010-01-04 Chris Allegretta <chrisa@asty.org>
* winio.c: edit_update, edit_redraw: Fix search not scrolling to the middle of the screen
(reported by alpha@qzx.com) and places where we rely on maxrows but should not.
2009-12-26 Jordi Mallach <jordi@gnu.org>
* doc/man/nano.1: Avoid a groff warning by prepending a zero-width
space to a line starting with '.
2009-12-22 Chris Allegretta <chrisa@asty.org>
* files.c (write_file): Fix compatibility with previous stat fix and tiny mode.
2009-12-22 David Lawrence Ramsey <pooka109@gmail.com>
* global.c: Add new strings for forward/back in the file browser. New variables
nano_forwardfile_msg and nano_backfile_msg.
2009-12-20 Chris Allegretta <chrisa@asty.org>
* files.c (is_file_writable): remove assert check for f, since it's not
initialized at the time. Fixes Savannah bug 28309, reported by Zoltan Kovacs.
2009-12-20 Brian Szymanski <skibrianski via Savannah>
* src/files.c (write_file): Check stat struct exists, and if not use just obtained stat data.
Fixes Ubuntu bug 471568, "reproducible crash in nano on trying to save to a file
different than the one specified on the command line".
2009-12-15 Chris Allegretta <chrisa@asty.org>
* doc/nanorc.sample.in - Remove erroneous 'set suspendenable' as it's actually a
key binding (e.g. 'bind M-Z suspendenable all') and not a settable flag. Fixes
Savannah bug 28299 reported by Mike Frysinger.
GNU nano 2.2.1 - 2009.12.12
2009-12-12 Chris Allegretta <chrisa@asty.org>
* text.c (do_delete), nano.c (do_output): Add check for length of current line
before and after adding/deleting text, and do full refresh if it is now
a different multiple of COLS. Also get rid of superfluous do_refresh
vars now that we have edit_refresh_needed.
2009-12-09 David Lawrence Ramsey <pooka109@gmail.com>
* global.c (shortcut_init), browser.c (do_browser): Fix M-W not being bound to
research in either main menu or browser.
2009-12-09 Chris Allegretta <chrisa@asty.org>
* files.c (read_file) - Add parameter for whether we should even try to check
file writability, as the message is useless when we're inserting into an
existing buffer. Fixes Savannah bug 28219.
2009-12-07 David Lawrence Ramsey <pooka109@gmail.com>
* global.c (shortcut_init): Many fixes for keybindings code oversights, including
restore page up/down and GotoDir to browser,
* browser.c (do_browser): Fix breaking out of a submenu (e.g. gotodir) breaks out
of browser altogether.
* doc/nanorc.sample.in: Add missing entries for fortran/ObjC/OCaml entries.
2009-12-03 David Lawrence Ramsey <pooka109@gmail.com>
* global.c (shortcut_init) - Remove help shortcut from help shortcut list :-) Tweaked
to reorder exit shortcut to end of list to not mess up prev/next shortcut symmetry.
2009-12-03 Eitan Adler <eitanadlerlist@gmail.com>
* doc/syntax/makefile.nanorc - Fix poor regex for all alpha characters which sometimes leads to
error messages, reported by gibboris@gmail.com.
2009-12-02 Chris Allegretta <chrisa@asty.org>
* text.c (add_undo, do_undo, do_redo) - Do not execute cases for SPLIT when DISABLE_WRAPPING
is defined. Fixes Savannah bug 28151 (anon).
2009-12-02 Jordi Mallach <jordi@gnu.org>
* doc/man/nano.1: Fix escaping of hyphens for the -$ option.
2009-12-01 Kamil Dudka <kdudka@redhat.com>
* chars.c, file.c - Better handle unused results for things like mbtowc(), new
macro IGNORE_CALL_RESULT.
2009-12-01 Chris Allegretta <chrisa@asty.org>
* global.c (shortcut_init) - Remove redundant entries for ^Y/^V reported by
Christian Weisgerber.
* doc/man/nanorc.5 - Fix typo in Meta documentation, reported by gibboris@gmail.com.
2009-12-01 David Lawrence Ramsey <pooka109@gmail.com>
* global.c (shortcut_init) - Add support for ^P and ^N in the help menu.
* Update documentation for 2.2 features including sample nanorc file, texinfo
file, man pages, UPGRADE file, and update copyright noticed for the current year.
GNU nano 2.2.0 - 2009.11.30
2009-11-29 Chris Allegretta <chrisa@asty.org>
* prompt.c (get_prompt_string) - Universally handle help key when is
disabled. Fixes Savannah
bug 28117 by David Lawrence Ramsey <pooka109@gmail.com>.
* chars.c, files.c: Add junk vars to silence the compiler. Sigh.
2009-11-29 David Lawrence Ramsey <pooka109@gmail.com>
* Change several *chars to const char, additional cleanups and casts to make compilers happier.
* global.c: Fix replace and insert file initializations for proper compilation options.
* nano.c (do_suspend): Update comments to reflect actual code path, bad Chris and thanks for
noticing Jordi.
* configure.ac: Fix typos
2009-11-27 Chris Allegretta <chrisa@asty.org>
* nano.c (do_suspend): Don't clear the screen but do move the cursor down to the last line
first in an effort to not corrupt the screen, which contradicts Pico but is consistent
with almost all other text editors. Fixes Savannah bug 28110/Debian bug 460510
reported by Tim Connors <reportbug@rather.puzzling.org>.
* doc/dyntax/makefile.nanorc - Sample Makefile highlighting based on wiki.linuxhelp.net version.
2009-11-26 Chris Allegretta <chrisa@asty.org>
* winio.c (edit_scroll): Adjust for long lines when scrolling.
* rcfile.c (parse_rcfile), initialize size argument to getline(), fixes crash on FreeBSD
reported by Eitan Adler <eitanadlerlist@gmail.com>.
2009-11-26 Jordi Mallach <jordi@gnu.org>
* doc/man/*: Update all man pages to escape unescaped hyphens.
2009-11-24 Chris Allegretta <chrisa@asty.org>
* move.c (do_page_up, do_page_down): Make these functions work better with soft
line wrapping.
* winio.c (compute_maxrows): Make maxrows calculation more accurate when all lines are > COLS.
2009-11-22 Chris Allegretta <chrisa@asty.org>
* nano.c (main): Allow edit_refresh_needed to take effect when using --enable-tiny
(fixes Savannah bug 28076 reported by David Lawrence Ramsey).
2009-11-22 David Lawrence Ramsey <pooka109@gmail.com>
* nano.c (move_to_filestruct): Fix bug 71 (cut at top of line recenters)
* Fix compilation with --enable-tiny
2009-11-22 Mike Frysinger <vapier@gentoo.org>
* doc/syntax/gentoo.nanorc: Tweak comment highlighting.
GNU nano 2.1.99pre2 - 2009.11.21
2009-11-21 Chris Allegretta <chrisa@asty.org>
* rcfile.c: Add unbinding keyword, fixes Savannah bug 22852 reported by frankd.
* prompt.c (update_statusbar_line): Set statusbar_pww when updating the line.
Fixes Savannah bug 24957 by Mike Frysinger.
2009-11-19 Chris Allegretta <chrisa@asty.org>
* nano.c (die_save_file) Try nd match the permissions of the file we were
editing but only make a minimal effort to do so. Fixes Savannah bug 27273
reported by Mike Frysinger.
2009-11-18 Adrian Bunk <bunk via Savannah>
* nano.c (main): Allow --fill and --nowrap to override nanorc entries and each other
on the command line.
2009-11-15 Chris Allegretta <chrisa@asty.org>
* winio.c (edit_refresh): Always computer maxsize regardless of whether smooth scrolling
is enabled. Fixes Savannah bug 28024 by Mike Frysinger.
GNU nano 2.1.99pre1 - 2009.11.15
2009-11-14 Chris Allegretta <chrisa@asty.org>
* move.c (do_first_line, do_last_line): Just set edit_refresh_needed rather than
get messy.
* files.c (do_writeout) - Only mention file modification if we're writing the same
file we originally opened.
2009-11-13 Chris Allegretta <chrisa@asty.org>
* winio.c: Add new static maxsize to be able to easier calculation with
softwrap.
* nano.c (do_mouse): Fix mouse support not working with soft wrapping. Fixes
Savannah bug 27549 reported by Hannes Schueller.
2009-11-11 Chris Allegretta <chrisa@asty.org>
* winio.c: Large tweaking of cursor and text display based on COLS not COLS - 1,
due to finally understanding that display_string wasn't being called properly
when softwrap was enabled. Fixes Savnnah bug 27603, Return key doesn't scroll
viewport reported by Hannes Schueller.
* - Fix size_t formatting issues with -pedantic
2009-11-09 Chris Allegretta <chrisa@asty.org>
* files.c (read_file): - Remove debugging messages from file load. Fixes
Savannah bug 27838.
2009-11-07 Chris Allegretta <chrisa@asty.org>
* nano.h - Add bogus value at begin of flags enumeration because it
causes casesens rcfile option to misbehave, reported by Helmut
Jarausch <jarausch@igpm.rwth-aachen.de>
2009-11-03 Chris Allegretta <chrisa@asty.org>
* nano.h - Fix comma at end of enumerator list which angers -pedantic.
* rcfile.c - Add in specific check for UNDOABLE and fix declaration as
to what flag it toggles. Fixes undo mode being able to be called from
the rc file, reported by Helmut Jarausch <jarausch@igpm.rwth-aachen.de>
2009-11-03 Mike Frysinger <vapier@gentoo.org>
* files.c - Move up is_file_writable() to stop implicit definition complaints.
2009-10-27 Chris Allegretta <chrisa@asty.org>
* browser.c (browser_init): Set column width to something sane when
initializing in a directory with no file entries. Fixes Savannah
bug 24163 found (and initial patch) by Paul Wise.
2009-09-15 Chris Allegretta <chrisa@asty.org>
* winio.c: Clean up some unused variables from the soft wrapping code.
GNU nano 2.1.11 - 2009.09.14
2009-09-12 Chris Allegretta <chrisa@asty.org>
* winio.c (edit_update) - properly update edittop when using soft wrapping.
Fixes lack of centering for searching for off-screen answers, found by
Hannes <mr_creosote@mutantwatch.de>.
2009-09-03 Chris Allegretta <chrisa@asty.org>
* global.c (shortcut_init): Fix up/down keys not responding in the file browser,
discovered by Hannes <mr_creosote@mutantwatch.de>.
* move.c (do_up) - Fix another scrolling issue with softwrap when the
cursor is beyond COLS, discovered by Hannes <mr_creosote@mutantwatch.de>.
2009-09-02 Chris Allegretta <chrisa@asty.org>
* Attempt to check file writability and emit a warning on the status bar
if nano doesn't think the file can be written to. Feature originally
requested by Damien Jolders <madamien@skullsquad.com> et al.
2009-08-29 Chris Allegretta <chrisa@asty.org>
* Fix more soft wrapping issues, particularly with scrolling,
discovered by Hannes <mr_creosote@mutantwatch.de>.
2009-08-19 Chris Allegretta <chrisa@asty.org>
* Fix issue with soft wrapping not displaying the last character of each line,
fixed bug discovered by Hannes <mr_creosote@mutantwatch.de>.
2009-08-17 Mike Frysinger <vapier@gentoo.org>
* doc/syntax/(gentoo|sh|tcl).nanorc: Fix problems with empty regexes on POSIX.
Fixes Savannah bug 27175.
2009-08-17 Chris Allegretta <chrisa@asty.org>
* Initial soft line wrapping implementation. Command line flags
-$ or --softwrap.
* nano.c, text.c: Clean up some fprintf warnings in debug mode due to printing
a size_t without using the zd specifier.
2009-08-13 Chris Allegretta <chrisa@asty.org>
* New global flag implementation courtesy of Adam Wysocki <gophi@arcabit.pl>, allows
previous undo flag to be implemented consistent with other flags.
GNU nano 2.1.10 - 2009.07.28
2009-07-27 Chris Allegretta <chrisa@asty.org>
* text.c (undo_cut, redo_cut): Don't actually try and undo/redo an empty cut, i.e. the magicline.
Fixes crash on cutting last line discovered by Eitan Adler <eitanadlerlist@gmail.com>.
2009-07-11 Chris Allegretta <chrisa@asty.org>
* nano-regress: Small tweaks
* Change undo code to off unless unabled via a command line option (-u/--undo). Until this code
stabilizes this is the only responsible way to treat it.
2009-03-08 Chris Allegretta <chrisa@asty.org>
* TODO - Break out some targets for various features into 2.2
and 2.4 series for things which are feasible.
2009-02-28 Chris Allegretta <chrisa@asty.org>
* configure.ac: Add check for whether _XOPEN_SOURCE_EXTENDED is needed for
curses to work w/color. Fixes compilation on HP-UX with older GCC,
reported by jay.krell@cornell.edu.
2009-02-23 Eitan Adler <eitanadlerlist@gmail.com>
* doc/man/Makefile.am: Fix make variable substitution to be more portable
2009-02-23 Chris Allegretta <chrisa@asty.org>
* rcfile.c (parse_keybinding) - Define a var before tryung to use it. Whoops!
* fix some redefinitions causing compiler warnings, from Eitan Adler. Other
(hopefully) fixes for uncasted malloc()s, reported by the same.
* doc/man/fr/Makefile.am: Add groff check fix to fr files.
GNU nano 2.1.9 - 2009.02.16
2009-02-16 Chris Allegretta <chrisa@asty.org>
* Add new argument to reset_multis for force redraws without attempting to
guess whether we need to, for functions that we don't have good info about
the text state. New utility function color.c:reset_multis_for_id().
2009-02-15 Chris Allegretta <chrisa@asty.org>
* configure.ac, doc/man/Makefile.am - Add check for HTML output support in GNU
groff. Fixes Savannah bug #24461: build traps on groff. Also, add installation
of html-ized man pages to $datadir/nano/man-html, since we should probably
install files we went to all the trouble of generating.
2009-02-14 Chris Allegretta <chrisa@asty.org>
* nano.c (precalc_multicolorinfo) - Add debugging so we have a better clue if further
issues arise. Also start at the beginning of later lines when trying to match the
end of a multi-line regex. Fixes more overly aggressive highlighting found by
Mike Frysinger. Finally, advance to the match end for performance.
2009-02-11 Chris Allegretta <chrisa@asty.org>
* nanorc.c (parse_include): Do call real_dir_from_tilde() on included
files in .nanorc, but still avoiding bug #25297. Fixes ~ and ~user
specifications for nanorc include files, as reported by Eitan Adler.
2009-02-09 Chris Allegretta <chrisa@asty.org>
* New option -q, --quiet, rcfile option "quiet" implemented. Skips printing
errors about the rcfile and asking user to press enter. Also, nano should
now only ask for one enter press when there is an error when not using -q.
Based on discussion between Eitan Adler and Mike Frysinger.
* rcfile.c (parse_keybinding) - Significant cleanups and fixes for
detecting and reporting errors in key bindings code.
2009-02-08 Chris Allegretta <chrisa@asty.org>
* Make reset_multidata reset more lines, since contrary to previous problems the
syntax highlting is now too *un*ambitious, causing display glitches when
deleting a regex boundary.
* Add more multidata initliazers for new buffers and 'magic lines'. Fixes segfaults
with syntax highlighting in new buffers, initially reported by Mike Frysinger.
GNU nano 2.1.8 - 2009.02.07
2009-02-06 Chris Allegretta <chrisa@asty.org>
* rcfile.c (parse_include): Abort on being unable to open an included rcfile. Fixes
Savannah bug 25490, nanorc: "include"ing a file which doesn't exist causes nano to segfault.
2009-02-05 Chris Allegretta <chrisa@asty.org>
* More color syntax speedups: Determine in reset_multis() whether we really need to call
edit_refresh(). Additional global var edit_refresh_needed() to hopefully reduce
repeated calls to the function. New helper funcs reset_multis_before() and
reset_multis_after().
2009-02-02 Chris Allegretta <chrisa@asty.org>
* New color precalculation code for mult-line regexes. New function precalc_multicolorinfo(),
new structure multidata for keeping track of where regexes start/stop. More
performance improvements forthcoming.
2009-01-29 Chris Allegretta <chrisa@asty.org>
* nano.c (move_to_filestruct) - properky initialize new fileage for multiswatching, sigh.
Fix cut sefaults discovered by Mike Frysinger.
2009-01-29 Chris Allegretta <chrisa@asty.org>
* nano.c (main): Add support for nano acting like a pager when invoked with - as first
file argument.
2009-01-28 Davide Pesavento <davidepesa@gmail.com>
* doc/syntax/gentoo.nanorc: Updates from David and Mike Frysinger.
2009-01-25 Chris Allegretta <chrisa@asty.org>
* files.c (open_file), nanorc.c (parse_include): Don't get_full_path on
included rc files, due to it potentially impacting the ability
to read files in nano's cwd(). Fixes Savnanah bug #25297 reported by Mike
Frysinger)
2009-01-24 Chris Allegretta <chrisa@asty.org>
* First pass at some caching of caching color info. Right now it's only for
multi-line regexes but this may not be enough to increase performance.
* Add interruptability to search functions. New functions enable_nodelay and
disable_nodelay and changes to the routines to handle checking for pending
searches. Fixes Savnnah bug 24946: Need interrrupt for search.
2009-01-19 Chris Allegretta <chrisa@asty.org>
* Change function definitions to shorts instead of (void *)s. New mapping function
iso_me_harder_funcmap(). Fixes compilation complaints with -pedantic,
reported by Eitan Adler <eitanadlerlist@gmail.com>.
GNU nano 2.1.7 - 2008.11.10
2008-10-20 Chris Allegretta <chrisa@asty.org>
* files.c (do_writeout): Add check for file modification when saving
the file so the user can at least know they may be blowing away changes.
2008-10-14 Chris Allegretta <chrisa@asty.org>
* nanorc.5: Fix redo man page entry and update explanation, reported by
Eitan Adler <eitanadlerlist@gmail.com>
* global.c (shortcut_init), search.c (search_init): Fix add_to_sclist for ^W^T so
invalid messages will display properly. Fixes Savannah bug 24507.
2008-10-13 Chris Allegretta <chrisa@asty.org>
* Remove CUTTOEND as an undo type as it's unneeded, fix u->to_end logic in undo struct.
* undo.c (update_undo): Don't free cutbuffer if NULL, fix for Savannah bug #24499
2008-10-04 Chris Allegretta <chrisa@asty.org>
* cut.c (Add_undo): Save last cut undo information so it can be used for next uncut, fixes
Savannah bug 24183.
GNU nano 2.1.6 - 2008.10.03
2008-10-03 Pascal Gentil <pascal.gentil@univ-rennes1.fr>
* fortran.nanorc: Sample python syntax highlighting file
2008-09-30 Dirkjan Ochtman <dirkjan@ochtman.nl>
* python.nanorc: Small python syntax update
2008-09-30 <bluestorm_dylc@hotmail.com>
* ocaml.nanorc: Sample OCaml syntax highlighting file
2008-09-30 Dave Geering <dgeering@toshiba-tap.com>
* objc.nanorc: Sample Objective-C Syntax Hightlighting file
2008-09-30 Chris Allegretta <chrisa@asty.org>
* configure.ac: Change extra, multibuffer, color and rcfile configure options to default to enabled
--enable-tiny will now disable these options as well
* python.nanorc, ruby.nanorc: Add header lines for python and ruby as well
2008-09-21 Chris Allegretta <chrisa@asty.org>
* rcfile.c, color.c, nano.h: Add new capability for matching a syntax type by the "header" (1st line)
of a file being edited. Based on Savannah bug 24197 and inital proof of concept by Dave Geering
<dgeering@toshiba-tap.com>
2008-09-16 Chris Allegretta <chrisa@asty.org>
* text.c: Add support for undoing a text uncut. Split out the undo and redo of a text cut
in order to avoid code duplication.
2008-09-06 Chris Allegretta <chrisa@asty.org>
* nano.c: Do call disable_signals at startup regardless, since under cygwin we can't generate
^C without it.
GNU nano 2.1.5 - 2008.08.30
2008-08-29 Chris Allegretta <chrisa@asty.org>
* configure.ac, color.c, rcfile.c, utils.c: 1st attempt at supporting systems which don't support
GNU-style word boundaries. New function fixbounds() to translate from GNU-style to
BSD-style, autoconf option GNU_WORDBOUNDS.
* nano-regress: New perl script to check for some of the more obvious issues with compilation
issues with certain configure options.
* global.c, help.c, browser.c, files.c, proto.h: Fix several compipation and programmatic
issues with --disable-help, especially that do-writeout was treating ^G the same as ^M.
2008-08-28 Chris Allegretta <chrisa@asty.org>
* configure.ac, rcfile.c: Add support for an alternate rcfilename at configure time. Maybe this
should become a command line option some day, but I don't see the need currently. Start of
fix for Savannah bug #24128: Add nanorc support to win32 platform.
2008-08-21 Chris Allegretta <chrisa@asty.org>
* text.c: Change error messages where we may possibly get into a bad state and urge
the user to save when this happens. Originally by Benno Schulenberg <bensberg@justemail.net>
* text.c (do_enter): Fix issue when compiled with --enable-debug, fixes Savannah bug 24092.
2008-08-08 Magnus Granberg <zorry@ume.nu> / Adam Conrad <?>
* files.c (write_file): Add needed flags to open() calls when writing out files. Fixes Savannah bug
#23827: Compilation fails with -D_FORTIFY_SOURCE=2
2008-08-08 Chris Allegretta <chrisa@asty.org>
* files.c (write_file): Check exit code of fclose(), since in certain out of space conditions the OS will
happily report successful fwrite()s until you try and close the file. Fix for Savannah bug
#24000: no free space on partition - nano claims successful write - file empty
GNU nano 2.1.4 - 2008.08.09
2008-08-08 Chris Allegretta <chrisa@asty.org>
* files.c (write_file): Do not go on and attempt to write the main file if writing the backup file failed,
related to Savannah bug 24000.
* text.c (do_redo): Fix improperly restoring the text when redoing a line split.
* text.c (add_undo): Fix check for multi-line cut check skips adding other new legit events.
2008-07-23 Chris Allegretta <chrisa@asty.org>
* text.c: Reset openfile-> to OTHER after an undo or redo so we don't mistakenly
mistakenly think this is an update when it's really an add. Also
Fix an extra ; after an if statement which makes nano try to free a struct which
may be NULL
GNU nano 2.1.3 - 2008.08.04
2008-07-23 Chris Allegretta <chrisa@asty.org>
* configure.ac: Add ncursesw dir to include path if lib detected
2008-07-11 Mike Frysinger <vapier@gentoo.org>
* doc/nanorc.sample.in: Include the updates files in the default sample nanorc.
2008-07-11 Fabian Groffen <grobian@gentoo.org>
* nano.c: Don't include langinfo.h if not using ENABLE_UTF8
(Savannah patch 6565)
2008-07-11 Mitsuya Shibata <mty.shibata@gmail.com>
* text.c: Fix crashing in help menu when using certain locales
(Savannah bug 23751)
2008-07-09 Chris Allegretta <chrisa@asty.org>
* nano.c/nano.h/global.c/text.c: New generalized undo code, currently
just works for adding and deleting text and splitting and unsplitting lines.
2008-06-29 Chris Allegretta <chrisa@asty.org>
* global.c: Fix for not having search history when --disable-justify is used
(Savannah bug 23733)
GNU nano 2.1.2 - 2008.06.24
2008-06-24 Chris Allegretta <chrisa@asty.org>
* rcfile.c: Added function check_bad_binding() to look for sequences which

236
NEWS
View File

@@ -1,4 +1,228 @@
2008/04/24 - GNU nano 2.1.2 "New York City" is released. This release
2010.08.05 - GNU nano 2.2.5 "Inactivity timeout" is now available.
This release includes slightly less restrictive checkng
when writing files in strange environments (e.g.
when being used out of crontab). For very strange situations
(such as where you cannot change the permissions on the
file you're writing, there is a new rc file option
"allow_insecure_backup" to be even more permission and
allowing the write to proceed. Also included are
some syntax highlighting updated, and that is about it.
Keep fighting the good fight children.
2010.04.15 - GNU nano 2.2.4 is nobody's fool. First and foremost,
this relase includes some security fixes due to
an assessment of nano's vulnerability to symlink attacks
on open files. The CVEs fixed with this release are
CVE-2010-1160 and CVE-2010-1161. Also included are fixes
for various crash modes when using the spell checker
on new files in multibuffer mode (surely you've used
that combination recently? No?) as well as a fixing
the 'file was modified' message when saving to a
new filename (since how would nano know?). And
the list would not be complete without our
third-times-the-charm fixes to page up/down due to
the soft wrapping code. The lone new feature
included is a new syntax higlighting definition for
cmake-related files. Please do consider upgrading to
this release if still using the 2.0 series since
fixes for that version are still forthcoming.
2010.02.11 - GNU nano 2.2.3 "fumbling toward stability" is released.
This release contains a fix for only one bug, but a
rather irritating one: when paging up/down with smooth
scrolling, the cursor position was not being preserved
due to a bug in 2.2.2. With such a targeted fix
like this what could POSSIBLY go WRONG? Hahaha.
Enjoy and if you find new bugs, as always please
use Savannah's bug tracker.
http://savannah.gnu.org/bugs/?func=additem&group=nano
2010.01.17 - GNU nano 2.2.2 is released for you, you, you. This
release includes fixes for: crashed when writing
backup files in certain conditions, improper
screen centering when moving up/down in various
combination of smooth scrolling and soft wrapping modes,
a search crash on the armel arch, and issues with
lots of keybinding customizations causing crashing
particularly on FreeBSD. Also included are better
help menu entries for forward/back in the file browser,
some man page tweaks and one assert fix. As always,
share and enjoy!
2009.12.12 - GNU nano 2.2.1 "DLR strikes back" is open for business.
This release fixes many bugs, including: missing
keybindings for page up/down and GotoDir in the browser,
^P/^N in the help menu, and restoration of M-W as the
default re-search binding. Other fixes include several
issues with compiler warnings and configure options, and
documentation updates, including the nano texinfo manual,
nano and nanorc man pages, and UPGRADE file, and some
missing syntax highliting entries for the saple nanorc.
And no release would be complete without the latest round
of 'final' soft wrapping fixes! Finally, nano will no
longer print a warning when attempting to insert the
contents of a read-only file into an existing buffer.
Enjoy and Happy Hanukkah.
2009.11.30 - GNU nano 2.2.0 "Doc Brown" is released! The culmination
of almost two years of development and hot on the heels
of nano's 10th birthday is available for all your
editing needs! Bugs fixed since the last release
include several fixes for tiny mode (involving both
the help keys and replace menu text), more 'final'
fixes for soft wrapping, and several typo and documentation
updates including nanorc tweaks and a new syntax
highlighting file for makefiles. Also included is a long
standing fix for random crashing when using nanorc on
FreeBSD, and nano will no longer clear the screen on
suspend to maintain compatibility with other *nix editors.
For those who haven't been playing along at home, please
see the official web page for the summary of new
features since 2.0. Special thanks to all who have
submitted bug reports recently in support of our new
stable release, and apologies for all those bugs we
didn't yet find :-) Peace to all.
2009.11.21 - GNU nano 2.1.99pre2 is available for a special pre-Black
Friday discount. Included are some (hopefully
final) fixes for issues with last page display
caused by the soft wrapping code, and a fix for
a long standing issue with hittig the home key when
going through the search history. On the features
front, nano will now attempt to retain the proper
ownership and permissions when trying to create a
.save file due to receiving a signal. Nano can also
now unbind keys from one or more menus via the 'unbind'
keyword. Finally, passing --fill or --nowrap on
the command line will now override any related
.nanorc entries. Speak now or forever hold your bugs!
2009.11.15 - GNU nano 2.1.99pre1 "take a bow" is out there, man, it's
out there all right. This release contains mainly
bugfixes, underscoring that we are preparing for the
next stable series release. Included are many fixes
for the new soft wrapping code, compiler warning tweaks,
and the modification time warning no longer triggers
when saving a file as a new name. Also include are
some fixes for various nanorc options, and there are
surely more bugs to find before we call the code base
stable, so please keep those reports coming!
2009.09.14 - GNU nano 2.1.11 is on very thin ice, very thin ice, very thin
ice. This release includes two new features: first, nano
will check whether the current file is writable when it
is opened, and warn if it is not on the status bar. Secondly,
a new soft-wrapping (AKA full line display) option is
available, which will attempt to fully display the contents
of lines longer than the width of the screen without the
usual truncation and a '$' symbol at the end of the line.
It can be enabled via Meta-$ inside the editor, via the
-$ or --softwrap command line flags, or "set softwrap"
in your .nanorc). As always please report any bugs to the
nano Savannah project page
(http://savannah.gnu.org/bugs/?func=additem&group=nano)
Remember: data loss happens, back up your files.
2009.07.28 - GNU nano 2.1.10 "Ellie" is released. This version includes
various fixes for portability including some older HP-UX
compiler combos, various compiler warnings, and some crash
fixes in the undo code. On the topic of the latter item,
the undo code is now marked as experimental since it can
cause severe stability and memory issues, and thus now
requires a flag (-u, --undo) in order to enable it.
Please feel free to continue to test the undo code and
thanks again for using nano for your text editing needs.
Go team Nano!
2009.02.16 - GNU nano 2.1.9 wonders what all that glass is doing on the
floor! This release is primarily meant as a less buggy
version of 2.1.8, particularly for issues with the new
sped-up syntax highlighting code. Other fixes include
configure-time detection of groff HTML support before
attempting to generate the HTML version of man pages,
and using ~ or ~username syntax in .nanorc should now
work again. Also, nano will now only ask for one
acknowledgement of errors it encounters when parsing
nanorc files, and a new flag -q (--quiet) will silence
these messages altogether. Give it a go, and happy
birthday lenny!
2009.02.07 - GNU nano 2.1.8 "unsafe at any speed" is released. This
release include some long overdue performance
improvements in syntax color highlighting, the ability
to abort running searches (useful mainly when
editing very large files) and the ability to use nano
like a pager for viewing standard input (i.e. "nano -").
Additionally, there are gentoo syntax highlighting
updates and fixes for issues with reading files
in a directory with strange parent directory permissions.
The key bindings code was also substantially changed
in order to be more ISO-C compatible. Be sure to use
the Savannah page not only for bug reports but for any
features you would like to see before the next stable
series is released. Have fun with it!
2008.11.10 - GNU nano 2.1.7 "Effingham" is ready to make good on those
campaign promises of lower bug rates and 50% more pie.
This release includes a new check for external
modifications when saving a file, some code and
documentation cleanups, and more bug fixes for
the new undo code (but we continue to welcome your bug
reports via the Savananh bug page at
http://savannah.gnu.org/bugs/?func=additem&group=nano.
Come get some.
2008.10.03 - GNU nano 2.1.6 was for new features before it was against
them. This release includes more undo capability,
several new syntax highlighting configurations including
Objective C, OCaml, and Fortran, and a new capability
to activate highlighting based on the 1st line of the
file being edited. Also, the new default configure
options now include color syntax highlighting, .nanorc
support, multibuffer and extras. These items can still
be disabled and are not enabled with --enable-tiny. Bug
fixes include better signal handling under Cygwin, and
that's about it. Again please remember to
submit bug reports via Savannah at
http://savannah.gnu.org/bugs/?func=additem&group=nano
as undo functions certainly need more testing.
Bon appetit.
2008.08.30 - GNU nano 2.1.5 is ready to lead on day one. This release
contains a better fix for incorrectly reported successful
writes on full filesystems, more helpful messages when
an internal error occurs in the undo code, and fixes for
various combinations of configure-time options and
compiler flags. Also included is new support for
changing the rc file name at configure time, and
using GNU-style regexes for word-boundaries on systems
which do not support them natively, as well as the ever
popular translation updates. Rock the tarball.
2008.08.09 - GNU nano 2.1.4 "I told you so!" is released. This release
includes fixes for several severe issues with the new
undo/redo code. Also the behavior of writing
files when using backup mode has changed as well: if writing
the backup file fails, nano will not attempt to write the
current file. This should help folks who enjoy "extreme
text editing" i.e. editing files on file systems which
are likely to run out of space; see Savannah bug 24000.
Have fun with it!
2008.08.04 - GNY nano 2.1.3 "least stable version ever" is released. This
release includes new (and experimental) undo and redo
functionality for most text operations. The default
key bindings are Meta-U for undo and Meta-E for redo, but
these can be remapped using the new 2.1 keybinding code.
Also included are some fixes for configuring using wide
curses, crashing when invoking the help menu with
certain locales, and not saving the search history when
compiled with configure options.
2008.04.24 - GNU nano 2.1.2 "New York City" is released. This release
contains fixes for binding bad keys, some
configure-specific compilation failures, and more issues
with the new input back end and in particular the status
@@ -6,7 +230,7 @@
compiling on AIX, and a segfault when making the terminal
window too small. Rest in Peace Tim and George!
2008/04/01 - GNU nano 2.1.1 wont get fooled again. This release contains
2008.04.01 - GNU nano 2.1.1 wont get fooled again. This release contains
fixes for the new user-rebindable keys (in particular
bracket match which was mis-bound), and various
problems with translations and configure-related
@@ -18,7 +242,7 @@
binding code to the Savannah page
(https://savannah.gnu.org/bugs/?group=nano).
2008/03/18 - GNU nano 2.1.0 "under old mismanagement" is released.
2008.03.18 - GNU nano 2.1.0 "under old mismanagement" is released.
This first release in the 2.1 development series
introduces rebinadble keys for most actions inside
the editor. Please see the nanorc(5) page for
@@ -28,7 +252,7 @@
https://savannah.gnu.org/bugs/?group=nano and
thanks for sticking with us!
2007/12/20 - GNU nano 2.0.7 keeps its balance. This release fixes
2007.12.20- GNU nano 2.0.7 keeps its balance. This release fixes
several bugs, among others: a segfault and several
cursor positioning problems when uncutting text or
inserting files into the current buffer; a problem where
@@ -50,12 +274,12 @@
under the GNU GPL version 3 or later and the GNU FDL
version 1.2 or later. Have fun.
2007/04/26 - GNU nano 2.0.6 "that was quick" is released. This release
2007.04.26- GNU nano 2.0.6 "that was quick" is released. This release
fixes a potential segfault after justifying text marked
from the bottom up. It also adds one more minor
documentation update. Enjoy.
2007/04/22 - GNU nano 2.0.5 braces for impact. Among other things, this
2007.04.22- GNU nano 2.0.5 braces for impact. Among other things, this
release fixes various problems (including a segfault)
when trying to open or save a file in a directory
beginning with "~" that isn't a home directory; fixes a

51
TODO
View File

@@ -1,9 +1,9 @@
TODO file (? means the feature may be implemented, but not definitely)
------------------------------------------------------------------------
For the next version:
- Undo/Redo keys (M-U and M-E)?
- Rebindable keys?
For the future (no targeted version, catch-all)
- Compatibility with vi/emacs status files so we can let other editors
know we're in a file?
- FriBidi support?
- Port to DJGPP?
- Make matching bracket searches sophisticated enough to skip over
@@ -11,37 +11,44 @@ For the next version:
- Allow indentation of marked text by spaces as well as tabs?
- Allow indentation to add just enough columns to reach the nearest
multiple of tabsize, rather than always adding tabsize columns?
- Allow piping marked text to an external command and replacing it with
the command's output (as the internal spell checker already does with
the "spell" command)?
- Rewrite the nano FAQ in SGML.
- Allow conversion between different character sets. Maybe use glib's
iconv() if the system's iconv() is inadequate, since we already use
glib's vsnprintf() if the system lacks vsnprintf()?
- Handle window resizes better. After we resize, we should stay
wherever we were before we resized, as Pico does.
- Fix problems with color syntaxes' highlighting lines too aggressively.
- Allow color syntaxes to apply to more than just color, so that we can
e.g. specify a different alternate spell checker depending on which
file type we have open.
- Allow color syntaxes to be selected based on more than just filename
extension, e.g. through libmagic?
- Allow text searches in the help browser.
- Allow even better file type detection than we have currently, e.g.
through libmagic?
- Allow setting marks (saved positions, not to be confused with the mark
set via Ctrl-^) at various lines and/or columns in the buffer, and
allow movement between them with a single keystroke.
- Add the ability to move to different lines of the screen with a single
keystroke, e.g. M-` (M-~) to go to the top line, M-& (M-7) to go to
the center line, and M-' (M-") to go to the last line.
allow movement between them with a single keystroke? (we're running
out of keystrokes)
- Allow searching for and replacing newlines.
- Allow soft wrapping as well as hard wrapping?
- Detect when we're pasting text, so that we can handle it differently
from normal typing?
- Make pasting text work as fast as it does in Pico.
- Fix handling of bad/incomplete UTF-8 sequences to display one Unicode
FFFD (Replacement Character) per sequence instead of one per byte.
Old requests:
For version 2.4:
- New regression framework built on expect.
- Allow text searches in the help browser.
- Handle window resizes better. After we resize, we should stay
wherever we were before we resized, as Pico does.
- Add the ability to move to different lines of the screen with a single
keystroke, e.g. M-` (M-~) to go to the top line, M-& (M-7) to go to
the center line, and M-' (M-") to go to the last line.
- Detect when we're pasting text, so that we can handle it differently
(i.e. faster than currently with screen redraws)
- Allow piping marked text to an external command and replacing it with
the command's output (as the internal spell checker already does with
the "spell" command)?
For version 2.2:
- Rebindable keys? [DONE]
- Undo/Redo keys (M-U and M-E)? [DONE]
- Fix problems with color syntaxes' highlighting lines too aggressively [DONE]
- Allow nano to work like a pager (read from stdin) [DONE]
- Allow color syntaxes to be selected based on more than just filename
extension, [DONE]
- Allow soft wrapping as well as hard wrapping? [DONE]
For version 2.0:
- UTF-8 support. [DONE]

16
UPGRADE
View File

@@ -1,6 +1,22 @@
GNU nano upgrading information
==============================
Visible changes since 2.0
-------------------------
* Editor Features
- The ability to rebind (reassign) keys using the nanorc.
- The ability to read standard input like a pager ("nano -").
- Color syntax highlighting can be set by the first line of a file.
- The ability to silence nanorc error messages (-q).
- Undo/redo operations (-u).
- Soft wrapping of text (-$).
* File Handling
- Better handling of backup files: if nano can't write a backup file,
it won't try to write the original file afterward.
- Emergency savefiles retain ownerships and permissions when possible.
- Performance improvements in color syntax highlighting.
Visible changes since 1.2
-------------------------
* Editor Features

View File

@@ -20,7 +20,7 @@
#
# $Id$
AC_INIT([GNU nano], [2.1.2], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [2.2.5], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_TARGET([])
AM_INIT_AUTOMAKE
@@ -50,7 +50,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(getopt.h libintl.h limits.h regex.h sys/param.h wchar.h wctype.h)
AC_CHECK_HEADERS(getopt.h libintl.h limits.h regex.h sys/param.h wchar.h wctype.h stdarg.h)
dnl Checks for options.
@@ -64,12 +64,6 @@ if test x$debug_support != xyes; then
AC_DEFINE(NDEBUG, 1, [Shut up assert warnings :-)])
fi
AC_ARG_ENABLE(extra,
[ --enable-extra Enable extra features, currently only easter eggs],
[if test x$enableval = xyes; then
AC_DEFINE(NANO_EXTRA, 1, [Define this to enable extra stuff.]) extra_support=yes
fi])
AC_ARG_ENABLE(tiny,
[ --enable-tiny Disable features for the sake of size],
[if test x$enableval = xyes; then
@@ -84,6 +78,16 @@ AC_ARG_ENABLE(tiny,
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
fi])
AC_ARG_ENABLE(extra,
[ --disable-extra Disable extra features, currently only easter eggs],
[if test x$enableval != xno; then
AC_DEFINE(NANO_EXTRA, 1, [Define this to enable extra stuff.]) extra_support=yes
fi],
[if test x$enable_tiny != xyes; then
AC_DEFINE(NANO_EXTRA, 1, [Define this to enable extra stuff.]) extra_support=yes
fi])
AC_ARG_ENABLE(browser,
[ --disable-browser Disable built-in file browser],
[if test x$enableval != xyes; then
@@ -139,8 +143,8 @@ AC_ARG_ENABLE(wrapping-as-root,
fi])
AC_ARG_ENABLE(color,
[ --enable-color Enable color and syntax highlighting],
[if test x$enableval = xyes; then
[ --disable-color Disable color and syntax highlighting],
if test x$enableval != xno; then
if test x$ac_cv_header_regex_h = xyes; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to use .nanorc files.]) nanorc_support=yes
AC_DEFINE(ENABLE_COLOR, 1, [Define this to have syntax highlighting, requires regex.h and ENABLE_NANORC too!]) color_support=yes
@@ -148,30 +152,46 @@ AC_ARG_ENABLE(color,
AC_MSG_ERROR([
*** The header file regex.h was not found. If you wish to use color
*** support this header file is required. Please either install C
*** libraries that include the regex.h file or do not call the configure
*** script with --enable-color.])
*** libraries that include the regex.h file or call the configure
*** script with --disable-color.])
fi
fi])
fi,
if test x$enable_tiny != xyes; then
if test x$ac_cv_header_regex_h = xyes; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to use .nanorc files.]) nanorc_support=yes
AC_DEFINE(ENABLE_COLOR, 1, [Define this to have syntax highlighting, requires regex.h and ENABLE_NANORC too!]) color_support=yes
else
AC_MSG_ERROR([
*** The header file regex.h was not found. If you wish to use color
*** support this header file is required. Please either install C
*** libraries that include the regex.h file or call the configure
*** script with --disable-color.])
fi
fi
)
AC_ARG_ENABLE(multibuffer,
[ --enable-multibuffer Enable multiple file buffers],
[if test x$enableval = xyes; then
[ --disable-multibuffer Disable multiple file buffers],
[if test x$enableval != xno; then
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.]) multibuffer_support=yes
fi])
fi],
[if test x$enable_tiny != xyes; then
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.]) multibuffer_support=yes
fi])
AC_ARG_ENABLE(nanorc,
[ --enable-nanorc Enable use of .nanorc files],
[if test x$enableval = xyes; then
[ --disable-nanorc Disable use of .nanorc files],
[if test x$enableval != xno; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to use .nanorc files.]) nanorc_support=yes
fi])
fi],
[if test x$enable_tiny != xyes; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to use .nanorc files.]) nanorc_support=yes
fi])
AC_ARG_ENABLE(all,
[ --enable-all Enable ALL extra nano functionality (kitchen sink option)],
[ --enable-all Enable ALL extra nano functionality (ignored for compatibility as all options default to on)],
[if test x$enableval = xyes; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to use .nanorc files.]) nanorc_support=yes
AC_DEFINE(ENABLE_COLOR, 1, [Define this to have syntax highlighting, requires regex.h and ENABLE_NANORC too!]) color_support=yes
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.]) multibuffer_support=yes
AC_DEFINE(NANO_EXTRA, 1, [Define this to enable extra stuff.]) extra_support=yes
echo "--enable-all option no longer needed, ignoring for compatibility"
fi])
AC_MSG_CHECKING([whether to enable UTF-8 support])
@@ -387,6 +407,12 @@ fi
AM_CONDITIONAL(USE_COLOR, test x$color_support = xyes)
AM_CONDITIONAL(USE_NANORC, test x$nanorc_support = xyes)
AC_ARG_ENABLE(altrcname,
[ --enable-altrcname Specify alternate rcfile name (default: .nanorc)],
[if test x$enableval != no; then
AC_DEFINE_UNQUOTED(RCFILE_NAME, "$enableval", [Specify alternate rcfile name (default: .nanorc)]) rcfilename=$enableval
fi])
dnl Checks for functions.
AC_CHECK_FUNCS(getdelim getline isblank strcasecmp strcasestr strncasecmp strnlen vsnprintf)
@@ -410,14 +436,13 @@ dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(getopt_long)
dnl Checks for libraries.
if eval "test x$CURSES_LIB_NAME = x"; then
AC_CHECK_HEADERS(ncurses.h)
if test x$enable_utf8 != xno; then
AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB="-lncursesw" CPPFLAGS="-I/usr/include/ncursesw $CPPFLAGS" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
fi
if eval "test x$CURSES_LIB_NAME = x"; then
@@ -491,6 +516,89 @@ else
fi
fi
if test x$color_support = xyes; then
# now check for the end of word boundary support (/< and />)
AC_MSG_CHECKING([for GNU-style word boundary regex support])
AC_TRY_RUN([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <regex.h>
int main(void)
{
regex_t r;
size_t nmatch;
regmatch_t pmatch;
if (regcomp(&r, "\\\\>", REG_EXTENDED|REG_NOSUB))
return 1;
if (regexec(&r, "word boundary", nmatch, &pmatch, 0))
return 1;
return 0;
}],
AC_MSG_RESULT(yes)
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
)
# if test x$CURSES_LIB_NAME = xcurses; then
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
AC_TRY_RUN([
#include <curses.h>
int main(void)
{
int testcolor = COLOR_WHITE;
return 0;
}], AC_MSG_RESULT(no),
AC_TRY_RUN([
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#include <curses.h>
int main(void)
{
int testcolor = COLOR_WHITE;
return 0;
}],
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(not sure)
AC_MSG_WARN([*** Couldn't successfully compile basic color test with or without _XOPEN_SOURCE_EXTENDED])
AC_MSG_WARN([*** This build may not compile. Consider configuring with --disable-color or installing ncurses])),
AC_MSG_WARN([*** Can't check need for _XOPEN_SOURCE_EXTENDED when cross-compiling]))
fi
#fi
AC_MSG_CHECKING([whether LINES and COLS can be redefined])
AC_TRY_RUN([
#include <curses.h>
int main(void)
{
LINES = 80;
COLS = 25;
return 0;
}],
AC_DEFINE(REDEFINIG_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
# Check for groff html support
AC_MSG_CHECKING([for HTML support in groff])
groff -t -mandoc -Thtml </dev/null >/dev/null
if test $? -ne 0 ; then
echo "no"
echo "*** Will not generate HTML version of man pages ***"
echo "*** Consider installing a newer version of groff with HTML support ***"
groff_html_support=no
else
echo "yes"
groff_html_support=yes
fi
AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)
AC_CONFIG_FILES([
Makefile
doc/Makefile

View File

@@ -83,9 +83,9 @@
<h2><a name="1.5"></a>1.5. Why the name change from TIP?</h2>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h2><a name="1.6"></a>1.6. What is the current version of nano?</h2>
<blockquote><p>The current version of nano *should* be 2.0.7. Of course, you should always check the nano homepage to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano *should* be 2.2.0. Of course, you should always check the nano homepage to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.7"></a>1.7. I want to read the man page without having to download the program!</h2>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="http://www.nano-editor.org/dist/v2.0/nano.1.html">here</a>.</p></blockquote>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="http://www.nano-editor.org/dist/v2.2/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
<h1><a name="2"></a>2. Where to get GNU nano.</h1>
<h2><a name="2.1"></a>2.1. FTP and WWW sites that carry nano.</h2>
@@ -99,8 +99,8 @@
<h2><a name="2.2"></a>2.2. RedHat and derivatives (.rpm) packages.</h2>
<blockquote>
<ul>
<li><a href="http://www.nano-editor.org/dist/v2.0/RPMS/">http://www.nano-editor.org/dist/v2.0/RPMS/</a></li>
<li><a href="http://www.ewtoo.org/~astyanax/nano/dist/v2.0/RPMS/">http://www.ewtoo.org/~astyanax/nano/dist/v2.0/RPMS/</a></li>
<li><a href="http://www.nano-editor.org/dist/v2.2/RPMS/">http://www.nano-editor.org/dist/v2.2/RPMS/</a></li>
<li><a href="http://www.ewtoo.org/~astyanax/nano/dist/v2.2/RPMS/">http://www.ewtoo.org/~astyanax/nano/dist/v2.2/RPMS/</a></li>
</ul>
</blockquote>
<h2><a name="2.3"></a>2.3. Debian (.deb) packages.</h2>
@@ -116,7 +116,7 @@
<blockquote><p>For the 'bleeding edge' current version of nano, you can use subversion to download the current source code. <b>Note:</b> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://svn.savannah.gnu.org/viewvc/trunk/nano/README.SVN?root=nano&view=markup">the nano SVN document</a> for info on anonymous SVN access to the nano source.</p></blockquote>
<hr width="100%">
<h1><a name="3"></a>3. Installation and Configuration</h1>
<h2><a name="3.1"></a>3.1. How do install the RPM or DEB package?</h2>
<h2><a name="3.1"></a>3.1. How do I install the RPM or DEB package?</h2>
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y.z-1.i386.rpm</b> if you have a RedHat-ish system or <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. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
<h2><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h2>
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
@@ -246,7 +246,7 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<h2><a name="7.2"></a>7.2. I want to send the development team a big load of cash (or just a thank you).</h2>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="http://www.nano-editor.org/dist/v2.0/BUGS">bug</a> in the program or implement a <a href="http://www.nano-editor.org/dist/v2.0/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="http://www.nano-editor.org/dist/v2.2/BUGS">bug</a> in the program or implement a <a href="http://www.nano-editor.org/dist/v2.2/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<h2><a name="7.3"></a>7.3. How do I submit a bug report or patch?</h2>
<blockquote>
<p>The best place to submit bugs is to the <A HREF="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</A> as you can check whether the bug you are submitting has already been submitted.
@@ -256,8 +256,10 @@ Of course, due to the license change you can now use the <A HREF="http://www.was
<h2><a name="7.5"></a>7.5. Can I have write access to the subversion tree?</h2>
<blockquote><p>Re-read Section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
<h2><a name="8"></a>8. ChangeLog</h2>
<blockquote><p>2007/12/21 - Update maintainer information. (DLR)<br>
2008/03/16 - Update docs to refer to subversion instead of CVS, add more words about Apline, and refer to Savannah for bugs and patches. (chrisa)
<blockquote><p>2009/11/30 - Update various bits for nano 2.2.x. (DLR)<br>
2009/11/18 - Typo fix. (j.mader@gmail.com)<br>
2008/03/16 - Update docs to refer to subversion instead of CVS, add more words about Alpine, and refer to Savannah for bugs and patches. (chrisa)<br>
2007/12/21 - Update maintainer information. (DLR)<br>
2007/12/09 - Add minor punctuation and wording fixes, and update various sections to account for Alpine. (DLR)<br>
2007/08/26 - Update links to the Free Translation Project. (DLR)<br>
2007/07/29 - Update RPM links for nano 2.0.x. (DLR)<br>

View File

@@ -6,20 +6,30 @@ endif
if USE_NANORC
man_MANS = nano.1 nanorc.5 rnano.1
if GROFF_HTML
BUILT_SOURCES = nano.1.html nanorc.5.html rnano.1.html
endif
else
man_MANS = nano.1 rnano.1
if GROFF_HTML
BUILT_SOURCES = nano.1.html rnano.1.html
endif
endif
nano_man_mans = nano.1 nanorc.5 rnano.1
if GROFF_HTML
htmlman_DATA = nano.1.html nanorc.5.html rnano.1.html
htmlmandir = $(datadir)/nano/man-html
nano_built_sources = nano.1.html nanorc.5.html rnano.1.html
nano.1.html: nano.1
groff -t -mandoc -Thtml < $< > $@
groff -t -mandoc -Thtml < $? > $@
nanorc.5.html: nanorc.5
groff -t -mandoc -Thtml < $< > $@
groff -t -mandoc -Thtml < $? > $@
rnano.1.html: rnano.1
groff -t -mandoc -Thtml < $< > $@
groff -t -mandoc -Thtml < $? > $@
EXTRA_DIST = $(nano_man_mans) $(nano_built_sources)
else
EXTRA_DIST = $(nano_man_mans)
endif

View File

@@ -2,20 +2,32 @@ mandir = @mandir@/fr
if USE_NANORC
man_MANS = nano.1 nanorc.5 rnano.1
if GROFF_HTML
BUILT_SOURCES = nano.1.html nanorc.5.html rnano.1.html
endif
else
man_MANS = nano.1 rnano.1
if GROFF_HTML
BUILT_SOURCES = nano.1.html rnano.1.html
endif
endif
nano_man_mans = nano.1 nanorc.5 rnano.1
if GROFF_HTML
htmlman_DATA = nano.1.html nanorc.5.html rnano.1.html
htmlmandir = $(datadir)/nano/man-html/fr
nano_built_sources = nano.1.html nanorc.5.html rnano.1.html
nano.1.html: nano.1
groff -t -mandoc -Thtml < $< > $@
groff -t -mandoc -Thtml < $? > $@
nanorc.5.html: nanorc.5
groff -t -mandoc -Thtml < $< > $@
groff -t -mandoc -Thtml < $? > $@
rnano.1.html: rnano.1
groff -t -mandoc -Thtml < $< > $@
groff -t -mandoc -Thtml < $? > $@
EXTRA_DIST = $(nano_man_mans) $(nano_built_sources)
else
EXTRA_DIST = $(nano_man_mans)
endif

View File

@@ -230,7 +230,7 @@ Passe automatiquement
\fIcolonne\fR. Si la valeur indiquée est de 0 ou moins, le point de
passage à la ligne aura lieu à la taille de l'écran moins \fIcolonne\fR.
Cela permet de faire varier le point de passage à la ligne lorsque l'on
change la taille de l'écran. La valeur par défaut est de -8.
change la taille de l'écran. La valeur par défaut est de \-8.
.TP
.B \-s \fIprogramme\fP (\-\-speller=\fIprogramme\fP)
Choix d'un correcteur orthographique de remplacement.

View File

@@ -143,7 +143,7 @@ Passe automatiquement
\fIn\fR. Si la valeur indiquée est de 0 ou moins, le point de passage à
la ligne aura lieu à la taille de l'écran moins \fIn\fR. Cela permet de
faire varier le point de passage à la ligne lorsque l'on change la
taille de l'écran. La valeur par défaut est de -8.
taille de l'écran. La valeur par défaut est de \-8.
.TP
.B set/unset historylog
Active l'utilisation de

View File

@@ -1,6 +1,6 @@
.\" Hey, EMACS: -*- nroff -*-
.\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
.\" Free Software Foundation, Inc.
.\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
.\" 2008, 2009 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -19,7 +19,7 @@
.\" <http://www.gnu.org/licenses/>.
.\"
.\" $Id$
.TH NANO 1 "version 2.0.0" "August 23, 2007"
.TH NANO 1 "version 2.2.0" "November 30, 2009"
.\" Please adjust this date whenever revising the manpage.
.\"
@@ -62,7 +62,7 @@ line.
.TP
.B \-B (\-\-backup)
When saving a file, back up the previous version of it to the current
filename suffixed with a ~.
filename suffixed with a ~.
.TP
.B \-C \fIdir\fP (\-\-backupdir=\fIdir\fP)
Set the directory where \fBnano\fP puts unique backup files if file
@@ -79,11 +79,11 @@ Enable multiple file buffers, if available.
.TP
.B \-H (\-\-historylog)
Log search and replace strings to \fI~/.nano_history\fP, so they can be
retrieved in later sessions, if nanorc support is available.
retrieved in later sessions, if \fInanorc\fP support is available.
.TP
.B \-I (\-\-ignorercfiles)
Don't look at \fISYSCONFDIR/nanorc\fP or \fI~/.nanorc\fP, if nanorc
support is available.
Don't look at \fISYSCONFDIR/nanorc\fP or \fI~/.nanorc\fP, if
\fInanorc\fP support is available.
.TP
.B \-K (\-\-rebindkeypad)
Interpret the numeric keypad keys so that they all work properly. You
@@ -107,10 +107,11 @@ Tab.
.TP
.B \-R (\-\-restricted)
Restricted mode: don't read or write to any file not specified on the
command line; read any nanorc files; allow suspending; allow a file
to be appended to, prepended to, or saved under a different name if it
already has one; or use backup files or spell checking. Also accessible
by invoking \fBnano\fP with any name beginning with 'r' (e.g. "rnano").
command line; read any \fInanorc\fP files; allow suspending; allow a
file to be appended to, prepended to, or saved under a different name if
it already has one; or use backup files or spell checking. Also
accessible by invoking \fBnano\fP with any name beginning with 'r' (e.g.
"rnano").
.TP
.B \-S (\-\-smooth)
Enable smooth scrolling. Text will scroll line-by-line, instead of the
@@ -172,11 +173,15 @@ chroot.
Preserve the XON and XOFF sequences (^Q and ^S) so they will be caught
by the terminal.
.TP
.B \-q (\-\-quiet)
Do not report errors in the \fInanorc\fP file and ask them to be
acknowledged by pressing Enter at startup.
.TP
.B \-r \fIcols\fP (\-\-fill=\fIcols\fP)
Wrap lines at column \fIcols\fP. If this value is 0 or less, wrapping
will occur at the width of the screen less \fIcols\fP columns, allowing
the wrap point to vary along with the width of the screen if the screen
is resized. The default value is -8.
is resized. The default value is \-8.
.TP
.B \-s \fIprog\fP (\-\-speller=\fIprog\fP)
Enable alternative spell checker command.
@@ -185,6 +190,10 @@ Enable alternative spell checker command.
Always save changed buffer without prompting. Same as Pico's \fB-t\fP
option.
.TP
.B \-u (\-\-undo)
Enable experimental generic-purpose undo code. By default, the undo and redo
shortcuts are Meta-U and Meta-E, respectively.
.TP
.B \-v (\-\-view)
View file (read only) mode.
.TP
@@ -197,6 +206,13 @@ Disable help screen at bottom of editor.
.B \-z (\-\-suspend)
Enable suspend ability.
.TP
.B \-$ (\-\-softwrap)
Enable 'soft wrapping'. \fBnano\fP will attempt to display the entire
contents of a line, even if it is longer than the screen width. Since
\&'$' normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g. 'nano \-wS$') or pass it
separately (e.g. 'nano \-wS \-$').
.TP
.B \-a, \-b, \-e, \-f, \-g, \-j
Ignored, for compatibility with Pico.
@@ -208,7 +224,7 @@ should be provided with \fBnano\fP.
.SH NOTES
If no alternative spell checker command is specified on the command
line or in one of the nanorc files, \fBnano\fP will check the
line or in one of the \fInanorc\fP files, \fBnano\fP will check the
\fBSPELL\fP environment variable for one.
In some cases \fBnano\fP will try to dump the buffer into an emergency

View File

@@ -1,5 +1,5 @@
.\" Hey, EMACS: -*- nroff -*-
.\" Copyright (C) 2003, 2004, 2005, 2006, 2007
.\" Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
.\" Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
@@ -45,9 +45,9 @@ the command line options. Additionally, the \fBsyntax\fP, \fBcolor\fP,
and \fBicolor\fP keywords are used to define syntax highlighting rules
for different text patterns. \fBnano\fP will read one command per line.
Options in nanorc files take precedence over nano's defaults, and
command line options override nanorc settings. Also, options are unset
by default, except for those that take arguments.
Options in \fInanorc\fP files take precedence over nano's defaults, and
command line options override \fInanorc\fP settings. Also, options are
unset by default, except for those that take arguments.
Quotes inside string parameters don't have to be escaped with
backslashes. The last double quote in the string will be treated as its
@@ -57,6 +57,11 @@ match \fI"\fP, \fI'\fP, \fI)\fP, \fI>\fP, \fI]\fP, and \fI}\fP.
The supported commands and arguments are:
.TP 3
.B set/unset allow_insecure_backup
When backing up files, allow the backup to succeed even if its permissions
can't be (re)set due to special OS considerations. You should
NOT enable this option unless you are sure you need it.
.TP
.B set/unset autoindent
Use auto-indentation.
.TP
@@ -91,7 +96,7 @@ Use cut to end of line by default.
.B set fill \fIn\fP
Wrap lines at column number \fIn\fP. If \fIn\fP is 0 or less, the
maximum line length will be the screen width less \fIn\fP columns. The
default value is -8.
default value is \-8.
.TP
.B set/unset historylog
Enable \fI~/.nano_history\fP for saving and reading search/replace
@@ -145,6 +150,11 @@ paragraphs. They cannot contain blank characters. Only closing
punctuation, optionally followed by closing brackets, can end sentences.
The default value is "\fI!.?\fP".
.TP
.B set/unset quiet
\fBnano\fP will not report errors in the \fInanorc\fP file and ask them
to be acknowledged by pressing enter at startup. If this is used it
should be placed at the top of the file to be fully effective.
.TP
.B set/unset quickblank
Do quick statusbar blanking. Statusbar messages will disappear after 1
keystroke instead of 25.
@@ -180,6 +190,9 @@ line.
.B set/unset smooth
Use smooth scrolling by default.
.TP
.B set/unset softwrap
Enable soft line wrapping for easier viewing of very long lones.
.TP
.B set speller "\fIspellprog\fP"
Use spelling checker \fIspellprog\fP instead of the built-in one, which
calls \fIspell\fP.
@@ -197,9 +210,15 @@ Convert typed tabs to spaces.
.B set/unset tempfile
Save automatically on exit, don't prompt.
.TP
.B set/unset undo
Enable experimental generic-purpose undo code.
.TP
.B set/unset view
Disallow file modification.
.TP
.B set/unset softwrap
Enable soft line wrapping for easier viewing of very long lones.
.TP
.B set whitespace "\fIstring\fP"
Set the two characters used to display the first characters of tabs and
spaces. They must be single-column characters.
@@ -210,7 +229,7 @@ characters as parts of words.
.TP
.B syntax "\fIstr\fP" ["\fIfileregex\fP" ... ]
Defines a syntax named \fIstr\fP which can be activated via the
-Y/--syntax command line option, or will be automatically activated if
\-Y/\-\-syntax command line option, or will be automatically activated if
the current filename matches the extended regular expression
\fIfileregex\fP. All following \fBcolor\fP and \fBicolor\fP statements
will apply to \fIsyntax\fP until a new syntax is defined.
@@ -262,7 +281,7 @@ followed by an alpha character or the word "Space".
Example: ^C
.TP
.B M-
followed by a prinable character or the word "Space".
followed by a printable character or the word "Space".
Example: M-C
.TP
.B F
@@ -396,6 +415,12 @@ Count the number of words in the current buffer.
.B refresh
Refresh the screen.
.TP
.B undo
Undo the text action peformed (add text, delete text, etc).
.TP
.B redo
Redo the last undone action (i.e., undo an undo).
.TP
.B suspend
Suspend the editor (if the suspend function is enabled, see the
"suspendenable" entry below).
@@ -431,7 +456,7 @@ When writing a file, append to the end instead of overwriting.
When writing a file, 'prepend' (write at the beginning) instead of overwriting.
.TP
.B backup
When writing a file, create a backup of the current file.
When writing a file, create a backup of the current file.
.TP
.B firstfile
Move to the first file when using the file browser (reading or writing files).
@@ -514,6 +539,13 @@ The 'go to directory' menu.
.TP
.B all
A special name meaning: apply to all menus where this function exists.
.TP
.B unbind \fIkey\fP \fImenu\fP
Unbind the key \fIkey\fP from the menu named \fImenu\fP or from all
menus by using \fIall\fP. Same key syntax as for binding.
Rebinds the key \fIkey\fP to a new function named \fIfunction\fP in the
context of menu \fImenu\fP. The format of \fIkey\fP should be one of:
.SH FILES
.TP
.I SYSCONFDIR/nanorc

View File

@@ -141,6 +141,9 @@
## Use smooth scrolling as the default.
# set smooth
## Enable soft line wrapping (AKA full line display).
# set softwrap
## Use this spelling checker instead of the internal one. This option
## does not properly have a default value.
##
@@ -158,6 +161,10 @@
## Save automatically on exit, don't prompt.
# set tempfile
## Enable the new (EXPERIMENTAL) generic undo code, not just for line
## cuts.
# set undo
## Disallow file modification. Why would you want this in an rcfile? ;)
# set view
@@ -222,6 +229,9 @@
# bind M-A casesens search
# bind ^S research main
## Set this if your backspace key sends delete most of the time (2.1.3+)
# bind kdel backspace all
## Nanorc files
# include "@PKGDATADIR@/nanorc.nanorc"
@@ -229,9 +239,27 @@
## C/C++
# include "@PKGDATADIR@/c.nanorc"
## Makefiles
# include "@PKGDATADIR@/makefile.nanorc"
## Cascading Style Sheets
# include "@PKGDATADIR@/css.nanorc"
## Debian files
# include "@PKGDATADIR@/debian.nanorc"
## Gentoo files
# include "@PKGDATADIR@/gentoo.nanorc"
## HTML
# include "@PKGDATADIR@/html.nanorc"
## PHP
# include "@PKGDATADIR@/php.nanorc"
## TCL
# include "@PKGDATADIR@/tcl.nanorc"
## TeX
# include "@PKGDATADIR@/tex.nanorc"
@@ -259,6 +287,18 @@
## Java
# include "@PKGDATADIR@/java.nanorc"
## Fortran
# include "@PKGDATADIR@/fortran.nanorc"
## Objective-C
# include "@PKGDATADIR@/objc.nanorc"
## OCaml
# include "@PKGDATADIR@/ocaml.nanorc"
## AWK
# include "@PKGDATADIR@/awk.nanorc"
## Assembler
# include "@PKGDATADIR@/asm.nanorc"
@@ -267,3 +307,6 @@
## POV-Ray
# include "@PKGDATADIR@/pov.nanorc"
## XML-type files
# include "@PKGDATADIR@/xml.nanorc"

View File

@@ -1,5 +1,6 @@
pkgdata_DATA = asm.nanorc \
c.nanorc \
cmake.nanorc \
groff.nanorc \
html.nanorc \
java.nanorc \
@@ -19,6 +20,11 @@ pkgdata_DATA = asm.nanorc \
debian.nanorc \
awk.nanorc \
css.nanorc \
xml.nanorc
xml.nanorc \
ocaml.nanorc \
objc.nanorc \
fortran.nanorc \
makefile.nanorc \
mgp.nanorc
EXTRA_DIST = $(pkgdata_DATA)

View File

@@ -8,7 +8,7 @@ color green "\<(class|namespace|template|public|protected|private|typename|this|
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
color magenta "\<(goto|continue|break|return)\>"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)"
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
##
## GCC builtins

19
doc/syntax/cmake.nanorc Normal file
View File

@@ -0,0 +1,19 @@
## CMake syntax highlighter for GNU Nano
##
syntax "cmake" "(CMakeLists\.txt|\.cmake)$"
icolor green "^[[:space:]]*[A-Z0-9_]+"
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
icolor brightgreen "^[[:space:]]*\<((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)\>[[:space:]]"
color brightgreen "[[:space:]]\<(OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))\>[[:space:]]"
icolor brightred "^[[:space:]]*\<((end)?(function|macro)|return)"
icolor cyan start="\$(\{|ENV\{)" end="\}"
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
icolor brightblue "^([[:space:]]*)?#.*"
icolor brightblue "[[:space:]]#.*"
color ,green "[[:space:]]+$"

41
doc/syntax/fortran.nanorc Normal file
View File

@@ -0,0 +1,41 @@
## Here is an example for Fortran 90/95
syntax "fortran" "\.(f|f90|f95)$"
#color red "\<[A-Z_]a[0-9A-Z_]+\>"
color red "\<[0-9]+\>"
icolor green "\<(action|advance|all|allocatable|allocated|any|apostrophe)\>"
icolor green "\<(append|asis|assign|assignment|associated|character|common)\>"
icolor green "\<(complex|data|default|delim|dimension|double precision)\>"
icolor green "\<(elemental|epsilon|external|file|fmt|form|format|huge)\>"
icolor green "\<(implicit|include|index|inquire|integer|intent|interface)\>"
icolor green "\<(intrinsic|iostat|kind|logical|module|none|null|only)>"
icolor green "\<(operator|optional|pack|parameter|pointer|position|private)\>"
icolor green "\<(program|public|real|recl|recursive|selected_int_kind)\>"
icolor green "\<(selected_real_kind|subroutine|status)\>"
icolor cyan "\<(abs|achar|adjustl|adjustr|allocate|bit_size|call|char)\>"
icolor cyan "\<(close|contains|count|cpu_time|cshift|date_and_time)\>"
icolor cyan "\<(deallocate|digits|dot_product|eor|eoshift|function|iachar)\>"
icolor cyan "\<(iand|ibclr|ibits|ibset|ichar|ieor|iolength|ior|ishft|ishftc)\>"
icolor cyan "\<(lbound|len|len_trim|matmul|maxexponent|maxloc|maxval|merge)\>"
icolor cyan "\<(minexponent|minloc|minval|mvbits|namelist|nearest|nullify)\>"
icolor cyan "\<(open|pad|present|print|product|pure|quote|radix)\>"
icolor cyan "\<(random_number|random_seed|range|read|readwrite|replace)\>"
icolor cyan "\<(reshape|rewind|save|scan|sequence|shape|sign|size|spacing)\>"
icolor cyan "\<(spread|sum|system_clock|target|transfer|transpose|trim)\>"
icolor cyan "\<(ubound|unpack|verify|write|tiny|type|use|yes)\>"
icolor yellow "\<(.and.|case|do|else|else?if|else?where|end|end?do|end?if)\>"
icolor yellow "\<(end?select|.eqv.|forall|if|lge|lgt|lle|llt|.neqv.|.not.)\>"
icolor yellow "\<(.or.|repeat|select case|then|where|while)\>"
icolor magenta "\<(continue|cycle|exit|go?to|result|return)\>"
## String highlighting.
icolor yellow "<[^= ]*>" ""(\\.|[^"])*""
## Comment highlighting
icolor blue "!.*"

View File

@@ -2,28 +2,32 @@
##
syntax "ebuild" "\.e(build|class)$"
## All the standard portage functions
color brightgreen "^src_(unpack|compile|install|test)" "^pkg_(config|nofetch|setup|(pre|post)(inst|rm))"
color brightgreen "^src_(unpack|prepare|configure|compile|install|test)" "^pkg_(config|nofetch|setup|(pre|post)(inst|rm))"
## Highlight bash related syntax
color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while|continue|break)\>"
color green "\<(declare|eval|exec|let)\>"
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
color green "-(e|d|f|r|g|u|w|x|L)\>"
color green "-[edfgruwxL]\>"
color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>"
## Highlight variables ... official portage ones in red, all others in bright red
color brightred "\$\{?[a-zA-Z_0-9]+\}?"
color red "\<(ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|FILESDIR|WORKDIR|(P|R)?DEPEND|PROVIDE|DISTDIR|RESTRICT|USERLAND)\>"
color red "\<(S|D|T|PV|PF|P|PN|A)\>" "\<C(XX)?FLAGS\>" "\<LDFLAGS\>" "\<C(HOST|TARGET|BUILD)\>"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|(P|R)?DEPEND|PROVIDE|PROPERTIES|RESTRICT|USERLAND)\>"
color red "\<(S|D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|ROOT|WORKDIR)\>" "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>"
color red "\<QA_((TEXTRELS|EXECSTACK|WX_LOAD)(_[a-zA-Z_0-9]+)?|DT_HASH|PRESTRIPPED)\>" "\<WANT_AUTO(CONF|MAKE)\>" "\<AT_M4DIR\>"
## Highlight portage commands
color magenta "\<use(_(with|enable))?\> [!a-zA-Z0-9_+ -]*" "inherit.*"
color brightblue "\<e(begin|end|conf|install|make|warn|infon?|error|log|patch|new(group|user))\>"
color brightblue "\<die\>" "\<use(_(with|enable))?\>" "\<inherit\>" "\<has\>" "\<(has|best)_version\>" "\<unpack\>"
color brightblue "\<(do|new)(ins|s?bin|doc|lib(|\.so|\.a)|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
color brightblue "\<e(begin|end|conf|install|make|qmake[34]|ant|(qa)?warn|infon?|error|log|patch|new(group|user))\>"
color brightblue "\<e(pause|beep|mktemp|(cvs|svn)_clean|punt_cxx)\>" "\<e(aclocal|auto(reconf|header|conf|make))\>"
color brightblue "\<built_with_use\>" "\<make_desktop_entry\>" "\<unpack(_(makeself|pdv))?\>"
color brightblue "\<die\>" "\<use(_(with|enable))?\>" "\<inherit\>" "\<has\>" "\<(has|best)_version\>"
color brightblue "\<(do|new)(ins|(games)?s?bin|doc|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
color brightblue "\<do(python|sed|dir|hard|sym|html|jar|mo)\>" "\<keepdir\>"
color brightblue "prepall(|docs|info|man|strip)" "prep(info|lib|lib\.(so|a)|man|strip)"
color brightblue "\<(|doc|ins|exe)into\>" "\<f(owners|perms)\>" "\<(exe|ins|dir)opts\>"
color brightblue "prepall(docs|info|man|strip)?" "prep(info|lib|lib\.(so|a)|man|strip|gamesdirs)"
color brightblue "\<(doc|ins|exe)?into\>" "\<(f|games)(owners|perms)\>" "\<(exe|ins|dir)opts\>"
## Highlight common commands used in ebuilds
color blue "\<make\>" "\<(cat|cd|chmod|chown|cp|echo|env|export|grep|let|ln|mkdir|mv|rm|sed|set|tar|touch|unset)\>"
color blue "\<make\>" "\<(awk|cat|cd|chmod|chown|cp|echo|env|export|find|e?grep|ln|mkdir|mv|rm|sed|set|tar|touch|unset|xargs)\>"
## Highlight comments (doesnt work that well)
color yellow "#.*$"
color yellow "(^|[[:space:]])#.*$"
## Highlight strings (doesnt work that well)
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
## Trailing space is bad!
@@ -31,17 +35,18 @@ color ,green "[[:space:]]+$"
## Here is an example for Portage control files
##
syntax "/etc/portage" "\.(keywords|mask|unmask|use)$"
syntax "/etc/portage" "\.(keywords|mask|unmask|use)(/.+)?$"
## Base text:
color green "^.+$"
## Use flags:
color brightred "[[:space:]]+\+?[a-zA-Z0-9_-]+"
color brightblue "[[:space:]]+-[a-zA-Z0-9_-]+"
## Likely version numbers:
## Likely version and slot numbers:
color magenta "-[[:digit:]].*([[:space:]]|$)"
color magenta ":[^[:space:]]+([[:space:]]|$)"
## Accepted arches:
color white "[~-]?\<(alpha|amd64|arm|hppa|ia64|mips|ppc|ppc64|s390|sh|sparc|x86|x86-fbsd)\>"
color white "[[:space:]][~-]?\*"
color white "[~-]?\<(alpha|amd64|arm|hppa|ia64|mips|ppc|ppc64|s390|sh|sparc(-fbsd)?|x86(-fbsd)?)\>"
color white "[[:space:]][*~-]?\*"
## Categories:
color cyan "^[[:space:]]*.*/"
## Masking regulators:

View File

@@ -0,0 +1,8 @@
# unattributed syntax highlighting example from wiki.linuxhelp.net/
syntax "makefile" "Makefile[^/]*$"
color red "[:=]"
color magenta "\<(if|ifeq|else|endif)\>"
color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
color brightblue "^[^ ]+:"
color green "#.*$"

8
doc/syntax/mgp.nanorc Normal file
View File

@@ -0,0 +1,8 @@
## Here is an example for Magicpoint presentations
##
syntax "mgp" "\.mgp$"
header "^%include.*"
icolor green "^%[a-z].*$"
color cyan "(^|[[:space:]])#.*$"
color cyan "(^|[[:space:]])%%.*$"
color ,green "[[:space:]]+$"

View File

@@ -4,8 +4,8 @@ syntax "nanorc" "\.?nanorc$"
## Possible errors and parameters
icolor brightwhite "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
## Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|speller|suspend|tabsize|tabstospaces|tempfile|view|whitespace|wordbounds)\>"
icolor green "^[[:space:]]*(set|unset|include|syntax)\>"
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|autoindent|backup|backupdir|backwards|boldtext|brackets|casesensitive|const|cut|fill|historylog|matchbrackets|morespace|mouse|multibuffer|noconvert|nofollow|nohelp|nonewlines|nowrap|operatingdir|preserve|punct)\>" "^[[:space:]]*(set|unset)[[:space:]]+(quickblank|quotestr|rebinddelete|rebindkeypad|regexp|smarthome|smooth|softwrap|speller|suspend|suspendenable|tabsize|tabstospaces|tempfile|undo|view|whitespace|wordbounds)\>"
icolor green "^[[:space:]]*(set|unset|include|syntax|header)\>"
## Colors
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="

41
doc/syntax/objc.nanorc Normal file
View File

@@ -0,0 +1,41 @@
## Here is an example for C/C++/Obj-C.
##
syntax "m" "\.m$"
## Stuffs
color brightwhite "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(float|double|BOOL|bool|char|int|short|long|id|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<[[:alpha:]_][[:alnum:]_]*_t\>"
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|using|mutable|volatile|register|explicit)\>"
color brightgreen "\<(for|if|while|do|else|case|default|switch)\>"
color brightgreen "\<(try|throw|catch|operator|new|delete)\>"
color brightgreen "\<(goto|continue|break|return)\>"
color brightgreen "@\<(en(code|d)|i(mplementation|nterface)|selector)\>"
##
## GCC builtins
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
## Selector/method
color brightmagenta "(^|[[:space:]])\[.*[[:space:]].*\]"
color white ":[[:alnum:]]*"
color magenta "[[:alnum:]]*:"
color white "\[[^][:space:]]*\]"
##
## String highlighting. You will in general want your comments and
## strings to come last, because syntax highlighting rules will be
## applied in the order they are read in.
color brightblack "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
color brightblack "<[^= ]*>" ""(\\.|[^"])*""
color brightblue "@"(\\.|[^"])*""
##
## This string is VERY resource intensive!
## color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
color brightblue "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
## Comment highlighting
color yellow "//.*"
color yellow start="/\*" end="\*/"

27
doc/syntax/ocaml.nanorc Normal file
View File

@@ -0,0 +1,27 @@
# OCaml sample nanorc
#
syntax "ocaml" "\.mli?$"
#uid
color red "\<[A-Z][0-9a-z_]{2,}\>"
#declarations
color green "\<(let|val|method|in|and|rec|private|virtual|constraint)\>"
#structure items
color red "\<(type|open|class|module|exception|external)\>"
#patterns
color blue "\<(fun|function|functor|match|try|with)\>"
#patterns-modifiers
color yellow "\<(as|when|of)\>"
#conditions
color cyan "\<(if|then|else)\>"
#blocs
color magenta "\<(begin|end|object|struct|sig|for|while|do|done|to|downto)\>"
#constantes
color green "\<(true|false)\>"
#modules/classes
color green "\<(include|inherit|initializer)\>"
#expr modifiers
color yellow "\<(new|ref|mutable|lazy|assert|raise)\>"
#comments
color white start="\(\*" end="\*\)"
#strings (no multiline handling yet)
color brightblack ""[^\"]*""

View File

@@ -1,6 +1,7 @@
## Here is an example for Perl.
##
syntax "perl" "\.p[lm]$"
header "^#!.*/perl[-0-9._]*"
color red "\<(accept|alarm|atan2|bin(d|mode)|c(aller|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))\>" "\<(get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)\>" "\<(keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek(dir)?)\>" "\<(se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr(y)?|truncate|umask)\>" "\<(un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\>"
color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne|lt|gt|le|ge|cmp|x|my|sub|use|package|can|isa)\>"
icolor cyan start="[$@%]" end="( |[^0-9A-Z_]|-)"

View File

@@ -1,8 +1,9 @@
## Here is an example for Python.
##
syntax "python" "\.py$"
header "^#!.*/python[-0-9._]*"
icolor brightblue "def [0-9A-Z_]+"
color brightcyan "\<(and|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|map|not|or|pass|print|raise|return|try|while)\>"
color brightcyan "\<(and|as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield)\>"
color brightgreen "['][^']*[^\\][']" "[']{3}.*[^\\][']{3}"
color brightgreen "["][^"]*[^\\]["]" "["]{3}.*[^\\]["]{3}"
color brightgreen start=""""[^"]" end=""""" start="'''[^']" end="'''"

View File

@@ -1,6 +1,7 @@
## Here is an example for Ruby.
##
syntax "ruby" "\.rb$"
header "^#!.*/ruby[-0-9._]*"
## Asciibetical list of reserved words
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>"
## Constants

View File

@@ -1,6 +1,7 @@
## Here is an example for Bourne shell scripts.
##
syntax "sh" "\.sh$"
header "^#!.*/(ba|k|pdk)?sh[-0-9_]*"
icolor brightgreen "^[0-9A-Z_]+\(\)"
color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|time|until|while)\>"
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"

View File

@@ -13,4 +13,4 @@ color green "(\(|\)|\;|`|\\|\$|<|>|!|=|&|\|)"
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
icolor brightred "\$\{?[0-9A-Z_!@#$*?-]+\}?"
color ,green "[[:space:]]+$"
color ,magenta "^([[:space:]]+|)#.*"
color ,magenta "^[[:space:]]*#.*"

View File

@@ -3,4 +3,4 @@
syntax "tex" "\.tex$"
icolor green "\\.|\\[A-Z]*"
color magenta "[{}]"
color blue "%.*"
color blue "(^|[^\])%.*"

View File

@@ -8,8 +8,8 @@
@c Run 'makeinfo' rather than 'texinfo-format-buffer'.
@smallbook
@set EDITION 0.1
@set VERSION 2.0.0
@set UPDATED 17 Dec 2007
@set VERSION 2.2.0
@set UPDATED 30 Nov 2009
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @code{nano}
@subtitle a small and friendly text editor.
@subtitle version 2.0.0
@subtitle version 2.2.0
@author Chris Allegretta
@page
@@ -33,8 +33,8 @@ editor.
This manual is part of the GNU @code{nano} distribution.@*
@sp4
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
2008, 2009 Free Software Foundation, Inc.
This document is dual-licensed. You may distribute and/or modify it
under the terms of either of the following licenses:
@@ -249,6 +249,10 @@ a chroot.
Preserve the ^Q (XON) and ^S (XOFF) sequences so data being sent to the
editor can be can be stopped and started.
@item -q, --quiet
Do not report errors in the nanorc file and ask them to be acknowledged
by pressing Enter at startup.
@item -r <#cols>, --fill=<#cols>
Wrap lines at column #cols. If this value is 0 or less, wrapping will
occur at the width of the screen less #cols, allowing it to vary along
@@ -266,6 +270,10 @@ Don't ask whether or not to save the current contents of the file when
exiting, assume yes. This is most useful when using @code{nano} as the
composer of a mailer program.
@item -u, --undo
Enable experimental generic-purpose undo code. By default, the undo and
redo shortcuts are Meta-U and Meta-E, respectively.
@item -v, --view
Don't allow the contents of the file to be altered. Note that this
option should NOT be used in place of correct file permissions to
@@ -288,6 +296,13 @@ disabled to display the help system navigation keys.
Enable @code{nano}'s suspend ability using the system's suspend
keystroke (usually ^Z).
@item -$, --softwrap
Enable 'soft wrapping'. @code{nano} will attempt to display the entire
contents of a line, even if it is longer than the screen width. Since
'$' normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g. 'nano -wS$') or pass it
separately (e.g. 'nano -wS -$').
@item -a, -b, -e, -f, -g, -j
Ignored, for compatibility with Pico.
@end table
@@ -447,6 +462,9 @@ nanorc. See @xref{Nanorc Files}, for more info.
@item Suspend Toggle (Meta-Z)
toggles the -z (@code{--suspend}) command line option.
@item Soft Wrapping Toggle (Meta-$)
toggles the -$ (@code{--softwrap}) command line option.
@end table
@@ -615,6 +633,9 @@ line.
@item set/unset smooth
Use smooth scrolling by default.
@item set/unset softwrap
Use soft wrapping by default.
@item set speller "spellprog"
Use spelling checker "spellprog" instead of the built-in one, which
calls "spell".
@@ -622,6 +643,10 @@ calls "spell".
@item set/unset suspend
Allow @code{nano} to be suspended.
@item set/unset suspendenable
If @code{nano} is allowed to be suspended, allow the suspend key
(usually ^Z) to actually suspend it.
@item set tabsize "n"
Use a tab size of "n" columns. The value of "n" must be greater than 0.
The default value is 8.
@@ -632,6 +657,9 @@ Convert typed tabs to spaces.
@item set/unset tempfile
Save automatically on exit, don't prompt.
@item set/unset undo
Enable experimental generic-purpose undo code.
@item set/unset view
Disallow file modification.

29
nano-regress Executable file
View File

@@ -0,0 +1,29 @@
#!/usr/bin/perl
use strict;
sub combinations {
return [] unless @_;
my $first = shift;
my @rest = combinations(@_);
return @rest, map { [$first, @$_] } @rest;
}
my @allargs=("--enable-debug", "--disable-wrapping", "--disable-justify", "--disable-extra", "--enable-tiny", "--disable-browser --disable-help --disable-mouse --disable-operatingdir --disable-speller", "--disable-multibuffer", "--disable-nanorc", "--with-slang");
my @combos = combinations(@allargs);
my $i = 0;
foreach my $name (@combos) {
my @args = @$name;
my $pct = $i / $#combos * 100;
printf "Trying with options: @args, %d%% done...\n", $pct;
my $cmd = "./configure @args && make clean all";
system("($cmd) >/dev/null 2>&1");
if ($? != 0) {
print "Build failed for args: @args\n";
print "To reproduce, run:\n $cmd\n";
exit(1);
}
$i++;
}
print "All options completed successfully!\n";

1021
po/bg.po

File diff suppressed because it is too large Load Diff

1112
po/ca.po

File diff suppressed because it is too large Load Diff

1010
po/cs.po

File diff suppressed because it is too large Load Diff

2188
po/da.po

File diff suppressed because it is too large Load Diff

1173
po/de.po

File diff suppressed because it is too large Load Diff

1024
po/es.po

File diff suppressed because it is too large Load Diff

1024
po/eu.po

File diff suppressed because it is too large Load Diff

2302
po/fi.po

File diff suppressed because it is too large Load Diff

1906
po/fr.po

File diff suppressed because it is too large Load Diff

1979
po/ga.po

File diff suppressed because it is too large Load Diff

1539
po/gl.po

File diff suppressed because it is too large Load Diff

1246
po/hu.po

File diff suppressed because it is too large Load Diff

989
po/id.po

File diff suppressed because it is too large Load Diff

1176
po/it.po

File diff suppressed because it is too large Load Diff

1136
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1021
po/nb.po

File diff suppressed because it is too large Load Diff

1154
po/nl.po

File diff suppressed because it is too large Load Diff

1171
po/nn.po

File diff suppressed because it is too large Load Diff

2100
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

995
po/ro.po

File diff suppressed because it is too large Load Diff

1188
po/ru.po

File diff suppressed because it is too large Load Diff

1218
po/rw.po

File diff suppressed because it is too large Load Diff

997
po/sr.po

File diff suppressed because it is too large Load Diff

1024
po/sv.po

File diff suppressed because it is too large Load Diff

989
po/tr.po

File diff suppressed because it is too large Load Diff

997
po/uk.po

File diff suppressed because it is too large Load Diff

1170
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
/**************************************************************************
* browser.c *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 *
* Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -156,7 +156,7 @@ char *do_browser(char *path, DIR *dir)
* time, put back the Enter key so that it's
* read in. */
if (old_selected == selected)
unget_kbinput(sc_seq_or(do_enter, 0), FALSE, FALSE);
unget_kbinput(sc_seq_or(DO_ENTER, 0), FALSE, FALSE);
}
}
#endif /* !DISABLE_MOUSE */
@@ -169,43 +169,43 @@ char *do_browser(char *path, DIR *dir)
if (!f)
break;
if (f->scfunc == total_refresh) {
if (f->scfunc == TOTAL_REFRESH) {
total_redraw();
} else if (f->scfunc == do_help_void) {
} else if (f->scfunc == DO_HELP_VOID) {
#ifndef DISABLE_HELP
do_browser_help();
curs_set(0);
do_browser_help();
curs_set(0);
#else
nano_disabled_msg();
#endif
/* Search for a filename. */
} else if (f->scfunc == do_search) {
} else if (f->scfunc == DO_SEARCH) {
curs_set(1);
do_filesearch();
curs_set(0);
/* Search for another filename. */
} else if (f->scfunc == (void *) whereis_next_msg) {
} else if (f->scfunc == DO_RESEARCH) {
do_fileresearch();
} else if (f->scfunc == do_page_up) {
} else if (f->scfunc == DO_PAGE_UP) {
if (selected >= (editwinrows + fileline % editwinrows) *
width)
selected -= (editwinrows + fileline % editwinrows) *
width;
else
selected = 0;
} else if (f->scfunc == do_page_down) {
} else if (f->scfunc == DO_PAGE_DOWN) {
selected += (editwinrows - fileline % editwinrows) *
width;
if (selected > filelist_len - 1)
selected = filelist_len - 1;
} else if (f->scfunc == (void *) first_file_msg) {
} else if (f->scfunc == FIRST_FILE_MSG) {
if (meta_key)
selected = 0;
} else if (f->scfunc == (void *) last_file_msg) {
} else if (f->scfunc == LAST_FILE_MSG) {
if (meta_key)
selected = filelist_len - 1;
/* Go to a specific directory. */
} else if (f->scfunc == (void *) goto_dir_msg) {
} else if (f->scfunc == GOTO_DIR_MSG) {
curs_set(1);
i = do_prompt(TRUE,
@@ -232,15 +232,15 @@ char *do_browser(char *path, DIR *dir)
* blank out ans, since we're done with it. */
statusbar(_("Cancelled"));
ans = mallocstrcpy(ans, "");
break;
continue;
} else if (i != 0) {
/* Put back the "Go to Directory" key and save
* answer in ans, so that the file list is displayed
* again, the prompt is displayed again, and what we
* typed before at the prompt is displayed again. */
unget_kbinput(sc_seq_or(do_gotolinecolumn_void, 0), FALSE, FALSE);
unget_kbinput(sc_seq_or(DO_GOTOLINECOLUMN_VOID, 0), FALSE, FALSE);
ans = mallocstrcpy(ans, answer);
break;
continue;
}
/* We have a directory. Blank out ans, since we're done
@@ -266,7 +266,7 @@ char *do_browser(char *path, DIR *dir)
_("Can't go outside of %s in restricted mode"),
operating_dir);
free(new_path);
break;
continue;
}
#endif
@@ -278,31 +278,31 @@ char *do_browser(char *path, DIR *dir)
strerror(errno));
beep();
free(new_path);
break;
continue;
}
/* Start over again with the new path value. */
free(path);
path = new_path;
goto change_browser_directory;
} else if (f->scfunc == do_up_void) {
} else if (f->scfunc == DO_UP_VOID) {
if (selected >= width)
selected -= width;
} else if (f->scfunc == do_left) {
} else if (f->scfunc == DO_LEFT) {
if (selected > 0)
selected--;
} else if (f->scfunc == do_down_void) {
} else if (f->scfunc == DO_DOWN_VOID) {
if (selected + width <= filelist_len - 1)
selected += width;
} else if (f->scfunc == do_right) {
} else if (f->scfunc == DO_RIGHT) {
if (selected < filelist_len - 1)
selected++;
} else if (f->scfunc == do_enter) {
} else if (f->scfunc == DO_ENTER) {
/* We can't move up from "/". */
if (strcmp(filelist[selected], "/..") == 0) {
statusbar(_("Can't move up a directory"));
beep();
break;
continue;
}
#ifndef DISABLE_OPERATINGDIR
@@ -314,7 +314,7 @@ char *do_browser(char *path, DIR *dir)
_("Can't go outside of %s in restricted mode"),
operating_dir);
beep();
break;
continue;
}
#endif
@@ -324,7 +324,7 @@ char *do_browser(char *path, DIR *dir)
statusbar(_("Error reading %s: %s"),
filelist[selected], strerror(errno));
beep();
break;
continue;
}
/* If we've successfully opened a file, we're done, so
@@ -332,7 +332,7 @@ char *do_browser(char *path, DIR *dir)
if (!S_ISDIR(st.st_mode)) {
retval = mallocstrcpy(NULL, filelist[selected]);
abort = TRUE;
break;
continue;
/* If we've successfully opened a directory, and it's
* "..", save the current directory in prev_dir, so that
* we can select it later. */
@@ -347,7 +347,7 @@ char *do_browser(char *path, DIR *dir)
statusbar(_("Error reading %s: %s"),
filelist[selected], strerror(errno));
beep();
break;
continue;
}
path = mallocstrcpy(path, filelist[selected]);
@@ -355,7 +355,7 @@ char *do_browser(char *path, DIR *dir)
/* Start over again with the new path value. */
goto change_browser_directory;
/* Abort the file browser. */
} else if (f->scfunc == do_exit) {
} else if (f->scfunc == DO_EXIT) {
abort = TRUE;
}
}
@@ -534,9 +534,9 @@ void browser_init(const char *path, DIR *dir)
}
/* If width isn't initialized yet, and we've taken up only one line,
* it means that width is equal to (COLS % longest). */
* it means that width is equal to longest. */
if (width == 0)
width = COLS % longest;
width = longest;
}
/* Determine the shortcut key corresponding to the values of kbinput
@@ -552,30 +552,32 @@ void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key)
if (!*meta_key) {
switch (*kbinput) {
case ' ':
*kbinput = sc_seq_or(do_page_down, 0);
*kbinput = sc_seq_or(DO_PAGE_DOWN, 0);
break;
case '-':
*kbinput = sc_seq_or(do_page_up, 0);
*kbinput = sc_seq_or(DO_PAGE_UP, 0);
break;
case '?':
*kbinput = sc_seq_or(do_help_void, 0);
#ifndef DISABLE_HELP
*kbinput = sc_seq_or(DO_HELP_VOID, 0);
#endif
break;
/* Cancel equivalent to Exit here. */
case 'E':
case 'e':
*kbinput = sc_seq_or(do_exit, 0);
*kbinput = sc_seq_or(DO_EXIT, 0);
break;
case 'G':
case 'g':
*kbinput = sc_seq_or((void *) goto_dir_msg, 0);
*kbinput = sc_seq_or(GOTO_DIR_MSG, 0);
break;
case 'S':
case 's':
*kbinput = sc_seq_or(do_enter, 0);
*kbinput = sc_seq_or(DO_ENTER, 0);
break;
case 'W':
case 'w':
*kbinput = sc_seq_or(do_search, 0);
*kbinput = sc_seq_or(DO_SEARCH, 0);
break;
}
}
@@ -839,18 +841,18 @@ int filesearch_init(void)
#endif
} else
#ifndef NANO_TINY
if (s && s->scfunc == (void *) case_sens_msg) {
if (s && s->scfunc == CASE_SENS_MSG) {
TOGGLE(CASE_SENSITIVE);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (s && s->scfunc == (void *) backwards_msg) {
} else if (s && s->scfunc == BACKWARDS_MSG) {
TOGGLE(BACKWARDS_SEARCH);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else
#endif
#ifdef HAVE_REGEX_H
if (s && s->scfunc == (void *) regexp_msg) {
if (s && s->scfunc == REGEXP_MSG) {
TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer);
return 1;

View File

@@ -2,7 +2,7 @@
/**************************************************************************
* chars.c *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 *
* Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -79,6 +79,16 @@ bool is_byte(int c)
return ((unsigned int)c == (unsigned char)c);
}
static void mbtowc_reset(void)
{
IGNORE_CALL_RESULT(mbtowc(NULL, NULL, 0));
}
static void wctomb_reset(void)
{
IGNORE_CALL_RESULT(wctomb(NULL, 0));
}
/* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c)
{
@@ -89,7 +99,7 @@ bool is_alnum_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
wc = bad_wchar;
}
@@ -109,7 +119,7 @@ bool is_blank_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
wc = bad_wchar;
}
@@ -156,7 +166,7 @@ bool is_cntrl_mbchar(const char *c)
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
wc = bad_wchar;
}
@@ -177,7 +187,7 @@ bool is_punct_mbchar(const char *c)
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
if (c_mb_len < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
wc = bad_wchar;
}
@@ -243,14 +253,14 @@ char *control_mbrep(const char *c, char *crep, int *crep_len)
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
*crep_len = bad_mbchar_len;
strncpy(crep, bad_mbchar, *crep_len);
} else {
*crep_len = wctomb(crep, control_wrep(wc));
if (*crep_len < 0) {
wctomb(NULL, 0);
wctomb_reset();
*crep_len = 0;
}
}
@@ -278,14 +288,14 @@ char *mbrep(const char *c, char *crep, int *crep_len)
/* Reject invalid Unicode characters. */
if (mbtowc(&wc, c, MB_CUR_MAX) < 0 || !is_valid_unicode(wc)) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
*crep_len = bad_mbchar_len;
strncpy(crep, bad_mbchar, *crep_len);
} else {
*crep_len = wctomb(crep, wc);
if (*crep_len < 0) {
wctomb(NULL, 0);
wctomb_reset();
*crep_len = 0;
}
}
@@ -311,7 +321,7 @@ int mbwidth(const char *c)
int width;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
wc = bad_wchar;
}
@@ -356,7 +366,7 @@ char *make_mbchar(long chr, int *chr_mb_len)
/* Reject invalid Unicode characters. */
if (*chr_mb_len < 0 || !is_valid_unicode((wchar_t)chr)) {
wctomb(NULL, 0);
wctomb_reset();
*chr_mb_len = 0;
}
} else {
@@ -388,7 +398,7 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
/* If buf contains an invalid multibyte character, only
* interpret buf's first byte. */
if (buf_mb_len < 0) {
mblen(NULL, 0);
IGNORE_CALL_RESULT(mblen(NULL, 0));
buf_mb_len = 1;
} else if (buf_mb_len == 0)
buf_mb_len++;
@@ -545,7 +555,7 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
s1_mb_len = parse_mbchar(s1, s1_mb, NULL);
if (mbtowc(&ws1, s1_mb, s1_mb_len) < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
ws1 = (unsigned char)*s1_mb;
bad_s1_mb = TRUE;
}
@@ -553,7 +563,7 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
s2_mb_len = parse_mbchar(s2, s2_mb, NULL);
if (mbtowc(&ws2, s2_mb, s2_mb_len) < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
ws2 = (unsigned char)*s2_mb;
bad_s2_mb = TRUE;
}
@@ -781,7 +791,7 @@ char *mbstrchr(const char *s, const char *c)
int c_mb_len = mbtowc(&wc, c, MB_CUR_MAX);
if (c_mb_len < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
wc = (unsigned char)*c;
bad_c_mb = TRUE;
}
@@ -790,7 +800,7 @@ char *mbstrchr(const char *s, const char *c)
int s_mb_len = parse_mbchar(s, s_mb, NULL);
if (mbtowc(&ws, s_mb, s_mb_len) < 0) {
mbtowc(NULL, NULL, 0);
mbtowc_reset();
ws = (unsigned char)*s;
bad_s_mb = TRUE;
}

View File

@@ -2,7 +2,7 @@
/**************************************************************************
* color.c *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 *
* Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -105,11 +105,13 @@ void color_init(void)
/* Update the color information based on the current filename. */
void color_update(void)
{
const syntaxtype *tmpsyntax;
syntaxtype *tmpsyntax;
syntaxtype *defsyntax = NULL;
colortype *tmpcolor, *defcolor = NULL;
assert(openfile != NULL);
openfile->syntax = NULL;
openfile->colorstrings = NULL;
/* If we specified a syntax override string, use it. */
@@ -121,8 +123,10 @@ void color_update(void)
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
tmpsyntax = tmpsyntax->next) {
if (strcmp(tmpsyntax->desc, syntaxstr) == 0)
if (strcmp(tmpsyntax->desc, syntaxstr) == 0) {
openfile->syntax = tmpsyntax;
openfile->colorstrings = tmpsyntax->color;
}
if (openfile->colorstrings != NULL)
break;
@@ -131,7 +135,7 @@ void color_update(void)
/* If we didn't specify a syntax override string, or if we did and
* there was no syntax by that name, get the syntax based on the
* file extension. */
* file extension, and then look in the header. */
if (openfile->colorstrings == NULL) {
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
tmpsyntax = tmpsyntax->next) {
@@ -141,6 +145,7 @@ void color_update(void)
* extensions, which we've checked for elsewhere. Skip over
* it here, but keep track of its color regexes. */
if (strcmp(tmpsyntax->desc, "default") == 0) {
defsyntax = tmpsyntax;
defcolor = tmpsyntax->color;
continue;
}
@@ -153,14 +158,16 @@ void color_update(void)
* already. */
if (not_compiled) {
e->ext = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(e->ext, e->ext_regex, REG_EXTENDED);
regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED);
}
/* Set colorstrings if we matched the extension
* regex. */
if (regexec(e->ext, openfile->filename, 0, NULL,
0) == 0)
0) == 0) {
openfile->syntax = tmpsyntax;
openfile->colorstrings = tmpsyntax->color;
}
if (openfile->colorstrings != NULL)
break;
@@ -174,12 +181,59 @@ void color_update(void)
}
}
}
/* If we haven't matched anything yet, try the headers */
if (openfile->colorstrings == NULL) {
#ifdef DEBUG
fprintf(stderr, "No match for file extensions, looking at headers...\n");
#endif
for (tmpsyntax = syntaxes; tmpsyntax != NULL;
tmpsyntax = tmpsyntax->next) {
exttype *e;
for (e = tmpsyntax->headers; e != NULL; e = e->next) {
bool not_compiled = (e->ext == NULL);
/* e->ext_regex has already been checked for validity
* elsewhere. Compile its specified regex if we haven't
* already. */
if (not_compiled) {
e->ext = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(e->ext, fixbounds(e->ext_regex), REG_EXTENDED);
}
/* Set colorstrings if we matched the extension
* regex. */
#ifdef DEBUG
fprintf(stderr, "Comparing header regex \"%s\" to fileage \"%s\"...\n", e->ext_regex, openfile->fileage->data);
#endif
if (regexec(e->ext, openfile->fileage->data, 0, NULL, 0) == 0) {
openfile->syntax = tmpsyntax;
openfile->colorstrings = tmpsyntax->color;
}
if (openfile->colorstrings != NULL)
break;
/* Decompile e->ext_regex's specified regex if we aren't
* going to use it. */
if (not_compiled) {
regfree(e->ext);
free(e->ext);
e->ext = NULL;
}
}
}
}
}
/* If we didn't get a syntax based on the file extension, and we
* have a default syntax, use it. */
if (openfile->colorstrings == NULL && defcolor != NULL)
if (openfile->colorstrings == NULL && defcolor != NULL) {
openfile->syntax = defsyntax;
openfile->colorstrings = defcolor;
}
for (tmpcolor = openfile->colorstrings; tmpcolor != NULL;
tmpcolor = tmpcolor->next) {
@@ -188,16 +242,119 @@ void color_update(void)
* regexes if we haven't already. */
if (tmpcolor->start == NULL) {
tmpcolor->start = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(tmpcolor->start, tmpcolor->start_regex,
regcomp(tmpcolor->start, fixbounds(tmpcolor->start_regex),
REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
}
if (tmpcolor->end_regex != NULL && tmpcolor->end == NULL) {
tmpcolor->end = (regex_t *)nmalloc(sizeof(regex_t));
regcomp(tmpcolor->end, tmpcolor->end_regex,
regcomp(tmpcolor->end, fixbounds(tmpcolor->end_regex),
REG_EXTENDED | (tmpcolor->icase ? REG_ICASE : 0));
}
}
}
/* Reset the multicolor info cache for records for any lines which need
to be recalculated */
void reset_multis_after(filestruct *fileptr, int mindex)
{
filestruct *oof;
for (oof = fileptr->next; oof != NULL; oof = oof->next) {
alloc_multidata_if_needed(oof);
if (oof->multidata == NULL)
continue;
if (oof->multidata[mindex] != CNONE)
oof->multidata[mindex] = -1;
else
break;
}
for (; oof != NULL; oof = oof->next) {
alloc_multidata_if_needed(oof);
if (oof->multidata == NULL)
continue;
if (oof->multidata[mindex] == CNONE)
oof->multidata[mindex] = -1;
else
break;
}
edit_refresh_needed = TRUE;
}
void reset_multis_before(filestruct *fileptr, int mindex)
{
filestruct *oof;
for (oof = fileptr->prev; oof != NULL; oof = oof->prev) {
alloc_multidata_if_needed(oof);
if (oof->multidata == NULL)
continue;
if (oof->multidata[mindex] != CNONE)
oof->multidata[mindex] = -1;
else
break;
}
for (; oof != NULL; oof = oof->prev) {
alloc_multidata_if_needed(oof);
if (oof->multidata == NULL)
continue;
if (oof->multidata[mindex] == CNONE)
oof->multidata[mindex] = -1;
else
break;
}
edit_refresh_needed = TRUE;
}
/* Reset one multiline regex info */
void reset_multis_for_id(filestruct *fileptr, int num)
{
reset_multis_before(fileptr, num);
reset_multis_after(fileptr, num);
fileptr->multidata[num] = -1;
}
/* Reset multi line strings around a filestruct ptr, trying to be smart about stopping
force = reset everything regardless, useful when we don't know how much screen state
has changed */
void reset_multis(filestruct *fileptr, bool force)
{
int nobegin, noend;
regmatch_t startmatch, endmatch;
const colortype *tmpcolor = openfile->colorstrings;
if (!openfile->syntax)
return;
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
/* If it's not a multi-line regex, amscray */
if (tmpcolor->end == NULL)
continue;
alloc_multidata_if_needed(fileptr);
if (force == TRUE) {
reset_multis_for_id(fileptr, tmpcolor->id);
continue;
}
/* Figure out where the first begin and end are to determine if
things changed drastically for the precalculated multi values */
nobegin = regexec(tmpcolor->start, fileptr->data, 1, &startmatch, 0);
noend = regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0);
if (fileptr->multidata[tmpcolor->id] == CWHOLELINE) {
if (nobegin && noend)
continue;
} else if (fileptr->multidata[tmpcolor->id] == CNONE) {
if (nobegin && noend)
continue;
} else if (fileptr->multidata[tmpcolor->id] & CBEGINBEFORE && !noend
&& (nobegin || endmatch.rm_eo > startmatch.rm_eo)) {
reset_multis_after(fileptr, tmpcolor->id);
continue;
}
/* If we got here assume the worst */
reset_multis_for_id(fileptr, tmpcolor->id);
}
}
#endif /* ENABLE_COLOR */

View File

@@ -2,8 +2,8 @@
/**************************************************************************
* cut.c *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -28,7 +28,6 @@
static bool keep_cutbuffer = FALSE;
/* Should we keep the contents of the cutbuffer? */
static filestruct *cutbottom = NULL;
/* Pointer to the end of the cutbuffer. */
/* Indicate that we should no longer keep the contents of the
@@ -114,7 +113,7 @@ void cut_to_eof(void)
* position to the end of the file into the cutbuffer. */
void do_cut_text(
#ifndef NANO_TINY
bool copy_text, bool cut_till_end
bool copy_text, bool cut_till_end, bool undoing
#else
void
#endif
@@ -163,6 +162,7 @@ void do_cut_text(
keep_cutbuffer = TRUE;
#ifndef NANO_TINY
if (cut_till_end) {
/* If cut_till_end is TRUE, move all text up to the end of the
* file into the cutbuffer. */
@@ -204,14 +204,19 @@ void do_cut_text(
* disturbing the text. */
if (!old_no_newlines)
UNSET(NO_NEWLINES);
} else
} else if (!undoing)
update_undo(CUT);
#endif
/* Leave the text in the cutbuffer, and mark the file as
* modified. */
set_modified();
/* Update the screen. */
edit_refresh();
edit_refresh_needed = TRUE;
#ifdef ENABLE_COLOR
reset_multis(openfile->current, FALSE);
#endif
#ifdef DEBUG
dump_filestruct(cutbuffer);
@@ -221,9 +226,12 @@ void do_cut_text(
/* Move text from the current filestruct into the cutbuffer. */
void do_cut_text_void(void)
{
#ifndef NANO_TINY
add_undo(CUT);
#endif
do_cut_text(
#ifndef NANO_TINY
FALSE, FALSE
FALSE, FALSE, FALSE
#endif
);
}
@@ -233,13 +241,16 @@ void do_cut_text_void(void)
* back into the filestruct afterward. */
void do_copy_text(void)
{
do_cut_text(TRUE, FALSE);
do_cut_text(TRUE, FALSE, FALSE);
}
/* Cut from the current cursor position to the end of the file. */
void do_cut_till_end(void)
{
do_cut_text(FALSE, TRUE);
#ifndef NANO_TINY
add_undo(CUT);
#endif
do_cut_text(FALSE, TRUE, FALSE);
}
#endif /* !NANO_TINY */
@@ -252,6 +263,10 @@ void do_uncut_text(void)
if (cutbuffer == NULL)
return;
#ifndef NANO_TINY
update_undo(UNCUT);
#endif
/* Add a copy of the text in the cutbuffer to the current filestruct
* at the current cursor position. */
copy_from_filestruct(cutbuffer, cutbottom);
@@ -264,7 +279,11 @@ void do_uncut_text(void)
set_modified();
/* Update the screen. */
edit_refresh();
edit_refresh_needed = TRUE;
#ifdef ENABLE_COLOR
reset_multis(openfile->current, FALSE);
#endif
#ifdef DEBUG
dump_filestruct_reverse();

View File

@@ -2,8 +2,8 @@
/**************************************************************************
* files.c *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -75,6 +75,8 @@ void initialize_buffer(void)
openfile->fmt = NIX_FILE;
openfile->current_stat = NULL;
openfile->undotop = NULL;
openfile->current_undo = NULL;
#endif
#ifdef ENABLE_COLOR
openfile->colorstrings = NULL;
@@ -94,12 +96,16 @@ void initialize_buffer_text(void)
openfile->edittop = openfile->fileage;
openfile->current = openfile->fileage;
#ifdef ENABLE_COLOR
openfile->fileage->multidata = NULL;
#endif
openfile->totsize = 0;
}
/* If it's not "", filename is a file to open. We make a new buffer, if
* necessary, and then open and read the file, if applicable. */
void open_buffer(const char *filename)
void open_buffer(const char *filename, bool undoable)
{
bool new_buffer = (openfile == NULL
#ifdef ENABLE_MULTIBUFFER
@@ -139,8 +145,8 @@ void open_buffer(const char *filename)
/* If we have a non-new file, read it in. Then, if the buffer has
* no stat, update the stat, if applicable. */
if (rc == 0) {
read_file(f, filename);
if (rc > 0) {
read_file(f, rc, filename, undoable, new_buffer);
#ifndef NANO_TINY
if (openfile->current_stat == NULL) {
openfile->current_stat =
@@ -189,8 +195,8 @@ void replace_buffer(const char *filename)
initialize_buffer_text();
/* If we have a non-new file, read it in. */
if (rc == 0)
read_file(f, filename);
if (rc > 0)
read_file(f, rc, filename, FALSE, TRUE);
/* Move back to the beginning of the first line of the buffer. */
openfile->current = openfile->fileage;
@@ -285,6 +291,47 @@ bool close_buffer(void)
}
#endif /* ENABLE_MULTIBUFFER */
/* A bit of a copy and paste from open_file(), is_file_writable()
* just checks whether the file is appendable as a quick
* permissions check, and we tend to err on the side of permissiveness
* (reporting TRUE when it might be wrong) to not fluster users
* editing on odd filesystems by printing incorrect warnings.
*/
int is_file_writable(const char *filename)
{
struct stat fileinfo, fileinfo2;
int fd;
FILE *f;
char *full_filename;
bool ans = TRUE;
if (ISSET(VIEW_MODE))
return TRUE;
assert(filename != NULL);
/* Get the specified file's full path. */
full_filename = get_full_path(filename);
/* Okay, if we can't stat the path due to a component's
permissions, just try the relative one */
if (full_filename == NULL
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
full_filename = mallocstrcpy(NULL, filename);
if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR |
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1
|| (f = fdopen(fd, "a")) == NULL)
ans = FALSE;
else
fclose(f);
close(fd);
free(full_filename);
return ans;
}
/* We make a new line of text from buf. buf is length buf_len. If
* first_line_ins is TRUE, then we put the new line at the top of the
* file. Otherwise, we assume prevnode is the last line of the file,
@@ -309,6 +356,10 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
fileptr->data[buf_len - 1] = '\0';
#endif
#ifdef ENABLE_COLOR
fileptr->multidata = NULL;
#endif
if (*first_line_ins) {
/* Special case: We're inserting with the cursor on the first
* line. */
@@ -337,8 +388,11 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
}
/* Read an open file into the current buffer. f should be set to the
* open file, and filename should be set to the name of the file. */
void read_file(FILE *f, const char *filename)
* open file, and filename should be set to the name of the file.
* undoable means do we want to create undo records to try and undo this.
* Will also attempt to check file writability if fd > 0 and checkwritable == TRUE
*/
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable)
{
size_t num_lines = 0;
/* The number of lines in the file. */
@@ -359,6 +413,8 @@ void read_file(FILE *f, const char *filename)
int input_int;
/* The current value we read from the file, whether an input
* character or EOF. */
bool writable = TRUE;
/* Is the file writable (if we care) */
#ifndef NANO_TINY
int format = 0;
/* 0 = *nix, 1 = DOS, 2 = Mac, 3 = both DOS and Mac. */
@@ -369,6 +425,11 @@ void read_file(FILE *f, const char *filename)
buf = charalloc(bufx);
buf[0] = '\0';
#ifndef NANO_TINY
if (undoable)
add_undo(INSERT);
#endif
if (openfile->current == openfile->fileage)
first_line_ins = TRUE;
else
@@ -453,6 +514,10 @@ void read_file(FILE *f, const char *filename)
if (ferror(f))
nperror(filename);
fclose(f);
if (fd > 0 && checkwritable) {
close(fd);
writable = is_file_writable(filename);
}
#ifndef NANO_TINY
/* If file conversion isn't disabled and the last character in this
@@ -487,7 +552,7 @@ void read_file(FILE *f, const char *filename)
/* If we didn't get a file and we don't already have one, open a
* blank buffer. */
if (fileptr == NULL)
open_buffer("");
open_buffer("", FALSE);
/* Attach the file we got to the filestruct. If we got a file of
* zero bytes, don't do anything. */
@@ -559,24 +624,48 @@ void read_file(FILE *f, const char *filename)
openfile->placewewant = xplustabs();
#ifndef NANO_TINY
if (format == 3)
statusbar(
if (undoable)
update_undo(INSERT);
if (format == 3) {
if (writable)
statusbar(
P_("Read %lu line (Converted from DOS and Mac format)",
"Read %lu lines (Converted from DOS and Mac format)",
(unsigned long)num_lines), (unsigned long)num_lines);
else if (format == 2) {
else
statusbar(
P_("Read %lu line (Converted from DOS and Mac format - Warning: No write permission)",
"Read %lu lines (Converted from DOS and Mac format - Warning: No write permission)",
(unsigned long)num_lines), (unsigned long)num_lines);
} else if (format == 2) {
openfile->fmt = MAC_FILE;
statusbar(P_("Read %lu line (Converted from Mac format)",
if (writable)
statusbar(P_("Read %lu line (Converted from Mac format)",
"Read %lu lines (Converted from Mac format)",
(unsigned long)num_lines), (unsigned long)num_lines);
else
statusbar(P_("Read %lu line (Converted from Mac format - Warning: No write permission)",
"Read %lu lines (Converted from Mac format - Warning: No write permission)",
(unsigned long)num_lines), (unsigned long)num_lines);
} else if (format == 1) {
openfile->fmt = DOS_FILE;
statusbar(P_("Read %lu line (Converted from DOS format)",
if (writable)
statusbar(P_("Read %lu line (Converted from DOS format)",
"Read %lu lines (Converted from DOS format)",
(unsigned long)num_lines), (unsigned long)num_lines);
else
statusbar(P_("Read %lu line (Converted from DOS format - Warning: No write permission)",
"Read %lu lines (Converted from DOS format - Warning: No write permission)",
(unsigned long)num_lines), (unsigned long)num_lines);
} else
#endif
statusbar(P_("Read %lu line", "Read %lu lines",
if (writable)
statusbar(P_("Read %lu line", "Read %lu lines",
(unsigned long)num_lines), (unsigned long)num_lines);
else
statusbar(P_("Read %lu line ( Warning: No write permission)",
"Read %lu lines (Warning: No write permission)",
(unsigned long)num_lines), (unsigned long)num_lines);
}
@@ -584,12 +673,12 @@ void read_file(FILE *f, const char *filename)
* "New File" if the file is missing. Otherwise, say "[filename] not
* found".
*
* Return -2 if we say "New File", -1 if the file isn't opened, and 0
* otherwise. The file might still have an error while reading with a 0
* return value. *f is set to the opened file. */
* Return -2 if we say "New File", -1 if the file isn't opened, and the
* fd opened otherwise. The file might still have an error while reading
* with a 0 return value. *f is set to the opened file. */
int open_file(const char *filename, bool newfie, FILE **f)
{
struct stat fileinfo;
struct stat fileinfo, fileinfo2;
int fd;
char *full_filename;
@@ -598,10 +687,21 @@ int open_file(const char *filename, bool newfie, FILE **f)
/* Get the specified file's full path. */
full_filename = get_full_path(filename);
if (full_filename == NULL)
/* Okay, if we can't stat the path due to a component's
permissions, just try the relative one */
if (full_filename == NULL
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
full_filename = mallocstrcpy(NULL, filename);
if (stat(full_filename, &fileinfo) == -1) {
/* Well, maybe we can open the file even if the OS
says its not there */
if ((fd = open(filename, O_RDONLY)) != -1) {
statusbar(_("Reading File"));
free(full_filename);
return 0;
}
if (newfie) {
statusbar(_("New File"));
return -2;
@@ -638,7 +738,7 @@ int open_file(const char *filename, bool newfie, FILE **f)
free(full_filename);
return 0;
return fd;
}
/* This function will return the name of the first available extension
@@ -769,14 +869,14 @@ void do_insertfile(
#ifndef NANO_TINY
#ifdef ENABLE_MULTIBUFFER
if (s && s->scfunc == (void *) new_buffer_msg) {
if (s && s->scfunc == NEW_BUFFER_MSG) {
/* Don't allow toggling if we're in view mode. */
if (!ISSET(VIEW_MODE))
TOGGLE(MULTIBUFFER);
continue;
} else
#endif
if (s && s->scfunc == (void *) ext_cmd_msg) {
if (s && s->scfunc == EXT_CMD_MSG) {
execute = !execute;
continue;
}
@@ -786,7 +886,7 @@ void do_insertfile(
#endif /* !NANO_TINY */
#ifndef DISABLE_BROWSER
if (s && s->scfunc == (void *) to_files_msg) {
if (s && s->scfunc == TO_FILES_MSG) {
char *tmp = do_browse_from(answer);
if (tmp == NULL)
@@ -851,7 +951,7 @@ void do_insertfile(
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
/* Open a blank buffer. */
open_buffer("");
open_buffer("", FALSE);
#endif
/* Save the command's output in the current buffer. */
@@ -875,7 +975,7 @@ void do_insertfile(
/* Save the file specified in answer in the current
* buffer. */
open_buffer(answer);
open_buffer(answer, TRUE);
#ifndef NANO_TINY
}
#endif
@@ -1090,7 +1190,7 @@ char *get_full_path(const char *origpath)
/* Finally, go back to the path specified in d_here,
* where we were before. We don't check for a chdir()
* error, since we can do nothing if we get one. */
chdir(d_here);
IGNORE_CALL_RESULT(chdir(d_here));
/* Free d_here, since we're done using it. */
free(d_here);
@@ -1358,6 +1458,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
/* The actual file, realname, we are writing to. */
char *tempname = NULL;
/* The temp file name we write to on prepend. */
int backup_cflags;
assert(name != NULL);
@@ -1400,14 +1501,22 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
realexists = (stat(realname, &st) != -1);
#ifndef NANO_TINY
/* if we have not stat()d this file before (say, the user just
* specified it interactively), stat and save the value
* or else we will chase null pointers when we do
* modtime checks, preserve file times, etc. during backup */
if (openfile->current_stat == NULL && !tmp && realexists)
stat(realname, openfile->current_stat);
/* We backup only if the backup toggle is set, the file isn't
* temporary, and the file already exists. Furthermore, if we
* aren't appending, prepending, or writing a selection, we backup
* only if the file has not been modified by someone else since nano
* opened it. */
if (ISSET(BACKUP_FILE) && !tmp && realexists && ((append !=
OVERWRITE || openfile->mark_set) ||
openfile->current_stat->st_mtime == st.st_mtime)) {
OVERWRITE || openfile->mark_set) || (openfile->current_stat &&
openfile->current_stat->st_mtime == st.st_mtime))) {
int backup_fd;
FILE *backup_file;
char *backupname;
struct utimbuf filetime;
@@ -1463,14 +1572,15 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
free(backuptemp);
backuptemp = get_next_filename(backupname, "~");
if (*backuptemp == '\0') {
statusbar(_("Error writing %s: %s"), backupname,
statusbar(_("Error writing backup file %s: %s"), backupname,
_("Too many backup files?"));
free(backuptemp);
free(backupname);
/* If we can't write to the backup, go on, since only
* saving the original file is better than saving
* nothing. */
goto skip_backup;
/* If we can't write to the backup, DONT go on, since
whatever caused the backup file to fail (e.g. disk
full may well cause the real file write to fail, which
means we could lose both the backup and the original! */
goto cleanup_and_exit;
} else {
free(backupname);
backupname = backuptemp;
@@ -1480,21 +1590,56 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
sprintf(backupname, "%s~", realname);
}
/* Open the destination backup file. Before we write to it, we
* set its permissions, so no unauthorized person can read it as
* we write. */
backup_file = fopen(backupname, "wb");
/* First, unlink any existing backups. Next, open the backup
file with O_CREAT and O_EXCL. If it succeeds, we
have a file descriptor to a new backup file. */
if (unlink(backupname) < 0 && errno != ENOENT && !ISSET(INSECURE_BACKUP)) {
statusbar(_("Error writing backup file %s: %s"), backupname,
strerror(errno));
free(backupname);
goto cleanup_and_exit;
}
if (backup_file == NULL || chmod(backupname,
openfile->current_stat->st_mode) == -1) {
statusbar(_("Error writing %s: %s"), backupname,
if (ISSET(INSECURE_BACKUP))
backup_cflags = O_WRONLY | O_CREAT | O_APPEND;
else
backup_cflags = O_WRONLY | O_CREAT | O_EXCL | O_APPEND;
backup_fd = open(backupname, backup_cflags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
/* Now we've got a safe file stream. If the previous open()
call failed, this will return NULL. */
backup_file = fdopen(backup_fd, "wb");
if (backup_fd < 0 || backup_file == NULL) {
statusbar(_("Error writing backup file %s: %s"), backupname,
strerror(errno));
free(backupname);
goto cleanup_and_exit;
}
/* We shouldn't worry about chown()ing something if we're not
root, since it's likely to fail! */
if (geteuid() == NANO_ROOT_UID && fchown(backup_fd,
openfile->current_stat->st_uid, openfile->current_stat->st_gid) == -1
&& !ISSET(INSECURE_BACKUP)) {
statusbar(_("Error writing backup file %s: %s"), backupname,
strerror(errno));
free(backupname);
if (backup_file != NULL)
fclose(backup_file);
/* If we can't write to the backup, go on, since only saving
* the original file is better than saving nothing. */
goto skip_backup;
fclose(backup_file);
goto cleanup_and_exit;
}
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1 && !ISSET(INSECURE_BACKUP)) {
statusbar(_("Error writing backup file %s: %s"), backupname,
strerror(errno));
free(backupname);
fclose(backup_file);
/* If we can't write to the backup, DONT go on, since
whatever caused the backup file to fail (e.g. disk
full may well cause the real file write to fail, which
means we could lose both the backup and the original! */
goto cleanup_and_exit;
}
#ifdef DEBUG
@@ -1504,27 +1649,28 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
/* Copy the file. */
copy_status = copy_file(f, backup_file);
if (copy_status != 0) {
statusbar(_("Error reading %s: %s"), realname,
strerror(errno));
beep();
goto cleanup_and_exit;
}
/* And set its metadata. */
if (copy_status != 0 || chown(backupname,
openfile->current_stat->st_uid,
openfile->current_stat->st_gid) == -1 ||
utime(backupname, &filetime) == -1) {
if (copy_status == -1) {
statusbar(_("Error reading %s: %s"), realname,
if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
statusbar(_("Error writing backup file %s: %s"), backupname,
strerror(errno));
beep();
} else
statusbar(_("Error writing %s: %s"), backupname,
strerror(errno));
/* If we can't read from or write to the backup, go on,
* since only saving the original file is better than saving
* nothing. */
/* If we can't write to the backup, DONT go on, since
whatever caused the backup file to fail (e.g. disk
full may well cause the real file write to fail, which
means we could lose both the backup and the original! */
goto cleanup_and_exit;
}
free(backupname);
}
skip_backup:
skip_backup:
#endif /* !NANO_TINY */
/* If NOFOLLOW_SYMLINKS is set and the file is a link, we aren't
@@ -1572,7 +1718,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
}
if (f_open == NULL) {
fd_source = open(realname, O_RDONLY | O_CREAT);
fd_source = open(realname, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR);
if (fd_source != -1) {
f_source = fdopen(fd_source, "rb");
@@ -1691,7 +1837,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
int fd_source;
FILE *f_source = NULL;
fd_source = open(tempname, O_RDONLY | O_CREAT);
fd_source = open(tempname, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR);
if (fd_source != -1) {
f_source = fdopen(fd_source, "rb");
@@ -1712,8 +1858,11 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
strerror(errno));
goto cleanup_and_exit;
}
} else
fclose(f);
} else if (fclose(f) != 0) {
statusbar(_("Error writing %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
}
if (!tmp && append == OVERWRITE) {
if (!nonamechange) {
@@ -1898,7 +2047,7 @@ bool do_writeout(bool exiting)
s = get_shortcut(currmenu, &i, &meta_key, &func_key);
#ifndef DISABLE_BROWSER
if (s && s->scfunc == (void *) to_files_msg) {
if (s && s->scfunc == TO_FILES_MSG) {
char *tmp = do_browse_from(answer);
if (tmp == NULL)
@@ -1910,25 +2059,27 @@ bool do_writeout(bool exiting)
} else
#endif /* !DISABLE_BROWSER */
#ifndef NANO_TINY
if (s && s->scfunc == (void *) dos_format_msg) {
if (s && s->scfunc == DOS_FORMAT_MSG) {
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE :
DOS_FILE;
continue;
} else if (s && s->scfunc == (void *) mac_format_msg) {
} else if (s && s->scfunc == MAC_FORMAT_MSG) {
openfile->fmt = (openfile->fmt == MAC_FILE) ? NIX_FILE :
MAC_FILE;
continue;
} else if (s && s->scfunc == (void *) backup_file_msg) {
} else if (s && s->scfunc == BACKUP_FILE_MSG) {
TOGGLE(BACKUP_FILE);
continue;
} else
#endif /* !NANO_TINY */
if (s && s->scfunc == (void *) prepend_msg) {
if (s && s->scfunc == PREPEND_MSG) {
append = (append == PREPEND) ? OVERWRITE : PREPEND;
continue;
} else if (s && s->scfunc == (void *) append_msg) {
} else if (s && s->scfunc == APPEND_MSG) {
append = (append == APPEND) ? OVERWRITE : APPEND;
continue;
} else if (s && s->scfunc == DO_HELP_VOID) {
continue;
}
#ifdef DEBUG
@@ -2007,6 +2158,18 @@ bool do_writeout(bool exiting)
continue;
}
}
#ifndef NANO_TINY
/* Complain if the file exists, the name hasn't changed, and the
stat information we had before does not match what we have now */
else if (name_exists && openfile->current_stat && (openfile->current_stat->st_mtime < st.st_mtime ||
openfile->current_stat->st_dev != st.st_dev || openfile->current_stat->st_ino != st.st_ino)) {
i = do_yesno_prompt(FALSE,
_("File was modified since you opened it, continue saving ? "));
if (i == 0 || i == -1)
continue;
}
#endif
}
/* Convert newlines to nulls, just before we save the

File diff suppressed because it is too large Load Diff

View File

@@ -2,8 +2,8 @@
/**************************************************************************
* help.c *
* *
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, *
* 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -145,35 +145,35 @@ void do_help(void (*refresh_func)(void))
if (!f)
continue;
if (f->scfunc == total_refresh) {
if (f->scfunc == TOTAL_REFRESH) {
total_redraw();
break;
} else if (f->scfunc == do_page_up) {
} else if (f->scfunc == DO_PAGE_UP) {
if (line > editwinrows - 2)
line -= editwinrows - 2;
else
line = 0;
} else if (f->scfunc == do_page_down) {
} else if (f->scfunc == DO_PAGE_DOWN) {
if (line + (editwinrows - 1) < last_line)
line += editwinrows - 2;
} else if (f->scfunc == do_up_void) {
} else if (f->scfunc == DO_UP_VOID) {
if (line > 0)
line--;
} else if (f->scfunc == do_down_void) {
} else if (f->scfunc == DO_DOWN_VOID) {
if (line + (editwinrows - 1) < last_line)
line++;
} else if (f->scfunc == do_first_line) {
} else if (f->scfunc == DO_FIRST_LINE) {
if (meta_key)
line = 0;
break;
} else if (f->scfunc == do_last_line) {
} else if (f->scfunc == DO_LAST_LINE) {
if (meta_key) {
if (line + (editwinrows - 1) < last_line)
line = last_line - (editwinrows - 1);
}
break;
/* Abort the help browser. */
} else if (f->scfunc == do_exit) {
} else if (f->scfunc == DO_EXIT) {
abort = TRUE;
break;
}
@@ -201,12 +201,6 @@ void do_help(void (*refresh_func)(void))
help_text = NULL;
}
/* Start the help browser for the edit window. */
void do_help_void(void)
{
do_help(&edit_refresh);
}
#ifndef DISABLE_BROWSER
/* Start the help browser for the file browser. */
void do_browser_help(void)
@@ -413,7 +407,7 @@ void help_init(void)
size_t endis_len = strlen(_("enable/disable"));
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == (void *) do_toggle)
if (s->scfunc == DO_TOGGLE)
allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 9;
}
@@ -484,7 +478,7 @@ void help_init(void)
/* And the toggles... */
if (currmenu == MMAIN)
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == (void *) do_toggle)
if (s->scfunc == DO_TOGGLE)
ptr += sprintf(ptr, "(%s)\t\t\t%s %s\n",
s->keystr, _(flagtostr(s->toggle)), _("enable/disable"));
@@ -513,15 +507,15 @@ void parse_help_input(int *kbinput, bool *meta_key, bool *func_key)
switch (*kbinput) {
/* For consistency with the file browser. */
case ' ':
*kbinput = sc_seq_or(do_page_up, 0);
*kbinput = sc_seq_or(DO_PAGE_UP, 0);
break;
case '-':
*kbinput = sc_seq_or(do_page_down, 0);;
*kbinput = sc_seq_or(DO_PAGE_DOWN, 0);;
break;
/* Cancel is equivalent to Exit here. */
case 'E':
case 'e':
*kbinput = sc_seq_or(do_exit, 0);;
*kbinput = sc_seq_or(DO_EXIT, 0);;
break;
}
}
@@ -552,3 +546,18 @@ size_t help_line_len(const char *ptr)
}
#endif /* !DISABLE_HELP */
/* Start the help browser for the edit window. */
void do_help_void(void)
{
#ifndef DISABLE_HELP
/* Start the help browser for the edit window. */
do_help(&edit_refresh);
#else
if (currmenu == MMAIN)
nano_disabled_msg();
else
beep();
#endif
}

View File

@@ -2,8 +2,8 @@
/**************************************************************************
* move.c *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -29,63 +29,71 @@
/* Move to the first line of the file. */
void do_first_line(void)
{
const filestruct *current_save = openfile->current;
size_t pww_save = openfile->placewewant;
openfile->current = openfile->fileage;
openfile->current = openfile->edittop = openfile->fileage;
openfile->current_x = 0;
openfile->placewewant = 0;
edit_redraw(current_save, pww_save);
edit_refresh_needed = 1;
}
/* Move to the last line of the file. */
void do_last_line(void)
{
const filestruct *current_save = openfile->current;
size_t pww_save = openfile->placewewant;
openfile->current = openfile->filebot;
openfile->current_x = strlen(openfile->filebot->data);
openfile->placewewant = xplustabs();
openfile->current_y = editwinrows - 1;
edit_redraw(current_save, pww_save);
edit_refresh_needed = 1;
}
/* Move up one page. */
void do_page_up(void)
{
int i;
int i, skipped = 0;
/* If there's less than a page of text left on the screen, put the
* cursor at the beginning of the first line of the file, and then
* update the edit window. */
if (openfile->current->lineno <= editwinrows - 2) {
if (openfile->current->lineno == 1 || (!ISSET(SOFTWRAP) &&
openfile->current->lineno <= editwinrows - 2)) {
do_first_line();
return;
}
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
#ifndef NANO_TINY
if (!ISSET(SMOOTH_SCROLL)) {
#endif
openfile->current = openfile->edittop;
openfile->placewewant = 0;
openfile->placewewant = openfile->current_y = 0;
#ifndef NANO_TINY
}
#endif
for (i = editwinrows - 2; i > 0 && openfile->current !=
openfile->fileage; i--)
for (i = editwinrows - 2; i - skipped > 0 && openfile->current !=
openfile->fileage; i--) {
openfile->current = openfile->current->prev;
if (ISSET(SOFTWRAP) && openfile->current) {
skipped += strlenpt(openfile->current->data) / COLS;
#ifdef DEBUG
fprintf(stderr, "do_page_up: i = %d, skipped = %d based on line %ld len %d\n", i, (unsigned long) skipped,
openfile->current->lineno, strlenpt(openfile->current->data));
#endif
}
}
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
#ifdef DEBUG
fprintf(stderr, "do_page_up: openfile->current->lineno = %lu, skipped = %d\n", (unsigned long) openfile->current->lineno, skipped);
#endif
/* Scroll the edit window up a page. */
edit_scroll(UP_DIR, editwinrows - 2);
edit_update(NONE);
}
/* Move down one page. */
@@ -96,7 +104,7 @@ void do_page_down(void)
/* If there's less than a page of text left on the screen, put the
* cursor at the beginning of the last line of the file, and then
* update the edit window. */
if (openfile->current->lineno + editwinrows - 2 >=
if (openfile->current->lineno + maxrows - 2 >=
openfile->filebot->lineno) {
do_last_line();
return;
@@ -108,20 +116,25 @@ void do_page_down(void)
if (!ISSET(SMOOTH_SCROLL)) {
#endif
openfile->current = openfile->edittop;
openfile->placewewant = 0;
openfile->placewewant = openfile->current_y = 0;
#ifndef NANO_TINY
}
#endif
for (i = editwinrows - 2; i > 0 && openfile->current !=
openfile->filebot; i--)
for (i = maxrows - 2; i > 0 && openfile->current !=
openfile->filebot; i--) {
openfile->current = openfile->current->next;
#ifdef DEBUG
fprintf(stderr, "do_page_down: moving to line %lu\n", (unsigned long) openfile->current->lineno);
#endif
}
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
/* Scroll the edit window down a page. */
edit_scroll(DOWN_DIR, editwinrows - 2);
edit_update(NONE);
}
#ifndef DISABLE_JUSTIFY
@@ -130,7 +143,7 @@ void do_page_down(void)
* afterwards. */
void do_para_begin(bool allow_update)
{
const filestruct *current_save = openfile->current;
filestruct *current_save = openfile->current;
const size_t pww_save = openfile->placewewant;
if (openfile->current != openfile->fileage) {
@@ -162,7 +175,7 @@ void do_para_begin_void(void)
* paragraph or isn't in a paragraph. */
void do_para_end(bool allow_update)
{
const filestruct *const current_save = openfile->current;
filestruct *const current_save = openfile->current;
const size_t pww_save = openfile->placewewant;
while (openfile->current != openfile->filebot &&
@@ -206,7 +219,7 @@ void do_para_end_void(void)
bool do_next_word(bool allow_punct, bool allow_update)
{
size_t pww_save = openfile->placewewant;
const filestruct *current_save = openfile->current;
filestruct *current_save = openfile->current;
char *char_mb;
int char_mb_len;
bool end_line = FALSE, started_on_word = FALSE;
@@ -301,7 +314,7 @@ void do_next_word_void(void)
bool do_prev_word(bool allow_punct, bool allow_update)
{
size_t pww_save = openfile->placewewant;
const filestruct *current_save = openfile->current;
filestruct *current_save = openfile->current;
char *char_mb;
int char_mb_len;
bool begin_line = FALSE, started_on_word = FALSE;
@@ -488,7 +501,7 @@ void do_up(
)
return;
assert(openfile->current_y == openfile->current->lineno - openfile->edittop->lineno);
assert(ISSET(SOFTWRAP) || openfile->current_y == openfile->current->lineno - openfile->edittop->lineno);
/* Move the current line of the edit window up. */
openfile->current = openfile->current->prev;
@@ -500,7 +513,7 @@ void do_up(
* smooth scrolling mode, or up half a page if we're not. If
* scroll_only is TRUE, scroll the edit window up one line
* unconditionally. */
if (openfile->current_y == 0
if (openfile->current_y == 0 || (ISSET(SOFTWRAP) && openfile->edittop->lineno == openfile->current->next->lineno)
#ifndef NANO_TINY
|| scroll_only
#endif
@@ -509,7 +522,7 @@ void do_up(
#ifndef NANO_TINY
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
#endif
editwinrows / 2);
editwinrows / 2 + 1);
/* If we're below the first line of the edit window, update the
* line we were on before and the line we're on now. The former
@@ -550,38 +563,48 @@ void do_down(
#endif
)
{
bool onlastline = FALSE;
/* If we're at the bottom of the file, get out. */
if (openfile->current == openfile->filebot)
return;
assert(openfile->current_y == openfile->current->lineno - openfile->edittop->lineno);
assert(ISSET(SOFTWRAP) || openfile->current_y == openfile->current->lineno - openfile->edittop->lineno);
/* Move the current line of the edit window down. */
openfile->current = openfile->current->next;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
if (ISSET(SOFTWRAP)) {
if (openfile->current->lineno - openfile->edittop->lineno >= maxrows)
onlastline = TRUE;
}
/* If scroll_only is FALSE and if we're on the first line of the
* edit window, scroll the edit window down one line if we're in
* smooth scrolling mode, or down half a page if we're not. If
* scroll_only is TRUE, scroll the edit window down one line
* unconditionally. */
if (openfile->current_y == editwinrows - 1
if (onlastline || openfile->current_y == editwinrows - 1
#ifndef NANO_TINY
|| scroll_only
#endif
)
) {
edit_scroll(DOWN_DIR,
#ifndef NANO_TINY
(ISSET(SMOOTH_SCROLL) || scroll_only) ? 1 :
#endif
editwinrows / 2);
editwinrows / 2 + 1);
edit_refresh_needed = TRUE;
}
/* If we're above the last line of the edit window, update the line
* we were on before and the line we're on now. The former needs to
* be redrawn if we're not on the first page, and the latter needs
* to be drawn unconditionally. */
if (openfile->current_y < editwinrows - 1) {
if (ISSET(SOFTWRAP) || openfile->current_y < editwinrows - 1) {
if (need_vertical_update(0))
update_line(openfile->current->prev, 0);
update_line(openfile->current, openfile->current_x);

View File

@@ -1,9 +1,9 @@
/* $Id$ */
/* $Id$ */
/**************************************************************************
* nano.c *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -32,7 +32,10 @@
#include <errno.h>
#include <ctype.h>
#include <locale.h>
#include <time.h>
#ifdef ENABLE_UTF8
#include <langinfo.h>
#endif
#include <termios.h>
#ifdef HAVE_GETOPT_H
#include <getopt.h>
@@ -65,6 +68,10 @@ filestruct *make_new_node(filestruct *prevnode)
newnode->next = NULL;
newnode->lineno = (prevnode != NULL) ? prevnode->lineno + 1 : 1;
#ifdef ENABLE_COLOR
newnode->multidata = NULL;
#endif
return newnode;
}
@@ -81,6 +88,9 @@ filestruct *copy_node(const filestruct *src)
dst->next = src->next;
dst->prev = src->prev;
dst->lineno = src->lineno;
#ifdef ENABLE_COLOR
dst->multidata = NULL;
#endif
return dst;
}
@@ -117,6 +127,11 @@ void delete_node(filestruct *fileptr)
if (fileptr->data != NULL)
free(fileptr->data);
#ifdef ENABLE_COLOR
if (fileptr->multidata)
free(fileptr->multidata);
#endif
free(fileptr);
}
@@ -354,6 +369,10 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
openfile->fileage->data = mallocstrcpy(NULL, "");
openfile->filebot = openfile->fileage;
#ifdef ENABLE_COLOR
openfile->fileage->multidata = NULL;
#endif
/* Restore the current line and cursor position. If the mark begins
* inside the partition, set the beginning of the mark to where the
* saved text used to start. */
@@ -375,11 +394,7 @@ void move_to_filestruct(filestruct **file_top, filestruct **file_bot,
/* If the top of the edit window was inside the old partition, put
* it in range of current. */
if (edittop_inside)
edit_update(
#ifndef NANO_TINY
ISSET(SMOOTH_SCROLL) ? NONE :
#endif
CENTER);
edit_update(NONE);
/* Renumber starting with the beginning line of the old
* partition. */
@@ -502,6 +517,10 @@ openfilestruct *make_new_opennode(void)
newnode->filebot = NULL;
newnode->edittop = NULL;
newnode->current = NULL;
#ifndef NANO_TINY
newnode->current_stat = NULL;
newnode->last_action = OTHER;
#endif
return newnode;
}
@@ -616,7 +635,11 @@ void die(const char *msg, ...)
if (filepart != NULL)
unpartition_filestruct(&filepart);
die_save_file(openfile->filename);
die_save_file(openfile->filename
#ifndef NANO_TINY
, openfile->current_stat
#endif
);
}
#ifdef ENABLE_MULTIBUFFER
@@ -629,7 +652,11 @@ void die(const char *msg, ...)
/* Save the current file buffer if it's been modified. */
if (openfile->modified)
die_save_file(openfile->filename);
die_save_file(openfile->filename
#ifndef NANO_TINY
, openfile->current_stat
#endif
);
}
}
#endif
@@ -640,7 +667,11 @@ void die(const char *msg, ...)
/* Save the current file under the name spacified in die_filename, which
* is modified to be unique if necessary. */
void die_save_file(const char *die_filename)
void die_save_file(const char *die_filename
#ifndef NANO_TINY
, struct stat *die_stat
#endif
)
{
char *retval;
bool failed = TRUE;
@@ -669,6 +700,17 @@ void die_save_file(const char *die_filename)
fprintf(stderr, _("\nBuffer not written: %s\n"),
_("Too many backup files?"));
#ifndef NANO_TINY
/* Try and chmod/chown the save file to the values of the original file, but
dont worry if it fails because we're supposed to be bailing as fast
as possible. */
if (die_stat) {
int shush;
shush = chmod(retval, die_stat->st_mode);
shush = chown(retval, die_stat->st_uid, die_stat->st_gid);
}
#endif
free(retval);
}
@@ -857,6 +899,8 @@ void usage(void)
#endif
print_opt("-p", "--preserve",
N_("Preserve XON (^Q) and XOFF (^S) keys"));
print_opt("-q", "--quiet",
N_("Silently ignore startup issues like rc file errors"));
#ifndef DISABLE_WRAPJUSTIFY
print_opt(_("-r <#cols>"), _("--fill=<#cols>"),
N_("Set wrapping point at column #cols"));
@@ -867,12 +911,17 @@ void usage(void)
#endif
print_opt("-t", "--tempfile",
N_("Auto save on exit, don't prompt"));
#ifndef NANO_TINY
print_opt("-u", "--undo", N_("Allow generic undo [EXPERIMENTAL]"));
#endif
print_opt("-v", "--view", N_("View mode (read-only)"));
#ifndef DISABLE_WRAPPING
print_opt("-w", "--nowrap", N_("Don't wrap long lines"));
#endif
print_opt("-x", "--nohelp", N_("Don't show the two help lines"));
print_opt("-z", "--suspend", N_("Enable suspension"));
print_opt("-$", "--softwrap", N_("Enable soft line wrapping"));
/* This is a special case. */
print_opt("-a, -b, -e,", "", NULL);
@@ -888,8 +937,8 @@ void version(void)
{
printf(_(" GNU nano version %s (compiled %s, %s)\n"), VERSION,
__TIME__, __DATE__);
printf(" (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007\n");
printf(" Free Software Foundation, Inc.\n");
printf(" (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,\n");
printf(" 2008, 2009 Free Software Foundation, Inc.\n");
printf(
_(" Email: nano@nano-editor.org Web: http://www.nano-editor.org/"));
printf(_("\n Compiled options:"));
@@ -1014,6 +1063,80 @@ void do_exit(void)
display_main_list();
}
static struct sigaction pager_oldaction, pager_newaction; /* Original and temporary handlers for SIGINT. */
static bool pager_sig_failed = FALSE; /* Did sigaction() fail without changing the signal handlers? */
static bool pager_input_aborted = FALSE; /* Did someone invoke the pager and abort it via ^C? */
/* Things which need to be run regardless of whether
we finished the stdin pipe correctly or not */
void finish_stdin_pager(void)
{
FILE *f;
int ttystdin;
/* Read whatever we did get from stdin */
f = fopen("/dev/stdin", "rb");
if (f == NULL)
nperror("fopen");
read_file(f, 0, "stdin", TRUE, FALSE);
ttystdin = open("/dev/tty", O_RDONLY);
if (!ttystdin)
die(_("Couldn't reopen stdin from keyboard, sorry\n"));
dup2(ttystdin,0);
close(ttystdin);
if (!pager_input_aborted)
tcgetattr(0, &oldterm);
if (!pager_sig_failed && sigaction(SIGINT, &pager_oldaction, NULL) == -1)
nperror("sigaction");
terminal_init();
doupdate();
}
/* Cancel reading from stdin like a pager */
RETSIGTYPE cancel_stdin_pager(int signal)
{
/* Currently do nothing, just handle the intr silently */
pager_input_aborted = TRUE;
}
/* Let nano read stdin for the first file at least */
void stdin_pager(void)
{
endwin();
if (!pager_input_aborted)
tcsetattr(0, TCSANOW, &oldterm);
fprintf(stderr, _("Reading from stdin, ^C to abort\n"));
/* Set things up so that Ctrl-C will cancel the new process. */
/* Enable interpretation of the special control keys so that we get
* SIGINT when Ctrl-C is pressed. */
#ifndef NANO_TINY
enable_signals();
#endif
if (sigaction(SIGINT, NULL, &pager_newaction) == -1) {
pager_sig_failed = TRUE;
nperror("sigaction");
} else {
pager_newaction.sa_handler = cancel_stdin_pager;
if (sigaction(SIGINT, &pager_newaction, &pager_oldaction) == -1) {
pager_sig_failed = TRUE;
nperror("sigaction");
}
}
open_buffer("", FALSE);
finish_stdin_pager();
}
/* Initialize the signal handlers. */
void signal_init(void)
{
@@ -1067,11 +1190,9 @@ RETSIGTYPE do_suspend(int signal)
disable_mouse_support();
#endif
/* Blank the screen, and move the cursor to the last line of the
* screen. */
erase();
/* Move the cursor to the last line of the screen. */
move(LINES - 1, 0);
refresh();
endwin();
/* Display our helpful message. */
printf(_("Use \"fg\" to return to nano.\n"));
@@ -1147,8 +1268,10 @@ RETSIGTYPE handle_sigwinch(int signal)
* otherwise. However, COLS and LINES are curses global variables,
* and in some cases curses has already updated them. But not in
* all cases. Argh. */
#ifdef REDEFINIG_MACROS_OK
COLS = win.ws_col;
LINES = win.ws_row;
#endif
/* If we've partitioned the filestruct, unpartition it now. */
if (filepart != NULL)
@@ -1236,6 +1359,9 @@ void do_toggle(int flag)
edit_refresh();
break;
#endif
case SOFTWRAP:
total_refresh();
break;
}
enabled = ISSET(flag);
@@ -1268,7 +1394,6 @@ void disable_extended_io(void)
tcsetattr(0, TCSANOW, &term);
}
#ifdef USE_SLANG
/* Disable interpretation of the special control keys in our terminal
* settings. */
void disable_signals(void)
@@ -1279,7 +1404,6 @@ void disable_signals(void)
term.c_lflag &= ~ISIG;
tcsetattr(0, TCSANOW, &term);
}
#endif
#ifndef NANO_TINY
/* Enable interpretation of the special control keys in our terminal
@@ -1346,8 +1470,8 @@ void terminal_init(void)
if (ISSET(PRESERVE))
enable_flow_control();
#ifdef USE_SLANG
disable_signals();
#ifdef USE_SLANG
if (!ISSET(PRESERVE))
disable_flow_control();
@@ -1436,6 +1560,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
kbinput = (int *)nrealloc(kbinput, kbinput_len *
sizeof(int));
kbinput[kbinput_len - 1] = input;
}
}
@@ -1450,7 +1575,7 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
* for verbatim input, turn off prepending of wrapped
* text. */
if (have_shortcut && (!have_shortcut || s == NULL || s->scfunc !=
do_verbatim_input))
DO_VERBATIM_INPUT))
wrap_reset();
#endif
@@ -1485,26 +1610,44 @@ int do_input(bool *meta_key, bool *func_key, bool *s_or_t, bool
default:
/* If the function associated with this shortcut is
* cutting or copying text, indicate this. */
if (s->scfunc == do_cut_text_void
if (s->scfunc == DO_CUT_TEXT_VOID
#ifndef NANO_TINY
|| s->scfunc == do_copy_text || s->scfunc ==
do_cut_till_end
|| s->scfunc == DO_COPY_TEXT || s->scfunc ==
DO_CUT_TILL_END
#endif
)
cut_copy = TRUE;
if (s->scfunc != NULL) {
if (s->scfunc != 0) {
const subnfunc *f = sctofunc((sc *) s);
*ran_func = TRUE;
if (ISSET(VIEW_MODE) && f && !f->viewok)
print_view_warning();
else
else {
#ifndef NANO_TINY
if (s->scfunc == (void *) do_toggle)
if (s->scfunc == DO_TOGGLE)
do_toggle(s->toggle);
else
else {
#else
{
#endif
s->scfunc();
iso_me_harder_funcmap(s->scfunc);
#ifdef ENABLE_COLOR
if (f && !f->viewok && openfile->syntax != NULL
&& openfile->syntax->nmultis > 0) {
reset_multis(openfile->current, FALSE);
}
#endif
if (edit_refresh_needed) {
#ifdef DEBUG
fprintf(stderr, "running edit_refresh() as edit_refresh_needed is true\n");
#endif
edit_refresh();
edit_refresh_needed = FALSE;
}
}
}
}
*finished = TRUE;
break;
@@ -1543,23 +1686,59 @@ int do_mouse(void)
bool sameline;
/* Did they click on the line with the cursor? If they
* clicked on the cursor, we set the mark. */
const filestruct *current_save = openfile->current;
filestruct *current_save = openfile->current;
size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant;
sameline = (mouse_y == openfile->current_y);
/* Move to where the click occurred. */
for (; openfile->current_y < mouse_y && openfile->current !=
openfile->filebot; openfile->current_y++)
openfile->current = openfile->current->next;
for (; openfile->current_y > mouse_y && openfile->current !=
openfile->fileage; openfile->current_y--)
openfile->current = openfile->current->prev;
#ifdef DEBUG
fprintf(stderr, "mouse_y = %d, current_y = %d\n", mouse_y, openfile->current_y);
#endif
openfile->current_x = actual_x(openfile->current->data,
if (ISSET(SOFTWRAP)) {
int i = 0;
for (openfile->current = openfile->edittop;
openfile->current->next && i < mouse_y;
openfile->current = openfile->current->next, i++) {
openfile->current_y = i;
i += strlenpt(openfile->current->data) / COLS;
}
#ifdef DEBUG
fprintf(stderr, "do_mouse(): moving to current_y = %d, i %d\n", openfile->current_y, i);
fprintf(stderr, " openfile->current->data = \"%s\"\n", openfile->current->data);
#endif
if (i > mouse_y) {
openfile->current = openfile->current->prev;
openfile->current_x = actual_x(openfile->current->data, mouse_x + (mouse_y - openfile->current_y) * COLS);
#ifdef DEBUG
fprintf(stderr, "do_mouse(): i > mouse_y, mouse_x = %d, current_x to = %d\n", mouse_x, openfile->current_x);
#endif
} else {
openfile->current_x = actual_x(openfile->current->data, mouse_x);
#ifdef DEBUG
fprintf(stderr, "do_mouse(): i <= mouse_y, mouse_x = %d, setting current_x to = %d\n", mouse_x, openfile->current_x);
#endif
}
openfile->placewewant = xplustabs();
} else {
/* Move to where the click occurred. */
for (; openfile->current_y < mouse_y && openfile->current !=
openfile->filebot; openfile->current_y++)
openfile->current = openfile->current->next;
for (; openfile->current_y > mouse_y && openfile->current !=
openfile->fileage; openfile->current_y--)
openfile->current = openfile->current->prev;
openfile->current_x = actual_x(openfile->current->data,
get_page_start(xplustabs()) + mouse_x);
openfile->placewewant = xplustabs();
openfile->placewewant = xplustabs();
}
#ifndef NANO_TINY
/* Clicking where the cursor is toggles the mark, as does
@@ -1576,22 +1755,161 @@ int do_mouse(void)
}
#endif /* !DISABLE_MOUSE */
#ifdef ENABLE_COLOR
void alloc_multidata_if_needed(filestruct *fileptr)
{
if (!fileptr->multidata)
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
}
/* Precalculate the multi-line start and end regex info so we can speed up
rendering (with any hope at all...) */
void precalc_multicolorinfo(void)
{
#ifdef DEBUG
fprintf(stderr, "entering precalc_multicolorinfo()\n");
#endif
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) {
const colortype *tmpcolor = openfile->colorstrings;
regmatch_t startmatch, endmatch;
filestruct *fileptr, *endptr;
time_t last_check = time(NULL), cur_check = 0;
/* Let us get keypresses to see if the user is trying to
start editing. We may want to throw up a statusbar
message before starting this later if it takes
too long to do this routine. For now silently
abort if they hit a key */
nodelay(edit, FALSE);
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
/* If it's not a multi-line regex, amscray */
if (tmpcolor->end == NULL)
continue;
#ifdef DEBUG
fprintf(stderr, "working on color id %d\n", tmpcolor->id);
#endif
for (fileptr = openfile->fileage; fileptr != NULL; fileptr = fileptr->next) {
int startx = 0;
int nostart = 0;
#ifdef DEBUG
fprintf(stderr, "working on lineno %lu\n", (unsigned long) fileptr->lineno);
#endif
alloc_multidata_if_needed(fileptr);
if ((cur_check = time(NULL)) - last_check > 1) {
last_check = cur_check;
if (wgetch(edit) != ERR)
goto precalc_cleanup;
}
while ((nostart = regexec(tmpcolor->start, &fileptr->data[startx], 1, &startmatch, 0)) == 0) {
/* Look for end and start marking how many lines are encompassed
whcih should speed up rendering later */
startx += startmatch.rm_eo;
#ifdef DEBUG
fprintf(stderr, "match found at pos %d...", startx);
#endif
/* Look on this line first for end */
if (regexec(tmpcolor->end, &fileptr->data[startx], 1, &endmatch, 0) == 0) {
startx += endmatch.rm_eo;
fileptr->multidata[tmpcolor->id] |= CSTARTENDHERE;
#ifdef DEBUG
fprintf(stderr, "end found on this line\n");
#endif
continue;
}
/* Nice, we didn't find the end regex on this line. Let's start looking for it */
for (endptr = fileptr->next; endptr != NULL; endptr = endptr->next) {
#ifdef DEBUG
fprintf(stderr, "advancing to line %lu to find end...\n", (unsigned long) endptr->lineno);
#endif
/* Check for keyboard input again */
if ((cur_check = time(NULL)) - last_check > 1) {
last_check = cur_check;
if (wgetch(edit) != ERR)
goto precalc_cleanup;
}
if (regexec(tmpcolor->end, endptr->data, 1, &endmatch, 0) == 0)
break;
}
if (endptr == NULL) {
#ifdef DEBUG
fprintf(stderr, "no end found, breaking out\n");
#endif
break;
}
#ifdef DEBUG
fprintf(stderr, "end found\n");
#endif
/* We found it, we found it, la la la la la. Mark all the
lines in between and the ends properly */
fileptr->multidata[tmpcolor->id] |= CENDAFTER;
#ifdef DEBUG
fprintf(stderr, "marking line %lu as CENDAFTER\n", (unsigned long) fileptr->lineno);
#endif
for (fileptr = fileptr->next; fileptr != endptr; fileptr = fileptr->next) {
alloc_multidata_if_needed(fileptr);
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
#ifdef DEBUG
fprintf(stderr, "marking intermediary line %lu as CWHOLELINE\n", (unsigned long) fileptr->lineno);
#endif
}
alloc_multidata_if_needed(endptr);
#ifdef DEBUG
fprintf(stderr, "marking line %lu as BEGINBEFORE\n", (unsigned long) fileptr->lineno);
#endif
endptr->multidata[tmpcolor->id] |= CBEGINBEFORE;
/* We should be able to skip all the way to the line of the match.
This may introduce more bugs but it's the Right Thing to do */
fileptr = endptr;
startx = endmatch.rm_eo;
#ifdef DEBUG
fprintf(stderr, "jumping to line %lu pos %d to continue\n", (unsigned long) endptr->lineno, startx);
#endif
}
if (nostart && startx == 0) {
#ifdef DEBUG
fprintf(stderr, "no start found on line %lu, continuing\n", (unsigned long) fileptr->lineno);
#endif
fileptr->multidata[tmpcolor->id] = CNONE;
continue;
}
}
}
}
precalc_cleanup:
nodelay(edit, FALSE);
}
#endif /* ENABLE_COLOR */
/* The user typed output_len multibyte characters. Add them to the edit
* buffer, filtering out all ASCII control characters if allow_cntrls is
* TRUE. */
void do_output(char *output, size_t output_len, bool allow_cntrls)
{
size_t current_len, i = 0;
bool do_refresh = FALSE;
/* Do we have to call edit_refresh(), or can we get away with
* just update_line()? */
size_t current_len, orig_lenpt, i = 0;
char *char_buf = charalloc(mb_cur_max());
int char_buf_len;
assert(openfile->current != NULL && openfile->current->data != NULL);
current_len = strlen(openfile->current->data);
if (ISSET(SOFTWRAP))
orig_lenpt = strlenpt(openfile->current->data);
while (i < output_len) {
/* If allow_cntrls is TRUE, convert nulls and newlines
@@ -1602,7 +1920,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
output[i] = '\n';
/* Newline to Enter, if needed. */
else if (output[i] == '\n') {
do_enter();
do_enter(FALSE);
i++;
continue;
}
@@ -1642,6 +1960,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
set_modified();
#ifndef NANO_TINY
update_undo(ADD);
/* Note that current_x has not yet been incremented. */
if (openfile->mark_set && openfile->current ==
openfile->mark_begin && openfile->current_x <
@@ -1653,33 +1973,37 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#ifndef DISABLE_WRAPPING
/* If we're wrapping text, we need to call edit_refresh(). */
if (!ISSET(NO_WRAP)) {
bool do_refresh_save = do_refresh;
do_refresh = do_wrap(openfile->current);
/* If we needed to call edit_refresh() before this, we'll
* still need to after this. */
if (do_refresh_save)
do_refresh = TRUE;
}
if (!ISSET(NO_WRAP))
if (do_wrap(openfile->current, FALSE))
edit_refresh_needed = TRUE;
#endif
#ifdef ENABLE_COLOR
/* If color syntaxes are available and turned on, we need to
* call edit_refresh(). */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
do_refresh = TRUE;
edit_refresh_needed = TRUE;
#endif
}
/* Well we might also need a full refresh if we've changed the
line length to be a new multiple of COLS */
if (ISSET(SOFTWRAP) && edit_refresh_needed == FALSE)
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
edit_refresh_needed = TRUE;
free(char_buf);
openfile->placewewant = xplustabs();
if (do_refresh)
#ifdef ENABLE_COLOR
reset_multis(openfile->current, FALSE);
#endif
if (edit_refresh_needed == TRUE) {
edit_refresh();
else
edit_refresh_needed = FALSE;
} else
update_line(openfile->current, openfile->current_x);
}
@@ -1731,6 +2055,7 @@ int main(int argc, char **argv)
{"operatingdir", 1, NULL, 'o'},
#endif
{"preserve", 0, NULL, 'p'},
{"quiet", 0, NULL, 'q'},
#ifndef DISABLE_WRAPJUSTIFY
{"fill", 1, NULL, 'r'},
#endif
@@ -1753,9 +2078,11 @@ int main(int argc, char **argv)
{"noconvert", 0, NULL, 'N'},
{"smooth", 0, NULL, 'S'},
{"quickblank", 0, NULL, 'U'},
{"undo", 0, NULL, 'u'},
{"wordbounds", 0, NULL, 'W'},
{"autoindent", 0, NULL, 'i'},
{"cut", 0, NULL, 'k'},
{"softwrap", 0, NULL, '$'},
#endif
{NULL, 0, NULL, 0}
};
@@ -1794,11 +2121,11 @@ int main(int argc, char **argv)
while ((optchr =
#ifdef HAVE_GETOPT_LONG
getopt_long(argc, argv,
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz",
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$",
long_options, NULL)
#else
getopt(argc, argv,
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pr:s:tvwxz")
"h?ABC:DEFHIKLNOQ:RST:UVWY:abcdefgijklmo:pqr:s:tuvwxz$")
#endif
) != -1) {
switch (optchr) {
@@ -1926,6 +2253,9 @@ int main(int argc, char **argv)
case 'p':
SET(PRESERVE);
break;
case 'q':
SET(QUIET);
break;
#ifndef DISABLE_WRAPJUSTIFY
case 'r':
if (!parse_num(optarg, &wrap_at)) {
@@ -1944,12 +2274,22 @@ int main(int argc, char **argv)
case 't':
SET(TEMP_FILE);
break;
#ifndef NANO_TINY
case 'u':
SET(UNDOABLE);
break;
#endif
case 'v':
SET(VIEW_MODE);
break;
#ifndef DISABLE_WRAPPING
case 'w':
SET(NO_WRAP);
/* If both --fill and --nowrap are given on the command line,
the last option wins, */
fill_used = FALSE;
break;
#endif
case 'x':
@@ -1958,6 +2298,11 @@ int main(int argc, char **argv)
case 'z':
SET(SUSPEND);
break;
#ifndef NANO_TINY
case '$':
SET(SOFTWRAP);
break;
#endif
default:
usage();
}
@@ -2005,7 +2350,10 @@ int main(int argc, char **argv)
char *alt_speller_cpy = alt_speller;
#endif
ssize_t tabsize_cpy = tabsize;
long flags_cpy = flags;
unsigned flags_cpy[sizeof(flags) / sizeof(flags[0])];
size_t i;
memcpy(flags_cpy, flags, sizeof(flags_cpy));
#ifndef DISABLE_OPERATINGDIR
operating_dir = NULL;
@@ -2057,7 +2405,9 @@ int main(int argc, char **argv)
#endif
if (tabsize_cpy != -1)
tabsize = tabsize_cpy;
flags |= flags_cpy;
for (i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
flags[i] |= flags_cpy[i];
}
#ifdef DISABLE_ROOTWRAPPING
/* If we don't have any rcfiles, --disable-wrapping-as-root is used,
@@ -2067,6 +2417,13 @@ int main(int argc, char **argv)
#endif
#endif /* ENABLE_NANORC */
#ifndef DISABLE_WRAPPING
/* Overwrite an rcfile "set nowrap" or --disable-wrapping-as-root
if a --fill option was given on the command line. */
if (fill_used)
UNSET(NO_WRAP);
#endif
/* If we're using bold text instead of reverse video text, set it up
* now. */
if (ISSET(BOLD_TEXT))
@@ -2206,6 +2563,12 @@ int main(int argc, char **argv)
optind++;
}
if (optind < argc && !strcmp(argv[optind], "-")) {
stdin_pager();
set_modified();
optind++;
}
#ifdef ENABLE_MULTIBUFFER
old_multibuffer = ISSET(MULTIBUFFER);
SET(MULTIBUFFER);
@@ -2224,7 +2587,7 @@ int main(int argc, char **argv)
icol == 1)
parse_line_column(&argv[i][1], &iline, &icol);
else {
open_buffer(argv[i]);
open_buffer(argv[i], FALSE);
if (iline > 1 || icol > 1) {
do_gotolinecolumn(iline, icol, FALSE, FALSE, FALSE,
@@ -2241,14 +2604,14 @@ int main(int argc, char **argv)
* buffer or a new buffer, depending on whether multibuffer mode is
* enabled. */
if (optind < argc)
open_buffer(argv[optind]);
open_buffer(argv[optind], FALSE);
/* We didn't open any files if all the command line arguments were
* invalid files like directories or if there were no command line
* arguments given. In this case, we have to load a blank buffer.
* Also, we unset view mode to allow editing. */
if (openfile == NULL) {
open_buffer("");
open_buffer("", FALSE);
UNSET(VIEW_MODE);
}
@@ -2261,6 +2624,11 @@ int main(int argc, char **argv)
fprintf(stderr, "Main: top and bottom win\n");
#endif
#ifdef ENABLE_COLOR
if (openfile->syntax && openfile->syntax->nmultis > 0)
precalc_multicolorinfo();
#endif
if (startline > 1 || startcol > 1)
do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE,
FALSE);
@@ -2307,3 +2675,4 @@ int main(int argc, char **argv)
/* We should never get here. */
assert(FALSE);
}

View File

@@ -2,8 +2,8 @@
/**************************************************************************
* nano.h *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -28,6 +28,12 @@
#include <config.h>
#endif
#ifdef NEED_XOPEN_SOURCE_EXTENDED
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#endif /* _XOPEN_SOURCE_EXTENDED */
#endif /* NEED_XOPEN_SOURCE_EXTENDED */
#ifdef __TANDEM
/* Tandem NonStop Kernel support. */
#include <floss.h>
@@ -44,11 +50,21 @@
#include <sys/param.h>
#endif
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#endif
/* Suppress warnings for __attribute__((warn_unused_result)) */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
/* Macros for flags. */
#define SET(bit) flags |= bit
#define UNSET(bit) flags &= ~bit
#define ISSET(bit) ((flags & bit) != 0)
#define TOGGLE(bit) flags ^= bit
#define FLAGOFF(flag) ((flag) / (sizeof(unsigned) * 8))
#define FLAGMASK(flag) (1 << ((flag) % (sizeof(unsigned) * 8)))
#define FLAGS(flag) flags[FLAGOFF(flag)]
#define SET(flag) FLAGS(flag) |= FLAGMASK(flag)
#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag)
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
/* Macros for character allocation and more. */
#define charalloc(howmuch) (char *)nmalloc((howmuch) * sizeof(char))
@@ -169,35 +185,9 @@ typedef enum {
CONTROL, META, FKEY, RAW
} function_type;
/* Structure types. */
typedef struct filestruct {
char *data;
/* The text of this line. */
ssize_t lineno;
/* The number of this line. */
struct filestruct *next;
/* Next node. */
struct filestruct *prev;
/* Previous node. */
} filestruct;
typedef struct partition {
filestruct *fileage;
/* The top line of this portion of the file. */
filestruct *top_prev;
/* The line before the top line of this portion of the file. */
char *top_data;
/* The text before the beginning of the top line of this portion
* of the file. */
filestruct *filebot;
/* The bottom line of this portion of the file. */
filestruct *bot_next;
/* The line after the bottom line of this portion of the
* file. */
char *bot_data;
/* The text after the end of the bottom line of this portion of
* the file. */
} partition;
typedef enum {
ADD, DEL, REPLACE, SPLIT, UNSPLIT, CUT, UNCUT, ENTER, INSERT, OTHER
} undo_type;
#ifdef ENABLE_COLOR
typedef struct colortype {
@@ -222,6 +212,8 @@ typedef struct colortype {
/* The compiled end (if any) of the regex string. */
struct colortype *next;
/* Next set of colors. */
int id;
/* basic id for assigning to lines later */
} colortype;
typedef struct exttype {
@@ -238,13 +230,99 @@ typedef struct syntaxtype {
/* The name of this syntax. */
exttype *extensions;
/* The list of extensions that this syntax applies to. */
exttype *headers;
/* Regexes to match on the 'header' (1st line) of the file */
colortype *color;
/* The colors used in this syntax. */
int nmultis;
/* How many multi line strings this syntax has */
struct syntaxtype *next;
/* Next syntax. */
} syntaxtype;
#define CNONE (1<<1)
/* Yay, regex doesn't apply to this line at all! */
#define CBEGINBEFORE (1<<2)
/* regex starts on an earlier line, ends on this one */
#define CENDAFTER (1<<3)
/* regex sraers on this line and ends on a later one */
#define CWHOLELINE (1<<4)
/* whole line engulfed by the regex start < me, end > me */
#define CSTARTENDHERE (1<<5)
/* regex starts and ends within this line */
#define CWTF (1<<6)
/* Something else */
#endif /* ENABLE_COLOR */
/* Structure types. */
typedef struct filestruct {
char *data;
/* The text of this line. */
ssize_t lineno;
/* The number of this line. */
struct filestruct *next;
/* Next node. */
struct filestruct *prev;
/* Previous node. */
#ifdef ENABLE_COLOR
short *multidata; /* Array of which multi-line regexes apply to this line */
#endif
} filestruct;
typedef struct partition {
filestruct *fileage;
/* The top line of this portion of the file. */
filestruct *top_prev;
/* The line before the top line of this portion of the file. */
char *top_data;
/* The text before the beginning of the top line of this portion
* of the file. */
filestruct *filebot;
/* The bottom line of this portion of the file. */
filestruct *bot_next;
/* The line after the bottom line of this portion of the
* file. */
char *bot_data;
/* The text after the end of the bottom line of this portion of
* the file. */
} partition;
#ifndef NANO_TINY
typedef struct undo {
ssize_t lineno;
undo_type type;
/* What type of undo was this */
int begin;
/* Where did this action begin or end */
char *strdata;
/* String type data we will use for ccopying the affected line back */
char *strdata2;
/* Sigh, need this too it looks like */
int xflags;
/* Some flag data we need */
/* Cut specific stuff we need */
filestruct *cutbuffer;
/* Copy of the cutbuffer */
filestruct *cutbottom;
/* Copy of cutbottom */
bool mark_set;
/* was the marker set when we cut */
bool to_end;
/* was this a cut to end */
ssize_t mark_begin_lineno;
/* copy copy copy */
ssize_t mark_begin_x;
/* Another shadow variable */
struct undo *next;
} undo;
#endif /* NANO_TINY */
typedef struct openfilestruct {
char *filename;
/* The current file's name. */
@@ -278,8 +356,15 @@ typedef struct openfilestruct {
/* The current file's format. */
struct stat *current_stat;
/* The current file's stat. */
undo *undotop;
/* Top of the undo list */
undo *current_undo;
/* The current (i.e. n ext) level of undo */
undo_type last_action;
#endif
#ifdef ENABLE_COLOR
syntaxtype *syntax;
/* The syntax struct for this file, if any */
colortype *colorstrings;
/* The current file's associated colors. */
#endif
@@ -318,25 +403,6 @@ typedef struct shortcut {
/* Next shortcut. */
} shortcut;
#ifndef NANO_TINY
typedef struct toggle {
int val;
/* The sequence to toggle the key. We should only need one. */
const char *desc;
/* The description of the toggle, e.g. "Cut to end"; we'll
* append Enabled or Disabled to it. */
#ifndef DISABLE_HELP
bool blank_after;
/* Whether there should be a blank line after the description of
* the toggle. */
#endif
long flag;
/* Which flag actually gets toggled. */
struct toggle *next;
/* Next toggle. */
} toggle;
#endif
#ifdef ENABLE_NANORC
typedef struct rcoption {
const char *name;
@@ -356,7 +422,7 @@ typedef struct sc {
/* The actual sequence to check on the the type is determined */
int menu;
/* What list does this apply to */
void (*scfunc)(void);
short scfunc;
/* The function we're going to run */
int toggle;
/* If a toggle, what we're toggling */
@@ -368,7 +434,7 @@ typedef struct sc {
} sc;
typedef struct subnfunc {
void (*scfunc)(void);
short scfunc;
/* What function is this */
int menus;
/* In what menus does this function applu */
@@ -390,39 +456,47 @@ typedef struct subnfunc {
} subnfunc;
/* Bitwise flags so that we can save space (or, more correctly, not
* waste it). */
#define CASE_SENSITIVE (1<<0)
#define CONST_UPDATE (1<<1)
#define NO_HELP (1<<2)
#define NOFOLLOW_SYMLINKS (1<<3)
#define SUSPEND (1<<4)
#define NO_WRAP (1<<5)
#define AUTOINDENT (1<<6)
#define VIEW_MODE (1<<7)
#define USE_MOUSE (1<<8)
#define USE_REGEXP (1<<9)
#define TEMP_FILE (1<<10)
#define CUT_TO_END (1<<11)
#define BACKWARDS_SEARCH (1<<12)
#define MULTIBUFFER (1<<13)
#define SMOOTH_SCROLL (1<<14)
#define REBIND_DELETE (1<<15)
#define REBIND_KEYPAD (1<<16)
#define NO_CONVERT (1<<17)
#define BACKUP_FILE (1<<18)
#define NO_COLOR_SYNTAX (1<<19)
#define PRESERVE (1<<20)
#define HISTORYLOG (1<<21)
#define RESTRICTED (1<<22)
#define SMART_HOME (1<<23)
#define WHITESPACE_DISPLAY (1<<24)
#define MORE_SPACE (1<<25)
#define TABS_TO_SPACES (1<<26)
#define QUICK_BLANK (1<<27)
#define WORD_BOUNDS (1<<28)
#define NO_NEWLINES (1<<29)
#define BOLD_TEXT (1<<30)
/* Enumeration to be used in flags table. See FLAGBIT and FLAGOFF
* definitions. */
enum
{
DONTUSE,
CASE_SENSITIVE,
CONST_UPDATE,
NO_HELP,
NOFOLLOW_SYMLINKS,
SUSPEND,
NO_WRAP,
AUTOINDENT,
VIEW_MODE,
USE_MOUSE,
USE_REGEXP,
TEMP_FILE,
CUT_TO_END,
BACKWARDS_SEARCH,
MULTIBUFFER,
SMOOTH_SCROLL,
REBIND_DELETE,
REBIND_KEYPAD,
NO_CONVERT,
BACKUP_FILE,
INSECURE_BACKUP,
NO_COLOR_SYNTAX,
PRESERVE,
HISTORYLOG,
RESTRICTED,
SMART_HOME,
WHITESPACE_DISPLAY,
MORE_SPACE,
TABS_TO_SPACES,
QUICK_BLANK,
WORD_BOUNDS,
NO_NEWLINES,
BOLD_TEXT,
QUIET,
UNDOABLE,
SOFTWRAP
};
/* Flags for which menus in which a given function should be present */
#define MMAIN (1<<0)
@@ -667,8 +741,173 @@ typedef struct subnfunc {
#define TOGGLE_BACKWARDS_KEY NANO_META_B
#define TOGGLE_DOS_KEY NANO_META_D
#define TOGGLE_MAC_KEY NANO_META_M
/* Extra bits for the undo function */
#define UNDO_DEL_DEL (1<<0)
#define UNDO_DEL_BACKSPACE (1<<1)
#define UNDO_SPLIT_MADENEW (1<<2)
/* Since in ISO C you can't pass around function pointers anymore,
let's make some integer macros for function names, and then I
can go cut my wrists after writing the big switch statement
that will necessitate. */
#endif /* !NANO_TINY */
#define CASE_SENS_MSG 1
#define BACKWARDS_MSG 2
#define REGEXP_MSG 3
#define WHEREIS_NEXT_MSG 4
#define FIRST_FILE_MSG 5
#define LAST_FILE_MSG 6
#define GOTO_DIR_MSG 7
#define TOTAL_REFRESH 8
#define DO_HELP_VOID 9
#define DO_SEARCH 10
#define DO_PAGE_UP 11
#define DO_PAGE_DOWN 12
#define DO_UP_VOID 13
#define DO_LEFT 14
#define DO_DOWN_VOID 15
#define DO_RIGHT 16
#define DO_ENTER 17
#define DO_EXIT 18
#define NEW_BUFFER_MSG 19
#define EXT_CMD_MSG 20
#define TO_FILES_MSG 21
#define DOS_FORMAT_MSG 23
#define MAC_FORMAT_MSG 24
#define BACKUP_FILE_MSG 25
#define PREPEND_MSG 26
#define APPEND_MSG 27
#define DO_FIRST_LINE 28
#define DO_LAST_LINE 29
#define DO_TOGGLE 30
#define GOTOTEXT_MSG 31
#define NO_REPLACE_MSG 32
#define DO_BACKSPACE 33
#define DO_DELETE 34
#define DO_TAB 35
#define DO_VERBATIM_INPUT 36
#define SWITCH_TO_NEXT_BUFFER_VOID 37
#define SWITCH_TO_PREV_BUFFER_VOID 38
#define DO_END 39
#define DO_HOME 40
#define NEXT_HISTORY_MSG 41
#define PREV_HISTORY_MSG 42
#define DO_REDO 43
#define DO_UNDO 44
#define DO_WORDLINECHAR_COUNT 45
#define DO_FIND_BRACKET 46
#define DO_PREV_WORD_VOID 47
#define DO_SUSPEND_VOID 48
#define CANCEL_MSG 49
#define DO_WRITEOUT_VOID 50
#define DO_INSERTFILE_VOID 51
#define DO_CUT_TEXT_VOID 52
#define DO_UNCUT_TEXT 53
#define DO_CURSORPOS_VOID 54
#define DO_GOTOLINECOLUMN_VOID 55
#define DO_REPLACE 56
#define DO_JUSTIFY_VOID 57
#define DO_PARA_BEGIN_VOID 58
#define DO_PARA_END_VOID 59
#define DO_FULL_JUSTIFY 60
#define DO_MARK 61
#define DO_RESEARCH 62
#define DO_COPY_TEXT 63
#define DO_INDENT_VOID 64
#define DO_UNINDENT 65
#define DO_SCROLL_UP 66
#define DO_SCROLL_DOWN 67
#define DO_NEXT_WORD_VOID 68
#define DO_CUT_TILL_END 69
#define NANO_GOTODIR_MSG 70
#define NANO_LASTFILE_MSG 71
#define NANO_FIRSTFILE_MSG 72
#define INSERT_FILE_MSG 73
#define NANO_MULTIBUFFER_MSG 74
#define NANO_EXECUTE_MSG 75
#define NANO_BACKUP_MSG 76
#define NANO_PREPEND_MSG 77
#define NANO_APPEND_MSG 78
#define NANO_MAC_MSG 79
#define NANO_DOS_MSG 80
#define NANO_TOFILES_MSG 81
#define NANO_NEXT_HISTORY_MSG 82
#define NANO_PREV_HISTORY_MSG 83
#define NANO_REGEXP_MSG 84
#define NANO_REVERSE_MSG 85
#define NANO_CASE_MSG 86
#define NANO_SUSPEND_MSG 87
#define SUSPEND_MSG 88
#define NANO_REFRESH_MSG 89
#define REFRESH_MSG 90
#define NANO_WORDCOUNT_MSG 91
#define NANO_FULLJUSTIFY_MSG 92
#define FULLJSTIFY_MSG 93
#define XOFF_COMPLAINT 94
#define XON_COMPLAINT 95
#define NANO_CUT_TILL_END_MSG 96
#define NANO_BACKSPACE_MSG 97
#define NANO_DELETE_MSG 98
#define NANO_ENTER_MSG 99
#define NANO_TAB_MSG 100
#define NANO_VERBATIM_MSG 101
#define NANO_NEXTFILE_MSG 102
#define NANO_PREVFILE_MSG 103
#define NANO_SCROLLDOWN_MSG 104
#define NANO_SCROLLUP_MSG 105
#define NANO_BRACKET_MSG 106
#define NANO_PARAEND_MSG 107
#define END_OF_PAR_MSG 108
#define NANO_PARABEGIN_MSG 109
#define BEG_OF_PAR_MSG 110
#define NANO_END_MSG 111
#define NANO_HOME_MSG 112
#define NANO_NEXTLINE_MSG 113
#define NANO_PREVLINE_MSG 114
#define NANO_PREVWORD_MSG 115
#define NANO_NEXTWORD_MSG 116
#define NANO_BACK_MSG 117
#define NANO_FORWARD_MSG 118
#define NANO_REDO_MSG 119
#define NANO_UNDO_MSG 120
#define NANO_UNINDENT_MSG 121
#define NANO_INDENT_MSG 122
#define NANO_COPY_MSG 123
#define NANO_WHEREIS_NEXT_MSG 124
#define NANO_MARK_MSG 125
#define NANO_REPLACE_MSG 126
#define REPLACE_MSG 127
#define NANO_GOTOLINE_MSG 128
#define NANO_LASTLINE_MSG 129
#define NANO_FIRSTLINE_MSG 130
#define NANO_SPELL_MSG 131
#define DO_SPELL 132
#define NANO_CURSORPOS_MSG 133
#define NANO_UNCUT_MSG 134
#define GET_HELP_MSG 135
#define NANO_HELP_MSG 136
#define NANO_CANCEL_MSG 137
#define NANO_EXIT_MSG 138
#define EXIT_MSG 139
#define NANO_EXITBROWSER_MSG 140
#define NANO_WRITEOUT_MSG 141
#define NANO_DISABLED_MSG 142
#define NANO_INSERT_MSG 143
#define WHEREIS_MSG 144
#define NANO_WHEREIS_MSG 145
#define NANO_PREVPAGE_MSG 146
#define NANO_NEXTPAGE_MSG 147
#define NANO_CUT_MSG 148
#define DO_CUT_TEXT 149
#define DO_NEXT_WORD 150
#define DO_PREV_WORD 151
#define VIEW TRUE
#define NOVIEW FALSE

View File

@@ -2,8 +2,8 @@
/**************************************************************************
* prompt.c *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -152,38 +152,38 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
}
if (*have_shortcut) {
if (s->scfunc == do_tab || s->scfunc == do_enter)
if (s->scfunc == DO_TAB || s->scfunc == DO_ENTER)
;
else if (s->scfunc == total_refresh)
else if (s->scfunc == TOTAL_REFRESH)
total_statusbar_refresh(refresh_func);
else if (s->scfunc == (void *) do_cut_text) {
else if (s->scfunc == DO_CUT_TEXT) {
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable Cut. */
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
'\0' || currmenu != MWRITEFILE)
do_statusbar_cut_text();
} else if (s->scfunc == do_right)
} else if (s->scfunc == DO_RIGHT)
do_statusbar_right();
else if (s->scfunc == do_left)
else if (s->scfunc == DO_LEFT)
do_statusbar_left();
#ifndef NANO_TINY
else if (s->scfunc == (void *) do_next_word)
else if (s->scfunc == DO_NEXT_WORD)
do_statusbar_next_word(FALSE);
else if (s->scfunc == (void *) do_prev_word)
else if (s->scfunc == DO_PREV_WORD)
do_statusbar_prev_word(FALSE);
#endif
else if (s->scfunc == do_home)
else if (s->scfunc == DO_HOME)
do_statusbar_home();
else if (s->scfunc == do_end)
else if (s->scfunc == DO_END)
do_statusbar_end();
#ifndef NANO_TINY
else if (s->scfunc == do_find_bracket)
else if (s->scfunc == DO_FIND_BRACKET)
do_statusbar_find_bracket();
#endif
else if (s->scfunc == do_verbatim_input) {
else if (s->scfunc == DO_VERBATIM_INPUT) {
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable verbatim input. */
@@ -201,18 +201,18 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
* to indicate that we're done. */
if (got_enter) {
get_input(NULL, 1);
input = sc_seq_or(do_enter, 0);
input = sc_seq_or(DO_ENTER, 0);
*finished = TRUE;
}
}
} else if (s->scfunc == do_delete) {
} else if (s->scfunc == DO_DELETE) {
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable Delete. */
if (!ISSET(RESTRICTED) || openfile->filename[0] ==
'\0' || currmenu != MWRITEFILE)
do_statusbar_delete();
} else if (s->scfunc == do_backspace) {
} else if (s->scfunc == DO_BACKSPACE) {
/* If we're using restricted mode, the filename
* isn't blank, and we're at the "Write File"
* prompt, disable Backspace. */
@@ -227,10 +227,10 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *have_shortcut,
* associated functions. */
f = sctofunc((sc *) s);
if (s->scfunc != NULL && s->execute == TRUE) {
if (s->scfunc != 0 && s->execute == TRUE) {
*ran_func = TRUE;
if (!ISSET(VIEW_MODE) || f->viewok)
f->scfunc();
if (f && (!ISSET(VIEW_MODE) || (f->viewok)))
iso_me_harder_funcmap(f->scfunc);
}
*finished = TRUE;
}
@@ -868,7 +868,7 @@ void update_statusbar_line(const char *curranswer, size_t index)
free(expanded);
wattroff(bottomwin, reverse_attr);
statusbar_pww = statusbar_xplustabs();
reset_statusbar_cursor();
wnoutrefresh(bottomwin);
}
@@ -956,7 +956,7 @@ const sc *get_prompt_string(int *actual, bool allow_tabs,
currmenu = menu;
#ifdef DEBUG
fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer, statusbar_x);
fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %lu\n", answer, (unsigned long) statusbar_x);
#endif
update_statusbar_line(answer, statusbar_x);
@@ -979,19 +979,19 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
s = get_shortcut(currmenu, &kbinput, meta_key, func_key);
if (s)
if (s->scfunc == (void *) cancel_msg || s->scfunc == do_enter)
if (s->scfunc == CANCEL_MSG || s->scfunc == DO_ENTER)
break;
#ifndef DISABLE_TABCOMP
if (s && s->scfunc != do_tab)
if (s && s->scfunc != DO_TAB)
tabbed = FALSE;
#endif
#ifndef DISABLE_TABCOMP
#ifndef NANO_TINY
if (s && s->scfunc == do_tab) {
if (s && s->scfunc == DO_TAB) {
if (history_list != NULL) {
if (last_kbinput != sc_seq_or(do_tab, NANO_CONTROL_I))
if (last_kbinput != sc_seq_or(DO_TAB, NANO_CONTROL_I))
complete_len = strlen(answer);
if (complete_len > 0) {
@@ -1010,7 +1010,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
} else
#endif /* !DISABLE_TABCOMP */
#ifndef NANO_TINY
if (s && s->scfunc == (void *) prev_history_msg) {
if (s && s->scfunc == PREV_HISTORY_MSG) {
if (history_list != NULL) {
/* If we're scrolling up at the bottom of the
* history list and answer isn't blank, save answer
@@ -1038,7 +1038,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
* statusbar prompt. */
finished = FALSE;
}
} else if (s && s->scfunc == (void *) next_history_msg) {
} else if (s && s->scfunc == NEXT_HISTORY_MSG) {
if (history_list != NULL) {
/* Get the newer search from the history list and
* save it in answer. If there is no newer search,
@@ -1070,8 +1070,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
}
} else
#endif /* !NANO_TINY */
#ifndef DISABLE_HELP
if (s && s->scfunc == do_help_void) {
if (s && s->scfunc == DO_HELP_VOID) {
update_statusbar_line(answer, statusbar_x);
/* This key has a shortcut list entry when it's used to
@@ -1082,7 +1081,6 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
* prompt. */
finished = FALSE;
}
#endif
/* If we have a shortcut with an associated function, break out
* if we're finished after running or trying to run the
@@ -1116,7 +1114,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
* we've finished putting in an answer, reset the statusbar cursor
* position too. */
if (s) {
if (s->scfunc == (void *) cancel_msg || s->scfunc == do_enter ||
if (s->scfunc == CANCEL_MSG || s->scfunc == DO_ENTER ||
ran_func) {
statusbar_x = old_statusbar_x;
statusbar_pww = old_pww;
@@ -1203,9 +1201,9 @@ int do_prompt(bool allow_tabs,
/* If we left the prompt via Cancel or Enter, set the return value
* properly. */
if (s && s->scfunc == (void *) cancel_msg)
if (s && s->scfunc == CANCEL_MSG)
retval = -1;
else if (s && s->scfunc == do_enter)
else if (s && s->scfunc == DO_ENTER)
retval = (*answer == '\0') ? -2 : 0;
blank_statusbar();
@@ -1313,7 +1311,7 @@ int do_yesno_prompt(bool all, const char *msg)
kbinput = get_kbinput(bottomwin, &meta_key, &func_key);
s = get_shortcut(currmenu, &kbinput, &meta_key, &func_key);
if (s && s->scfunc == (void *) cancel_msg)
if (s && s->scfunc == CANCEL_MSG)
ok = -1;
#ifndef DISABLE_MOUSE
else if (kbinput == KEY_MOUSE) {
@@ -1345,7 +1343,7 @@ int do_yesno_prompt(bool all, const char *msg)
}
}
#endif /* !DISABLE_MOUSE */
else if (s && s->scfunc == total_refresh) {
else if (s && s->scfunc == TOTAL_REFRESH) {
total_redraw();
continue;
} else {

View File

@@ -2,8 +2,8 @@
/**************************************************************************
* proto.h *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -30,6 +30,7 @@
#ifndef NANO_TINY
extern sigjmp_buf jump_buf;
extern bool jump_buf_main;
extern bool use_undo;
#endif
#ifndef DISABLE_WRAPJUSTIFY
@@ -40,13 +41,15 @@ extern ssize_t wrap_at;
extern char *last_search;
extern char *last_replace;
extern long flags;
extern unsigned flags[4];
extern WINDOW *topwin;
extern WINDOW *edit;
extern WINDOW *bottomwin;
extern int editwinrows;
extern int maxrows;
extern filestruct *cutbuffer;
extern filestruct *cutbottom;
#ifndef DISABLE_JUSTIFY
extern filestruct *jusbuffer;
#endif
@@ -60,6 +63,7 @@ extern char *matchbrackets;
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
extern char *whitespace;
extern int whitespace_len[2];
extern undo_type last_action;
#endif
#ifndef DISABLE_JUSTIFY
@@ -74,7 +78,7 @@ extern char *quoteerr;
extern size_t quotelen;
#endif
#endif
extern bool nodelay_mode;
extern char *answer;
extern ssize_t tabsize;
@@ -98,11 +102,9 @@ extern syntaxtype *syntaxes;
extern char *syntaxstr;
#endif
extern bool edit_refresh_needed;
extern const shortcut *currshortcut;
extern int currmenu;
#ifndef NANO_TINY
extern toggle *toggles;
#endif
#ifndef NANO_TINY
extern filestruct *search_history;
@@ -240,7 +242,7 @@ void cut_to_eof(void);
#endif
void do_cut_text(
#ifndef NANO_TINY
bool copy_text, bool cut_till_end
bool copy_text, bool cut_till_end, bool undoing
#else
void
#endif
@@ -256,7 +258,7 @@ void do_uncut_text(void);
void make_new_buffer(void);
void initialize_buffer(void);
void initialize_buffer_text(void);
void open_buffer(const char *filename);
void open_buffer(const char *filename, bool undoable);
#ifndef DISABLE_SPELLER
void replace_buffer(const char *filename);
#endif
@@ -269,7 +271,7 @@ bool close_buffer(void);
#endif
filestruct *read_line(char *buf, filestruct *prevnode, bool
*first_line_ins, size_t buf_len);
void read_file(FILE *f, const char *filename);
void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable);
int open_file(const char *filename, bool newfie, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile(
@@ -344,12 +346,12 @@ void thanks_for_all_the_fish(void);
#endif
/* All functions in help.c. */
#ifndef DISABLE_HELP
void do_help(void (*refresh_func)(void));
void do_help_void(void);
#ifndef DISABLE_BROWSER
void do_browser_help(void);
#endif
void do_help_void(void);
#ifndef DISABLE_HELP
void do_help(void (*refresh_func)(void));
void help_init(void);
void parse_help_input(int *kbinput, bool *meta_key, bool *func_key);
size_t help_line_len(const char *ptr);
@@ -426,7 +428,11 @@ void free_openfilestruct(openfilestruct *src);
void print_view_warning(void);
void finish(void);
void die(const char *msg, ...);
void die_save_file(const char *die_filename);
void die_save_file(const char *die_filename
#ifndef NANO_TINY
, struct stat *die_stat
#endif
);
void window_init(void);
#ifndef DISABLE_MOUSE
void disable_mouse_support(void);
@@ -543,6 +549,8 @@ void parse_syntax(char *ptr);
void parse_include(char *ptr);
short color_to_short(const char *colorname, bool *bright);
void parse_colors(char *ptr, bool icase);
void reset_multis(filestruct *fileptr, bool force);
void alloc_multidata_if_needed(filestruct *fileptr);
#endif
void parse_rcfile(FILE *rcstream
#ifdef ENABLE_COLOR
@@ -619,15 +627,17 @@ void do_tab(void);
void do_indent(ssize_t cols);
void do_indent_void(void);
void do_unindent(void);
void do_undo(void);
void do_redo(void);
#endif
void do_enter(void);
void do_enter(bool undoing);
#ifndef NANO_TINY
RETSIGTYPE cancel_command(int signal);
bool execute_command(const char *command);
#endif
#ifndef DISABLE_WRAPPING
void wrap_reset(void);
bool do_wrap(filestruct *line);
bool do_wrap(filestruct *line, bool undoing);
#endif
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal
@@ -684,6 +694,7 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream);
#endif
#ifdef HAVE_REGEX_H
bool regexp_bol_or_eol(const regex_t *preg, const char *string);
const char *fixbounds(const char *r);
#endif
#ifndef DISABLE_SPELLER
bool is_whole_word(size_t pos, const char *buf, const char *word);
@@ -706,8 +717,11 @@ void new_magicline(void);
void remove_magicline(void);
void mark_order(const filestruct **top, size_t *top_x, const filestruct
**bot, size_t *bot_x, bool *right_side_up);
void add_undo(undo_type current_action);
void update_undo(undo_type action);
#endif
size_t get_totsize(const filestruct *begin, const filestruct *end);
filestruct *fsfromline(ssize_t lineno);
#ifdef DEBUG
void dump_filestruct(const filestruct *inptr);
void dump_filestruct_reverse(void);
@@ -738,10 +752,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
#endif
const sc *get_shortcut(int menu, int *kbinput, bool
*meta_key, bool *func_key);
const sc *first_sc_for(int menu, void *func);
#ifndef NANO_TINY
const toggle *get_toggle(int kbinput, bool meta_key);
#endif
const sc *first_sc_for(int menu, short func);
void blank_line(WINDOW *win, int y, int x, int n);
void blank_titlebar(void);
void blank_topbar(void);
@@ -757,13 +768,13 @@ void statusbar(const char *msg, ...);
void bottombars(int menu);
void onekey(const char *keystroke, const char *desc, size_t len);
void reset_cursor(void);
void edit_draw(const filestruct *fileptr, const char *converted, int
void edit_draw(filestruct *fileptr, const char *converted, int
line, size_t start);
void update_line(const filestruct *fileptr, size_t index);
int update_line(filestruct *fileptr, size_t index);
bool need_horizontal_update(size_t pww_save);
bool need_vertical_update(size_t pww_save);
void edit_scroll(scroll_dir direction, ssize_t nlines);
void edit_redraw(const filestruct *old_current, size_t pww_save);
void edit_redraw(filestruct *old_current, size_t pww_save);
void edit_refresh(void);
void edit_update(update_type location);
void total_redraw(void);
@@ -772,49 +783,49 @@ void display_main_list(void);
void do_cursorpos(bool constant);
void do_cursorpos_void(void);
void do_replace_highlight(bool highlight, const char *word);
char *flagtostr(int flag);
const char *flagtostr(int flag);
const subnfunc *sctofunc(sc *s);
const subnfunc *getfuncfromkey(WINDOW *win);
void print_sclist(void);
sc *strtosc(int menu, char *input);
function_type strtokeytype(char *str);
function_type strtokeytype(const char *str);
int strtomenu(char *input);
void assign_keyinfo(sc *s);
void xon_complaint(void);
void xoff_complaint(void);
int sc_seq_or (void *func, int defaultval);
int sc_seq_or (short func, int defaultval);
void do_suspend_void(void);
const char *cancel_msg;
extern const char *cancel_msg;
#ifndef NANO_TINY
const char *case_sens_msg;
const char *backwards_msg;
const char *prev_history_msg;
const char *next_history_msg;
extern const char *case_sens_msg;
extern const char *backwards_msg;
extern const char *prev_history_msg;
extern const char *next_history_msg;
#endif
const char *replace_msg;
const char *no_replace_msg;
const char *go_to_line_msg;
const char *whereis_next_msg;
const char *first_file_msg;
const char *last_file_msg;
const char *goto_dir_msg;
const char *ext_cmd_msg;
const char *to_files_msg;
const char *dos_format_msg;
const char *mac_format_msg;
const char *append_msg;
const char *prepend_msg;
const char *backup_file_msg;
const char *dos_format_msg;
const char *mac_format_msg;
const char *append_msg;
const char *prepend_msg;
const char *backup_file_msg;
const char *gototext_msg;
const char *new_buffer_msg;
extern const char *replace_msg;
extern const char *no_replace_msg;
extern const char *go_to_line_msg;
extern const char *whereis_next_msg;
extern const char *first_file_msg;
extern const char *last_file_msg;
extern const char *goto_dir_msg;
extern const char *ext_cmd_msg;
extern const char *to_files_msg;
extern const char *dos_format_msg;
extern const char *mac_format_msg;
extern const char *append_msg;
extern const char *prepend_msg;
extern const char *backup_file_msg;
extern const char *gototext_msg;
extern const char *new_buffer_msg;
void iso_me_harder_funcmap(short func);
void enable_nodelay(void);
void disable_nodelay(void);
#ifdef HAVE_REGEX_H
const char *regexp_msg;
extern const char *regexp_msg;
#endif
#ifdef NANO_EXTRA

View File

@@ -2,7 +2,7 @@
/**************************************************************************
* rcfile.c *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 *
* Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -77,6 +77,7 @@ static const rcoption rcopts[] = {
#ifndef NANO_TINY
{"autoindent", AUTOINDENT},
{"backup", BACKUP_FILE},
{"allow_insecure_backup", INSECURE_BACKUP},
{"backupdir", 0},
{"backwards", BACKWARDS_SEARCH},
{"casesensitive", CASE_SENSITIVE},
@@ -84,12 +85,15 @@ static const rcoption rcopts[] = {
{"historylog", HISTORYLOG},
{"matchbrackets", 0},
{"noconvert", NO_CONVERT},
{"quiet", QUIET},
{"quickblank", QUICK_BLANK},
{"smarthome", SMART_HOME},
{"smooth", SMOOTH_SCROLL},
{"tabstospaces", TABS_TO_SPACES},
{"undo", UNDOABLE},
{"whitespace", 0},
{"wordbounds", WORD_BOUNDS},
{"softwrap", SOFTWRAP},
#endif
{NULL, 0}
};
@@ -103,8 +107,11 @@ static char *nanorc = NULL;
#ifdef ENABLE_COLOR
static syntaxtype *endsyntax = NULL;
/* The end of the list of syntaxes. */
static exttype *endheader = NULL;
/* End of header list */
static colortype *endcolor = NULL;
/* The end of the color list for the current syntax. */
#endif
/* We have an error in some part of the rcfile. Print the error message
@@ -114,6 +121,9 @@ void rcfile_error(const char *msg, ...)
{
va_list ap;
if (ISSET(QUIET))
return;
fprintf(stderr, "\n");
if (lineno > 0) {
errors = TRUE;
@@ -217,19 +227,19 @@ char *parse_next_regex(char *ptr)
bool nregcomp(const char *regex, int eflags)
{
regex_t preg;
int rc = regcomp(&preg, regex, REG_EXTENDED | eflags);
const char *r = fixbounds(regex);
int rc = regcomp(&preg, r, REG_EXTENDED | eflags);
if (rc != 0) {
size_t len = regerror(rc, &preg, NULL, 0);
char *str = charalloc(len);
regerror(rc, &preg, str, len);
rcfile_error(N_("Bad regex \"%s\": %s"), regex, str);
rcfile_error(N_("Bad regex \"%s\": %s"), r, str);
free(str);
}
regfree(&preg);
return (rc == 0);
}
@@ -290,8 +300,11 @@ void parse_syntax(char *ptr)
endsyntax->desc = mallocstrcpy(NULL, nameptr);
endsyntax->color = NULL;
endcolor = NULL;
endheader = NULL;
endsyntax->extensions = NULL;
endsyntax->headers = NULL;
endsyntax->next = NULL;
endsyntax->nmultis = 0;
#ifdef DEBUG
fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
@@ -380,50 +393,50 @@ void parse_keybinding(char *ptr)
for (i = 0; i < strlen(keycopy); i++)
keycopy[i] = toupper(keycopy[i]);
if (keycopy[0] != 'M' && keycopy[0] != '^' && keycopy[0] != 'F') {
if (keycopy[0] != 'M' && keycopy[0] != '^' && keycopy[0] != 'F' && keycopy[0] != 'K') {
rcfile_error(
N_("keybindings must begin with \"^\", \"M\", or \"F\"\n"));
N_("keybindings must begin with \"^\", \"M\", or \"F\""));
return;
}
funcptr = ptr;
ptr = parse_next_word(ptr);
if (funcptr == NULL) {
if (!strcmp(funcptr, "")) {
rcfile_error(
N_("Must specify function to bind key to\n"));
N_("Must specify function to bind key to"));
return;
}
menuptr = ptr;
ptr = parse_next_word(ptr);
if (menuptr == NULL) {
if (!strcmp(menuptr, "")) {
rcfile_error(
/* Note to translators, do not translate the word "all"
in the sentence below, everything else is fine */
N_("Must specify menu bind key to (or \"all\")\n"));
N_("Must specify menu to bind key to (or \"all\")"));
return;
}
menu = strtomenu(menuptr);
if (menu < 1) {
rcfile_error(
N_("Could not map name \"%s\" to a menu\n"), menuptr);
return;
}
newsc = strtosc(menu, funcptr);
if (newsc == NULL) {
rcfile_error(
N_("Could not map name \"%s\" to a function\n"), funcptr);
N_("Could not map name \"%s\" to a function"), funcptr);
return;
}
if (menu < 1) {
rcfile_error(
N_("Could not map name \"%s\" to a menu"), menuptr);
return;
}
#ifdef DEBUG
fprintf(stderr, "newsc now address %d, menu func assigned = %d, menu = %d\n",
(int) newsc, (int) newsc->scfunc, menu);
&newsc, newsc->scfunc, menu);
#endif
@@ -438,11 +451,10 @@ void parse_keybinding(char *ptr)
if (check_bad_binding(newsc)) {
rcfile_error(
N_("Sorry, keystr \"%s\" is an illegal binding\n"), newsc->keystr);
N_("Sorry, keystr \"%s\" is an illegal binding"), newsc->keystr);
return;
}
/* now let's have some fun. Try and delete the other entries
we found for the same menu, then make this new new
beginning */
@@ -458,13 +470,77 @@ void parse_keybinding(char *ptr)
sclist = newsc;
}
/* Let user unbind a sequence from a given (or all) menus */
void parse_unbinding(char *ptr)
{
char *keyptr = NULL, *keycopy = NULL, *menuptr = NULL;
sc *s;
int i, menu;
assert(ptr != NULL);
if (*ptr == '\0') {
rcfile_error(N_("Missing key name"));
return;
}
keyptr = ptr;
ptr = parse_next_word(ptr);
keycopy = mallocstrcpy(NULL, keyptr);
for (i = 0; i < strlen(keycopy); i++)
keycopy[i] = toupper(keycopy[i]);
#ifdef DEBUG
fprintf(stderr, "Starting unbinding code");
#endif
if (keycopy[0] != 'M' && keycopy[0] != '^' && keycopy[0] != 'F' && keycopy[0] != 'K') {
rcfile_error(
N_("keybindings must begin with \"^\", \"M\", or \"F\""));
return;
}
menuptr = ptr;
ptr = parse_next_word(ptr);
if (!strcmp(menuptr, "")) {
rcfile_error(
/* Note to translators, do not translate the word "all"
in the sentence below, everything else is fine */
N_("Must specify menu to bind key to (or \"all\")"));
return;
}
menu = strtomenu(menuptr);
if (menu < 1) {
rcfile_error(
N_("Could not map name \"%s\" to a menu"), menuptr);
return;
}
#ifdef DEBUG
fprintf(stderr, "unbinding \"%s\" from menu = %d\n", keycopy, menu);
#endif
/* Now find the apropriate entries in the menu to delete */
for (s = sclist; s != NULL; s = s->next) {
if (((s->menu & menu)) && !strcmp(s->keystr,keycopy)) {
s->menu &= ~menu;
#ifdef DEBUG
fprintf(stderr, "deleted menu entry %d\n", s->menu);
#endif
}
}
}
/* Read and parse additional syntax files. */
void parse_include(char *ptr)
{
struct stat rcinfo;
FILE *rcstream;
char *option, *full_option, *nanorc_save = nanorc;
char *option, *nanorc_save = nanorc, *expanded;
size_t lineno_save = lineno;
option = ptr;
@@ -472,37 +548,35 @@ void parse_include(char *ptr)
option++;
ptr = parse_argument(ptr);
/* Get the specified file's full path. */
full_option = get_full_path(option);
if (full_option == NULL)
full_option = mallocstrcpy(NULL, option);
/* Can't get the specified file's full path cause it may screw up
our cwd depending on the parent dirs' permissions, (see Savannah bug 25297) */
/* Don't open directories, character files, or block files. */
if (stat(full_option, &rcinfo) != -1) {
if (stat(option, &rcinfo) != -1) {
if (S_ISDIR(rcinfo.st_mode) || S_ISCHR(rcinfo.st_mode) ||
S_ISBLK(rcinfo.st_mode)) {
rcfile_error(S_ISDIR(rcinfo.st_mode) ?
_("\"%s\" is a directory") :
_("\"%s\" is a device file"), option);
goto cleanup_include;
}
}
expanded = real_dir_from_tilde(option);
/* Open the new syntax file. */
if ((rcstream = fopen(full_option, "rb")) == NULL) {
rcfile_error(_("Error reading %s: %s"), option,
if ((rcstream = fopen(expanded, "rb")) == NULL) {
rcfile_error(_("Error reading %s: %s"), expanded,
strerror(errno));
goto cleanup_include;
return;
}
/* Use the name and line number position of the new syntax file
* while parsing it, so we can know where any errors in it are. */
nanorc = full_option;
nanorc = expanded;
lineno = 0;
#ifdef DEBUG
fprintf(stderr, "Parsing file \"%s\"\n", full_option);
fprintf(stderr, "Parsing file \"%s\" (expanded from \"%s\")\n", expanded, option);
#endif
parse_rcfile(rcstream
@@ -516,8 +590,6 @@ void parse_include(char *ptr)
nanorc = nanorc_save;
lineno = lineno_save;
cleanup_include:
free(full_option);
}
/* Return the short value corresponding to the color named in colorname,
@@ -712,9 +784,76 @@ void parse_colors(char *ptr, bool icase)
/* Save the ending regex string if it's valid. */
newcolor->end_regex = (nregcomp(fgstr, icase ? REG_ICASE :
0)) ? mallocstrcpy(NULL, fgstr) : NULL;
/* Lame way to skip another static counter */
newcolor->id = endsyntax->nmultis;
endsyntax->nmultis++;
}
}
}
/* Parse the headers (1st line) of the file which may influence the regex used. */
void parse_headers(char *ptr)
{
char *regstr;
assert(ptr != NULL);
if (syntaxes == NULL) {
rcfile_error(
N_("Cannot add a header regex without a syntax command"));
return;
}
if (*ptr == '\0') {
rcfile_error(N_("Missing regex string"));
return;
}
/* Now for the fun part. Start adding regexes to individual strings
* in the colorstrings array, woo! */
while (ptr != NULL && *ptr != '\0') {
exttype *newheader;
/* The new color structure. */
if (*ptr != '"') {
rcfile_error(
N_("Regex strings must begin and end with a \" character"));
ptr = parse_next_regex(ptr);
continue;
}
ptr++;
regstr = ptr;
ptr = parse_next_regex(ptr);
if (ptr == NULL)
break;
newheader = (exttype *)nmalloc(sizeof(exttype));
/* Save the regex string if it's valid */
if (nregcomp(regstr, 0)) {
newheader->ext_regex = mallocstrcpy(NULL, regstr);
newheader->ext = NULL;
newheader->next = NULL;
#ifdef DEBUG
fprintf(stderr, "Starting a new header entry: %s\n", newheader->ext_regex);
#endif
if (endheader == NULL) {
endsyntax->headers = newheader;
} else {
endheader->next = newheader;
}
endheader = newheader;
} else
free(newheader);
}
}
#endif /* ENABLE_COLOR */
/* Check whether the user has unmapped every shortcut for a
@@ -724,7 +863,7 @@ static void check_vitals_mapped(void)
subnfunc *f;
int v;
#define VITALS 5
void *vitals[VITALS] = { do_exit, do_exit, (void *) cancel_msg, (void *) cancel_msg, (void *) cancel_msg };
short vitals[VITALS] = { DO_EXIT, DO_EXIT, CANCEL_MSG, CANCEL_MSG, CANCEL_MSG };
int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE };
for (v = 0; v < VITALS; v++) {
@@ -754,7 +893,7 @@ void parse_rcfile(FILE *rcstream
{
char *buf = NULL;
ssize_t len;
size_t n;
size_t n = 0;
while ((len = getline(&buf, &n, rcstream)) > 0) {
char *ptr, *keyword, *option;
@@ -812,12 +951,16 @@ void parse_rcfile(FILE *rcstream
rcfile_error(N_("Syntax \"%s\" has no color commands"),
endsyntax->desc);
parse_syntax(ptr);
} else if (strcasecmp(keyword, "color") == 0)
} else if (strcasecmp(keyword, "header") == 0)
parse_headers(ptr);
else if (strcasecmp(keyword, "color") == 0)
parse_colors(ptr, FALSE);
else if (strcasecmp(keyword, "icolor") == 0)
parse_colors(ptr, TRUE);
else if (strcasecmp(keyword, "bind") == 0)
parse_keybinding(ptr);
else if (strcasecmp(keyword, "unbind") == 0)
parse_unbinding(ptr);
#endif /* ENABLE_COLOR */
else
rcfile_error(N_("Command \"%s\" not understood"), keyword);
@@ -970,6 +1113,9 @@ void parse_rcfile(FILE *rcstream
else
rcfile_error(N_("Cannot unset flag \"%s\""),
rcopts[i].name);
/* Looks like we still need this specific hack for undo */
if (strcasecmp(rcopts[i].name, "undo") == 0)
shortcut_init(0);
break;
}
}
@@ -988,15 +1134,6 @@ void parse_rcfile(FILE *rcstream
lineno = 0;
check_vitals_mapped();
if (errors) {
errors = FALSE;
fprintf(stderr,
_("\nPress Enter to continue starting nano.\n"));
while (getchar() != '\n')
;
}
return;
}
@@ -1044,8 +1181,11 @@ void do_rcfile(void)
if (homedir == NULL)
rcfile_error(N_("I can't find my home directory! Wah!"));
else {
nanorc = charealloc(nanorc, strlen(homedir) + 9);
sprintf(nanorc, "%s/.nanorc", homedir);
#ifndef RCFILE_NAME
#define RCFILE_NAME ".nanorc"
#endif
nanorc = charealloc(nanorc, strlen(homedir) + strlen(RCFILE_NAME) + 2);
sprintf(nanorc, "%s/%s", homedir, RCFILE_NAME);
/* Don't open directories, character files, or block files. */
if (stat(nanorc, &rcinfo) != -1) {
@@ -1074,6 +1214,14 @@ void do_rcfile(void)
free(nanorc);
nanorc = NULL;
if (errors && !ISSET(QUIET)) {
errors = FALSE;
fprintf(stderr,
_("\nPress Enter to continue starting nano.\n"));
while (getchar() != '\n')
;
}
#ifdef ENABLE_COLOR
set_colorpairs();
#endif

View File

@@ -2,8 +2,8 @@
/**************************************************************************
* search.c *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -28,6 +28,7 @@
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <time.h>
static bool search_last_line = FALSE;
/* Have we gone past the last line while searching? */
@@ -137,7 +138,7 @@ int search_init(bool replacing, bool use_answer)
int i = 0;
char *buf;
sc *s;
void *func = NULL;
char func = 0;
bool meta_key = FALSE, func_key = FALSE;
static char *backupstring = NULL;
/* The search string we'll be using. */
@@ -235,31 +236,32 @@ int search_init(bool replacing, bool use_answer)
#endif
;
#ifndef NANO_TINY
} else if (func == (void *) case_sens_msg) {
} else if (func == CASE_SENS_MSG) {
TOGGLE(CASE_SENSITIVE);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (func == (void *) backwards_msg) {
} else if (func == BACKWARDS_MSG) {
TOGGLE(BACKWARDS_SEARCH);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
#endif
#ifdef HAVE_REGEX_H
} else if (func == (void *) regexp_msg) {
} else if (func == REGEXP_MSG) {
TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
#endif
} else if (func == (void *) do_replace ||
func == (void *) no_replace_msg) {
} else if (func == DO_REPLACE ||
func == NO_REPLACE_MSG) {
backupstring = mallocstrcpy(backupstring, answer);
return -2; /* Call the opposite search function. */
} else if (func == (void *) go_to_line_msg) {
} else if (func == DO_GOTOLINECOLUMN_VOID) {
do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE, FALSE,
TRUE);
/* Put answer up on the statusbar and
* fall through. */
return 3;
} else {
return -1;
}
@@ -287,6 +289,8 @@ bool findnextstr(
ssize_t current_y_find = openfile->current_y;
filestruct *fileptr = openfile->current;
const char *rev_start = fileptr->data, *found = NULL;
const subnfunc *f;
time_t lastkbcheck = time(NULL);
/* rev_start might end up 1 character before the start or after the
* end of the line. This won't be a problem because strstrwrapper()
@@ -301,7 +305,17 @@ bool findnextstr(
openfile->current_x + 1;
/* Look for needle in the current line we're searching. */
enable_nodelay();
while (TRUE) {
if (time(NULL) - lastkbcheck > 1) {
lastkbcheck = time(NULL);
f = getfuncfromkey(edit);
if (f && f->scfunc == CANCEL_MSG) {
statusbar(_("Cancelled"));
return FALSE;
}
}
found = strstrwrapper(fileptr->data, needle, rev_start);
/* We've found a potential match. */
@@ -347,6 +361,7 @@ bool findnextstr(
/* We've finished processing the file, so get out. */
if (search_last_line) {
not_found_msg(needle);
disable_nodelay();
return FALSE;
}
@@ -404,9 +419,11 @@ bool findnextstr(
#endif
) {
not_found_msg(needle);
disable_nodelay();
return FALSE;
}
disable_nodelay();
/* We've definitely found something. */
openfile->current = fileptr;
openfile->current_x = current_x_find;
@@ -702,6 +719,9 @@ ssize_t do_replace_loop(
filepart = partition_filestruct(top, top_x, bot, bot_x);
openfile->edittop = openfile->fileage;
openfile->mark_set = FALSE;
#ifdef ENABLE_COLOR
reset_multis(openfile->current, TRUE);
#endif
edit_refresh();
}
#endif
@@ -788,6 +808,9 @@ ssize_t do_replace_loop(
char *copy;
size_t length_change;
#ifndef NANO_TINY
update_undo(REPLACE);
#endif
if (i == 2)
replaceall = TRUE;
@@ -843,6 +866,10 @@ ssize_t do_replace_loop(
free(openfile->current->data);
openfile->current->data = copy;
#ifdef ENABLE_COLOR
reset_multis(openfile->current, TRUE);
#endif
edit_refresh();
if (!replaceall) {
#ifdef ENABLE_COLOR
/* If color syntaxes are available and turned on, we
@@ -1017,7 +1044,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
s = get_shortcut(currmenu, &i, &meta_key, &func_key);
if (s && s->scfunc == (void *) gototext_msg) {
if (s && s->scfunc == GOTOTEXT_MSG) {
/* Keep answer up on the statusbar. */
search_init(TRUE, TRUE);
@@ -1330,7 +1357,7 @@ void update_history(filestruct **h, const char *s)
assert(hage != NULL && hbot != NULL);
/* If this string is already in the history, delete it. */
p = find_history(*hage, *hbot, s, (size_t)-1);
p = find_history(*hage, *hbot, s, strlen(s));
if (p != NULL) {
filestruct *foo, *bar;

View File

@@ -1,9 +1,9 @@
/* $Id$ */
/* $Id$ */
/**************************************************************************
* text.c *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -66,9 +66,11 @@ void do_mark(void)
/* Delete the character under the cursor. */
void do_delete(void)
{
bool do_refresh = FALSE;
/* Do we have to call edit_refresh(), or can we get away with
* just update_line()? */
size_t orig_lenpt = 0;
#ifndef NANO_TINY
update_undo(DEL);
#endif
assert(openfile->current != NULL && openfile->current->data != NULL && openfile->current_x <= strlen(openfile->current->data));
@@ -82,6 +84,9 @@ void do_delete(void)
assert(openfile->current_x < strlen(openfile->current->data));
if (ISSET(SOFTWRAP))
orig_lenpt = strlenpt(openfile->current->data);
/* Let's get dangerous. */
charmove(&openfile->current->data[openfile->current_x],
&openfile->current->data[openfile->current_x +
@@ -104,7 +109,7 @@ void do_delete(void)
/* If we're deleting at the end of a line, we need to call
* edit_refresh(). */
if (openfile->current->data[openfile->current_x] == '\0')
do_refresh = TRUE;
edit_refresh_needed = TRUE;
openfile->current->data = charealloc(openfile->current->data,
openfile->current_x + strlen(foo->data) + 1);
@@ -134,18 +139,13 @@ void do_delete(void)
} else
return;
if (ISSET(SOFTWRAP) && edit_refresh_needed == FALSE)
if (strlenpt(openfile->current->data) / COLS != orig_lenpt / COLS)
edit_refresh_needed = TRUE;
set_modified();
#ifdef ENABLE_COLOR
/* If color syntaxes are available and turned on, we need to call
* edit_refresh(). */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
do_refresh = TRUE;
#endif
if (do_refresh)
edit_refresh();
else
if (edit_refresh_needed == FALSE)
update_line(openfile->current, openfile->current_x);
}
@@ -184,7 +184,7 @@ void do_tab(void)
free(output);
} else {
#endif
do_output("\t", 1, TRUE);
do_output((char *) "\t", 1, TRUE);
#ifndef NANO_TINY
}
#endif
@@ -342,7 +342,7 @@ void do_indent(ssize_t cols)
set_modified();
/* Update the screen. */
edit_refresh();
edit_refresh_needed = TRUE;
}
}
@@ -359,10 +359,330 @@ void do_unindent(void)
{
do_indent(-tabsize);
}
/* undo a cut, or re-do an uncut */
void undo_cut(undo *u)
{
/* If we cut the magicline may was well not crash :/ */
if (!u->cutbuffer)
return;
cutbuffer = copy_filestruct(u->cutbuffer);
/* Compute cutbottom for the uncut using out copy */
for (cutbottom = cutbuffer; cutbottom->next != NULL; cutbottom = cutbottom->next)
;
/* Get to where we need to uncut from */
if (u->mark_set && u->mark_begin_lineno < u->lineno)
do_gotolinecolumn(u->mark_begin_lineno, u->mark_begin_x+1, FALSE, FALSE, FALSE, FALSE);
else
do_gotolinecolumn(u->lineno, u->begin+1, FALSE, FALSE, FALSE, FALSE);
copy_from_filestruct(cutbuffer, cutbottom);
free_filestruct(cutbuffer);
cutbuffer = NULL;
}
/* Re-do a cut, or undo an uncut */
void redo_cut(undo *u) {
int i;
filestruct *t, *c;
/* If we cut the magicline may was well not crash :/ */
if (!u->cutbuffer)
return;
do_gotolinecolumn(u->lineno, u->begin+1, FALSE, FALSE, FALSE, FALSE);
openfile->mark_set = u->mark_set;
if (cutbuffer)
free(cutbuffer);
cutbuffer = NULL;
/* Move ahead the same # lines we had if a marked cut */
if (u->mark_set) {
for (i = 1, t = openfile->fileage; i != u->mark_begin_lineno; i++)
t = t->next;
openfile->mark_begin = t;
} else if (!u->to_end) {
/* Here we have a regular old potentially multi-line ^K cut. We'll
need to trick nano into thinking it's a marked cut to cut more
than one line again */
for (c = u->cutbuffer, t = openfile->current; c->next != NULL && t->next != NULL; ) {
#ifdef DEBUG
fprintf(stderr, "Advancing, lineno = %lu, data = \"%s\"\n", (unsigned long) t->lineno, t->data);
#endif
c = c->next;
t = t->next;
}
openfile->mark_begin = t;
openfile->mark_begin_x = 0;
openfile->mark_set = TRUE;
}
openfile->mark_begin_x = u->mark_begin_x;
do_cut_text(FALSE, u->to_end, TRUE);
openfile->mark_set = FALSE;
openfile->mark_begin = NULL;
openfile->mark_begin_x = 0;
edit_refresh_needed = TRUE;
}
/* Undo the last thing(s) we did */
void do_undo(void)
{
undo *u = openfile->current_undo;
filestruct *f = openfile->current, *t;
int len = 0;
char *undidmsg, *data;
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
if (!u) {
statusbar(_("Nothing in undo buffer!"));
return;
}
if (u->lineno <= f->lineno)
for (; f->prev != NULL && f->lineno != u->lineno; f = f->prev)
;
else
for (; f->next != NULL && f->lineno != u->lineno; f = f->next)
;
if (f->lineno != u->lineno) {
statusbar(_("Internal error: can't match line %d. Please save your work"), u->lineno);
return;
}
#ifdef DEBUG
fprintf(stderr, "data we're about to undo = \"%s\"\n", f->data);
fprintf(stderr, "Undo running for type %d\n", u->type);
#endif
openfile->current_x = u->begin;
switch(u->type) {
case ADD:
undidmsg = _("text add");
len = strlen(f->data) - strlen(u->strdata) + 1;
data = charalloc(len);
strncpy(data, f->data, u->begin);
strcpy(&data[u->begin], &f->data[u->begin + strlen(u->strdata)]);
free(f->data);
f->data = data;
break;
case DEL:
undidmsg = _("text delete");
len = strlen(f->data) + strlen(u->strdata) + 1;
data = charalloc(len);
strncpy(data, f->data, u->begin);
strcpy(&data[u->begin], u->strdata);
strcpy(&data[u->begin + strlen(u->strdata)], &f->data[u->begin]);
free(f->data);
f->data = data;
if (u->xflags == UNDO_DEL_BACKSPACE)
openfile->current_x += strlen(u->strdata);
break;
#ifndef DISABLE_WRAPPING
case SPLIT:
undidmsg = _("line wrap");
f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(u->strdata) + 1);
strcpy(&f->data[strlen(f->data) - 1], u->strdata);
if (u->strdata2 != NULL)
f->next->data = mallocstrcpy(f->next->data, u->strdata2);
else {
filestruct *foo = openfile->current->next;
unlink_node(foo);
delete_node(foo);
}
renumber(f);
break;
#endif /* DISABLE_WRAPPING */
case UNSPLIT:
undidmsg = _("line join");
t = make_new_node(f);
t->data = mallocstrcpy(NULL, u->strdata);
data = mallocstrncpy(NULL, f->data, u->begin);
data[u->begin] = '\0';
free(f->data);
f->data = data;
splice_node(f, t, f->next);
renumber(f);
break;
case CUT:
undidmsg = _("text cut");
undo_cut(u);
break;
case UNCUT:
undidmsg = _("text uncut");
redo_cut(u);
break;
case ENTER:
undidmsg = _("line break");
if (f->next) {
filestruct *foo = f->next;
f->data = (char *) nrealloc(f->data, strlen(f->data) + strlen(f->next->data) + 1);
strcat(f->data, f->next->data);
unlink_node(foo);
delete_node(foo);
}
break;
case INSERT:
undidmsg = _("text insert");
cutbuffer = NULL;
cutbottom = NULL;
/* When we updated mark_begin_lineno in update_undo, it was effectively how many line
were inserted due to being partitioned before read_file was called. So we
add its value here */
openfile->mark_begin = fsfromline(u->lineno + u->mark_begin_lineno - 1);
openfile->mark_begin_x = 0;
openfile->mark_set = TRUE;
do_gotolinecolumn(u->lineno, u->begin+1, FALSE, FALSE, FALSE, FALSE);
cut_marked();
u->cutbuffer = cutbuffer;
u->cutbottom = cutbottom;
cutbuffer = oldcutbuffer;
cutbottom = oldcutbottom;
openfile->mark_set = FALSE;
break;
case REPLACE:
undidmsg = _("text replace");
data = u->strdata;
u->strdata = f->data;
f->data = data;
break;
default:
undidmsg = _("Internal error: unknown type. Please save your work");
break;
}
renumber(f);
do_gotolinecolumn(u->lineno, u->begin, FALSE, FALSE, FALSE, TRUE);
statusbar(_("Undid action (%s)"), undidmsg);
openfile->current_undo = openfile->current_undo->next;
openfile->last_action = OTHER;
}
void do_redo(void)
{
undo *u = openfile->undotop;
filestruct *f = openfile->current;
int len = 0;
char *undidmsg, *data;
for (; u != NULL && u->next != openfile->current_undo; u = u->next)
;
if (!u) {
statusbar(_("Nothing to re-do!"));
return;
}
if (u->next != openfile->current_undo) {
statusbar(_("Internal error: Redo setup failed. Please save your work"));
return;
}
if (u->lineno <= f->lineno)
for (; f->prev != NULL && f->lineno != u->lineno; f = f->prev)
;
else
for (; f->next != NULL && f->lineno != u->lineno; f = f->next)
;
if (f->lineno != u->lineno) {
statusbar(_("Internal error: can't match line %d. Please save your work"), u->lineno);
return;
}
#ifdef DEBUG
fprintf(stderr, "data we're about to redo = \"%s\"\n", f->data);
fprintf(stderr, "Redo running for type %d\n", u->type);
#endif
switch(u->type) {
case ADD:
undidmsg = _("text add");
len = strlen(f->data) + strlen(u->strdata) + 1;
data = charalloc(len);
strncpy(data, f->data, u->begin);
strcpy(&data[u->begin], u->strdata);
strcpy(&data[u->begin + strlen(u->strdata)], &f->data[u->begin]);
free(f->data);
f->data = data;
break;
case DEL:
undidmsg = _("text delete");
len = strlen(f->data) + strlen(u->strdata) + 1;
data = charalloc(len);
strncpy(data, f->data, u->begin);
strcpy(&data[u->begin], &f->data[u->begin + strlen(u->strdata)]);
free(f->data);
f->data = data;
break;
case ENTER:
undidmsg = _("line break");
do_gotolinecolumn(u->lineno, u->begin+1, FALSE, FALSE, FALSE, FALSE);
do_enter(TRUE);
break;
#ifndef DISABLE_WRAPPING
case SPLIT:
undidmsg = _("line wrap");
if (u->xflags & UNDO_SPLIT_MADENEW)
prepend_wrap = TRUE;
do_wrap(f, TRUE);
renumber(f);
break;
#endif /* DISABLE_WRAPPING */
case UNSPLIT:
undidmsg = _("line join");
len = strlen(f->data) + strlen(u->strdata + 1);
data = charalloc(len);
strcpy(data, f->data);
strcat(data, u->strdata);
free(f->data);
f->data = data;
if (f->next != NULL) {
filestruct *tmp = f->next;
unlink_node(tmp);
delete_node(tmp);
}
renumber(f);
break;
case CUT:
undidmsg = _("text cut");
redo_cut(u);
break;
case UNCUT:
undidmsg = _("text uncut");
undo_cut(u);
break;
case REPLACE:
undidmsg = _("text replace");
data = u->strdata;
u->strdata = f->data;
f->data = data;
break;
case INSERT:
undidmsg = _("text insert");
do_gotolinecolumn(u->lineno, u->begin+1, FALSE, FALSE, FALSE, FALSE);
copy_from_filestruct(u->cutbuffer, u->cutbottom);
openfile->placewewant = xplustabs();
break;
default:
undidmsg = _("Internal error: unknown type. Please save your work");
break;
}
do_gotolinecolumn(u->lineno, u->begin, FALSE, FALSE, FALSE, TRUE);
statusbar(_("Redid action (%s)"), undidmsg);
openfile->current_undo = u;
openfile->last_action = OTHER;
}
#endif /* !NANO_TINY */
/* Someone hits Enter *gasp!* */
void do_enter(void)
void do_enter(bool undoing)
{
filestruct *newnode = make_new_node(openfile->current);
size_t extra = 0;
@@ -370,6 +690,10 @@ void do_enter(void)
assert(openfile->current != NULL && openfile->current->data != NULL);
#ifndef NANO_TINY
if (!undoing)
add_undo(ENTER);
/* Do auto-indenting, like the neolithic Turbo Pascal editor. */
if (ISSET(AUTOINDENT)) {
/* If we are breaking the line in the indentation, the new
@@ -414,7 +738,7 @@ void do_enter(void)
openfile->placewewant = xplustabs();
edit_refresh();
edit_refresh_needed = TRUE;
}
#ifndef NANO_TINY
@@ -448,7 +772,7 @@ bool execute_command(const char *command)
* arguments. */
shellenv = getenv("SHELL");
if (shellenv == NULL)
shellenv = "/bin/sh";
shellenv = (char *) "/bin/sh";
/* Fork a child. */
if ((pid = fork()) == 0) {
@@ -495,7 +819,7 @@ bool execute_command(const char *command)
if (f == NULL)
nperror("fdopen");
read_file(f, "stdin");
read_file(f, 0, "stdin", TRUE, FALSE);
if (wait(NULL) == -1)
nperror("wait");
@@ -510,6 +834,265 @@ bool execute_command(const char *command)
return TRUE;
}
/* Add a new undo struct to the top of the current pile */
void add_undo(undo_type current_action)
{
undo *u;
char *data;
openfilestruct *fs = openfile;
static undo *last_cutu = NULL; /* Last thing we cut to set up the undo for uncut */
ssize_t wrap_loc; /* For calculating split beginning */
if (!ISSET(UNDOABLE))
return;
/* Ugh, if we were called while cutting not-to-end, non-marked and on the same lineno,
we need to abort here */
u = fs->current_undo;
if (current_action == CUT && u && u->type == CUT
&& !u->mark_set && u->lineno == fs->current->lineno)
return;
/* Blow away the old undo stack if we are starting from the middle */
while (fs->undotop != NULL && fs->undotop != fs->current_undo) {
undo *u2 = fs->undotop;
fs->undotop = fs->undotop->next;
if (u2->strdata != NULL)
free(u2->strdata);
if (u2->cutbuffer)
free_filestruct(u2->cutbuffer);
free(u2);
}
/* Allocate and initialize a new undo type */
u = (undo *) nmalloc(sizeof(undo));
u->type = current_action;
u->lineno = fs->current->lineno;
u->begin = fs->current_x;
u->next = fs->undotop;
fs->undotop = u;
fs->current_undo = u;
u->strdata = NULL;
u->strdata2 = NULL;
u->cutbuffer = NULL;
u->cutbottom = NULL;
u->mark_set = 0;
u->mark_begin_lineno = 0;
u->mark_begin_x = 0;
u->xflags = 0;
u->to_end = FALSE;
switch (u->type) {
/* We need to start copying data into the undo buffer or we wont be able
to restore it later */
case ADD:
data = charalloc(2);
data[0] = fs->current->data[fs->current_x];
data[1] = '\0';
u->strdata = data;
break;
case DEL:
if (u->begin != strlen(fs->current->data)) {
data = mallocstrncpy(NULL, &fs->current->data[u->begin], 2);
data[1] = '\0';
u->strdata = data;
break;
}
/* Else purposely fall into unsplit code */
current_action = u->type = UNSPLIT;
case UNSPLIT:
if (fs->current->next) {
data = mallocstrcpy(NULL, fs->current->next->data);
u->strdata = data;
}
break;
#ifndef DISABLE_WRAPPING
case SPLIT:
wrap_loc = break_line(openfile->current->data, fill
#ifndef DISABLE_HELP
, FALSE
#endif
);
u->strdata = mallocstrcpy(NULL, &openfile->current->data[wrap_loc]);
/* Don't both saving the next line if we're not prepending as a new line
will be created */
if (prepend_wrap)
u->strdata2 = mallocstrcpy(NULL, fs->current->next->data);
u->begin = wrap_loc;
break;
#endif /* DISABLE_WRAPPING */
case INSERT:
case REPLACE:
data = mallocstrcpy(NULL, fs->current->data);
u->strdata = data;
break;
case CUT:
u->mark_set = openfile->mark_set;
if (u->mark_set) {
u->mark_begin_lineno = openfile->mark_begin->lineno;
u->mark_begin_x = openfile->mark_begin_x;
}
u->to_end = (ISSET(CUT_TO_END)) ? TRUE : FALSE;
last_cutu = u;
break;
case UNCUT:
if (!last_cutu)
statusbar(_("Internal error: can't setup uncut. Please save your work."));
else if (last_cutu->type == CUT) {
u->cutbuffer = last_cutu->cutbuffer;
u->cutbottom = last_cutu->cutbottom;
}
break;
case ENTER:
break;
case OTHER:
statusbar(_("Internal error: unknown type. Please save your work."));
break;
}
#ifdef DEBUG
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d, type = %d\n",
fs->current->data, (unsigned long) fs->current_x, u->begin, current_action);
fprintf(stderr, "left add_undo...\n");
#endif
fs->last_action = current_action;
}
/* Update an undo item, or determine whether a new one
is really needed and bounce the data to add_undo
instead. The latter functionality just feels
gimmicky and may just be more hassle than
it's worth, so it should be axed if needed. */
void update_undo(undo_type action)
{
undo *u;
char *data;
int len = 0;
openfilestruct *fs = openfile;
if (!ISSET(UNDOABLE))
return;
#ifdef DEBUG
fprintf(stderr, "action = %d, fs->last_action = %d, openfile->current->lineno = %lu",
action, fs->last_action, (unsigned long) openfile->current->lineno);
if (fs->current_undo)
fprintf(stderr, "fs->current_undo->lineno = %lu\n", (unsigned long) fs->current_undo->lineno);
else
fprintf(stderr, "\n");
#endif
/* Change to an add if we're not using the same undo struct
that we should be using */
if (action != fs->last_action
|| (action != CUT && action != INSERT && action != SPLIT
&& openfile->current->lineno != fs->current_undo->lineno)) {
add_undo(action);
return;
}
assert(fs->undotop != NULL);
u = fs->undotop;
switch (u->type) {
case ADD:
#ifdef DEBUG
fprintf(stderr, "fs->current->data = \"%s\", current_x = %lu, u->begin = %d\n",
fs->current->data, (unsigned long) fs->current_x, u->begin);
#endif
len = strlen(u->strdata) + 2;
data = (char *) nrealloc((void *) u->strdata, len * sizeof(char *));
data[len-2] = fs->current->data[fs->current_x];
data[len-1] = '\0';
u->strdata = (char *) data;
#ifdef DEBUG
fprintf(stderr, "current undo data now \"%s\"\n", u->strdata);
#endif
break;
case DEL:
len = strlen(u->strdata) + 2;
assert(len > 2);
if (fs->current_x == u->begin) {
/* They're deleting */
if (!u->xflags)
u->xflags = UNDO_DEL_DEL;
else if (u->xflags != UNDO_DEL_DEL) {
add_undo(action);
return;
}
data = charalloc(len);
strcpy(data, u->strdata);
data[len-2] = fs->current->data[fs->current_x];;
data[len-1] = '\0';
free(u->strdata);
u->strdata = data;
} else if (fs->current_x == u->begin - 1) {
/* They're backspacing */
if (!u->xflags)
u->xflags = UNDO_DEL_BACKSPACE;
else if (u->xflags != UNDO_DEL_BACKSPACE) {
add_undo(action);
return;
}
data = charalloc(len);
data[0] = fs->current->data[fs->current_x];
strcpy(&data[1], u->strdata);
free(u->strdata);
u->strdata = data;
u->begin--;
} else {
/* They deleted something else on the line */
add_undo(DEL);
return;
}
#ifdef DEBUG
fprintf(stderr, "current undo data now \"%s\"\nu->begin = %d\n", u->strdata, u->begin);
#endif
break;
case CUT:
if (!cutbuffer)
break;
if (u->cutbuffer)
free(u->cutbuffer);
u->cutbuffer = copy_filestruct(cutbuffer);
/* Compute cutbottom for the uncut using out copy */
for (u->cutbottom = u->cutbuffer; u->cutbottom->next != NULL; u->cutbottom = u->cutbottom->next)
;
break;
case REPLACE:
case UNCUT:
add_undo(action);
break;
case INSERT:
u->mark_begin_lineno = openfile->current->lineno;
break;
#ifndef DISABLE_WRAPPING
case SPLIT:
/* This will only be called if we made a completely new line,
and as such we should note that so we can destroy it later */
u->xflags = UNDO_SPLIT_MADENEW;
break;
#endif /* DISABLE_WRAPPING */
case UNSPLIT:
/* These cases are handled by the earlier check for a new line and action */
case ENTER:
case OTHER:
break;
}
#ifdef DEBUG
fprintf(stderr, "Done in udpate_undo (type was %d)\n", action);
#endif
if (fs->last_action != action) {
#ifdef DEBUG
fprintf(stderr, "Starting add_undo for new action as it does not match last_action\n");
#endif
add_undo(action);
}
fs->last_action = action;
}
#endif /* !NANO_TINY */
#ifndef DISABLE_WRAPPING
@@ -523,7 +1106,7 @@ void wrap_reset(void)
/* We wrap the given line. Precondition: we assume the cursor has been
* moved forward since the last typed character. Return TRUE if we
* wrapped, and FALSE otherwise. */
bool do_wrap(filestruct *line)
bool do_wrap(filestruct *line, bool undoing)
{
size_t line_len;
/* The length of the line we wrap. */
@@ -588,6 +1171,9 @@ bool do_wrap(filestruct *line)
return FALSE;
#ifndef NANO_TINY
if (!undoing)
add_undo(SPLIT);
/* If autoindent is turned on, and we're on the character just after
* the indentation, we don't wrap. */
if (ISSET(AUTOINDENT)) {
@@ -682,6 +1268,8 @@ bool do_wrap(filestruct *line)
null_at(&line->data, wrap_loc);
if (prepending) {
if (!undoing)
update_undo(SPLIT);
/* If we're prepending, copy the text from the next line, minus
* the indentation that we already copied above. */
strcat(new_line, next_line);
@@ -800,6 +1388,15 @@ ssize_t break_line(const char *line, ssize_t goal
/* In fact, the whole line displays shorter than goal. */
return cur_loc;
#ifndef DISABLE_HELP
if (newln && blank_loc <= 0) {
/* If blank was not found or was found only first character,
* force line break. */
cur_loc -= line_len;
return cur_loc;
}
#endif
if (blank_loc == -1) {
/* No blank was found that was short enough. */
bool found_blank = FALSE;
@@ -1420,7 +2017,7 @@ void do_justify(bool full_justify)
last_par_line = openfile->filebot;
break;
} else {
edit_refresh();
edit_refresh_needed = TRUE;
return;
}
}
@@ -1684,7 +2281,7 @@ void do_justify(bool full_justify)
&finished, FALSE);
s = get_shortcut(currmenu, &kbinput, &meta_key, &func_key);
if (s && s->scfunc == do_uncut_text) {
if (s && s->scfunc == DO_UNCUT_TEXT) {
/* Splice the justify buffer back into the file, but only if we
* actually justified something. */
if (first_par_line != NULL) {
@@ -1732,7 +2329,7 @@ void do_justify(bool full_justify)
if (!openfile->modified)
titlebar(NULL);
edit_refresh();
edit_refresh_needed = TRUE;
}
} else {
unget_kbinput(kbinput, meta_key, func_key);
@@ -2085,7 +2682,7 @@ const char *do_int_speller(const char *tempfile_name)
free(read_buff);
search_replace_abort();
edit_refresh();
edit_refresh_needed = TRUE;
/* Process the end of the spell process. */
waitpid(pid_spell, &spell_status, 0);
@@ -2155,6 +2752,11 @@ const char *do_alt_speller(char *tempfile_name)
}
#endif
if (openfile->totsize == 0) {
statusbar(_("Finished checking spelling"));
return NULL;
}
endwin();
/* Set up an argument list to pass execvp(). */
@@ -2464,3 +3066,4 @@ void do_verbatim_input(void)
free(output);
}

View File

@@ -2,8 +2,8 @@
/**************************************************************************
* utils.c *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -183,14 +183,7 @@ void sunder(char *str)
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301, USA. */
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
#ifndef HAVE_GETLINE
/* This function is equivalent to getline(). */
ssize_t ngetline(char **lineptr, size_t *n, FILE *stream)
{
return getdelim(lineptr, n, '\n', stream);
}
#endif
#ifdef ENABLE_NANORC
#ifndef HAVE_GETDELIM
/* This function is equivalent to getdelim(). */
@@ -242,7 +235,15 @@ ssize_t ngetdelim(char **lineptr, size_t *n, int delim, FILE *stream)
return (c == EOF && (indx - 1) == 0) ? -1 : indx - 1;
}
#endif
#endif /* !NANO_TINY && ENABLE_NANORC */
#ifndef HAVE_GETLINE
/* This function is equivalent to getline(). */
ssize_t ngetline(char **lineptr, size_t *n, FILE *stream)
{
return getdelim(lineptr, n, '\n', stream);
}
#endif
#endif /* ENABLE_NANORC */
#ifdef HAVE_REGEX_H
/* Do the compiled regex in preg and the regex in string match the
@@ -253,6 +254,42 @@ bool regexp_bol_or_eol(const regex_t *preg, const char *string)
regexec(preg, string, 0, NULL, REG_NOTBOL | REG_NOTEOL) ==
REG_NOMATCH);
}
/* Fix the regex if we're on platforms which requires an adjustment
* from GNU-style to BSD-style word boundaries. */
const char *fixbounds(const char *r) {
#ifndef GNU_WORDBOUNDS
int i, j = 0;
char *r2 = charalloc(strlen(r) * 5);
char *r3;
#ifdef DEBUG
fprintf(stderr, "fixbounds(): Start string = \"%s\"\n", r);
#endif
for (i = 0; i < strlen(r); i++) {
if (r[i] != '\0' && r[i] == '\\' && (r[i+1] == '>' || r[i+1] == '<')) {
strcpy(&r2[j], "[[:");
r2[j+3] = r[i+1];
strcpy(&r2[j+4], ":]]");
i++;
j += 6;
} else
r2[j] = r[i];
j++;
}
r2[j] = '\0';
r3 = mallocstrcpy(NULL, r2);
free(r2);
#ifdef DEBUG
fprintf(stderr, "fixbounds(): Ending string = \"%s\"\n", r3);
#endif
return (const char *) r3;
#endif
return r;
}
#endif
#ifndef DISABLE_SPELLER
@@ -505,6 +542,9 @@ void new_magicline(void)
openfile->filebot->next->prev = openfile->filebot;
openfile->filebot->next->next = NULL;
openfile->filebot->next->lineno = openfile->filebot->lineno + 1;
#ifdef ENABLE_COLOR
openfile->filebot->next->multidata = NULL;
#endif
openfile->filebot = openfile->filebot->next;
openfile->totsize++;
}
@@ -586,6 +626,23 @@ size_t get_totsize(const filestruct *begin, const filestruct *end)
return totsize;
}
/* Get back a pointer given a line number in the current openfilestruct */
filestruct *fsfromline(ssize_t lineno)
{
filestruct *f = openfile->current;
if (lineno <= openfile->current->lineno)
for (; f->lineno != lineno && f != openfile->fileage; f = f->prev)
;
else
for (; f->lineno != lineno && f->next != NULL; f = f->next)
;
if (f->lineno != lineno)
f = NULL;
return f;
}
#ifdef DEBUG
/* Dump the filestruct inptr to stderr. */
void dump_filestruct(const filestruct *inptr)

View File

@@ -1,10 +1,9 @@
/* $Id$ */
/**************************************************************************
* winio.c *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 *
* Free Software Foundation, Inc. *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009 Free Software Foundation, Inc. *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) *
@@ -123,17 +122,21 @@ void get_key_buffer(WINDOW *win)
doupdate();
errcount = 0;
while ((input = wgetch(win)) == ERR) {
errcount++;
if (nodelay_mode) {
if ((input = wgetch(win)) == ERR)
return;
} else
while ((input = wgetch(win)) == ERR) {
errcount++;
/* If we've failed to get a character MAX_BUF_SIZE times in a
* row, assume that the input source we were using is gone and
* die gracefully. We could check if errno is set to EIO
* ("Input/output error") and die gracefully in that case, but
* it's not always set properly. Argh. */
if (errcount == MAX_BUF_SIZE)
handle_hupterm(0);
}
/* If we've failed to get a character MAX_BUF_SIZE times in a
* row, assume that the input source we were using is gone and
* die gracefully. We could check if errno is set to EIO
* ("Input/output error") and die gracefully in that case, but
* it's not always set properly. Argh. */
if (errcount == MAX_BUF_SIZE)
handle_hupterm(0);
}
#ifndef NANO_TINY
allow_pending_sigwinch(FALSE);
@@ -331,7 +334,12 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
*func_key = FALSE;
/* Read in a character. */
while ((kbinput = get_input(win, 1)) == NULL);
if (nodelay_mode) {
kbinput = get_input(win, 1);
if (kbinput == 0)
return 0;
} else
while ((kbinput = get_input(win, 1)) == NULL);
switch (*kbinput) {
case ERR:
@@ -489,36 +497,36 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
if (retval != ERR) {
switch (retval) {
case NANO_CONTROL_8:
retval = ISSET(REBIND_DELETE) ? sc_seq_or(do_delete, 0) :
sc_seq_or(do_backspace, 0);
retval = ISSET(REBIND_DELETE) ? sc_seq_or(DO_DELETE, 0) :
sc_seq_or(DO_BACKSPACE, 0);
break;
case KEY_DOWN:
#ifdef KEY_SDOWN
/* ncurses and Slang don't support KEY_SDOWN. */
case KEY_SDOWN:
#endif
retval = sc_seq_or((void *) do_down_void, *kbinput);
retval = sc_seq_or(DO_DOWN_VOID, *kbinput);
break;
case KEY_UP:
#ifdef KEY_SUP
/* ncurses and Slang don't support KEY_SUP. */
case KEY_SUP:
#endif
retval = sc_seq_or((void *) do_up_void, *kbinput);
retval = sc_seq_or(DO_UP_VOID, *kbinput);
break;
case KEY_LEFT:
#ifdef KEY_SLEFT
/* Slang doesn't support KEY_SLEFT. */
case KEY_SLEFT:
#endif
retval = sc_seq_or((void *) do_left, *kbinput);
retval = sc_seq_or(DO_LEFT, *kbinput);
break;
case KEY_RIGHT:
#ifdef KEY_SRIGHT
/* Slang doesn't support KEY_SRIGHT. */
case KEY_SRIGHT:
#endif
retval = sc_seq_or((void *) do_right, *kbinput);
retval = sc_seq_or(DO_RIGHT, *kbinput);
break;
#ifdef KEY_SHOME
/* HP-UX 10-11 and Slang don't support KEY_SHOME. */
@@ -526,36 +534,36 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
#endif
case KEY_A1: /* Home (7) on numeric keypad with
* NumLock off. */
retval = sc_seq_or((void *) do_home, *kbinput);
retval = sc_seq_or(DO_HOME, *kbinput);
break;
case KEY_BACKSPACE:
retval = sc_seq_or((void *) do_backspace, *kbinput);
retval = sc_seq_or(DO_BACKSPACE, *kbinput);
break;
#ifdef KEY_SDC
/* Slang doesn't support KEY_SDC. */
case KEY_SDC:
if (ISSET(REBIND_DELETE))
retval = sc_seq_or((void *) do_delete, *kbinput);
retval = sc_seq_or(DO_DELETE, *kbinput);
else
retval = sc_seq_or((void *) do_backspace, *kbinput);
retval = sc_seq_or(DO_BACKSPACE, *kbinput);
break;
#endif
#ifdef KEY_SIC
/* Slang doesn't support KEY_SIC. */
case KEY_SIC:
retval = sc_seq_or((void *) do_insertfile_void, *kbinput);
retval = sc_seq_or(DO_INSERTFILE_VOID, *kbinput);
break;
#endif
case KEY_C3: /* PageDown (4) on numeric keypad with
* NumLock off. */
retval = sc_seq_or((void *) do_page_down, *kbinput);
retval = sc_seq_or(DO_PAGE_DOWN, *kbinput);
break;
case KEY_A3: /* PageUp (9) on numeric keypad with
* NumLock off. */
retval = sc_seq_or((void *) do_page_up, *kbinput);
retval = sc_seq_or(DO_PAGE_UP, *kbinput);
break;
case KEY_ENTER:
retval = sc_seq_or((void *) do_enter, *kbinput);
retval = sc_seq_or(DO_ENTER, *kbinput);
break;
case KEY_B2: /* Center (5) on numeric keypad with
* NumLock off. */
@@ -567,7 +575,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
/* HP-UX 10-11 and Slang don't support KEY_SEND. */
case KEY_SEND:
#endif
retval = sc_seq_or((void *) do_end, *kbinput);
retval = sc_seq_or(DO_END, *kbinput);
break;
#ifdef KEY_BEG
/* Slang doesn't support KEY_BEG. */
@@ -583,7 +591,7 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
/* Slang doesn't support KEY_SCANCEL. */
case KEY_SCANCEL:
#endif
retval = first_sc_for(currmenu, (void *) cancel_msg)->seq;
retval = first_sc_for(currmenu, CANCEL_MSG)->seq;
break;
#endif
#ifdef KEY_SBEG
@@ -596,13 +604,13 @@ int parse_kbinput(WINDOW *win, bool *meta_key, bool *func_key)
#ifdef KEY_SSUSPEND
/* Slang doesn't support KEY_SSUSPEND. */
case KEY_SSUSPEND:
retval = sc_seq_or(do_suspend_void, 0);
retval = sc_seq_or(DO_SUSPEND_VOID, 0);
break;
#endif
#ifdef KEY_SUSPEND
/* Slang doesn't support KEY_SUSPEND. */
case KEY_SUSPEND:
retval = sc_seq_or(do_suspend_void, 0);
retval = sc_seq_or(DO_SUSPEND_VOID, 0);
break;
#endif
#ifdef PDCURSES
@@ -750,15 +758,15 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
retval = KEY_B2;
break;
case 'F': /* Esc O F == End on xterm/Terminal. */
retval = sc_seq_or(do_end, 0);
retval = sc_seq_or(DO_END, 0);
break;
case 'H': /* Esc O H == Home on xterm/Terminal. */
retval = sc_seq_or(do_home, 0);;
retval = sc_seq_or(DO_HOME, 0);;
break;
case 'M': /* Esc O M == Enter on numeric keypad with
* NumLock off on VT100/VT220/VT320/xterm/
* rxvt/Eterm. */
retval = sc_seq_or(do_home, 0);;
retval = sc_seq_or(DO_HOME, 0);;
break;
case 'P': /* Esc O P == F1 on VT100/VT220/VT320/Mach
* console. */
@@ -823,7 +831,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
case 'n': /* Esc O n == Delete (.) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
* xterm/rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_delete, 0);;
retval = sc_seq_or(DO_DELETE, 0);;
break;
case 'o': /* Esc O o == '/' on numeric keypad with
* NumLock off on VT100/VT220/VT320/xterm/
@@ -833,27 +841,27 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
case 'p': /* Esc O p == Insert (0) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
* rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_insertfile_void, 0);;
retval = sc_seq_or(DO_INSERTFILE_VOID, 0);;
break;
case 'q': /* Esc O q == End (1) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
* rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_end, 0);;
retval = sc_seq_or(DO_END, 0);;
break;
case 'r': /* Esc O r == Down (2) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
* rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_down_void, 0);;
retval = sc_seq_or(DO_DOWN_VOID, 0);;
break;
case 's': /* Esc O s == PageDown (3) on numeric
* keypad with NumLock off on VT100/VT220/
* VT320/rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_page_down, 0);;
retval = sc_seq_or(DO_PAGE_DOWN, 0);;
break;
case 't': /* Esc O t == Left (4) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
* rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_left, 0);;
retval = sc_seq_or(DO_LEFT, 0);;
break;
case 'u': /* Esc O u == Center (5) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
@@ -863,22 +871,22 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
case 'v': /* Esc O v == Right (6) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
* rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_right, 0);
retval = sc_seq_or(DO_RIGHT, 0);
break;
case 'w': /* Esc O w == Home (7) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
* rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_home, 0);;
retval = sc_seq_or(DO_HOME, 0);
break;
case 'x': /* Esc O x == Up (8) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
* rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_up_void, 0);;
retval = sc_seq_or(DO_UP_VOID, 0);
break;
case 'y': /* Esc O y == PageUp (9) on numeric keypad
* with NumLock off on VT100/VT220/VT320/
* rxvt/Eterm/Terminal. */
retval = sc_seq_or(do_up, 0);;
retval = sc_seq_or(DO_PAGE_UP, 0);
break;
}
break;
@@ -972,7 +980,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
break;
default: /* Esc [ 1 ~ == Home on
* VT320/Linux console. */
retval = sc_seq_or(do_home, 0);;
retval = sc_seq_or(DO_HOME, 0);;
break;
}
}
@@ -1023,40 +1031,40 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
default: /* Esc [ 2 ~ == Insert on
* VT220/VT320/Linux console/
* xterm/Terminal. */
retval = sc_seq_or(do_insertfile_void, 0);;
retval = sc_seq_or(DO_INSERTFILE_VOID, 0);;
break;
}
}
break;
case '3': /* Esc [ 3 ~ == Delete on VT220/VT320/
* Linux console/xterm/Terminal. */
retval = sc_seq_or(do_delete, 0);;
retval = sc_seq_or(DO_DELETE, 0);;
break;
case '4': /* Esc [ 4 ~ == End on VT220/VT320/Linux
* console/xterm. */
retval = sc_seq_or(do_end, 0);;
retval = sc_seq_or(DO_END, 0);;
break;
case '5': /* Esc [ 5 ~ == PageUp on VT220/VT320/
* Linux console/xterm/Terminal;
* Esc [ 5 ^ == PageUp on Eterm. */
retval = sc_seq_or(do_page_up, 0);;
retval = sc_seq_or(DO_PAGE_UP, 0);;
break;
case '6': /* Esc [ 6 ~ == PageDown on VT220/VT320/
* Linux console/xterm/Terminal;
* Esc [ 6 ^ == PageDown on Eterm. */
retval = sc_seq_or(do_page_down, 0);;
retval = sc_seq_or(DO_PAGE_DOWN, 0);;
break;
case '7': /* Esc [ 7 ~ == Home on rxvt. */
retval = sc_seq_or(do_home, 0);
retval = sc_seq_or(DO_HOME, 0);
break;
case '8': /* Esc [ 8 ~ == End on rxvt. */
retval = sc_seq_or(do_end, 0);
retval = sc_seq_or(DO_END, 0);
break;
case '9': /* Esc [ 9 == Delete on Mach console. */
retval = sc_seq_or(do_delete, 0);;
retval = sc_seq_or(DO_DELETE, 0);;
break;
case '@': /* Esc [ @ == Insert on Mach console. */
retval = sc_seq_or(do_insertfile_void, 0);;
retval = sc_seq_or(DO_INSERTFILE_VOID, 0);;
break;
case 'A': /* Esc [ A == Up on ANSI/VT220/Linux
* console/FreeBSD console/Mach console/
@@ -1079,23 +1087,23 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
break;
case 'F': /* Esc [ F == End on FreeBSD
* console/Eterm. */
retval = sc_seq_or(do_end, 0);
retval = sc_seq_or(DO_END, 0);
break;
case 'G': /* Esc [ G == PageDown on FreeBSD
* console. */
retval = sc_seq_or(do_page_down, 0);
retval = sc_seq_or(DO_PAGE_DOWN, 0);
break;
case 'H': /* Esc [ H == Home on ANSI/VT220/FreeBSD
* console/Mach console/Eterm. */
retval = sc_seq_or(do_home, 0);
retval = sc_seq_or(DO_HOME, 0);
break;
case 'I': /* Esc [ I == PageUp on FreeBSD
* console. */
retval = sc_seq_or(do_page_up, 0);
retval = sc_seq_or(DO_PAGE_UP, 0);
break;
case 'L': /* Esc [ L == Insert on ANSI/FreeBSD
* console. */
retval = sc_seq_or(do_insertfile_void, 0);
retval = sc_seq_or(DO_INSERTFILE_VOID, 0);
break;
case 'M': /* Esc [ M == F1 on FreeBSD console. */
retval = KEY_F(1);
@@ -1143,10 +1151,10 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
retval = KEY_F(8);
break;
case 'U': /* Esc [ U == PageDown on Mach console. */
retval = sc_seq_or(do_page_down, 0);
retval = sc_seq_or(DO_PAGE_DOWN, 0);
break;
case 'V': /* Esc [ V == PageUp on Mach console. */
retval = sc_seq_or(do_page_up, 0);
retval = sc_seq_or(DO_PAGE_UP, 0);
break;
case 'W': /* Esc [ W == F11 on FreeBSD console. */
retval = KEY_F(11);
@@ -1155,7 +1163,7 @@ int get_escape_seq_kbinput(const int *seq, size_t seq_len)
retval = KEY_F(12);
break;
case 'Y': /* Esc [ Y == End on Mach console. */
retval = sc_seq_or(do_end, 0);
retval = sc_seq_or(DO_END, 0);
break;
case 'Z': /* Esc [ Z == F14 on FreeBSD console. */
retval = KEY_F(14);
@@ -1212,13 +1220,13 @@ int get_escape_seq_abcd(int kbinput)
{
switch (tolower(kbinput)) {
case 'a':
return sc_seq_or(do_up_void, 0);;
return sc_seq_or(DO_UP_VOID, 0);;
case 'b':
return sc_seq_or(do_down_void, 0);;
return sc_seq_or(DO_DOWN_VOID, 0);;
case 'c':
return sc_seq_or(do_right, 0);;
return sc_seq_or(DO_RIGHT, 0);;
case 'd':
return sc_seq_or(do_left, 0);;
return sc_seq_or(DO_LEFT, 0);;
default:
return ERR;
}
@@ -1697,14 +1705,19 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
for (; j > 0; j--) {
if (f->next != NULL)
f = f->next;
while (f->next != NULL && ((f->menus & currmenu) == 0 || strlen(f->help) == 0))
while (f->next != NULL && ((f->menus & currmenu) == 0
#ifndef DISABLE_HELP
|| strlen(f->help) == 0
#endif
))
f = f->next;
}
/* And put back the equivalent key. */
if (f != NULL) {
const sc *s = first_sc_for(currmenu, (void *) f->scfunc);
const sc *s = first_sc_for(currmenu, f->scfunc);
if (s != NULL)
unget_kbinput(s->seq, s->type == META, FALSE);
}
@@ -1733,7 +1746,7 @@ int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts)
* wheel is equivalent to moving down three lines. */
for (i = 0; i < 3; i++)
unget_kbinput((mevent.bstate & BUTTON4_PRESSED) ?
sc_seq_or(do_up_void, 0) : sc_seq_or(do_down_void, 0);, FALSE,
sc_seq_or(DO_UP_VOID, 0) : sc_seq_or(DO_DOWN_VOID, 0), FALSE,
FALSE);
return 1;
@@ -1785,6 +1798,32 @@ const sc *get_shortcut(int menu, int *kbinput, bool
return NULL;
}
/* Try to get a function back from a window. Just a wrapper so
functions to need to create function_key meta_key blah blah
mmenu - what menu name to look through for valid funcs */
const subnfunc *getfuncfromkey(WINDOW *win)
{
int kbinput;
bool func_key = FALSE, meta_key = FALSE;
const sc *s;
const subnfunc *f;
kbinput = parse_kbinput(win, &meta_key, &func_key);
if (kbinput == 0)
return NULL;
s = get_shortcut(currmenu, &kbinput, &meta_key, &func_key);
if (!s)
return NULL;
f = sctofunc((sc *) s);
return f;
}
/* Move to (x, y) in win, and display a line of n spaces with the
* current attributes. */
void blank_line(WINDOW *win, int y, int x, int n)
@@ -2387,6 +2426,7 @@ void onekey(const char *keystroke, const char *desc, size_t len)
* in the edit window at (current_y, current_x). */
void reset_cursor(void)
{
size_t xpt;
/* If we haven't opened any files yet, put the cursor in the top
* left corner of the edit window and get out. */
if (openfile == NULL) {
@@ -2394,13 +2434,25 @@ void reset_cursor(void)
return;
}
openfile->current_y = openfile->current->lineno -
openfile->edittop->lineno;
if (openfile->current_y < editwinrows) {
size_t xpt = xplustabs();
xpt = xplustabs();
wmove(edit, openfile->current_y, xpt - get_page_start(xpt));
}
if (ISSET(SOFTWRAP)) {
filestruct *tmp;
openfile->current_y = 0;
for (tmp = openfile->edittop; tmp && tmp != openfile->current; tmp = tmp->next)
openfile->current_y += 1 + strlenpt(tmp->data) / COLS;
openfile->current_y += xplustabs() / COLS;
if (openfile->current_y < editwinrows)
wmove(edit, openfile->current_y, xpt % COLS);
} else {
openfile->current_y = openfile->current->lineno -
openfile->edittop->lineno;
if (openfile->current_y < editwinrows)
wmove(edit, openfile->current_y, xpt - get_page_start(xpt));
}
}
/* edit_draw() takes care of the job of actually painting a line into
@@ -2411,7 +2463,7 @@ void reset_cursor(void)
* character of this page. That is, the first character of converted
* corresponds to character number actual_x(fileptr->data, start) of the
* line. */
void edit_draw(const filestruct *fileptr, const char *converted, int
void edit_draw(filestruct *fileptr, const char *converted, int
line, size_t start)
{
#if !defined(NANO_TINY) || defined(ENABLE_COLOR)
@@ -2439,6 +2491,14 @@ void edit_draw(const filestruct *fileptr, const char *converted, int
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) {
const colortype *tmpcolor = openfile->colorstrings;
/* Set up multi-line color data for this line if it's not yet calculated */
if (fileptr->multidata == NULL && openfile->syntax
&& openfile->syntax->nmultis > 0) {
int i;
fileptr->multidata = (short *) nmalloc(openfile->syntax->nmultis * sizeof(short));
for (i = 0; i < openfile->syntax->nmultis; i++)
fileptr->multidata[i] = -1; /* Assue this applies until we know otherwise */
}
for (; tmpcolor != NULL; tmpcolor = tmpcolor->next) {
int x_start;
/* Starting column for mvwaddnstr. Zero-based. */
@@ -2504,7 +2564,7 @@ void edit_draw(const filestruct *fileptr, const char *converted, int
}
k = startmatch.rm_eo;
}
} else {
} else if (fileptr->multidata != NULL && fileptr->multidata[tmpcolor->id] != CNONE) {
/* This is a multi-line regex. There are two steps.
* First, we have to see if the beginning of the line is
* colored by a start on an earlier line, and an end on
@@ -2521,6 +2581,22 @@ void edit_draw(const filestruct *fileptr, const char *converted, int
regoff_t start_col;
/* Where it starts in that line. */
const filestruct *end_line;
short md = fileptr->multidata[tmpcolor->id];
if (md == -1)
fileptr->multidata[tmpcolor->id] = CNONE; /* until we find out otherwise */
else if (md == CNONE)
continue;
else if (md == CWHOLELINE) {
mvwaddnstr(edit, line, 0, converted, -1);
continue;
} else if (md == CBEGINBEFORE) {
regexec(tmpcolor->end, fileptr->data, 1, &endmatch, 0);
paintlen = actual_x(converted, strnlenpt(fileptr->data,
endmatch.rm_eo) - start);
mvwaddnstr(edit, line, 0, converted, paintlen);
continue;
}
while (start_line != NULL && regexec(tmpcolor->start,
start_line->data, 1, &startmatch, 0) ==
@@ -2584,15 +2660,16 @@ void edit_draw(const filestruct *fileptr, const char *converted, int
* expanded location of the end of the match minus
* the expanded location of the beginning of the
* page. */
if (end_line != fileptr)
if (end_line != fileptr) {
paintlen = -1;
else
fileptr->multidata[tmpcolor->id] = CWHOLELINE;
} else {
paintlen = actual_x(converted,
strnlenpt(fileptr->data,
endmatch.rm_eo) - start);
fileptr->multidata[tmpcolor->id] = CBEGINBEFORE;
}
mvwaddnstr(edit, line, 0, converted, paintlen);
step_two:
/* Second step, we look for starts on this line. */
start_col = 0;
@@ -2637,6 +2714,9 @@ void edit_draw(const filestruct *fileptr, const char *converted, int
mvwaddnstr(edit, line, x_start,
converted + index, paintlen);
if (paintlen > 0)
fileptr->multidata[tmpcolor->id] = CSTARTENDHERE;
}
} else {
/* There is no end on this line. But we
@@ -2657,6 +2737,7 @@ void edit_draw(const filestruct *fileptr, const char *converted, int
/* We painted to the end of the line, so
* don't bother checking any more
* starts. */
fileptr->multidata[tmpcolor->id] = CENDAFTER;
break;
}
}
@@ -2745,43 +2826,86 @@ void edit_draw(const filestruct *fileptr, const char *converted, int
/* Just update one line in the edit buffer. This is basically a wrapper
* for edit_draw(). The line will be displayed starting with
* fileptr->data[index]. Likely arguments are current_x or zero. */
void update_line(const filestruct *fileptr, size_t index)
* fileptr->data[index]. Likely arguments are current_x or zero.
* Returns: Number of additiona lines consumed (needed for SOFTWRAP)
*/
int update_line(filestruct *fileptr, size_t index)
{
int line;
int line = 0;
int extralinesused = 0;
/* The line in the edit window that we want to update. */
char *converted;
/* fileptr->data converted to have tabs and control characters
* expanded. */
size_t page_start;
filestruct *tmp;
assert(fileptr != NULL);
line = fileptr->lineno - openfile->edittop->lineno;
if (ISSET(SOFTWRAP)) {
for (tmp = openfile->edittop; tmp && tmp != fileptr; tmp = tmp->next) {
line += 1 + (strlenpt(tmp->data) / COLS);
}
} else
line = fileptr->lineno - openfile->edittop->lineno;
if (line < 0 || line >= editwinrows)
return;
return 1;
/* First, blank out the line. */
blank_line(edit, line, 0, COLS);
/* Next, convert variables that index the line to their equivalent
* positions in the expanded line. */
index = strnlenpt(fileptr->data, index);
if (ISSET(SOFTWRAP))
index = 0;
else
index = strnlenpt(fileptr->data, index);
page_start = get_page_start(index);
/* Expand the line, replacing tabs with spaces, and control
* characters with their displayed forms. */
converted = display_string(fileptr->data, page_start, COLS, TRUE);
converted = display_string(fileptr->data, page_start, COLS, !ISSET(SOFTWRAP));
#ifdef DEBUG
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
fprintf(stderr, "update_line(): converted(1) line = %s\n", converted);
#endif
/* Paint the line. */
edit_draw(fileptr, converted, line, page_start);
free(converted);
if (page_start > 0)
mvwaddch(edit, line, 0, '$');
if (strlenpt(fileptr->data) > page_start + COLS)
mvwaddch(edit, line, COLS - 1, '$');
if (!ISSET(SOFTWRAP)) {
if (page_start > 0)
mvwaddch(edit, line, 0, '$');
if (strlenpt(fileptr->data) > page_start + COLS)
mvwaddch(edit, line, COLS - 1, '$');
} else {
int full_length = strlenpt(fileptr->data);
for (index += COLS; index <= full_length && line < editwinrows; index += COLS) {
line++;
#ifdef DEBUG
fprintf(stderr, "update_line(): Softwrap code, moving to %d index %lu\n", line, (unsigned long) index);
#endif
blank_line(edit, line, 0, COLS);
/* Expand the line, replacing tabs with spaces, and control
* characters with their displayed forms. */
converted = display_string(fileptr->data, index, COLS, !ISSET(SOFTWRAP));
#ifdef DEBUG
if (ISSET(SOFTWRAP) && strlen(converted) >= COLS - 2)
fprintf(stderr, "update_line(): converted(2) line = %s\n", converted);
#endif
/* Paint the line. */
edit_draw(fileptr, converted, line, index);
free(converted);
extralinesused++;
}
}
return extralinesused;
}
/* Return TRUE if we need an update after moving horizontally, and FALSE
@@ -2810,6 +2934,34 @@ bool need_vertical_update(size_t pww_save)
get_page_start(openfile->placewewant);
}
/* When edittop changes, try and figure out how many lines
* we really have to work with (i.e. set maxrows)
*/
void compute_maxrows(void)
{
int n;
filestruct *foo = openfile->edittop;
if (!ISSET(SOFTWRAP)) {
maxrows = editwinrows;
return;
}
maxrows = 0;
for (n = 0; n < editwinrows && foo; n++) {
maxrows ++;
n += strlenpt(foo->data) / COLS;
foo = foo->next;
}
if (n < editwinrows)
maxrows += editwinrows - n;
#ifdef DEBUG
fprintf(stderr, "compute_maxrows(): maxrows = %ld\n", maxrows);
#endif
}
/* Scroll the edit window in the given direction and the given number
* of lines, and draw new lines on the blank lines left after the
* scrolling. direction is the direction to scroll, either UP_DIR or
@@ -2818,14 +2970,47 @@ bool need_vertical_update(size_t pww_save)
* also assume that scrollok(edit) is FALSE. */
void edit_scroll(scroll_dir direction, ssize_t nlines)
{
bool do_redraw = need_vertical_update(0);
const filestruct *foo;
ssize_t i;
filestruct *foo;
ssize_t i, extracuzsoft = 0;
bool do_redraw = FALSE;
/* Don't bother scrolling less than one line. */
if (nlines < 1)
return;
if (need_vertical_update(0))
do_redraw = TRUE;
/* If using soft wrapping, we want to scroll down enough to display the entire next
line, if possible... */
if (ISSET(SOFTWRAP) && direction == DOWN_DIR) {
#ifdef DEBUG
fprintf(stderr, "Softwrap: Entering check for extracuzsoft\n");
#endif
for (i = maxrows, foo = openfile->edittop; foo && i > 0; i--, foo = foo->next)
;
if (foo) {
extracuzsoft += strlenpt(foo->data) / COLS;
#ifdef DEBUG
fprintf(stderr, "Setting extracuzsoft to %lu due to strlen %lu of line %lu\n", (unsigned long) extracuzsoft,
(unsigned long) strlenpt(foo->data), (unsigned long) foo->lineno);
#endif
/* Now account for whether the edittop line itself is >COLS, if scrolling down */
for (foo = openfile->edittop; foo && extracuzsoft > 0; nlines++) {
extracuzsoft -= 1 + strlenpt(foo->data) / COLS;
#ifdef DEBUG
fprintf(stderr, "Edittop adjustment, setting nlines to %lu\n", (unsigned long) nlines);
#endif
if (foo == openfile->filebot)
break;
foo = foo->next;
}
}
}
/* Part 1: nlines is the number of lines we're going to scroll the
* text of the edit window. */
@@ -2842,6 +3027,13 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
break;
openfile->edittop = openfile->edittop->next;
}
/* Don't over-scroll on long lines */
if (ISSET(SOFTWRAP)) {
ssize_t len = strlenpt(openfile->edittop->data) / COLS;
i -= len;
if (len > 0)
do_redraw = TRUE;
}
}
/* Limit nlines to the number of lines we could scroll. */
@@ -2850,9 +3042,9 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
/* Don't bother scrolling zero lines or more than the number of
* lines in the edit window minus one; in both cases, get out, and
* call edit_refresh() beforehand if we need to. */
if (nlines == 0 || nlines >= editwinrows) {
if (nlines == 0 || do_redraw || nlines >= editwinrows) {
if (do_redraw || nlines >= editwinrows)
edit_refresh();
edit_refresh_needed = TRUE;
return;
}
@@ -2914,19 +3106,24 @@ void edit_scroll(scroll_dir direction, ssize_t nlines)
/* Update any lines between old_current and current that need to be
* updated. Use this if we've moved without changing any text. */
void edit_redraw(const filestruct *old_current, size_t pww_save)
void edit_redraw(filestruct *old_current, size_t pww_save)
{
bool do_redraw = need_vertical_update(0) ||
need_vertical_update(pww_save);
const filestruct *foo = NULL;
filestruct *foo = NULL;
/* If either old_current or current is offscreen, scroll the edit
* window until it's onscreen and get out. */
if (old_current->lineno < openfile->edittop->lineno ||
old_current->lineno >= openfile->edittop->lineno +
editwinrows || openfile->current->lineno <
maxrows || openfile->current->lineno <
openfile->edittop->lineno || openfile->current->lineno >=
openfile->edittop->lineno + editwinrows) {
openfile->edittop->lineno + maxrows) {
#ifdef DEBUG
fprintf(stderr, "edit_redraw(): line %lu was offscreen, oldcurrent = %lu edittop = %lu", openfile->current->lineno,
old_current->lineno, openfile->edittop->lineno);
#endif
filestruct *old_edittop = openfile->edittop;
ssize_t nlines;
@@ -2940,7 +3137,7 @@ void edit_redraw(const filestruct *old_current, size_t pww_save)
if (old_edittop->lineno < openfile->edittop->lineno)
old_lineno = old_edittop->lineno;
else
old_lineno = (old_edittop->lineno + editwinrows <=
old_lineno = (old_edittop->lineno + maxrows <=
openfile->filebot->lineno) ?
old_edittop->lineno + editwinrows :
openfile->filebot->lineno;
@@ -2959,28 +3156,13 @@ void edit_redraw(const filestruct *old_current, size_t pww_save)
/* Put edittop in range of current, get the difference in lines
* between the original edittop and the current edittop, and
* then restore the original edittop. */
edit_update(
#ifndef NANO_TINY
ISSET(SMOOTH_SCROLL) ? NONE :
#endif
CENTER);
nlines = openfile->edittop->lineno - old_edittop->lineno;
openfile->edittop = old_edittop;
edit_update(CENTER);
/* Update old_current if we're not on the same page as
* before. */
if (do_redraw)
update_line(old_current, 0);
/* Scroll the edit window up or down until edittop is in range
* of current. */
if (nlines < 0)
edit_scroll(UP_DIR, -nlines);
else
edit_scroll(DOWN_DIR, nlines);
#ifndef NANO_TINY
/* If the mark is on, update all the lines between the old first
* line or old last line of the edit window (depending on
@@ -3026,19 +3208,24 @@ void edit_redraw(const filestruct *old_current, size_t pww_save)
* if we've moved and changed text. */
void edit_refresh(void)
{
const filestruct *foo;
filestruct *foo;
int nlines;
/* Figure out what maxrows should really be */
compute_maxrows();
if (openfile->current->lineno < openfile->edittop->lineno ||
openfile->current->lineno >= openfile->edittop->lineno +
editwinrows)
maxrows) {
#ifdef DEBUG
fprintf(stderr, "edit_refresh(): line = %d, edittop %d + maxrows %d\n", openfile->current->lineno, openfile->edittop->lineno, maxrows);
#endif
/* Put the top line of the edit window in range of the current
* line. */
edit_update(
#ifndef NANO_TINY
ISSET(SMOOTH_SCROLL) ? NONE :
#endif
CENTER);
edit_update(CENTER);
}
foo = openfile->edittop;
@@ -3047,7 +3234,7 @@ void edit_refresh(void)
#endif
for (nlines = 0; nlines < editwinrows && foo != NULL; nlines++) {
update_line(foo, (foo == openfile->current) ?
nlines += update_line(foo, (foo == openfile->current) ?
openfile->current_x : 0);
foo = foo->next;
}
@@ -3086,10 +3273,17 @@ void edit_update(update_type location)
goal = editwinrows - 1;
}
for (; goal > 0 && foo->prev != NULL; goal--)
for (; goal > 0 && foo->prev != NULL; goal--) {
foo = foo->prev;
if (ISSET(SOFTWRAP) && foo)
goal -= strlenpt(foo->data) / COLS;
}
openfile->edittop = foo;
#ifdef DEBUG
fprintf(stderr, "edit_udpate(), setting edittop to lineno %d\n", openfile->edittop->lineno);
#endif
compute_maxrows();
edit_refresh_needed = TRUE;
}
/* Unconditionally redraw the entire screen. */
@@ -3178,6 +3372,19 @@ void do_cursorpos_void(void)
do_cursorpos(FALSE);
}
void enable_nodelay(void)
{
nodelay_mode = TRUE;
nodelay(edit, TRUE);
}
void disable_nodelay(void)
{
nodelay_mode = FALSE;
nodelay(edit, FALSE);
}
/* Highlight the current word being replaced or spell checked. We
* expect word to have tabs and control characters expanded. */
void do_replace_highlight(bool highlight, const char *word)