From: Alexandre Duret-Lutz <duret_g@epita.fr>
To: zsh-workers@math.gatech.edu
Subject: Re: playing with backreferences in list-colors
Date: 24 Jan 2000 16:07:31 +0100 [thread overview]
Message-ID: <mvbemb7fqz0.fsf@phobos.lrde.epita.fr> (raw)
In-Reply-To: Sven Wischnowsky's message of "Mon, 24 Jan 2000 10:54:43 +0100 (MET)"
After 9408 and 9416, I have still some problems :
1) listcolor stop colorization on the first (-1,-1) backref,
even if there are valid backrefs after.
2) colorization of enclosed backrefs are wrongs.
Let's say O denotes color for the outer block, I the inner color,
N means no color. And I am matching over a 8 letter string.
((??)??)* -> OOOONNNN
(?(??)?)* -> 0IIIONNN
(??(??))* -> OOIIONNN
I expect the patch below to fix these two points. Sorting the
end positions was needed to fix this second point (at least I
didn't find any better way to do that).
The test `endpos[curisbeg] < begpos[curisbeg]' of the patch
is there to handle cases like :
~ % [[ fbar = (#b)f((o)#)bar ]]
~ % echo $mbegin / $mend
2 -1 / 1 -1
where the outer backref matched the empty string
(empty strings don't need to be colored, I think).
Index: Src/Zle/complist.c
--- Src/Zle/complist.c Mon, 24 Jan 2000 13:43:41 +0100 Alexandre
+++ Src/Zle/complist.c Mon, 24 Jan 2000 15:25:07 +0100 Alexandre
@@ -391,7 +391,8 @@
static int nrefs;
static int begpos[MAX_POS], curisbeg;
-static int endpos[MAX_POS], curisend;
+static int endpos[MAX_POS];
+static int sendpos[MAX_POS], curissend; /* sorted end positions */
static char **patcols, *curiscols[MAX_POS];
static int curiscol;
@@ -450,29 +451,45 @@
curiscols[curiscol = 0] = *patcols++;
- curisbeg = curisend = 0;
+ curisbeg = curissend = 0;
- for (i = nrefs; i < MAX_POS; i++)
- begpos[i] = endpos[i] = -1;
+ for (i = 0; i < nrefs; i++)
+ sendpos[i] = 0xfffffff;
+ for (; i < MAX_POS; i++)
+ begpos[i] = endpos[i] = sendpos[i] = 0xfffffff;
}
static void
doiscol(Listcols c, int pos)
{
- if (endpos[curisend] >= 0 && pos > endpos[curisend]) {
- curisend++;
+ int fi;
+
+ while (pos > sendpos[curissend]) {
+ curissend++;
if (curiscol) {
zcputs(c, NULL, COL_NO);
zlrputs(c, curiscols[--curiscol]);
}
}
- if (pos == begpos[curisbeg] && *patcols) {
- curisbeg++;
-
- zcputs(c, NULL, COL_NO);
- zlrputs(c, *patcols);
-
- curiscols[++curiscol] = *patcols++;
+ while (((fi = (endpos[curisbeg] < begpos[curisbeg] ||
+ begpos[curisbeg] == -1)) ||
+ pos == begpos[curisbeg]) && *patcols) {
+ if (!fi) {
+ int i, j, e = endpos[curisbeg];
+
+ /* insert e in sendpos */
+ for (i = curissend; sendpos[i] <= e; ++i)
+ ;
+ for (j = i + 1; j < MAX_POS; ++j)
+ sendpos[j] = sendpos[j-1];
+ sendpos[i] = e;
+
+ zcputs(c, NULL, COL_NO);
+ zlrputs(c, *patcols);
+ curiscols[++curiscol] = *patcols;
+ }
+ ++patcols;
+ ++curisbeg;
}
}
--
Alexandre Duret-Lutz
next prev parent reply other threads:[~2000-01-24 15:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-01-24 9:54 Sven Wischnowsky
2000-01-24 15:07 ` Alexandre Duret-Lutz [this message]
2000-01-28 6:14 ` Bart Schaefer
2000-01-28 6:18 ` Bart Schaefer
-- strict thread matches above, loose matches on Subject: below --
2000-01-28 8:14 Sven Wischnowsky
2000-01-24 9:14 Sven Wischnowsky
2000-01-22 17:17 Alexandre Duret-Lutz
2000-01-22 19:53 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mvbemb7fqz0.fsf@phobos.lrde.epita.fr \
--to=duret_g@epita.fr \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).