really fix the resetstatus problems this time, and add a few other
miscellaneous fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1969 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
056c5ef4a6
commit
045883aa34
26
ChangeLog
26
ChangeLog
|
@ -76,10 +76,21 @@ CVS code -
|
||||||
- Simplify by reusing variables whereever possible, and add a
|
- Simplify by reusing variables whereever possible, and add a
|
||||||
parameter execute to indicate whether or not to be in "Execute
|
parameter execute to indicate whether or not to be in "Execute
|
||||||
Command" mode. (DLR)
|
Command" mode. (DLR)
|
||||||
- If file browsing succeeds, copy the filename we browsed to
|
- Rework so that goto is no longer needed, using do_writeout()
|
||||||
into ans, put back Enter, and show the prompt one last time so
|
as a model. (DLR)
|
||||||
that it's exited properly and the cursor position at the
|
- If file browsing succeeds, call statusq_abort() so that the
|
||||||
statusbar is reset. (DLR)
|
cursor position at the statusbar is reset. (DLR)
|
||||||
|
do_writeout()
|
||||||
|
- Restructure if blocks for greater efficiency, using
|
||||||
|
do_insertfile() as a model. (DLR)
|
||||||
|
- Simplify where possible, and use an int retval to hold the
|
||||||
|
return value instead of i. (DLR)
|
||||||
|
- If file browsing succeeds, call statusq_abort() so that the
|
||||||
|
cursor position at the statusbar is reset. (DLR)
|
||||||
|
- Remove unneeded calls to display_main_list(). (DLR)
|
||||||
|
do_writeout_void()
|
||||||
|
- Call display_main_list(), for consistency with
|
||||||
|
do_insertfile_void(). (DLR)
|
||||||
open_prevfile(), open_nextfile()
|
open_prevfile(), open_nextfile()
|
||||||
- Translate the "New Buffer" string when displaying "Switched
|
- Translate the "New Buffer" string when displaying "Switched
|
||||||
to" messages on the statusbar. (DLR)
|
to" messages on the statusbar. (DLR)
|
||||||
|
@ -165,13 +176,14 @@ CVS code -
|
||||||
- Refresh the screen when Ctrl-L is pressed at the statusbar
|
- Refresh the screen when Ctrl-L is pressed at the statusbar
|
||||||
prompt, as Pico does. (DLR)
|
prompt, as Pico does. (DLR)
|
||||||
- Always return the key pressed by the user. (DLR)
|
- Always return the key pressed by the user. (DLR)
|
||||||
- Take new parameter reset_x, containing the value of
|
|
||||||
resetstatuspos, so that resetstatuspos can be a static
|
|
||||||
variable for just statusq(). (DLR)
|
|
||||||
statusq()
|
statusq()
|
||||||
- Rework slightly to reset the cursor position when the user
|
- Rework slightly to reset the cursor position when the user
|
||||||
hits Enter as well as Cancel. This means that resetstatuspos
|
hits Enter as well as Cancel. This means that resetstatuspos
|
||||||
no longer needs to be global. (DLR)
|
no longer needs to be global. (DLR)
|
||||||
|
statusq_abort()
|
||||||
|
- New function to set resetstatuspos to FALSE when we don't
|
||||||
|
properly exit the statusbar prompt, e.g. when we get a file
|
||||||
|
from the file browser). (DLR)
|
||||||
reset_cursor()
|
reset_cursor()
|
||||||
- If this is called before any files have been opened, as it can
|
- If this is called before any files have been opened, as it can
|
||||||
be by statusbar(), put the cursor at the top left corner of
|
be by statusbar(), put the cursor at the top left corner of
|
||||||
|
|
99
src/files.c
99
src/files.c
|
@ -494,15 +494,11 @@ void do_insertfile(
|
||||||
int i;
|
int i;
|
||||||
const char *msg;
|
const char *msg;
|
||||||
char *ans = mallocstrcpy(NULL, "");
|
char *ans = mallocstrcpy(NULL, "");
|
||||||
/* The last answer the user typed on the statusbar. Saved for if
|
/* The last answer the user typed on the statusbar. */
|
||||||
* they do M-F or cancel the file browser. */
|
|
||||||
|
|
||||||
wrap_reset();
|
wrap_reset();
|
||||||
|
|
||||||
#if !defined(DISABLE_BROWSER) || (!defined(NANO_SMALL) && defined(ENABLE_MULTIBUFFER))
|
while (TRUE) {
|
||||||
start_again:
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (execute) {
|
if (execute) {
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
|
@ -540,6 +536,7 @@ void do_insertfile(
|
||||||
|
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
statusbar(_("Cancelled"));
|
statusbar(_("Cancelled"));
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
int old_current_x = current_x;
|
int old_current_x = current_x;
|
||||||
|
|
||||||
|
@ -550,7 +547,7 @@ void do_insertfile(
|
||||||
/* Don't allow toggling if we're in view mode. */
|
/* Don't allow toggling if we're in view mode. */
|
||||||
if (!ISSET(VIEW_MODE))
|
if (!ISSET(VIEW_MODE))
|
||||||
TOGGLE(MULTIBUFFER);
|
TOGGLE(MULTIBUFFER);
|
||||||
goto start_again;
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -558,20 +555,21 @@ void do_insertfile(
|
||||||
if (i == NANO_TOFILES_KEY) {
|
if (i == NANO_TOFILES_KEY) {
|
||||||
char *tmp = do_browse_from(answer);
|
char *tmp = do_browse_from(answer);
|
||||||
|
|
||||||
if (tmp != NULL) {
|
if (tmp == NULL)
|
||||||
|
continue;
|
||||||
free(answer);
|
free(answer);
|
||||||
answer = tmp;
|
answer = tmp;
|
||||||
ans = mallocstrcpy(ans, answer);
|
|
||||||
unget_kbinput(NANO_ENTER_KEY, FALSE);
|
/* We have a file now. Get out of the statusbar prompt
|
||||||
}
|
* cleanly. */
|
||||||
goto start_again;
|
statusq_abort();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (i == NANO_TOOTHERINSERT_KEY) {
|
if (i == NANO_TOOTHERINSERT_KEY) {
|
||||||
execute = !execute;
|
execute = !execute;
|
||||||
goto start_again;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execute)
|
if (execute)
|
||||||
|
@ -604,7 +602,10 @@ void do_insertfile(
|
||||||
|
|
||||||
/* Refresh the screen. */
|
/* Refresh the screen. */
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
} /* while (TRUE) */
|
||||||
|
|
||||||
free(ans);
|
free(ans);
|
||||||
}
|
}
|
||||||
|
@ -1770,7 +1771,9 @@ int write_marked(const char *name, int tmp, int append)
|
||||||
int do_writeout(bool exiting)
|
int do_writeout(bool exiting)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int append = 0;
|
int retval = 0, append = 0;
|
||||||
|
char *ans;
|
||||||
|
/* The last answer the user typed on the statusbar. */
|
||||||
#ifdef NANO_EXTRA
|
#ifdef NANO_EXTRA
|
||||||
static bool did_cred = FALSE;
|
static bool did_cred = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1780,25 +1783,23 @@ int do_writeout(bool exiting)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (exiting && filename[0] != '\0' && ISSET(TEMP_FILE)) {
|
if (exiting && filename[0] != '\0' && ISSET(TEMP_FILE)) {
|
||||||
i = write_file(filename, FALSE, 0, FALSE);
|
retval = write_file(filename, FALSE, 0, FALSE);
|
||||||
if (i == 1) {
|
|
||||||
/* Write succeeded. */
|
/* Write succeeded. */
|
||||||
display_main_list();
|
if (retval == 1)
|
||||||
return 1;
|
return retval;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (ISSET(MARK_ISSET) && !exiting)
|
if (ISSET(MARK_ISSET) && !exiting)
|
||||||
answer = mallocstrcpy(answer, "");
|
ans = mallocstrcpy(NULL, "");
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
answer = mallocstrcpy(answer, filename);
|
ans = mallocstrcpy(NULL, filename);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
char *ans = mallocstrcpy(NULL, answer);
|
|
||||||
const char *formatstr, *backupstr;
|
const char *formatstr, *backupstr;
|
||||||
|
|
||||||
if (ISSET(DOS_FILE))
|
if (ISSET(DOS_FILE))
|
||||||
|
@ -1834,33 +1835,35 @@ int do_writeout(bool exiting)
|
||||||
* and we're at the "Write File" prompt, disable tab
|
* and we're at the "Write File" prompt, disable tab
|
||||||
* completion. */
|
* completion. */
|
||||||
i = statusq(!ISSET(RESTRICTED) || filename[0] == '\0',
|
i = statusq(!ISSET(RESTRICTED) || filename[0] == '\0',
|
||||||
writefile_list,
|
writefile_list, ans,
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
ans, NULL, "%s%s%s", _(msg), formatstr, backupstr
|
NULL, "%s%s%s", _(msg), formatstr, backupstr
|
||||||
#else
|
#else
|
||||||
filename, "%s", _(msg)
|
"%s", _(msg)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
|
||||||
free(ans);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
statusbar(_("Cancelled"));
|
statusbar(_("Cancelled"));
|
||||||
display_main_list();
|
retval = -1;
|
||||||
return -1;
|
break;
|
||||||
}
|
} else {
|
||||||
|
ans = mallocstrcpy(ans, answer);
|
||||||
|
|
||||||
#ifndef DISABLE_BROWSER
|
#ifndef DISABLE_BROWSER
|
||||||
if (i == NANO_TOFILES_KEY) {
|
if (i == NANO_TOFILES_KEY) {
|
||||||
char *tmp = do_browse_from(answer);
|
char *tmp = do_browse_from(answer);
|
||||||
|
|
||||||
currshortcut = writefile_list;
|
currshortcut = writefile_list;
|
||||||
|
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
continue;
|
continue;
|
||||||
free(answer);
|
free(answer);
|
||||||
answer = tmp;
|
answer = tmp;
|
||||||
|
|
||||||
|
/* We have a file now. Get out of the statusbar prompt
|
||||||
|
* cleanly. */
|
||||||
|
statusq_abort();
|
||||||
} else
|
} else
|
||||||
#endif /* !DISABLE_BROWSER */
|
#endif /* !DISABLE_BROWSER */
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
|
@ -1890,11 +1893,12 @@ int do_writeout(bool exiting)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NANO_EXTRA
|
#ifdef NANO_EXTRA
|
||||||
if (exiting && !ISSET(TEMP_FILE) && strcasecmp(answer, "zzy") == 0
|
if (exiting && !ISSET(TEMP_FILE) &&
|
||||||
&& !did_cred) {
|
strcasecmp(answer, "zzy") == 0 && !did_cred) {
|
||||||
do_credits();
|
do_credits();
|
||||||
did_cred = TRUE;
|
did_cred = TRUE;
|
||||||
return -1;
|
retval = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (append == 0 && strcmp(answer, filename) != 0) {
|
if (append == 0 && strcmp(answer, filename) != 0) {
|
||||||
|
@ -1905,8 +1909,8 @@ int do_writeout(bool exiting)
|
||||||
if (i == 0 || i == -1)
|
if (i == 0 || i == -1)
|
||||||
continue;
|
continue;
|
||||||
/* If we're using restricted mode, we aren't allowed to
|
/* If we're using restricted mode, we aren't allowed to
|
||||||
* change the name of a file once it has one because that
|
* change the name of a file once it has one because
|
||||||
* would allow reading from or writing to files not
|
* that would allow reading from or writing to files not
|
||||||
* specified on the command line. In this case, don't
|
* specified on the command line. In this case, don't
|
||||||
* bother showing the "Different Name" prompt. */
|
* bother showing the "Different Name" prompt. */
|
||||||
} else if (!ISSET(RESTRICTED) && filename[0] != '\0'
|
} else if (!ISSET(RESTRICTED) && filename[0] != '\0'
|
||||||
|
@ -1921,15 +1925,15 @@ int do_writeout(bool exiting)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
/* Here's where we allow the selected text to be written to a
|
/* Here's where we allow the selected text to be written to
|
||||||
* separate file. If we're using restricted mode, this is
|
* a separate file. If we're using restricted mode, this is
|
||||||
* disabled since it allows reading from or writing to files not
|
* disabled since it allows reading from or writing to files
|
||||||
* specified on the command line. */
|
* not specified on the command line. */
|
||||||
if (!ISSET(RESTRICTED) && !exiting && ISSET(MARK_ISSET))
|
if (!ISSET(RESTRICTED) && !exiting && ISSET(MARK_ISSET))
|
||||||
i = write_marked(answer, FALSE, append);
|
retval = write_marked(answer, FALSE, append);
|
||||||
else
|
else
|
||||||
#endif /* !NANO_SMALL */
|
#endif /* !NANO_SMALL */
|
||||||
i = write_file(answer, FALSE, append, FALSE);
|
retval = write_file(answer, FALSE, append, FALSE);
|
||||||
|
|
||||||
#ifdef ENABLE_MULTIBUFFER
|
#ifdef ENABLE_MULTIBUFFER
|
||||||
/* If we're not about to exit, update the current entry in
|
/* If we're not about to exit, update the current entry in
|
||||||
|
@ -1937,14 +1941,19 @@ int do_writeout(bool exiting)
|
||||||
if (!exiting)
|
if (!exiting)
|
||||||
add_open_file(TRUE);
|
add_open_file(TRUE);
|
||||||
#endif
|
#endif
|
||||||
display_main_list();
|
|
||||||
return i;
|
break;
|
||||||
|
}
|
||||||
} /* while (TRUE) */
|
} /* while (TRUE) */
|
||||||
|
|
||||||
|
free(ans);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_writeout_void(void)
|
void do_writeout_void(void)
|
||||||
{
|
{
|
||||||
do_writeout(FALSE);
|
do_writeout(FALSE);
|
||||||
|
display_main_list();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a malloc()ed string containing the actual directory, used
|
/* Return a malloc()ed string containing the actual directory, used
|
||||||
|
|
17
src/proto.h
17
src/proto.h
|
@ -551,15 +551,21 @@ void check_statusblank(void);
|
||||||
void blank_bottombars(void);
|
void blank_bottombars(void);
|
||||||
char *display_string(const char *buf, size_t start_col, size_t len);
|
char *display_string(const char *buf, size_t start_col, size_t len);
|
||||||
void nanoget_repaint(const char *buf, const char *inputbuf, size_t x);
|
void nanoget_repaint(const char *buf, const char *inputbuf, size_t x);
|
||||||
int nanogetstr(int allowtabs, const char *buf, const char *def,
|
int nanogetstr(bool allow_tabs, const char *buf, const char *def,
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
historyheadtype *history_list,
|
historyheadtype *history_list,
|
||||||
#endif
|
#endif
|
||||||
const shortcut *s, bool reset_x
|
const shortcut *s
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
, bool *list
|
, bool *list
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
int statusq(bool allow_tabs, const shortcut *s, const char *def,
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
historyheadtype *history_list,
|
||||||
|
#endif
|
||||||
|
const char *msg, ...);
|
||||||
|
void statusq_abort(void);
|
||||||
void titlebar(const char *path);
|
void titlebar(const char *path);
|
||||||
void set_modified(void);
|
void set_modified(void);
|
||||||
void statusbar(const char *msg, ...);
|
void statusbar(const char *msg, ...);
|
||||||
|
@ -579,12 +585,7 @@ void edit_scroll(updown direction, int nlines);
|
||||||
void edit_redraw(const filestruct *old_current, size_t old_pww);
|
void edit_redraw(const filestruct *old_current, size_t old_pww);
|
||||||
void edit_refresh(void);
|
void edit_refresh(void);
|
||||||
void edit_update(topmidnone location);
|
void edit_update(topmidnone location);
|
||||||
int statusq(int allowtabs, const shortcut *s, const char *def,
|
int do_yesno(bool all, const char *msg);
|
||||||
#ifndef NANO_SMALL
|
|
||||||
historyheadtype *history_list,
|
|
||||||
#endif
|
|
||||||
const char *msg, ...);
|
|
||||||
int do_yesno(int all, const char *msg);
|
|
||||||
void total_refresh(void);
|
void total_refresh(void);
|
||||||
void display_main_list(void);
|
void display_main_list(void);
|
||||||
void do_cursorpos(bool constant);
|
void do_cursorpos(bool constant);
|
||||||
|
|
217
src/winio.c
217
src/winio.c
|
@ -33,6 +33,9 @@
|
||||||
static int statusblank = 0; /* Number of keystrokes left after
|
static int statusblank = 0; /* Number of keystrokes left after
|
||||||
* we call statusbar(), before we
|
* we call statusbar(), before we
|
||||||
* actually blank the statusbar. */
|
* actually blank the statusbar. */
|
||||||
|
static bool resetstatuspos = FALSE;
|
||||||
|
/* Should we reset the cursor position
|
||||||
|
* at the statusbar prompt? */
|
||||||
|
|
||||||
/* Control character compatibility:
|
/* Control character compatibility:
|
||||||
*
|
*
|
||||||
|
@ -1755,11 +1758,11 @@ void nanoget_repaint(const char *buf, const char *inputbuf, size_t x)
|
||||||
|
|
||||||
/* Get the input from the keyboard; this should only be called from
|
/* Get the input from the keyboard; this should only be called from
|
||||||
* statusq(). */
|
* statusq(). */
|
||||||
int nanogetstr(int allowtabs, const char *buf, const char *def,
|
int nanogetstr(bool allow_tabs, const char *buf, const char *def,
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
historyheadtype *history_list,
|
historyheadtype *history_list,
|
||||||
#endif
|
#endif
|
||||||
const shortcut *s, bool reset_x
|
const shortcut *s
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
, bool *list
|
, bool *list
|
||||||
#endif
|
#endif
|
||||||
|
@ -1793,11 +1796,11 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||||
xend = strlen(def);
|
xend = strlen(def);
|
||||||
|
|
||||||
/* Only put x at the end of the string if it's uninitialized, if it
|
/* Only put x at the end of the string if it's uninitialized, if it
|
||||||
would be past the end of the string as it is, or if reset_x is
|
would be past the end of the string as it is, or if
|
||||||
TRUE. Otherwise, leave it alone. This is so the cursor position
|
resetstatuspos is TRUE. Otherwise, leave it alone. This is so
|
||||||
stays at the same place if a prompt-changing toggle is
|
the cursor position stays at the same place if a prompt-changing
|
||||||
pressed. */
|
toggle is pressed. */
|
||||||
if (x == -1 || x > xend || reset_x)
|
if (x == -1 || x > xend || resetstatuspos)
|
||||||
x = xend;
|
x = xend;
|
||||||
|
|
||||||
answer = charealloc(answer, xend + 1);
|
answer = charealloc(answer, xend + 1);
|
||||||
|
@ -1944,7 +1947,7 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
if (allowtabs) {
|
if (allow_tabs) {
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
|
|
||||||
answer = input_tab(answer, x, &tabbed, &shift, list);
|
answer = input_tab(answer, x, &tabbed, &shift, list);
|
||||||
|
@ -2090,6 +2093,106 @@ int nanogetstr(int allowtabs, const char *buf, const char *def,
|
||||||
return kbinput;
|
return kbinput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ask a question on the statusbar. Answer will be stored in answer
|
||||||
|
* global. Returns -1 on aborted enter, -2 on a blank string, and 0
|
||||||
|
* otherwise, the valid shortcut key caught. def is any editable text
|
||||||
|
* we want to put up by default.
|
||||||
|
*
|
||||||
|
* New arg tabs tells whether or not to allow tab completion. */
|
||||||
|
int statusq(bool allow_tabs, const shortcut *s, const char *def,
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
historyheadtype *which_history,
|
||||||
|
#endif
|
||||||
|
const char *msg, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
char *foo = charalloc(COLS - 3);
|
||||||
|
int ret;
|
||||||
|
#ifndef DISABLE_TABCOMP
|
||||||
|
bool list = FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bottombars(s);
|
||||||
|
|
||||||
|
va_start(ap, msg);
|
||||||
|
vsnprintf(foo, COLS - 4, msg, ap);
|
||||||
|
va_end(ap);
|
||||||
|
foo[COLS - 4] = '\0';
|
||||||
|
|
||||||
|
ret = nanogetstr(allow_tabs, foo, def,
|
||||||
|
#ifndef NANO_SMALL
|
||||||
|
which_history,
|
||||||
|
#endif
|
||||||
|
s
|
||||||
|
#ifndef DISABLE_TABCOMP
|
||||||
|
, &list
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
free(foo);
|
||||||
|
resetstatuspos = FALSE;
|
||||||
|
|
||||||
|
switch (ret) {
|
||||||
|
case NANO_FIRSTLINE_KEY:
|
||||||
|
case NANO_FIRSTLINE_FKEY:
|
||||||
|
do_first_line();
|
||||||
|
resetstatuspos = TRUE;
|
||||||
|
break;
|
||||||
|
case NANO_LASTLINE_KEY:
|
||||||
|
case NANO_LASTLINE_FKEY:
|
||||||
|
do_last_line();
|
||||||
|
resetstatuspos = TRUE;
|
||||||
|
break;
|
||||||
|
#ifndef DISABLE_JUSTIFY
|
||||||
|
case NANO_PARABEGIN_KEY:
|
||||||
|
case NANO_PARABEGIN_ALTKEY1:
|
||||||
|
case NANO_PARABEGIN_ALTKEY2:
|
||||||
|
do_para_begin();
|
||||||
|
resetstatuspos = TRUE;
|
||||||
|
break;
|
||||||
|
case NANO_PARAEND_KEY:
|
||||||
|
case NANO_PARAEND_ALTKEY1:
|
||||||
|
case NANO_PARAEND_ALTKEY2:
|
||||||
|
do_para_end();
|
||||||
|
resetstatuspos = TRUE;
|
||||||
|
break;
|
||||||
|
case NANO_FULLJUSTIFY_KEY:
|
||||||
|
case NANO_FULLJUSTIFY_ALTKEY:
|
||||||
|
if (!ISSET(VIEW_MODE))
|
||||||
|
do_full_justify();
|
||||||
|
resetstatuspos = TRUE;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case NANO_CANCEL_KEY:
|
||||||
|
ret = -1;
|
||||||
|
resetstatuspos = TRUE;
|
||||||
|
break;
|
||||||
|
case NANO_ENTER_KEY:
|
||||||
|
ret = (answer[0] == '\0') ? -2 : 0;
|
||||||
|
resetstatuspos = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
blank_statusbar();
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "I got \"%s\"\n", answer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DISABLE_TABCOMP
|
||||||
|
/* if we've done tab completion, there might be a list of
|
||||||
|
filename matches on the edit window at this point; make sure
|
||||||
|
they're cleared off. */
|
||||||
|
if (list)
|
||||||
|
edit_refresh();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void statusq_abort(void)
|
||||||
|
{
|
||||||
|
resetstatuspos = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void titlebar(const char *path)
|
void titlebar(const char *path)
|
||||||
{
|
{
|
||||||
size_t space;
|
size_t space;
|
||||||
|
@ -2972,106 +3075,10 @@ void edit_update(topmidnone location)
|
||||||
edit_refresh();
|
edit_refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ask a question on the statusbar. Answer will be stored in answer
|
|
||||||
* global. Returns -1 on aborted enter, -2 on a blank string, and 0
|
|
||||||
* otherwise, the valid shortcut key caught. def is any editable text
|
|
||||||
* we want to put up by default.
|
|
||||||
*
|
|
||||||
* New arg tabs tells whether or not to allow tab completion. */
|
|
||||||
int statusq(int allowtabs, const shortcut *s, const char *def,
|
|
||||||
#ifndef NANO_SMALL
|
|
||||||
historyheadtype *which_history,
|
|
||||||
#endif
|
|
||||||
const char *msg, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
char *foo = charalloc(COLS - 3);
|
|
||||||
int ret;
|
|
||||||
static bool resetstatuspos = FALSE;
|
|
||||||
#ifndef DISABLE_TABCOMP
|
|
||||||
bool list = FALSE;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bottombars(s);
|
|
||||||
|
|
||||||
va_start(ap, msg);
|
|
||||||
vsnprintf(foo, COLS - 4, msg, ap);
|
|
||||||
va_end(ap);
|
|
||||||
foo[COLS - 4] = '\0';
|
|
||||||
|
|
||||||
ret = nanogetstr(allowtabs, foo, def,
|
|
||||||
#ifndef NANO_SMALL
|
|
||||||
which_history,
|
|
||||||
#endif
|
|
||||||
s, resetstatuspos
|
|
||||||
#ifndef DISABLE_TABCOMP
|
|
||||||
, &list
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
free(foo);
|
|
||||||
resetstatuspos = FALSE;
|
|
||||||
|
|
||||||
switch (ret) {
|
|
||||||
case NANO_FIRSTLINE_KEY:
|
|
||||||
case NANO_FIRSTLINE_FKEY:
|
|
||||||
do_first_line();
|
|
||||||
resetstatuspos = TRUE;
|
|
||||||
break;
|
|
||||||
case NANO_LASTLINE_KEY:
|
|
||||||
case NANO_LASTLINE_FKEY:
|
|
||||||
do_last_line();
|
|
||||||
resetstatuspos = TRUE;
|
|
||||||
break;
|
|
||||||
#ifndef DISABLE_JUSTIFY
|
|
||||||
case NANO_PARABEGIN_KEY:
|
|
||||||
case NANO_PARABEGIN_ALTKEY1:
|
|
||||||
case NANO_PARABEGIN_ALTKEY2:
|
|
||||||
do_para_begin();
|
|
||||||
resetstatuspos = TRUE;
|
|
||||||
break;
|
|
||||||
case NANO_PARAEND_KEY:
|
|
||||||
case NANO_PARAEND_ALTKEY1:
|
|
||||||
case NANO_PARAEND_ALTKEY2:
|
|
||||||
do_para_end();
|
|
||||||
resetstatuspos = TRUE;
|
|
||||||
break;
|
|
||||||
case NANO_FULLJUSTIFY_KEY:
|
|
||||||
case NANO_FULLJUSTIFY_ALTKEY:
|
|
||||||
if (!ISSET(VIEW_MODE))
|
|
||||||
do_full_justify();
|
|
||||||
resetstatuspos = TRUE;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case NANO_CANCEL_KEY:
|
|
||||||
ret = -1;
|
|
||||||
resetstatuspos = TRUE;
|
|
||||||
break;
|
|
||||||
case NANO_ENTER_KEY:
|
|
||||||
ret = (answer[0] == '\0') ? -2 : 0;
|
|
||||||
resetstatuspos = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
blank_statusbar();
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stderr, "I got \"%s\"\n", answer);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DISABLE_TABCOMP
|
|
||||||
/* if we've done tab completion, there might be a list of
|
|
||||||
filename matches on the edit window at this point; make sure
|
|
||||||
they're cleared off. */
|
|
||||||
if (list)
|
|
||||||
edit_refresh();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ask a simple yes/no question, specified in msg, on the statusbar.
|
/* Ask a simple yes/no question, specified in msg, on the statusbar.
|
||||||
* Return 1 for Y, 0 for N, 2 for All (if all is TRUE when passed in)
|
* Return 1 for Y, 0 for N, 2 for All (if all is TRUE when passed in)
|
||||||
* and -1 for abort (^C). */
|
* and -1 for abort (^C). */
|
||||||
int do_yesno(int all, const char *msg)
|
int do_yesno(bool all, const char *msg)
|
||||||
{
|
{
|
||||||
int ok = -2, width = 16;
|
int ok = -2, width = 16;
|
||||||
const char *yesstr; /* String of yes characters accepted. */
|
const char *yesstr; /* String of yes characters accepted. */
|
||||||
|
|
Loading…
Reference in New Issue