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-d3aeb78583b8master
parent
180a569fdb
commit
32da456ab0
|
@ -1,5 +1,11 @@
|
||||||
CVS code -
|
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:
|
- nano.c:
|
||||||
|
die()
|
||||||
|
- Only save files that were modified (David Lawrence Ramsey).
|
||||||
do_cont()
|
do_cont()
|
||||||
- Run signal_init() after doupdate() so ^Y wont suddenly
|
- Run signal_init() after doupdate() so ^Y wont suddenly
|
||||||
start suspending after returning from ^Z suspend in Hurd.
|
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).
|
- Typo in file switch string (found by David Lawrence Ramsey).
|
||||||
main()
|
main()
|
||||||
- Handle Alt prev/next file keys (,.), as well as normal ones (<>).
|
- 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:
|
- files.c:
|
||||||
read_file()
|
read_file()
|
||||||
- Make conversion message less confusing (suggested by Jordi).
|
- Make conversion message less confusing (suggested by Jordi).
|
||||||
|
|
27
files.c
27
files.c
|
@ -93,11 +93,19 @@ void new_file(void)
|
||||||
duplicates; without this, if nano is started without a filename on
|
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
|
the command line, a new file will be created, but it will be given
|
||||||
no open_files entry, leading to problems later on */
|
no open_files entry, leading to problems later on */
|
||||||
if (!open_files)
|
if (!open_files) {
|
||||||
add_open_file(0, 0);
|
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
|
#endif
|
||||||
|
|
||||||
UNSET(VIEW_MODE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -440,6 +448,13 @@ int do_insertfile_void(void)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_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));
|
result = do_insertfile(ISSET(MULTIBUFFER));
|
||||||
#else
|
#else
|
||||||
result = do_insertfile(0);
|
result = do_insertfile(0);
|
||||||
|
@ -523,10 +538,16 @@ int add_open_file(int update, int dup_fix)
|
||||||
/* save current line number */
|
/* save current line number */
|
||||||
open_files->lineno = current->lineno;
|
open_files->lineno = current->lineno;
|
||||||
|
|
||||||
/* save current filestruct and restore full file position afterward */
|
/* 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 = nmalloc(sizeof(filestruct));
|
||||||
open_files->file = copy_filestruct(fileage);
|
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);
|
do_gotopos(open_files->lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
|
||||||
|
}
|
||||||
|
|
||||||
/* save current modification status */
|
/* save current modification status */
|
||||||
open_files->file_modified = ISSET(MODIFIED);
|
open_files->file_modified = ISSET(MODIFIED);
|
||||||
|
|
18
global.c
18
global.c
|
@ -324,15 +324,31 @@ void shortcut_init(int unjustify)
|
||||||
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
|
nano_justify_msg, 0, NANO_JUSTIFY_FKEY, 0,
|
||||||
NOVIEW, do_justify);
|
NOVIEW, do_justify);
|
||||||
else
|
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"),
|
sc_init_one(&main_list[3], NANO_INSERTFILE_KEY, _("Read File"),
|
||||||
nano_insert_msg,
|
nano_insert_msg,
|
||||||
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
|
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ISSET(PICO_MODE))
|
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"),
|
sc_init_one(&main_list[4], NANO_INSERTFILE_KEY, _("Read File"),
|
||||||
nano_insert_msg,
|
nano_insert_msg,
|
||||||
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
|
0, NANO_INSERTFILE_FKEY, 0, NOVIEW, do_insertfile_void);
|
||||||
|
#endif
|
||||||
|
|
||||||
else
|
else
|
||||||
sc_init_one(&main_list[4], NANO_REPLACE_KEY, _("Replace"),
|
sc_init_one(&main_list[4], NANO_REPLACE_KEY, _("Replace"),
|
||||||
nano_replace_msg,
|
nano_replace_msg,
|
||||||
|
|
29
nano.c
29
nano.c
|
@ -122,12 +122,12 @@ void die(char *msg, ...)
|
||||||
|
|
||||||
fprintf(stderr, msg);
|
fprintf(stderr, msg);
|
||||||
|
|
||||||
/* save the currently loaded file (if modified, its open_files entry
|
/* save the currently loaded file if it's been modified */
|
||||||
isn't up to date) */
|
if (ISSET(MODIFIED))
|
||||||
die_save_file(filename);
|
die_save_file(filename);
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#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) {
|
if (open_files) {
|
||||||
filestruct *tmp;
|
filestruct *tmp;
|
||||||
|
|
||||||
|
@ -142,6 +142,8 @@ void die(char *msg, ...)
|
||||||
currently loaded file), don't save it again */
|
currently loaded file), don't save it again */
|
||||||
if (tmp != open_files) {
|
if (tmp != open_files) {
|
||||||
fileage = open_files->file;
|
fileage = open_files->file;
|
||||||
|
/* save the file if it's been modified */
|
||||||
|
if (open_files->file_modified)
|
||||||
die_save_file(open_files->data);
|
die_save_file(open_files->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3101,16 +3103,10 @@ int main(int argc, char *argv[])
|
||||||
case '9': /* Alt-[-9 = Delete in Hurd Console */
|
case '9': /* Alt-[-9 = Delete in Hurd Console */
|
||||||
kbinput = KEY_DC;
|
kbinput = KEY_DC;
|
||||||
break;
|
break;
|
||||||
case '@': /* Alt-[-9 = Insert in Hurd Console */
|
case '@': /* Alt-[-@ = Insert in Hurd Console */
|
||||||
case 'L': /* Insert Key - FreeBSD Console */
|
case 'L': /* Alt-[-L = Insert - FreeBSD Console */
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
goto do_insertkey;
|
||||||
do_insertfile(ISSET(MULTIBUFFER));
|
case '[': /* Alt-[-[-[A-E], F1-F5 in Linux console */
|
||||||
#else
|
|
||||||
do_insertfile(0);
|
|
||||||
#endif
|
|
||||||
keyhandled = 1;
|
|
||||||
break;
|
|
||||||
case '[': /* Alt-[-[-[A-E], F1-F5 in linux console */
|
|
||||||
kbinput = wgetch(edit);
|
kbinput = wgetch(edit);
|
||||||
if (kbinput >= 'A' && kbinput <= 'E')
|
if (kbinput >= 'A' && kbinput <= 'E')
|
||||||
kbinput = KEY_F(kbinput - 64);
|
kbinput = KEY_F(kbinput - 64);
|
||||||
|
@ -3224,9 +3220,12 @@ int main(int argc, char *argv[])
|
||||||
do_insertkey:
|
do_insertkey:
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#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
|
#else
|
||||||
do_insertfile(0);
|
print_view_warning();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
keyhandled = 1;
|
keyhandled = 1;
|
||||||
|
|
Loading…
Reference in New Issue