diff --git a/doc/windows.jax b/doc/windows.jax index 3388bf105..09aeed200 100644 --- a/doc/windows.jax +++ b/doc/windows.jax @@ -1,4 +1,4 @@ -*windows.txt* For Vim バージョン 9.0. Last change: 2022 May 11 +*windows.txt* For Vim バージョン 9.0. Last change: 2022 Nov 27 VIMリファレンスマニュアル by Bram Moolenaar @@ -196,7 +196,7 @@ CTRL-W v *CTRL-W_v* い。 CTRL-W n *CTRL-W_n* -CTRL-W CTRL_N *CTRL-W_CTRL-N* +CTRL-W CTRL-N *CTRL-W_CTRL-N* :[N]new [++opt] [+cmd] *:new* 新しいウィンドウを作成して空のファイルの編集が始まる。新しい ウィンドウの高さはNになる(デフォルトの高さはカレントウィンドウ @@ -638,6 +638,56 @@ CTRL-W | カレントウィンドウの幅を N桁にする (デフォルト:可 ウィンドウの最小の高さと幅は 'winminheight' と 'winminwidth' によって設定され る。これらは絶対的な値で、ウィンドウはこれらより小さくなることはない。 + +WinScrolled と WinResized 自動コマンド ~ + *win-scrolled-resized* +ウィンドウ サイズの変更の通知を受け取りたい場合は、|WinResized| 自動コマンドイ +ベントを使用できる。 +垂直方向または水平方向にスクロールするウィンドウ内のテキストの通知を受け取りた +い場合は、|WinScrolled| 自動コマンドイベントを使用できる。これはウィンドウサイ +ズの変更でもトリガーされる。 +例外: テキストが 'incsearch' のためにスクロールしても、イベントはトリガーされ +ない。 + *WinResized-event* +|WinResized| イベントは表示更新後にトリガーされ、その時にいくつかのウィンドウ +のサイズが変更される可能性がある。前回以降に変更されたウィンドウの ID のリスト +は、v:event.windows 変数で提供される。例: + [1003, 1006] + *WinScrolled-event* +|WinScrolled| イベントは |WinResized| の後、およびウィンドウがスクロールされた +場合にもトリガーされる。これは、垂直方向 (ウィンドウ上部のテキストが変更された +場合) または水平方向 ('wrap' がオフの場合、または最初の行の最初に表示される部 +分が変更された場合) になる。Note |WinScrolled| は |WinResized| よりも何回もト +リガーされるため、編集が少し遅くなる可能性があることに注意。 + +|WinScrolled| によって提供される情報は、ウィンドウIDをキーとして、変更があった +各ウィンドウの辞書と、"all" をキーとした変更の総カウントです。|v:event| の値の +例 (|Vim9| 構文): + { + all: {width: 0, height: 2, leftcol: 0, skipcol: 0, topline: 1, topfill: 0}, + 1003: {width: 0, height: -1, leftcol: 0, skipcol: 0, topline: 0, topfill: 0}, + 1006: {width: 0, height: 1, leftcol: 0, skipcol: 0, topline: 1, topfill: 0}, + } + +Note "all" エントリは、個別のウィンドウの絶対値が累積されていることに注意。 + +何が変更されたかについてさらに詳しい情報が必要な場合、またはイベントを +"debounce" したい場合 (過剰な動作を避けるためにすべてのイベントを処理しない)、 +`winlayout()` および `getwininfo()` 関数を使用するとよい。 + +|WinScrolled| および |WinResized| は最初の自動コマンドが追加されたときはトリ +ガーされず、最初のスクロールまたはサイズ変更の後にのみトリガーされる。別のタブ +ページに切り替えるときにトリガーされる場合がある。 + +実行されるコマンドは、ウィンドウサイズやスクロールの変更を引き起こさないことが +期待される。 +いずれにせよ、このようなことが起こった場合、イベントはすぐに再びトリガーされ +る。言い換えると、イベントをトリガーする直前に、現在のサイズとスクロール位置が +保存され、変更があったかどうかを判断するために使用される。 + *E1312* +ここでウィンドウのレイアウトを変更する (ウィンドウを分割、閉じる、または移動す +る) ことはできない。 + ============================================================================== 7. コマンド引数とバッファリスト *buffer-list* diff --git a/en/windows.txt b/en/windows.txt index 2d96b043b..74cec4230 100644 --- a/en/windows.txt +++ b/en/windows.txt @@ -1,4 +1,4 @@ -*windows.txt* For Vim version 9.0. Last change: 2022 May 11 +*windows.txt* For Vim version 9.0. Last change: 2022 Nov 27 VIM REFERENCE MANUAL by Bram Moolenaar @@ -189,7 +189,7 @@ CTRL-W v *CTRL-W_v* it doesn't! CTRL-W n *CTRL-W_n* -CTRL-W CTRL_N *CTRL-W_CTRL-N* +CTRL-W CTRL-N *CTRL-W_CTRL-N* :[N]new [++opt] [+cmd] *:new* Create a new window and start editing an empty file in it. Make new window N high (default is to use half the existing @@ -631,6 +631,56 @@ it). The minimal height and width of a window is set with 'winminheight' and 'winminwidth'. These are hard values, a window will never become smaller. + +WinScrolled and WinResized autocommands ~ + *win-scrolled-resized* +If you want to get notified of changes in window sizes, the |WinResized| +autocommand event can be used. +If you want to get notified of text in windows scrolling vertically or +horizontally, the |WinScrolled| autocommand event can be used. This will also +trigger in window size changes. +Exception: the events will not be triggered when the text scrolls for +'incsearch'. + *WinResized-event* +The |WinResized| event is triggered after updating the display, several +windows may have changed size then. A list of the IDs of windows that changed +since last time is provided in the v:event.windows variable, for example: + [1003, 1006] + *WinScrolled-event* +The |WinScrolled| event is triggered after |WinResized|, and also if a window +was scrolled. That can be vertically (the text at the top of the window +changed) or horizontally (when 'wrap' is off or when the first displayed part +of the first line changes). Note that |WinScrolled| will trigger many more +times than |WinResized|, it may slow down editing a bit. + +The information provided by |WinScrolled| is a dictionary for each window that +has changes, using the window ID as the key, and a total count of the changes +with the key "all". Example value for |v:event| (|Vim9| syntax): + { + all: {width: 0, height: 2, leftcol: 0, skipcol: 0, topline: 1, topfill: 0}, + 1003: {width: 0, height: -1, leftcol: 0, skipcol: 0, topline: 0, topfill: 0}, + 1006: {width: 0, height: 1, leftcol: 0, skipcol: 0, topline: 1, topfill: 0}, + } + +Note that the "all" entry has the absolute values of the individual windows +accumulated. + +If you need more information about what changed, or you want to "debounce" the +events (not handle every event to avoid doing too much work), you may want to +use the `winlayout()` and `getwininfo()` functions. + +|WinScrolled| and |WinResized| do not trigger when the first autocommand is +added, only after the first scroll or resize. They may trigger when switching +to another tab page. + +The commands executed are expected to not cause window size or scroll changes. +If this happens anyway, the event will trigger again very soon. In other +words: Just before triggering the event, the current sizes and scroll +positions are stored and used to decide whether there was a change. + *E1312* +It is not allowed to change the window layout here (split, close or move +windows). + ============================================================================== 7. Argument and buffer list commands *buffer-list*