prompt: concentrate manipulations of 'statusbar_x' into a single file
parent
e6c6a72ee8
commit
0c455155ad
13
src/files.c
13
src/files.c
|
@ -1112,18 +1112,7 @@ void do_insertfile(void)
|
||||||
#endif
|
#endif
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (func == flip_pipe) {
|
if (func == flip_pipe) {
|
||||||
/* Remove or add the pipe character at the answer's head. */
|
add_or_remove_pipe_symbol_from_answer();
|
||||||
if (answer[0] == '|') {
|
|
||||||
charmove(answer, answer + 1, strlen(answer) + 1);
|
|
||||||
if (statusbar_x > 0)
|
|
||||||
statusbar_x--;
|
|
||||||
} else {
|
|
||||||
answer = charealloc(answer, strlen(answer) + 2);
|
|
||||||
charmove(answer + 1, answer, strlen(answer) + 1);
|
|
||||||
answer[0] = '|';
|
|
||||||
statusbar_x++;
|
|
||||||
}
|
|
||||||
|
|
||||||
given = mallocstrcpy(given, answer);
|
given = mallocstrcpy(given, answer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,8 +152,6 @@ char *word_chars = NULL;
|
||||||
|
|
||||||
char *answer = NULL;
|
char *answer = NULL;
|
||||||
/* The answer string used by the statusbar prompt. */
|
/* The answer string used by the statusbar prompt. */
|
||||||
size_t statusbar_x = HIGHEST_POSITIVE;
|
|
||||||
/* The cursor position in answer. */
|
|
||||||
|
|
||||||
ssize_t tabsize = -1;
|
ssize_t tabsize = -1;
|
||||||
/* The width of a tab in spaces. The default is set in main(). */
|
/* The width of a tab in spaces. The default is set in main(). */
|
||||||
|
|
19
src/prompt.c
19
src/prompt.c
|
@ -25,6 +25,8 @@
|
||||||
|
|
||||||
static char *prompt = NULL;
|
static char *prompt = NULL;
|
||||||
/* The prompt string used for statusbar questions. */
|
/* The prompt string used for statusbar questions. */
|
||||||
|
static size_t statusbar_x = HIGHEST_POSITIVE;
|
||||||
|
/* The cursor position in answer. */
|
||||||
|
|
||||||
#ifdef ENABLE_MOUSE
|
#ifdef ENABLE_MOUSE
|
||||||
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
|
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
|
||||||
|
@ -417,6 +419,23 @@ void update_the_statusbar(void)
|
||||||
wnoutrefresh(bottomwin);
|
wnoutrefresh(bottomwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NANO_TINY
|
||||||
|
/* Remove or add the pipe character at the answer's head. */
|
||||||
|
void add_or_remove_pipe_symbol_from_answer(void)
|
||||||
|
{
|
||||||
|
if (answer[0] == '|') {
|
||||||
|
charmove(answer, answer + 1, strlen(answer) + 1);
|
||||||
|
if (statusbar_x > 0)
|
||||||
|
statusbar_x--;
|
||||||
|
} else {
|
||||||
|
answer = charealloc(answer, strlen(answer) + 2);
|
||||||
|
charmove(answer + 1, answer, strlen(answer) + 1);
|
||||||
|
answer[0] = '|';
|
||||||
|
statusbar_x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get a string of input at the statusbar prompt. */
|
/* Get a string of input at the statusbar prompt. */
|
||||||
functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
|
||||||
bool allow_files, bool *listed, filestruct **history_list,
|
bool allow_files, bool *listed, filestruct **history_list,
|
||||||
|
|
|
@ -124,7 +124,6 @@ extern char *quoteerr;
|
||||||
extern char *word_chars;
|
extern char *word_chars;
|
||||||
|
|
||||||
extern char *answer;
|
extern char *answer;
|
||||||
extern size_t statusbar_x;
|
|
||||||
|
|
||||||
extern ssize_t tabsize;
|
extern ssize_t tabsize;
|
||||||
|
|
||||||
|
@ -465,6 +464,7 @@ size_t statusbar_xplustabs(void);
|
||||||
size_t get_statusbar_page_start(size_t start_col, size_t column);
|
size_t get_statusbar_page_start(size_t start_col, size_t column);
|
||||||
void reinit_statusbar_x(void);
|
void reinit_statusbar_x(void);
|
||||||
void update_the_statusbar(void);
|
void update_the_statusbar(void);
|
||||||
|
void add_or_remove_pipe_symbol_from_answer(void);
|
||||||
int do_prompt(bool allow_tabs, bool allow_files,
|
int do_prompt(bool allow_tabs, bool allow_files,
|
||||||
int menu, const char *curranswer, filestruct **history_list,
|
int menu, const char *curranswer, filestruct **history_list,
|
||||||
void (*refresh_func)(void), const char *msg, ...);
|
void (*refresh_func)(void), const char *msg, ...);
|
||||||
|
|
Loading…
Reference in New Issue