Skip to content

Commit 0740ea9

Browse files
committed
Update by original
1 parent 71c5725 commit 0740ea9

File tree

2 files changed

+13
-284
lines changed

2 files changed

+13
-284
lines changed

doc/eval.jax

Lines changed: 6 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Note: 式の評価はコンパイル時に無効化できる。無効化され
3636
12. サンドボックス |eval-sandbox|
3737
13. テキストロック |textlock|
3838
14. Vim script ライブラリ |vim-script-library|
39-
15. クリップボードプロバイダ |clipboard-providers|
4039

4140
テストのサポートは |testing.txt| を参照。
4241
プロファイリングは |profiling| に記録されている。
@@ -2184,17 +2183,9 @@ v:clipmethod 現在使用されているクリップボードへのアクセス
21842183
かの値になる:
21852184
wayland Wayland プロトコルが使用されている。
21862185
x11 X11 セレクションが使用されている。
2187-
gui GUI固有のメソッドが使用されている。
2188-
other 他のメソッドが使用されている。
2189-
none クリップボード機能が無効または使用でき
2190-
ない。
2186+
none 上記メソッドが無効または使用できない。
21912187
詳細は 'clipmethod' を参照。
21922188

2193-
*v:clipproviders*
2194-
v:clipproviders
2195-
クリップボードプロバイダを含む辞書。詳細については
2196-
|clipboard-providers| を参照。
2197-
21982189
*v:cmdarg* *cmdarg-variable*
21992190
v:cmdarg 2つの目的のために使われる:
22002191
1. ファイルの読み書きコマンドに与えられる余分な引数。現在のと
@@ -3224,8 +3215,9 @@ text...
32243215
endif
32253216
END
32263217
< 結果: ["if ok", " echo 'done'", "endif"]
3227-
マーカーは "let" のインデントと並ばなければならず、最
3228-
初の行のインデントは全てのテキスト行から取り除かれる。
3218+
エンドマーカーは "let" のインデントと並ばなければなら
3219+
ず、最初の行のインデントは全てのテキスト行から取り除か
3220+
れる。
32293221
具体例: 最初の空でないテキスト行の先頭のインデントと完
32303222
全に一致する全ての先頭のインデントは入力行から削除され
32313223
る。`let` の前の先頭のインデントと完全に一致する先頭の
@@ -3314,10 +3306,10 @@ text...
33143306
:cons[t] {var-name} = {expr1}
33153307
:cons[t] [{name1}, {name2}, ...] = {expr1}
33163308
:cons[t] [{name}, ..., ; {lastname}] = {expr1}
3317-
:cons[t] {var-name} =<< [trim] [eval] {marker}
3309+
:cons[t] {var-name} =<< [trim] [eval] {endmarker}
33183310
text...
33193311
text...
3320-
{marker}
3312+
{endmarker}
33213313
|:let|に似ているが、加えて、値がセットされたあとに変数
33223314
がロックされる。これは、ロックされた変数と同じで、
33233315
|:let|のすぐ後に|:lockvar|を使うことで変数をロックする
@@ -5113,132 +5105,5 @@ NOTE: <args> のエスケープはユーザーに任される
51135105
:call dist#vim9#Launch(<args>)
51145106
:Launch <app> <args>.
51155107
<
5116-
==============================================================================
5117-
15. クリップボードプロバイダ *clipboard-providers*
5118-
5119-
Vim が |+clipboard_provider| 機能 (|+eval| 機能を必要とする) 付きでコンパイル
5120-
されている場合、カスタムクリップボードの作成が可能になる。これらのプロバイダは
5121-
"+" および "*" レジスタを処理する。Note |+wayland_clipboard| または
5122-
|+xterm_clipboard| 機能がコンパイルされていない場合は、"+" レジスタは使用でき
5123-
ないことに注意。
5124-
5125-
プロバイダを追加するには、次の形式で |v:clipproviders| 辞書に新しいエントリを
5126-
追加する: >
5127-
let v:clipproviders["name"] = {
5128-
\ "available": function("Available"),
5129-
\ "paste": {
5130-
\ '+': function("Paste"), " For the + register
5131-
\ '*': function("Paste"), " For the * register
5132-
\ },
5133-
\ "copy": {
5134-
\ '+': function("Copy"), " Same thing as above
5135-
\ '*': function("Copy"),
5136-
\ },
5137-
\ }
5138-
5139-
キーは 'clipmethod' で使用するプロバイダ名である。例えば次の例では、これを使用
5140-
するために "name" を 'clipmethod' に追加する。 >
5141-
set clipmethod=name,wayland,x11,gui
5142-
5143-
各コールバックは、文字列内の関数名、|Funcref|、または |lambda| 式のいずれかに
5144-
なる。
51455108

5146-
note これらの辞書エントリはオプションであることに注意。例えば、"copy" 機能が必
5147-
要ない場合は、単に除外することができる。Vim が何かをヤンク/コピーする場合、何
5148-
も行われない。
5149-
5150-
*clipboard-provider-available*
5151-
"available" コールバックは、使用可能なクリップボードレジスタを含む文字列を返す
5152-
必要がある。例えば、"+" レジスタのみが使用可能な場合は関数は "+" を返し、"+"
5153-
と "*" の両方が使用可能な場合は "+*" を返す。
5154-
5155-
*clipboard-provider-paste*
5156-
"paste" コールバックは、最初の引数としてペーストするレジスタ (文字列) を、2 番
5157-
目の引数としてアクセスの種類 (文字列) を受け取る。タプル/リスト、または文字列
5158-
のいずれかを返す。タプル/リストを返す場合は、以下の 2 つの要素を持つ必要がある:
5159-
- |setreg()| に準拠したレジスタのタイプ。
5160-
- 文字列のリスト
5161-
レジスタのタイプが空文字列の場合、型は自動的に選択される。|setreg()| を参照。
5162-
文字列が返される場合は、"clear" または "previous" のいずれかになる。"clear" は
5163-
レジスタをクリアし、"previous" はレジスタの前の (または現在の) 内容を使用する
5164-
(表示方法によって異なる)。
5165-
5166-
2 番目の引数であるアクセスタイプは、"explicit" または "implicit" のいずれかに
5167-
なる。"explicit" とは、テキストを挿入したり、|getreg()| を呼び出したりなど、
5168-
ユーザーがクリップボードに直接アクセスしていることを意味する。"implicit" と
5169-
は、|:registers| が呼び出されたときや、無関係な操作によって Vim がクリップボー
5170-
ドにアクセスしたときなど、クリップボードが間接的にアクセスされていることを意味
5171-
する。
5172-
5173-
Vim の一部の操作は暗黙的にクリップボードに間接的にアクセスするため、これは便利
5174-
である。例えば、OSC52 コマンド (エスケープコードを介してクリップボードにアクセ
5175-
スする) のプロバイダを作成する場合などである。多くの端末では、Vim がクリップ
5176-
ボードにアクセスするかどうか確認メッセージが表示される。これは、バックグラウン
5177-
ドでクリップボードにアクセスする操作を行うたびに端末が許可を求めるため、非常に
5178-
煩わしい場合がある。暗黙的なアクセスを処理する良い方法は、レジスタの内容を変更
5179-
せずに "previous" を返すことである。
5180-
5181-
*clipboard-provider-copy*
5182-
"copy" コールバックは何も返さず、指定された引数を順番に受け取る:
5183-
- 操作対象のレジスタ
5184-
- |getregtype()| に準拠したレジスタの型。
5185-
- コピーする文字列のリスト
5186-
5187-
プロバイダは与えられた情報を使って自由に操作できる。この関数は、クリップボード
5188-
レジスタ(群)を変更するリクエストごとに呼び出される。
5189-
5190-
*clipboard-provider-textlock*
5191-
"paste" および "copy" コールバックの両方で、バッファのテキストを変更することは
5192-
できない。|textlock| を参照。
5193-
5194-
*clipboard-provider-example*
5195-
以下は、OSC52 コマンドを通じてクリップボードプロバイダ機能を使用するスクリプト
5196-
の例: >vim
5197-
5198-
func Available()
5199-
return "*"
5200-
endfunc
5201-
5202-
func Paste(reg, type)
5203-
" 暗黙的なアクセスの場合は何もしない
5204-
if a:type == "implicit"
5205-
return "previous"
5206-
endif
5207-
5208-
augroup OSC
5209-
autocmd!
5210-
autocmd TermResponseAll osc ++once call feedkeys("\<F30>", '!')
5211-
augroup END
5212-
5213-
" コマンドを送信
5214-
call echoraw("\<Esc>]52;;?\<Esc>\\")
5215-
5216-
" 自動コマンドがトリガーされるまで待つ
5217-
while getchar(-1) != "\<F30>"
5218-
endwhile
5219-
5220-
autocmd! OSC
5221-
5222-
" base64 データを取り出す
5223-
let l:stuff = matchstr(v:termosc, '52;.\+;\zs[A-Za-z0-9+/=]\+')
5224-
5225-
return ("", blob2str(base64_decode(l:stuff)))
5226-
endfunc
5227-
5228-
func Copy(reg, type, lines)
5229-
call echoraw("\<Esc>]52;c;" ..
5230-
\ base64_encode(str2blob(a:lines)) .. "\<Esc>\\")
5231-
endfunc
5232-
let v:clipproviders["myosc"] = {
5233-
\ "available": function("Available"),
5234-
\ "paste": {
5235-
\ '*': function("Paste")
5236-
\ },
5237-
\ "copy": {
5238-
\ '*': function("Copy")
5239-
\ },
5240-
\ }
5241-
set clipmethod=myosc
5242-
5243-
<
52445109
vim:tw=78:ts=8:noet:ft=help:norl:

en/eval.txt

Lines changed: 7 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ a remark is given.
3838
12. The sandbox |eval-sandbox|
3939
13. Textlock |textlock|
4040
14. Vim script library |vim-script-library|
41-
15. Clipboard providers |clipboard-providers|
4241

4342
Testing support is documented in |testing.txt|.
4443
Profiling is documented at |profiling|.
@@ -2246,17 +2245,10 @@ v:clipmethod The current method of accessing the clipboard that is being
22462245
used. Can either have the value of:
22472246
wayland The Wayland protocol is being used.
22482247
x11 X11 selections are being used.
2249-
gui GUI specific method is being used
2250-
other Some other method is being used
2251-
none Clipboard functionality is disabled or
2252-
unavailable.
2248+
none The above methods are unavailable or
2249+
cannot be used.
22532250
See 'clipmethod' for more details.
22542251

2255-
*v:clipproviders*
2256-
v:clipproviders
2257-
A dictionary containing clipboard providers, see
2258-
|clipboard-providers| for more information.
2259-
22602252
*v:cmdarg* *cmdarg-variable*
22612253
v:cmdarg This variable is used for two purposes:
22622254
1. The extra arguments given to a file read/write command.
@@ -3315,8 +3307,9 @@ text...
33153307
endif
33163308
END
33173309
< Results in: ["if ok", " echo 'done'", "endif"]
3318-
The marker must line up with "let" and the indentation
3319-
of the first line is removed from all the text lines.
3310+
The end marker must line up with "let" and the
3311+
indentation of the first line is removed from all the
3312+
text lines.
33203313
Specifically: all the leading indentation exactly
33213314
matching the leading indentation of the first
33223315
non-empty text line is stripped from the input lines.
@@ -3409,10 +3402,10 @@ text...
34093402
:cons[t] {var-name} = {expr1}
34103403
:cons[t] [{name1}, {name2}, ...] = {expr1}
34113404
:cons[t] [{name}, ..., ; {lastname}] = {expr1}
3412-
:cons[t] {var-name} =<< [trim] [eval] {marker}
3405+
:cons[t] {var-name} =<< [trim] [eval] {endmarker}
34133406
text...
34143407
text...
3415-
{marker}
3408+
{endmarker}
34163409
Similar to |:let|, but additionally lock the variable
34173410
after setting the value. This is the same as locking
34183411
the variable with |:lockvar| just after |:let|, thus: >
@@ -5269,134 +5262,5 @@ Usage: >vim
52695262
:call dist#vim9#Launch(<args>)
52705263
:Launch <app> <args>.
52715264
<
5272-
==============================================================================
5273-
15. Clipboard providers *clipboard-providers*
5274-
5275-
When Vim is compiled with the |+clipboard_provider| feature, which requires
5276-
the |+eval| feature, creating custom clipboards is possible. These providers
5277-
handle the "+" and "*" registers. Note that if |+wayland_clipboard| or
5278-
|+xterm_clipboard| features are not compiled in, then the "+" register will
5279-
not be available.
5280-
5281-
To add a provider, add a new entry to the |v:clipproviders| dictionary, in the
5282-
format of: >
5283-
let v:clipproviders["name"] = {
5284-
\ "available": function("Available"),
5285-
\ "paste": {
5286-
\ '+': function("Paste"), " For the + register
5287-
\ '*': function("Paste"), " For the * register
5288-
\ },
5289-
\ "copy": {
5290-
\ '+': function("Copy"), " Same thing as above
5291-
\ '*': function("Copy"),
5292-
\ },
5293-
\ }
5294-
5295-
The key is the provider name, which should be used in 'clipmethod', for
5296-
example in the following example, you would add "name" to 'clipmethod' in
5297-
order to use it. >
5298-
set clipmethod=name,wayland,x11,gui
5299-
5300-
Each callback can either be a name of a function in a string, a |Funcref|, or
5301-
a |lambda| expression.
5302-
5303-
Note that these dictionary entries are optional, for example, if you don't
5304-
care about the "copy" functions, then you can simply exclude them. When Vim
5305-
yanks/copies something, then simply nothing will be done.
5306-
5307-
*clipboard-provider-available*
5308-
The "available" callback should return a string, which should contain which
5309-
clipboard registers are available. For example, if the "+" register is only
5310-
available, then the function would return "+", or if both "+" and "*" are
5311-
available, then return "+*".
5312-
5313-
*clipboard-provider-paste*
5314-
The "paste" callback takes a first argument which is the register being put
5315-
(string), and a second argument which is the type of access (string). It
5316-
should return either a tuple/list or string. If a tuple/list is returned, it
5317-
should have two elements:
5318-
- The register type conforming to |setreg()|.
5319-
- A list of strings
5320-
If the register type is an empty string, then the type is automatically
5321-
chosen, see |setreg()|. If a string is returned, then it can either be "clear"
5322-
or "previous". "clear" makes Vim clear the register, and "previous" makes Vim
5323-
use the previous register contents (or current depending on how you view it).
5324-
5325-
The second argument, the access type, can either be "explicit" or "implicit".
5326-
"explicit" means that the user is directly accessing the clipboard, such as
5327-
putting text, or calling |getreg()|; "implicit" means that the clipboard is
5328-
being accessed indirectly, such when |:registers| is called, or when an
5329-
unrelated operation causes Vim to access the clipboard.
5330-
5331-
This is useful since some operations in Vim implicity access the clipboard
5332-
indirectly. For example, if when you want to create a provider for the OSC52
5333-
command (accessing the clipboard via an escape code). Many terminals show a
5334-
confirmation if you want Vim to access the clipboard. This can be very
5335-
annoying with the terminal asking for permission everytime you do something
5336-
that accesses the clipboard behind the scenes. A good way to handle implicit
5337-
access is to return "previous", which leaves the register contents unchanged.
5338-
5339-
*clipboard-provider-copy*
5340-
The "copy" callback returns nothing, and takes the given arguments in order:
5341-
- The register being operated on
5342-
- The register type, conforming to |getregtype()|
5343-
- A list of strings to copy
5344-
5345-
The provider can do whatever it wants with the given information. This
5346-
function is called on every request to change the clipboard register(s).
5347-
5348-
*clipboard-provider-textlock*
5349-
In both the "paste" and "copy" callbacks, it is not allowed to change the
5350-
buffer text, see |textlock|.
5351-
5352-
*clipboard-provider-example*
5353-
Here is an example script that uses the clipboard provider feature through the
5354-
OSC52 command: >vim
5355-
5356-
func Available()
5357-
return "*"
5358-
endfunc
5359-
5360-
func Paste(reg, type)
5361-
" If implicit access, don't do anything
5362-
if a:type == "implicit"
5363-
return "previous"
5364-
endif
5365-
5366-
augroup OSC
5367-
autocmd!
5368-
autocmd TermResponseAll osc ++once call feedkeys("\<F30>", '!')
5369-
augroup END
5370-
5371-
" Send command
5372-
call echoraw("\<Esc>]52;;?\<Esc>\\")
5373-
5374-
" Wait until autocmd is triggered
5375-
while getchar(-1) != "\<F30>"
5376-
endwhile
5377-
5378-
autocmd! OSC
5379-
5380-
" Extract the base64 stuff
5381-
let l:stuff = matchstr(v:termosc, '52;.\+;\zs[A-Za-z0-9+/=]\+')
5382-
5383-
return ("", blob2str(base64_decode(l:stuff)))
5384-
endfunc
5385-
5386-
func Copy(reg, type, lines)
5387-
call echoraw("\<Esc>]52;c;" ..
5388-
\ base64_encode(str2blob(a:lines)) .. "\<Esc>\\")
5389-
endfunc
5390-
let v:clipproviders["myosc"] = {
5391-
\ "available": function("Available"),
5392-
\ "paste": {
5393-
\ '*': function("Paste")
5394-
\ },
5395-
\ "copy": {
5396-
\ '*': function("Copy")
5397-
\ },
5398-
\ }
5399-
set clipmethod=myosc
54005265

5401-
<
54025266
vim:tw=78:ts=8:noet:ft=help:norl:

0 commit comments

Comments
 (0)