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