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
2bc72693
Commit
2bc72693
authored
Aug 12, 2009
by
Dylan Smith
Committed by
Alexandre Julliard
Aug 12, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
richedit: Add helpers for setting cursor to start/end of text.
parent
32dcd3bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
36 deletions
+32
-36
caret.c
dlls/riched20/caret.c
+27
-31
editor.c
dlls/riched20/editor.c
+3
-5
editor.h
dlls/riched20/editor.h
+2
-0
No files found.
dlls/riched20/caret.c
View file @
2bc72693
...
...
@@ -27,6 +27,21 @@ WINE_DEFAULT_DEBUG_CHANNEL(richedit);
static
BOOL
ME_MoveCursorChars
(
ME_TextEditor
*
editor
,
ME_Cursor
*
pCursor
,
int
nRelOfs
);
void
ME_SetCursorToStart
(
ME_TextEditor
*
editor
,
ME_Cursor
*
cursor
)
{
cursor
->
pPara
=
editor
->
pBuffer
->
pFirst
->
member
.
para
.
next_para
;
cursor
->
pRun
=
ME_FindItemFwd
(
cursor
->
pPara
,
diRun
);
cursor
->
nOffset
=
0
;
}
void
ME_SetCursorToEnd
(
ME_TextEditor
*
editor
,
ME_Cursor
*
cursor
)
{
cursor
->
pPara
=
editor
->
pBuffer
->
pLast
->
member
.
para
.
prev_para
;
cursor
->
pRun
=
ME_FindItemBack
(
editor
->
pBuffer
->
pLast
,
diRun
);
cursor
->
nOffset
=
0
;
}
int
ME_GetSelectionOfs
(
ME_TextEditor
*
editor
,
int
*
from
,
int
*
to
)
{
*
from
=
ME_GetCursorOfs
(
&
editor
->
pCursors
[
0
]);
...
...
@@ -58,9 +73,9 @@ int ME_GetSelection(ME_TextEditor *editor, ME_Cursor **from, ME_Cursor **to)
int
ME_GetTextLength
(
ME_TextEditor
*
editor
)
{
ME_
DisplayItem
*
pLast
=
editor
->
pBuffer
->
pLast
;
return
ME_CharOfsFromRunOfs
(
editor
,
pLast
->
member
.
para
.
prev_para
,
ME_FindItemBack
(
pLast
,
diRun
),
0
);
ME_
Cursor
cursor
;
ME_SetCursorToEnd
(
editor
,
&
cursor
);
return
ME_GetCursorOfs
(
&
cursor
);
}
...
...
@@ -111,12 +126,8 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
/* select all */
if
(
from
==
0
&&
to
==
-
1
)
{
editor
->
pCursors
[
1
].
pPara
=
editor
->
pBuffer
->
pFirst
->
member
.
para
.
next_para
;
editor
->
pCursors
[
1
].
pRun
=
ME_FindItemFwd
(
editor
->
pCursors
[
1
].
pPara
,
diRun
);
editor
->
pCursors
[
1
].
nOffset
=
0
;
editor
->
pCursors
[
0
].
pPara
=
editor
->
pBuffer
->
pLast
->
member
.
para
.
prev_para
;
editor
->
pCursors
[
0
].
pRun
=
ME_FindItemBack
(
editor
->
pBuffer
->
pLast
,
diRun
);
editor
->
pCursors
[
0
].
nOffset
=
0
;
ME_SetCursorToStart
(
editor
,
&
editor
->
pCursors
[
1
]);
ME_SetCursorToEnd
(
editor
,
&
editor
->
pCursors
[
0
]);
ME_InvalidateSelection
(
editor
);
ME_ClearTempStyle
(
editor
);
return
len
+
1
;
...
...
@@ -164,9 +175,7 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
if
(
selectionEnd
)
{
editor
->
pCursors
[
0
].
pPara
=
editor
->
pBuffer
->
pLast
->
member
.
para
.
prev_para
;
editor
->
pCursors
[
0
].
pRun
=
ME_FindItemBack
(
editor
->
pBuffer
->
pLast
,
diRun
);
editor
->
pCursors
[
0
].
nOffset
=
0
;
ME_SetCursorToEnd
(
editor
,
&
editor
->
pCursors
[
0
]);
editor
->
pCursors
[
1
]
=
editor
->
pCursors
[
0
];
ME_InvalidateSelection
(
editor
);
ME_ClearTempStyle
(
editor
);
...
...
@@ -812,12 +821,8 @@ ME_SelectByType(ME_TextEditor *editor, ME_SelectionType selectionType)
case
stDocument
:
/* Select everything with cursor anchored from the start of the text */
editor
->
nSelectionType
=
stDocument
;
editor
->
pCursors
[
1
].
pPara
=
editor
->
pBuffer
->
pFirst
->
member
.
para
.
next_para
;
editor
->
pCursors
[
1
].
pRun
=
ME_FindItemFwd
(
editor
->
pCursors
[
1
].
pPara
,
diRun
);
editor
->
pCursors
[
1
].
nOffset
=
0
;
editor
->
pCursors
[
0
].
pPara
=
editor
->
pBuffer
->
pLast
->
member
.
para
.
prev_para
;
editor
->
pCursors
[
0
].
pRun
=
ME_FindItemBack
(
editor
->
pBuffer
->
pLast
,
diRun
);
editor
->
pCursors
[
0
].
nOffset
=
0
;
ME_SetCursorToStart
(
editor
,
&
editor
->
pCursors
[
1
]);
ME_SetCursorToEnd
(
editor
,
&
editor
->
pCursors
[
0
]);
break
;
default:
assert
(
0
);
}
...
...
@@ -1331,9 +1336,7 @@ static void ME_ArrowPageUp(ME_TextEditor *editor, ME_Cursor *pCursor)
if
(
editor
->
vert_si
.
nPos
<
p
->
member
.
row
.
nHeight
)
{
pCursor
->
pPara
=
editor
->
pBuffer
->
pFirst
->
member
.
para
.
next_para
;
pCursor
->
pRun
=
ME_FindItemFwd
(
pCursor
->
pPara
,
diRun
);
pCursor
->
nOffset
=
0
;
ME_SetCursorToStart
(
editor
,
pCursor
);
editor
->
bCaretAtEnd
=
FALSE
;
/* Native clears seems to clear this x value on page up at the top
* of the text, but not on page down at the end of the text.
...
...
@@ -1398,9 +1401,7 @@ static void ME_ArrowPageDown(ME_TextEditor *editor, ME_Cursor *pCursor)
if
(
editor
->
vert_si
.
nPos
>=
y
-
editor
->
sizeWindow
.
cy
)
{
pCursor
->
pPara
=
editor
->
pBuffer
->
pLast
->
member
.
para
.
prev_para
;
pCursor
->
pRun
=
ME_FindItemBack
(
editor
->
pBuffer
->
pLast
,
diRun
);
pCursor
->
nOffset
=
0
;
ME_SetCursorToEnd
(
editor
,
pCursor
);
editor
->
bCaretAtEnd
=
FALSE
;
}
else
{
ME_DisplayItem
*
pRun
=
pCursor
->
pRun
;
...
...
@@ -1469,9 +1470,7 @@ static void ME_ArrowHome(ME_TextEditor *editor, ME_Cursor *pCursor)
static
void
ME_ArrowCtrlHome
(
ME_TextEditor
*
editor
,
ME_Cursor
*
pCursor
)
{
pCursor
->
pPara
=
editor
->
pBuffer
->
pFirst
->
member
.
para
.
next_para
;
pCursor
->
pRun
=
ME_FindItemFwd
(
pCursor
->
pPara
,
diRun
);
pCursor
->
nOffset
=
0
;
ME_SetCursorToStart
(
editor
,
pCursor
);
editor
->
bCaretAtEnd
=
FALSE
;
}
...
...
@@ -1502,10 +1501,7 @@ static void ME_ArrowEnd(ME_TextEditor *editor, ME_Cursor *pCursor)
static
void
ME_ArrowCtrlEnd
(
ME_TextEditor
*
editor
,
ME_Cursor
*
pCursor
)
{
pCursor
->
pPara
=
editor
->
pBuffer
->
pLast
->
member
.
para
.
prev_para
;
pCursor
->
pRun
=
ME_FindItemBack
(
editor
->
pBuffer
->
pLast
,
diRun
);
assert
(
pCursor
->
pRun
->
member
.
run
.
nFlags
&
MERF_ENDPARA
);
pCursor
->
nOffset
=
0
;
ME_SetCursorToEnd
(
editor
,
pCursor
);
editor
->
bCaretAtEnd
=
FALSE
;
}
...
...
dlls/riched20/editor.c
View file @
2bc72693
...
...
@@ -1882,7 +1882,7 @@ static int ME_GetTextEx(ME_TextEditor *editor, GETTEXTEX *ex, LPARAM pText)
}
else
{
ME_
CursorFromCharOfs
(
editor
,
0
,
&
start
);
ME_
SetCursorToStart
(
editor
,
&
start
);
nChars
=
INT_MAX
;
}
if
(
ex
->
codepage
==
1200
)
...
...
@@ -2623,9 +2623,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
*/
ed
->
nCursors
=
4
;
ed
->
pCursors
=
ALLOC_N_OBJ
(
ME_Cursor
,
ed
->
nCursors
);
ed
->
pCursors
[
0
].
pPara
=
ed
->
pBuffer
->
pFirst
->
member
.
para
.
next_para
;
ed
->
pCursors
[
0
].
pRun
=
ME_FindItemFwd
(
ed
->
pCursors
[
0
].
pPara
,
diRun
);
ed
->
pCursors
[
0
].
nOffset
=
0
;
ME_SetCursorToStart
(
ed
,
&
ed
->
pCursors
[
0
]);
ed
->
pCursors
[
1
]
=
ed
->
pCursors
[
0
];
ed
->
pCursors
[
2
]
=
ed
->
pCursors
[
0
];
ed
->
pCursors
[
3
]
=
ed
->
pCursors
[
1
];
...
...
@@ -2645,7 +2643,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
ed
->
nUndoMode
=
umAddToUndo
;
ed
->
nParagraphs
=
1
;
ed
->
nLastSelStart
=
ed
->
nLastSelEnd
=
0
;
ed
->
pLastSelStartPara
=
ed
->
pLastSelEndPara
=
ME_FindItemFwd
(
ed
->
pBuffer
->
pFirst
,
diParagraph
)
;
ed
->
pLastSelStartPara
=
ed
->
pLastSelEndPara
=
ed
->
pCursors
[
0
].
pPara
;
ed
->
bHideSelection
=
FALSE
;
ed
->
pfnWordBreak
=
NULL
;
ed
->
lpOleCallback
=
NULL
;
...
...
dlls/riched20/editor.h
View file @
2bc72693
...
...
@@ -155,6 +155,8 @@ void ME_GetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W *pFmt);
void
ME_SetDefaultCharFormat
(
ME_TextEditor
*
editor
,
CHARFORMAT2W
*
mod
);
/* caret.c */
void
ME_SetCursorToStart
(
ME_TextEditor
*
editor
,
ME_Cursor
*
cursor
);
void
ME_SetCursorToEnd
(
ME_TextEditor
*
editor
,
ME_Cursor
*
cursor
);
int
ME_SetSelection
(
ME_TextEditor
*
editor
,
int
from
,
int
to
);
void
ME_HideCaret
(
ME_TextEditor
*
ed
);
void
ME_ShowCaret
(
ME_TextEditor
*
ed
);
...
...
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