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
master
David Lawrence Ramsey 2006-06-30 21:01:55 +00:00
parent 296ee153b0
commit 6f499096ad
3 changed files with 39 additions and 37 deletions

View File

@ -16,6 +16,7 @@ CVS code -
- Remove unneeded call to blank_edit(). (DLR) - Remove unneeded call to blank_edit(). (DLR)
- After entering "..", select the directory we were in before - After entering "..", select the directory we were in before
instead of the first filename in the list, as Pico does. (DLR) instead of the first filename in the list, as Pico does. (DLR)
- Simplify screen update handling. (DLR)
browser_refresh() browser_refresh()
- Simplify. (DLR) - Simplify. (DLR)
- Fix problems where translated versions of "(dir)" could be - 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 allocated, use null_at() to strip the directory from the
string. Also, return the stripped path instead of modifying string. Also, return the stripped path instead of modifying
path. (DLR) path. (DLR)
- help.c:
do_help()
- Simplify screen update handling. (DLR)
- doc/syntax/c.nanorc: - doc/syntax/c.nanorc:
- Since .i and .ii are preprocessed C and C++ output, colorize - Since .i and .ii are preprocessed C and C++ output, colorize
them here. (Mike Frysinger) them here. (Mike Frysinger)

View File

@ -49,8 +49,7 @@ static bool search_last_file = FALSE;
char *do_browser(char *path, DIR *dir) char *do_browser(char *path, DIR *dir)
{ {
int kbinput; int kbinput;
bool meta_key, func_key; bool meta_key, func_key, old_const_update = ISSET(CONST_UPDATE);
bool old_const_update = ISSET(CONST_UPDATE);
char *prev_dir = NULL; char *prev_dir = NULL;
/* The directory we were in, if any, before backing up via /* The directory we were in, if any, before backing up via
* entering "..". */ * entering "..". */
@ -102,10 +101,13 @@ char *do_browser(char *path, DIR *dir)
} }
do { 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; struct stat st;
int i; int i;
size_t fileline;
char *new_path; char *new_path;
/* 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
@ -124,8 +126,6 @@ char *do_browser(char *path, DIR *dir)
/* We can click in the edit window to select a /* We can click in the edit window to select a
* file. */ * file. */
if (wenclose(edit, mouse_y, mouse_x)) { if (wenclose(edit, mouse_y, mouse_x)) {
size_t old_selected = selected;
/* Subtract out the size of topwin. */ /* Subtract out the size of topwin. */
mouse_y -= 2 - no_more_space(); mouse_y -= 2 - no_more_space();
@ -325,7 +325,7 @@ char *do_browser(char *path, DIR *dir)
* get out. */ * get out. */
if (!S_ISDIR(st.st_mode)) { if (!S_ISDIR(st.st_mode)) {
retval = mallocstrcpy(NULL, filelist[selected]); retval = mallocstrcpy(NULL, filelist[selected]);
abort = TRUE; kbinput = NANO_EXIT_KEY;
break; break;
/* If we've successfully opened a directory, and it's /* If we've successfully opened a directory, and it's
* "..", save the current directory in prev_dir, so that * "..", 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. */ /* Start over again with the new path value. */
free_chararray(filelist, filelist_len); free_chararray(filelist, filelist_len);
goto change_browser_directory; goto change_browser_directory;
/* Abort the browser. */
case NANO_EXIT_KEY:
abort = TRUE;
break;
} }
if (abort) /* Display the file list if we don't have a key, we do have a
break; * key and the selected file has changed, or if we haven't
* updated the screen already. */
browser_refresh(); if ((kbinput == ERR || old_selected == selected) && kbinput !=
NANO_REFRESH_KEY)
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);

View File

@ -43,8 +43,7 @@ void do_help(void (*refresh_func)(void))
/* The line number in help_text of the last help line. This /* The line number in help_text of the last help line. This
* variable is zero-based. */ * variable is zero-based. */
int kbinput = ERR; int kbinput = ERR;
bool meta_key, func_key; bool meta_key, func_key, old_no_help = ISSET(NO_HELP);
bool old_no_help = ISSET(NO_HELP);
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
const shortcut *oldshortcut = currshortcut; const shortcut *oldshortcut = currshortcut;
/* We will set currshortcut to allow clicking on the help /* We will set currshortcut to allow clicking on the help
@ -139,30 +138,31 @@ void do_help(void (*refresh_func)(void))
break; break;
} }
if ((kbinput != ERR && line == old_line) || kbinput == /* Display the help text if we don't have a key, we do have a
NANO_REFRESH_KEY) * key and the help text has moved, or if we haven't updated the
goto skip_redisplay; * 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 for (i = 0; i < editwinrows && *ptr != '\0'; i++) {
* page. */ size_t j = help_line_len(ptr);
for (i = 0; i < line; i++) {
ptr += help_line_len(ptr); mvwaddnstr(edit, i, 0, ptr, j);
if (*ptr == '\n') ptr += j;
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++;
}
skip_redisplay:
kbinput = get_kbinput(edit, &meta_key, &func_key); kbinput = get_kbinput(edit, &meta_key, &func_key);
parse_help_input(&kbinput, &meta_key, &func_key); parse_help_input(&kbinput, &meta_key, &func_key);
} while (kbinput != NANO_EXIT_KEY); } while (kbinput != NANO_EXIT_KEY);