zsh-users
 help / color / mirror / code / Atom feed
* Predict-on and colored/higlighted predicted text
@ 2003-01-25 16:43 Clifford Caoile
  2003-01-25 20:57 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Clifford Caoile @ 2003-01-25 16:43 UTC (permalink / raw)
  To: zsh-users

Dear zsh-users:

Hello, first time for me to reach out to the zsh community. Thanks for
zsh shell! 

I have been exploring the 4.0.x functionality called "predict-on" and
"predict-off". It has been both a gee-wiz and a oh-darn experience,
meaning that I've be amazed and disappointed by zsh's history-based
prediction. I like it! I also hate it when it gets in the way! Oh
well. Also it reminds me of recent capabilities found in Windows such
as auto complete in Internet Explorer and Visual Studio 6.

Since zsh is a text-based program and doesn't have the luxury of
popping up a graphically overlaid text list widget like a graphical
program, I was wondering how far this prediction can be graphically
enhanced? Would it be possible to color code or highlight or
underscore the part of the line that is filled in by prediction?
Something like:

        cursor is here | 
                       v
% rsync -azvP -e ssh myhost:ive/done/this/before/ localcopy/
                       -------------------------------------
                       ^
                       | something graphical reminds you of 
                       | prediction text, like a underscore?

Comments? Would you think this would be useful?

I've searched the archives for predict color but nothing comes up.

---
  ,-~-.
 < ^ ; ~,  
  (_  _,   Clifford Escobar CAOILE  (aka "Piyo-kun")
   J~~>  _.___...:.__..__.: __.:_. .:_.__::_..:._::._...  _____ p(^_^)q
 


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

* Re: Predict-on and colored/higlighted predicted text
  2003-01-25 16:43 Predict-on and colored/higlighted predicted text Clifford Caoile
@ 2003-01-25 20:57 ` Bart Schaefer
  2003-01-26  2:55   ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2003-01-25 20:57 UTC (permalink / raw)
  To: zsh-users

On Jan 26,  1:43am, Clifford Caoile wrote:
}
} I have been exploring the 4.0.x functionality called "predict-on" and
} "predict-off". It has been both a gee-wiz and a oh-darn experience

Yes, that was pretty much my experience, even while writing it.  If you
haven't looked at the styles related to predictive typing, I suggest you
do so ("man zshcontrib"), and perhaps try these settings:

zstyle :predict verbose yes
zstyle :predict cursor key
zstyle ':completion:predict:*' completer \
	_oldlist _complete _ignored _history _prefix

I was going to suggest using the "toggle" style as well, but you'd better
apply the appended patch first or you'll be saying "oh darn" even more.

zstyle :predict toggle yes

} Also it reminds me of recent capabilities found in Windows such
} as auto complete in Internet Explorer and Visual Studio 6.

That was the intention.  If you want a different style of auto completion,
have a look at incremental-complete-word.

} I was wondering how far this prediction can be graphically enhanced?

Not very far, I'm afraid.

} Would it be possible to color code or highlight or underscore the part
} of the line that is filled in by prediction?

Unfortunately the zsh line editor does not provide a way to insert into
the command line any characters that are not actually part of the command.
On a text terminal, the way highlighting/underscoring/etc. is done is by
sending "invisible" characters to the terminal that cause it to change
the appearance of whatever follows.  So without some fairly large changes
to ZLE, colorizing parts of the command is not possible.

However, it's always the case that everything to the right of the cursor
is the part filled in by prediction, so there is that much of a cue.

With some of the recent enchancements to history search in zsh-4.1.x-dev,
it might be possible to have a single keystroke search multiple times and
generate a listing of all the possible hits (a bit like the droplist that
appears below the Address: bar when auto-completing in IE).  I'm not sure
how usable that would be in practice, though.

Here's the patch I mentioned:

Index: Functions/Zle/predict-on
===================================================================
--- predict-on	9 Apr 2001 20:14:12 -0000	1.1.1.1
+++ predict-on	25 Jan 2003 20:18:23 -0000
@@ -55,7 +55,8 @@
     ((++CURSOR))
   else
     LBUFFER="$LBUFFER$KEYS"
-    if [[ $LASTWIDGET == (self-insert|magic-space|backward-delete-char) ]]
+    if [[ $LASTWIDGET == (self-insert|magic-space|backward-delete-char) ||
+	  $LASTWIDGET == (complete-word|accept-*|predict-*) ]]
     then
       if ! zle .history-beginning-search-backward
       then

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: Predict-on and colored/higlighted predicted text
  2003-01-25 20:57 ` Bart Schaefer
@ 2003-01-26  2:55   ` Bart Schaefer
  2003-01-28 12:34     ` Clifford Caoile
  2003-01-29  6:44     ` Felix Rosencrantz
  0 siblings, 2 replies; 5+ messages in thread
From: Bart Schaefer @ 2003-01-26  2:55 UTC (permalink / raw)
  To: zsh-users

I wrote:

} Unfortunately the zsh line editor does not provide a way to insert
} into the command line any characters that are not actually part of the
} command. [...] So without some fairly large changes to ZLE, colorizing
} parts of the command is not possible.

I was thinking about this, and it turns out it's not *quite* impossible,
but it does depend on redrawing behavior; so I'm not sure it will always
work, and it'd be really unpleasant over a slow connection.

Here's a small function that shows how to do it.  It highlights from the
cursor position to the end of the line, but it wouldn't be hard to
adapt to highlight any given section.

function hilite {
  setopt localoptions promptpercent
  local rbuffer="$RBUFFER"
  RBUFFER=""				# Truncate the buffer
  zle -R				# Redraw that much
  print -nP %U				# Begin highlight
  RBUFFER="$rbuffer"			# Restore the buffer
  zle -R				# Redraw the rest
  print -nP %u				# End highlight
}

However, as soon as you begin to edit the line, all bets are off as to
where the highlight remains (or doesn't).
__________

In that same message, I also wrote:

} ... perhaps try these settings:

I failed to cut'n'paste one that should have been included, to disable
menu selection when autocompleting.  If you don't have menu selection
enabled, you don't need this.

zstyle ':completion:predict:*' menu yes

There's probably a more clever setting of that for zsh-4.1.x-dev now
that menu selection has "interactive mode", but I haven't worked out
what it is.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* RE: Predict-on and colored/higlighted predicted text
  2003-01-26  2:55   ` Bart Schaefer
@ 2003-01-28 12:34     ` Clifford Caoile
  2003-01-29  6:44     ` Felix Rosencrantz
  1 sibling, 0 replies; 5+ messages in thread
From: Clifford Caoile @ 2003-01-28 12:34 UTC (permalink / raw)
  To: zsh-users

Bart Schaefer:

Thank you for your feedback. Sorry, I been a bit busy and I haven't been
able to try your suggestions. I'm not sure what to make of that function or
how to use it, actually. But I'll give it a try and get back to you on it.

Thanks again.
  ,-~-.
 < ^ ; ~,  Clifford Escobar CAOILE  (aka "Piyo-kun")
  (_  _,
   J~~>  _.___...:.__..__.: __.:_. .:_.__::_..:._::._...  _____ p(^_^)q


| -----Original Message-----
| From: Bart Schaefer [mailto:schaefer@brasslantern.com]
| Sent: Sunday, January 26, 2003 11:55
| To: zsh-users@sunsite.dk
| Subject: Re: Predict-on and colored/higlighted predicted text
|
|
| I wrote:
|
| } Unfortunately the zsh line editor does not provide a way to insert
| } into the command line any characters that are not actually part of the
| } command. [...] So without some fairly large changes to ZLE, colorizing
| } parts of the command is not possible.
|
| I was thinking about this, and it turns out it's not *quite* impossible,
| but it does depend on redrawing behavior; so I'm not sure it will always
| work, and it'd be really unpleasant over a slow connection.
|
| Here's a small function that shows how to do it.  It highlights from the
| cursor position to the end of the line, but it wouldn't be hard to
| adapt to highlight any given section.
|
| function hilite {
|   setopt localoptions promptpercent
|   local rbuffer="$RBUFFER"
|   RBUFFER=""				# Truncate the buffer
|   zle -R				# Redraw that much
|   print -nP %U				# Begin highlight
|   RBUFFER="$rbuffer"			# Restore the buffer
|   zle -R				# Redraw the rest
|   print -nP %u				# End highlight
| }
|
| However, as soon as you begin to edit the line, all bets are off as to
| where the highlight remains (or doesn't).
| __________
|
| In that same message, I also wrote:
|
| } ... perhaps try these settings:
|
| I failed to cut'n'paste one that should have been included, to disable
| menu selection when autocompleting.  If you don't have menu selection
| enabled, you don't need this.
|
| zstyle ':completion:predict:*' menu yes
|
| There's probably a more clever setting of that for zsh-4.1.x-dev now
| that menu selection has "interactive mode", but I haven't worked out
| what it is.
|
| --
| Bart Schaefer                                 Brass Lantern Enterprises
| http://www.well.com/user/barts              http://www.brasslantern.com
|
| Zsh: http://www.zsh.org | PHPerl Project:
http://phperl.sourceforge.net



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

* Re: Predict-on and colored/higlighted predicted text
  2003-01-26  2:55   ` Bart Schaefer
  2003-01-28 12:34     ` Clifford Caoile
@ 2003-01-29  6:44     ` Felix Rosencrantz
  1 sibling, 0 replies; 5+ messages in thread
From: Felix Rosencrantz @ 2003-01-29  6:44 UTC (permalink / raw)
  To: zsh-users


--- Bart Schaefer <schaefer@brasslantern.com> wrote:
> I wrote:
> 
> } [...] So without some fairly large changes to ZLE, colorizing
> } parts of the command is not possible.
> 
> I was thinking about this, and it turns out it's not *quite* impossible,
> but it does depend on redrawing behavior; so I'm not sure it will always
> work, and it'd be really unpleasant over a slow connection.
>
> However, as soon as you begin to edit the line, all bets are off as to
> where the highlight remains (or doesn't).

I didn't try the function you sent, but the conditions seem to match
incremental search really well.  During incremental search the command line is
just displayed, and not editted.

So do you think it would be difficult change zle to add highlighting to show
the matching text in the displayed command line during incremental search.

-FR.


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


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

end of thread, other threads:[~2003-01-29  6:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-25 16:43 Predict-on and colored/higlighted predicted text Clifford Caoile
2003-01-25 20:57 ` Bart Schaefer
2003-01-26  2:55   ` Bart Schaefer
2003-01-28 12:34     ` Clifford Caoile
2003-01-29  6:44     ` Felix Rosencrantz

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