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
fe2fd44e
Commit
fe2fd44e
authored
Nov 02, 2020
by
Huw Davies
Committed by
Alexandre Julliard
Nov 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
riched20: Return a row ptr from the row from row number function.
Signed-off-by:
Huw Davies
<
huw@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c5b13787
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
49 deletions
+43
-49
editor.c
dlls/riched20/editor.c
+27
-21
editor.h
dlls/riched20/editor.h
+1
-1
row.c
dlls/riched20/row.c
+15
-27
No files found.
dlls/riched20/editor.c
View file @
fe2fd44e
...
...
@@ -4237,26 +4237,32 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
}
case
EM_GETLINE
:
{
ME_DisplayItem
*
run
;
ME_Row
*
row
;
ME_Run
*
run
;
const
unsigned
int
nMaxChars
=
*
(
WORD
*
)
lParam
;
unsigned
int
nCharsLeft
=
nMaxChars
;
char
*
dest
=
(
char
*
)
lParam
;
BOOL
wroteNull
=
FALSE
;
ME_Cursor
start
,
end
;
TRACE
(
"EM_GETLINE: row=%d, nMaxChars=%d (%s)
\n
"
,
(
int
)
wParam
,
nMaxChars
,
unicode
?
"Unicode"
:
"Ansi"
);
run
=
ME_FindRowWithNumber
(
editor
,
wParam
);
if
(
run
==
NULL
)
return
0
;
row
=
row_from_row_number
(
editor
,
wParam
);
if
(
row
==
NULL
)
return
0
;
while
(
nCharsLeft
&&
(
run
=
ME_FindItemFwd
(
run
,
diRunOrStartRow
))
&&
run
->
type
==
diRun
)
row_first_cursor
(
row
,
&
start
);
row_end_cursor
(
row
,
&
end
,
TRUE
);
run
=
&
start
.
pRun
->
member
.
run
;
while
(
nCharsLeft
)
{
WCHAR
*
str
=
get_text
(
&
run
->
member
.
run
,
0
)
;
WCHAR
*
str
;
unsigned
int
nCopy
;
int
ofs
=
(
run
==
&
start
.
pRun
->
member
.
run
)
?
start
.
nOffset
:
0
;
int
len
=
(
run
==
&
end
.
pRun
->
member
.
run
)
?
end
.
nOffset
:
run
->
len
;
nCopy
=
min
(
nCharsLeft
,
run
->
member
.
run
.
len
);
str
=
get_text
(
run
,
ofs
);
nCopy
=
min
(
nCharsLeft
,
len
);
if
(
unicode
)
memcpy
(
dest
,
str
,
nCopy
*
sizeof
(
WCHAR
));
...
...
@@ -4265,6 +4271,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
nCharsLeft
,
NULL
,
NULL
);
dest
+=
nCopy
*
(
unicode
?
sizeof
(
WCHAR
)
:
1
);
nCharsLeft
-=
nCopy
;
if
(
run
==
&
end
.
pRun
->
member
.
run
)
break
;
run
=
row_next_run
(
row
,
run
);
}
/* append line termination, space allowing */
...
...
@@ -4321,20 +4329,18 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
}
case
EM_LINEINDEX
:
{
ME_DisplayItem
*
item
,
*
para
;
int
nCharOfs
;
ME_Row
*
row
;
ME_Cursor
cursor
;
int
ofs
;
if
(
wParam
==
-
1
)
item
=
ME_FindItemBack
(
editor
->
pCursors
[
0
].
pRun
,
diStartRow
);
else
item
=
ME_FindRowWithNumber
(
editor
,
wParam
);
if
(
!
item
)
return
-
1
;
para
=
ME_GetParagraph
(
item
);
item
=
ME_FindItemFwd
(
item
,
diRun
);
nCharOfs
=
para
->
member
.
para
.
nCharOfs
+
item
->
member
.
run
.
nCharOfs
;
TRACE
(
"EM_LINEINDEX: nCharOfs==%d
\n
"
,
nCharOfs
);
return
nCharOfs
;
if
(
wParam
==
-
1
)
row
=
row_from_cursor
(
editor
->
pCursors
);
else
row
=
row_from_row_number
(
editor
,
wParam
);
if
(
!
row
)
return
-
1
;
row_first_cursor
(
row
,
&
cursor
);
ofs
=
ME_GetCursorOfs
(
&
cursor
);
TRACE
(
"EM_LINEINDEX: nCharOfs==%d
\n
"
,
ofs
);
return
ofs
;
}
case
EM_LINELENGTH
:
{
...
...
dlls/riched20/editor.h
View file @
fe2fd44e
...
...
@@ -115,11 +115,11 @@ void row_end_cursor( ME_Row *row, ME_Cursor *cursor, BOOL include_eop ) DECLSPEC
void
row_first_cursor
(
ME_Row
*
row
,
ME_Cursor
*
cursor
)
DECLSPEC_HIDDEN
;
ME_Run
*
row_first_run
(
ME_Row
*
row
)
DECLSPEC_HIDDEN
;
ME_Row
*
row_from_cursor
(
ME_Cursor
*
cursor
)
DECLSPEC_HIDDEN
;
ME_Row
*
row_from_row_number
(
ME_TextEditor
*
editor
,
int
row_num
)
DECLSPEC_HIDDEN
;
ME_Row
*
row_next
(
ME_Row
*
row
)
DECLSPEC_HIDDEN
;
ME_Run
*
row_next_run
(
ME_Row
*
row
,
ME_Run
*
run
)
DECLSPEC_HIDDEN
;
ME_DisplayItem
*
ME_RowStart
(
ME_DisplayItem
*
item
)
DECLSPEC_HIDDEN
;
/* ME_DisplayItem *ME_RowEnd(ME_DisplayItem *item); */
ME_DisplayItem
*
ME_FindRowWithNumber
(
ME_TextEditor
*
editor
,
int
nRow
)
DECLSPEC_HIDDEN
;
int
ME_RowNumberFromCharOfs
(
ME_TextEditor
*
editor
,
int
nOfs
)
DECLSPEC_HIDDEN
;
static
inline
ME_DisplayItem
*
row_get_di
(
ME_Row
*
row
)
{
...
...
dlls/riched20/row.c
View file @
fe2fd44e
...
...
@@ -82,39 +82,27 @@ void row_end_cursor( ME_Row *row, ME_Cursor *cursor, BOOL include_eop )
cursor
->
nOffset
=
(
item
->
type
==
diStartRow
||
include_eop
)
?
cursor
->
pRun
->
member
.
run
.
len
:
0
;
}
/* I'm sure these functions would simplify some code in caret ops etc,
* I just didn't remember them when I wrote that code
*/
ME_DisplayItem
*
ME_RowStart
(
ME_DisplayItem
*
item
)
{
return
ME_FindItemBackOrHere
(
item
,
diStartRow
);
}
/*
ME_DisplayItem *ME_RowEnd(ME_DisplayItem *item) {
ME_DisplayItem *item2 = ME_FindItemFwd(item, diStartRowOrParagraphOrEnd);
if (!item2) return NULL;
return ME_FindItemBack(item, diRun);
}
*/
ME_DisplayItem
*
ME_FindRowWithNumber
(
ME_TextEditor
*
editor
,
int
nRow
)
ME_Row
*
row_from_row_number
(
ME_TextEditor
*
editor
,
int
row_num
)
{
ME_DisplayItem
*
item
=
ME_FindItemFwd
(
editor
->
pBuffer
->
pFirst
,
diParagraph
);
int
nCount
=
0
;
ME_Paragraph
*
para
=
editor_first_para
(
editor
);
ME_Row
*
row
;
int
count
=
0
;
while
(
item
->
type
==
diParagraph
&&
nCount
+
item
->
member
.
para
.
nRows
<=
nRow
)
{
nCount
+=
item
->
member
.
para
.
nRows
;
item
=
item
->
member
.
para
.
next_para
;
}
if
(
item
->
type
!=
diParagraph
)
return
NULL
;
for
(
item
=
ME_FindItemFwd
(
item
,
diStartRow
);
item
&&
nCount
<
nRow
;
nCount
++
)
item
=
ME_FindItemFwd
(
item
,
diStartRow
);
return
item
;
while
(
para_next
(
para
)
&&
count
+
para
->
nRows
<=
row_num
)
{
count
+=
para
->
nRows
;
para
=
para_next
(
para
)
;
}
if
(
!
para_next
(
para
))
return
NULL
;
for
(
row
=
para_first_row
(
para
);
row
&&
count
<
row_num
;
count
++
)
row
=
row_next
(
row
);
return
row
;
}
...
...
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