// 初期化-現在行の取得 var isSel = !document.selection.IsEmpty; // カーソルの位置x var curCol = document.selection.GetActivePointX( eePosLogical ); var lineCount=document.GetLines(); // 文書全体の行数 if(!isSel){ var curLine = document.selection.GetActivePointY( eePosLogical ); // カーソル位置の現在行 }else{ var start_x = document.selection.GetAnchorPointX(eePosLogical); var start_y = document.selection.GetAnchorPointY(eePosLogical); var end_x = document.selection.GetActivePointX(eePosLogical); var end_y = document.selection.GetActivePointY(eePosLogical); if(start_y > end_y){ // 下から上へ選択した時 if(start_x == 1){ var curLine = start_y -1; }else{ var curLine = start_y; } var up_y = end_y; }else{ if(end_x == 1){ var curLine = end_y - 1; // 選択範囲の右下に合わせる }else{ var curLine = end_y; // 選択範囲の右下に合わせる } var up_y = start_y } } if(curLine == lineCount) Quit(); // クリップボードのデータを退避 str = clipboardData.getData("Text"); // 最終行に移動する場合 if(!isSel){ if(lineCount-1 == curLine){ document.selection.EndOfDocument(); document.selection.NewLine(); document.selection.SetActivePoint( eePosLogical, curCol, curLine, false ); } document.selection.SelectLine(); }else{ if(lineCount-1 == curLine){ document.selection.Collapse(); document.selection.EndOfDocument(); document.selection.NewLine(); // 選択範囲を復元 document.selection.SetActivePoint(eePosLogical, 1, curLine, true ); document.selection.SetAnchorPoint(eePosLogical, 1, up_y); } document.selection.SetActivePoint(eePosLogical, 1, curLine+1, true); document.selection.SetAnchorPoint(eePosLogical, 1, up_y); } document.selection.Cut() document.selection.LineDown(); document.selection.StartOfLine(false, eeLineLogical) document.selection.Paste(); if(lineCount-1==curLine){ document.selection.EndOfDocument(); document.selection.DeleteLeft(1); } if(isSel){ document.selection.SetActivePoint(eePosLogical, 1, curLine+2, false ); document.selection.SetAnchorPoint(eePosLogical, 1, up_y+1); }else{ // カーソルの位置を復元 document.selection.SetActivePoint( eePosLogical, curCol, curLine+1, true ); document.selection.Collapse(); } // クリップボードのデータを復元 clipboardData.setData("Text", str);