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
172ce3ee
Commit
172ce3ee
authored
Apr 16, 2011
by
Andrew Nguyen
Committed by
Alexandre Julliard
Apr 18, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Convert the hex edit code to Unicode.
parent
9b586bc2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
hexedit.c
programs/regedit/hexedit.c
+22
-20
No files found.
programs/regedit/hexedit.c
View file @
172ce3ee
...
...
@@ -58,7 +58,7 @@ const WCHAR szHexEditClass[] = {'H','e','x','E','d','i','t',0};
static
inline
LRESULT
HexEdit_SetFont
(
HEXEDIT_INFO
*
infoPtr
,
HFONT
hFont
,
BOOL
redraw
);
static
inline
BYTE
hexchar_to_byte
(
T
CHAR
ch
)
static
inline
BYTE
hexchar_to_byte
(
W
CHAR
ch
)
{
if
(
ch
>=
'0'
&&
ch
<=
'9'
)
return
ch
-
'0'
;
...
...
@@ -70,17 +70,19 @@ static inline BYTE hexchar_to_byte(TCHAR ch)
return
-
1
;
}
static
LP
T
STR
HexEdit_GetLineText
(
BYTE
*
pData
,
LONG
cbData
,
LONG
pad
)
static
LP
W
STR
HexEdit_GetLineText
(
BYTE
*
pData
,
LONG
cbData
,
LONG
pad
)
{
LPTSTR
lpszLine
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
cbData
*
3
+
pad
*
3
+
DIV_SPACES
+
cbData
+
1
)
*
sizeof
(
TCHAR
));
static
const
WCHAR
percent_02xW
[]
=
{
'%'
,
'0'
,
'2'
,
'X'
,
' '
,
0
};
LPWSTR
lpszLine
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
cbData
*
3
+
pad
*
3
+
DIV_SPACES
+
cbData
+
1
)
*
sizeof
(
WCHAR
));
LONG
i
;
if
(
!
lpszLine
)
return
NULL
;
for
(
i
=
0
;
i
<
cbData
;
i
++
)
wsprintf
(
lpszLine
+
i
*
3
,
TEXT
(
"%02X "
)
,
pData
[
i
]);
wsprintf
W
(
lpszLine
+
i
*
3
,
percent_02xW
,
pData
[
i
]);
for
(
i
=
0
;
i
<
pad
*
3
;
i
++
)
lpszLine
[
cbData
*
3
+
i
]
=
' '
;
...
...
@@ -117,7 +119,7 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr)
nXStart
=
GetSystemMetrics
(
SM_CXBORDER
);
nYStart
=
GetSystemMetrics
(
SM_CYBORDER
);
if
(
GetWindowLong
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
WS_DISABLED
)
if
(
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
WS_DISABLED
)
clrOldText
=
SetTextColor
(
hdc
,
GetSysColor
(
COLOR_GRAYTEXT
));
else
clrOldText
=
SetTextColor
(
hdc
,
GetSysColor
(
COLOR_WINDOWTEXT
));
...
...
@@ -127,14 +129,14 @@ HexEdit_Paint(HEXEDIT_INFO *infoPtr)
for
(
pData
=
infoPtr
->
pData
+
lByteOffset
;
pData
<
infoPtr
->
pData
+
infoPtr
->
cbData
;
pData
+=
infoPtr
->
nBytesPerLine
)
{
LP
T
STR
lpszLine
;
LP
W
STR
lpszLine
;
LONG
nLineLen
=
min
((
LONG
)((
infoPtr
->
pData
+
infoPtr
->
cbData
)
-
pData
),
infoPtr
->
nBytesPerLine
);
lpszLine
=
HexEdit_GetLineText
(
pData
,
nLineLen
,
infoPtr
->
nBytesPerLine
-
nLineLen
);
/* FIXME: draw hex <-> ASCII mapping highlighted? */
TextOut
(
hdc
,
nXStart
,
nYStart
,
lpszLine
,
infoPtr
->
nBytesPerLine
*
3
+
DIV_SPACES
+
nLineLen
);
TextOut
W
(
hdc
,
nXStart
,
nYStart
,
lpszLine
,
infoPtr
->
nBytesPerLine
*
3
+
DIV_SPACES
+
nLineLen
);
nYStart
+=
infoPtr
->
nHeight
;
HeapFree
(
GetProcessHeap
(),
0
,
lpszLine
);
...
...
@@ -157,7 +159,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr)
INT
nByteLinePos
=
nCaretBytePos
%
infoPtr
->
nBytesPerLine
;
INT
nLine
=
nCaretBytePos
/
infoPtr
->
nBytesPerLine
;
LONG
nLineLen
=
min
(
infoPtr
->
cbData
-
nLine
*
infoPtr
->
nBytesPerLine
,
infoPtr
->
nBytesPerLine
);
LP
T
STR
lpszLine
=
HexEdit_GetLineText
(
infoPtr
->
pData
+
nLine
*
infoPtr
->
nBytesPerLine
,
nLineLen
,
infoPtr
->
nBytesPerLine
-
nLineLen
);
LP
W
STR
lpszLine
=
HexEdit_GetLineText
(
infoPtr
->
pData
+
nLine
*
infoPtr
->
nBytesPerLine
,
nLineLen
,
infoPtr
->
nBytesPerLine
-
nLineLen
);
INT
nCharOffset
;
/* calculate offset of character caret is on in the line */
...
...
@@ -169,7 +171,7 @@ HexEdit_UpdateCaret(HEXEDIT_INFO *infoPtr)
hdc
=
GetDC
(
infoPtr
->
hwndSelf
);
hOldFont
=
SelectObject
(
hdc
,
infoPtr
->
hFont
);
GetTextExtentPoint32
(
hdc
,
lpszLine
,
nCharOffset
,
&
size
);
GetTextExtentPoint32
W
(
hdc
,
lpszLine
,
nCharOffset
,
&
size
);
SelectObject
(
hdc
,
hOldFont
);
ReleaseDC
(
infoPtr
->
hwndSelf
,
hdc
);
...
...
@@ -221,7 +223,7 @@ HexEdit_EnsureVisible(HEXEDIT_INFO *infoPtr, INT nCaretPos)
si
.
fMask
=
SIF_POS
;
SetScrollInfo
(
infoPtr
->
hwndSelf
,
SB_VERT
,
&
si
,
FALSE
);
SendMessage
(
infoPtr
->
hwndSelf
,
WM_VSCROLL
,
MAKELONG
(
SB_THUMBPOSITION
,
0
),
0
);
SendMessage
W
(
infoPtr
->
hwndSelf
,
WM_VSCROLL
,
MAKELONG
(
SB_THUMBPOSITION
,
0
),
0
);
}
...
...
@@ -255,7 +257,7 @@ HexEdit_GetData(HEXEDIT_INFO *infoPtr, INT cbData, BYTE *pData)
}
static
inline
LRESULT
HexEdit_Char
(
HEXEDIT_INFO
*
infoPtr
,
T
CHAR
ch
)
HexEdit_Char
(
HEXEDIT_INFO
*
infoPtr
,
W
CHAR
ch
)
{
INT
nCaretBytePos
=
infoPtr
->
nCaretPos
/
2
;
...
...
@@ -349,7 +351,7 @@ HexEdit_Destroy (HEXEDIT_INFO *infoPtr)
HeapFree
(
GetProcessHeap
(),
0
,
infoPtr
->
pData
);
/* free info data */
HeapFree
(
GetProcessHeap
(),
0
,
infoPtr
);
SetWindowLongPtr
(
hwnd
,
0
,
0
);
SetWindowLongPtr
W
(
hwnd
,
0
,
0
);
return
0
;
}
...
...
@@ -360,12 +362,12 @@ HexEdit_EraseBackground (HEXEDIT_INFO *infoPtr, HDC hdc)
HBRUSH
hBrush
,
hSolidBrush
=
NULL
;
RECT
rc
;
if
(
GetWindowLong
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
WS_DISABLED
)
if
(
GetWindowLong
W
(
infoPtr
->
hwndSelf
,
GWL_STYLE
)
&
WS_DISABLED
)
hBrush
=
hSolidBrush
=
CreateSolidBrush
(
GetSysColor
(
COLOR_BTNFACE
));
else
{
hBrush
=
(
HBRUSH
)
SendMessage
(
GetParent
(
infoPtr
->
hwndSelf
),
WM_CTLCOLOREDIT
,
(
WPARAM
)
hdc
,
(
LPARAM
)
infoPtr
->
hwndSelf
);
hBrush
=
(
HBRUSH
)
SendMessage
W
(
GetParent
(
infoPtr
->
hwndSelf
),
WM_CTLCOLOREDIT
,
(
WPARAM
)
hdc
,
(
LPARAM
)
infoPtr
->
hwndSelf
);
if
(
!
hBrush
)
hBrush
=
hSolidBrush
=
CreateSolidBrush
(
GetSysColor
(
COLOR_WINDOW
));
}
...
...
@@ -505,7 +507,7 @@ HexEdit_SetFocus (HEXEDIT_INFO *infoPtr, HWND lostFocus)
static
inline
LRESULT
HexEdit_SetFont
(
HEXEDIT_INFO
*
infoPtr
,
HFONT
hFont
,
BOOL
redraw
)
{
TEXTMETRIC
tm
;
TEXTMETRIC
W
tm
;
HDC
hdc
;
HFONT
hOldFont
=
NULL
;
LONG
i
;
...
...
@@ -517,7 +519,7 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
if
(
infoPtr
->
hFont
)
hOldFont
=
SelectObject
(
hdc
,
infoPtr
->
hFont
);
GetTextMetrics
(
hdc
,
&
tm
);
GetTextMetrics
W
(
hdc
,
&
tm
);
infoPtr
->
nHeight
=
tm
.
tmHeight
+
tm
.
tmExternalLeading
;
GetClientRect
(
infoPtr
->
hwndSelf
,
&
rcClient
);
...
...
@@ -525,9 +527,9 @@ HexEdit_SetFont (HEXEDIT_INFO *infoPtr, HFONT hFont, BOOL redraw)
for
(
i
=
0
;
;
i
++
)
{
BYTE
*
pData
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
i
);
LP
T
STR
lpszLine
=
HexEdit_GetLineText
(
pData
,
i
,
0
);
LP
W
STR
lpszLine
=
HexEdit_GetLineText
(
pData
,
i
,
0
);
SIZE
size
;
GetTextExtentPoint32
(
hdc
,
lpszLine
,
lstrlen
(
lpszLine
),
&
size
);
GetTextExtentPoint32
W
(
hdc
,
lpszLine
,
lstrlenW
(
lpszLine
),
&
size
);
HeapFree
(
GetProcessHeap
(),
0
,
lpszLine
);
HeapFree
(
GetProcessHeap
(),
0
,
pData
);
if
(
size
.
cx
>
(
rcClient
.
right
-
rcClient
.
left
))
...
...
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