選択範囲を上下に移動

2013年3月15日 (金) 22:06時点におけるKs (トーク | 投稿記録)による版 (ページの作成:「= 概要 = 選択されている範囲を 1 行上下します.<br> (某所よりログが流れてしまうため待避) = コード = == 下へ移動 == <sourc...」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)

概要

選択されている範囲を 1 行上下します.
(某所よりログが流れてしまうため待避)

コード

下へ移動

var s = Document.Selection;
var ty = s.GetTopPointY(mePosLogical);
var by = s.GetBottomPointY(mePosLogical);
if (Document.GetLines(0) > by) {
  SelectLine(s, ty, by+1);
  var a = s.Text.split("\n");
  a.unshift(a.pop());
  s.Text = a.join("\n");
  SelectLine(s, ty+1, by+1);
}
function SelectLine(s, ty, by) {
  s.SetAnchorPoint(mePosLogical, 1, ty);
  s.SetActivePoint(mePosLogical, 1, by, true);
  s.EndOfLine(true, mePosLogical);
}

下へ移動

var s = Document.Selection;
var ty = s.GetTopPointY(mePosLogical);
var by = s.GetBottomPointY(mePosLogical);
if (ty > 1) {
  SelectLine(s, ty-1, by);
  var a = s.Text.split("\n");
  a.push(a.shift());
  s.Text = a.join("\n");
  SelectLine(s, ty-1, by-1);
}
function SelectLine(s, ty, by) {
  s.SetAnchorPoint(mePosLogical, 1, ty);
  s.SetActivePoint(mePosLogical, 1, by, true);
  s.EndOfLine(true, mePosLogical);
}
スポンサーリンク