commit 68e2c375e7f204d34c077b81f83fad04ec6baa6b
parent 99c87ccb0c42b027e63309565d49c772ae07fcb3
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Fri, 30 Jun 2006 03:19:28 +0000
in browser_refresh(), for the ".." entry, display "(parent dir)" instead
of "(dir)", as Pico does
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3695 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -17,6 +17,8 @@ CVS code -
- Simplify. (DLR)
- Fix problems where translated versions of "(dir)" could be
truncated, and where file sizes could be too long. (DLR)
+ - For the ".." entry, display "(parent dir)" instead of "(dir)",
+ as Pico does. (DLR)
- doc/syntax/c.nanorc:
- Since .i and .ii are preprocessed C and C++ output, colorize
them here. (Mike Frysinger)
diff --git a/src/browser.c b/src/browser.c
@@ -418,7 +418,8 @@ char *do_browse_from(const char *inpath)
/* Set filelist to the list of files contained in the directory path,
* set filelist_len to the number of files in that list, and set longest
* to the width in columns of the longest filename in that list, up to
- * COLS - 1 (but at least 7). Assume path exists and is a directory. */
+ * COLS - 1 (but at least 15). Assume path exists and is a
+ * directory. */
void browser_init(const char *path, DIR *dir)
{
const struct dirent *nextdir;
@@ -470,8 +471,8 @@ void browser_init(const char *path, DIR *dir)
if (longest > COLS - 1)
longest = COLS - 1;
- if (longest < 7)
- longest = 7;
+ if (longest < 15)
+ longest = 15;
}
/* Determine the shortcut key corresponding to the values of kbinput
@@ -539,8 +540,9 @@ void browser_refresh(void)
for (; i < filelist_len && line < editwinrows; i++) {
struct stat st;
- char *disp = display_string(tail(filelist[i]), 0, longest,
- FALSE);
+ const char *filetail = tail(filelist[i]);
+ char *disp = display_string(filetail, 0, longest, FALSE);
+ size_t foo_col;
/* Highlight the currently selected file or directory. */
if (i == selected)
@@ -567,7 +569,8 @@ void browser_refresh(void)
foo = mallocstrcpy(NULL, _("(dir)"));
} else if (S_ISDIR(st.st_mode))
/* If the file is a directory, display it as such. */
- foo = mallocstrcpy(NULL, _("(dir)"));
+ foo = mallocstrcpy(NULL, (strcmp(filetail, "..") == 0) ?
+ _("(parent dir)") : _("(dir)"));
else {
foo = charalloc(uimax_digits + 4);
@@ -588,8 +591,10 @@ void browser_refresh(void)
(unsigned int)(st.st_size >> 30));
}
- mvwaddnstr(edit, line, col - strlenpt(foo), foo,
- actual_x(foo, 7));
+ foo_col = col - strlenpt(foo);
+
+ mvwaddnstr(edit, line, foo_col, foo, actual_x(foo, longest -
+ foo_col));
if (i == selected)
wattroff(edit, reverse_attr);