* PATCH: Re: long completion selections and listings
@ 2000-07-12 9:23 Sven Wischnowsky
2000-07-12 10:14 ` PATCH: " Peter Stephenson
0 siblings, 1 reply; 2+ messages in thread
From: Sven Wischnowsky @ 2000-07-12 9:23 UTC (permalink / raw)
To: zsh-workers
Peter Stephenson wrote:
> According to the manual, select-prompt has a default when you used
> scrolling with menus. It doesn't show up for me --- I had to set it
> explicitly. (If I remember right, I didn't put it in compinstall because
> there was already a sensible default.)
You get the default when setting select-prompt to the empty string and
that works for me.
> Another thing, maybe I misunderstood somewhere, but I have
> zstyle ':completion:*' menu 'select=long' 'select=5'
> Since I don't have select=long-list, I wouldn't expect long listings to
> switch automatically to menu selection, but at the moment they do.
> Lists which do fit on the screen don't.
I hope you meant this: it shouldn't start menu selection if not
starting menu completion. Right.
Bye
Sven
Index: Completion/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_main_complete,v
retrieving revision 1.35
diff -u -r1.35 _main_complete
--- Completion/Core/_main_complete 2000/07/03 08:05:27 1.35
+++ Completion/Core/_main_complete 2000/07/12 09:22:39
@@ -175,7 +175,7 @@
-n "$_menu_style[(r)(yes|true|on|1)=long-list]" ) ]]; then
compstate[insert]=menu
elif [[ "$compstate[insert]" = "$_saved_insert" ]]; then
- if [[ -n "$_menu_style[(r)select=long]" && tmp -gt LINES ]]; then
+ if [[ -n "$_menu_style[(r)(yes|true|1|on)=long]" && tmp -gt LINES ]]; then
compstate[insert]=menu
else
sel=( "${(@M)_menu_style:#(yes|true|1|on)*}" )
@@ -183,11 +183,13 @@
if (( $#sel )); then
min=9999999
for i in "$sel[@]"; do
- if [[ "$i" = *\=* ]]; then
+ if [[ "$i" = *\=[0-9]* ]]; then
num="${i#*\=}"
[[ num -lt 0 ]] && num=0
- else
- num=$nm
+ elif [[ "$i" != *\=* ]]; then
+ num=0
+ else
+ num=9999999
fi
[[ num -lt min ]] && min="$num"
@@ -199,11 +201,13 @@
if (( $#sel )); then
max=9999999
for i in "$sel[@]"; do
- if [[ "$i" = *\=* ]]; then
+ if [[ "$i" = *\=[0-9]* ]]; then
num="${i#*\=}"
[[ num -lt 0 ]] && num=0
- else
+ elif [[ "$i" != *\=* ]]; then
num=0
+ else
+ num=9999999
fi
[[ num -lt max ]] && max="$num"
@@ -229,20 +233,22 @@
elif [[ -n "$_menu_style[(r)select=long*]" ]]; then
if [[ tmp -gt LINES ]]; then
zmodload -i zsh/complist
- MENUSELECT=0
+ MENUSELECT=00
fi
fi
- if [[ "$MENUSELECT" != 0 ]]; then
+ if [[ "$MENUSELECT" != 00 ]]; then
sel=( "${(@M)_menu_style:#select*}" )
if (( $#sel )); then
min=9999999
for i in "$sel[@]"; do
- if [[ "$i" = *\=* ]]; then
+ if [[ "$i" = *\=[0-9]* ]]; then
num="${i#*\=}"
[[ num -lt 0 ]] && num=0
- else
+ elif [[ "$i" != *\=* ]]; then
num=0
+ else
+ num=9999999
fi
[[ num -lt min ]] && min="$num"
--
Sven Wischnowsky wischnow@informatik.hu-berlin.de
^ permalink raw reply [flat|nested] 2+ messages in thread
* PATCH: Re: PATCH: Re: long completion selections and listings
2000-07-12 9:23 PATCH: Re: long completion selections and listings Sven Wischnowsky
@ 2000-07-12 10:14 ` Peter Stephenson
0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2000-07-12 10:14 UTC (permalink / raw)
To: Zsh hackers list
Sven wrote:
> Peter Stephenson wrote:
>
> > According to the manual, select-prompt has a default when you used
> > scrolling with menus. It doesn't show up for me --- I had to set it
> > explicitly. (If I remember right, I didn't put it in compinstall because
> > there was already a sensible default.)
>
> You get the default when setting select-prompt to the empty string and
> that works for me.
It does say that in the manual. What's confusing me is that (if I've read
this right), list-prompt uses a default if you don't set it to the empty
string, and select-prompt is the other way round. I think I've handled
that difference in the following.
This adds select-prompt to compinstall and corrects the menu at the
previous level (I had moved handling of scrolling but hadn't changed the
description in the menu).
Index: Completion/Core/compinstall
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/compinstall,v
retrieving revision 1.16
diff -u -r1.16 compinstall
--- Completion/Core/compinstall 2000/07/03 14:00:44 1.16
+++ Completion/Core/compinstall 2000/07/12 10:12:01
@@ -1243,7 +1243,7 @@
__ci_do_selection() {
- local key listc menu select amenu elt
+ local key listc menu select amenu elt listp selectp haslistp hasselectp
integer num
__ci_get_this_style list-colors listc
@@ -1251,6 +1251,9 @@
__ci_get_this_style list-prompt listp
[[ -n $listp ]] && haslistp=1
listp=${(Q)listp}
+ __ci_get_this_style select-prompt selectp
+ [[ -n $selectp ]] && hasselectp=1
+ selectp=${(Q)selectp}
while true; do
clear
@@ -1319,6 +1322,7 @@
- a negative number to turn this feature off
- an empty line to leave the setting the way it is.
"
+ # Better to parse and display the current setting.
while true; do
vared -eh -p 'value> ' select
[[ -z $select || $select = ((-|)<->|l|<->#ll<->#) ]] && break;
@@ -1363,6 +1367,23 @@
menu="$amenu"
;;
esac
+ if [[ $menu = *select* ]]; then
+ print "\
+You can also set a prompt to use for menu selection when it would scroll
+off the screen. Unless this is set, you won't see a prompt, but the feature
+is still enabled.
+
+Edit a prompt below. It can contain \`%l' to show the number of matches
+as \`current_number/total_number', \`%p' to show the fraction of
+the way down the list, or font-control sequences such as %B, %U, %S and
+the corresponding %b, %u, %s; quotes will be added automatically. Delete
+the whole line to turn it off. Hit return to keep the current value.
+"
+ [[ -z $hasselectp ]] &&
+ selectp='%SScrolling active: current selection at %p%s'
+ vared -eh -p 'prompt> ' -c selectp
+ [[ -z $selectp ]] && hasselectp=
+ fi
;;
3) print "\
You can make completion lists scroll when they don't fit on the screen.
@@ -1395,6 +1416,8 @@
__ci_set_this_style menu menu
[[ -n $haslistp ]] && listp=${(qq)listp}
__ci_set_this_style list-prompt listp
+ [[ -n $hasselectp ]] && selectp=${(qq)selectp}
+ __ci_set_this_style select-prompt selectp
return 0
}
@@ -1411,8 +1434,7 @@
*** compinstall: display and insertion options ***
1. Change appearance of completion lists: allows descriptions of
- completions to appear, sorting of different types of completions,
- and scrolling of completion lists.
+ completions to appear and sorting of different types of completions.
2. Change how completions are inserted: includes options for sorting,
and keeping the original or an unambiguous prefix with correction etc.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-07-12 10:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-12 9:23 PATCH: Re: long completion selections and listings Sven Wischnowsky
2000-07-12 10:14 ` PATCH: " Peter Stephenson
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).