mirror of git://git.sv.gnu.org/nano.git
in do_browser() and do_help(), simplify screen update handling
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3708 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
296ee153b0
commit
6f499096ad
|
@ -16,6 +16,7 @@ CVS code -
|
|||
- Remove unneeded call to blank_edit(). (DLR)
|
||||
- After entering "..", select the directory we were in before
|
||||
instead of the first filename in the list, as Pico does. (DLR)
|
||||
- Simplify screen update handling. (DLR)
|
||||
browser_refresh()
|
||||
- Simplify. (DLR)
|
||||
- Fix problems where translated versions of "(dir)" could be
|
||||
|
@ -32,6 +33,9 @@ CVS code -
|
|||
allocated, use null_at() to strip the directory from the
|
||||
string. Also, return the stripped path instead of modifying
|
||||
path. (DLR)
|
||||
- help.c:
|
||||
do_help()
|
||||
- Simplify screen update handling. (DLR)
|
||||
- doc/syntax/c.nanorc:
|
||||
- Since .i and .ii are preprocessed C and C++ output, colorize
|
||||
them here. (Mike Frysinger)
|
||||
|
|
|
@ -49,8 +49,7 @@ static bool search_last_file = FALSE;
|
|||
char *do_browser(char *path, DIR *dir)
|
||||
{
|
||||
int kbinput;
|
||||
bool meta_key, func_key;
|
||||
bool old_const_update = ISSET(CONST_UPDATE);
|
||||
bool meta_key, func_key, old_const_update = ISSET(CONST_UPDATE);
|
||||
char *prev_dir = NULL;
|
||||
/* The directory we were in, if any, before backing up via
|
||||
* entering "..". */
|
||||
|
@ -102,10 +101,13 @@ char *do_browser(char *path, DIR *dir)
|
|||
}
|
||||
|
||||
do {
|
||||
bool abort = FALSE;
|
||||
size_t fileline;
|
||||
/* The line number the selected file is on. */
|
||||
size_t old_selected = selected;
|
||||
/* We display the file list only if the selected file
|
||||
* changed. */
|
||||
struct stat st;
|
||||
int i;
|
||||
size_t fileline;
|
||||
char *new_path;
|
||||
|
||||
/* Compute the line number we're on now, so that we don't divide
|
||||
|
@ -124,8 +126,6 @@ char *do_browser(char *path, DIR *dir)
|
|||
/* We can click in the edit window to select a
|
||||
* file. */
|
||||
if (wenclose(edit, mouse_y, mouse_x)) {
|
||||
size_t old_selected = selected;
|
||||
|
||||
/* Subtract out the size of topwin. */
|
||||
mouse_y -= 2 - no_more_space();
|
||||
|
||||
|
@ -325,7 +325,7 @@ char *do_browser(char *path, DIR *dir)
|
|||
* get out. */
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
retval = mallocstrcpy(NULL, filelist[selected]);
|
||||
abort = TRUE;
|
||||
kbinput = NANO_EXIT_KEY;
|
||||
break;
|
||||
/* If we've successfully opened a directory, and it's
|
||||
* "..", save the current directory in prev_dir, so that
|
||||
|
@ -349,16 +349,14 @@ char *do_browser(char *path, DIR *dir)
|
|||
/* Start over again with the new path value. */
|
||||
free_chararray(filelist, filelist_len);
|
||||
goto change_browser_directory;
|
||||
/* Abort the browser. */
|
||||
case NANO_EXIT_KEY:
|
||||
abort = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (abort)
|
||||
break;
|
||||
|
||||
browser_refresh();
|
||||
/* Display the file list if we don't have a key, we do have a
|
||||
* key and the selected file has changed, or if we haven't
|
||||
* updated the screen already. */
|
||||
if ((kbinput == ERR || old_selected == selected) && kbinput !=
|
||||
NANO_REFRESH_KEY)
|
||||
browser_refresh();
|
||||
|
||||
kbinput = get_kbinput(edit, &meta_key, &func_key);
|
||||
parse_browser_input(&kbinput, &meta_key, &func_key);
|
||||
|
|
44
src/help.c
44
src/help.c
|
@ -43,8 +43,7 @@ void do_help(void (*refresh_func)(void))
|
|||
/* The line number in help_text of the last help line. This
|
||||
* variable is zero-based. */
|
||||
int kbinput = ERR;
|
||||
bool meta_key, func_key;
|
||||
bool old_no_help = ISSET(NO_HELP);
|
||||
bool meta_key, func_key, old_no_help = ISSET(NO_HELP);
|
||||
#ifndef DISABLE_MOUSE
|
||||
const shortcut *oldshortcut = currshortcut;
|
||||
/* We will set currshortcut to allow clicking on the help
|
||||
|
@ -139,30 +138,31 @@ void do_help(void (*refresh_func)(void))
|
|||
break;
|
||||
}
|
||||
|
||||
if ((kbinput != ERR && line == old_line) || kbinput ==
|
||||
NANO_REFRESH_KEY)
|
||||
goto skip_redisplay;
|
||||
/* Display the help text if we don't have a key, we do have a
|
||||
* key and the help text has moved, or if we haven't updated the
|
||||
* screen already. */
|
||||
if ((kbinput == ERR || line != old_line) && kbinput !=
|
||||
NANO_REFRESH_KEY) {
|
||||
blank_edit();
|
||||
|
||||
blank_edit();
|
||||
/* Calculate where in the text we should be, based on the
|
||||
* page. */
|
||||
for (i = 0; i < line; i++) {
|
||||
ptr += help_line_len(ptr);
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
}
|
||||
|
||||
/* Calculate where in the text we should be, based on the
|
||||
* page. */
|
||||
for (i = 0; i < line; i++) {
|
||||
ptr += help_line_len(ptr);
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
for (i = 0; i < editwinrows && *ptr != '\0'; i++) {
|
||||
size_t j = help_line_len(ptr);
|
||||
|
||||
mvwaddnstr(edit, i, 0, ptr, j);
|
||||
ptr += j;
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < editwinrows && *ptr != '\0'; i++) {
|
||||
size_t j = help_line_len(ptr);
|
||||
|
||||
mvwaddnstr(edit, i, 0, ptr, j);
|
||||
ptr += j;
|
||||
if (*ptr == '\n')
|
||||
ptr++;
|
||||
}
|
||||
|
||||
skip_redisplay:
|
||||
kbinput = get_kbinput(edit, &meta_key, &func_key);
|
||||
parse_help_input(&kbinput, &meta_key, &func_key);
|
||||
} while (kbinput != NANO_EXIT_KEY);
|
||||
|
|
Loading…
Reference in New Issue