[PATCH 6/7] [Kernel32]: in console edition mode, speed up update of edited line when appending characters
Eric Pouech
eric.pouech at orange.fr
Sat Dec 29 09:21:53 CST 2012
A+
---
dlls/kernel32/editline.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/dlls/kernel32/editline.c b/dlls/kernel32/editline.c
index 2a69f86..c9465ff 100644
--- a/dlls/kernel32/editline.c
+++ b/dlls/kernel32/editline.c
@@ -1002,23 +1002,32 @@ WCHAR* CONSOLE_Readline(HANDLE hConsoleIn)
}
else if (!ctx.done && !ctx.error)
{
- DWORD last;
- /* erase previous chars */
- WCEL_WriteNChars(&ctx, '\b', ctx.last_rub);
-
- /* write chars up to cursor */
- ctx.last_rub = WCEL_WriteConsole(&ctx, 0, ctx.ofs);
- /* write chars past cursor */
- last = ctx.last_rub + WCEL_WriteConsole(&ctx, ctx.ofs, ctx.len - ctx.ofs);
- if (last < ctx.last_max) /* ctx.line has been shortened, erase */
+ /* if we've just appended a last character, simply do it */
+ if (ctx.ofs && ctx.ofs == ctx.len && !func && !(ir.Event.KeyEvent.dwControlKeyState & LEFT_ALT_PRESSED))
{
- WCEL_WriteNChars(&ctx, ' ', ctx.last_max - last);
- WCEL_WriteNChars(&ctx, '\b', ctx.last_max - last);
- ctx.last_max = last;
+ ctx.last_rub += WCEL_WriteConsole(&ctx, ctx.ofs - 1, 1);
+ ctx.last_max = ctx.last_rub;
+ }
+ else
+ {
+ DWORD last;
+ /* erase previous chars */
+ WCEL_WriteNChars(&ctx, '\b', ctx.last_rub);
+
+ /* write chars up to cursor */
+ ctx.last_rub = WCEL_WriteConsole(&ctx, 0, ctx.ofs);
+ /* write chars past cursor */
+ last = ctx.last_rub + WCEL_WriteConsole(&ctx, ctx.ofs, ctx.len - ctx.ofs);
+ if (last < ctx.last_max) /* ctx.line has been shortened, erase */
+ {
+ WCEL_WriteNChars(&ctx, ' ', ctx.last_max - last);
+ WCEL_WriteNChars(&ctx, '\b', ctx.last_max - last);
+ ctx.last_max = last;
+ }
+ else ctx.last_max = last;
+ /* reposition at cursor */
+ WCEL_WriteNChars(&ctx, '\b', last - ctx.last_rub);
}
- else ctx.last_max = last;
- /* reposition at cursor */
- WCEL_WriteNChars(&ctx, '\b', last - ctx.last_rub);
}
}
if (ctx.error)
More information about the wine-patches
mailing list