「選択文字列を強調」の版間の差分

提供: MeryWiki
ナビゲーションに移動 検索に移動
MSY-07 (トーク | 投稿記録)
省略された波括弧の追加
MSY-07 (トーク | 投稿記録)
スペースからタブに変更
11行目: 11行目:
// 何も選択してない場合は単語を選択
// 何も選択してない場合は単語を選択
with (document.selection) {
with (document.selection) {
  var s = Text;
var s = Text;
  if (s.length == 0) {
if (s.length == 0) {
    SelectWord();
SelectWord();
  }
}
  s = Text;
s = Text;
}
}
// 選択範囲が空ではない場合
// 選択範囲が空ではない場合
if (s.length > 0) {
if (s.length > 0) {
  with (document.selection) {
with (document.selection) {
    // カーソル位置を保存
// カーソル位置を保存
    var ax = GetActivePointX(mePosView);
var ax = GetActivePointX(mePosView);
    var ay = GetActivePointY(mePosView);
var ay = GetActivePointY(mePosView);
    // 選択開始位置を保存
// 選択開始位置を保存
    var tx = GetTopPointX(mePosView);
var tx = GetTopPointX(mePosView);
    var ty = GetTopPointY(mePosView);
var ty = GetTopPointY(mePosView);
    // 選択終了位置を保存
// 選択終了位置を保存
    var bx = GetBottomPointX(mePosView);
var bx = GetBottomPointX(mePosView);
    var by = GetBottomPointY(mePosView);
var by = GetBottomPointY(mePosView);
    // 選択開始位置に移動
// 選択開始位置に移動
    SetActivePoint(mePosView, tx, ty, false);
SetActivePoint(mePosView, tx, ty, false);
    // 1回検索することでハイライト表示させる
// 1回検索することでハイライト表示させる
    Find(s, meFindNext);
Find(s, meFindNext);
    // 選択開始位置、終了位置を復元
// 選択開始位置、終了位置を復元
    if (ax == bx && ay == by) {
if (ax == bx && ay == by) {
      SetActivePoint(mePosView, tx, ty, false);
SetActivePoint(mePosView, tx, ty, false);
      SetActivePoint(mePosView, bx, by, true);
SetActivePoint(mePosView, bx, by, true);
    }
}
  }
}
}
}
</syntaxhighlight>
</syntaxhighlight>

2024年12月29日 (日) 23:53時点における版

選択文字列を強調(ハイライト表示)します。

// -----------------------------------------------------------------------------
// 選択文字列を強調
//
// Copyright (c) Kuro. All Rights Reserved.
// www:    https://www.haijin-boys.com/
// -----------------------------------------------------------------------------

// 何も選択してない場合は単語を選択
with (document.selection) {
	var s = Text;
	if (s.length == 0) {
		SelectWord();
	}
	s = Text;
}
// 選択範囲が空ではない場合
if (s.length > 0) {
	with (document.selection) {
		// カーソル位置を保存
		var ax = GetActivePointX(mePosView);
		var ay = GetActivePointY(mePosView);
		// 選択開始位置を保存
		var tx = GetTopPointX(mePosView);
		var ty = GetTopPointY(mePosView);
		// 選択終了位置を保存
		var bx = GetBottomPointX(mePosView);
		var by = GetBottomPointY(mePosView);
		// 選択開始位置に移動
		SetActivePoint(mePosView, tx, ty, false);
		// 1回検索することでハイライト表示させる
		Find(s, meFindNext);
		// 選択開始位置、終了位置を復元
		if (ax == bx && ay == by) {
			SetActivePoint(mePosView, tx, ty, false);
			SetActivePoint(mePosView, bx, by, true);
		}
	}
}
スポンサーリンク