「選択範囲を広げる」の版間の差分
空行と改行の除去 |
機種依存文字の修正 |
||
| 492行目: | 492行目: | ||
var d = document, s = d.selection; | var d = document, s = d.selection; | ||
s.Mode = meModeMulti; | s.Mode = meModeMulti; | ||
// | // (1) まず、GetActivePos と GetAnchorPos で複数選択のリストを作成します | ||
var selections = [{ s: s.GetAnchorPos(), e: s.GetActivePos() }]; | var selections = [{ s: s.GetAnchorPos(), e: s.GetActivePos() }]; | ||
if (s.Count > 0) { | if (s.Count > 0) { | ||
| 502行目: | 502行目: | ||
var q = 0; | var q = 0; | ||
for (var i = 0; i < selections.length; i++) { | for (var i = 0; i < selections.length; i++) { | ||
// | // (2) そのリストを上から順に SetActivePos で、「シングルカーソル」で範囲選択します。この段階で複数選択は解除され、通常のマクロ操作が可能となります | ||
s.SetActivePos(selections[i].s + p); | s.SetActivePos(selections[i].s + p); | ||
s.SetActivePos(selections[i].e + p, true); | s.SetActivePos(selections[i].e + p, true); | ||
q = d.TextLength; | q = d.TextLength; | ||
// | // (3) <ここで通常のマクロの機能を使って普通に編集などを行います> | ||
fn(); | fn(); | ||
p += d.TextLength - q; | p += d.TextLength - q; | ||
// | // (4) 処理を行った後の選択範囲をリストに反映し、これをリストの最後まで繰り返します | ||
selections[i] = { s: s.GetAnchorPos(), e: s.GetActivePos() }; | selections[i] = { s: s.GetAnchorPos(), e: s.GetActivePos() }; | ||
} | } | ||
// | // (5) そのリストを上から順に document.selection.AddPos(StartPos, EndPos) で複数選択として復元します | ||
for (var i = 0; i < selections.length; i++) | for (var i = 0; i < selections.length; i++) | ||
s.AddPos(selections[i].s, selections[i].e); | s.AddPos(selections[i].s, selections[i].e); | ||
スポンサーリンク