commit 81a55239e28a0f70ebae0951c8eebd6ad7c8981a
parent 53b609386d58d7048e5b9e62d23b1a7b05b30e1b
Author: Giygas <none>
Date: Sun, 12 Jan 2025 22:27:41 -0800
Added option to hide dotfiles by default from directory listing.
Diffstat:
M | README | | | 10 | +++++++--- |
M | patch-acme3k | | | 269 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- |
2 files changed, 244 insertions(+), 35 deletions(-)
diff --git a/README b/README
@@ -1,13 +1,17 @@
-My collection of acme patches.
+A patch for plan9port acme that provides several quality-of-life improvements.
Patching plan9port-20240109p0
Done:
-- colours
+- Full, comprehensive colour customisation via config.h
+- Keyboard navigation with the up/down arrow keys
+- In addition to selecting the most recently typed string, pressing ESC now also warps the cursor to the selected text.
+- Dotfiles are hidden from directory file listings by default. Show and Hide commands added to show or hide dotfiles in the currently viewed directory. Default behaviour can be modified via config.h
To do:
A lot...
- Modified makefile that copies and patches the local plan9 source
-- Minor keyboard tweaks
+- More keyboard tweaks
- Double-click, triple-click semantics
+- Support custom rules for automatically filling the tag with strings based on the opened file/directory
Special shout-out to https://github.com/karahobny/acme2k
diff --git a/patch-acme3k b/patch-acme3k
@@ -1,6 +1,6 @@
diff -u a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
---- a/src/cmd/acme/acme.c Thu Jan 2 21:32:59 2025
-+++ b/src/cmd/acme/acme.c Thu Jan 2 21:33:09 2025
+--- a/src/cmd/acme/acme.c Sun Jan 12 22:18:48 2025
++++ b/src/cmd/acme/acme.c Sun Jan 12 22:18:57 2025
@@ -11,6 +11,7 @@
#include <libsec.h>
#include "dat.h"
@@ -9,6 +9,15 @@ diff -u a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
/* for generating syms in mkfile only: */
#include <bio.h>
#include "edit.h"
+@@ -297,7 +298,7 @@
+ nr = runestrlen(rb);
+ rs = cleanrname(runestr(rb, nr));
+ winsetname(w, rs.r, rs.nr);
+- textload(&w->body, 0, s, 1);
++ textload(&w->body, 0, s, 1, Hidedotfiles);
+ w->body.file->mod = FALSE;
+ w->dirty = FALSE;
+ winsettag(w);
@@ -547,7 +548,7 @@
case MResize:
if(getwindow(display, Refnone) < 0)
@@ -86,8 +95,8 @@ diff -u a/src/cmd/acme/acme.c b/src/cmd/acme/acme.c
/*
diff -u a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c
---- a/src/cmd/acme/cols.c Thu Jan 2 21:32:59 2025
-+++ b/src/cmd/acme/cols.c Thu Jan 2 21:33:09 2025
+--- a/src/cmd/acme/cols.c Sun Jan 12 22:18:48 2025
++++ b/src/cmd/acme/cols.c Sun Jan 12 22:18:57 2025
@@ -29,7 +29,7 @@
Rectangle r1;
Text *t;
@@ -190,8 +199,17 @@ diff -u a/src/cmd/acme/cols.c b/src/cmd/acme/cols.c
Only in b/src/cmd/acme: config.def.h
Only in b/src/cmd/acme: config.h
diff -u a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h
---- a/src/cmd/acme/dat.h Thu Jan 2 21:32:59 2025
-+++ b/src/cmd/acme/dat.h Thu Jan 2 21:33:09 2025
+--- a/src/cmd/acme/dat.h Sun Jan 12 22:18:48 2025
++++ b/src/cmd/acme/dat.h Sun Jan 12 22:18:57 2025
+@@ -213,7 +213,7 @@
+ void textframescroll(Text*, int);
+ void textinit(Text*, File*, Rectangle, Reffont*, Image**);
+ void textinsert(Text*, uint, Rune*, uint, int);
+-int textload(Text*, uint, char*, int);
++int textload(Text*, uint, char*, int, int);
+ Rune textreadc(Text*, uint);
+ void textredraw(Text*, Rectangle, Font*, Image*, int);
+ void textreset(Text*);
@@ -222,7 +222,7 @@
void textscroll(Text*, int);
void textselect(Text*);
@@ -220,11 +238,163 @@ diff -u a/src/cmd/acme/dat.h b/src/cmd/acme/dat.h
extern char wdir[]; /* must use extern because no dimension given */
int editing;
int erroutfd;
+diff -u a/src/cmd/acme/exec.c b/src/cmd/acme/exec.c
+--- a/src/cmd/acme/exec.c Sun Jan 12 22:18:48 2025
++++ b/src/cmd/acme/exec.c Sun Jan 12 22:18:57 2025
+@@ -13,6 +13,7 @@
+ #include <9pclient.h>
+ #include "dat.h"
+ #include "fns.h"
++#include "config.h"
+
+ Buffer snarfbuf;
+
+@@ -52,6 +53,7 @@
+ void put(Text*, Text*, Text*, int, int, Rune*, int);
+ void putall(Text*, Text*, Text*, int, int, Rune*, int);
+ void sendx(Text*, Text*, Text*, int, int, Rune*, int);
++void dotshow(Text*, Text*, Text*, int, int, Rune*, int);
+ void sort(Text*, Text*, Text*, int, int, Rune*, int);
+ void tab(Text*, Text*, Text*, int, int, Rune*, int);
+ void zeroxx(Text*, Text*, Text*, int, int, Rune*, int);
+@@ -76,6 +78,7 @@
+ static Rune LExit[] = { 'E', 'x', 'i', 't', 0 };
+ static Rune LFont[] = { 'F', 'o', 'n', 't', 0 };
+ static Rune LGet[] = { 'G', 'e', 't', 0 };
++static Rune LHide[] = { 'H', 'i', 'd', 'e', 0 };
+ static Rune LID[] = { 'I', 'D', 0 };
+ static Rune LIncl[] = { 'I', 'n', 'c', 'l', 0 };
+ static Rune LIndent[] = { 'I', 'n', 'd', 'e', 'n', 't', 0 };
+@@ -90,6 +93,7 @@
+ static Rune LPutall[] = { 'P', 'u', 't', 'a', 'l', 'l', 0 };
+ static Rune LRedo[] = { 'R', 'e', 'd', 'o', 0 };
+ static Rune LSend[] = { 'S', 'e', 'n', 'd', 0 };
++static Rune LShow[] = { 'S', 'h', 'o', 'w', 0 };
+ static Rune LSnarf[] = { 'S', 'n', 'a', 'r', 'f', 0 };
+ static Rune LSort[] = { 'S', 'o', 'r', 't', 0 };
+ static Rune LTab[] = { 'T', 'a', 'b', 0 };
+@@ -106,7 +110,8 @@
+ { LEdit, edit, FALSE, XXX, XXX },
+ { LExit, xexit, FALSE, XXX, XXX },
+ { LFont, fontx, FALSE, XXX, XXX },
+- { LGet, get, FALSE, TRUE, XXX },
++ { LGet, get, FALSE, TRUE, Hidedotfiles },
++ { LHide, dotshow, FALSE, TRUE, TRUE },
+ { LID, id, FALSE, XXX, XXX },
+ { LIncl, incl, FALSE, XXX, XXX },
+ { LIndent, indent, FALSE, XXX, XXX },
+@@ -121,6 +126,7 @@
+ { LPutall, putall, FALSE, XXX, XXX },
+ { LRedo, undo, FALSE, FALSE, XXX },
+ { LSend, sendx, TRUE, XXX, XXX },
++ { LShow, dotshow, FALSE, TRUE, FALSE },
+ { LSnarf, cut, FALSE, TRUE, FALSE },
+ { LSort, sort, FALSE, XXX, XXX },
+ { LTab, tab, FALSE, XXX, XXX },
+@@ -585,7 +591,7 @@
+ };
+
+ void
+-get(Text *et, Text *t, Text *argt, int flag1, int _0, Rune *arg, int narg)
++get(Text *et, Text *t, Text *argt, int flag1, int flag2, Rune *arg, int narg)
+ {
+ char *name;
+ Rune *r;
+@@ -596,8 +602,6 @@
+ Dir *d;
+ long q0, q1;
+
+- USED(_0);
+-
+ if(flag1)
+ if(et==nil || et->w==nil)
+ return;
+@@ -616,6 +620,7 @@
+ free(d);
+ if(isdir){
+ warning(nil, "%s is a directory; can't read with multiple windows on it\n", name);
++ free(name);
+ return;
+ }
+ }
+@@ -635,7 +640,7 @@
+ windirfree(u->w);
+ }
+ samename = runeeq(r, n, t->file->name, t->file->nname);
+- textload(t, 0, name, samename);
++ textload(t, 0, name, samename, flag2);
+ if(samename){
+ t->file->mod = FALSE;
+ dirty = FALSE;
+@@ -1804,4 +1809,35 @@
+ arg[0] = c;
+ arg[1] = cpid;
+ threadcreate(runwaittask, arg, STACK);
++}
++
++void
++dotshow(Text *et, Text *t, Text *argt, int flag1, int flag2, Rune *arg, int narg)
++{
++ Dir *d;
++ int isdir;
++ char *name;
++ Window *w;
++
++ if(flag1)
++ if(et==nil || et->w==nil)
++ return;
++ w = et->w;
++ t = &w->body;
++ name = getname(t, argt, arg, narg, FALSE);
++ if (name==nil) {
++ warning(nil, "no file name\n");
++ return;
++ }
++ d = dirstat(name);
++ isdir = (d!=nil && (d->qid.type & QTDIR));
++ free(d);
++ if (!isdir) {
++ warning(nil, "%s is not a directory\n", name);
++ free(name);
++ return;
++ }
++
++ get(et, t, argt, flag1, flag2, arg, narg);
++ free(name);
+ }
+diff -u a/src/cmd/acme/look.c b/src/cmd/acme/look.c
+--- a/src/cmd/acme/look.c Sun Jan 12 22:18:48 2025
++++ b/src/cmd/acme/look.c Sun Jan 12 22:18:57 2025
+@@ -13,6 +13,7 @@
+ #include <libsec.h>
+ #include "dat.h"
+ #include "fns.h"
++#include "config.h"
+
+ CFid *plumbsendfid;
+ CFid *plumbeditfid;
+@@ -784,7 +785,7 @@
+ w = makenewwindow(t);
+ t = &w->body;
+ winsetname(w, e->name, e->nname);
+- if(textload(t, 0, e->bname, 1) >= 0)
++ if(textload(t, 0, e->bname, 1, Hidedotfiles) >= 0)
+ t->file->unread = FALSE;
+ t->file->mod = FALSE;
+ t->w->dirty = FALSE;
Common subdirectories: a/src/cmd/acme/mail and b/src/cmd/acme/mail
diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
---- a/src/cmd/acme/rows.c Thu Jan 2 21:32:59 2025
-+++ b/src/cmd/acme/rows.c Thu Jan 2 21:33:10 2025
-@@ -28,7 +28,7 @@
+--- a/src/cmd/acme/rows.c Sun Jan 12 22:18:49 2025
++++ b/src/cmd/acme/rows.c Sun Jan 12 22:18:57 2025
+@@ -12,6 +12,7 @@
+ #include <libsec.h>
+ #include "dat.h"
+ #include "fns.h"
++#include "config.h"
+
+ static Rune Lcolhdr[] = {
+ 'N', 'e', 'w', 'c', 'o', 'l', ' ',
+@@ -28,7 +29,7 @@
Rectangle r1;
Text *t;
@@ -233,7 +403,7 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
row->r = r;
row->col = nil;
row->ncol = 0;
-@@ -42,7 +42,7 @@
+@@ -42,7 +43,7 @@
t->col = nil;
r1.min.y = r1.max.y;
r1.max.y += Border;
@@ -242,7 +412,7 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
textinsert(t, 0, Lcolhdr, 29, TRUE);
textsetselect(t, t->file->b.nc, t->file->b.nc);
}
-@@ -73,7 +73,7 @@
+@@ -73,7 +74,7 @@
r = d->r;
if(Dx(r) < 100)
return nil;
@@ -251,7 +421,7 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
r1 = r;
r1.max.x = min(x-Border, r.max.x-50);
if(Dx(r1) < 50)
-@@ -81,7 +81,7 @@
+@@ -81,7 +82,7 @@
colresize(d, r1);
r1.min.x = r1.max.x;
r1.max.x = r1.min.x+Border;
@@ -260,7 +430,7 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
r.min.x = r1.max.x;
}
if(c == nil){
-@@ -115,7 +115,7 @@
+@@ -115,7 +116,7 @@
textresize(&row->tag, r1, TRUE);
r1.min.y = r1.max.y;
r1.max.y += Border;
@@ -269,7 +439,7 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
r.min.y = r1.max.y;
r1 = r;
r1.max.x = r1.min.x;
-@@ -130,7 +130,7 @@
+@@ -130,7 +131,7 @@
if(i > 0){
r2 = r1;
r2.max.x = r2.min.x+Border;
@@ -278,7 +448,7 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
r1.min.x = r2.max.x;
}
colresize(c, r1);
-@@ -191,14 +191,14 @@
+@@ -191,14 +192,14 @@
p.x = c->r.max.x-80-Scrollwid;
r = d->r;
r.max.x = c->r.max.x;
@@ -295,7 +465,7 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
r.min.x = r.max.x;
r.max.x = c->r.max.x;
colresize(c, r);
-@@ -223,7 +223,7 @@
+@@ -223,7 +224,7 @@
memmove(row->col+i, row->col+i+1, (row->ncol-i)*sizeof(Column*));
row->col = realloc(row->col, row->ncol*sizeof(Column*));
if(row->ncol == 0){
@@ -304,7 +474,7 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
return;
}
if(i == row->ncol){ /* extend last column right */
-@@ -234,7 +234,7 @@
+@@ -234,7 +235,7 @@
c = row->col[i];
r.max.x = c->r.max.x;
}
@@ -313,7 +483,7 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
colresize(c, r);
}
-@@ -601,12 +601,12 @@
+@@ -601,12 +602,12 @@
r2.min.x = x;
if(Dx(r1) < 50 || Dx(r2) < 50)
continue;
@@ -328,10 +498,45 @@ diff -u a/src/cmd/acme/rows.c b/src/cmd/acme/rows.c
}
if(i >= row->ncol)
rowadd(row, nil, x);
+@@ -782,7 +783,7 @@
+ }
+ Bterm(bout);
+ free(bout);
+- textload(&w->body, 0, buf, 1);
++ textload(&w->body, 0, buf, 1, Hidedotfiles);
+ remove(buf);
+ close(fd);
+ w->body.file->mod = TRUE;
diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
---- a/src/cmd/acme/text.c Thu Jan 2 21:32:59 2025
-+++ b/src/cmd/acme/text.c Thu Jan 2 21:33:10 2025
-@@ -667,7 +667,7 @@
+--- a/src/cmd/acme/text.c Sun Jan 12 22:18:49 2025
++++ b/src/cmd/acme/text.c Sun Jan 12 22:18:57 2025
+@@ -12,6 +12,7 @@
+ #include <complete.h>
+ #include "dat.h"
+ #include "fns.h"
++#include "config.h"
+
+ Image *tagcols[NCOL];
+ Image *textcols[NCOL];
+@@ -190,7 +191,7 @@
+ }
+
+ int
+-textload(Text *t, uint q0, char *file, int setqid)
++textload(Text *t, uint q0, char *file, int setqid, int hidedotfiles)
+ {
+ Rune *rp;
+ Dirlist *dl, **dlp;
+@@ -243,6 +244,8 @@
+ dbuf = nil;
+ while((n=dirread(fd, &dbuf)) > 0){
+ for(i=0; i<n; i++){
++ if (hidedotfiles==TRUE && dbuf[i].name[0]=='.')
++ continue;
+ dl = emalloc(sizeof(Dirlist));
+ j = strlen(dbuf[i].name);
+ tmp = emalloc(j+1+1);
+@@ -667,7 +670,7 @@
void
texttype(Text *t, Rune r)
{
@@ -340,7 +545,7 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
int nnb, nb, n, i;
int nr;
Rune *rp;
-@@ -694,8 +694,21 @@
+@@ -694,8 +697,21 @@
case Kdown:
if(t->what == Tag)
goto Tagdown;
@@ -364,7 +569,7 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
case Kscrollonedown:
if(t->what == Tag)
goto Tagdown;
-@@ -712,8 +725,18 @@
+@@ -712,8 +728,18 @@
case Kup:
if(t->what == Tag)
goto Tagup;
@@ -385,7 +590,7 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
case Kscrolloneup:
if(t->what == Tag)
goto Tagup;
-@@ -840,6 +863,12 @@
+@@ -840,6 +866,12 @@
else
textsetselect(t, t->q0, t->eq0);
}
@@ -398,7 +603,7 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
if(t->ncache > 0)
typecommit(t);
t->iq1 = t->q0;
-@@ -1258,7 +1287,7 @@
+@@ -1258,7 +1290,7 @@
};
uint
@@ -407,7 +612,7 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
{
uint p0, p1, q, tmp;
ulong msec;
-@@ -1291,12 +1320,12 @@
+@@ -1291,12 +1323,12 @@
pt1 = pt0;
reg = region(q, p0);
if(reg == 0)
@@ -422,7 +627,7 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
else if(q < p1)
selrestore(f, qt, q, p1);
-@@ -1304,7 +1333,7 @@
+@@ -1304,7 +1336,7 @@
if(q > p1)
selrestore(f, pt1, p1, q);
else
@@ -431,7 +636,7 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
}
p1 = q;
pt1 = qt;
-@@ -1341,12 +1370,12 @@
+@@ -1341,12 +1373,12 @@
}
int
@@ -446,7 +651,7 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
buts = mousectl->m.buttons;
if((buts & mask) == 0){
*q0 = p0+t->org;
-@@ -1364,7 +1393,7 @@
+@@ -1364,7 +1396,7 @@
int buts;
*tp = nil;
@@ -455,7 +660,7 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
if(buts & 4)
return 0;
if(buts & 1){ /* pick up argument */
-@@ -1379,7 +1408,7 @@
+@@ -1379,7 +1411,7 @@
{
int h;
@@ -466,8 +671,8 @@ diff -u a/src/cmd/acme/text.c b/src/cmd/acme/text.c
Only in b/src/cmd/acme: tfile
diff -u a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
---- a/src/cmd/acme/wind.c Thu Jan 2 21:32:59 2025
-+++ b/src/cmd/acme/wind.c Thu Jan 2 21:33:10 2025
+--- a/src/cmd/acme/wind.c Sun Jan 12 22:18:49 2025
++++ b/src/cmd/acme/wind.c Sun Jan 12 22:18:57 2025
@@ -235,7 +235,6 @@
r1.min.y = min(y, r.max.y);
r1.max.y = r.max.y;