zsh-users
 help / color / mirror / code / Atom feed
* zle -R does it support color?
@ 2011-02-09  0:29 Wendell Hom
  2011-02-09  5:25 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Wendell Hom @ 2011-02-09  0:29 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 709 bytes --]

Hi all,

I have a script that helps me navigate around directories and aid in filename 
completion.  

I am using zle -R to list the file/directory choices that match a string in the 
buffer.  The script serves its purpose, but I can't seem to get any color output 
using zle -R; it displays control characters instead.  Does zle -R support color 
output?  It would be nice to have a color-coded output so I can easily spot 
directories vs. filenames vs. symlinks, etc.

Thanks,
Wendell



 
____________________________________________________________________________________
Food fight? Enjoy some healthy debate 
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: zle -R does it support color?
  2011-02-09  0:29 zle -R does it support color? Wendell Hom
@ 2011-02-09  5:25 ` Bart Schaefer
  2011-02-09  6:15   ` Wendell Hom
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2011-02-09  5:25 UTC (permalink / raw)
  To: zsh-users

On Feb 8,  4:29pm, Wendell Hom wrote:
}
} I am using zle -R to list the file/directory choices that match a
} string in the buffer. The script serves its purpose, but I can't seem
} to get any color output using zle -R; it displays control characters
} instead. Does zle -R support color output?

No, zle -R doesn't support any sort of terminal control.  ZLE is pretty
restrictive of what it will let you do outside of a prompt string, in
order that it be able to keep track of what the screen (well, the bit
of the screen that it last scribbled on) looks like at all times.
It doesn't "know" which escape sequences require zero display space,
which ones move the cursor around, etc., so it won't emit any of them.

You might be able to do something with POSTDISPLAY and region_highlight
but it'd require a fair amount of work.

} It would be nice to have a color-coded output so I can easily spot
} directories vs. filenames vs symlinks, etc.

Out of curiosity, why are you simulating a completion with zle -R
rather than doing a real completion list and allowing that to color
the results?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: zle -R does it support color?
  2011-02-09  5:25 ` Bart Schaefer
@ 2011-02-09  6:15   ` Wendell Hom
  2011-02-09  8:11     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Wendell Hom @ 2011-02-09  6:15 UTC (permalink / raw)
  To: Bart Schaefer, zsh-users

[-- Attachment #1: Type: text/plain, Size: 2405 bytes --]

The way my "completion" widget works is that when it is invoked, it enters a 
loop and waits for the next key to be pressed.  

Every time a key is pressed, the new completion list is redisplayed 
automatically.  Some commonly used keys like the Enter key, semicolon, quotes, 
etc., are also mapped to perform different functions that help move around 
directories and choosing files.  Once control returns from the widget, the 
normal key bindings are back.  It basically cuts down on typing and speeds 
things up for me.

I resorted to simulating the completion using zle -R because I wasn't able to 
get the completion widget to do what I wanted.  I wanted to be able to stay 
within the widget so that the keys perform different functions.  I suppose that 
can be accomplished instead by binding a key to change key mappings, but I also 
wanted the completion list to change automatically without having to hit the Tab 
key each time once I enter this mode.   Or if I can find a way to redisplay the 
completion list w/o returning from the widget, then that should work but I am 
not sure if that is possible.




________________________________
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Sent: Tue, February 8, 2011 9:25:27 PM
Subject: Re: zle -R does it support color?

On Feb 8,  4:29pm, Wendell Hom wrote:
}
} I am using zle -R to list the file/directory choices that match a
} string in the buffer. The script serves its purpose, but I can't seem
} to get any color output using zle -R; it displays control characters
} instead. Does zle -R support color output?

No, zle -R doesn't support any sort of terminal control.  ZLE is pretty
restrictive of what it will let you do outside of a prompt string, in
order that it be able to keep track of what the screen (well, the bit
of the screen that it last scribbled on) looks like at all times.
It doesn't "know" which escape sequences require zero display space,
which ones move the cursor around, etc., so it won't emit any of them.

You might be able to do something with POSTDISPLAY and region_highlight
but it'd require a fair amount of work.

} It would be nice to have a color-coded output so I can easily spot
} directories vs. filenames vs symlinks, etc.

Out of curiosity, why are you simulating a completion with zle -R
rather than doing a real completion list and allowing that to color
the results?



      

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: zle -R does it support color?
  2011-02-09  6:15   ` Wendell Hom
@ 2011-02-09  8:11     ` Bart Schaefer
  2011-02-09 20:08       ` Wendell Hom
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2011-02-09  8:11 UTC (permalink / raw)
  To: zsh-users

On Feb 8, 10:15pm, Wendell Hom wrote:
} 
} The way my "completion" widget works is that when it is invoked, it   
} enters a loop and waits for the next key to be pressed.               
} 
} Every time a key is pressed, the new completion list is redisplayed 
} automatically.

Have you looked at Functions/Zle/incremental-complete-word ?  Thus spake
"man zshcontrib":

     This allows incremental completion of a word.  After starting this
     command, a list of completion choices can be shown after every
     character you type, which you can delete with ^H or DEL.  Pressing
     return accepts the completion so far and returns you to normal
     editing (that is, the command line is _not_ immediately executed).
     You can hit TAB to do normal completion, ^G to abort back to the
     state when you started, and ^D to list the matches.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: zle -R does it support color?
  2011-02-09  8:11     ` Bart Schaefer
@ 2011-02-09 20:08       ` Wendell Hom
  0 siblings, 0 replies; 5+ messages in thread
From: Wendell Hom @ 2011-02-09 20:08 UTC (permalink / raw)
  To: Bart Schaefer, zsh-users

[-- Attachment #1: Type: text/plain, Size: 1439 bytes --]

Hi Bart,

Thanks for pointing out the widget.  It looks like the same general idea (except 
mine is customized towards my needs); there's a loop, a read -k, and the use of 
zle -R.  I guess that means there will be no color support there either.  


I'll take a look at POSTDISPLAY and region_highlight that you mentioned before 
when I get to it and see if I can use it. 


Thanks!
Wendell




________________________________
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Sent: Wed, February 9, 2011 12:11:34 AM
Subject: Re: zle -R does it support color?

On Feb 8, 10:15pm, Wendell Hom wrote:
} 
} The way my "completion" widget works is that when it is invoked, it  
} enters a loop and waits for the next key to be pressed.              
} 
} Every time a key is pressed, the new completion list is redisplayed 
} automatically.

Have you looked at Functions/Zle/incremental-complete-word ?  Thus spake
"man zshcontrib":

     This allows incremental completion of a word.  After starting this
     command, a list of completion choices can be shown after every
     character you type, which you can delete with ^H or DEL.  Pressing
     return accepts the completion so far and returns you to normal
     editing (that is, the command line is _not_ immediately executed).
     You can hit TAB to do normal completion, ^G to abort back to the
     state when you started, and ^D to list the matches.



      

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-02-09 20:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-09  0:29 zle -R does it support color? Wendell Hom
2011-02-09  5:25 ` Bart Schaefer
2011-02-09  6:15   ` Wendell Hom
2011-02-09  8:11     ` Bart Schaefer
2011-02-09 20:08       ` Wendell Hom

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).