yet more breakage fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2839 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-07-09 04:42:47 +00:00
parent be5cdb2748
commit 56001845cd
4 changed files with 57 additions and 57 deletions

View File

@ -15,11 +15,13 @@ CVS code -
Accordingly, remove the globals. Changes to pretty much Accordingly, remove the globals. Changes to pretty much
every function. Rename global_init() resize_init(), rename every function. Rename global_init() resize_init(), rename
add_open_file() make_new_buffer(), rename load_buffer() add_open_file() make_new_buffer(), rename load_buffer()
open_buffer(), rename open_prevnext_file() open_buffer(), rename load_open_file() load_buffer(), rename
switch_to_prevnext_buffer(), rename open_prevfile_void() open_prevnext_file() switch_to_prevnext_buffer(), rename
switch_to_prev_buffer(), rename open_nextfile_void() open_prevfile_void() switch_to_prev_buffer(), rename
switch_to_next_buffer(), remove load_file(), and remove open_nextfile_void() switch_to_next_buffer(), remove
load_open_file(). (DLR) load_file(), rename cancel_fork() cancel_command(),
rename open_pipe() execute_command(), and remove
execute_command(). (DLR)
- files.c: - files.c:
open_file() open_file()
- Assert that filename isn't NULL, and don't do anything special - Assert that filename isn't NULL, and don't do anything special

View File

@ -190,19 +190,20 @@ void open_buffer(const char *filename)
#endif #endif
} }
/* If we have a file, move back to the first line of it if we're /* If we have a file and we're loading into a new buffer, move back
* loading into a new buffer. Then update the titlebar, the colors * to the first line of the buffer. */
* (if applicable), and the edit window. */ if (rc != -1 && new_buffer)
if (rc != -1) { openfile->current = openfile->fileage;
if (new_buffer) }
openfile->current = openfile->fileage;
/* Update the screen to account for the current buffer. */
void load_buffer(void)
{
titlebar(NULL); titlebar(NULL);
#ifdef ENABLE_COLOR #ifdef ENABLE_COLOR
update_color(); update_color();
#endif #endif
edit_refresh(); edit_refresh();
}
} }
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
@ -227,6 +228,9 @@ void switch_to_prevnext_buffer(bool next_buf)
fprintf(stderr, "filename is %s\n", openfile->filename); fprintf(stderr, "filename is %s\n", openfile->filename);
#endif #endif
/* Update the screen to account for the current buffer. */
load_buffer();
/* Indicate the switch on the statusbar. */ /* Indicate the switch on the statusbar. */
statusbar(_("Switched to %s"), statusbar(_("Switched to %s"),
((openfile->filename[0] == '\0') ? _("New Buffer") : ((openfile->filename[0] == '\0') ? _("New Buffer") :
@ -609,19 +613,6 @@ char *get_next_filename(const char *name, const char *suffix)
return buf; return buf;
} }
#ifndef NANO_SMALL
void execute_command(const char *command)
{
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
/* Add a new entry to the openfile structure. */
open_buffer("");
#endif
open_pipe(command);
}
#endif /* !NANO_SMALL */
void do_insertfile( void do_insertfile(
#ifndef NANO_SMALL #ifndef NANO_SMALL
bool execute bool execute
@ -755,19 +746,35 @@ void do_insertfile(
#endif #endif
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (execute) if (execute) {
execute_command(answer); #ifdef ENABLE_MULTIBUFFER
else { if (ISSET(MULTIBUFFER))
/* Open a new blank buffer. */
open_buffer("");
#endif #endif
/* Save the command's output in the current buffer. */
execute_command(answer);
} else {
#endif
/* Make sure the path to the file specified in answer is
* tilde-expanded. */
answer = mallocstrassn(answer, answer = mallocstrassn(answer,
real_dir_from_tilde(answer)); real_dir_from_tilde(answer));
/* Save the file specified in answer in the current
* buffer. */
open_buffer(answer); open_buffer(answer);
#ifndef NANO_SMALL #ifndef NANO_SMALL
} }
#endif #endif
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
if (!ISSET(MULTIBUFFER)) if (ISSET(MULTIBUFFER))
/* Update the screen to account for the current
* buffer. */
load_buffer();
else
#endif #endif
{ {
filestruct *top_save = openfile->fileage; filestruct *top_save = openfile->fileage;
@ -792,27 +799,18 @@ void do_insertfile(
* partition. */ * partition. */
renumber(top_save); renumber(top_save);
/* Set edittop back to what it was before. */ /* Restore the old edittop. */
openfile->edittop = edittop_save; openfile->edittop = edittop_save;
}
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
/* Update the titlebar. */
titlebar(NULL);
else {
#endif
/* Mark the file as modified. */
set_modified();
/* Restore the old place we want. */ /* Restore the old place we want. */
openfile->placewewant = pww_save; openfile->placewewant = pww_save;
#ifdef ENABLE_MULTIBUFFER
}
#endif
/* Refresh the screen. */ /* Mark the file as modified. */
edit_refresh(); set_modified();
/* Update the screen. */
edit_refresh();
}
break; break;
} }

View File

@ -68,9 +68,9 @@ static struct sigaction act; /* For all our fun signal handlers */
static sigjmp_buf jmpbuf; /* Used to return to main() after a static sigjmp_buf jmpbuf; /* Used to return to main() after a
SIGWINCH. */ SIGWINCH. */
static int pid; /* The PID of the newly forked process static int pid; /* The PID of the newly forked process
* in open_pipe(). It must be global * in execute_command(). It must be
* because the signal handler needs * global because the signal handler
* it. */ * needs it. */
#endif #endif
#ifndef DISABLE_JUSTIFY #ifndef DISABLE_JUSTIFY
@ -1169,14 +1169,14 @@ void nano_disabled_msg(void)
} }
#ifndef NANO_SMALL #ifndef NANO_SMALL
void cancel_fork(int signal) void cancel_command(int signal)
{ {
if (kill(pid, SIGKILL) == -1) if (kill(pid, SIGKILL) == -1)
nperror("kill"); nperror("kill");
} }
/* Return TRUE on success. */ /* Return TRUE on success. */
bool open_pipe(const char *command) bool execute_command(const char *command)
{ {
int fd[2]; int fd[2];
FILE *f; FILE *f;
@ -1222,7 +1222,7 @@ bool open_pipe(const char *command)
sig_failed = TRUE; sig_failed = TRUE;
nperror("sigaction"); nperror("sigaction");
} else { } else {
newaction.sa_handler = cancel_fork; newaction.sa_handler = cancel_command;
if (sigaction(SIGINT, &newaction, &oldaction) == -1) { if (sigaction(SIGINT, &newaction, &oldaction) == -1) {
sig_failed = TRUE; sig_failed = TRUE;
nperror("sigaction"); nperror("sigaction");
@ -4699,6 +4699,9 @@ int main(int argc, char **argv)
UNSET(VIEW_MODE); UNSET(VIEW_MODE);
} }
/* Update the screen to account for the current buffer. */
load_buffer();
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
if (!old_multibuffer) if (!old_multibuffer)
UNSET(MULTIBUFFER); UNSET(MULTIBUFFER);
@ -4708,7 +4711,6 @@ int main(int argc, char **argv)
fprintf(stderr, "Main: top and bottom win\n"); fprintf(stderr, "Main: top and bottom win\n");
#endif #endif
titlebar(NULL);
display_main_list(); display_main_list();
if (startline > 1 || startcol > 1) if (startline > 1 || startcol > 1)

View File

@ -240,6 +240,7 @@ void free_openfilestruct(openfilestruct *src);
#endif #endif
void make_new_buffer(void); void make_new_buffer(void);
void open_buffer(const char *filename); void open_buffer(const char *filename);
void load_buffer(void);
#ifdef ENABLE_MULTIBUFFER #ifdef ENABLE_MULTIBUFFER
void switch_to_prevnext_buffer(bool next); void switch_to_prevnext_buffer(bool next);
void switch_to_prev_buffer_void(void); void switch_to_prev_buffer_void(void);
@ -251,9 +252,6 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool
void read_file(FILE *f, const char *filename); void read_file(FILE *f, const char *filename);
int open_file(const char *filename, bool newfie, FILE **f); int open_file(const char *filename, bool newfie, FILE **f);
char *get_next_filename(const char *name, const char *suffix); char *get_next_filename(const char *name, const char *suffix);
#ifndef NANO_SMALL
void execute_command(const char *command);
#endif
void do_insertfile( void do_insertfile(
#ifndef NANO_SMALL #ifndef NANO_SMALL
bool execute bool execute
@ -380,8 +378,8 @@ int no_more_space(void);
int no_help(void); int no_help(void);
void nano_disabled_msg(void); void nano_disabled_msg(void);
#ifndef NANO_SMALL #ifndef NANO_SMALL
void cancel_fork(int signal); void cancel_command(int signal);
bool open_pipe(const char *command); bool execute_command(const char *command);
#endif #endif
void do_verbatim_input(void); void do_verbatim_input(void);
void do_backspace(void); void do_backspace(void);