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
84fc75c3
Commit
84fc75c3
authored
Oct 22, 2006
by
Mikołaj Zalewski
Committed by
Alexandre Julliard
Oct 23, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notepad: Implement Find and Find Next.
parent
b0905acb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
82 additions
and
4 deletions
+82
-4
dialog.c
programs/notepad/dialog.c
+5
-3
main.c
programs/notepad/main.c
+75
-1
main.h
programs/notepad/main.h
+2
-0
No files found.
programs/notepad/dialog.c
View file @
84fc75c3
...
...
@@ -663,7 +663,7 @@ VOID DIALOG_Search(VOID)
Globals
.
find
.
hInstance
=
Globals
.
hInstance
;
Globals
.
find
.
lpstrFindWhat
=
Globals
.
szFindText
;
Globals
.
find
.
wFindWhatLen
=
SIZEOF
(
Globals
.
szFindText
);
Globals
.
find
.
Flags
=
FR_DOWN
;
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 */
...
...
@@ -674,8 +674,10 @@ VOID DIALOG_Search(VOID)
VOID
DIALOG_SearchNext
(
VOID
)
{
/* FIXME: Search Next */
DIALOG_Search
();
if
(
Globals
.
lastFind
.
lpstrFindWhat
==
NULL
)
DIALOG_Search
();
else
/* use the last find data */
NOTEPAD_DoFind
(
&
Globals
.
lastFind
);
}
VOID
DIALOG_HelpContents
(
VOID
)
...
...
programs/notepad/main.c
View file @
84fc75c3
...
...
@@ -25,6 +25,7 @@
#define UNICODE
#include <windows.h>
#include <shlwapi.h>
#include <stdio.h>
#include "main.h"
...
...
@@ -314,6 +315,65 @@ static VOID NOTEPAD_InitMenuPopup(HMENU menu, int index)
GetWindowTextLength
(
Globals
.
hEdit
)
?
MF_ENABLED
:
MF_GRAYED
);
}
static
LPTSTR
NOTEPAD_StrRStr
(
LPTSTR
pszSource
,
LPTSTR
pszLast
,
LPTSTR
pszSrch
)
{
int
len
=
lstrlen
(
pszSrch
);
pszLast
--
;
while
(
pszLast
>=
pszSource
)
{
if
(
StrCmpN
(
pszLast
,
pszSrch
,
len
)
==
0
)
return
pszLast
;
pszLast
--
;
}
return
NULL
;
}
/***********************************************************************
* The user activated the Find dialog
*/
void
NOTEPAD_DoFind
(
FINDREPLACE
*
fr
)
{
LPTSTR
content
;
LPTSTR
found
;
int
len
=
lstrlen
(
fr
->
lpstrFindWhat
);
int
fileLen
;
DWORD
pos
;
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
0
:
found
=
StrRStrI
(
content
,
content
+
pos
-
len
,
fr
->
lpstrFindWhat
);
break
;
case
FR_DOWN
:
found
=
StrStrI
(
content
+
pos
,
fr
->
lpstrFindWhat
);
break
;
case
FR_MATCHCASE
:
found
=
NOTEPAD_StrRStr
(
content
,
content
+
pos
-
len
,
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
)
{
DIALOG_StringMsgBox
(
Globals
.
hFindReplaceDlg
,
STRING_NOTFOUND
,
fr
->
lpstrFindWhat
,
MB_ICONINFORMATION
|
MB_OK
);
return
;
}
SendMessage
(
Globals
.
hEdit
,
EM_SETSEL
,
found
-
content
,
found
-
content
+
len
);
}
/***********************************************************************
*
* NOTEPAD_WndProc
...
...
@@ -321,13 +381,27 @@ static VOID NOTEPAD_InitMenuPopup(HMENU menu, int index)
static
LRESULT
WINAPI
NOTEPAD_WndProc
(
HWND
hWnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
if
(
msg
==
aFINDMSGSTRING
)
/* not a constant so can't be used in switch */
{
FINDREPLACE
*
fr
=
(
FINDREPLACE
*
)
lParam
;
if
(
fr
->
Flags
&
FR_DIALOGTERM
)
Globals
.
hFindReplaceDlg
=
NULL
;
if
(
fr
->
Flags
&
FR_FINDNEXT
)
{
Globals
.
lastFind
=
*
fr
;
NOTEPAD_DoFind
(
fr
);
}
return
0
;
}
switch
(
msg
)
{
case
WM_CREATE
:
{
static
const
WCHAR
editW
[]
=
{
'e'
,
'd'
,
'i'
,
't'
,
0
};
DWORD
dwStyle
=
WS_CHILD
|
WS_VISIBLE
|
WS_BORDER
|
WS_VSCROLL
|
ES_AUTOVSCROLL
|
ES_MULTILINE
;
ES_AUTOVSCROLL
|
ES_MULTILINE
|
ES_NOHIDESEL
;
RECT
rc
;
GetClientRect
(
hWnd
,
&
rc
);
...
...
programs/notepad/main.h
View file @
84fc75c3
...
...
@@ -51,6 +51,7 @@ typedef struct
INT
iWindowPosDY
;
FINDREPLACE
find
;
FINDREPLACE
lastFind
;
HGLOBAL
hDevMode
;
/* printer mode */
HGLOBAL
hDevNames
;
/* printer names */
}
NOTEPAD_GLOBALS
;
...
...
@@ -58,3 +59,4 @@ typedef struct
extern
NOTEPAD_GLOBALS
Globals
;
VOID
SetFileName
(
LPCWSTR
szFileName
);
void
NOTEPAD_DoFind
(
FINDREPLACE
*
fr
);
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