「上に行挿入」の版間の差分
ナビゲーションに移動
検索に移動
ページの作成:「現在行の上に行挿入します。 Shift + Enter や Ctrl + Shift + Enter に割り当てると便利です。 <source lang="javascript"> #title="上に行挿入" B...」 |
編集の要約なし |
||
| 13行目: | 13行目: | ||
selection = Document.Selection; | selection = Document.Selection; | ||
var ay = selection.GetActivePointY(mePosLogical); | var ay = selection.GetActivePointY(mePosLogical); | ||
var line = Document.GetLine( | var line = Document.GetLine(ay); | ||
var lineIndent = line.match(/^[ \t ]*/); | var lineIndent = line.match(/^[ \t ]*/); | ||
2019年5月11日 (土) 21:49時点における版
現在行の上に行挿入します。 Shift + Enter や Ctrl + Shift + Enter に割り当てると便利です。
#title="上に行挿入"
BeginUndoGroup();
Redraw = false;
// 以下の insertIndent のフラグを設定して、現在行のインデントを反映するかを選択してください。
// true: 現在行と同じインデントを挿入する
// false: 現在行のインデントを挿入しない
var insertIndent = true;
selection = Document.Selection;
var ay = selection.GetActivePointY(mePosLogical);
var line = Document.GetLine(ay);
var lineIndent = line.match(/^[ \t ]*/);
selection.StartOfLine(false, mePosLogical);
if (insertIndent) {
selection.Text = lineIndent;
}
var indentX = selection.GetActivePointX(mePosLogical);
selection.Text = '\n';
selection.SetActivePoint(mePosLogical, indentX, ay);
Redraw = true;
スポンサーリンク