From 1e3455d13add82a644c8df419636aa7f1fbce631 Mon Sep 17 00:00:00 2001 From: 0delta <0deltast@gmail.com> Date: Fri, 21 Jun 2019 15:19:19 +0900 Subject: [PATCH 1/5] update popup.{txt,jax} --- doc/popup.jax | 63 ++++++++++++++++++++++++++++++++++++++---------- en/popup.txt | 67 +++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 29 deletions(-) diff --git a/doc/popup.jax b/doc/popup.jax index 9a303b772..98eca0255 100644 --- a/doc/popup.jax +++ b/doc/popup.jax @@ -88,12 +88,17 @@ Exコマンドの出力のために画面がスクロールアップすると、 TODO: - Why does 'nrformats' leak from the popup window buffer??? +- When the lines do not fit show a scrollbar (like in the popup menu). + Use the mouse wheel for scrolling. - Disable commands, feedkeys(), CTRL-W, etc. in a popup window. Use ERROR_IF_POPUP_WINDOW for more commands. - Add 'balloonpopup': instead of showing text, let the callback open a popup window and return the window ID. The popup will then be closed when the mouse moves, except when it moves inside the popup. - For the "moved" property also include mouse movement? +- Can the buffer be re-used, to avoid using up lots of buffer numbers? +- Have an option to attach the popup to a text position, like text properties + do. (#4560) - Make redrawing more efficient and avoid flicker: - put popup menu also put in popup_mask? - Invoke filter with character before mapping? @@ -102,16 +107,12 @@ TODO: if wrapping inserts indent - When drawing on top half a double-wide character, display ">" or "<" in the incomplete cell. -- Can the buffer be re-used, to avoid using up lots of buffer numbers? - Use a popup window for the "info" item of completion instead of using a preview window. Ideas in issue #4544. How to add highlighting? -- When the lines do not fit show a scrollbar (like in the popup menu). - Use the mouse wheel for scrolling. - Implement: - tabpage option with number flip option - transparent text property + transparent area, to minimize covering text. Define rectangles? ============================================================================== @@ -163,8 +164,8 @@ popup_atcursor({text}, {options}) *popup_atcursor()* *popup_clear()* -popup_clear() 不作法にふるまうプラグインに対する緊急の解決策: すべてのポップ - アップウィンドウを閉じる。 +popup_clear() 不作法にふるまうプラグインに対する緊急の解決策: グローバルポッ + プアップとカレントタブポップアップをすべて閉じる。 popup_close({id} [, {result}]) *popup_close()* @@ -233,6 +234,8 @@ popup_filter_menu({id}, {key}) *popup_filter_menu()* 初のエントリのインデックスは 1 である。メニューをキャンセルす ると、-1 でコールバックが呼び出される。 + ショートカットキーを追加する場合 + |popup_menu-shortcut-exsample| を参照。 popup_filter_yesno({id}, {key}) *popup_filter_yesno()* ポップアップに使用できるフィルタ。キー 'y'、'Y' および 'n' ま @@ -241,6 +244,7 @@ popup_filter_yesno({id}, {key}) *popup_filter_yesno()* を呼び出す。Esc と 'x' を押すと、'n' を押すのと同じように機能 する。CTRL-C は -1 でコールバックを呼び出す。他のキーは無視さ れる。 + |popup_dialog-example| を参照。 popup_getoptions({id}) *popup_getoptions()* @@ -256,6 +260,10 @@ popup_getoptions({id}) *popup_getoptions()* すべての値が空の場合、"borderhighlight" は含まれない。 + グローバルポップアップの場合 "tabpage" には -1 が設定され、 + カレントタブページの場合は正の整数、別のタブページの場合は負の + 整数が設定される。 + ポップアップウィンドウ {id} が見つからない場合は空の辞書が返さ れる。 @@ -472,8 +480,8 @@ POPUP_CREATE() の引数 *popup_create-usage* 0 (デフォルト)の場合: カレントタブページにポップアップ を表示する。 それ以外の場合は、ポップアップが表示されるタブページの - 番号。無効な場合はカレントタブページが使用される。 - {-1と0のみ実装} {only -1 and 0 are implemented} + 番号。無効な場合、ポップアップは生成されず、エラーに + なる。 *E996* title ポップアップの最初の項目の上、ボーダーの上に表示される テキスト。上枠がない場合は、タイトルを付けるために1行 のパディングが追加される。最初と最後に1つ以上のスペー @@ -506,8 +514,9 @@ POPUP_CREATE() の引数 *popup_create-usage* リストに1文字が含まれている場合は、それがすべてに使用 される。リストに2文字が含まれている場合、最初の文字は ボーダーに使用され、2番目の文字はコーナーに使用される。 - 'encoding' が "utf-8" のときはデフォルトで2重線が使わ - れる。それ以外の場合はASCII文字が使われる。 + 'encoding' が "utf-8" かつ 'ambiwidth' が "single" の + ときはデフォルトで2重線が使われる。それ以外の場合は + ASCII文字が使われる。 zindex ポップアップの優先度。デフォルトは50。最小値は1、最大 値は32000。 time ポップアップが閉じるまでの時間(msec)。省略した場合は @@ -617,7 +626,7 @@ Note "x" はポップアップを閉じる通常の方法である。Escを使 3. 例 *popup-examples* TODO - + *popup_dialog-example* ユーザーに y/Y か n/N を押すように促す: > func MyDialogHandler(id, result) @@ -626,10 +635,38 @@ TODO endif endfunc - call popup_create(['Continue? y/n'], { + call popup_dialog('Continue? y/n', { \ 'filter': 'popup_filter_yesno', \ 'callback': 'MyDialogHandler', \ }) < + *popup_menu-shortcut-example* +Extend popup_filter_menu() with shortcut keys: > + + call popup_menu('Save', 'Cancel', 'Discard'], { + \ 'filter': 'MyMenuFilter', + \ 'callback': 'MyMenuHandler', + \ }) + + func MyMenuFilter(id, key) + " Handle shortcuts + if a:key == 'S' + call popup_close(a:id, 1) + return 1 + endif + if a:key == 'C' + call popup_close(a:id, 2) + return 1 + endif + if a:key == 'D' + call popup_close(a:id, 3) + return 1 + endif + + " No shortcut, pass to generic filter + return popup_filter_menu(a:id, a:key) + endfunc +< + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/en/popup.txt b/en/popup.txt index 51b284904..6ea247711 100644 --- a/en/popup.txt +++ b/en/popup.txt @@ -88,12 +88,17 @@ that it is in. TODO: - Why does 'nrformats' leak from the popup window buffer??? +- When the lines do not fit show a scrollbar (like in the popup menu). + Use the mouse wheel for scrolling. - Disable commands, feedkeys(), CTRL-W, etc. in a popup window. Use ERROR_IF_POPUP_WINDOW for more commands. - Add 'balloonpopup': instead of showing text, let the callback open a popup window and return the window ID. The popup will then be closed when the mouse moves, except when it moves inside the popup. - For the "moved" property also include mouse movement? +- Can the buffer be re-used, to avoid using up lots of buffer numbers? +- Have an option to attach the popup to a text position, like text properties + do. (#4560) - Make redrawing more efficient and avoid flicker: - put popup menu also put in popup_mask? - Invoke filter with character before mapping? @@ -102,17 +107,12 @@ TODO: if wrapping inserts indent - When drawing on top half a double-wide character, display ">" or "<" in the incomplete cell. -- Can the buffer be re-used, to avoid using up lots of buffer numbers? - Use a popup window for the "info" item of completion instead of using a preview window. Ideas in issue #4544. How to add highlighting? -- When the lines do not fit show a scrollbar (like in the popup menu). - Use the mouse wheel for scrolling. - Implement: - tabpage option with number flip option - transparent text property - + transparent area, to minimize covering text. Define rectangles? ============================================================================== 2. Functions *popup-functions* @@ -123,7 +123,7 @@ Creating a popup window: |popup_create()| centered in the screen |popup_atcursor()| just above the cursor position, closes when the cursor moves away - |popup_notifiation()| show a notification for three seconds + |popup_notification()| show a notification for three seconds |popup_dialog()| centered with padding and border |popup_menu()| prompt for selecting an item from a list @@ -163,7 +163,7 @@ popup_atcursor({text}, {options}) *popup_atcursor()* *popup_clear()* popup_clear() Emergency solution to a misbehaving plugin: close all popup - windows. + windows for the current tab and global popups. popup_close({id} [, {result}]) *popup_close()* @@ -216,7 +216,7 @@ popup_dialog({text}, {options}) *popup_dialog()* popup_filter_menu({id}, {key}) *popup_filter_menu()* Filter that can be used for a popup. These keys can be used: - j select item below + j select item below k select item above accept current selection x Esc CTRL-C cancel the menu @@ -230,6 +230,9 @@ popup_filter_menu({id}, {key}) *popup_filter_menu()* the second argument. The first entry has index one. Cancelling the menu invokes the callback with -1. + To add shortcut keys, see the example here: + |popup_menu-shortcut-example| + popup_filter_yesno({id}, {key}) *popup_filter_yesno()* 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()* as the second argument. Pressing Esc and 'x' works like pressing 'n'. CTRL-C invokes the callback with -1. Other keys are ignored. + See the example here: |popup_dialog-example| popup_getoptions({id}) *popup_getoptions()* @@ -253,6 +257,10 @@ popup_getoptions({id}) *popup_getoptions()* "borderhighlight" is not included when all values are empty. + "tabpage" will be -1 for a global popup, zero for a popup on + the current tabpage and a positive number for a popup on + another tabpage. + If popup window {id} is not found an empty Dict is returned. @@ -390,7 +398,7 @@ manipulation is restricted: - 'bufhidden' is "hide" - 'buflisted' is off - 'undolevels' is -1: no undo at all -- all other buffer-local and window_local options are set to their Vim default +- all other buffer-local and window-local options are set to their Vim default value. 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: When 0 (the default): display the popup on the current tab page. Otherwise the number of the tab page the popup is - displayed on; when invalid the current tab page is used. - {only -1 and 0 are implemented} + displayed on; when invalid the popup is not created + and an error is given. *E996* title Text to be displayed above the first item in the popup, on top of any border. If there is no top 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: When the list has two characters the first is used for the border lines, the second for the corners. By default a double line is used all around when - 'encoding' is "utf-8", otherwise ASCII characters are - used. + 'encoding' is "utf-8" and 'ambiwidth' is "single, + otherwise ASCII characters are used. zindex Priority for the popup, default 50. Minimum value is 1, maximum value is 32000. time Time in milliseconds after which the popup will close. @@ -628,7 +636,7 @@ pressed, the number -1 is passed to the callback. 3. Examples *popup-examples* TODO - + *popup_dialog-example* Prompt the user to press y/Y or n/N: > func MyDialogHandler(id, result) @@ -637,10 +645,37 @@ Prompt the user to press y/Y or n/N: > endif endfunc - call popup_create(['Continue? y/n'], { + call popup_dialog('Continue? y/n', { \ 'filter': 'popup_filter_yesno', \ 'callback': 'MyDialogHandler', \ }) < + *popup_menu-shortcut-example* +Extend popup_filter_menu() with shortcut keys: > + + call popup_menu('Save', 'Cancel', 'Discard'], { + \ 'filter': 'MyMenuFilter', + \ 'callback': 'MyMenuHandler', + \ }) + + func MyMenuFilter(id, key) + " Handle shortcuts + if a:key == 'S' + call popup_close(a:id, 1) + return 1 + endif + if a:key == 'C' + call popup_close(a:id, 2) + return 1 + endif + if a:key == 'D' + call popup_close(a:id, 3) + return 1 + endif + + " No shortcut, pass to generic filter + return popup_filter_menu(a:id, a:key) + endfunc +< vim:tw=78:ts=8:noet:ft=help:norl: From 8f638f584f6c09a9d08254913e7659cb0e1562d7 Mon Sep 17 00:00:00 2001 From: 0delta <0deltast@gmail.com> Date: Fri, 21 Jun 2019 16:37:03 +0900 Subject: [PATCH 2/5] add jp comment & fix typo --- doc/.textlintrc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ doc/popup.jax | 10 +++++----- 2 files changed, 56 insertions(+), 5 deletions(-) create mode 100644 doc/.textlintrc diff --git a/doc/.textlintrc b/doc/.textlintrc new file mode 100644 index 000000000..539989cdb --- /dev/null +++ b/doc/.textlintrc @@ -0,0 +1,51 @@ +{ +"plugins": { + "@textlint/text": { + "extensions": [".jax"] + } + }, +"rules": { +// それぞれのルールのデフォルト値 +"preset-japanese": { +// https://github.com/textlint-ja/textlint-rule-max-ten +// 一文で使える"、"の数 +"max-ten": { +"max": 3 +}, +// https://github.com/takahashim/textlint-rule-no-doubled-conjunctive-particle-ga +// 逆接の接続助詞「が」が、同一文中に複数回出現していないかどうか +// e.g.) 今日は早朝から出発したが、定刻には間に合わなかったが、無事会場に到着した。 +"no-doubled-conjunctive-particle-ga": true, +// https://github.com/takahashim/textlint-rule-no-doubled-conjunction +// 同じ接続詞が連続して出現していないかどうか +"no-doubled-conjunction": true, +// https://github.com/textlint-ja/textlint-rule-no-double-negative-ja +// 二重否定の検出 +"no-double-negative-ja": true, +// https://github.com/textlint-ja/textlint-rule-no-doubled-joshi +// 二重助詞の検出 +// 連続して同じ助詞が出た場合のみを検出 +"no-doubled-joshi": { +"min_interval": 1 +}, +// https://github.com/azu/textlint-rule-sentence-length +// 一文の最大の長さ +"sentence-length": { +"max": 100 +}, +// https://github.com/textlint-ja/textlint-rule-no-dropping-the-ra +// ら抜き言葉を使用しない +"no-dropping-the-ra": true, +// https://github.com/azu/textlint-rule-no-mix-dearu-desumasu +// 文の敬体(ですます調)、常体(である調)のチェック +"no-mix-dearu-desumasu": true, +// https://github.com/azu/textlint-rule-no-nfd +// ホ゜ケット エンシ゛ン +// のような、Mac OS XでPDFやFinderからのコピペで発生する濁点のチェック +"no-nfd": true, +// https://github.com/textlint-rule/textlint-rule-no-invalid-control-character +// 制御文字の検出 +"no-invalid-control-character": true +} +} +} diff --git a/doc/popup.jax b/doc/popup.jax index 98eca0255..914926ca5 100644 --- a/doc/popup.jax +++ b/doc/popup.jax @@ -235,7 +235,7 @@ popup_filter_menu({id}, {key}) *popup_filter_menu()* ると、-1 でコールバックが呼び出される。 ショートカットキーを追加する場合 - |popup_menu-shortcut-exsample| を参照。 + |popup_menu-shortcut-example| を参照。 popup_filter_yesno({id}, {key}) *popup_filter_yesno()* ポップアップに使用できるフィルタ。キー 'y'、'Y' および 'n' ま @@ -261,7 +261,7 @@ popup_getoptions({id}) *popup_getoptions()* すべての値が空の場合、"borderhighlight" は含まれない。 グローバルポップアップの場合 "tabpage" には -1 が設定され、 - カレントタブページの場合は正の整数、別のタブページの場合は負の + カレントタブページの場合は 0 、別のタブページの場合は正の 整数が設定される。 ポップアップウィンドウ {id} が見つからない場合は空の辞書が返さ @@ -641,7 +641,7 @@ TODO \ }) < *popup_menu-shortcut-example* -Extend popup_filter_menu() with shortcut keys: > +popup_filter_menu() をショートカットで拡張できるようにする: > call popup_menu('Save', 'Cancel', 'Discard'], { \ 'filter': 'MyMenuFilter', @@ -649,7 +649,7 @@ Extend popup_filter_menu() with shortcut keys: > \ }) func MyMenuFilter(id, key) - " Handle shortcuts + " ショートカットキーをハンドリングする if a:key == 'S' call popup_close(a:id, 1) return 1 @@ -663,7 +663,7 @@ Extend popup_filter_menu() with shortcut keys: > return 1 endif - " No shortcut, pass to generic filter + " ショートカットキーじゃない場合は通常のフィルタに渡す return popup_filter_menu(a:id, a:key) endfunc < From 71f2cf9ab50dedd8fcbf67d471ddd3fec522ead2 Mon Sep 17 00:00:00 2001 From: 0delta <0deltast@gmail.com> Date: Fri, 21 Jun 2019 16:44:18 +0900 Subject: [PATCH 3/5] delete foreign file --- doc/.textlintrc | 51 ------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 doc/.textlintrc diff --git a/doc/.textlintrc b/doc/.textlintrc deleted file mode 100644 index 539989cdb..000000000 --- a/doc/.textlintrc +++ /dev/null @@ -1,51 +0,0 @@ -{ -"plugins": { - "@textlint/text": { - "extensions": [".jax"] - } - }, -"rules": { -// それぞれのルールのデフォルト値 -"preset-japanese": { -// https://github.com/textlint-ja/textlint-rule-max-ten -// 一文で使える"、"の数 -"max-ten": { -"max": 3 -}, -// https://github.com/takahashim/textlint-rule-no-doubled-conjunctive-particle-ga -// 逆接の接続助詞「が」が、同一文中に複数回出現していないかどうか -// e.g.) 今日は早朝から出発したが、定刻には間に合わなかったが、無事会場に到着した。 -"no-doubled-conjunctive-particle-ga": true, -// https://github.com/takahashim/textlint-rule-no-doubled-conjunction -// 同じ接続詞が連続して出現していないかどうか -"no-doubled-conjunction": true, -// https://github.com/textlint-ja/textlint-rule-no-double-negative-ja -// 二重否定の検出 -"no-double-negative-ja": true, -// https://github.com/textlint-ja/textlint-rule-no-doubled-joshi -// 二重助詞の検出 -// 連続して同じ助詞が出た場合のみを検出 -"no-doubled-joshi": { -"min_interval": 1 -}, -// https://github.com/azu/textlint-rule-sentence-length -// 一文の最大の長さ -"sentence-length": { -"max": 100 -}, -// https://github.com/textlint-ja/textlint-rule-no-dropping-the-ra -// ら抜き言葉を使用しない -"no-dropping-the-ra": true, -// https://github.com/azu/textlint-rule-no-mix-dearu-desumasu -// 文の敬体(ですます調)、常体(である調)のチェック -"no-mix-dearu-desumasu": true, -// https://github.com/azu/textlint-rule-no-nfd -// ホ゜ケット エンシ゛ン -// のような、Mac OS XでPDFやFinderからのコピペで発生する濁点のチェック -"no-nfd": true, -// https://github.com/textlint-rule/textlint-rule-no-invalid-control-character -// 制御文字の検出 -"no-invalid-control-character": true -} -} -} From 7b08aa572c5130ab24558d025dcf63bddac434e4 Mon Sep 17 00:00:00 2001 From: 0delta <0deltast@gmail.com> Date: Fri, 21 Jun 2019 16:48:28 +0900 Subject: [PATCH 4/5] lint --- doc/popup.jax | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/popup.jax b/doc/popup.jax index 914926ca5..4b89fc10b 100644 --- a/doc/popup.jax +++ b/doc/popup.jax @@ -260,9 +260,9 @@ popup_getoptions({id}) *popup_getoptions()* すべての値が空の場合、"borderhighlight" は含まれない。 - グローバルポップアップの場合 "tabpage" には -1 が設定され、 - カレントタブページの場合は 0 、別のタブページの場合は正の - 整数が設定される。 + グローバルポップアップの場合 "tabpage" には -1 が設定され、カ + レントタブページの場合は 0 、別のタブページの場合は正の整数が + 設定される。 ポップアップウィンドウ {id} が見つからない場合は空の辞書が返さ れる。 From 48c5dbb6d57a861c0ba9dc5df6f0afbdd5ed8373 Mon Sep 17 00:00:00 2001 From: 0delta <0deltast@gmail.com> Date: Fri, 21 Jun 2019 16:58:47 +0900 Subject: [PATCH 5/5] fix wording --- doc/popup.jax | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/popup.jax b/doc/popup.jax index 4b89fc10b..54e70049f 100644 --- a/doc/popup.jax +++ b/doc/popup.jax @@ -663,7 +663,7 @@ popup_filter_menu() をショートカットで拡張できるようにする: > return 1 endif - " ショートカットキーじゃない場合は通常のフィルタに渡す + " ショートカットキーではない場合は通常のフィルタに渡す return popup_filter_menu(a:id, a:key) endfunc <