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