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
043b5d9b
Commit
043b5d9b
authored
Mar 08, 2005
by
Krzysztof Foltman
Committed by
Alexandre Julliard
Mar 08, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- specialized handler for SF_TEXT (ANSI or Unicode), simple and fast
- clears control's text on EM_STREAMIN with no SFF_SELECTION
parent
5c017522
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
25 deletions
+97
-25
caret.c
dlls/riched20/caret.c
+17
-0
editor.c
dlls/riched20/editor.c
+79
-25
editor.h
dlls/riched20/editor.h
+1
-0
No files found.
dlls/riched20/caret.c
View file @
043b5d9b
...
...
@@ -844,6 +844,23 @@ void ME_DeleteSelection(ME_TextEditor *editor)
ME_DeleteTextAtCursor
(
editor
,
ME_GetSelCursor
(
editor
,
-
1
),
to
-
from
);
}
ME_Style
*
ME_GetSelectionInsertStyle
(
ME_TextEditor
*
editor
)
{
ME_Style
*
style
;
int
from
,
to
;
ME_Cursor
c
;
ME_GetSelection
(
editor
,
&
from
,
&
to
);
ME_CursorFromCharOfs
(
editor
,
from
,
&
c
);
if
(
from
!=
to
)
{
style
=
c
.
pRun
->
member
.
run
.
style
;
ME_AddRefStyle
(
style
);
/* ME_GetInsertStyle has already done that */
}
else
style
=
ME_GetInsertStyle
(
editor
,
0
);
return
style
;
}
void
ME_SendSelChange
(
ME_TextEditor
*
editor
)
{
SELCHANGE
sc
;
...
...
dlls/riched20/editor.c
View file @
043b5d9b
...
...
@@ -306,27 +306,88 @@ ME_TextBuffer *ME_MakeText() {
return
buf
;
}
static
LRESULT
ME_StreamIn
(
HWND
hwnd
,
DWORD
format
,
EDITSTREAM
*
stream
)
{
RTF_Info
parser
;
#define STREAMIN_BUFFER_SIZE 1024
TRACE
(
"%p %p
\n
"
,
stream
,
hwnd
);
static
LRESULT
ME_StreamInText
(
ME_TextEditor
*
editor
,
DWORD
dwFormat
,
EDITSTREAM
*
stream
,
ME_Style
*
style
)
{
BYTE
buffer
[
STREAMIN_BUFFER_SIZE
+
1
];
WCHAR
wszText
[
STREAMIN_BUFFER_SIZE
+
1
];
TRACE
(
"%08lx %p
\n
"
,
dwFormat
,
stream
);
stream
->
dwError
=
0
;
do
{
long
nDataSize
=
0
,
nWideChars
=
0
;
stream
->
dwError
=
stream
->
pfnCallback
(
stream
->
dwCookie
,
(
dwFormat
&
SF_UNICODE
?
(
BYTE
*
)
wszText
:
buffer
),
STREAMIN_BUFFER_SIZE
,
&
nDataSize
);
if
(
stream
->
dwError
)
break
;
if
(
!
nDataSize
)
break
;
if
(
!
(
dwFormat
&
SF_UNICODE
))
{
/* FIXME? this is doomed to fail on true MBCS like UTF-8, luckily they're unlikely to be used as CP_ACP */
nWideChars
=
MultiByteToWideChar
(
CP_ACP
,
0
,
buffer
,
nDataSize
,
wszText
,
STREAMIN_BUFFER_SIZE
);
}
else
nWideChars
=
nDataSize
>>
1
;
ME_InsertTextFromCursor
(
editor
,
0
,
wszText
,
nWideChars
,
style
);
if
(
nDataSize
<
STREAMIN_BUFFER_SIZE
)
break
;
}
while
(
1
);
ME_CommitUndo
(
editor
);
return
0
;
}
/* setup the RTF parser */
memset
(
&
parser
,
0
,
sizeof
parser
);
RTFSetEditStream
(
&
parser
,
stream
);
parser
.
rtfFormat
=
format
&
(
SF_TEXT
|
SF_RTF
);
parser
.
hwndEdit
=
hwnd
;
WriterInit
(
&
parser
);
RTFInit
(
&
parser
);
BeginFile
(
&
parser
);
static
LRESULT
ME_StreamIn
(
ME_TextEditor
*
editor
,
DWORD
format
,
EDITSTREAM
*
stream
)
{
RTF_Info
parser
;
ME_Style
*
style
;
/* do the parsing */
RTFRead
(
&
parser
);
RTFFlushOutputBuffer
(
&
parser
);
FIXME
(
"%08lx %p
\n
"
,
format
,
stream
);
TRACE
(
"%p %p
\n
"
,
stream
,
editor
->
hWnd
);
if
(
format
&
SFF_SELECTION
)
{
style
=
ME_GetSelectionInsertStyle
(
editor
);
SendMessageW
(
editor
->
hWnd
,
WM_CLEAR
,
0
,
0
);
}
else
{
style
=
editor
->
pBuffer
->
pDefaultStyle
;
ME_AddRefStyle
(
style
);
SendMessageA
(
editor
->
hWnd
,
EM_SETSEL
,
0
,
0
);
SetWindowTextA
(
editor
->
hWnd
,
""
);
ME_ClearTempStyle
(
editor
);
}
if
(
format
&
SF_RTF
)
{
/* setup the RTF parser */
memset
(
&
parser
,
0
,
sizeof
parser
);
RTFSetEditStream
(
&
parser
,
stream
);
parser
.
rtfFormat
=
format
&
(
SF_TEXT
|
SF_RTF
);
parser
.
hwndEdit
=
editor
->
hWnd
;
WriterInit
(
&
parser
);
RTFInit
(
&
parser
);
BeginFile
(
&
parser
);
/* do the parsing */
RTFRead
(
&
parser
);
RTFFlushOutputBuffer
(
&
parser
);
}
else
if
(
format
&
SF_TEXT
)
ME_StreamInText
(
editor
,
format
,
stream
,
style
);
else
ERR
(
"EM_STREAMIN without SF_TEXT or SF_RTF
\n
"
);
/* put the cursor at the top */
SendMessageA
(
hwnd
,
EM_SETSEL
,
0
,
0
);
if
(
!
(
format
&
SFF_SELECTION
))
SendMessageA
(
editor
->
hWnd
,
EM_SETSEL
,
0
,
0
);
else
{
/* FIXME where to put cursor now ? */
}
ME_ReleaseStyle
(
style
);
return
0
;
}
...
...
@@ -464,7 +525,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
/* Messages specific to Richedit controls */
case
EM_STREAMIN
:
return
ME_StreamIn
(
hWnd
,
wParam
,
(
EDITSTREAM
*
)
lParam
);
return
ME_StreamIn
(
editor
,
wParam
,
(
EDITSTREAM
*
)
lParam
);
case
WM_GETDLGCODE
:
{
UINT
code
=
DLGC_WANTCHARS
|
DLGC_WANTARROWS
;
...
...
@@ -606,20 +667,13 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
case
EM_REPLACESEL
:
{
int
from
,
to
;
ME_Cursor
c
;
ME_Style
*
style
;
LPWSTR
wszText
=
ME_ToUnicode
(
hWnd
,
(
void
*
)
lParam
);
size_t
len
=
lstrlenW
(
wszText
);
TRACE
(
"EM_REPLACESEL - %s
\n
"
,
debugstr_w
(
wszText
));
ME_GetSelection
(
editor
,
&
from
,
&
to
);
ME_CursorFromCharOfs
(
editor
,
from
,
&
c
);
if
(
from
!=
to
)
{
style
=
c
.
pRun
->
member
.
run
.
style
;
ME_AddRefStyle
(
style
);
/* ME_GetInsertStyle has already done that */
}
else
style
=
ME_GetInsertStyle
(
editor
,
0
);
style
=
ME_GetSelectionInsertStyle
(
editor
);
ME_InternalDeleteText
(
editor
,
from
,
to
-
from
);
ME_InsertTextFromCursor
(
editor
,
0
,
wszText
,
len
,
style
);
ME_ReleaseStyle
(
style
);
...
...
dlls/riched20/editor.h
View file @
043b5d9b
...
...
@@ -156,6 +156,7 @@ void ME_SendSelChange(ME_TextEditor *editor);
void
ME_InsertGraphicsFromCursor
(
ME_TextEditor
*
editor
,
int
nCursor
);
void
ME_InternalDeleteText
(
ME_TextEditor
*
editor
,
int
nOfs
,
int
nChars
);
int
ME_GetTextLength
(
ME_TextEditor
*
editor
);
ME_Style
*
ME_GetSelectionInsertStyle
(
ME_TextEditor
*
editor
);
/* wrap.c */
void
ME_PrepareParagraphForWrapping
(
ME_Context
*
c
,
ME_DisplayItem
*
tp
);
...
...
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