-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpsearch.mac
More file actions
180 lines (146 loc) · 3.95 KB
/
psearch.mac
File metadata and controls
180 lines (146 loc) · 3.95 KB
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
/* psearch.mac
検索結果をポップアップ表示する秀丸マクロ。
(xyzzyのpsearchに相当するマクロです。)
【動作】
カーソル位置にある単語を検索し、検索結果をメニューで一覧表示します。
更に、メニューから単語のある行へジャンプすることができます。
選択の「あり・なし」で検索方法が変わります。
選択無し:カーソル位置の単語を検索。
選択あり:選択された文字を検索。(単語では検索しない)
【動作を確認した環境】
・秀丸エディタ 8.40 b40
・田楽DLL
http://www.ceres.dti.ne.jp/~sugiura/
田楽DLL Ver.3.20で動作することを確認しています、別途インストールしてください。
【オリジナルの作者】
秀丸エディタスレ Part30
178 :名無しさん@お腹いっぱい。 :2010/10/14(木) 02:08:50 ID:7v+i/hHB0 (2 回発言)
【連絡先】
ohtorii
http://d.hatena.ne.jp/ohtorii/
https://github.com/ohtorii
*/
////////////////////////////////////////////////////////////////////////////
// カスタマイズ
////////////////////////////////////////////////////////////////////////////
//メニューに検索結果を幾つ表示するか。
#g_max_num = 100;
////////////////////////////////////////////////////////////////////////////
// メイン処理
////////////////////////////////////////////////////////////////////////////
$g_tabspace="";
$g_searchbuffer = searchbuffer;
#g_searchoption = searchoption;
call Main;
setsearch $g_searchbuffer, #g_searchoption;
endmacro;
Main:
call LoadDengaku;
if(! ##return){
return false;
}
call SetupTabSpace;
#old_lineno = lineno;
#lineno[-1] = lineno;
#column[-1] = column;
#search_word = false;
if(! selecting){
selectword;
#search_word=true;
}
$word = gettext(seltopx, seltopy, selendx, selendy);
if(0==strlen($word)){
return ;
}
disabledraw;
gofiletop;
if(#search_word){
searchdown2 $word, word,nocasesense,noregular,nohilight;
}else{
searchdown2 $word,nocasesense,noregular,nohilight;
}
hilightfound 1;
#cur_pos_index = -1;
#prev_line_no = -1;
while (result && (#i < #g_max_num)) {
if(lineno != #prev_line_no){
if(lineno == #old_lineno){
#cur_pos_index = #i;
$mark = "→";
}else{
$mark = " ";
}
call GetLineStr;
$line_str = $$return;
$m[#i] = $mark + str(lineno) + ": " + $line_str;
#lineno[#i] = lineno;
#column[#i] = column;
}
#i = #i + 1;
#prev_line_no = lineno;
finddown;
}
movetolineno #column[-1] + 1, #lineno[-1];
enabledraw;
menuarray $m, #i;
if (result){
if(#cur_pos_index != (result-1)){
#r = result-1;
disabledraw;
movetolineno #column[#r] + 1, #lineno[#r];
//カーソルを画面中心にする
//enabledraw y - (windowheight/2);
}
}
return ;
GetLineStr:
escape;
golinetop2;
beginsel;
golineend2;
endsel;
$$text = gettext2(seltopcolumn, seltoplineno, selendcolumn, selendlineno);
call TrimString $$text;
$$text = $$return;
//& -> &&へ変換する。この処理がないとメニューで文字の下にアンダーバーが付く。
$$text=dllfuncstr("GSUB",$$text,"&","&&",-1);
//タブ文字を空白文字へ変換する。
$$text = dllfuncstr("GSUB", $$text, "\t", " ", -1);
return $$text;
LoadDengaku:
//田楽DLLをロード
loaddll ( hidemarudir + "\\DengakuDLL.dll" );
if ( !result ){
message "田楽DLLをロードできませんでした。";
return false;
}
//
//田楽DLLのバージョンチェック
$dllver = leftstr ( dllfuncstr("GETVERSION") ,1 ) + rightstr ( dllfuncstr("GETVERSION") ,2 );
if ( val ( $dllver ) <= 204 ) {
message "このマクロの実行には Ver2.04 以降の田楽DLLが必要です。";
freedll;
return false;
}
return true;
SetupTabSpace:
$g_tabspace="";
##i=0;
while(##i<tabcount){
$g_tabspace=$g_tabspace+" ";
##i=##i+1;
}
return;
TrimString:
$$space="\r\n\t ";//空白文字を定義
while(1){
##word=strlen($$1);
//文字列の先頭に空白文字がある場合、空白文字を削除
if(strstr($$space,leftstr($$1,2))!=-1)$$1=rightstr($$1,##word-2);
else if(strstr($$space,rightstr($$1,2))!=-1)$$1=leftstr($$1,##word-2);
//ここまで全角文字の対処
else if(strstr($$space,leftstr($$1,1))!=-1)$$1=rightstr($$1,##word-1);
else if(strstr($$space,rightstr($$1,1))!=-1)$$1=leftstr($$1,##word-1);
else break;
}
return $$1;