about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-08-13 12:34:20 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-08-13 12:34:20 +0000
commit3fcbcf8a79b81230201f0e362eddb2399f4ca76e (patch)
treea7779ea5e23309f2c555a22d1fc07eb8127e2da5
parent73af1e03100d32ef10bfd303a9b156d3c8e789aa (diff)
downloadzsh-3fcbcf8a79b81230201f0e362eddb2399f4ca76e.tar.gz
zsh-3fcbcf8a79b81230201f0e362eddb2399f4ca76e.tar.xz
zsh-3fcbcf8a79b81230201f0e362eddb2399f4ca76e.zip
zsh-workers/7430
-rw-r--r--Completion/User/_colors14
-rw-r--r--Completion/User/_cursors15
-rw-r--r--Completion/User/_x_options4
-rw-r--r--Completion/User/_xsetroot15
-rw-r--r--Src/Zle/zle_tricky.c48
5 files changed, 70 insertions, 26 deletions
diff --git a/Completion/User/_colors b/Completion/User/_colors
index 797a7d7b3..7a7b0824b 100644
--- a/Completion/User/_colors
+++ b/Completion/User/_colors
@@ -5,16 +5,10 @@ if (( ! $+_color_cache )); then
 
   # Cache of color names doesn't exist yet, create it.
 
-  for f in /usr/{,local/,X11R6/,openwin/}lib/X11/rgb.txt
-  do
-    if [[ -f $f ]]; then
-      file=$f
-      break;
-    fi
-  done
+  file=( /usr/{lib,{{X11R6,openwin},local{,/X11{,R6}}}/lib}/X11/rgb.txt )
 
-  if [[ -n "$file" ]]; then
-    _color_cache=( "${(@)${(@f)$(< $file)}[2,-1]##*		}" )
+  if (( $#file )); then
+    _color_cache=( "${(@)${(@f)$(< $file[1])}[2,-1]##*		}" )
   else
 
     # Stupid default value.
@@ -23,4 +17,4 @@ if (( ! $+_color_cache )); then
   fi
 fi
 
-compadd - "$_color_cache[@]"
+compadd -M 'm:{a-z}={A-Z} m:-=\  r:|[ A-Z0-9]=* r:|=*' - "$_color_cache[@]"
diff --git a/Completion/User/_cursors b/Completion/User/_cursors
new file mode 100644
index 000000000..7e5cbc44e
--- /dev/null
+++ b/Completion/User/_cursors
@@ -0,0 +1,15 @@
+#autoload
+
+if (( ! $+_cursor_cache )); then
+  local file
+
+  file=( /usr/{include,{{X11R6,openwin},local{,/X11{,R6}}}/include}/X11/cursorfont.h(N) )
+
+  if (( $#file )); then
+    _cursor_cache=( "${(@)${(@)${(M@)${(@f)$(< $file[1])}:#*XC_*}[2,-1]#* XC_}% *}" )
+  else
+    _cursor_cache=( X_cursor )
+  fi
+fi
+
+compadd -M 'm:-=_ r:|_=*' - "$_cursor_cache[@]"
diff --git a/Completion/User/_x_options b/Completion/User/_x_options
index 51b602a33..9c3a303bb 100644
--- a/Completion/User/_x_options
+++ b/Completion/User/_x_options
@@ -4,7 +4,7 @@
 
 if [ "$words[CURRENT-1]" = "-display" ]; then
   _compskip=all
-  _hosts -S :0
+  _hosts -S ':0 ' -r :
 else
-  compadd -P- -J options - display name xrm
+  compadd -J options - -display -name -xrm
 fi
diff --git a/Completion/User/_xsetroot b/Completion/User/_xsetroot
new file mode 100644
index 000000000..74a0b6180
--- /dev/null
+++ b/Completion/User/_xsetroot
@@ -0,0 +1,15 @@
+#compdef xsetroot
+
+case "$words[CURRENT-1]" in
+-cursor) _files -/g '*.(#i)(xbm|curs(|or))'; return;;
+-cursor_name) _cursors; return;;
+-bitmap) _files -/g '*.(#i)xbm'; return;;
+-([fb]g|solid)) _colors; return;;
+esac
+
+if [[ CURRENT -gt 2 && "$words[CURRENT-2]" = -cursor ]]; then
+  _files -/g '*.(#i)(xbm|curs(|or)|mask)'
+else
+  compadd -M 'm:-=_ r:|_=*' - -help -def -cursor -cursor_name -bitmap -mod -gray -grey \
+                       -fg -bg -rv -solid -name
+fi
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index ed32d312f..a279c8de3 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2294,7 +2294,7 @@ match_str(char *l, char *w, int *bp, int *rwlp, int sfx, int test)
 	for (mp = NULL, ms = mstack; !mp && ms; ms = ms->next) {
 	    for (mp = ms->matcher; mp; mp = mp->next) {
 		t = 1;
-		if (lm == mp ||
+		if ((lm && lm == mp) ||
 		    ((oll == ll || olw == lw) && test && mp->wlen < 0))
 		    /* If we were called recursively, don't use `*' patterns
 		     * at the beginning (avoiding infinite recursion). */
@@ -2335,8 +2335,9 @@ match_str(char *l, char *w, int *bp, int *rwlp, int sfx, int test)
 			continue;
 		    if (ap) {
 			if (!pattern_match(ap, l + aoff, NULL, NULL) ||
-			    (both && !pattern_match(ap, w + aoff, NULL, NULL)))
-			    continue;
+			    (both && (!pattern_match(ap, w + aoff, NULL, NULL) ||
+				      !match_parts(l + aoff, w + aoff, alen))))
+				continue;
 		    } else if (!both || il || iw)
 			continue;
 
@@ -2346,11 +2347,12 @@ match_str(char *l, char *w, int *bp, int *rwlp, int sfx, int test)
 			savl = l[-(llen + zoff)];
 			l[-(llen + zoff)] = '\0';
 		    }
-		    for (t = 0, tp = w, ct = 0, ict = lw - alen;
+		    for (t = 0, tp = w, ct = 0, ict = lw - alen + 1;
 			 ict;
 			 tp += add, ct++, ict--) {
 			if (both ||
-			    pattern_match(ap, tp - moff, NULL, NULL)) {
+			    (pattern_match(ap, tp - moff, NULL, NULL) &&
+			     match_parts(l + aoff , tp - moff, alen))) {
 			    if (sfx) {
 				savw = tp[-zoff];
 				tp[-zoff] = '\0';
@@ -2598,6 +2600,24 @@ match_str(char *l, char *w, int *bp, int *rwlp, int sfx, int test)
     return iw;
 }
 
+/* Wrapper for match_str(), only for a certain length and only doing
+ * the test. */
+
+/**/
+static int
+match_parts(char *l, char *w, int n)
+{
+    char lsav = l[n], wsav = w[n];
+    int ret;
+
+    l[n] = w[n] = '\0';
+    ret = match_str(l, w, NULL, NULL, 0, 1);
+    l[n] = lsav;
+    w[n] = wsav;
+
+    return ret;
+}
+
 /* Check if the word w is matched by the strings in pfx and sfx (the prefix
  * and the suffix from the line) or the pattern cp. In clp a cline list for
  * w is returned.
@@ -2928,7 +2948,7 @@ cmp_anchors(Cline o, Cline n, int join)
 	return 1;
     }
     /* Didn't work, try to build a string matching both anchors. */
-    if (join && !(o->flags & CLF_JOIN) &&
+    if (join && !(o->flags & CLF_JOIN) && o->word && n->word &&
 	(j = join_strs(o->wlen, o->word, n->wlen, n->word))) {
 	o->flags |= CLF_JOIN;
 	o->wlen = strlen(j);
@@ -3397,6 +3417,10 @@ join_clines(Cline o, Cline n)
 			 (o->flags  & (CLF_SUF | CLF_MID));
 		     t = tn);
 		if (tn && cmp_anchors(o, tn, 1)) {
+		    Cline t;
+
+		    t = tn->prefix; tn->prefix = n->prefix; n->prefix = t;
+		    t = tn->suffix; tn->suffix = n->suffix; n->suffix = t;
 		    n = tn;
 		    continue;
 		}
@@ -3429,20 +3453,18 @@ join_clines(Cline o, Cline n)
 	    }
 	    /* Now see if they have matching anchors. If not, cut the list. */
 	    if (!(o->flags & CLF_MID) && !cmp_anchors(o, n, 1)) {
-#if 0
-		/* This used to search forward for matching anchors.
-		 * Unfortunately this does the wrong thing if the prefixes
-		 * before the differing anchors match nicely. */
-
 		Cline t, tn;
 
 		for (t = n; (tn = t->next) && !cmp_anchors(o, tn, 1); t = tn);
 
 		if (tn) {
+		    Cline t;
+
+		    t = tn->prefix; tn->prefix = n->prefix; n->prefix = t;
+		    t = tn->suffix; tn->suffix = n->suffix; n->suffix = t;
 		    n = tn;
 		    continue;
 		} else {
-#endif
 		    if (o->flags & CLF_SUF)
 			break;
 
@@ -3451,9 +3473,7 @@ join_clines(Cline o, Cline n)
 		    free_cline(o->next);
 		    o->next = NULL;
 		    o->flags |= CLF_MISS;
-#if 0
 		}
-#endif
 	    }
 	    /* Ok, they are equal, now join the sub-lists. */
 	    if (o->flags & CLF_MID)