zsh-users
 help / color / mirror / code / Atom feed
* How to capture the tab completion result?
@ 2013-05-25 23:27 Mario Signorino
  2013-05-26 23:10 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Mario Signorino @ 2013-05-25 23:27 UTC (permalink / raw)
  To: zsh-users

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

Hi all

I need some help and possibly also an advice.

I want is to surround the result of the tab-completion with a special
not-printable chars.

I'm working on an application with embedded a special terminal emulator
inherited from gnome-terminal. I want to modify the common TAB behaviour
and manipulate the result of all TAB-completions: any string generated
pressing TAB should be handled by my app before going on screen.
So: the "special not printable chars" would be the way to tell my terminal:
"hey... there are some tab completions for you".

In my program I will do some work on the completion result and then I will
display it to the user in the terminal window (in some cases). I need to do
the job in my c++ code and there is no way to do that at shell level.

The best would be to switch on and off this features with an environment
var in order not to mess up the system in case I login with a standard
terminal. The dream would also have some difference between "file
completion" and everything else (as command option). For example:
completing an "ls /etc/ap" gives me a lot of result: I should know in my
terminal app that the results are files and which is their full path. In
this case, parsing the "ls /etc/ap" wuold be easy... but sometimes in the
command line there are many more chars...

The "surround char" is what I think is the easiest way... maybe also
putting everything in an env variable could be another valid way.
Everything should works also through an ssh connection... this means: I
cannot use any trick as piping result in a socket or anything else that
uses local resource.

I just spent three day into bash sources without any acceptable result. So,
looking for an alternative, I came on zsh.
So: can I do what I need with zsh?
One "yes!" and a general suggestion will be enough.

Tnx
Mario

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

* Re: How to capture the tab completion result?
  2013-05-25 23:27 How to capture the tab completion result? Mario Signorino
@ 2013-05-26 23:10 ` Bart Schaefer
  2013-05-27 16:45   ` Mario Signorino
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2013-05-26 23:10 UTC (permalink / raw)
  To: Zsh Users

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

On Saturday, May 25, 2013, Mario Signorino wrote:

> Hi all
>
> I need some help and possibly also an advice.
>
> I want is to surround the result of the tab-completion with a special
> not-printable chars.


This is not going to be straightforward, but have a look at Test/comptest
in the sources, which does a similar thing.  It forces completion listings
and then "colors" them with markup that can be parsed.  The characters it
uses aren't actually non-printing, but if your app is going to grab the
listing on its way to the terminal anyway, perhaps it can also strip the
markup.

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

* Re: How to capture the tab completion result?
  2013-05-26 23:10 ` Bart Schaefer
@ 2013-05-27 16:45   ` Mario Signorino
  2013-05-28  8:25     ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Mario Signorino @ 2013-05-27 16:45 UTC (permalink / raw)
  Cc: Zsh Users

On Mon, May 27, 2013 at 1:10 AM, Bart Schaefer
<schaefer@brasslantern.com> wrote:
> > I want is to surround the result of the tab-completion with a special
> > not-printable chars.
> This is not going to be straightforward, but have a look at Test/comptest
> in the sources, which does a similar thing.  It forces completion listings

Hi!
That's exactly what I needed.
Now...

zstyle ":completion:*:descriptions" format "\033[H<DESCRIPTION>%d</DESCRIPTION>"

Is it also possible to enable the interpretation of backslash escapes?
For example I added a "\033[H" in the above line.
I tried, but... no luck.

Tnx
Mario


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

* Re: How to capture the tab completion result?
  2013-05-27 16:45   ` Mario Signorino
@ 2013-05-28  8:25     ` Bart Schaefer
  2013-05-30 21:15       ` Mario Signorino
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2013-05-28  8:25 UTC (permalink / raw)
  To: Mario Signorino; +Cc: Zsh Users

On Mon, May 27, 2013 at 9:45 AM, Mario Signorino
<mario.signorino@gnufish.net> wrote:
>
> zstyle ":completion:*:descriptions" format "\033[H<DESCRIPTION>%d</DESCRIPTION>"
>
> Is it also possible to enable the interpretation of backslash escapes?

Just use the $'...' notation to embed a literal escape in the style:

zstyle ":completion:*:descriptions" format
$'\033[H<DESCRIPTION>%d</DESCRIPTION>'

It's sort of a matter of personal preference whether to write
$'\033'"[H..." (concatenate two sets of quotes) or just wrap the whole
thing in $'...' like I did.  Concatenating the double quotes makes it
easier to reference variables, etc., but you can't use $'...' inside
double quotes.


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

* Re: How to capture the tab completion result?
  2013-05-28  8:25     ` Bart Schaefer
@ 2013-05-30 21:15       ` Mario Signorino
  0 siblings, 0 replies; 6+ messages in thread
From: Mario Signorino @ 2013-05-30 21:15 UTC (permalink / raw)
  Cc: Zsh Users

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

Again: that's exactly what I needed.
Tnx a lot.
Mario


On Tue, May 28, 2013 at 10:25 AM, Bart Schaefer
<schaefer@brasslantern.com>wrote:

> On Mon, May 27, 2013 at 9:45 AM, Mario Signorino
> <mario.signorino@gnufish.net> wrote:
> >
> > zstyle ":completion:*:descriptions" format
> "\033[H<DESCRIPTION>%d</DESCRIPTION>"
> >
> > Is it also possible to enable the interpretation of backslash escapes?
>
> Just use the $'...' notation to embed a literal escape in the style:
>
> zstyle ":completion:*:descriptions" format
> $'\033[H<DESCRIPTION>%d</DESCRIPTION>'
>
> It's sort of a matter of personal preference whether to write
> $'\033'"[H..." (concatenate two sets of quotes) or just wrap the whole
> thing in $'...' like I did.  Concatenating the double quotes makes it
> easier to reference variables, etc., but you can't use $'...' inside
> double quotes.
>

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

* Re: How to capture the tab completion result?
@ 2013-05-26 11:23 Marc Chantreux
  0 siblings, 0 replies; 6+ messages in thread
From: Marc Chantreux @ 2013-05-26 11:23 UTC (permalink / raw)
  To: Mario Signorino; +Cc: zsh-users

On Sun, May 26, 2013 at 01:27:51AM +0200, Mario Signorino wrote:
> I want is to surround the result of the tab-completion with a special
> not-printable chars. 

it also would be nice to use zsh as a completion engine for the vim
omni-completion. 

regards

-- 
Marc Chantreux (eiro on github and freenode)
http://eiro.github.com/
http://eiro.github.com/atom.xml
"Don't believe everything you read on the Internet"
    -- Abraham Lincoln


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

end of thread, other threads:[~2013-05-30 21:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-25 23:27 How to capture the tab completion result? Mario Signorino
2013-05-26 23:10 ` Bart Schaefer
2013-05-27 16:45   ` Mario Signorino
2013-05-28  8:25     ` Bart Schaefer
2013-05-30 21:15       ` Mario Signorino
2013-05-26 11:23 Marc Chantreux

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