Skip to content

Commit 0e39230

Browse files
authored
Merge pull request #610 from 0Delta/update_popup
update popup.{txt,jax}
2 parents c26702d + 48c5dbb commit 0e39230

File tree

2 files changed

+101
-29
lines changed

2 files changed

+101
-29
lines changed

doc/popup.jax

+50-13
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,17 @@ Exコマンドの出力のために画面がスクロールアップすると、
8888

8989
TODO:
9090
- Why does 'nrformats' leak from the popup window buffer???
91+
- When the lines do not fit show a scrollbar (like in the popup menu).
92+
Use the mouse wheel for scrolling.
9193
- Disable commands, feedkeys(), CTRL-W, etc. in a popup window.
9294
Use ERROR_IF_POPUP_WINDOW for more commands.
9395
- Add 'balloonpopup': instead of showing text, let the callback open a popup
9496
window and return the window ID. The popup will then be closed when the
9597
mouse moves, except when it moves inside the popup.
9698
- For the "moved" property also include mouse movement?
99+
- Can the buffer be re-used, to avoid using up lots of buffer numbers?
100+
- Have an option to attach the popup to a text position, like text properties
101+
do. (#4560)
97102
- Make redrawing more efficient and avoid flicker:
98103
- put popup menu also put in popup_mask?
99104
- Invoke filter with character before mapping?
@@ -102,16 +107,12 @@ TODO:
102107
if wrapping inserts indent
103108
- When drawing on top half a double-wide character, display ">" or "<" in the
104109
incomplete cell.
105-
- Can the buffer be re-used, to avoid using up lots of buffer numbers?
106110
- Use a popup window for the "info" item of completion instead of using a
107111
preview window. Ideas in issue #4544.
108112
How to add highlighting?
109-
- When the lines do not fit show a scrollbar (like in the popup menu).
110-
Use the mouse wheel for scrolling.
111113
- Implement:
112-
tabpage option with number
113114
flip option
114-
transparent text property
115+
transparent area, to minimize covering text. Define rectangles?
115116

116117

117118
==============================================================================
@@ -163,8 +164,8 @@ popup_atcursor({text}, {options}) *popup_atcursor()*
163164

164165

165166
*popup_clear()*
166-
popup_clear() 不作法にふるまうプラグインに対する緊急の解決策: すべてのポップ
167-
アップウィンドウを閉じる
167+
popup_clear() 不作法にふるまうプラグインに対する緊急の解決策: グローバルポッ
168+
プアップとカレントタブポップアップをすべて閉じる
168169

169170

170171
popup_close({id} [, {result}]) *popup_close()*
@@ -233,6 +234,8 @@ popup_filter_menu({id}, {key}) *popup_filter_menu()*
233234
初のエントリのインデックスは 1 である。メニューをキャンセルす
234235
ると、-1 でコールバックが呼び出される。
235236

237+
ショートカットキーを追加する場合
238+
|popup_menu-shortcut-example| を参照。
236239

237240
popup_filter_yesno({id}, {key}) *popup_filter_yesno()*
238241
ポップアップに使用できるフィルタ。キー 'y'、'Y' および 'n' ま
@@ -241,6 +244,7 @@ popup_filter_yesno({id}, {key}) *popup_filter_yesno()*
241244
を呼び出す。Esc と 'x' を押すと、'n' を押すのと同じように機能
242245
する。CTRL-C は -1 でコールバックを呼び出す。他のキーは無視さ
243246
れる。
247+
|popup_dialog-example| を参照。
244248

245249

246250
popup_getoptions({id}) *popup_getoptions()*
@@ -256,6 +260,10 @@ popup_getoptions({id}) *popup_getoptions()*
256260

257261
すべての値が空の場合、"borderhighlight" は含まれない。
258262

263+
グローバルポップアップの場合 "tabpage" には -1 が設定され、カ
264+
レントタブページの場合は 0 、別のタブページの場合は正の整数が
265+
設定される。
266+
259267
ポップアップウィンドウ {id} が見つからない場合は空の辞書が返さ
260268
れる。
261269

@@ -472,8 +480,8 @@ POPUP_CREATE() の引数 *popup_create-usage*
472480
0 (デフォルト)の場合: カレントタブページにポップアップ
473481
を表示する。
474482
それ以外の場合は、ポップアップが表示されるタブページの
475-
番号。無効な場合はカレントタブページが使用される。
476-
{-1と0のみ実装} {only -1 and 0 are implemented}
483+
番号。無効な場合、ポップアップは生成されず、エラーに
484+
なる。 *E996*
477485
title ポップアップの最初の項目の上、ボーダーの上に表示される
478486
テキスト。上枠がない場合は、タイトルを付けるために1行
479487
のパディングが追加される。最初と最後に1つ以上のスペー
@@ -506,8 +514,9 @@ POPUP_CREATE() の引数 *popup_create-usage*
506514
リストに1文字が含まれている場合は、それがすべてに使用
507515
される。リストに2文字が含まれている場合、最初の文字は
508516
ボーダーに使用され、2番目の文字はコーナーに使用される。
509-
'encoding' が "utf-8" のときはデフォルトで2重線が使わ
510-
れる。それ以外の場合はASCII文字が使われる。
517+
'encoding' が "utf-8" かつ 'ambiwidth' が "single" の
518+
ときはデフォルトで2重線が使われる。それ以外の場合は
519+
ASCII文字が使われる。
511520
zindex ポップアップの優先度。デフォルトは50。最小値は1、最大
512521
値は32000。
513522
time ポップアップが閉じるまでの時間(msec)。省略した場合は
@@ -617,7 +626,7 @@ Note "x" はポップアップを閉じる通常の方法である。Escを使
617626
3. 例 *popup-examples*
618627

619628
TODO
620-
629+
*popup_dialog-example*
621630
ユーザーに y/Y か n/N を押すように促す: >
622631
623632
func MyDialogHandler(id, result)
@@ -626,10 +635,38 @@ TODO
626635
endif
627636
endfunc
628637
629-
call popup_create(['Continue? y/n'], {
638+
call popup_dialog('Continue? y/n', {
630639
\ 'filter': 'popup_filter_yesno',
631640
\ 'callback': 'MyDialogHandler',
632641
\ })
633642
<
643+
*popup_menu-shortcut-example*
644+
popup_filter_menu() をショートカットで拡張できるようにする: >
645+
646+
call popup_menu('Save', 'Cancel', 'Discard'], {
647+
\ 'filter': 'MyMenuFilter',
648+
\ 'callback': 'MyMenuHandler',
649+
\ })
650+
651+
func MyMenuFilter(id, key)
652+
" ショートカットキーをハンドリングする
653+
if a:key == 'S'
654+
call popup_close(a:id, 1)
655+
return 1
656+
endif
657+
if a:key == 'C'
658+
call popup_close(a:id, 2)
659+
return 1
660+
endif
661+
if a:key == 'D'
662+
call popup_close(a:id, 3)
663+
return 1
664+
endif
665+
666+
" ショートカットキーではない場合は通常のフィルタに渡す
667+
return popup_filter_menu(a:id, a:key)
668+
endfunc
669+
<
670+
634671

635672
vim:tw=78:ts=8:noet:ft=help:norl:

en/popup.txt

+51-16
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,17 @@ that it is in.
8888

8989
TODO:
9090
- Why does 'nrformats' leak from the popup window buffer???
91+
- When the lines do not fit show a scrollbar (like in the popup menu).
92+
Use the mouse wheel for scrolling.
9193
- Disable commands, feedkeys(), CTRL-W, etc. in a popup window.
9294
Use ERROR_IF_POPUP_WINDOW for more commands.
9395
- Add 'balloonpopup': instead of showing text, let the callback open a popup
9496
window and return the window ID. The popup will then be closed when the
9597
mouse moves, except when it moves inside the popup.
9698
- For the "moved" property also include mouse movement?
99+
- Can the buffer be re-used, to avoid using up lots of buffer numbers?
100+
- Have an option to attach the popup to a text position, like text properties
101+
do. (#4560)
97102
- Make redrawing more efficient and avoid flicker:
98103
- put popup menu also put in popup_mask?
99104
- Invoke filter with character before mapping?
@@ -102,17 +107,12 @@ TODO:
102107
if wrapping inserts indent
103108
- When drawing on top half a double-wide character, display ">" or "<" in the
104109
incomplete cell.
105-
- Can the buffer be re-used, to avoid using up lots of buffer numbers?
106110
- Use a popup window for the "info" item of completion instead of using a
107111
preview window. Ideas in issue #4544.
108112
How to add highlighting?
109-
- When the lines do not fit show a scrollbar (like in the popup menu).
110-
Use the mouse wheel for scrolling.
111113
- Implement:
112-
tabpage option with number
113114
flip option
114-
transparent text property
115-
115+
transparent area, to minimize covering text. Define rectangles?
116116

117117
==============================================================================
118118
2. Functions *popup-functions*
@@ -123,7 +123,7 @@ Creating a popup window:
123123
|popup_create()| centered in the screen
124124
|popup_atcursor()| just above the cursor position, closes when
125125
the cursor moves away
126-
|popup_notifiation()| show a notification for three seconds
126+
|popup_notification()| show a notification for three seconds
127127
|popup_dialog()| centered with padding and border
128128
|popup_menu()| prompt for selecting an item from a list
129129

@@ -163,7 +163,7 @@ popup_atcursor({text}, {options}) *popup_atcursor()*
163163

164164
*popup_clear()*
165165
popup_clear() Emergency solution to a misbehaving plugin: close all popup
166-
windows.
166+
windows for the current tab and global popups.
167167

168168

169169
popup_close({id} [, {result}]) *popup_close()*
@@ -216,7 +216,7 @@ popup_dialog({text}, {options}) *popup_dialog()*
216216

217217
popup_filter_menu({id}, {key}) *popup_filter_menu()*
218218
Filter that can be used for a popup. These keys can be used:
219-
j <Down> select item below
219+
j <Down> select item below
220220
k <Up> select item above
221221
<Space> <Enter> accept current selection
222222
x Esc CTRL-C cancel the menu
@@ -230,6 +230,9 @@ popup_filter_menu({id}, {key}) *popup_filter_menu()*
230230
the second argument. The first entry has index one.
231231
Cancelling the menu invokes the callback with -1.
232232

233+
To add shortcut keys, see the example here:
234+
|popup_menu-shortcut-example|
235+
233236

234237
popup_filter_yesno({id}, {key}) *popup_filter_yesno()*
235238
Filter that can be used for a popup. It handles only the keys
@@ -238,6 +241,7 @@ popup_filter_yesno({id}, {key}) *popup_filter_yesno()*
238241
as the second argument. Pressing Esc and 'x' works like
239242
pressing 'n'. CTRL-C invokes the callback with -1. Other
240243
keys are ignored.
244+
See the example here: |popup_dialog-example|
241245

242246

243247
popup_getoptions({id}) *popup_getoptions()*
@@ -253,6 +257,10 @@ popup_getoptions({id}) *popup_getoptions()*
253257

254258
"borderhighlight" is not included when all values are empty.
255259

260+
"tabpage" will be -1 for a global popup, zero for a popup on
261+
the current tabpage and a positive number for a popup on
262+
another tabpage.
263+
256264
If popup window {id} is not found an empty Dict is returned.
257265

258266

@@ -390,7 +398,7 @@ manipulation is restricted:
390398
- 'bufhidden' is "hide"
391399
- 'buflisted' is off
392400
- 'undolevels' is -1: no undo at all
393-
- all other buffer-local and window_local options are set to their Vim default
401+
- all other buffer-local and window-local options are set to their Vim default
394402
value.
395403

396404
It is possible to change the specifically mentioned options, but anything
@@ -474,8 +482,8 @@ The second argument of |popup_create()| is a dictionary with options:
474482
When 0 (the default): display the popup on the current
475483
tab page.
476484
Otherwise the number of the tab page the popup is
477-
displayed on; when invalid the current tab page is used.
478-
{only -1 and 0 are implemented}
485+
displayed on; when invalid the popup is not created
486+
and an error is given. *E996*
479487
title Text to be displayed above the first item in the
480488
popup, on top of any border. If there is no top
481489
border one line of padding is added to put the title
@@ -515,8 +523,8 @@ The second argument of |popup_create()| is a dictionary with options:
515523
When the list has two characters the first is used for
516524
the border lines, the second for the corners.
517525
By default a double line is used all around when
518-
'encoding' is "utf-8", otherwise ASCII characters are
519-
used.
526+
'encoding' is "utf-8" and 'ambiwidth' is "single,
527+
otherwise ASCII characters are used.
520528
zindex Priority for the popup, default 50. Minimum value is
521529
1, maximum value is 32000.
522530
time Time in milliseconds after which the popup will close.
@@ -628,7 +636,7 @@ pressed, the number -1 is passed to the callback.
628636
3. Examples *popup-examples*
629637

630638
TODO
631-
639+
*popup_dialog-example*
632640
Prompt the user to press y/Y or n/N: >
633641
634642
func MyDialogHandler(id, result)
@@ -637,10 +645,37 @@ Prompt the user to press y/Y or n/N: >
637645
endif
638646
endfunc
639647
640-
call popup_create(['Continue? y/n'], {
648+
call popup_dialog('Continue? y/n', {
641649
\ 'filter': 'popup_filter_yesno',
642650
\ 'callback': 'MyDialogHandler',
643651
\ })
644652
<
653+
*popup_menu-shortcut-example*
654+
Extend popup_filter_menu() with shortcut keys: >
655+
656+
call popup_menu('Save', 'Cancel', 'Discard'], {
657+
\ 'filter': 'MyMenuFilter',
658+
\ 'callback': 'MyMenuHandler',
659+
\ })
660+
661+
func MyMenuFilter(id, key)
662+
" Handle shortcuts
663+
if a:key == 'S'
664+
call popup_close(a:id, 1)
665+
return 1
666+
endif
667+
if a:key == 'C'
668+
call popup_close(a:id, 2)
669+
return 1
670+
endif
671+
if a:key == 'D'
672+
call popup_close(a:id, 3)
673+
return 1
674+
endif
675+
676+
" No shortcut, pass to generic filter
677+
return popup_filter_menu(a:id, a:key)
678+
endfunc
679+
<
645680

646681
vim:tw=78:ts=8:noet:ft=help:norl:

0 commit comments

Comments
 (0)