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
every function. Rename global_init() resize_init(), rename
add_open_file() make_new_buffer(), rename load_buffer()
open_buffer(), rename open_prevnext_file()
switch_to_prevnext_buffer(), rename open_prevfile_void()
switch_to_prev_buffer(), rename open_nextfile_void()
switch_to_next_buffer(), remove load_file(), and remove
load_open_file(). (DLR)
open_buffer(), rename load_open_file() load_buffer(), rename
open_prevnext_file() switch_to_prevnext_buffer(), rename
open_prevfile_void() switch_to_prev_buffer(), rename
open_nextfile_void() switch_to_next_buffer(), remove
load_file(), rename cancel_fork() cancel_command(),
rename open_pipe() execute_command(), and remove
execute_command(). (DLR)
- files.c:
open_file()
- 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
}
/* If we have a file, move back to the first line of it if we're
* loading into a new buffer. Then update the titlebar, the colors
* (if applicable), and the edit window. */
if (rc != -1) {
if (new_buffer)
openfile->current = openfile->fileage;
/* If we have a file and we're loading into a new buffer, move back
* to the first line of the buffer. */
if (rc != -1 && new_buffer)
openfile->current = openfile->fileage;
}
/* Update the screen to account for the current buffer. */
void load_buffer(void)
{
titlebar(NULL);
#ifdef ENABLE_COLOR
update_color();
#endif
edit_refresh();
}
}
#ifdef ENABLE_MULTIBUFFER
@ -227,6 +228,9 @@ void switch_to_prevnext_buffer(bool next_buf)
fprintf(stderr, "filename is %s\n", openfile->filename);
#endif
/* Update the screen to account for the current buffer. */
load_buffer();
/* Indicate the switch on the statusbar. */
statusbar(_("Switched to %s"),
((openfile->filename[0] == '\0') ? _("New Buffer") :
@ -609,19 +613,6 @@ char *get_next_filename(const char *name, const char *suffix)
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(
#ifndef NANO_SMALL
bool execute
@ -755,19 +746,35 @@ void do_insertfile(
#endif
#ifndef NANO_SMALL
if (execute)
execute_command(answer);
else {
if (execute) {
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
/* Open a new blank buffer. */
open_buffer("");
#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,
real_dir_from_tilde(answer));
/* Save the file specified in answer in the current
* buffer. */
open_buffer(answer);
#ifndef NANO_SMALL
}
#endif
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(MULTIBUFFER))
if (ISSET(MULTIBUFFER))
/* Update the screen to account for the current
* buffer. */
load_buffer();
else
#endif
{
filestruct *top_save = openfile->fileage;
@ -792,27 +799,18 @@ void do_insertfile(
* partition. */
renumber(top_save);
/* Set edittop back to what it was before. */
/* Restore the old edittop. */
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. */
openfile->placewewant = pww_save;
#ifdef ENABLE_MULTIBUFFER
}
#endif
/* Refresh the screen. */
edit_refresh();
/* Mark the file as modified. */
set_modified();
/* Update the screen. */
edit_refresh();
}
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
SIGWINCH. */
static int pid; /* The PID of the newly forked process
* in open_pipe(). It must be global
* because the signal handler needs
* it. */
* in execute_command(). It must be
* global because the signal handler
* needs it. */
#endif
#ifndef DISABLE_JUSTIFY
@ -1169,14 +1169,14 @@ void nano_disabled_msg(void)
}
#ifndef NANO_SMALL
void cancel_fork(int signal)
void cancel_command(int signal)
{
if (kill(pid, SIGKILL) == -1)
nperror("kill");
}
/* Return TRUE on success. */
bool open_pipe(const char *command)
bool execute_command(const char *command)
{
int fd[2];
FILE *f;
@ -1222,7 +1222,7 @@ bool open_pipe(const char *command)
sig_failed = TRUE;
nperror("sigaction");
} else {
newaction.sa_handler = cancel_fork;
newaction.sa_handler = cancel_command;
if (sigaction(SIGINT, &newaction, &oldaction) == -1) {
sig_failed = TRUE;
nperror("sigaction");
@ -4699,6 +4699,9 @@ int main(int argc, char **argv)
UNSET(VIEW_MODE);
}
/* Update the screen to account for the current buffer. */
load_buffer();
#ifdef ENABLE_MULTIBUFFER
if (!old_multibuffer)
UNSET(MULTIBUFFER);
@ -4708,7 +4711,6 @@ int main(int argc, char **argv)
fprintf(stderr, "Main: top and bottom win\n");
#endif
titlebar(NULL);
display_main_list();
if (startline > 1 || startcol > 1)

View File

@ -240,6 +240,7 @@ void free_openfilestruct(openfilestruct *src);
#endif
void make_new_buffer(void);
void open_buffer(const char *filename);
void load_buffer(void);
#ifdef ENABLE_MULTIBUFFER
void switch_to_prevnext_buffer(bool next);
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);
int open_file(const char *filename, bool newfie, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
#ifndef NANO_SMALL
void execute_command(const char *command);
#endif
void do_insertfile(
#ifndef NANO_SMALL
bool execute
@ -380,8 +378,8 @@ int no_more_space(void);
int no_help(void);
void nano_disabled_msg(void);
#ifndef NANO_SMALL
void cancel_fork(int signal);
bool open_pipe(const char *command);
void cancel_command(int signal);
bool execute_command(const char *command);
#endif
void do_verbatim_input(void);
void do_backspace(void);