CVS code -
+- General
+ - Better integration of View mode (-v) and multibuffer.
+ Fixes to new_file(), do_insertfile_void(), shortcut_init()
+ (David Lawrence Ramsey).
- nano.c:
+ die()
+ - Only save files that were modified (David Lawrence Ramsey).
do_cont()
- Run signal_init() after doupdate() so ^Y wont suddenly
start suspending after returning from ^Z suspend in Hurd.
- Typo in file switch string (found by David Lawrence Ramsey).
main()
- Handle Alt prev/next file keys (,.), as well as normal ones (<>).
+ - Handle OS-specific insert keys by jump to do_insertkey (David
+ Lawrence Ramsey).
- files.c:
read_file()
- Make conversion message less confusing (suggested by Jordi).
duplicates; without this, if nano is started without a filename on
the command line, a new file will be created, but it will be given
no open_files entry, leading to problems later on */
- if (!open_files)
+ if (!open_files) {
add_open_file(0, 0);
+ /* turn off view mode in this case; this is for consistency
+ whether multibuffers are compiled in or not */
+ UNSET(VIEW_MODE);
+ }
+#else
+ /* if multibuffers haven't been compiled in, turn off view mode
+ unconditionally; otherwise, don't turn them off (except in the
+ above case), so that we can view multiple files properly */
+ UNSET(VIEW_MODE);
#endif
- UNSET(VIEW_MODE);
}
{
int result = 0;
#ifdef ENABLE_MULTIBUFFER
- result = do_insertfile(ISSET(MULTIBUFFER));
+ if (ISSET(VIEW_MODE)) {
+ if (ISSET(MULTIBUFFER))
+ result = do_insertfile(1);
+ else
+ statusbar(_("Key illegal in non-multibuffer mode"));
+ }
+ else
+ result = do_insertfile(ISSET(MULTIBUFFER));
#else
result = do_insertfile(0);
#endif
/* save current line number */
open_files->lineno = current->lineno;
- /* save current filestruct and restore full file position afterward */
- open_files->file = nmalloc(sizeof(filestruct));
- open_files->file = copy_filestruct(fileage);
- do_gotopos(open_files->lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
+ /* if we're in view mode and updating, the file contents won't
+ have changed, so we won't bother resaving the filestruct
+ then; otherwise, we will */
+ if (!(ISSET(VIEW_MODE) && !update)) {
+ /* save current filestruct and restore full file position
+ afterward */
+ open_files->file = nmalloc(sizeof(filestruct));
+ open_files->file = copy_filestruct(fileage);
+ do_gotopos(open_files->lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
+ }
/* save current modification status */
open_files->file_modified = ISSET(MODIFIED);
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
NOVIEW, do_justify);
else
+
+#ifdef ENABLE_MULTIBUFFER
+ /* this is so we can view multiple files */
+ sc_init_one(&main_list[3], NANO_INSERTFILE_KEY, _("Read File"),
+ nano_insert_msg,
+ 0, NANO_INSERTFILE_FKEY, 0, VIEW, do_insertfile_void);
+#else
sc_init_one(&main_list[3], NANO_INSERTFILE_KEY, _("Read File"),
nano_insert_msg,
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
-
+#endif
if (ISSET(PICO_MODE))
+
+#ifdef ENABLE_MULTIBUFFER
+ /* this is so we can view multiple files */
+ sc_init_one(&main_list[4], NANO_INSERTFILE_KEY, _("Read File"),
+ nano_insert_msg,
+ 0, NANO_INSERTFILE_FKEY, 0, VIEW, do_insertfile_void);
+#else
sc_init_one(&main_list[4], NANO_INSERTFILE_KEY, _("Read File"),
nano_insert_msg,
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
+#endif
+
else
sc_init_one(&main_list[4], NANO_REPLACE_KEY, _("Replace"),
nano_replace_msg,
fprintf(stderr, msg);
- /* save the currently loaded file (if modified, its open_files entry
- isn't up to date) */
- die_save_file(filename);
+ /* save the currently loaded file if it's been modified */
+ if (ISSET(MODIFIED))
+ die_save_file(filename);
#ifdef ENABLE_MULTIBUFFER
- /* then save all of the other loaded files, if any */
+ /* then save all of the other modified loaded files, if any */
if (open_files) {
filestruct *tmp;
currently loaded file), don't save it again */
if (tmp != open_files) {
fileage = open_files->file;
- die_save_file(open_files->data);
+ /* save the file if it's been modified */
+ if (open_files->file_modified)
+ die_save_file(open_files->data);
}
open_files = open_files->next;
case '9': /* Alt-[-9 = Delete in Hurd Console */
kbinput = KEY_DC;
break;
- case '@': /* Alt-[-9 = Insert in Hurd Console */
- case 'L': /* Insert Key - FreeBSD Console */
-#ifdef ENABLE_MULTIBUFFER
- do_insertfile(ISSET(MULTIBUFFER));
-#else
- do_insertfile(0);
-#endif
- keyhandled = 1;
- break;
- case '[': /* Alt-[-[-[A-E], F1-F5 in linux console */
+ case '@': /* Alt-[-@ = Insert in Hurd Console */
+ case 'L': /* Alt-[-L = Insert - FreeBSD Console */
+ goto do_insertkey;
+ case '[': /* Alt-[-[-[A-E], F1-F5 in Linux console */
kbinput = wgetch(edit);
if (kbinput >= 'A' && kbinput <= 'E')
kbinput = KEY_F(kbinput - 64);
do_insertkey:
#ifdef ENABLE_MULTIBUFFER
- do_insertfile(ISSET(MULTIBUFFER));
+ /* do_insertfile_void() contains the logic needed to
+ handle view mode with the view mode/multibuffer
+ exception, so use it here */
+ do_insertfile_void();
#else
- do_insertfile(0);
+ print_view_warning();
#endif
keyhandled = 1;