[-- Attachment #1.1: Type: text/plain, Size: 553 bytes --]
A patch I've been using for a few days now, thought maybe
someone else will find it useful as well.
Without the patch, Ctrl+F (or Insert) triggers file name
completion, but when you have more than 32 matching items,
it just prints "[XX files]" and gives up. This patch adds
to the behavior: rio provides more and more matching items
if you continue pressing Ctrl+F, despite the initial
message. It stops when the current completion does not
give results anymore, so as not to spam with duplicates
if your key repeat rate is as high as mine.
[-- Attachment #2.1: Type: text/plain, Size: 363 bytes --]
from postmaster@9front:
The following attachment had content that we can't
prove to be harmless. To avoid possible automatic
execution, we changed the content headers.
The original header was:
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=rio-completion.patch
Content-Type: text/x-patch; charset=utf-8; name=rio-completion.patch
[-- Attachment #2.2: rio-completion.patch.suspect --]
[-- Type: application/octet-stream, Size: 3620 bytes --]
diff b75e549126641108880a24a4ff0b38171eb1a856 uncommitted
--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -136,6 +137,7 @@
Channel *kbdread; /* chan(Consreadmesg) */
Channel *complete; /* chan(Completion*) */
Channel *gone; /* chan(char*) */
+ int ncomplete;
uint nr; /* number of runes in window */
uint maxr; /* number of runes allocated in r */
Rune *r;
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -242,6 +242,40 @@
}
static void
+wdelete(Window *w, uint q0, uint q1)
+{
+ uint n, p0, p1;
+
+ n = q1-q0;
+ if(n == 0)
+ return;
+ runemove(w->r+q0, w->r+q1, w->nr-q1);
+ w->nr -= n;
+ if(q0 < w->q0)
+ w->q0 -= min(n, w->q0-q0);
+ if(q0 < w->q1)
+ w->q1 -= min(n, w->q1-q0);
+ if(q1 < w->qh)
+ w->qh -= n;
+ else if(q0 < w->qh)
+ w->qh = q0;
+ if(q1 <= w->org)
+ w->org -= n;
+ else if(q0 < w->org+w->nchars){
+ p1 = q1 - w->org;
+ if(p1 > w->nchars)
+ p1 = w->nchars;
+ if(q0 < w->org){
+ w->org = q0;
+ p0 = 0;
+ }else
+ p0 = q0 - w->org;
+ frdelete(w, p0, p1);
+ wfill(w);
+ }
+}
+
+static void
wsetselect(Window *w, uint q0, uint q1)
{
int p0, p1;
@@ -519,7 +540,7 @@
static void
showcandidates(Window *w, Completion *c)
{
- int i;
+ int i, n, i0, toomuch;
Fmt f;
Rune *rp;
uint nr, qline;
@@ -526,20 +547,28 @@
char *s;
runefmtstrinit(&f);
+ toomuch = c->nfile > 32;
+ n = w->ncomplete++;
if (c->nmatch == 0)
s = "[no matches in ";
else
- s = "[";
- if(c->nfile > 32)
+ s = (n<1 || (toomuch && n==1)) ? "[" : "";
+ if(toomuch && n < 1)
fmtprint(&f, "%s%d files]\n", s, c->nfile);
else{
fmtprint(&f, "%s", s);
- for(i=0; i<c->nfile; i++){
+ n -= toomuch;
+ i0 = n*33;
+ for(i=i0; i<c->nfile && i<(n+1)*33; i++){
if(i > 0)
fmtprint(&f, " ");
fmtprint(&f, "%s", c->filename[i]);
}
- fmtprint(&f, "]\n");
+ if(i==i0){
+ free(runefmtstrflush(&f));
+ return;
+ }
+ fmtprint(&f, i>=c->nfile ? "]\n" : " …\n");
}
rp = runefmtstrflush(&f);
nr = runestrlen(rp);
@@ -553,6 +582,10 @@
/* advance host point to avoid readback */
w->qh = winsert(w, rp, nr, qline)+nr;
} else {
+ if(qline>2 && w->r[qline-2]==L'…' && w->r[qline-3]==' '){
+ qline -= 3;
+ wdelete(w, qline, qline+3);
+ }
winsert(w, rp, nr, qline);
}
free(rp);
@@ -709,40 +742,6 @@
wshow(w, w->nr);
}
-static void
-wdelete(Window *w, uint q0, uint q1)
-{
- uint n, p0, p1;
-
- n = q1-q0;
- if(n == 0)
- return;
- runemove(w->r+q0, w->r+q1, w->nr-q1);
- w->nr -= n;
- if(q0 < w->q0)
- w->q0 -= min(n, w->q0-q0);
- if(q0 < w->q1)
- w->q1 -= min(n, w->q1-q0);
- if(q1 < w->qh)
- w->qh -= n;
- else if(q0 < w->qh)
- w->qh = q0;
- if(q1 <= w->org)
- w->org -= n;
- else if(q0 < w->org+w->nchars){
- p1 = q1 - w->org;
- if(p1 > w->nchars)
- p1 = w->nchars;
- if(q0 < w->org){
- w->org = q0;
- p0 = 0;
- }else
- p0 = q0 - w->org;
- frdelete(w, p0, p1);
- wfill(w);
- }
-}
-
void
wcut(Window *w)
{
@@ -859,6 +858,8 @@
if(w->i==nil)
return;
+ if(r != Kack && r != Kins)
+ w->ncomplete = 0;
/* navigation keys work only when mouse and kbd is not open */
if(!w->mouseopen)
switch(r){
@@ -1472,6 +1482,8 @@
incref(w); /* hold up window while we track */
if(w->i != nil){
+ if(but < 4)
+ w->ncomplete = 0;
if(shiftdown && but > 3)
wkeyctl(w, but == 4 ? Kscrolloneup : Kscrollonedown);
else if(ptinrect(w->mc.xy, w->scrollr) || (but > 3))
@@ -1743,6 +1754,7 @@
if(!cr->advance)
showcandidates(w, cr);
if(cr->advance){
+ w->ncomplete = 0;
rp = runesmprint("%s", cr->string);
if(rp){
nr = runestrlen(rp);