-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemangle.mac
195 lines (169 loc) · 4.81 KB
/
demangle.mac
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*デマングルする秀丸マクロ
(動作)
-編集中のテキストには変更を加えません。デマングルした結果を
「新しいウインドウ、または、アウトプット枠」へ出力します。
-選択範囲あり(一行)
選択範囲をデマングルして表示。
-選択範囲あり(複数行)
選択の開始行から終了行までを一行単位でデマングルして表示します。
-選択範囲無し
直近のマングルされた名前っぽい箇所をデマングルして表示。
-矩形選択
「選択範囲あり(複数行)」と同じ動作
ohtorii
http://d.hatena.ne.jp/ohtorii/
https://github.com/ohtorii
*/
////////////////////////////////////////////////////////////////////////////
// ユーザーカスタマイズ
////////////////////////////////////////////////////////////////////////////
$g_exe_abs_path = currentmacrodirectory + "\\" + "demangle.exe";
$g_dll_dengaku_abs_path = hidemarudir + "\\" + "DengakuDLL.dll";
////////////////////////////////////////////////////////////////////////////
// メイン処理
////////////////////////////////////////////////////////////////////////////
$g_mangle_names = "";
$old_searchbuffer = searchbuffer;
#old_searchoption = searchoption;
//動作環境を固定化する。
//折りたたみを維持,部分編集を維持,範囲選択,最後に移動
//マクロ終了時に元に戻る。
setcompatiblemode 0x0003|0x000c|0x0200|0x2000;
call ClearOutput;
call LoadDengaku;
if(result){
call Main;
freedll;
setsearch $old_searchbuffer, #old_searchoption;
//runexを非同期で呼ぶとマクロが終了するため最後に処理する。
call DoDemangle;
}
endmacro;
Main:
disabledraw;
##old_column=column;
##old_lineno=lineno;
if(rectselecting){
call DoRecselecting;
}else{
if(selecting) {
if(seltoplineno==selendlineno){
call DoSelectingSingle;
}else{
call DoSelectingMulti;
}
}else{
call DoNoSelecting;
}
}
movetolineno 1+##old_column,##old_lineno;
return ;
DoRecselecting:
##old_x=x;
##old_y=y;
##old_seltopcolumn=seltopcolumn;
##old_seltoplineno=seltoplineno;
##old_selendlineno=selendlineno;
escape;
while(##old_seltoplineno <= ##old_selendlineno){
/*
以下の時にうまくカーソル移動するために2回に分けて移動する。
\t\t|name_1
name|_1
・| は矩形選択時のカーソル位置
・\t==8space
*/
movetolineno 1,##old_seltoplineno;
moveto ##old_x,y;
call DoNoSelecting;
##old_seltoplineno=##old_seltoplineno+1;
}
return ;
DoSelectingMulti:
##old_seltoplineno=seltoplineno;
##old_selendlineno=selendlineno;
while(##old_seltoplineno <= ##old_selendlineno){
movetolineno 1,##old_seltoplineno;
selectline;
$$str = gettext2(seltopcolumn,seltoplineno,selendcolumn,selendlineno);
$$str = dllfuncstr("RTRIM",$$str);
$g_mangle_names=$g_mangle_names + " " + $$str;
##old_seltoplineno=##old_seltoplineno+1;
}
return ;
DoSelectingSingle:
$$str = gettext2(seltopcolumn,seltoplineno,selendcolumn,selendlineno);
$$str = dllfuncstr("RTRIM",$$str);
$g_mangle_names=$g_mangle_names + " " + $$str;
return ;
DoNoSelecting:
if(linelen2){
call DoNoSelecting_Move;
##old_lineno = lineno;
searchdown2 "[\\c@?$_]+", regular,nocasesense,nohilight;
if(result && selecting && (##old_lineno==lineno)){
$$str = gettext2(seltopcolumn,seltoplineno,selendcolumn,selendlineno);
$$str = dllfuncstr("RTRIM",$$str);
$g_mangle_names=$g_mangle_names + " " + $$str;
}
}
return ;
/*カーソルをマングル化された(と思われる)名前の先頭へ移動する。*/
DoNoSelecting_Move:
##old_lineno = lineno;
##old_column = column;
##u = unicode;
if((0x0d==##u)||(0x0a==##u)||(0==##u)||(-1==##u)){
//カーソルは行末なので左へ1列移動
left;
##old_column = column;
##u = unicode;
}
if(##old_lineno != lineno){
movetolineno ##old_column+1, ##old_lineno;
return ;
}
while((0x20<##u) && (##u<0x7f) && (##old_lineno == lineno)){
left;
if(! result){
break;
}
##u = unicode;
}
if(##old_lineno != lineno){
movetolineno 1, ##old_lineno;
return ;
}
return ;
DoDemangle:
if( strlen($g_mangle_names)){
$$cmd_exe = "\"" + $g_exe_abs_path + "\"";
$$cmd = $$cmd_exe + " " + $g_mangle_names;
//message $$cmd;
runex $$cmd
, 0 //sync 0:async 1:sync
, 5, "" //stdin 0:none 1:auto 2:file 3:(reserve) 4:all 5:select
, 7, "" //stdout 0:none 1:auto 2:file 3:add file 4:new 5:insert 6:replace
, 1, "" //stderr 0:none 1:=out 2:file 3:add file 4:new 5:insert 6:replace
, 0, "" //folder 0:none 1:current 2:specify 3:(reserve) 4:exe's folder
, 2 //show 0:auto 1:show 2:hide
, 1 //nodraw 0:draw 1:no draw
, 0 //unicode 0:ansi 2:unicode
;
}
return ;
ClearOutput:
loaddll "HmOutputPane.dll";
//アウトプット枠を開く
#ret=dllfunc("Output",hidemaruhandle(0),"");
//アウトプット枠をクリア
#h=dllfunc("GetWindowHandle",hidemaruhandle(0));
#ret=sendmessage(#h,0x111/*WM_COMMAND*/,1009,0);
return ;
LoadDengaku:
loaddll $g_dll_dengaku_abs_path;
if (!result) {
message "田楽DLLのロードに失敗しました\n" + "DengakuDLL.dllが秀丸のディレクトリに存在するか確認してください";
return false;
}
return true;