various minor fixes

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2528 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-05-20 02:57:05 +00:00
parent 5754201944
commit 6f25a67833
3 changed files with 25 additions and 18 deletions

View File

@ -71,9 +71,15 @@ CVS code -
num_of_digits() num_of_digits()
- Use a size_t instead of an int, and rename to digits(). (DLR) - Use a size_t instead of an int, and rename to digits(). (DLR)
- winio.c: - winio.c:
nanogetstr()
- Rename variable def to curranswer to avoid confusion. (DLR)
- Only declare and use the tabbed variable if DISABLE_TABCOMP
isn't defined. (DLR)
statusq() statusq()
- Rename variable which_history to history_list, for - Rename variable which_history to history_list, for
consistency. (DLR) consistency. (DLR)
- Rename variables def and ret to curranswer and retval to avoid
confusion. (DLR)
do_help() do_help()
- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for - Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
consistency. (DLR) consistency. (DLR)

View File

@ -650,7 +650,7 @@ void check_statusblank(void);
char *display_string(const char *buf, size_t start_col, size_t len, bool char *display_string(const char *buf, size_t start_col, size_t len, bool
dollars); dollars);
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(bool allow_tabs, const char *buf, const char *def, int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
#ifndef NANO_SMALL #ifndef NANO_SMALL
historyheadtype *history_list, historyheadtype *history_list,
#endif #endif
@ -659,7 +659,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
, bool *list , bool *list
#endif #endif
); );
int statusq(bool allow_tabs, const shortcut *s, const char *def, int statusq(bool allow_tabs, const shortcut *s, const char *curranswer,
#ifndef NANO_SMALL #ifndef NANO_SMALL
historyheadtype *history_list, historyheadtype *history_list,
#endif #endif

View File

@ -2428,7 +2428,7 @@ 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(bool allow_tabs, const char *buf, const char *def, int nanogetstr(bool allow_tabs, const char *buf, const char *curranswer,
#ifndef NANO_SMALL #ifndef NANO_SMALL
historyheadtype *history_list, historyheadtype *history_list,
#endif #endif
@ -2440,9 +2440,11 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
{ {
int kbinput; int kbinput;
bool meta_key, func_key, s_or_t, ran_func, finished; bool meta_key, func_key, s_or_t, ran_func, finished;
size_t answer_len = strlen(curranswer);
#ifndef DISABLE_TABCOMP
bool tabbed = FALSE; bool tabbed = FALSE;
/* Used by input_tab(). */ /* Used by input_tab(). */
size_t answer_len = strlen(def); #endif
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* For history. */ /* For history. */
@ -2469,11 +2471,7 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
resetstatuspos) resetstatuspos)
statusbar_x = answer_len; statusbar_x = answer_len;
answer = charealloc(answer, answer_len + 1); answer = mallocstrcpy(answer, curranswer);
if (answer_len > 0)
strcpy(answer, def);
else
answer[0] = '\0';
currshortcut = s; currshortcut = s;
@ -2495,8 +2493,10 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
assert(statusbar_x <= answer_len && answer_len == strlen(answer)); assert(statusbar_x <= answer_len && answer_len == strlen(answer));
#ifndef DISABLE_TABCOMP
if (kbinput != NANO_TAB_KEY) if (kbinput != NANO_TAB_KEY)
tabbed = FALSE; tabbed = FALSE;
#endif
switch (kbinput) { switch (kbinput) {
case NANO_TAB_KEY: case NANO_TAB_KEY:
@ -2646,12 +2646,12 @@ int nanogetstr(bool allow_tabs, const char *buf, const char *def,
/* Ask a question on the statusbar. Answer will be stored in answer /* 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 * global. Returns -1 on aborted enter, -2 on a blank string, and 0
* otherwise, the valid shortcut key caught. def is any editable text * otherwise, the valid shortcut key caught. curranswer is any editable
* we want to put up by default. * text that we want to put up by default.
* *
* The allow_tabs parameter tells whether or not to allow tab * The allow_tabs parameter tells whether or not to allow tab
* completion. */ * completion. */
int statusq(bool allow_tabs, const shortcut *s, const char *def, int statusq(bool allow_tabs, const shortcut *s, const char *curranswer,
#ifndef NANO_SMALL #ifndef NANO_SMALL
historyheadtype *history_list, historyheadtype *history_list,
#endif #endif
@ -2659,7 +2659,7 @@ int statusq(bool allow_tabs, const shortcut *s, const char *def,
{ {
va_list ap; va_list ap;
char *foo = charalloc(((COLS - 4) * mb_cur_max()) + 1); char *foo = charalloc(((COLS - 4) * mb_cur_max()) + 1);
int ret; int retval;
#ifndef DISABLE_TABCOMP #ifndef DISABLE_TABCOMP
bool list = FALSE; bool list = FALSE;
#endif #endif
@ -2671,7 +2671,7 @@ int statusq(bool allow_tabs, const shortcut *s, const char *def,
va_end(ap); va_end(ap);
null_at(&foo, actual_x(foo, COLS - 4)); null_at(&foo, actual_x(foo, COLS - 4));
ret = nanogetstr(allow_tabs, foo, def, retval = nanogetstr(allow_tabs, foo, curranswer,
#ifndef NANO_SMALL #ifndef NANO_SMALL
history_list, history_list,
#endif #endif
@ -2683,16 +2683,17 @@ int statusq(bool allow_tabs, const shortcut *s, const char *def,
free(foo); free(foo);
resetstatuspos = FALSE; resetstatuspos = FALSE;
switch (ret) { switch (retval) {
case NANO_CANCEL_KEY: case NANO_CANCEL_KEY:
ret = -1; retval = -1;
resetstatuspos = TRUE; resetstatuspos = TRUE;
break; break;
case NANO_ENTER_KEY: case NANO_ENTER_KEY:
ret = (answer[0] == '\0') ? -2 : 0; retval = (answer[0] == '\0') ? -2 : 0;
resetstatuspos = TRUE; resetstatuspos = TRUE;
break; break;
} }
blank_statusbar(); blank_statusbar();
#ifdef DEBUG #ifdef DEBUG
@ -2707,7 +2708,7 @@ int statusq(bool allow_tabs, const shortcut *s, const char *def,
edit_refresh(); edit_refresh();
#endif #endif
return ret; return retval;
} }
void statusq_abort(void) void statusq_abort(void)