[475] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[3] | 3 | #include "common.h"
|
---|
| 4 |
|
---|
[763] | 5 | HRESULT ApplyDialogTexture( HWND );
|
---|
| 6 |
|
---|
[3] | 7 | long *pFindPos;
|
---|
| 8 | int FindPosCounter;
|
---|
| 9 |
|
---|
[80] | 10 | char *CompareSuper(HWND hDlg,char *buffer,char *szFind,BOOL IsBigSmall,bool isWordUnit,BOOL IsRegExp,int *pLength ){
|
---|
[3] | 11 | char *pTemp;
|
---|
| 12 |
|
---|
| 13 | if(buffer[0]=='\0') return 0;
|
---|
| 14 |
|
---|
| 15 | if(IsRegExp){
|
---|
| 16 | //正規表現を有効にしながら検索
|
---|
[80] | 17 | pTemp=obj_RegExp.compare(hDlg,buffer,szFind,IsBigSmall, isWordUnit, pLength);
|
---|
[3] | 18 | }
|
---|
| 19 | else{
|
---|
| 20 | //通常の検索
|
---|
[80] | 21 | pTemp=ComparisonString(buffer,szFind,IsBigSmall?true:false, isWordUnit );
|
---|
[3] | 22 |
|
---|
| 23 | *pLength=lstrlen(szFind);
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | return pTemp;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
[80] | 29 | void SetSearchData(HWND hDlg,char *str,_int8 IsBigSmall, bool isWordUnit){
|
---|
[3] | 30 | extern HANDLE hHeap;
|
---|
| 31 | int i,i2,i3,i4,i5,length;
|
---|
| 32 | int WndNum;
|
---|
| 33 | char *buffer,*FindStr,*LineStr;
|
---|
| 34 | HWND hEdit;
|
---|
| 35 |
|
---|
| 36 | WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
|
---|
| 37 | if(WndNum==-1) return;
|
---|
| 38 | hEdit=GetWindow(GetWindow(hClient,GW_CHILD),GW_CHILD);
|
---|
| 39 |
|
---|
[629] | 40 | i=lstrlen(MdiInfo[WndNum]->pMdiTextEdit->buffer)+1;
|
---|
[3] | 41 |
|
---|
| 42 | buffer=(char *)HeapAlloc(hHeap,0,i);
|
---|
[629] | 43 | lstrcpy(buffer,MdiInfo[WndNum]->pMdiTextEdit->buffer);
|
---|
[3] | 44 |
|
---|
| 45 | LineStr=(char *)HeapAlloc(hHeap,0,i+64);
|
---|
| 46 |
|
---|
| 47 | pFindPos[0]=(long)hEdit;
|
---|
| 48 | i=0;
|
---|
| 49 | i3=1;
|
---|
| 50 | while(1){
|
---|
[80] | 51 | FindStr=CompareSuper(hDlg,buffer+i,str,IsBigSmall, isWordUnit, pobj_nv->bRegExp,&length);
|
---|
[3] | 52 | if(FindStr==(char *)-1){
|
---|
| 53 | //エラー
|
---|
| 54 | return;
|
---|
| 55 | }
|
---|
| 56 | if(!FindStr) break;
|
---|
| 57 |
|
---|
| 58 | i=FindStr-buffer;
|
---|
| 59 | for(i4=0,i5=1;i>i4;i4++){
|
---|
| 60 | if(buffer[i4-1]=='\r'&&buffer[i4]=='\n') i5++;
|
---|
| 61 | }
|
---|
| 62 | for(;i>0;i--){
|
---|
| 63 | if(buffer[i-2]=='\r'&&buffer[i-1]=='\n') break;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | FindPosCounter+=sizeof(long);
|
---|
| 67 | pFindPos=(long *)HeapReAlloc(hHeap,0,pFindPos,FindPosCounter);
|
---|
| 68 | pFindPos[i3]=i;
|
---|
| 69 |
|
---|
| 70 | sprintf(LineStr,"Line:%d ",i5);
|
---|
| 71 | for(i2=lstrlen(LineStr);;i++,i2++){
|
---|
| 72 | if((buffer[i]=='\r'&&buffer[i+1]=='\n')||buffer[i]=='\0'){
|
---|
| 73 | LineStr[i2]=0;
|
---|
| 74 | break;
|
---|
| 75 | }
|
---|
| 76 | LineStr[i2]=buffer[i];
|
---|
| 77 | }
|
---|
[763] | 78 | SendDlgItemMessage(hDlg,IDC_FINDLIST,LB_ADDSTRING,0,(LPARAM)LineStr);
|
---|
[3] | 79 | i3++;
|
---|
| 80 | }
|
---|
| 81 | HeapDefaultFree(buffer);
|
---|
| 82 | HeapDefaultFree(LineStr);
|
---|
| 83 | }
|
---|
| 84 | BOOL CALLBACK DlgFindAll(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
|
---|
| 85 | int i,WndNum;
|
---|
| 86 |
|
---|
| 87 | switch(message){
|
---|
| 88 | case WM_INITDIALOG:
|
---|
| 89 | SetPosCenter(hwnd);
|
---|
[763] | 90 | ApplyDialogTexture(hwnd);
|
---|
[3] | 91 | break;
|
---|
| 92 | case WM_COMMAND:
|
---|
| 93 | switch(LOWORD(wParam)){
|
---|
| 94 | case IDC_SHOWITEM:
|
---|
| 95 | i=SendDlgItemMessage(hwnd,IDC_FINDLIST,LB_GETCURSEL,0,0);
|
---|
| 96 | if(i==LB_ERR) return 1;
|
---|
| 97 | i++;
|
---|
| 98 |
|
---|
| 99 | if(!IsWindow((HWND)pFindPos[0])){
|
---|
| 100 | MessageBeep(0);
|
---|
| 101 | return 1;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | WndNum=GetWndNum(GetParent((HWND)pFindPos[0]));
|
---|
| 105 | if(WndNum==-1) return 1;
|
---|
| 106 |
|
---|
| 107 | CHARRANGE CharRange;
|
---|
| 108 | CharRange.cpMin=pFindPos[i];
|
---|
| 109 |
|
---|
| 110 | char *pBuf;
|
---|
[629] | 111 | pBuf=MdiInfo[WndNum]->pMdiTextEdit->buffer;
|
---|
[3] | 112 |
|
---|
| 113 | //行の末端位置を取得
|
---|
| 114 | for(i=CharRange.cpMin;;i++){
|
---|
| 115 | if(pBuf[i]=='\0') break;
|
---|
| 116 | if(pBuf[i]=='\r'&&pBuf[i+1]=='\n') break;
|
---|
| 117 | }
|
---|
| 118 | CharRange.cpMax=i;
|
---|
| 119 |
|
---|
| 120 | TextEdit_SetSel(WndNum,CharRange.cpMin,CharRange.cpMax,TRUE);
|
---|
| 121 |
|
---|
| 122 | SetFocus((HWND)pFindPos[0]);
|
---|
| 123 | return 1;
|
---|
| 124 | case IDCANCEL:
|
---|
| 125 | HeapDefaultFree(pFindPos);
|
---|
| 126 | EndDialog(hwnd,0);
|
---|
| 127 | return 1;
|
---|
| 128 | case IDC_FINDLIST:
|
---|
| 129 | if(HIWORD(wParam)==LBN_DBLCLK) SendMessage(hwnd,WM_COMMAND,IDC_SHOWITEM,0);
|
---|
| 130 | return 1;
|
---|
| 131 | }
|
---|
| 132 | break;
|
---|
| 133 | case WM_SIZE:
|
---|
| 134 | RECT rect;
|
---|
| 135 | GetClientRect(hwnd,&rect);
|
---|
| 136 | MoveWindow(GetDlgItem(hwnd,IDC_FINDLIST),rect.left,26,rect.right,rect.bottom-26,1);
|
---|
| 137 | return 1;
|
---|
| 138 | }
|
---|
| 139 | return 0;
|
---|
| 140 | }
|
---|
[80] | 141 | BOOL StartSearch(HWND hDlg,char *FindString,_int8 IsBigSmall, bool isWordUnit, BOOL IsShowMessage){
|
---|
[3] | 142 | int i;
|
---|
| 143 | char *pBuf,msg[255];
|
---|
| 144 | CHARRANGE CharRange;
|
---|
| 145 |
|
---|
| 146 | int WndNum;
|
---|
| 147 | WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
|
---|
| 148 | if(WndNum==-1) return 0;
|
---|
| 149 |
|
---|
[629] | 150 | pBuf=MdiInfo[WndNum]->pMdiTextEdit->buffer;
|
---|
[3] | 151 |
|
---|
| 152 | TextEdit_GetSel(WndNum,&CharRange);
|
---|
| 153 | i=CharRange.cpMax;
|
---|
| 154 |
|
---|
| 155 | FindStart:
|
---|
| 156 |
|
---|
| 157 | int length;
|
---|
| 158 |
|
---|
[80] | 159 | i=(int)CompareSuper(hDlg,pBuf+i,FindString,IsBigSmall, isWordUnit, pobj_nv->bRegExp,&length);
|
---|
[3] | 160 | if(i==-1){
|
---|
| 161 | //エラー
|
---|
| 162 | return 0;
|
---|
| 163 | }
|
---|
| 164 |
|
---|
| 165 | if(i){
|
---|
| 166 | //検索文字列を反転表示
|
---|
| 167 | i-=(int)pBuf;
|
---|
| 168 | CharRange.cpMin=i;
|
---|
| 169 | CharRange.cpMax=i+length;
|
---|
| 170 | TextEdit_SetSel(WndNum,CharRange.cpMin,CharRange.cpMax,TRUE);
|
---|
| 171 |
|
---|
| 172 | return 1;
|
---|
| 173 | }
|
---|
| 174 | else{
|
---|
| 175 | if(!IsShowMessage) return 0;
|
---|
| 176 |
|
---|
[80] | 177 | i=(int)CompareSuper(hDlg,pBuf,FindString,IsBigSmall, isWordUnit, pobj_nv->bRegExp,&length);
|
---|
[3] | 178 | if(i==-1){
|
---|
| 179 | //エラー
|
---|
| 180 | return 0;
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | if(i){
|
---|
| 184 | //"ファイルの最初から検索しますか?"
|
---|
| 185 | if(MessageBox(hDlg,STRING_SEARCH_AGAIN,"ProjectEditor - Search",MB_YESNO|MB_ICONINFORMATION)==IDYES){
|
---|
| 186 | i=0;
|
---|
| 187 | goto FindStart;
|
---|
| 188 | }
|
---|
| 189 | }
|
---|
| 190 | else{
|
---|
| 191 | //"文字列 \"%s\" が見つかりません"
|
---|
| 192 | sprintf(msg,STRING_SEARCH_NOTFOUND,FindString);
|
---|
| 193 | MessageBox(hDlg,msg,"ProjectEditor - Search",MB_OK|MB_ICONINFORMATION);
|
---|
| 194 | }
|
---|
| 195 | }
|
---|
| 196 | return 0;
|
---|
| 197 | }
|
---|
| 198 | void AddFindData(HWND hwnd,char ppData[MAX_FINDLIST][MAX_PATH],char *str){
|
---|
| 199 | int i;
|
---|
| 200 | for(i=0;i<MAX_FINDLIST;i++){
|
---|
| 201 | if(lstrcmp(ppData[i],str)==0) break;
|
---|
| 202 | }
|
---|
| 203 | if(i==MAX_FINDLIST) i--;
|
---|
| 204 | for(;i>0;i--) lstrcpy(ppData[i],ppData[i-1]);
|
---|
| 205 | lstrcpy(ppData[0],str);
|
---|
| 206 | SendMessage(hwnd,CB_RESETCONTENT,0,0);
|
---|
| 207 | for(i=0;i<MAX_FINDLIST;i++){
|
---|
| 208 | if(ppData[i][0]=='\0') break;
|
---|
[763] | 209 | SendMessage(hwnd,CB_ADDSTRING,0,(LPARAM)ppData[i]);
|
---|
[3] | 210 | }
|
---|
| 211 | SendMessage(hwnd,CB_SETCURSEL,0,0);
|
---|
| 212 | }
|
---|
[763] | 213 | INT_PTR CALLBACK DlgFind(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
|
---|
[3] | 214 | extern HANDLE hHeap;
|
---|
| 215 | HWND FindAllDlg;
|
---|
| 216 | int i,WndNum;
|
---|
| 217 | char temporary[8192],*pTemp;
|
---|
| 218 | CHARRANGE CharRange;
|
---|
| 219 |
|
---|
| 220 | switch(message){
|
---|
| 221 | case WM_INITDIALOG:
|
---|
| 222 | SetPosCenter(hwnd);
|
---|
| 223 |
|
---|
| 224 | //大文字・小文字
|
---|
| 225 | if(pobj_nv->bFindStrBigSmall) SendDlgItemMessage(hwnd,IDC_ISBIGSMALL,BM_SETCHECK,BST_CHECKED,0);
|
---|
| 226 |
|
---|
[80] | 227 | // 単語単位
|
---|
| 228 | if( pobj_nv->isWordUnit ){
|
---|
| 229 | SendDlgItemMessage( hwnd, IDC_ISWORDUNIT, BM_SETCHECK, BST_CHECKED, 0 );
|
---|
| 230 | }
|
---|
| 231 |
|
---|
[3] | 232 | //正規表現
|
---|
| 233 | if(pobj_nv->bRegExp) SendDlgItemMessage(hwnd,IDC_REGEXP,BM_SETCHECK,BST_CHECKED,0);
|
---|
| 234 |
|
---|
| 235 | //検索文字列コンボボックスを初期化
|
---|
| 236 | SendDlgItemMessage(hwnd,IDC_FINDSTR,CB_RESETCONTENT,0,0);
|
---|
| 237 | for(i=0;i<MAX_FINDLIST;i++){
|
---|
| 238 | if(pobj_nv->FindStr[i][0]=='\0') break;
|
---|
[763] | 239 | SendDlgItemMessage(hwnd,IDC_FINDSTR,CB_ADDSTRING,0,(LPARAM)pobj_nv->FindStr[i]);
|
---|
[3] | 240 | }
|
---|
| 241 | SendDlgItemMessage(hwnd,IDC_FINDSTR,CB_LIMITTEXT,8192,0);
|
---|
| 242 |
|
---|
| 243 | WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
|
---|
| 244 |
|
---|
| 245 | //選択されている文字列を取得
|
---|
| 246 | TextEdit_GetSel(WndNum,&CharRange);
|
---|
| 247 | pTemp=(char *)HeapAlloc(hHeap,0,CharRange.cpMax-CharRange.cpMin+1);
|
---|
| 248 | memcpy(pTemp,
|
---|
[629] | 249 | MdiInfo[WndNum]->pMdiTextEdit->buffer+CharRange.cpMin,
|
---|
[3] | 250 | CharRange.cpMax-CharRange.cpMin);
|
---|
| 251 | pTemp[CharRange.cpMax-CharRange.cpMin]=0;
|
---|
| 252 |
|
---|
| 253 | if(pTemp[0]) SetDlgItemText(hwnd,IDC_FINDSTR,pTemp);
|
---|
| 254 | else SendDlgItemMessage(hwnd,IDC_FINDSTR,CB_SETCURSEL,0,0);
|
---|
| 255 |
|
---|
| 256 | HeapDefaultFree(pTemp);
|
---|
| 257 |
|
---|
| 258 | SetFocus(GetDlgItem(hwnd,IDC_FINDSTR));
|
---|
[763] | 259 |
|
---|
| 260 | ApplyDialogTexture(hwnd);
|
---|
[3] | 261 | break;
|
---|
| 262 | case WM_COMMAND:
|
---|
| 263 | switch(LOWORD(wParam)){
|
---|
| 264 | case IDOK:
|
---|
| 265 | GetDlgItemText(hwnd,IDC_FINDSTR,temporary,MAX_PATH);
|
---|
| 266 | if(temporary[0]==0) return 1;
|
---|
| 267 | AddFindData(GetDlgItem(hwnd,IDC_FINDSTR),pobj_nv->FindStr,temporary);
|
---|
| 268 |
|
---|
| 269 | //大文字・小文字
|
---|
| 270 | if(SendDlgItemMessage(hwnd,IDC_ISBIGSMALL,BM_GETCHECK,0,0)) pobj_nv->bFindStrBigSmall=1;
|
---|
| 271 | else pobj_nv->bFindStrBigSmall=0;
|
---|
| 272 |
|
---|
[80] | 273 | // 単語単位
|
---|
| 274 | pobj_nv->isWordUnit =
|
---|
| 275 | ( SendDlgItemMessage( hwnd, IDC_ISWORDUNIT, BM_GETCHECK, 0, 0 ) != 0 );
|
---|
| 276 |
|
---|
[3] | 277 | //正規表現
|
---|
| 278 | if(SendDlgItemMessage(hwnd,IDC_REGEXP,BM_GETCHECK,0,0)) pobj_nv->bRegExp=1;
|
---|
| 279 | else pobj_nv->bRegExp=0;
|
---|
| 280 |
|
---|
[80] | 281 | StartSearch(hwnd,temporary,pobj_nv->bFindStrBigSmall, pobj_nv->isWordUnit, 1);
|
---|
[3] | 282 | return 1;
|
---|
| 283 | case IDC_FINDALL:
|
---|
| 284 | GetDlgItemText(hwnd,IDC_FINDSTR,temporary,MAX_PATH);
|
---|
| 285 | if(temporary[0]==0) return 1;
|
---|
| 286 | AddFindData(GetDlgItem(hwnd,IDC_FINDSTR),pobj_nv->FindStr,temporary);
|
---|
| 287 |
|
---|
| 288 | //大文字・小文字
|
---|
| 289 | if(SendDlgItemMessage(hwnd,IDC_ISBIGSMALL,BM_GETCHECK,0,0)) pobj_nv->bFindStrBigSmall=1;
|
---|
| 290 | else pobj_nv->bFindStrBigSmall=0;
|
---|
| 291 |
|
---|
[80] | 292 | // 単語単位
|
---|
| 293 | pobj_nv->isWordUnit =
|
---|
| 294 | ( SendDlgItemMessage( hwnd, IDC_ISWORDUNIT, BM_GETCHECK, 0, 0 ) != 0 );
|
---|
| 295 |
|
---|
[3] | 296 | //正規表現
|
---|
| 297 | if(SendDlgItemMessage(hwnd,IDC_REGEXP,BM_GETCHECK,0,0)) pobj_nv->bRegExp=1;
|
---|
| 298 | else pobj_nv->bRegExp=0;
|
---|
| 299 |
|
---|
| 300 | FindAllDlg=CreateDialog(hResInst,MAKEINTRESOURCE(IDD_FINDALL),GetWindow(hwnd,GW_OWNER),(DLGPROC)DlgFindAll);
|
---|
| 301 | ShowWindow(FindAllDlg,SW_SHOW);
|
---|
| 302 |
|
---|
| 303 | FindPosCounter=sizeof(long);
|
---|
| 304 | pFindPos=(long *)HeapAlloc(hHeap,0,FindPosCounter);
|
---|
[80] | 305 | SetSearchData(FindAllDlg,temporary,pobj_nv->bFindStrBigSmall, pobj_nv->isWordUnit );
|
---|
[3] | 306 | case IDCANCEL:
|
---|
| 307 | EndDialog(hwnd,0);
|
---|
| 308 | return 1;
|
---|
| 309 | }
|
---|
| 310 | break;
|
---|
| 311 | }
|
---|
| 312 | return 0;
|
---|
| 313 | }
|
---|
[763] | 314 | INT_PTR CALLBACK DlgPermutation(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){
|
---|
[3] | 315 | extern HANDLE hHeap;
|
---|
| 316 | extern HINSTANCE hInst;
|
---|
| 317 | int i;
|
---|
| 318 | int WndNum;
|
---|
| 319 | char temporary[8192],temp2[8192],*pTemp;
|
---|
| 320 | CHARRANGE CharRange;
|
---|
| 321 | switch(message){
|
---|
| 322 | case WM_INITDIALOG:
|
---|
| 323 | SetPosCenter(hwnd);
|
---|
| 324 |
|
---|
| 325 | //大文字・小文字
|
---|
| 326 | if(pobj_nv->bFindStrBigSmall) SendDlgItemMessage(hwnd,IDC_ISBIGSMALL,BM_SETCHECK,BST_CHECKED,0);
|
---|
| 327 |
|
---|
[80] | 328 | // 単語単位
|
---|
| 329 | if( pobj_nv->isWordUnit ){
|
---|
| 330 | SendDlgItemMessage( hwnd, IDC_ISWORDUNIT, BM_SETCHECK, BST_CHECKED, 0 );
|
---|
| 331 | }
|
---|
| 332 |
|
---|
[3] | 333 | //正規表現
|
---|
| 334 | if(pobj_nv->bRegExp) SendDlgItemMessage(hwnd,IDC_REGEXP,BM_SETCHECK,BST_CHECKED,0);
|
---|
| 335 |
|
---|
| 336 |
|
---|
| 337 | //検索文字列コンボボックスを初期化
|
---|
| 338 | SendDlgItemMessage(hwnd,IDC_FINDSTR,CB_RESETCONTENT,0,0);
|
---|
| 339 | for(i=0;i<MAX_FINDLIST;i++){
|
---|
| 340 | if(pobj_nv->FindStr[i][0]=='\0') break;
|
---|
[763] | 341 | SendDlgItemMessage(hwnd,IDC_FINDSTR,CB_ADDSTRING,0,(LPARAM)pobj_nv->FindStr[i]);
|
---|
[3] | 342 | }
|
---|
| 343 | SendDlgItemMessage(hwnd,IDC_FINDSTR,CB_LIMITTEXT,8192,0);
|
---|
| 344 |
|
---|
| 345 | WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
|
---|
| 346 |
|
---|
| 347 | //選択されている文字列を取得
|
---|
| 348 | TextEdit_GetSel(WndNum,&CharRange);
|
---|
| 349 | pTemp=(char *)HeapAlloc(hHeap,0,CharRange.cpMax-CharRange.cpMin+1);
|
---|
| 350 | memcpy(pTemp,
|
---|
[629] | 351 | MdiInfo[WndNum]->pMdiTextEdit->buffer+CharRange.cpMin,
|
---|
[3] | 352 | CharRange.cpMax-CharRange.cpMin);
|
---|
| 353 | pTemp[CharRange.cpMax-CharRange.cpMin]=0;
|
---|
| 354 |
|
---|
| 355 | if(pTemp[0]) SetDlgItemText(hwnd,IDC_FINDSTR,pTemp);
|
---|
| 356 | else SendDlgItemMessage(hwnd,IDC_FINDSTR,CB_SETCURSEL,0,0);
|
---|
| 357 |
|
---|
| 358 | HeapDefaultFree(pTemp);
|
---|
| 359 |
|
---|
| 360 | //置換文字列コンボボックスを初期化
|
---|
| 361 | SendDlgItemMessage(hwnd,IDC_PERMUTATIONSTR,CB_RESETCONTENT,0,0);
|
---|
| 362 | for(i=0;i<MAX_FINDLIST;i++){
|
---|
| 363 | if(pobj_nv->PermutationStr[i][0]=='\0') break;
|
---|
[763] | 364 | SendDlgItemMessage(hwnd,IDC_PERMUTATIONSTR,CB_ADDSTRING,0,(LPARAM)pobj_nv->PermutationStr[i]);
|
---|
[3] | 365 | }
|
---|
| 366 | SendDlgItemMessage(hwnd,IDC_PERMUTATIONSTR,CB_SETCURSEL,0,0);
|
---|
| 367 | SendDlgItemMessage(hwnd,IDC_PERMUTATIONSTR,CB_LIMITTEXT,8192,0);
|
---|
| 368 |
|
---|
| 369 | SetFocus(GetDlgItem(hwnd,IDC_FINDSTR));
|
---|
[763] | 370 |
|
---|
| 371 | ApplyDialogTexture(hwnd);
|
---|
[3] | 372 | break;
|
---|
| 373 | case WM_COMMAND:
|
---|
| 374 | switch(LOWORD(wParam)){
|
---|
| 375 | case IDC_FIND:
|
---|
| 376 | //大文字・小文字
|
---|
| 377 | if(SendDlgItemMessage(hwnd,IDC_ISBIGSMALL,BM_GETCHECK,0,0)) pobj_nv->bFindStrBigSmall=1;
|
---|
| 378 | else pobj_nv->bFindStrBigSmall=0;
|
---|
| 379 |
|
---|
[80] | 380 | // 単語単位
|
---|
| 381 | pobj_nv->isWordUnit =
|
---|
| 382 | ( SendDlgItemMessage( hwnd, IDC_ISWORDUNIT, BM_GETCHECK, 0, 0 ) != 0 );
|
---|
| 383 |
|
---|
[3] | 384 | //正規表現
|
---|
| 385 | if(SendDlgItemMessage(hwnd,IDC_REGEXP,BM_GETCHECK,0,0)) pobj_nv->bRegExp=1;
|
---|
| 386 | else pobj_nv->bRegExp=0;
|
---|
| 387 |
|
---|
| 388 | GetDlgItemText(hwnd,IDC_FINDSTR,temporary,MAX_PATH);
|
---|
| 389 | if(temporary[0]==0) return 1;
|
---|
| 390 | AddFindData(GetDlgItem(hwnd,IDC_FINDSTR),pobj_nv->FindStr,temporary);
|
---|
| 391 |
|
---|
[80] | 392 | StartSearch(hwnd,temporary,pobj_nv->bFindStrBigSmall, pobj_nv->isWordUnit, 1);
|
---|
[3] | 393 | return 1;
|
---|
| 394 | case IDC_PERMUTATIONNEXT:
|
---|
| 395 | //////////
|
---|
| 396 | // 置換
|
---|
| 397 | //////////
|
---|
| 398 |
|
---|
| 399 | //大文字・小文字
|
---|
| 400 | if(SendDlgItemMessage(hwnd,IDC_ISBIGSMALL,BM_GETCHECK,0,0)) pobj_nv->bFindStrBigSmall=1;
|
---|
| 401 | else pobj_nv->bFindStrBigSmall=0;
|
---|
| 402 |
|
---|
[80] | 403 | // 単語単位
|
---|
| 404 | pobj_nv->isWordUnit =
|
---|
| 405 | ( SendDlgItemMessage( hwnd, IDC_ISWORDUNIT, BM_GETCHECK, 0, 0 ) != 0 );
|
---|
| 406 |
|
---|
[3] | 407 | //正規表現
|
---|
| 408 | if(SendDlgItemMessage(hwnd,IDC_REGEXP,BM_GETCHECK,0,0)) pobj_nv->bRegExp=1;
|
---|
| 409 | else pobj_nv->bRegExp=0;
|
---|
| 410 |
|
---|
| 411 | //検索する文字列を取得
|
---|
| 412 | GetDlgItemText(hwnd,IDC_FINDSTR,temporary,MAX_PATH);
|
---|
| 413 | if(temporary[0]==0) return 1;
|
---|
| 414 | AddFindData(GetDlgItem(hwnd,IDC_FINDSTR),pobj_nv->FindStr,temporary);
|
---|
| 415 |
|
---|
| 416 | //置換する文字列を取得
|
---|
| 417 | GetDlgItemText(hwnd,IDC_PERMUTATIONSTR,temp2,MAX_PATH);
|
---|
| 418 | AddFindData(GetDlgItem(hwnd,IDC_PERMUTATIONSTR),pobj_nv->PermutationStr,temp2);
|
---|
| 419 |
|
---|
| 420 | WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
|
---|
| 421 |
|
---|
| 422 | //選択されている文字列を取得
|
---|
| 423 | TextEdit_GetSel(WndNum,&CharRange);
|
---|
| 424 | pTemp=(char *)HeapAlloc(hHeap,0,CharRange.cpMax-CharRange.cpMin+1);
|
---|
| 425 | memcpy(pTemp,
|
---|
[629] | 426 | MdiInfo[WndNum]->pMdiTextEdit->buffer+CharRange.cpMin,
|
---|
[3] | 427 | CharRange.cpMax-CharRange.cpMin);
|
---|
| 428 | pTemp[CharRange.cpMax-CharRange.cpMin]=0;
|
---|
| 429 |
|
---|
| 430 | int length;
|
---|
[80] | 431 | i=(int)CompareSuper(hwnd,pTemp,temporary,pobj_nv->bFindStrBigSmall, pobj_nv->isWordUnit, pobj_nv->bRegExp,&length);
|
---|
[3] | 432 | if(i==-1){
|
---|
| 433 | HeapDefaultFree(pTemp);
|
---|
| 434 | return 1;
|
---|
| 435 | }
|
---|
| 436 |
|
---|
| 437 | if(i){
|
---|
| 438 | if(pobj_nv->bRegExp){
|
---|
| 439 | char *pTempPermu;
|
---|
| 440 |
|
---|
| 441 | //正規表現の結果文字列を取得(置換後用の文字列を取得)
|
---|
| 442 | pTempPermu=obj_RegExp.GetPermuStr(hwnd,pTemp,temporary,temp2,pobj_nv->bFindStrBigSmall);
|
---|
| 443 | if(pTempPermu==(char *)-1||pTempPermu==0){
|
---|
| 444 | HeapDefaultFree(pTemp);
|
---|
| 445 | return 1;
|
---|
| 446 | }
|
---|
| 447 |
|
---|
| 448 | //置換する
|
---|
| 449 | TextEdit_ReplaceUpdateUndoData(WndNum,pTempPermu,0,1);
|
---|
| 450 |
|
---|
| 451 | HeapDefaultFree(pTempPermu);
|
---|
| 452 | }
|
---|
| 453 | else{
|
---|
| 454 | //置換する
|
---|
| 455 | TextEdit_ReplaceUpdateUndoData(WndNum,temp2,0,1);
|
---|
| 456 | }
|
---|
| 457 | }
|
---|
| 458 | HeapDefaultFree(pTemp);
|
---|
| 459 |
|
---|
| 460 | //次を検索
|
---|
| 461 | SendMessage(hwnd,WM_COMMAND,IDC_FIND,0);
|
---|
| 462 |
|
---|
| 463 | return 1;
|
---|
| 464 | case IDC_PERMUTATIONALL:
|
---|
| 465 | //////////////
|
---|
| 466 | // すべて置換
|
---|
| 467 | //////////////
|
---|
| 468 |
|
---|
| 469 | //大文字・小文字
|
---|
| 470 | if(SendDlgItemMessage(hwnd,IDC_ISBIGSMALL,BM_GETCHECK,0,0)) pobj_nv->bFindStrBigSmall=1;
|
---|
| 471 | else pobj_nv->bFindStrBigSmall=0;
|
---|
| 472 |
|
---|
[80] | 473 | // 単語単位
|
---|
| 474 | pobj_nv->isWordUnit =
|
---|
| 475 | ( SendDlgItemMessage( hwnd, IDC_ISWORDUNIT, BM_GETCHECK, 0, 0 ) != 0 );
|
---|
| 476 |
|
---|
[3] | 477 | //正規表現
|
---|
| 478 | if(SendDlgItemMessage(hwnd,IDC_REGEXP,BM_GETCHECK,0,0)) pobj_nv->bRegExp=1;
|
---|
| 479 | else pobj_nv->bRegExp=0;
|
---|
| 480 |
|
---|
| 481 | //検索する文字列を取得
|
---|
| 482 | GetDlgItemText(hwnd,IDC_FINDSTR,temporary,MAX_PATH);
|
---|
| 483 | if(temporary[0]==0) return 1;
|
---|
| 484 | AddFindData(GetDlgItem(hwnd,IDC_FINDSTR),pobj_nv->FindStr,temporary);
|
---|
| 485 |
|
---|
| 486 | //置換する文字列を取得
|
---|
| 487 | GetDlgItemText(hwnd,IDC_PERMUTATIONSTR,temp2,MAX_PATH);
|
---|
| 488 | AddFindData(GetDlgItem(hwnd,IDC_PERMUTATIONSTR),pobj_nv->PermutationStr,temp2);
|
---|
| 489 |
|
---|
| 490 | //正規表現
|
---|
| 491 | if(SendDlgItemMessage(hwnd,IDC_REGEXP,BM_GETCHECK,0,0)) pobj_nv->bRegExp=1;
|
---|
| 492 | else pobj_nv->bRegExp=0;
|
---|
| 493 |
|
---|
| 494 | WndNum=GetWndNum(GetWindow(hClient,GW_CHILD));
|
---|
| 495 |
|
---|
| 496 | TextEdit_SetSel(WndNum,0,0,TRUE);
|
---|
| 497 |
|
---|
[80] | 498 | while(StartSearch(hwnd,temporary,pobj_nv->bFindStrBigSmall, pobj_nv->isWordUnit, 0)){
|
---|
[3] | 499 | if(pobj_nv->bRegExp){
|
---|
| 500 | //選択されている文字列を取得
|
---|
| 501 | TextEdit_GetSel(WndNum,&CharRange);
|
---|
| 502 | pTemp=(char *)HeapAlloc(hHeap,0,CharRange.cpMax-CharRange.cpMin+1);
|
---|
| 503 | memcpy(pTemp,
|
---|
[629] | 504 | MdiInfo[WndNum]->pMdiTextEdit->buffer+CharRange.cpMin,
|
---|
[3] | 505 | CharRange.cpMax-CharRange.cpMin);
|
---|
| 506 | pTemp[CharRange.cpMax-CharRange.cpMin]=0;
|
---|
| 507 |
|
---|
| 508 | char *pTempPermu;
|
---|
| 509 |
|
---|
| 510 | //正規表現の結果文字列を取得(置換後用の文字列を取得)
|
---|
| 511 | pTempPermu=obj_RegExp.GetPermuStr(hwnd,pTemp,temporary,temp2,pobj_nv->bFindStrBigSmall);
|
---|
| 512 | if(pTempPermu==(char *)-1||pTempPermu==0){
|
---|
| 513 | HeapDefaultFree(pTemp);
|
---|
| 514 | return 1;
|
---|
| 515 | }
|
---|
| 516 |
|
---|
| 517 | //置換する
|
---|
| 518 | TextEdit_ReplaceUpdateUndoData(WndNum,pTempPermu,0,1);
|
---|
| 519 |
|
---|
| 520 | HeapDefaultFree(pTempPermu);
|
---|
| 521 | HeapDefaultFree(pTemp);
|
---|
| 522 | }
|
---|
| 523 | else{
|
---|
| 524 | //置換する
|
---|
| 525 | TextEdit_ReplaceUpdateUndoData(WndNum,temp2,0,1);
|
---|
| 526 | }
|
---|
| 527 | }
|
---|
| 528 |
|
---|
| 529 | return 1;
|
---|
| 530 | case IDCANCEL:
|
---|
| 531 | EndDialog(hwnd,0);
|
---|
| 532 | return 1;
|
---|
| 533 | }
|
---|
| 534 | break;
|
---|
| 535 | }
|
---|
| 536 | return 0;
|
---|
| 537 | }
|
---|