shithub: nc

Download patch

ref: f3f8f9740885562909d2437233517cc37bf71e66
parent: e423f457570af50cba086007c2a9f6db520151e1
author: phil9 <telephil9@gmail.com>
date: Tue Dec 27 11:49:51 EST 2022

start with left panel showing current directory instead of home

--- a/a.h
+++ b/a.h
@@ -105,7 +105,7 @@
 	Byes,
 };
 
-Dirview*	mkdirview(char*);
+Dirview*	mkdirview(char*, char*);
 void		dirviewsetrect(Dirview*, Rectangle);
 void		dirviewredraw(Dirview*);
 void		dirviewemouse(Dirview*, Mouse);
--- a/dirview.c
+++ b/dirview.c
@@ -57,7 +57,7 @@
 }
 
 Dirview*
-mkdirview(char *path)
+mkdirview(char *lpath, char *rpath)
 {
 	Dirview *dv;
 	Dirmodel *m;
@@ -65,10 +65,10 @@
 	dv = emalloc(sizeof *dv);
 	dv->c = chancreate(sizeof(ulong), 1);
 	dv->b = nil;
-	m = mkdirmodel(path);
+	m = mkdirmodel(lpath);
 	dv->leftp = mkdirpanel(m);
 	dv->leftp->focused = 1;
-	m = mkdirmodel(path);
+	m = mkdirmodel(rpath);
 	dv->rightp = mkdirpanel(m);
 	return dv;
 }
--- a/main.c
+++ b/main.c
@@ -109,7 +109,7 @@
 void
 threadmain(int argc, char **argv)
 {
-	char *home;
+	char *home, pwd[1024] = {0};
 	Mouse m;
 	Rune k;
 	ulong l;
@@ -138,7 +138,9 @@
 		sysfatal("initkdb: %r");
 	display->locking = 0;
 	home = homedir();
-	dview = mkdirview(home);
+	if(getwd(pwd, sizeof pwd) == nil)
+		strncpy(pwd, home, strlen(home));
+	dview = mkdirview(pwd, home);
 	text = mktext();
 	abar = mkactionbar();
 	colsinit();