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
02228ee1
Commit
02228ee1
authored
Aug 13, 2009
by
Dylan Smith
Committed by
Alexandre Julliard
Aug 13, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
richedit: Use ME_Cursor instead of offsets for ME_CharFromPos.
parent
a69ef265
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
22 deletions
+28
-22
caret.c
dlls/riched20/caret.c
+9
-7
editor.c
dlls/riched20/editor.c
+18
-14
editor.h
dlls/riched20/editor.h
+1
-1
No files found.
dlls/riched20/caret.c
View file @
02228ee1
...
@@ -1004,30 +1004,32 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y,
...
@@ -1004,30 +1004,32 @@ static BOOL ME_FindPixelPos(ME_TextEditor *editor, int x, int y,
}
}
/*
Returns the character offset
closest to the pixel position
/*
Sets the cursor to the position
closest to the pixel position
*
*
* x & y are pixel positions in client coordinates.
* x & y are pixel positions in client coordinates.
*
*
* isExact will be set to TRUE if the run is directly under the pixel
* isExact will be set to TRUE if the run is directly under the pixel
* position, FALSE if it not, unless isExact is set to NULL.
* position, FALSE if it not, unless isExact is set to NULL.
*
* return FALSE if outside client area and the cursor is not set,
* otherwise TRUE is returned.
*/
*/
int
ME_CharFromPos
(
ME_TextEditor
*
editor
,
int
x
,
int
y
,
BOOL
*
isExact
)
BOOL
ME_CharFromPos
(
ME_TextEditor
*
editor
,
int
x
,
int
y
,
ME_Cursor
*
cursor
,
BOOL
*
isExact
)
{
{
ME_Cursor
cursor
;
RECT
rc
;
RECT
rc
;
BOOL
bResult
;
BOOL
bResult
;
ITextHost_TxGetClientRect
(
editor
->
texthost
,
&
rc
);
ITextHost_TxGetClientRect
(
editor
->
texthost
,
&
rc
);
if
(
x
<
0
||
y
<
0
||
x
>=
rc
.
right
||
y
>=
rc
.
bottom
)
{
if
(
x
<
0
||
y
<
0
||
x
>=
rc
.
right
||
y
>=
rc
.
bottom
)
{
if
(
isExact
)
*
isExact
=
FALSE
;
if
(
isExact
)
*
isExact
=
FALSE
;
return
-
1
;
return
FALSE
;
}
}
x
+=
editor
->
horz_si
.
nPos
;
x
+=
editor
->
horz_si
.
nPos
;
y
+=
editor
->
vert_si
.
nPos
;
y
+=
editor
->
vert_si
.
nPos
;
bResult
=
ME_FindPixelPos
(
editor
,
x
,
y
,
&
cursor
,
NULL
);
bResult
=
ME_FindPixelPos
(
editor
,
x
,
y
,
cursor
,
NULL
);
if
(
isExact
)
*
isExact
=
bResult
;
if
(
isExact
)
*
isExact
=
bResult
;
return
cursor
.
pPara
->
member
.
para
.
nCharOfs
return
TRUE
;
+
cursor
.
pRun
->
member
.
run
.
nCharOfs
+
cursor
.
nOffset
;
}
}
...
...
dlls/riched20/editor.c
View file @
02228ee1
...
@@ -2476,9 +2476,9 @@ static int ME_CalculateClickCount(ME_TextEditor *editor, UINT msg, WPARAM wParam
...
@@ -2476,9 +2476,9 @@ static int ME_CalculateClickCount(ME_TextEditor *editor, UINT msg, WPARAM wParam
static
BOOL
ME_SetCursor
(
ME_TextEditor
*
editor
)
static
BOOL
ME_SetCursor
(
ME_TextEditor
*
editor
)
{
{
ME_Cursor
cursor
;
POINT
pt
;
POINT
pt
;
BOOL
isExact
;
BOOL
isExact
;
int
offset
;
SCROLLBARINFO
sbi
;
SCROLLBARINFO
sbi
;
DWORD
messagePos
=
GetMessagePos
();
DWORD
messagePos
=
GetMessagePos
();
pt
.
x
=
(
short
)
LOWORD
(
messagePos
);
pt
.
x
=
(
short
)
LOWORD
(
messagePos
);
...
@@ -2533,13 +2533,11 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
...
@@ -2533,13 +2533,11 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
ITextHost_TxSetCursor
(
editor
->
texthost
,
hLeft
,
FALSE
);
ITextHost_TxSetCursor
(
editor
->
texthost
,
hLeft
,
FALSE
);
return
TRUE
;
return
TRUE
;
}
}
offset
=
ME_CharFromPos
(
editor
,
pt
.
x
,
pt
.
y
,
&
isExact
);
ME_CharFromPos
(
editor
,
pt
.
x
,
pt
.
y
,
&
cursor
,
&
isExact
);
if
(
isExact
)
if
(
isExact
)
{
{
ME_Cursor
cursor
;
ME_Run
*
run
;
ME_Run
*
run
;
ME_CursorFromCharOfs
(
editor
,
offset
,
&
cursor
);
run
=
&
cursor
.
pRun
->
member
.
run
;
run
=
&
cursor
.
pRun
->
member
.
run
;
if
(
run
->
style
->
fmt
.
dwMask
&
CFM_LINK
&&
if
(
run
->
style
->
fmt
.
dwMask
&
CFM_LINK
&&
run
->
style
->
fmt
.
dwEffects
&
CFE_LINK
)
run
->
style
->
fmt
.
dwEffects
&
CFE_LINK
)
...
@@ -2553,6 +2551,7 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
...
@@ -2553,6 +2551,7 @@ static BOOL ME_SetCursor(ME_TextEditor *editor)
if
(
ME_IsSelection
(
editor
))
if
(
ME_IsSelection
(
editor
))
{
{
int
selStart
,
selEnd
;
int
selStart
,
selEnd
;
int
offset
=
ME_GetCursorOfs
(
&
cursor
);
ME_GetSelectionOfs
(
editor
,
&
selStart
,
&
selEnd
);
ME_GetSelectionOfs
(
editor
,
&
selStart
,
&
selEnd
);
if
(
selStart
<=
offset
&&
selEnd
>=
offset
)
{
if
(
selStart
<=
offset
&&
selEnd
>=
offset
)
{
...
@@ -2926,20 +2925,17 @@ get_msg_name(UINT msg)
...
@@ -2926,20 +2925,17 @@ get_msg_name(UINT msg)
static
void
ME_LinkNotify
(
ME_TextEditor
*
editor
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
static
void
ME_LinkNotify
(
ME_TextEditor
*
editor
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
{
int
x
,
y
;
int
x
,
y
;
ME_DisplayItem
*
para
,
*
run
;
BOOL
isExact
;
BOOL
isExact
;
int
nCharOfs
;
/* The start of the clicked text. Absolute character offset
*/
ME_Cursor
cursor
;
/* The start of the clicked text.
*/
ENLINK
info
;
ENLINK
info
;
x
=
(
short
)
LOWORD
(
lParam
);
x
=
(
short
)
LOWORD
(
lParam
);
y
=
(
short
)
HIWORD
(
lParam
);
y
=
(
short
)
HIWORD
(
lParam
);
nCharOfs
=
ME_CharFromPos
(
editor
,
x
,
y
,
&
isExact
);
ME_CharFromPos
(
editor
,
x
,
y
,
&
cursor
,
&
isExact
);
if
(
!
isExact
)
return
;
if
(
!
isExact
)
return
;
ME_RunOfsFromCharOfs
(
editor
,
nCharOfs
,
&
para
,
&
run
,
NULL
);
if
(
cursor
.
pRun
->
member
.
run
.
style
->
fmt
.
dwMask
&
CFM_LINK
&&
cursor
.
pRun
->
member
.
run
.
style
->
fmt
.
dwEffects
&
CFE_LINK
)
if
((
run
->
member
.
run
.
style
->
fmt
.
dwMask
&
CFM_LINK
)
&&
(
run
->
member
.
run
.
style
->
fmt
.
dwEffects
&
CFE_LINK
))
{
/* The clicked run has CFE_LINK set */
{
/* The clicked run has CFE_LINK set */
info
.
nmhdr
.
hwndFrom
=
editor
->
hWnd
;
info
.
nmhdr
.
hwndFrom
=
editor
->
hWnd
;
info
.
nmhdr
.
idFrom
=
GetWindowLongW
(
editor
->
hWnd
,
GWLP_ID
);
info
.
nmhdr
.
idFrom
=
GetWindowLongW
(
editor
->
hWnd
,
GWLP_ID
);
...
@@ -2947,8 +2943,9 @@ static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM
...
@@ -2947,8 +2943,9 @@ static void ME_LinkNotify(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM
info
.
msg
=
msg
;
info
.
msg
=
msg
;
info
.
wParam
=
wParam
;
info
.
wParam
=
wParam
;
info
.
lParam
=
lParam
;
info
.
lParam
=
lParam
;
info
.
chrg
.
cpMin
=
ME_CharOfsFromRunOfs
(
editor
,
para
,
run
,
0
);
cursor
.
nOffset
=
0
;
info
.
chrg
.
cpMax
=
info
.
chrg
.
cpMin
+
run
->
member
.
run
.
strText
->
nLen
;
info
.
chrg
.
cpMin
=
ME_GetCursorOfs
(
&
cursor
);
info
.
chrg
.
cpMax
=
info
.
chrg
.
cpMin
+
cursor
.
pRun
->
member
.
run
.
strText
->
nLen
;
SendMessageW
(
GetParent
(
editor
->
hWnd
),
WM_NOTIFY
,
info
.
nmhdr
.
idFrom
,
(
LPARAM
)
&
info
);
SendMessageW
(
GetParent
(
editor
->
hWnd
),
WM_NOTIFY
,
info
.
nmhdr
.
idFrom
,
(
LPARAM
)
&
info
);
}
}
}
}
...
@@ -3824,7 +3821,14 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
...
@@ -3824,7 +3821,14 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
case
EM_SETZOOM
:
case
EM_SETZOOM
:
return
ME_SetZoom
(
editor
,
wParam
,
lParam
);
return
ME_SetZoom
(
editor
,
wParam
,
lParam
);
case
EM_CHARFROMPOS
:
case
EM_CHARFROMPOS
:
return
ME_CharFromPos
(
editor
,
((
POINTL
*
)
lParam
)
->
x
,
((
POINTL
*
)
lParam
)
->
y
,
NULL
);
{
ME_Cursor
cursor
;
if
(
ME_CharFromPos
(
editor
,
((
POINTL
*
)
lParam
)
->
x
,
((
POINTL
*
)
lParam
)
->
y
,
&
cursor
,
NULL
))
return
ME_GetCursorOfs
(
&
cursor
);
else
return
-
1
;
}
case
EM_POSFROMCHAR
:
case
EM_POSFROMCHAR
:
{
{
ME_DisplayItem
*
pPara
,
*
pRun
;
ME_DisplayItem
*
pPara
,
*
pRun
;
...
...
dlls/riched20/editor.h
View file @
02228ee1
...
@@ -162,7 +162,7 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to);
...
@@ -162,7 +162,7 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to);
void
ME_HideCaret
(
ME_TextEditor
*
ed
);
void
ME_HideCaret
(
ME_TextEditor
*
ed
);
void
ME_ShowCaret
(
ME_TextEditor
*
ed
);
void
ME_ShowCaret
(
ME_TextEditor
*
ed
);
void
ME_MoveCaret
(
ME_TextEditor
*
ed
);
void
ME_MoveCaret
(
ME_TextEditor
*
ed
);
int
ME_CharFromPos
(
ME_TextEditor
*
editor
,
int
x
,
int
y
,
BOOL
*
isExact
);
BOOL
ME_CharFromPos
(
ME_TextEditor
*
editor
,
int
x
,
int
y
,
ME_Cursor
*
cursor
,
BOOL
*
isExact
);
void
ME_LButtonDown
(
ME_TextEditor
*
editor
,
int
x
,
int
y
,
int
clickNum
);
void
ME_LButtonDown
(
ME_TextEditor
*
editor
,
int
x
,
int
y
,
int
clickNum
);
void
ME_MouseMove
(
ME_TextEditor
*
editor
,
int
x
,
int
y
);
void
ME_MouseMove
(
ME_TextEditor
*
editor
,
int
x
,
int
y
);
BOOL
ME_DeleteTextAtCursor
(
ME_TextEditor
*
editor
,
int
nCursor
,
int
nChars
);
BOOL
ME_DeleteTextAtCursor
(
ME_TextEditor
*
editor
,
int
nCursor
,
int
nChars
);
...
...
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