Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: arguments for insert-composed-char



I could have sworn I'd sent this but I can't see it...

Index: Doc/Zsh/contrib.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/contrib.yo,v
retrieving revision 1.50
diff -u -r1.50 contrib.yo
--- Doc/Zsh/contrib.yo	19 Oct 2005 22:49:38 -0000	1.50
+++ Doc/Zsh/contrib.yo	21 Oct 2005 09:20:54 -0000
@@ -671,6 +671,13 @@
 two-character codes are a subset of those given by RFC 1345 (see for
 example tt(http://www.faqs.org/rfcs/rfc1345.html)).
 
+The function may optionally be followed by up to two characters which
+replace one or both of the characters read from the keyboard; if both
+characters are supplied, no input is read.  For example,
+tt(insert-composed-char a:) can be used within a widget to insert an a with
+umlaut into the command line.  This has the advantages over use of a
+literal character that it is more portable.
+
 For best results zsh should have been built with support for multibyte
 characters (configured with tt(--enable-multibyte)); however, the function
 works for the limited range of characters available in single-byte
Index: Functions/Zle/insert-composed-char
===================================================================
RCS file: /cvsroot/zsh/zsh/Functions/Zle/insert-composed-char,v
retrieving revision 1.2
diff -u -r1.2 insert-composed-char
--- Functions/Zle/insert-composed-char	22 Sep 2005 22:23:45 -0000	1.2
+++ Functions/Zle/insert-composed-char	21 Oct 2005 09:20:54 -0000
@@ -147,8 +147,22 @@
   unfunction define-composed-chars
 fi
 
-read -k basechar || return 1
-read -k accent || return 1
+if (( $# )); then
+  basechar=${1[1]}
+  if [[ $1 = ? ]]; then
+    shift
+  else
+    1=${1[2,-1]}
+  fi
+else
+  read -k basechar || return 1
+fi
+
+if (( $# )); then
+  accent=${1[1]}
+else
+  read -k accent || return 1
+fi
 
 local -A charmap
 charmap=(${=zsh_accented_chars[$accent]})

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com



Messages sorted by: Reverse Date, Date, Thread, Author