Commit 2dc9cbef authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Renaming some things, for more contrast or to be more fitting.

And condensing the renamed function, and making it void because
the result isn't used anyway.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5187 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 0f7b99b4
Showing with 26 additions and 29 deletions
+26 -29
2015-04-08 Benno Schulenberg <bensberg@justemail.net>
* src/browser.c (browser_select_dirname, findnextfile): Rename
'currselected' to 'looking_at', for more contrast with 'selected',
and rename browser_select_filename() to browser_select_dirname().
2015-04-07 Benno Schulenberg <bensberg@justemail.net> 2015-04-07 Benno Schulenberg <bensberg@justemail.net>
* src/browser.c (do_fileresearch): Don't search for the empty string * src/browser.c (do_fileresearch): Don't search for the empty string
when nothing was sought yet (when historylog is set). when nothing was sought yet (when historylog is set).
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* browser.c * * browser.c *
* * * *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, * * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014 Free Software Foundation, Inc. * * 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
* *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3, or (at your option) * * the Free Software Foundation; either version 3, or (at your option) *
...@@ -39,8 +40,7 @@ static int width = 0; ...@@ -39,8 +40,7 @@ static int width = 0;
static int longest = 0; static int longest = 0;
/* The number of columns in the longest filename in the list. */ /* The number of columns in the longest filename in the list. */
static size_t selected = 0; static size_t selected = 0;
/* The currently selected filename in the list. This variable /* The currently selected filename in the list; zero-based. */
* is zero-based. */
/* Our main file browser function. path is the tilde-expanded path we /* Our main file browser function. path is the tilde-expanded path we
* start browsing from. */ * start browsing from. */
...@@ -88,7 +88,7 @@ char *do_browser(char *path, DIR *dir) ...@@ -88,7 +88,7 @@ char *do_browser(char *path, DIR *dir)
/* If prev_dir isn't NULL, select the directory saved in it, and /* If prev_dir isn't NULL, select the directory saved in it, and
* then blow it away. */ * then blow it away. */
if (prev_dir != NULL) { if (prev_dir != NULL) {
browser_select_filename(prev_dir); browser_select_dirname(prev_dir);
free(prev_dir); free(prev_dir);
prev_dir = NULL; prev_dir = NULL;
...@@ -683,26 +683,18 @@ void browser_refresh(void) ...@@ -683,26 +683,18 @@ void browser_refresh(void)
wnoutrefresh(edit); wnoutrefresh(edit);
} }
/* Look for needle. If we find it, set selected to its location. Note /* Look for needle. If we find it, set selected to its location.
* that needle must be an exact match for a file in the list. The * Note that needle must be an exact match for a file in the list. */
* return value specifies whether we found anything. */ void browser_select_dirname(const char *needle)
bool browser_select_filename(const char *needle)
{ {
size_t currselected; size_t looking_at = 0;
bool found = FALSE;
for (currselected = 0; currselected < filelist_len; for (; looking_at < filelist_len; looking_at++) {
currselected++) { if (strcmp(filelist[looking_at], needle) == 0) {
if (strcmp(filelist[currselected], needle) == 0) { selected = looking_at;
found = TRUE;
break; break;
} }
} }
if (found)
selected = currselected;
return found;
} }
/* Set up the system variables for a filename search. Return -1 if the /* Set up the system variables for a filename search. Return -1 if the
...@@ -764,11 +756,11 @@ int filesearch_init(void) ...@@ -764,11 +756,11 @@ int filesearch_init(void)
/* Look for the given needle in the list of files. */ /* Look for the given needle in the list of files. */
void findnextfile(const char *needle) void findnextfile(const char *needle)
{ {
size_t currselected = selected; size_t looking_at = selected;
/* The location in the file list of the filename we're looking at. */ /* The location in the file list of the filename we're looking at. */
bool came_full_circle = FALSE; bool came_full_circle = FALSE;
/* Have we reached the starting file again? */ /* Have we reached the starting file again? */
const char *filetail = tail(filelist[currselected]); const char *filetail = tail(filelist[looking_at]);
/* The filename we display, minus the path. */ /* The filename we display, minus the path. */
const char *rev_start = filetail, *found = NULL; const char *rev_start = filetail, *found = NULL;
...@@ -779,7 +771,7 @@ void findnextfile(const char *needle) ...@@ -779,7 +771,7 @@ void findnextfile(const char *needle)
/* If we've found a match and it's not the same filename where /* If we've found a match and it's not the same filename where
* we started, then we're done. */ * we started, then we're done. */
if (found != NULL && currselected != selected) if (found != NULL && looking_at != selected)
break; break;
/* If we've found a match and we're back at the beginning, then /* If we've found a match and we're back at the beginning, then
...@@ -797,24 +789,24 @@ void findnextfile(const char *needle) ...@@ -797,24 +789,24 @@ void findnextfile(const char *needle)
/* Move to the next filename in the list. If we've reached the /* Move to the next filename in the list. If we've reached the
* end of the list, wrap around. */ * end of the list, wrap around. */
if (currselected < filelist_len - 1) if (looking_at < filelist_len - 1)
currselected++; looking_at++;
else { else {
currselected = 0; looking_at = 0;
statusbar(_("Search Wrapped")); statusbar(_("Search Wrapped"));
} }
if (currselected == selected) if (looking_at == selected)
/* We've reached the original starting file. */ /* We've reached the original starting file. */
came_full_circle = TRUE; came_full_circle = TRUE;
filetail = tail(filelist[currselected]); filetail = tail(filelist[looking_at]);
rev_start = filetail; rev_start = filetail;
} }
/* Select the one we've found. */ /* Select the one we've found. */
selected = currselected; selected = looking_at;
} }
/* Search for a filename. */ /* Search for a filename. */
......
...@@ -149,7 +149,7 @@ char *do_browse_from(const char *inpath); ...@@ -149,7 +149,7 @@ char *do_browse_from(const char *inpath);
void browser_init(const char *path, DIR *dir); void browser_init(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput); functionptrtype parse_browser_input(int *kbinput);
void browser_refresh(void); void browser_refresh(void);
bool browser_select_filename(const char *needle); void browser_select_dirname(const char *needle);
int filesearch_init(void); int filesearch_init(void);
void findnextfile(const char *needle); void findnextfile(const char *needle);
void filesearch_abort(void); void filesearch_abort(void);
......
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