diff --git a/doc/terminal.jax b/doc/terminal.jax index 1d096ec0d..21e5d57b1 100644 --- a/doc/terminal.jax +++ b/doc/terminal.jax @@ -947,6 +947,20 @@ term_start({cmd} [, {options}]) *term_start()* をそれぞれ 1 つずつしか受け付けず、標準エラー出力用の個別のハ ンドルがないためである。 + Note: term_start() は、コールバックに常に RAW モードを使用す + る。"out_cb" と "err_cb" は、OS から読み取った生のデータチャン + クを受け取る。1 つのコールバック呼び出しには、NL で区切られた + 複数の行が含まれる場合があり (pty 経由の標準出力の場合)、各行 + には行規律 (ONLCR) による末尾の CR が含まれる場合がある。行ご + との処理が必要な場合は、コールバックで "msg" を NL で分割し、 + 末尾の CR を削除する必要がある。 + 例: > + func Handle(ch, msg) + for line in split(a:msg, "\n") + echom substitute(line, '\r$', '', '') + endfor + endfunc +< 追加のオプションは以下のとおり: "term_name" (コマンド名の代わりに使用される)バッファ 名に使用する名前。 diff --git a/en/terminal.txt b/en/terminal.txt index 6c9430dc8..01fd88ca6 100644 --- a/en/terminal.txt +++ b/en/terminal.txt @@ -965,6 +965,20 @@ term_start({cmd} [, {options}]) *term_start()* input and one output handle, with no separate handle for stderr. + Note: term_start() always uses RAW mode for its callbacks. + "out_cb" and "err_cb" receive the raw chunk of data as read + from the OS. A single callback invocation may contain + multiple lines separated by NL, and (for stdout via a pty) + each line may have a trailing CR from the line discipline + (ONLCR). If per-line handling is desired, the callback must + split "msg" on NL and strip the trailing CR itself. + Example: > + func Handle(ch, msg) + for line in split(a:msg, "\n") + echom substitute(line, '\r$', '', '') + endfor + endfunc +< There are extra options: "term_name" name to use for the buffer name, instead of the command name.