Console: Bell character support, escape code '<esc>]K' (erase in line) support

git-svn-id: svn://kolibrios.org@9096 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2021-07-28 07:36:54 +00:00
parent 32a304e64b
commit 7f933eb487

View File

@ -43,7 +43,7 @@ con_init:
push ebx push ebx
mov [con.init_cmd],1 mov [con.init_cmd],1
mov ecx, 4 mov ecx, 4
mov eax, con.wnd_width mov eax, con.wnd_width
@ -152,24 +152,24 @@ con_set_cursor_height:
ret 4 ret 4
con_init_check: con_init_check:
mov ah,[con.init_cmd] mov ah,[con.init_cmd]
test ah,ah test ah,ah
jne cmd_init_yes jne cmd_init_yes
push con.title_init_console push con.title_init_console
push -1 push -1
push -1 push -1
push -1 push -1
push -1 push -1
call con_init call con_init
cmd_init_yes: cmd_init_yes:
ret ret
; void __stdcall con_write_asciiz(const char* string); ; void __stdcall con_write_asciiz(const char* string);
con_write_asciiz: con_write_asciiz:
call con_init_check call con_init_check
push ebx esi push ebx esi
or ebx, -1 or ebx, -1
mov esi, [esp+12] mov esi, [esp+12]
@ -265,7 +265,7 @@ con.charjump:
; int __cdecl con_printf(const char* format, ...) ; int __cdecl con_printf(const char* format, ...)
con_printf: con_printf:
call con_init_check call con_init_check
xor eax, eax xor eax, eax
pushad pushad
call con.get_data_ptr call con.get_data_ptr
@ -755,6 +755,8 @@ con.write_special_char:
jz .write_esc jz .write_esc
cmp al, 8 cmp al, 8
jz .write_bs jz .write_bs
cmp al, 7
jz .bell
cmp al, 9 cmp al, 9
jnz con.write_char jnz con.write_char
.write_tab: .write_tab:
@ -790,6 +792,15 @@ con.write_special_char:
@@: @@:
pop eax pop eax
ret ret
.bell:
pusha
push 55
pop eax
mov ebx, eax
mov esi, con.beep2
int 0x40
popa
ret
.write_esc: .write_esc:
mov [con_esc], 1 mov [con_esc], 1
mov [con_esc_attr_n], 1 mov [con_esc_attr_n], 1
@ -868,6 +879,8 @@ con.write_special_char:
je .dec_rst je .dec_rst
cmp al, 'h' cmp al, 'h'
je .dec_set je .dec_set
cmp al, 'K'
je .erase_in_line
ret ; simply skip unknown sequences ret ; simply skip unknown sequences
.dec_rst: .dec_rst:
@ -896,6 +909,58 @@ con.write_special_char:
.show_cursor: .show_cursor:
mov [con.cursor_height], (15*font_height+50)/100 ; default height mov [con.cursor_height], (15*font_height+50)/100 ; default height
ret ret
.erase_in_line:
mov eax, [con_esc_attrs]
test eax, eax
jz .erase_till_end_of_line ; <esc>[0K (or <esc>[K)
dec eax
jz .erase_till_start_of_line ; <esc>[1K
dec eax
je .erase_current_line ; <esc>[2K
ret ; unknown sequence
.erase_till_end_of_line:
push edi ecx
mov edi, [con.cur_y]
imul edi, [con.scr_width]
add edi, [con.cur_x]
shl edi, 1
add edi, [con.data]
mov ecx, [con.scr_width]
sub ecx, [con.cur_x]
mov ah, byte[con_flags]
mov al, ' '
rep stosw
pop ecx edi
ret
.erase_till_start_of_line:
push edi ecx
mov edi, [con.cur_y]
imul edi, [con.scr_width]
shl edi, 1
add edi, [con.data]
mov ecx, [con.cur_y]
mov ah, byte[con_flags]
mov al, ' '
rep stosw
pop ecx edi
ret
.erase_current_line:
push edi ecx
mov edi, [con.cur_y]
imul edi, [con.scr_width]
shl edi, 1
add edi, [con.data]
mov ecx, [con.scr_width]
mov ah, byte[con_flags]
mov al, ' '
rep stosw
pop ecx edi
ret
.clear: .clear:
mov eax, [con_esc_attrs] mov eax, [con_esc_attrs]
test eax, eax test eax, eax
@ -1309,16 +1374,16 @@ end if
ret ret
con_exit: con_exit:
mov ah,[con.init_cmd] mov ah,[con.init_cmd]
test ah,ah test ah,ah
je .ret je .ret
cmp byte [esp+4], 0 cmp byte [esp+4], 0
jz .noexit jz .noexit
mov [con.thread_op], 1 mov [con.thread_op], 1
call con.wake call con.wake
ret 4 ret 4
.noexit: .noexit:
push esi push esi
@ -1387,7 +1452,7 @@ con.force_entered_char:
; int __stdcall con_getch(void); ; int __stdcall con_getch(void);
con_getch: con_getch:
call con_init_check call con_init_check
call con.force_entered_char call con.force_entered_char
test byte [con_flags+1], 2 test byte [con_flags+1], 2
jnz con_getch_closed jnz con_getch_closed
@ -1406,7 +1471,7 @@ con_getch_closed:
; int __stdcall con_getch2(void); ; int __stdcall con_getch2(void);
con_getch2: con_getch2:
call con_init_check call con_init_check
call con.force_entered_char call con.force_entered_char
test byte [con_flags+1], 2 test byte [con_flags+1], 2
jnz con_getch_closed jnz con_getch_closed
@ -1421,7 +1486,7 @@ con_gets:
push eax push eax
; char* __stdcall con_gets2(con_gets2_callback callback, char* str, int n); ; char* __stdcall con_gets2(con_gets2_callback callback, char* str, int n);
con_gets2: con_gets2:
call con_init_check call con_init_check
mov eax, [esp+8] ; str mov eax, [esp+8] ; str
pushad pushad
mov esi, eax ; str mov esi, eax ; str
@ -1738,27 +1803,27 @@ con_gets2:
; void __stdcall con_cls(); ; void __stdcall con_cls();
con_cls: con_cls:
mov ah,[con.init_cmd] mov ah,[con.init_cmd]
test ah,ah test ah,ah
je cmd_init_no je cmd_init_no
push edi push edi
call con.write_special_char.cls call con.write_special_char.cls
pop edi pop edi
call con.update_screen call con.update_screen
ret ret
cmd_init_no: cmd_init_no:
push con.title_init_console push con.title_init_console
push -1 push -1
push -1 push -1
push -1 push -1
push -1 push -1
call con_init call con_init
ret ret
; void __stdcall con_get_cursor_pos(int* px, int* py); ; void __stdcall con_get_cursor_pos(int* px, int* py);
@ -2647,7 +2712,8 @@ con.thread_err db 'Cannot create console thread!',13,10,0
con.nomem_err db 'Not enough memory!',13,10,0 con.nomem_err db 'Not enough memory!',13,10,0
con.aFinished db ' [Finished]',0 con.aFinished db ' [Finished]',0
con.aNull db '(null)',0 con.aNull db '(null)',0
con.beep db 0x90, 0x3C, 0x00 con.beep db 0x90, 0x3C, 0x00
con.beep2 db 0x85, 0x25, 0x85, 0x40, 0x00
con.ipc_buf dd 0,8,0,0 con.ipc_buf dd 0,8,0,0
db 0 db 0