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
8b4c2ce9
Commit
8b4c2ce9
authored
Dec 12, 2010
by
Eric Pouech
Committed by
Alexandre Julliard
Dec 13, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Proper support for echo-input (enable/disable) when getting console input.
parent
4149643f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
29 deletions
+41
-29
editline.c
dlls/kernel32/editline.c
+41
-29
No files found.
dlls/kernel32/editline.c
View file @
8b4c2ce9
...
...
@@ -66,6 +66,7 @@ typedef struct WCEL_Context {
unsigned
done
:
1
,
/* to 1 when we're done with editing */
error
:
1
,
/* to 1 when an error occurred in the editing */
can_wrap
:
1
,
/* to 1 when multi-line edition can take place */
shall_echo
:
1
,
/* to 1 when characters should be echo:ed when keyed-in */
can_pos_cursor
:
1
;
/* to 1 when console can (re)position cursor */
unsigned
histSize
;
unsigned
histPos
;
...
...
@@ -128,6 +129,7 @@ static inline COORD WCEL_GetCoord(WCEL_Context* ctx, int ofs)
static
inline
void
WCEL_Update
(
WCEL_Context
*
ctx
,
int
beg
,
int
len
)
{
if
(
!
ctx
->
shall_echo
)
return
;
if
(
ctx
->
can_pos_cursor
)
{
WriteConsoleOutputCharacterW
(
ctx
->
hConOut
,
&
ctx
->
line
[
beg
],
len
,
...
...
@@ -194,34 +196,38 @@ static BOOL WCEL_Grow(WCEL_Context* ctx, size_t len)
static
void
WCEL_DeleteString
(
WCEL_Context
*
ctx
,
int
beg
,
int
end
)
{
unsigned
str_len
=
end
-
beg
;
COORD
cbeg
=
WCEL_GetCoord
(
ctx
,
ctx
->
len
-
str_len
);
COORD
cend
=
WCEL_GetCoord
(
ctx
,
ctx
->
len
);
CHAR_INFO
ci
;
if
(
end
<
ctx
->
len
)
memmove
(
&
ctx
->
line
[
beg
],
&
ctx
->
line
[
end
],
(
ctx
->
len
-
end
)
*
sizeof
(
WCHAR
));
/* we need to clean from ctx->len - str_len to ctx->len */
ci
.
Char
.
UnicodeChar
=
' '
;
ci
.
Attributes
=
ctx
->
csbi
.
wAttributes
;
if
(
cbeg
.
Y
==
cend
.
Y
)
{
/* partial erase of sole line */
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
cbeg
.
X
,
cbeg
.
Y
,
cend
.
X
-
cbeg
.
X
,
&
ci
);
}
else
if
(
ctx
->
shall_echo
)
{
int
i
;
/* erase til eol on first line */
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
cbeg
.
X
,
cbeg
.
Y
,
ctx
->
csbi
.
dwSize
.
X
-
cbeg
.
X
,
&
ci
);
/* completely erase all the others (full lines) */
for
(
i
=
cbeg
.
Y
+
1
;
i
<
cend
.
Y
;
i
++
)
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
0
,
i
,
ctx
->
csbi
.
dwSize
.
X
,
&
ci
);
/* erase from beginning of line until last pos on last line */
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
0
,
cend
.
Y
,
cend
.
X
,
&
ci
);
COORD
cbeg
=
WCEL_GetCoord
(
ctx
,
ctx
->
len
-
str_len
);
COORD
cend
=
WCEL_GetCoord
(
ctx
,
ctx
->
len
);
CHAR_INFO
ci
;
ci
.
Char
.
UnicodeChar
=
' '
;
ci
.
Attributes
=
ctx
->
csbi
.
wAttributes
;
if
(
cbeg
.
Y
==
cend
.
Y
)
{
/* partial erase of sole line */
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
cbeg
.
X
,
cbeg
.
Y
,
cend
.
X
-
cbeg
.
X
,
&
ci
);
}
else
{
int
i
;
/* erase til eol on first line */
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
cbeg
.
X
,
cbeg
.
Y
,
ctx
->
csbi
.
dwSize
.
X
-
cbeg
.
X
,
&
ci
);
/* completely erase all the others (full lines) */
for
(
i
=
cbeg
.
Y
+
1
;
i
<
cend
.
Y
;
i
++
)
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
0
,
i
,
ctx
->
csbi
.
dwSize
.
X
,
&
ci
);
/* erase from beginning of line until last pos on last line */
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
0
,
cend
.
Y
,
cend
.
X
,
&
ci
);
}
}
ctx
->
len
-=
str_len
;
WCEL_Update
(
ctx
,
0
,
ctx
->
len
);
...
...
@@ -378,7 +384,8 @@ static void WCEL_FindPrevInHist(WCEL_Context* ctx)
ctx
->
ofs
=
0
;
WCEL_InsertString
(
ctx
,
data
);
ctx
->
ofs
=
oldofs
;
SetConsoleCursorPosition
(
ctx
->
hConOut
,
WCEL_GetCoord
(
ctx
,
ctx
->
ofs
));
if
(
ctx
->
shall_echo
)
SetConsoleCursorPosition
(
ctx
->
hConOut
,
WCEL_GetCoord
(
ctx
,
ctx
->
ofs
));
HeapFree
(
GetProcessHeap
(),
0
,
data
);
return
;
}
...
...
@@ -630,15 +637,18 @@ static void WCEL_MoveToLastHist(WCEL_Context* ctx)
static
void
WCEL_Redraw
(
WCEL_Context
*
ctx
)
{
COORD
c
=
WCEL_GetCoord
(
ctx
,
ctx
->
len
);
CHAR_INFO
ci
;
if
(
ctx
->
shall_echo
)
{
COORD
c
=
WCEL_GetCoord
(
ctx
,
ctx
->
len
);
CHAR_INFO
ci
;
WCEL_Update
(
ctx
,
0
,
ctx
->
len
);
WCEL_Update
(
ctx
,
0
,
ctx
->
len
);
ci
.
Char
.
UnicodeChar
=
' '
;
ci
.
Attributes
=
ctx
->
csbi
.
wAttributes
;
ci
.
Char
.
UnicodeChar
=
' '
;
ci
.
Attributes
=
ctx
->
csbi
.
wAttributes
;
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
c
.
X
,
c
.
Y
,
ctx
->
csbi
.
dwSize
.
X
-
c
.
X
,
&
ci
);
CONSOLE_FillLineUniform
(
ctx
->
hConOut
,
c
.
X
,
c
.
Y
,
ctx
->
csbi
.
dwSize
.
X
-
c
.
X
,
&
ci
);
}
}
static
void
WCEL_RepeatCount
(
WCEL_Context
*
ctx
)
...
...
@@ -812,6 +822,7 @@ WCHAR* CONSOLE_Readline(HANDLE hConsoleIn, BOOL can_pos_cursor)
OPEN_EXISTING
,
0
,
0
))
==
INVALID_HANDLE_VALUE
||
!
GetConsoleScreenBufferInfo
(
ctx
.
hConOut
,
&
ctx
.
csbi
))
return
NULL
;
ctx
.
shall_echo
=
(
GetConsoleMode
(
hConsoleIn
,
&
ks
)
&&
(
ks
&
ENABLE_ECHO_INPUT
))
?
1
:
0
;
ctx
.
can_wrap
=
(
GetConsoleMode
(
ctx
.
hConOut
,
&
ks
)
&&
(
ks
&
ENABLE_WRAP_AT_EOL_OUTPUT
))
?
1
:
0
;
ctx
.
can_pos_cursor
=
can_pos_cursor
;
...
...
@@ -868,6 +879,7 @@ WCHAR* CONSOLE_Readline(HANDLE hConsoleIn, BOOL can_pos_cursor)
else
TRACE
(
"Dropped event
\n
"
);
/* EPP WCEL_Dump(&ctx, "after func"); */
if
(
!
ctx
.
shall_echo
)
continue
;
if
(
ctx
.
can_pos_cursor
)
{
if
(
ctx
.
ofs
!=
ofs
)
...
...
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