make sure browser_refresh() is used when refreshing or doing tab
completion at the prompt in the file browser git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3296 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
1f907c7413
Коммит
6816007242
14
ChangeLog
14
ChangeLog
@ -18,12 +18,14 @@ CVS code -
|
|||||||
New function parse_browser_input(); changes to do_browser().
|
New function parse_browser_input(); changes to do_browser().
|
||||||
(DLR)
|
(DLR)
|
||||||
- Allow tab completion of directories at the "Go To Directory"
|
- Allow tab completion of directories at the "Go To Directory"
|
||||||
prompt. Changes to do_browser(), do_insertfile(),
|
prompt. Also, move the browser drawing routines to a separate
|
||||||
do_writeout(), cwd_tab_completion(), input_tab(),
|
function, and make sure it's used when refreshing or doing tab
|
||||||
get_prompt_string(), do_prompt(), search_init(), do_replace(),
|
completion at the prompt in the file browser. New function
|
||||||
do_gotolinecolumn(), and do_int_spell_fix. (DLR)
|
browser_refresh(); changes to do_browser(), browser_init(),
|
||||||
- Move the browser drawing routines to a separate function. New
|
do_insertfile(), do_writeout(), cwd_tab_completion(),
|
||||||
function browser_refresh(); changes to do_browser(). (DLR)
|
input_tab(), do_statusbar_input(), get_prompt_string(),
|
||||||
|
do_prompt(), search_init(), do_replace(), do_gotolinecolumn(),
|
||||||
|
and do_int_spell_fix(). (DLR)
|
||||||
- browser.c:
|
- browser.c:
|
||||||
do_browser()
|
do_browser()
|
||||||
- Properly set currshortcut back to the file browser shortcut
|
- Properly set currshortcut back to the file browser shortcut
|
||||||
|
186
src/browser.c
186
src/browser.c
@ -30,17 +30,27 @@
|
|||||||
|
|
||||||
#ifndef DISABLE_BROWSER
|
#ifndef DISABLE_BROWSER
|
||||||
|
|
||||||
|
static char **filelist = NULL;
|
||||||
|
/* The list of files to display in the browser. */
|
||||||
|
static size_t filelist_len = 0;
|
||||||
|
/* The number of files in the list. */
|
||||||
|
static int width = 0;
|
||||||
|
/* The number of columns to display the list in. */
|
||||||
|
static int longest = 0;
|
||||||
|
/* The number of columns in the longest filename in the list. */
|
||||||
|
static int selected = 0;
|
||||||
|
/* The currently selected filename in the list. */
|
||||||
|
|
||||||
/* Our browser function. path is the path to start browsing from.
|
/* Our browser function. path is the path to start browsing from.
|
||||||
* Assume path has already been tilde-expanded. */
|
* Assume path has already been tilde-expanded. */
|
||||||
char *do_browser(char *path, DIR *dir)
|
char *do_browser(char *path, DIR *dir)
|
||||||
{
|
{
|
||||||
int kbinput, width, longest, selected;
|
int kbinput;
|
||||||
bool meta_key, func_key;
|
bool meta_key, func_key;
|
||||||
bool old_const_update = ISSET(CONST_UPDATE);
|
bool old_const_update = ISSET(CONST_UPDATE);
|
||||||
char *ans = mallocstrcpy(NULL, "");
|
char *ans = mallocstrcpy(NULL, "");
|
||||||
/* The last answer the user typed on the statusbar. */
|
/* The last answer the user typed on the statusbar. */
|
||||||
size_t numents;
|
char *retval = NULL;
|
||||||
char **filelist, *retval = NULL;
|
|
||||||
|
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
blank_statusbar();
|
blank_statusbar();
|
||||||
@ -67,12 +77,12 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
assert(path != NULL && path[strlen(path) - 1] == '/');
|
assert(path != NULL && path[strlen(path) - 1] == '/');
|
||||||
|
|
||||||
/* Get the list of files. */
|
/* Get the list of files. */
|
||||||
filelist = browser_init(path, &longest, &numents, dir);
|
browser_init(path, dir);
|
||||||
|
|
||||||
assert(filelist != NULL);
|
assert(filelist != NULL);
|
||||||
|
|
||||||
/* Sort the list. */
|
/* Sort the list. */
|
||||||
qsort(filelist, numents, sizeof(char *), diralphasort);
|
qsort(filelist, filelist_len, sizeof(char *), diralphasort);
|
||||||
|
|
||||||
titlebar(path);
|
titlebar(path);
|
||||||
|
|
||||||
@ -89,7 +99,7 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
check_statusblank();
|
check_statusblank();
|
||||||
|
|
||||||
/* Compute the line number we're on now, so that we don't divide
|
/* Compute the line number we're on now, so that we don't divide
|
||||||
* by zero later. */
|
* by 0. */
|
||||||
fileline = selected;
|
fileline = selected;
|
||||||
if (width != 0)
|
if (width != 0)
|
||||||
fileline /= width;
|
fileline /= width;
|
||||||
@ -122,8 +132,8 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
/* If we're off the screen, reset to the last item.
|
/* If we're off the screen, reset to the last item.
|
||||||
* If we clicked the same place as last time, select
|
* If we clicked the same place as last time, select
|
||||||
* this name! */
|
* this name! */
|
||||||
if (selected > numents - 1)
|
if (selected > filelist_len - 1)
|
||||||
selected = numents - 1;
|
selected = filelist_len - 1;
|
||||||
else if (old_selected == selected)
|
else if (old_selected == selected)
|
||||||
/* Put back the "Select" key, so that the file
|
/* Put back the "Select" key, so that the file
|
||||||
* is selected. */
|
* is selected. */
|
||||||
@ -149,12 +159,12 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NANO_NEXTLINE_KEY:
|
case NANO_NEXTLINE_KEY:
|
||||||
if (selected + width <= numents - 1)
|
if (selected + width <= filelist_len - 1)
|
||||||
selected += width;
|
selected += width;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NANO_FORWARD_KEY:
|
case NANO_FORWARD_KEY:
|
||||||
if (selected < numents - 1)
|
if (selected < filelist_len - 1)
|
||||||
selected++;
|
selected++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -170,8 +180,8 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
case NANO_NEXTPAGE_KEY:
|
case NANO_NEXTPAGE_KEY:
|
||||||
selected += (editwinrows - fileline % editwinrows) *
|
selected += (editwinrows - fileline % editwinrows) *
|
||||||
width;
|
width;
|
||||||
if (selected >= numents)
|
if (selected >= filelist_len)
|
||||||
selected = numents - 1;
|
selected = filelist_len - 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NANO_HELP_KEY:
|
case NANO_HELP_KEY:
|
||||||
@ -232,7 +242,7 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
path = mallocstrcpy(path, filelist[selected]);
|
path = mallocstrcpy(path, filelist[selected]);
|
||||||
|
|
||||||
/* Start over again with the new path value. */
|
/* Start over again with the new path value. */
|
||||||
free_chararray(filelist, numents);
|
free_chararray(filelist, filelist_len);
|
||||||
goto change_browser_directory;
|
goto change_browser_directory;
|
||||||
|
|
||||||
/* Redraw the screen. */
|
/* Redraw the screen. */
|
||||||
@ -252,7 +262,7 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
_("Go To Directory"));
|
browser_refresh, _("Go To Directory"));
|
||||||
|
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
#if !defined(DISABLE_HELP) || !defined(DISABLE_MOUSE)
|
||||||
@ -312,7 +322,7 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
/* Start over again with the new path value. */
|
/* Start over again with the new path value. */
|
||||||
free(path);
|
free(path);
|
||||||
path = new_path;
|
path = new_path;
|
||||||
free_chararray(filelist, numents);
|
free_chararray(filelist, filelist_len);
|
||||||
goto change_browser_directory;
|
goto change_browser_directory;
|
||||||
|
|
||||||
/* Abort the browser. */
|
/* Abort the browser. */
|
||||||
@ -324,7 +334,7 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
if (abort)
|
if (abort)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
browser_refresh(&width, longest, selected, filelist, numents);
|
browser_refresh();
|
||||||
|
|
||||||
kbinput = get_kbinput(edit, &meta_key, &func_key);
|
kbinput = get_kbinput(edit, &meta_key, &func_key);
|
||||||
parse_browser_input(&kbinput, &meta_key, &func_key);
|
parse_browser_input(&kbinput, &meta_key, &func_key);
|
||||||
@ -340,73 +350,11 @@ char *do_browser(char *path, DIR *dir)
|
|||||||
/* Clean up. */
|
/* Clean up. */
|
||||||
free(path);
|
free(path);
|
||||||
free(ans);
|
free(ans);
|
||||||
free_chararray(filelist, numents);
|
free_chararray(filelist, filelist_len);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a list of files contained in the directory path. *longest is
|
|
||||||
* the maximum display length of a file, up to COLS - 1 (but at least
|
|
||||||
* 7). *numents is the number of files. We assume path exists and is a
|
|
||||||
* directory. If neither is true, we return NULL. */
|
|
||||||
char **browser_init(const char *path, int *longest, size_t *numents, DIR
|
|
||||||
*dir)
|
|
||||||
{
|
|
||||||
const struct dirent *nextdir;
|
|
||||||
char **filelist;
|
|
||||||
size_t i = 0, path_len;
|
|
||||||
|
|
||||||
assert(dir != NULL);
|
|
||||||
|
|
||||||
*longest = 0;
|
|
||||||
|
|
||||||
while ((nextdir = readdir(dir)) != NULL) {
|
|
||||||
size_t dlen;
|
|
||||||
|
|
||||||
/* Don't show the "." entry. */
|
|
||||||
if (strcmp(nextdir->d_name, ".") == 0)
|
|
||||||
continue;
|
|
||||||
i++;
|
|
||||||
|
|
||||||
dlen = strlenpt(nextdir->d_name);
|
|
||||||
if (dlen > *longest)
|
|
||||||
*longest = (dlen > COLS - 1) ? COLS - 1 : dlen;
|
|
||||||
}
|
|
||||||
|
|
||||||
*numents = i;
|
|
||||||
rewinddir(dir);
|
|
||||||
*longest += 10;
|
|
||||||
|
|
||||||
filelist = (char **)nmalloc(*numents * sizeof(char *));
|
|
||||||
|
|
||||||
path_len = strlen(path);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
while ((nextdir = readdir(dir)) != NULL && i < *numents) {
|
|
||||||
/* Don't show the "." entry. */
|
|
||||||
if (strcmp(nextdir->d_name, ".") == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
filelist[i] = charalloc(path_len + strlen(nextdir->d_name) + 1);
|
|
||||||
sprintf(filelist[i], "%s%s", path, nextdir->d_name);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Maybe the number of files in the directory changed between the
|
|
||||||
* first time we scanned and the second. i is the actual length of
|
|
||||||
* filelist, so record it. */
|
|
||||||
*numents = i;
|
|
||||||
closedir(dir);
|
|
||||||
|
|
||||||
if (*longest > COLS - 1)
|
|
||||||
*longest = COLS - 1;
|
|
||||||
if (*longest < 7)
|
|
||||||
*longest = 7;
|
|
||||||
|
|
||||||
return filelist;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The file browser front end. We check to see if inpath has a dir in
|
/* The file browser front end. We check to see if inpath has a dir in
|
||||||
* it. If it does, we start do_browser() from there. Otherwise, we
|
* it. If it does, we start do_browser() from there. Otherwise, we
|
||||||
* start do_browser() from the current directory. */
|
* start do_browser() from the current directory. */
|
||||||
@ -462,6 +410,64 @@ char *do_browse_from(const char *inpath)
|
|||||||
return do_browser(path, dir);
|
return do_browser(path, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set filelist to the list of files contained in the directory path,
|
||||||
|
* set filelist_len to the number of files in that list, and set longest
|
||||||
|
* to the width in columns of the longest filename in that list, up to
|
||||||
|
* COLS - 1 (but at least 7). Assume path exists and is a directory. */
|
||||||
|
void browser_init(const char *path, DIR *dir)
|
||||||
|
{
|
||||||
|
const struct dirent *nextdir;
|
||||||
|
size_t i = 0, path_len;
|
||||||
|
|
||||||
|
assert(dir != NULL);
|
||||||
|
|
||||||
|
longest = 0;
|
||||||
|
|
||||||
|
while ((nextdir = readdir(dir)) != NULL) {
|
||||||
|
size_t d_len;
|
||||||
|
|
||||||
|
/* Don't show the "." entry. */
|
||||||
|
if (strcmp(nextdir->d_name, ".") == 0)
|
||||||
|
continue;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
d_len = strlenpt(nextdir->d_name);
|
||||||
|
if (d_len > longest)
|
||||||
|
longest = (d_len > COLS - 1) ? COLS - 1 : d_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
filelist_len = i;
|
||||||
|
rewinddir(dir);
|
||||||
|
longest += 10;
|
||||||
|
|
||||||
|
filelist = (char **)nmalloc(filelist_len * sizeof(char *));
|
||||||
|
|
||||||
|
path_len = strlen(path);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
while ((nextdir = readdir(dir)) != NULL && i < filelist_len) {
|
||||||
|
/* Don't show the "." entry. */
|
||||||
|
if (strcmp(nextdir->d_name, ".") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
filelist[i] = charalloc(path_len + strlen(nextdir->d_name) + 1);
|
||||||
|
sprintf(filelist[i], "%s%s", path, nextdir->d_name);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Maybe the number of files in the directory changed between the
|
||||||
|
* first time we scanned and the second. i is the actual length of
|
||||||
|
* filelist, so record it. */
|
||||||
|
filelist_len = i;
|
||||||
|
closedir(dir);
|
||||||
|
|
||||||
|
if (longest > COLS - 1)
|
||||||
|
longest = COLS - 1;
|
||||||
|
if (longest < 7)
|
||||||
|
longest = 7;
|
||||||
|
}
|
||||||
|
|
||||||
/* Determine the shortcut key corresponding to the values of kbinput
|
/* Determine the shortcut key corresponding to the values of kbinput
|
||||||
* (the key itself), meta_key (whether the key is a meta sequence), and
|
* (the key itself), meta_key (whether the key is a meta sequence), and
|
||||||
* func_key (whether the key is a function key), if any. In the
|
* func_key (whether the key is a function key), if any. In the
|
||||||
@ -499,13 +505,10 @@ void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display the list of files in the array filelist with the size
|
/* Calculate the number of columns needed to display the list of files
|
||||||
* numents. width is the number of columns in the list, which we
|
* in the array filelist, if necessary, and then display the list of
|
||||||
* calculate and return. longest is the length of the longest filename,
|
* files. */
|
||||||
* and hence the width of each column of the list. selected is the
|
void browser_refresh(void)
|
||||||
* filename that is currently selected. */
|
|
||||||
void browser_refresh(int *width, int longest, int selected, char
|
|
||||||
**filelist, size_t numents)
|
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
int i;
|
int i;
|
||||||
@ -515,14 +518,14 @@ void browser_refresh(int *width, int longest, int selected, char
|
|||||||
|
|
||||||
assert(width != NULL);
|
assert(width != NULL);
|
||||||
|
|
||||||
i = (*width != 0) ? *width * editwinrows * ((selected / *width) /
|
i = (width != 0) ? width * editwinrows * ((selected / width) /
|
||||||
editwinrows) : 0;
|
editwinrows) : 0;
|
||||||
|
|
||||||
blank_edit();
|
blank_edit();
|
||||||
|
|
||||||
wmove(edit, 0, 0);
|
wmove(edit, 0, 0);
|
||||||
|
|
||||||
for (; i < numents && editline <= editwinrows - 1; i++) {
|
for (; i < filelist_len && editline <= editwinrows - 1; i++) {
|
||||||
char *disp = display_string(tail(filelist[i]), 0, longest,
|
char *disp = display_string(tail(filelist[i]), 0, longest,
|
||||||
FALSE);
|
FALSE);
|
||||||
|
|
||||||
@ -575,8 +578,11 @@ void browser_refresh(int *width, int longest, int selected, char
|
|||||||
if (col > COLS - longest) {
|
if (col > COLS - longest) {
|
||||||
editline++;
|
editline++;
|
||||||
col = 0;
|
col = 0;
|
||||||
if (*width == 0)
|
|
||||||
*width = filecols;
|
/* Set the number of columns to display the list in, if
|
||||||
|
* necessary, so that we don't divide by 0. */
|
||||||
|
if (width == 0)
|
||||||
|
width = filecols;
|
||||||
}
|
}
|
||||||
|
|
||||||
wmove(edit, editline, col);
|
wmove(edit, editline, col);
|
||||||
|
19
src/files.c
19
src/files.c
@ -723,7 +723,7 @@ void do_insertfile(
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
_(msg),
|
edit_refresh, _(msg),
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
operating_dir != NULL && strcmp(operating_dir, ".") != 0 ?
|
operating_dir != NULL && strcmp(operating_dir, ".") != 0 ?
|
||||||
operating_dir :
|
operating_dir :
|
||||||
@ -1761,9 +1761,13 @@ int do_writeout(bool exiting)
|
|||||||
#endif
|
#endif
|
||||||
writefile_list, ans,
|
writefile_list, ans,
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
NULL, "%s%s%s", _(msg), formatstr, backupstr
|
NULL,
|
||||||
|
#endif
|
||||||
|
edit_refresh, "%s%s%s", _(msg),
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
formatstr, backupstr
|
||||||
#else
|
#else
|
||||||
"%s", _(msg)
|
"", ""
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2127,14 +2131,15 @@ char **cwd_tab_completion(const char *buf, bool allow_files, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Do tab completion. place refers to how much the statusbar cursor
|
/* Do tab completion. place refers to how much the statusbar cursor
|
||||||
* position should be advanced. */
|
* position should be advanced. refresh_func is the function we will
|
||||||
|
* call to refresh the edit window. */
|
||||||
char *input_tab(char *buf, bool allow_files, size_t *place, bool
|
char *input_tab(char *buf, bool allow_files, size_t *place, bool
|
||||||
*lastwastab, bool *list)
|
*lastwastab, void (*refresh_func)(void), bool *list)
|
||||||
{
|
{
|
||||||
size_t num_matches = 0;
|
size_t num_matches = 0;
|
||||||
char **matches = NULL;
|
char **matches = NULL;
|
||||||
|
|
||||||
assert(buf != NULL && place != NULL && *place <= strlen(buf) && lastwastab != NULL && list != NULL);
|
assert(buf != NULL && place != NULL && *place <= strlen(buf) && lastwastab != NULL && refresh_func != NULL && list != NULL);
|
||||||
|
|
||||||
*list = FALSE;
|
*list = FALSE;
|
||||||
|
|
||||||
@ -2292,7 +2297,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place, bool
|
|||||||
/* Only refresh the edit window if we don't have a list of filename
|
/* Only refresh the edit window if we don't have a list of filename
|
||||||
* matches on it. */
|
* matches on it. */
|
||||||
if (*list == FALSE)
|
if (*list == FALSE)
|
||||||
edit_refresh();
|
refresh_func();
|
||||||
|
|
||||||
/* Enable el cursor. */
|
/* Enable el cursor. */
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
|
26
src/prompt.c
26
src/prompt.c
@ -46,9 +46,11 @@ static bool reset_statusbar_x = FALSE;
|
|||||||
* shortcut key, and set finished to TRUE if we're done after running
|
* shortcut key, and set finished to TRUE if we're done after running
|
||||||
* or trying to run a function associated with a shortcut key. If
|
* or trying to run a function associated with a shortcut key. If
|
||||||
* allow_funcs is FALSE, don't actually run any functions associated
|
* allow_funcs is FALSE, don't actually run any functions associated
|
||||||
* with shortcut keys. */
|
* with shortcut keys. refresh_func is the function we will call to
|
||||||
|
* refresh the edit window. */
|
||||||
int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
|
int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
|
||||||
bool *ran_func, bool *finished, bool allow_funcs)
|
bool *ran_func, bool *finished, bool allow_funcs, void
|
||||||
|
(*refresh_func)(void))
|
||||||
{
|
{
|
||||||
int input;
|
int input;
|
||||||
/* The character we read in. */
|
/* The character we read in. */
|
||||||
@ -153,7 +155,7 @@ int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
|
|||||||
switch (input) {
|
switch (input) {
|
||||||
/* Handle the "universal" statusbar prompt shortcuts. */
|
/* Handle the "universal" statusbar prompt shortcuts. */
|
||||||
case NANO_REFRESH_KEY:
|
case NANO_REFRESH_KEY:
|
||||||
total_refresh();
|
refresh_func();
|
||||||
break;
|
break;
|
||||||
case NANO_HOME_KEY:
|
case NANO_HOME_KEY:
|
||||||
do_statusbar_home();
|
do_statusbar_home();
|
||||||
@ -905,7 +907,7 @@ int get_prompt_string(bool allow_tabs,
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
filestruct **history_list,
|
filestruct **history_list,
|
||||||
#endif
|
#endif
|
||||||
const shortcut *s
|
void (*refresh_func)(void), const shortcut *s
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
, bool *list
|
, bool *list
|
||||||
#endif
|
#endif
|
||||||
@ -962,8 +964,8 @@ int get_prompt_string(bool allow_tabs,
|
|||||||
* disable all keys that would change the text if the filename isn't
|
* disable all keys that would change the text if the filename isn't
|
||||||
* blank and we're at the "Write File" prompt. */
|
* blank and we're at the "Write File" prompt. */
|
||||||
while ((kbinput = do_statusbar_input(&meta_key, &func_key, &s_or_t,
|
while ((kbinput = do_statusbar_input(&meta_key, &func_key, &s_or_t,
|
||||||
&ran_func, &finished, TRUE)) != NANO_CANCEL_KEY && kbinput !=
|
&ran_func, &finished, TRUE, refresh_func)) != NANO_CANCEL_KEY &&
|
||||||
NANO_ENTER_KEY) {
|
kbinput != NANO_ENTER_KEY) {
|
||||||
assert(statusbar_x <= strlen(answer));
|
assert(statusbar_x <= strlen(answer));
|
||||||
|
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
@ -989,7 +991,7 @@ int get_prompt_string(bool allow_tabs,
|
|||||||
#endif /* !NANO_TINY */
|
#endif /* !NANO_TINY */
|
||||||
if (allow_tabs)
|
if (allow_tabs)
|
||||||
answer = input_tab(answer, allow_files,
|
answer = input_tab(answer, allow_files,
|
||||||
&statusbar_x, &tabbed, list);
|
&statusbar_x, &tabbed, refresh_func, list);
|
||||||
|
|
||||||
update_statusbar_line(answer, statusbar_x);
|
update_statusbar_line(answer, statusbar_x);
|
||||||
break;
|
break;
|
||||||
@ -1101,7 +1103,9 @@ int get_prompt_string(bool allow_tabs,
|
|||||||
* static prompt, which should be NULL initially, and the answer will be
|
* static prompt, which should be NULL initially, and the answer will be
|
||||||
* stored in the answer global. Returns -1 on aborted enter, -2 on a
|
* stored in the answer global. Returns -1 on aborted enter, -2 on a
|
||||||
* blank string, and 0 otherwise, the valid shortcut key caught.
|
* blank string, and 0 otherwise, the valid shortcut key caught.
|
||||||
* curranswer is any editable text that we want to put up by default.
|
* curranswer is any editable text that we want to put up by default,
|
||||||
|
* and refresh_func is the function we want to call to refresh the edit
|
||||||
|
* window.
|
||||||
*
|
*
|
||||||
* The allow_tabs parameter indicates whether we should allow tabs to be
|
* The allow_tabs parameter indicates whether we should allow tabs to be
|
||||||
* interpreted. The allow_files parameter indicates whether we should
|
* interpreted. The allow_files parameter indicates whether we should
|
||||||
@ -1115,7 +1119,7 @@ int do_prompt(bool allow_tabs,
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
filestruct **history_list,
|
filestruct **history_list,
|
||||||
#endif
|
#endif
|
||||||
const char *msg, ...)
|
void (*refresh_func)(void), const char *msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int retval;
|
int retval;
|
||||||
@ -1145,7 +1149,7 @@ int do_prompt(bool allow_tabs,
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
history_list,
|
history_list,
|
||||||
#endif
|
#endif
|
||||||
s
|
refresh_func, s
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
, &list
|
, &list
|
||||||
#endif
|
#endif
|
||||||
@ -1179,7 +1183,7 @@ int do_prompt(bool allow_tabs,
|
|||||||
* matches on the edit window at this point. Make sure that they're
|
* matches on the edit window at this point. Make sure that they're
|
||||||
* cleared off. */
|
* cleared off. */
|
||||||
if (list)
|
if (list)
|
||||||
edit_refresh();
|
refresh_func();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
15
src/proto.h
15
src/proto.h
@ -138,12 +138,10 @@ extern char *homedir;
|
|||||||
/* Public functions in browser.c. */
|
/* Public functions in browser.c. */
|
||||||
#ifndef DISABLE_BROWSER
|
#ifndef DISABLE_BROWSER
|
||||||
char *do_browser(char *path, DIR *dir);
|
char *do_browser(char *path, DIR *dir);
|
||||||
char **browser_init(const char *path, int *longest, size_t *numents, DIR
|
|
||||||
*dir);
|
|
||||||
char *do_browse_from(const char *inpath);
|
char *do_browse_from(const char *inpath);
|
||||||
|
void browser_init(const char *path, DIR *dir);
|
||||||
void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key);
|
void parse_browser_input(int *kbinput, bool *meta_key, bool *func_key);
|
||||||
void browser_refresh(int *width, int longest, int selected, char
|
void browser_refresh(void);
|
||||||
**filelist, size_t numents);
|
|
||||||
void striponedir(char *path);
|
void striponedir(char *path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -302,7 +300,7 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
|
|||||||
char **cwd_tab_completion(const char *buf, bool allow_files, size_t
|
char **cwd_tab_completion(const char *buf, bool allow_files, size_t
|
||||||
*num_matches, size_t buflen);
|
*num_matches, size_t buflen);
|
||||||
char *input_tab(char *buf, bool allow_files, size_t *place, bool
|
char *input_tab(char *buf, bool allow_files, size_t *place, bool
|
||||||
*lastwastab, bool *list);
|
*lastwastab, void (*refresh_func)(void), bool *list);
|
||||||
#endif
|
#endif
|
||||||
const char *tail(const char *foo);
|
const char *tail(const char *foo);
|
||||||
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
|
#if !defined(NANO_TINY) && defined(ENABLE_NANORC)
|
||||||
@ -438,7 +436,8 @@ void do_output(char *output, size_t output_len, bool allow_cntrls);
|
|||||||
|
|
||||||
/* Public functions in prompt.c. */
|
/* Public functions in prompt.c. */
|
||||||
int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
|
int do_statusbar_input(bool *meta_key, bool *func_key, bool *s_or_t,
|
||||||
bool *ran_func, bool *finished, bool allow_funcs);
|
bool *ran_func, bool *finished, bool allow_funcs, void
|
||||||
|
(*refresh_func)(void));
|
||||||
#ifndef DISABLE_MOUSE
|
#ifndef DISABLE_MOUSE
|
||||||
bool do_statusbar_mouse(void);
|
bool do_statusbar_mouse(void);
|
||||||
#endif
|
#endif
|
||||||
@ -474,7 +473,7 @@ int get_prompt_string(bool allow_tabs,
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
filestruct **history_list,
|
filestruct **history_list,
|
||||||
#endif
|
#endif
|
||||||
const shortcut *s
|
void (*refresh_func)(void), const shortcut *s
|
||||||
#ifndef DISABLE_TABCOMP
|
#ifndef DISABLE_TABCOMP
|
||||||
, bool *list
|
, bool *list
|
||||||
#endif
|
#endif
|
||||||
@ -487,7 +486,7 @@ int do_prompt(bool allow_tabs,
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
filestruct **history_list,
|
filestruct **history_list,
|
||||||
#endif
|
#endif
|
||||||
const char *msg, ...);
|
void (*refresh_func)(void), const char *msg, ...);
|
||||||
void do_prompt_abort(void);
|
void do_prompt_abort(void);
|
||||||
int do_yesno_prompt(bool all, const char *msg);
|
int do_yesno_prompt(bool all, const char *msg);
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ int search_init(bool replacing, bool use_answer)
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
&search_history,
|
&search_history,
|
||||||
#endif
|
#endif
|
||||||
"%s%s%s%s%s%s", _("Search"),
|
edit_refresh, "%s%s%s%s%s%s", _("Search"),
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* This string is just a modifier for the search prompt; no
|
/* This string is just a modifier for the search prompt; no
|
||||||
@ -927,7 +927,7 @@ void do_replace(void)
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
&replace_history,
|
&replace_history,
|
||||||
#endif
|
#endif
|
||||||
_("Replace with"));
|
edit_refresh, _("Replace with"));
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
/* Add this replace string to the replace history list. i == 0
|
/* Add this replace string to the replace history list. i == 0
|
||||||
@ -995,7 +995,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
_("Enter line number, column number"));
|
edit_refresh, _("Enter line number, column number"));
|
||||||
|
|
||||||
free(ans);
|
free(ans);
|
||||||
|
|
||||||
|
@ -1676,7 +1676,7 @@ bool do_int_spell_fix(const char *word)
|
|||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
_("Edit a replacement")) == -1);
|
edit_refresh, _("Edit a replacement")) == -1);
|
||||||
|
|
||||||
do_replace_highlight(FALSE, exp_word);
|
do_replace_highlight(FALSE, exp_word);
|
||||||
|
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user