Commit af3314c3 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

add the statusbar prompt's equivalent of placewewant,statusbar_pww, to

prompt.c, and convert (most of) its functions to use it


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3098 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 63 additions and 12 deletions
+63 -12
...@@ -60,6 +60,14 @@ CVS code - ...@@ -60,6 +60,14 @@ CVS code -
file browser.c; changes to striponedir(), browser_init(), file browser.c; changes to striponedir(), browser_init(),
do_browser(), and do_browse_from() (all moved to browser.c). do_browser(), and do_browse_from() (all moved to browser.c).
(DLR) (DLR)
- Add the statusbar prompt's equivalent of placewewant,
statusbar_pww, to prompt.c, and convert (most of) its
functions to use it. Changes to do_statusbar_mouse(),
do_statusbar_output(), do_statusbar_home(),
do_statusbar_end(), do_statusbar_right(), do_statusbar_left(),
do_statusbar_delete(), do_statusbar_cut_text(),
do_statusbar_next_word(), do_statusbar_prev_word(),
do_statusbar_verbatim_input(), and nanogetstr(). (DLR)
- files.c: - files.c:
read_file() read_file()
- Remove apparently unneeded logic to handle a case where - Remove apparently unneeded logic to handle a case where
......
...@@ -34,6 +34,8 @@ static char *prompt = NULL; ...@@ -34,6 +34,8 @@ static char *prompt = NULL;
* questions. */ * questions. */
static size_t statusbar_x = (size_t)-1; static size_t statusbar_x = (size_t)-1;
/* The cursor position in answer. */ /* The cursor position in answer. */
static size_t statusbar_pww = (size_t)-1;
/* The place we want in answer. */
static bool reset_statusbar_x = FALSE; static bool reset_statusbar_x = FALSE;
/* Should we reset the cursor position /* Should we reset the cursor position
* at the statusbar prompt? */ * at the statusbar prompt? */
...@@ -255,7 +257,8 @@ bool do_statusbar_mouse(void) ...@@ -255,7 +257,8 @@ bool do_statusbar_mouse(void)
get_statusbar_page_start(start_col, start_col + get_statusbar_page_start(start_col, start_col +
statusbar_xplustabs()) + mouse_x - start_col - statusbar_xplustabs()) + mouse_x - start_col -
1); 1);
nanoget_repaint(answer, statusbar_x); statusbar_pww = statusbar_xplustabs();
/*nanoget_repaint(answer, statusbar_x);*/
} }
} }
} }
...@@ -322,6 +325,10 @@ void do_statusbar_output(char *output, size_t output_len, bool ...@@ -322,6 +325,10 @@ void do_statusbar_output(char *output, size_t output_len, bool
} }
free(char_buf); free(char_buf);
statusbar_pww = statusbar_xplustabs();
/*nanoget_repaint(answer, statusbar_x);*/
} }
void do_statusbar_home(void) void do_statusbar_home(void)
...@@ -335,26 +342,45 @@ void do_statusbar_home(void) ...@@ -335,26 +342,45 @@ void do_statusbar_home(void)
if (statusbar_x == statusbar_x_save || if (statusbar_x == statusbar_x_save ||
statusbar_x == strlen(answer)) statusbar_x == strlen(answer))
statusbar_x = 0; statusbar_x = 0;
} else
statusbar_pww = statusbar_xplustabs();
} else {
#endif #endif
statusbar_x = 0; statusbar_x = 0;
statusbar_pww = statusbar_xplustabs();
#ifndef NANO_SMALL
}
#endif
/*nanoget_repaint(answer, statusbar_x);*/
} }
void do_statusbar_end(void) void do_statusbar_end(void)
{ {
statusbar_x = strlen(answer); statusbar_x = strlen(answer);
statusbar_pww = statusbar_xplustabs();
/*nanoget_repaint(answer, statusbar_x);*/
} }
void do_statusbar_right(void) void do_statusbar_right(void)
{ {
if (statusbar_x < strlen(answer)) if (statusbar_x < strlen(answer)) {
statusbar_x = move_mbright(answer, statusbar_x); statusbar_x = move_mbright(answer, statusbar_x);
statusbar_pww = statusbar_xplustabs();
/*nanoget_repaint(answer, statusbar_x);*/
}
} }
void do_statusbar_left(void) void do_statusbar_left(void)
{ {
if (statusbar_x > 0) if (statusbar_x > 0) {
statusbar_x = move_mbleft(answer, statusbar_x); statusbar_x = move_mbleft(answer, statusbar_x);
statusbar_pww = statusbar_xplustabs();
/*nanoget_repaint(answer, statusbar_x);*/
}
} }
void do_statusbar_backspace(void) void do_statusbar_backspace(void)
...@@ -367,6 +393,8 @@ void do_statusbar_backspace(void) ...@@ -367,6 +393,8 @@ void do_statusbar_backspace(void)
void do_statusbar_delete(void) void do_statusbar_delete(void)
{ {
statusbar_pww = statusbar_xplustabs();
if (answer[statusbar_x] != '\0') { if (answer[statusbar_x] != '\0') {
int char_buf_len = parse_mbchar(answer + statusbar_x, NULL, int char_buf_len = parse_mbchar(answer + statusbar_x, NULL,
NULL); NULL);
...@@ -394,9 +422,12 @@ void do_statusbar_cut_text(void) ...@@ -394,9 +422,12 @@ void do_statusbar_cut_text(void)
#endif #endif
null_at(&answer, 0); null_at(&answer, 0);
statusbar_x = 0; statusbar_x = 0;
statusbar_pww = statusbar_xplustabs();
#ifndef NANO_SMALL #ifndef NANO_SMALL
} }
#endif #endif
/*nanoget_repaint(answer, statusbar_x);*/
} }
#ifndef NANO_SMALL #ifndef NANO_SMALL
...@@ -455,6 +486,10 @@ bool do_statusbar_next_word(bool allow_punct) ...@@ -455,6 +486,10 @@ bool do_statusbar_next_word(bool allow_punct)
free(char_mb); free(char_mb);
statusbar_pww = statusbar_xplustabs();
/*nanoget_repaint(answer, statusbar_x);*/
/* Return whether we started on a word. */ /* Return whether we started on a word. */
return started_on_word; return started_on_word;
} }
...@@ -544,6 +579,10 @@ bool do_statusbar_prev_word(bool allow_punct) ...@@ -544,6 +579,10 @@ bool do_statusbar_prev_word(bool allow_punct)
free(char_mb); free(char_mb);
statusbar_pww = statusbar_xplustabs();
/*nanoget_repaint(answer, statusbar_x);*/
/* Return whether we started on a word. */ /* Return whether we started on a word. */
return started_on_word; return started_on_word;
} }
...@@ -663,14 +702,16 @@ int nanogetstr(bool allow_tabs, const char *curranswer, ...@@ -663,14 +702,16 @@ int nanogetstr(bool allow_tabs, const char *curranswer,
answer = mallocstrcpy(answer, curranswer); answer = mallocstrcpy(answer, curranswer);
curranswer_len = strlen(answer); curranswer_len = strlen(answer);
/* Only put statusbar_x at the end of the string if it's /* Only put statusbar_x at the end of the string (and change
* uninitialized, if it would be past the end of curranswer, or if * statusbar_pww to match) if it's uninitialized, if it would be
* reset_statusbar_x is TRUE. Otherwise, leave it alone. This is * past the end of curranswer, or if reset_statusbar_x is TRUE.
* so the cursor position stays at the same place if a * Otherwise, leave it alone. This is so the cursor position stays
* prompt-changing toggle is pressed. */ * at the same place if a prompt-changing toggle is pressed. */
if (statusbar_x == (size_t)-1 || statusbar_x > curranswer_len || if (statusbar_x == (size_t)-1 || statusbar_x > curranswer_len ||
reset_statusbar_x) reset_statusbar_x) {
statusbar_x = curranswer_len; statusbar_x = curranswer_len;
statusbar_pww = statusbar_xplustabs();
}
currshortcut = s; currshortcut = s;
...@@ -799,10 +840,12 @@ int nanogetstr(bool allow_tabs, const char *curranswer, ...@@ -799,10 +840,12 @@ int nanogetstr(bool allow_tabs, const char *curranswer,
#endif #endif
/* We finished putting in an answer or ran a normal shortcut's /* We finished putting in an answer or ran a normal shortcut's
* associated function, so reset statusbar_x. */ * associated function, so reset statusbar_x and statusbar_pww. */
if (kbinput == NANO_CANCEL_KEY || kbinput == NANO_ENTER_KEY || if (kbinput == NANO_CANCEL_KEY || kbinput == NANO_ENTER_KEY ||
ran_func) ran_func) {
statusbar_x = (size_t)-1; statusbar_x = (size_t)-1;
statusbar_pww = (size_t)-1;
}
return kbinput; return kbinput;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment