* Re: Problem with setting both listpacked&listrowsfirst?
@ 1999-10-12 7:19 Sven Wischnowsky
0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 1999-10-12 7:19 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote:
> [ ... ] Sven, I know it's going to be two
> weeks until you read this, but: I thought you were going to start using
> more descriptive variable names?
Yes, but that was mostly copied from an older version I had and I
didn't have much time then. The patch below should make things
clearer (I hope ;-).
Bye
Sven
diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c Mon Oct 11 20:10:25 1999
+++ Src/Zle/zle_tricky.c Mon Oct 11 21:28:40 1999
@@ -8817,14 +8817,14 @@
}
if (isset(LISTPACKED)) {
char **pp;
- int *ws, j, k, cl, ml, mm;
+ int *ws, tlines, tline, tcols, maxlen, nth, width;
for (g = amatches; g; g = g->next) {
ws = g->widths = (int *) zalloc(columns * sizeof(int));
memset(ws, 0, columns * sizeof(int));
- i = g->lins;
- mm = g->cols;
- cl = 0;
+ tlines = g->lins;
+ tcols = g->cols;
+ width = 0;
if ((pp = g->ylist)) {
if (!(g->flags & CGF_LINES)) {
@@ -8835,139 +8835,145 @@
ylens[i] = strlen(*pp) + add;
if (isset(LISTROWSFIRST)) {
- int x, l = 0, v;
+ int count, tcol, first, maxlines = 0, llines;
- for (mm = columns / g->shortest; mm > g->cols; mm--) {
- for (j = i = ml = cl = l = v = x = 0,
- k = g->dcount;
- k > 0; k--) {
- if (ylens[j] > ml)
- ml = ylens[j];
- j += mm;
- v++;
- if (j >= g->dcount) {
- if ((cl += ml) >= columns)
+ for (tcols = columns / g->shortest; tcols > g->cols;
+ tcols--) {
+ for (nth = first = maxlen = width = maxlines =
+ llines = tcol = 0,
+ count = g->dcount;
+ count > 0; count--) {
+ if (ylens[nth] > maxlen)
+ maxlen = ylens[nth];
+ nth += tcols;
+ tlines++;
+ if (nth >= g->dcount) {
+ if ((width += maxlen) >= columns)
break;
- ws[x++] = ml;
- ml = 0;
- j = ++i;
- if (v > l)
- l = v;
- v = 0;
+ ws[tcol++] = maxlen;
+ maxlen = 0;
+ nth = ++first;
+ if (llines > maxlines)
+ maxlines = llines;
+ llines = 0;
}
}
- if (j < yl) {
- ws[x++] = ml;
- cl += ml;
+ if (nth < yl) {
+ ws[tcol++] = maxlen;
+ width += maxlen;
}
- if (!k && cl < columns)
+ if (!count && width < columns)
break;
}
- if (mm > g->cols)
- i = l;
+ if (tcols > g->cols)
+ tlines = maxlines;
} else {
- for (i = ((g->totl + columns) / columns);
- i < g->lins; i++) {
- for (pp = g->ylist, j = k = cl = ml = mm;
- *pp; j++, pp++) {
- if (ylens[j] > ml)
- ml = ylens[j];
- if (++k == i) {
- if ((cl += ml) >= columns)
+ for (tlines = ((g->totl + columns) / columns);
+ tlines < g->lins; tlines++) {
+ for (pp = g->ylist, nth = tline = width =
+ maxlen = tcols = 0;
+ *pp; nth++, pp++) {
+ if (ylens[nth] > maxlen)
+ maxlen = ylens[nth];
+ if (++tline == tlines) {
+ if ((width += maxlen) >= columns)
break;
- ws[mm++] = ml;
- ml = k = 0;
+ ws[tcols++] = maxlen;
+ maxlen = tline = 0;
}
}
- if (k) {
- ws[mm++] = ml;
- cl += ml;
+ if (tline) {
+ ws[tcols++] = maxlen;
+ width += maxlen;
}
- if (j == yl && cl < columns)
+ if (nth == yl && width < columns)
break;
}
}
}
} else if (g->width) {
if (isset(LISTROWSFIRST)) {
- int x, l = 0, v, al;
- Cmatch *q;
+ int addlen, count, tcol, maxlines = 0, llines, i;
+ Cmatch *first;
- for (mm = columns / g->shortest; mm > g->cols; mm--) {
- p = q = skipnolist(g->matches);
- for (i = ml = cl = l = v = x = 0, k = g->dcount;
- k > 0; k--) {
+ for (tcols = columns / g->shortest; tcols > g->cols;
+ tcols--) {
+ p = first = skipnolist(g->matches);
+ for (maxlen = width = maxlines = llines = tcol = 0,
+ count = g->dcount;
+ count > 0; count--) {
m = *p;
- al = mlens[m->gnum] + add;
- if (al > ml)
- ml = al;
- for (j = mm; j && *p; j--)
+ addlen = mlens[m->gnum] + add;
+ if (addlen > maxlen)
+ maxlen = addlen;
+ for (i = tcols; i && *p; i--)
p = skipnolist(p + 1);
- v++;
+ llines++;
if (!*p) {
- if (v > l)
- l = v;
- v = 0;
+ if (llines > maxlines)
+ maxlines = llines;
+ llines = 0;
- if ((cl += ml) >= columns)
+ if ((width += maxlen) >= columns)
break;
- ws[x++] = ml;
- ml = 0;
+ ws[tcol++] = maxlen;
+ maxlen = 0;
- p = q = skipnolist(q + 1);
+ p = first = skipnolist(first + 1);
}
}
- if (v) {
- ws[x++] = ml;
- cl += ml;
+ if (tlines) {
+ ws[tcol++] = maxlen;
+ width += maxlen;
}
- if (!k && cl < columns)
+ if (!count && width < columns)
break;
}
- if (mm > g->cols)
- i = l;
+ if (tcols > g->cols)
+ tlines = maxlines;
} else {
- int al;
+ int addlen;
- for (i = ((g->totl + columns) / columns);
- i < g->lins; i++) {
- for (p = g->matches, j = k = cl = ml = mm = 0;
- (m = *p); p++, j++) {
+ for (tlines = ((g->totl + columns) / columns);
+ tlines < g->lins; tlines++) {
+ for (p = g->matches, nth = tline = width =
+ maxlen = tcols = 0;
+ (m = *p); p++, nth++) {
if (!(m->flags &
(m->disp ? (CMF_DISPLINE | CMF_HIDE) :
(CMF_NOLIST | CMF_HIDE)))) {
- al = mlens[m->gnum] + add;
- if (al > ml)
- ml = al;
- if (++k == i) {
- if ((cl += ml) >= columns)
+ addlen = mlens[m->gnum] + add;
+ if (addlen > maxlen)
+ maxlen = addlen;
+ if (++tline == tlines) {
+ if ((width += maxlen) >= columns)
break;
- ws[mm++] = ml;
- ml = k = 0;
+ ws[tcols++] = maxlen;
+ maxlen = tline = 0;
}
}
}
- if (k) {
- ws[mm++] = ml;
- cl += ml;
+ if (tline) {
+ ws[tcols++] = maxlen;
+ width += maxlen;
}
- if (j == g->dcount && cl < columns)
+ if (nth == g->dcount && width < columns)
break;
}
}
}
- if (i == g->lins) {
+ if (tlines == g->lins) {
zfree(ws, columns * sizeof(int));
g->widths = NULL;
} else {
- nlines += i - g->lins;
- g->lins = i;
- g->cols = mm;
- g->totl = cl;
- cl -= add;
- if (cl > max)
- max = cl;
+ nlines += tlines - g->lins;
+ g->lins = tlines;
+ g->cols = tcols;
+ g->totl = width;
+ width -= add;
+ if (width > max)
+ max = width;
}
}
for (g = amatches; g; g = g->next) {
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 3+ messages in thread
* Problem with setting both listpacked&listrowsfirst?
@ 1999-09-24 6:31 Felix Rosencrantz
1999-09-25 22:07 ` Bart Schaefer
0 siblings, 1 reply; 3+ messages in thread
From: Felix Rosencrantz @ 1999-09-24 6:31 UTC (permalink / raw)
To: zsh-workers
I think I've applied all the completion patches to ZSH 3.1.6-pws-5.
(7959 7960 7974 7985 7998 8011 8021 8028)
When I do a "setopt listpacked listrowsfirst" and attempt completion with tab I
don't get a listing for ambiguous matches.
-FR
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Problem with setting both listpacked&listrowsfirst?
1999-09-24 6:31 Felix Rosencrantz
@ 1999-09-25 22:07 ` Bart Schaefer
0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1999-09-25 22:07 UTC (permalink / raw)
To: zsh-workers
On Sep 23, 11:31pm, Felix Rosencrantz wrote:
} Subject: Problem with setting both listpacked&listrowsfirst?
}
} I think I've applied all the completion patches to ZSH 3.1.6-pws-5.
} (7959 7960 7974 7985 7998 8011 8021 8028)
}
} When I do a "setopt listpacked listrowsfirst" and attempt completion
} with tab I don't get a listing for ambiguous matches.
I can reproduce this, but ONLY if using the new-style completions, and
then (so far) only for normal file completions (e.g. completion after
"ls"). It's got something to do with lines 8880-8919 of zle_tricky.c,
and how the value of `i' is computed (Sven, I know it's going to be two
weeks until you read this, but: I thought you were going to start using
more descriptive variable names?).
I tried a few different tweaks, but although I got it to display the list
I couldn't get it to position the cursor properly afterwards.
I can't figure out how to get zsh to enter the branch at 8826-8856, so
I don't know whether that has a problem as well.
Even for completions that do work, the columns are ragged:
zagzig<4> set<TAB>
set setclock setconsole setenv setfdprm setfont
setfx setkeycodes setleds setmetamode setopt setserial
setsid setsysfont setterm setup setup_compinit setxkbmap
I don't know of that's an intended side-effect of LISTPACKED or not, but
it doesn't always happen.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-10-12 7:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-12 7:19 Problem with setting both listpacked&listrowsfirst? Sven Wischnowsky
-- strict thread matches above, loose matches on Subject: below --
1999-09-24 6:31 Felix Rosencrantz
1999-09-25 22:07 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).