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