num_of_digits()
- Use a size_t instead of an int, and rename to digits(). (DLR)
- 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()
- Rename variable which_history to history_list, for
consistency. (DLR)
+ - Rename variables def and ret to curranswer and retval to avoid
+ confusion. (DLR)
do_help()
- Don't treat NANO_CANCEL_KEY as NANO_EXIT_KEY anymore, for
consistency. (DLR)
char *display_string(const char *buf, size_t start_col, size_t len, bool
dollars);
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
historyheadtype *history_list,
#endif
, bool *list
#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
historyheadtype *history_list,
#endif
/* Get the input from the keyboard; this should only be called from
* 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
historyheadtype *history_list,
#endif
{
int kbinput;
bool meta_key, func_key, s_or_t, ran_func, finished;
+ size_t answer_len = strlen(curranswer);
+#ifndef DISABLE_TABCOMP
bool tabbed = FALSE;
/* Used by input_tab(). */
- size_t answer_len = strlen(def);
+#endif
#ifndef NANO_SMALL
/* For history. */
resetstatuspos)
statusbar_x = answer_len;
- answer = charealloc(answer, answer_len + 1);
- if (answer_len > 0)
- strcpy(answer, def);
- else
- answer[0] = '\0';
+ answer = mallocstrcpy(answer, curranswer);
currshortcut = s;
assert(statusbar_x <= answer_len && answer_len == strlen(answer));
+#ifndef DISABLE_TABCOMP
if (kbinput != NANO_TAB_KEY)
tabbed = FALSE;
+#endif
switch (kbinput) {
case NANO_TAB_KEY:
/* 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.
+ * otherwise, the valid shortcut key caught. curranswer is any editable
+ * text that we want to put up by default.
*
* The allow_tabs parameter tells whether or not to allow tab
* 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
historyheadtype *history_list,
#endif
{
va_list ap;
char *foo = charalloc(((COLS - 4) * mb_cur_max()) + 1);
- int ret;
+ int retval;
#ifndef DISABLE_TABCOMP
bool list = FALSE;
#endif
va_end(ap);
null_at(&foo, actual_x(foo, COLS - 4));
- ret = nanogetstr(allow_tabs, foo, def,
+ retval = nanogetstr(allow_tabs, foo, curranswer,
#ifndef NANO_SMALL
history_list,
#endif
free(foo);
resetstatuspos = FALSE;
- switch (ret) {
+ switch (retval) {
case NANO_CANCEL_KEY:
- ret = -1;
+ retval = -1;
resetstatuspos = TRUE;
break;
case NANO_ENTER_KEY:
- ret = (answer[0] == '\0') ? -2 : 0;
+ retval = (answer[0] == '\0') ? -2 : 0;
resetstatuspos = TRUE;
break;
}
+
blank_statusbar();
#ifdef DEBUG
edit_refresh();
#endif
- return ret;
+ return retval;
}
void statusq_abort(void)