Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
d1641163
Commit
d1641163
authored
Feb 01, 2018
by
Nikolay Sivov
Committed by
Alexandre Julliard
Feb 01, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32/edit: Get rid of ansi buffer.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
662f727a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
152 deletions
+27
-152
edit.c
dlls/comctl32/edit.c
+27
-152
No files found.
dlls/comctl32/edit.c
View file @
d1641163
...
@@ -100,7 +100,6 @@ typedef struct tagLINEDEF {
...
@@ -100,7 +100,6 @@ typedef struct tagLINEDEF {
typedef
struct
typedef
struct
{
{
BOOL
is_unicode
;
/* how the control was created */
LPWSTR
text
;
/* the actual contents of the control */
LPWSTR
text
;
/* the actual contents of the control */
UINT
text_length
;
/* cached length of text buffer (in WCHARs) - use get_text_length() to retrieve */
UINT
text_length
;
/* cached length of text buffer (in WCHARs) - use get_text_length() to retrieve */
UINT
buffer_size
;
/* the size of the buffer in characters */
UINT
buffer_size
;
/* the size of the buffer in characters */
...
@@ -126,7 +125,7 @@ typedef struct
...
@@ -126,7 +125,7 @@ typedef struct
and just line width for single line controls */
and just line width for single line controls */
INT
region_posx
;
/* Position of cursor relative to region: */
INT
region_posx
;
/* Position of cursor relative to region: */
INT
region_posy
;
/* -1: to left, 0: within, 1: to right */
INT
region_posy
;
/* -1: to left, 0: within, 1: to right */
void
*
word_break_proc
;
/* 32-bit word break proc: ANSI or Unicode */
EDITWORDBREAKPROCW
word_break_proc
;
INT
line_count
;
/* number of lines */
INT
line_count
;
/* number of lines */
INT
y_offset
;
/* scroll offset in number of lines */
INT
y_offset
;
/* scroll offset in number of lines */
BOOL
bCaptureState
;
/* flag indicating whether mouse was captured */
BOOL
bCaptureState
;
/* flag indicating whether mouse was captured */
...
@@ -145,8 +144,6 @@ typedef struct
...
@@ -145,8 +144,6 @@ typedef struct
LPINT
tabs
;
LPINT
tabs
;
LINEDEF
*
first_line_def
;
/* linked list of (soft) linebreaks */
LINEDEF
*
first_line_def
;
/* linked list of (soft) linebreaks */
HLOCAL
hloc32W
;
/* our unicode local memory block */
HLOCAL
hloc32W
;
/* our unicode local memory block */
HLOCAL
hloc32A
;
/* alias for ANSI control receiving EM_GETHANDLE
or EM_SETHANDLE */
HLOCAL
hlocapp
;
/* The text buffer handle belongs to the app */
HLOCAL
hlocapp
;
/* The text buffer handle belongs to the app */
/*
/*
* IME Data
* IME Data
...
@@ -299,27 +296,9 @@ static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count
...
@@ -299,27 +296,9 @@ static INT EDIT_CallWordBreakProc(EDITSTATE *es, INT start, INT index, INT count
INT
ret
;
INT
ret
;
if
(
es
->
word_break_proc
)
if
(
es
->
word_break_proc
)
{
ret
=
es
->
word_break_proc
(
es
->
text
+
start
,
index
,
count
,
action
);
if
(
es
->
is_unicode
)
{
EDITWORDBREAKPROCW
wbpW
=
(
EDITWORDBREAKPROCW
)
es
->
word_break_proc
;
ret
=
wbpW
(
es
->
text
+
start
,
index
,
count
,
action
);
}
else
{
EDITWORDBREAKPROCA
wbpA
=
(
EDITWORDBREAKPROCA
)
es
->
word_break_proc
;
INT
countA
;
CHAR
*
textA
;
countA
=
WideCharToMultiByte
(
CP_ACP
,
0
,
es
->
text
+
start
,
count
,
NULL
,
0
,
NULL
,
NULL
);
textA
=
HeapAlloc
(
GetProcessHeap
(),
0
,
countA
);
WideCharToMultiByte
(
CP_ACP
,
0
,
es
->
text
+
start
,
count
,
textA
,
countA
,
NULL
,
NULL
);
ret
=
wbpA
(
textA
,
index
,
countA
,
action
);
HeapFree
(
GetProcessHeap
(),
0
,
textA
);
}
}
else
else
ret
=
EDIT_WordBreakProc
(
es
,
es
->
text
,
index
+
start
,
count
+
start
,
action
)
-
start
;
ret
=
EDIT_WordBreakProc
(
es
,
es
->
text
,
index
+
start
,
count
+
start
,
action
)
-
start
;
return
ret
;
return
ret
;
}
}
...
@@ -1219,35 +1198,14 @@ static inline void text_buffer_changed(EDITSTATE *es)
...
@@ -1219,35 +1198,14 @@ static inline void text_buffer_changed(EDITSTATE *es)
*/
*/
static
void
EDIT_LockBuffer
(
EDITSTATE
*
es
)
static
void
EDIT_LockBuffer
(
EDITSTATE
*
es
)
{
{
if
(
!
es
->
text
)
{
if
(
!
es
->
text
)
if
(
!
es
->
hloc32W
)
return
;
if
(
es
->
hloc32A
)
{
CHAR
*
textA
=
LocalLock
(
es
->
hloc32A
);
HLOCAL
hloc32W_new
;
UINT
countW_new
=
MultiByteToWideChar
(
CP_ACP
,
0
,
textA
,
-
1
,
NULL
,
0
);
if
(
countW_new
>
es
->
buffer_size
+
1
)
{
UINT
alloc_size
=
ROUND_TO_GROW
(
countW_new
*
sizeof
(
WCHAR
));
TRACE
(
"Resizing 32-bit UNICODE buffer from %d+1 to %d WCHARs
\n
"
,
es
->
buffer_size
,
countW_new
);
hloc32W_new
=
LocalReAlloc
(
es
->
hloc32W
,
alloc_size
,
LMEM_MOVEABLE
|
LMEM_ZEROINIT
);
if
(
hloc32W_new
)
{
{
es
->
hloc32W
=
hloc32W_new
;
if
(
!
es
->
hloc32W
)
es
->
buffer_size
=
LocalSize
(
hloc32W_new
)
/
sizeof
(
WCHAR
)
-
1
;
return
;
TRACE
(
"Real new size %d+1 WCHARs
\n
"
,
es
->
buffer_size
);
}
else
WARN
(
"FAILED! Will synchronize partially
\n
"
);
}
es
->
text
=
LocalLock
(
es
->
hloc32W
);
es
->
text
=
LocalLock
(
es
->
hloc32W
);
MultiByteToWideChar
(
CP_ACP
,
0
,
textA
,
-
1
,
es
->
text
,
es
->
buffer_size
+
1
);
LocalUnlock
(
es
->
hloc32A
);
}
else
es
->
text
=
LocalLock
(
es
->
hloc32W
);
}
}
es
->
lock_count
++
;
es
->
lock_count
++
;
}
}
...
@@ -1260,59 +1218,39 @@ static void EDIT_LockBuffer(EDITSTATE *es)
...
@@ -1260,59 +1218,39 @@ static void EDIT_LockBuffer(EDITSTATE *es)
static
void
EDIT_UnlockBuffer
(
EDITSTATE
*
es
,
BOOL
force
)
static
void
EDIT_UnlockBuffer
(
EDITSTATE
*
es
,
BOOL
force
)
{
{
/* Edit window might be already destroyed */
/* Edit window might be already destroyed */
if
(
!
IsWindow
(
es
->
hwndSelf
))
if
(
!
IsWindow
(
es
->
hwndSelf
))
{
{
WARN
(
"edit hwnd %p already destroyed
\n
"
,
es
->
hwndSelf
);
WARN
(
"edit hwnd %p already destroyed
\n
"
,
es
->
hwndSelf
);
return
;
return
;
}
}
if
(
!
es
->
lock_count
)
{
if
(
!
es
->
lock_count
)
{
ERR
(
"lock_count == 0 ... please report
\n
"
);
ERR
(
"lock_count == 0 ... please report
\n
"
);
return
;
return
;
}
}
if
(
!
es
->
text
)
{
if
(
!
es
->
text
)
{
ERR
(
"es->text == 0 ... please report
\n
"
);
ERR
(
"es->text == 0 ... please report
\n
"
);
return
;
return
;
}
}
if
(
force
||
(
es
->
lock_count
==
1
))
{
if
(
es
->
hloc32W
)
{
UINT
countA
=
0
;
UINT
countW
=
get_text_length
(
es
)
+
1
;
if
(
es
->
hloc32A
)
if
(
force
||
(
es
->
lock_count
==
1
))
{
UINT
countA_new
=
WideCharToMultiByte
(
CP_ACP
,
0
,
es
->
text
,
countW
,
NULL
,
0
,
NULL
,
NULL
);
TRACE
(
"Synchronizing with 32-bit ANSI buffer
\n
"
);
TRACE
(
"%d WCHARs translated to %d bytes
\n
"
,
countW
,
countA_new
);
countA
=
LocalSize
(
es
->
hloc32A
);
if
(
countA_new
>
countA
)
{
{
HLOCAL
hloc32A_new
;
if
(
es
->
hloc32W
)
UINT
alloc_size
=
ROUND_TO_GROW
(
countA_new
);
TRACE
(
"Resizing 32-bit ANSI buffer from %d to %d bytes
\n
"
,
countA
,
alloc_size
);
hloc32A_new
=
LocalReAlloc
(
es
->
hloc32A
,
alloc_size
,
LMEM_MOVEABLE
|
LMEM_ZEROINIT
);
if
(
hloc32A_new
)
{
{
es
->
hloc32A
=
hloc32A_new
;
countA
=
LocalSize
(
hloc32A_new
);
TRACE
(
"Real new size %d bytes
\n
"
,
countA
);
}
else
WARN
(
"FAILED! Will synchronize partially
\n
"
);
}
WideCharToMultiByte
(
CP_ACP
,
0
,
es
->
text
,
countW
,
LocalLock
(
es
->
hloc32A
),
countA
,
NULL
,
NULL
);
LocalUnlock
(
es
->
hloc32A
);
}
LocalUnlock
(
es
->
hloc32W
);
LocalUnlock
(
es
->
hloc32W
);
es
->
text
=
NULL
;
es
->
text
=
NULL
;
}
}
else
{
else
{
ERR
(
"no buffer ... please report
\n
"
);
ERR
(
"no buffer ... please report
\n
"
);
return
;
return
;
}
}
}
}
es
->
lock_count
--
;
es
->
lock_count
--
;
}
}
...
@@ -2401,41 +2339,16 @@ static BOOL EDIT_EM_FmtLines(EDITSTATE *es, BOOL add_eol)
...
@@ -2401,41 +2339,16 @@ static BOOL EDIT_EM_FmtLines(EDITSTATE *es, BOOL add_eol)
*/
*/
static
HLOCAL
EDIT_EM_GetHandle
(
EDITSTATE
*
es
)
static
HLOCAL
EDIT_EM_GetHandle
(
EDITSTATE
*
es
)
{
{
HLOCAL
hLocal
;
if
(
!
(
es
->
style
&
ES_MULTILINE
))
if
(
!
(
es
->
style
&
ES_MULTILINE
))
return
0
;
return
0
;
if
(
es
->
is_unicode
)
hLocal
=
es
->
hloc32W
;
else
{
if
(
!
es
->
hloc32A
)
{
CHAR
*
textA
;
UINT
countA
,
alloc_size
;
TRACE
(
"Allocating 32-bit ANSI alias buffer
\n
"
);
countA
=
WideCharToMultiByte
(
CP_ACP
,
0
,
es
->
text
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
alloc_size
=
ROUND_TO_GROW
(
countA
);
if
(
!
(
es
->
hloc32A
=
LocalAlloc
(
LMEM_MOVEABLE
|
LMEM_ZEROINIT
,
alloc_size
)))
{
ERR
(
"Could not allocate %d bytes for 32-bit ANSI alias buffer
\n
"
,
alloc_size
);
return
0
;
}
textA
=
LocalLock
(
es
->
hloc32A
);
WideCharToMultiByte
(
CP_ACP
,
0
,
es
->
text
,
-
1
,
textA
,
countA
,
NULL
,
NULL
);
LocalUnlock
(
es
->
hloc32A
);
}
hLocal
=
es
->
hloc32A
;
}
EDIT_UnlockBuffer
(
es
,
TRUE
);
EDIT_UnlockBuffer
(
es
,
TRUE
);
/* The text buffer handle belongs to the app */
/* The text buffer handle belongs to the app */
es
->
hlocapp
=
hLocal
;
es
->
hlocapp
=
es
->
hloc32W
;
TRACE
(
"Returning %p, LocalSize() = %ld
\n
"
,
hLocal
,
LocalSize
(
hLocal
));
TRACE
(
"Returning %p, LocalSize() = %ld
\n
"
,
es
->
hlocapp
,
LocalSize
(
es
->
hlocapp
));
return
hLocal
;
return
es
->
hlocapp
;
}
}
...
@@ -2725,42 +2638,7 @@ static void EDIT_EM_SetHandle(EDITSTATE *es, HLOCAL hloc)
...
@@ -2725,42 +2638,7 @@ static void EDIT_EM_SetHandle(EDITSTATE *es, HLOCAL hloc)
EDIT_UnlockBuffer
(
es
,
TRUE
);
EDIT_UnlockBuffer
(
es
,
TRUE
);
if
(
es
->
is_unicode
)
{
if
(
es
->
hloc32A
)
{
LocalFree
(
es
->
hloc32A
);
es
->
hloc32A
=
NULL
;
}
es
->
hloc32W
=
hloc
;
es
->
hloc32W
=
hloc
;
}
else
{
INT
countW
,
countA
;
HLOCAL
hloc32W_new
;
WCHAR
*
textW
;
CHAR
*
textA
;
countA
=
LocalSize
(
hloc
);
textA
=
LocalLock
(
hloc
);
countW
=
MultiByteToWideChar
(
CP_ACP
,
0
,
textA
,
countA
,
NULL
,
0
);
if
(
!
(
hloc32W_new
=
LocalAlloc
(
LMEM_MOVEABLE
|
LMEM_ZEROINIT
,
countW
*
sizeof
(
WCHAR
))))
{
ERR
(
"Could not allocate new unicode buffer
\n
"
);
return
;
}
textW
=
LocalLock
(
hloc32W_new
);
MultiByteToWideChar
(
CP_ACP
,
0
,
textA
,
countA
,
textW
,
countW
);
LocalUnlock
(
hloc32W_new
);
LocalUnlock
(
hloc
);
if
(
es
->
hloc32W
)
LocalFree
(
es
->
hloc32W
);
es
->
hloc32W
=
hloc32W_new
;
es
->
hloc32A
=
hloc
;
}
es
->
buffer_size
=
LocalSize
(
es
->
hloc32W
)
/
sizeof
(
WCHAR
)
-
1
;
es
->
buffer_size
=
LocalSize
(
es
->
hloc32W
)
/
sizeof
(
WCHAR
)
-
1
;
/* The text buffer handle belongs to the control */
/* The text buffer handle belongs to the control */
...
@@ -2944,7 +2822,7 @@ static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, const INT *tabs)
...
@@ -2944,7 +2822,7 @@ static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, const INT *tabs)
* EM_SETWORDBREAKPROC
* EM_SETWORDBREAKPROC
*
*
*/
*/
static
void
EDIT_EM_SetWordBreakProc
(
EDITSTATE
*
es
,
void
*
wbp
)
static
void
EDIT_EM_SetWordBreakProc
(
EDITSTATE
*
es
,
EDITWORDBREAKPROCW
wbp
)
{
{
if
(
es
->
word_break_proc
==
wbp
)
if
(
es
->
word_break_proc
==
wbp
)
return
;
return
;
...
@@ -4382,7 +4260,6 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
...
@@ -4382,7 +4260,6 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
* WM_XXX messages before WM_NCCREATE is completed.
* WM_XXX messages before WM_NCCREATE is completed.
*/
*/
es
->
is_unicode
=
TRUE
;
es
->
style
=
lpcs
->
style
;
es
->
style
=
lpcs
->
style
;
es
->
bEnableState
=
!
(
es
->
style
&
WS_DISABLED
);
es
->
bEnableState
=
!
(
es
->
style
&
WS_DISABLED
);
...
@@ -4534,13 +4411,11 @@ static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es)
...
@@ -4534,13 +4411,11 @@ static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es)
LINEDEF
*
pc
,
*
pp
;
LINEDEF
*
pc
,
*
pp
;
/* The app can own the text buffer handle */
/* The app can own the text buffer handle */
if
(
es
->
hloc32W
&&
(
es
->
hloc32W
!=
es
->
hlocapp
))
{
if
(
es
->
hloc32W
&&
(
es
->
hloc32W
!=
es
->
hlocapp
))
LocalFree
(
es
->
hloc32W
);
LocalFree
(
es
->
hloc32W
);
}
if
(
es
->
hloc32A
&&
(
es
->
hloc32A
!=
es
->
hlocapp
))
{
LocalFree
(
es
->
hloc32A
);
}
EDIT_InvalidateUniscribeData
(
es
);
EDIT_InvalidateUniscribeData
(
es
);
pc
=
es
->
first_line_def
;
pc
=
es
->
first_line_def
;
while
(
pc
)
while
(
pc
)
{
{
...
...
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