DLR's latest patch: view+multibuffer, die() fixes, insert key fixes in main()

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@961 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2002-01-02 15:12:21 +00:00
parent 180a569fdb
commit 32da456ab0
4 changed files with 69 additions and 25 deletions

View File

@ -1,5 +1,11 @@
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.
@ -13,6 +19,8 @@ CVS code -
- 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).

35
files.c
View File

@ -93,11 +93,19 @@ void new_file(void)
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);
}
@ -440,7 +448,14 @@ int do_insertfile_void(void)
{
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
@ -523,10 +538,16 @@ int add_open_file(int update, int dup_fix)
/* 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);

View File

@ -324,15 +324,31 @@ void shortcut_init(int unjustify)
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,

33
nano.c
View File

@ -122,12 +122,12 @@ void die(char *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;
@ -142,7 +142,9 @@ void die(char *msg, ...)
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;
@ -3101,16 +3103,10 @@ int main(int argc, char *argv[])
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);
@ -3224,9 +3220,12 @@ int main(int argc, char *argv[])
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;