From 5b768d8b9a0603d04fa13dd43579954eeffaab7d Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Mon, 2 Sep 2013 14:30:01 +0000 Subject: [PATCH] Console: correct handeling of escape codes [J, [0J, [1J, [2J git-svn-id: svn://kolibrios.org@3885 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../develop/libraries/console/console.asm | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/programs/develop/libraries/console/console.asm b/programs/develop/libraries/console/console.asm index 2941ffb446..3ab3d69250 100644 --- a/programs/develop/libraries/console/console.asm +++ b/programs/develop/libraries/console/console.asm @@ -820,7 +820,7 @@ con.write_special_char: mov [con_esc], 0 mov [con_sci], 0 ; in any case, leave Esc mode cmp al, 'J' - jz .cls + jz .clear cmp al, 'H' jz .setcursor cmp al, 'f' @@ -836,7 +836,50 @@ con.write_special_char: cmp al, 'D' jz .cursor_left ret ; simply skip unknown sequences -.cls: +.clear: + mov eax, [con_esc_attrs] + test eax, eax + jz .clear_till_end_of_screen ; [0J (or [J) + dec eax + jz .clear_till_start_of_screen ; [1J + dec eax + je .cls ; [2J + ret ; unknown sequence + +.clear_till_end_of_screen: + push edi ecx + mov ecx, [con.scr_width] + imul ecx, [con.scr_height] + + mov edi, [con.cur_y] + imul edi, [con.scr_width] + add edi, [con.cur_x] + + sub ecx, edi + shl edi, 1 + add edi, [con.data] + mov ah, byte[con_flags] + mov al, ' ' + rep stosw + + and [con.cur_x], 0 + and [con.cur_y], 0 + pop ecx edi + ret + +.clear_till_start_of_screen: + push edi ecx + mov ecx, [con.cur_y] + imul ecx, [con.scr_width] + add ecx, [con.cur_x] + mov edi, [con.data] + mov ah, byte[con_flags] + mov al, ' ' + rep stosw + pop ecx edi + ret + +.cls: ; clear screen completely push ecx and [con.cur_x], 0 and [con.cur_y], 0