「矩形選択範囲の各行先頭に文字挿入」の版間の差分

MSY-07 (トーク | 投稿記録)
ソースコードを整形
MSY-07 (トーク | 投稿記録)
ソースコードを修正
 
18行目: 18行目:


// ステータスバー初期化
// ステータスバー初期化
Status = ""
Status = "";


// 矩形選択判定
// 矩形選択判定
var s = Document.Selection;
var s = document.selection;
var isBoxed = (s.GetBottomPointY(mePosView) - s.GetTopPointY(mePosView)) != (s.Text.match(/\n/g) || []).length;
var isBoxed = (s.GetBottomPointY(mePosView) - s.GetTopPointY(mePosView)) != (s.Text.match(/\n/g) || []).length;


if (isBoxed) {
if (isBoxed) {
var Ptr = "^";
var Ptr = "^";
var Rep = window.prompt("挿入する文字列", "").replace(/\\/g, "\\\\");
var Rep = Prompt("挿入する文字列", "").replace(/\\/g, "\\\\");
// 挿入文字が空ではない場合のみ、置換実行
// 挿入文字が空ではない場合のみ、置換実行
if (Rep) {
if (Rep) {
document.selection.Replace(Ptr, Rep, meFindReplaceRegExp + meReplaceSelOnly + meReplaceAll);
document.selection.Replace(Ptr, Rep, meFindReplaceRegExp + meReplaceSelOnly + meReplaceAll);
Editor.ActiveDocument.HighlightFind = false;
editor.ActiveDocument.HighlightFind = false;
}
}
} else {
} else {
Status = "矩形選択がされていません。"
Status = "矩形選択がされていません。";
}
}
</syntaxhighlight>
</syntaxhighlight>
スポンサーリンク