非選択時に改行単位で行をコピー/切り取り/貼り付け、改行単位で行削除
- ページ: Macro/投稿
- 作者: jj?
- カテゴリー: js
- 投稿日: 2015-03-31 (火) 23:13:39
メッセージ
クリップボードにコピー(Ctrl+C) や 切り取り(Ctrl+X) と同じですが、
非選択状態の場合に、折り返しがあっても改行単位でカーソル行全体を
コピー/切り取り する点が異なります。
貼り付け(Ctrl+V) も同じですが、非選択状態の場合に、折り返しがあっても
改行単位の行頭から貼り付け する点が異なります。
行削除(Shift+Ctrl+E) は、折り返しがあっても改行単位で行全体を削除
する点が異なります。更に、範囲選択状態でも動作し、複数行が選択されていれば
選択行すべてを削除します。
(要sakura:2.1.0.0以降)
(2015/04/28)
・共通設定『編集』プロパティ-[選択なしでコピーを可能にする]、[ラインモード貼り付けを可能にする] の挙動に合わせた。
・切り取り後のカーソル位置を、通常の切り取りに合わせた。
・貼り付け(PasteEx.js)追加。
・行削除(DeleteLineEx.js)追加。
個人的には改行単位の方が便利なので、Ctrl+C と F8、Ctrl+X と F7 に割り当てて
使ってます。(…でもこういうのは機能追加の要望を出せばよかったかも。)
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
| |
var bBY_NEWLINE = true;
Main();
function Main()
{
var sCF_LOCAL = "#X-Macro_CopyCutEx#"; var nOpt;
var s;
if( (!bBY_NEWLINE) || (Editor.GetSelectedString(0) != "") ){
Editor.Copy(); return;
}
Editor.SetClipboardByFormat( "test", sCF_LOCAL, 0, -1 ); Editor.Copy(); if( Editor.IsIncludeClipboardFormat( sCF_LOCAL ) ) return;
nOpt = (Editor.IsIncludeClipboardFormat( "MSDEVLineSelect" )) ? 0x02 : 0x00; s = Editor.GetLineStr( 0 );
if( s == "" ) return; Editor.SetClipboard( nOpt, s ); }
|
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
| |
var bBY_NEWLINE = true;
var bKEEP_CURSOR_POSITION = true;
Main();
function Main()
{
var sCF_LOCAL = "#X-Macro_CopyCutEx#"; var nInsMode;
var nOpt;
var s;
var x, y, x2;
if( (!bBY_NEWLINE) || (Editor.GetSelectedString(0) != "") ){
Editor.Cut(); return;
}
switch( Editor.ExpandParameter("${R?0$:1$:2}")-0 ){
case 0: return;
case 1: nInsMode = Editor.IsInsMode();
Editor.ChgmodINS();
if( nInsMode == Editor.IsInsMode() ) return; Editor.ChgmodINS();
break;
case 2: default:
break;
}
Editor.SetClipboardByFormat( "test", sCF_LOCAL, 0, -1 ); Editor.Copy(); if( Editor.IsIncludeClipboardFormat( sCF_LOCAL ) ) return;
nOpt = (Editor.IsIncludeClipboardFormat( "MSDEVLineSelect" )) ? 0x02 : 0x00; s = Editor.GetLineStr( 0 );
if( s == "" ) return; Editor.SetClipboard( nOpt, s );
x = Editor.ExpandParameter("$x") -0; y = Editor.ExpandParameter("$y") -0;
Editor.SetDrawSwitch( 0 );
Editor.AddRefUndoBuffer(); Editor.AppendUndoBufferCursor();
if( bKEEP_CURSOR_POSITION ){
if( y < Editor.GetLineCount(0) ){
while( (Editor.ExpandParameter("$y") -0) == y ) Editor.Down();
x2 = Editor.ExpandParameter("$x") -0;
}else{
x2 = 1; }
Editor.MoveCursor( y, x, 0 );
}
Editor.SelectLine(0);
@if( 0 )
Editor.Delete();
@else
Editor.InsText(""); @end
if( bKEEP_CURSOR_POSITION ){
Editor.MoveCursor( y, x2, 0 );
Editor.AppendUndoBufferCursor();
}
Editor.SetUndoBuffer(); Editor.SetDrawSwitch( 1 );
Editor.ReDraw();
}
|
コードは概ね同様なのでZIP。
PasteEx.zip
DeleteLineEx.zip
旧版:
CopyCutEx.old20150331.zip