Hi, Ian Lynagh wrote [020217 19:03]: > On Sat, Feb 16, 2002 at 06:48:05PM +0100, Thomas Köhler wrote: [...] > > 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. That idea is not so bad, though I usually have very usuable terminal definitions :-) > [0] It still looks like it has problems when the prompt has > scrolled off the top of the screen, at least in an rxvt. In some cases, it doesn't work correctly, yes. This includes the case when you type a very long line, a wrap happens and you switch modes then - bad luck, --NORMAL-- appears in the wrong place (one line below). But that doesn't happen enough to bother me for now... > This should also solve a few of my current problems (flicker, > characters not being echoed when pasted and having the default > state shown). Yes, there's quite a few issues to resolve when you want to write something to some special position in the terminal... > I do have a couple of further questions for you though... No problem :-) > > 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? I've inserted those &! in all places because for some situations, the cursor was not back to its original position yet before the function has been called, so by this little trick, the function returns, the cursor is back, and _then_ the "INSERT" is being drawed. Funny issue indeed. I don't remember offhand which of those &! I really needed, and I just dodn't mind because it works OK for now... > 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. Maybe, didn't evaluate that much further. Perhaps worth thinking about it... > > 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! That idea came to my mind after reading zsh-users some day, and once you find the trick, all seems so obvious and you think "why have I been so silly?". It's always the same :-) > > show_mode() { > > local COL > > local x > > COL=$[COLUMNS-3] > > COL=$[COL-$#1] > > x=$(echo $PREBUFFER | wc -l ) > > x=$[x+1] > > echo -n "7[$x;A[0;G" > > echo -n "" > > echo -n "[0;37;44m--$1--[0m" > > echo -n "8" > > } > > Am I missing something or is COL never actually used? Well... no, you're not missing anything, I just forgot to remove it, it was in there in my first version (and has been used then because I used to have the mode on the right hand side instead of the left hand side). > And doesn't > echo -n "" > do nothing? Actually, it prints an empty string :-) One thing I'm thinking of at the moment: Some more issues (where to put the "showmode") could be resolved better by always using the same position on the screen - for example, always on the last line, at the left hand side. That way, some fidling around with $LINES might be needed (as I used to use $COLUMNS in my original version, but then I decided to put the showmode feature to the left hand side, and, well, put a clock[1] on the right hand side), and one would have to create a long prompt (part of which would be overwritten when you're down at the bottom), but it might be a better idea? Perhaps worth a try... [1] Don't try this at home: Sometimes there's a race condition when zsh tries to complete things and that little cron comes in the way, and so sometimes (not very often, but still sometimes) zsh crashes. It used to be worse back in 3.1.9-dev-xx-days, though :) Here it is anyways, for those who still want it... ### a clock in the prompt. Yes, this _is_ cool. trap CRON ALRM TMOUT=1 CRON() { local STRING local COL local x STRING=$(date) COL=$[COLUMNS-5] COL=$[COL-$#STRING] x=$(echo $PREBUFFER | wc -l ) x=$[x+1] echo -n "7[$x;A[$COL;G[0;37;44m-- $STRING --[0m8" } > Thanks > Ian Ciao, Thomas -- Thomas Köhler Email: jean-luc@xxxxxxxxxxxxxxxxx | LCARS - Linux <>< WWW: http://jeanluc-picard.de | for Computers IRC: jeanluc | on All Real PGP public key available from Homepage! | Starships
Attachment:
pgpH5thchp8Qq.pgp
Description: PGP signature