From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9481 invoked from network); 16 Feb 2002 20:05:21 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 16 Feb 2002 20:05:21 -0000 Received: (qmail 16667 invoked by alias); 16 Feb 2002 20:05:05 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4681 Received: (qmail 16643 invoked from network); 16 Feb 2002 20:05:04 -0000 Date: Sat, 16 Feb 2002 20:05:00 +0000 From: Ian Lynagh To: zsh-users@sunsite.dk Subject: Re: vim-a-like vi mode status bar Message-ID: <20020216200500.GA1720@stu163.keble.ox.ac.uk> Mail-Followup-To: zsh-users@sunsite.dk References: <20020216172000.GA892@stu163.keble.ox.ac.uk> <20020216174804.GA11720@picard.franken.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20020216174804.GA11720@picard.franken.de> User-Agent: Mutt/1.3.25i Sender: Ian Lynagh Hi, On Sat, Feb 16, 2002 at 06:48:05PM +0100, Thomas K=F6hler wrote: >=20 > Ian Lynagh wrote [020216 18:28]: > > I have thought it would be nice to have a vim-a-like indicator of > > whether or not you are insert or command mode when using the vi line > > editting mode for a long time now. In a burst of enthusiasm I have put > > something together over the last couple of days (attached). However it's > > not quite as nice as it might have been and I have run into a few > > annoyances along the way. >=20 > Well, I use something similar. Of course, I have a multiline Thanks, very interesting to see another implementation. > prompt, so what I have here might work for you, but it might need > some adjustment - the escape sequences for moving the cursor > might not work for your type of terminal... That's an approach I thought of but decided against, partly because of the potential terminal issues and partly because of the cases like multi-line input and screen clearing. However, you seem to have these mostly[0] sussed so I might switch to this with a simple command to switch to a simpler prompt if I do happen to be using a less fancy terminal. [0] It still looks like it has problems when the prompt has scrolled off the top of the screen, at least in an rxvt. This should also solve a few of my current problems (flicker, characters not being echoed when pasted and having the default state shown). I do have a couple of further questions for you though... > redisplay() { > builtin zle .redisplay > ( true ; show_mode "INSERT") &! > } I am not sure why you have the &! here - if it is worth doing then that implies you might do something else before it has finished in which case your cursor might not be where you think it is? It also seems to me you might be better off with a variable (or zstyle lookup or whatever) for the current state and a single redisplay. This would have the advantage that you wouldn't have to worry about things being rebound incorrectly later on. > zle -N redisplay Just overwriting the built-in widgets rather than aliasing seems so *obvious* now how did I ever not think of it? Too caught up in the excitement of being able to alias them I think! > show_mode() { > local COL > local x > COL=3D$[COLUMNS-3] > COL=3D$[COL-$#1] > x=3D$(echo $PREBUFFER | wc -l ) > x=3D$[x+1] > echo -n "=1B7=1B[$x;A=1B[0;G" > echo -n "" > echo -n "=1B[0;37;44m--$1--=1B[0m" > echo -n "=1B8" > } Am I missing something or is COL never actually used? And doesn't echo -n "" do nothing? Thanks Ian