- New file browser code. New functions in files.c:do_browser(),
helper functions browser_init(), tail(), striponedir(),
filestat(). New shortcut list browser_list. Some new
- strings to translate. Chris needs to add comments to his
- code.
+ strings to translate. Added function do_browse_from().
- We only call keypad() once now for each window, at the beginning.
FINALLY! No more keypad_on(), no more individual calls in
main(), do_help(), do_browser(), etc etc etc. Removed call to
- Spell Erik Andersen's name right.
titlebar()
- Now takes an arg, needed for browser function.
+- utils.c:
+ mallocstrcpy()
+ - Takes char pointers now instead of void (makes debugging a
+ helluva lot easier)
- es.po:
- Updates for file browser (Jordi).
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
if (i == NANO_TOFILES_KEY) {
- char *tmp = do_browser(getcwd(NULL, 0));
+
+ char *tmp = do_browse_from(realname);
#ifdef DISABLE_TABCOMP
realname = NULL;
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
if (i == NANO_TOFILES_KEY) {
- char *tmp = do_browser(getcwd(NULL, 0));
+
+ char *tmp = do_browse_from(answer);
if (tmp != NULL)
answer = mallocstrcpy(answer, tmp);
free(foo);
return retval;
}
+
+/* Browser fron't end, checks to see if inpath has a dir in it and if so
+ starts do_browser from there, else from the current dir */
+char *do_browse_from(char *inpath)
+{
+ struct stat st;
+ char *tmp = NULL;
+
+ tmp = mallocstrcpy(tmp, inpath);
+
+ /* If there's no / in the string, we may was well start from . */
+ if (tmp == NULL || !strstr(tmp, "/"))
+ return do_browser(getcwd(NULL, 0));
+
+ /* If the string is a directory, pass do_browser that */
+ st = filestat(tmp);
+ if (S_ISDIR(st.st_mode))
+ return do_browser(tmp);
+
+ /* Okay, there's a dir in there, but not at the end of the string...
+ try stripping it off */
+ striponedir(tmp);
+ align(&tmp);
+ return do_browser(tmp);
+
+}
+
+
+
#endif
void bottombars(shortcut s[], int slen);
void blank_statusbar_refresh(void);
void *nmalloc (size_t howmuch);
-void *mallocstrcpy(void *dest, void *src);
+void *mallocstrcpy(char *dest, char *src);
void wrap_reset(void);
void display_main_list(void);
void nano_small_msg(void);
#if !defined(DISABLE_BROWSER) && !defined(NANO_SMALL)
char *do_browser(char *path);
+struct stat filestat(const char *path);
+char *do_browse_from(char *inpath);
#endif
filestruct *copy_node(filestruct * src);
Should be used as dest = mallocstrcpy(dest, src);
*/
-void *mallocstrcpy(void *dest, void *src)
+void *mallocstrcpy(char *dest, char *src)
{
if (dest != NULL)