Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
31376006
Commit
31376006
authored
Apr 25, 2009
by
Rico Schüller
Committed by
Alexandre Julliard
Apr 27, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notepad: Implement replace.
parent
4d4819d8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
107 additions
and
0 deletions
+107
-0
De.rc
programs/notepad/De.rc
+1
-0
En.rc
programs/notepad/En.rc
+1
-0
dialog.c
programs/notepad/dialog.c
+19
-0
dialog.h
programs/notepad/dialog.h
+1
-0
main.c
programs/notepad/main.c
+82
-0
main.h
programs/notepad/main.h
+1
-0
notepad_res.h
programs/notepad/notepad_res.h
+1
-0
rsrc.rc
programs/notepad/rsrc.rc
+1
-0
No files found.
programs/notepad/De.rc
View file @
31376006
...
...
@@ -53,6 +53,7 @@ POPUP "&Bearbeiten" {
POPUP "&Suchen" {
MENUITEM "Suchen...\tStrg+F", CMD_SEARCH
MENUITEM "&Weitersuchen\tF3", CMD_SEARCH_NEXT
MENUITEM "&Ersetzen...\tStrg+H", CMD_REPLACE
}
POPUP "&Hilfe" {
MENUITEM "&Inhalt", CMD_HELP_CONTENTS
...
...
programs/notepad/En.rc
View file @
31376006
...
...
@@ -53,6 +53,7 @@ POPUP "&Edit" {
POPUP "&Search" {
MENUITEM "&Search...\tCtrl+F", CMD_SEARCH
MENUITEM "&Search next\tF3", CMD_SEARCH_NEXT
MENUITEM "&Replace...\tCtrl+H", CMD_REPLACE
}
POPUP "&Help" {
MENUITEM "&Contents", CMD_HELP_CONTENTS
...
...
programs/notepad/dialog.c
View file @
31376006
...
...
@@ -747,6 +747,25 @@ VOID DIALOG_SearchNext(VOID)
NOTEPAD_DoFind
(
&
Globals
.
lastFind
);
}
VOID
DIALOG_Replace
(
VOID
)
{
ZeroMemory
(
&
Globals
.
find
,
sizeof
(
Globals
.
find
));
Globals
.
find
.
lStructSize
=
sizeof
(
Globals
.
find
);
Globals
.
find
.
hwndOwner
=
Globals
.
hMainWnd
;
Globals
.
find
.
hInstance
=
Globals
.
hInstance
;
Globals
.
find
.
lpstrFindWhat
=
Globals
.
szFindText
;
Globals
.
find
.
wFindWhatLen
=
SIZEOF
(
Globals
.
szFindText
);
Globals
.
find
.
lpstrReplaceWith
=
Globals
.
szReplaceText
;
Globals
.
find
.
wReplaceWithLen
=
SIZEOF
(
Globals
.
szReplaceText
);
Globals
.
find
.
Flags
=
FR_DOWN
|
FR_HIDEWHOLEWORD
;
/* We only need to create the modal FindReplace dialog which will */
/* notify us of incoming events using hMainWnd Window Messages */
Globals
.
hFindReplaceDlg
=
ReplaceText
(
&
Globals
.
find
);
assert
(
Globals
.
hFindReplaceDlg
!=
0
);
}
VOID
DIALOG_HelpContents
(
VOID
)
{
WinHelp
(
Globals
.
hMainWnd
,
helpfileW
,
HELP_INDEX
,
0
);
...
...
programs/notepad/dialog.h
View file @
31376006
...
...
@@ -38,6 +38,7 @@ VOID DIALOG_EditWrap(VOID);
VOID
DIALOG_Search
(
VOID
);
VOID
DIALOG_SearchNext
(
VOID
);
VOID
DIALOG_Replace
(
VOID
);
VOID
DIALOG_SelectFont
(
VOID
);
...
...
programs/notepad/main.c
View file @
31376006
...
...
@@ -294,6 +294,7 @@ static int NOTEPAD_MenuCommand(WPARAM wParam)
case
CMD_SEARCH
:
DIALOG_Search
();
break
;
case
CMD_SEARCH_NEXT
:
DIALOG_SearchNext
();
break
;
case
CMD_REPLACE
:
DIALOG_Replace
();
break
;
case
CMD_WRAP
:
DIALOG_EditWrap
();
break
;
case
CMD_FONT
:
DIALOG_SelectFont
();
break
;
...
...
@@ -414,6 +415,77 @@ void NOTEPAD_DoFind(FINDREPLACE *fr)
SendMessage
(
Globals
.
hEdit
,
EM_SETSEL
,
found
-
content
,
found
-
content
+
len
);
}
void
NOTEPAD_DoReplace
(
FINDREPLACE
*
fr
)
{
LPTSTR
content
;
int
len
=
lstrlen
(
fr
->
lpstrFindWhat
);
int
fileLen
;
DWORD
pos
;
DWORD
pos_start
;
fileLen
=
GetWindowTextLength
(
Globals
.
hEdit
)
+
1
;
content
=
HeapAlloc
(
GetProcessHeap
(),
0
,
fileLen
*
sizeof
(
TCHAR
));
if
(
!
content
)
return
;
GetWindowText
(
Globals
.
hEdit
,
content
,
fileLen
);
SendMessage
(
Globals
.
hEdit
,
EM_GETSEL
,
(
WPARAM
)
&
pos_start
,
(
LPARAM
)
&
pos
);
switch
(
fr
->
Flags
&
(
FR_DOWN
|
FR_MATCHCASE
))
{
case
FR_DOWN
:
if
(
pos
-
pos_start
==
len
&&
StrCmpNI
(
fr
->
lpstrFindWhat
,
content
+
pos_start
,
len
)
==
0
)
SendMessage
(
Globals
.
hEdit
,
EM_REPLACESEL
,
TRUE
,
(
LPARAM
)
fr
->
lpstrReplaceWith
);
break
;
case
FR_DOWN
|
FR_MATCHCASE
:
if
(
pos
-
pos_start
==
len
&&
StrCmpN
(
fr
->
lpstrFindWhat
,
content
+
pos_start
,
len
)
==
0
)
SendMessage
(
Globals
.
hEdit
,
EM_REPLACESEL
,
TRUE
,
(
LPARAM
)
fr
->
lpstrReplaceWith
);
break
;
default:
/* shouldn't happen */
return
;
}
HeapFree
(
GetProcessHeap
(),
0
,
content
);
NOTEPAD_DoFind
(
fr
);
}
void
NOTEPAD_DoReplaceAll
(
FINDREPLACE
*
fr
)
{
LPTSTR
content
;
LPTSTR
found
;
int
len
=
lstrlen
(
fr
->
lpstrFindWhat
);
int
fileLen
;
DWORD
pos
;
SendMessage
(
Globals
.
hEdit
,
EM_SETSEL
,
0
,
0
);
while
(
TRUE
){
fileLen
=
GetWindowTextLength
(
Globals
.
hEdit
)
+
1
;
content
=
HeapAlloc
(
GetProcessHeap
(),
0
,
fileLen
*
sizeof
(
TCHAR
));
if
(
!
content
)
return
;
GetWindowText
(
Globals
.
hEdit
,
content
,
fileLen
);
SendMessage
(
Globals
.
hEdit
,
EM_GETSEL
,
0
,
(
LPARAM
)
&
pos
);
switch
(
fr
->
Flags
&
(
FR_DOWN
|
FR_MATCHCASE
))
{
case
FR_DOWN
:
found
=
StrStrI
(
content
+
pos
,
fr
->
lpstrFindWhat
);
break
;
case
FR_DOWN
|
FR_MATCHCASE
:
found
=
StrStr
(
content
+
pos
,
fr
->
lpstrFindWhat
);
break
;
default:
/* shouldn't happen */
return
;
}
HeapFree
(
GetProcessHeap
(),
0
,
content
);
if
(
found
==
NULL
)
{
SendMessage
(
Globals
.
hEdit
,
EM_SETSEL
,
0
,
0
);
return
;
}
SendMessage
(
Globals
.
hEdit
,
EM_SETSEL
,
found
-
content
,
found
-
content
+
len
);
SendMessage
(
Globals
.
hEdit
,
EM_REPLACESEL
,
TRUE
,
(
LPARAM
)
fr
->
lpstrReplaceWith
);
}
}
/***********************************************************************
*
* NOTEPAD_WndProc
...
...
@@ -432,6 +504,16 @@ static LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam,
Globals
.
lastFind
=
*
fr
;
NOTEPAD_DoFind
(
fr
);
}
if
(
fr
->
Flags
&
FR_REPLACE
)
{
Globals
.
lastFind
=
*
fr
;
NOTEPAD_DoReplace
(
fr
);
}
if
(
fr
->
Flags
&
FR_REPLACEALL
)
{
Globals
.
lastFind
=
*
fr
;
NOTEPAD_DoReplaceAll
(
fr
);
}
return
0
;
}
...
...
programs/notepad/main.h
View file @
31376006
...
...
@@ -35,6 +35,7 @@ typedef struct
LOGFONT
lfFont
;
BOOL
bWrapLongLines
;
WCHAR
szFindText
[
MAX_PATH
];
WCHAR
szReplaceText
[
MAX_PATH
];
WCHAR
szFileName
[
MAX_PATH
];
WCHAR
szFileTitle
[
MAX_PATH
];
WCHAR
szFilter
[
2
*
MAX_STRING_LEN
+
100
];
...
...
programs/notepad/notepad_res.h
View file @
31376006
...
...
@@ -45,6 +45,7 @@
#define CMD_SEARCH 0x120
#define CMD_SEARCH_NEXT 0x121
#define CMD_REPLACE 0x122
#define CMD_WRAP 0x119
#define CMD_FONT 0x140
...
...
programs/notepad/rsrc.rc
View file @
31376006
...
...
@@ -30,6 +30,7 @@ ID_ACCEL ACCELERATORS
"^A", CMD_SELECT_ALL
"^C", CMD_COPY
"^F", CMD_SEARCH
"H", CMD_REPLACE, VIRTKEY, CONTROL
"^N", CMD_NEW
"^O", CMD_OPEN
"^P", CMD_PRINT
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment