Просмотр исходного кода

Arrow up works in svim, now wokring on arrow down

jorn_dev
Jørn Guldberg 5 лет назад
Родитель
Сommit
f6b8c72451
1 измененных файлов: 65 добавлений и 14 удалений
  1. +65
    -14
      lib/svim.nasm

+ 65
- 14
lib/svim.nasm Просмотреть файл

@ -190,7 +190,7 @@ svim:
.check_down_key:
cmp ax, 0x50e0 ; down key
jne .no_arrow_key_pressed
call handle_down_key_pressed
jmp .svim_loop
.no_arrow_key_pressed:
cmp ax, 0x11b ; ESC key
@ -342,8 +342,8 @@ handle_up_key_pressed:
call get_cursor_position ; Find the position of the cursor
xor cx, cx
mov cl, dl ; Store coulun count
inc cx
push cx ; save the column count.
inc cx
.find_first_line_break:
cmp BYTE cl, 0
je .find_right_position_on_new_line
@ -353,7 +353,6 @@ handle_up_key_pressed:
.find_right_position_on_new_line:
call svim_get_left_line_count ; updates the value in svim_get_cursor_distance_to_next_line_break
mov ax, [svim_get_cursor_distance_to_next_line_break]
call dumpax
pop cx
.move_curser_to_correct_position_on_the_new_line:
cmp cx, ax
@ -364,18 +363,34 @@ handle_up_key_pressed:
.end:
ret
handle_down_key_pressed:
call get_cursor_position ; Find the position of the cursor
xor cx, cx
mov cl, dl ; Store coulun count
push cx ; save the column count.
inc cx
.find_first_line_break:
cmp BYTE cl, 0
je .end;.find_left_position_on_new_line
call handle_right_key_pressed
dec cl
jmp .find_first_line_break
ret
; .find_left_position_on_new_line:
; call svim_get_right_line_count ; updates the value in svim_get_cursor_distance_to_next_line_break
; mov ax, [svim_get_cursor_distance_to_next_line_break]
; pop cx
; cmp cx, ax
; jg .move_curser_to_correct_position_on_the_new_line
; mov cx, ax
; .move_curser_to_correct_position_on_the_new_line:
; cmp cx, 0
; je .end
; call handle_right_key_pressed
; dec cx
; jmp .move_curser_to_correct_position_on_the_new_line
get_cursor_position:
xor ax, ax
xor bx, bx
mov ah, 0x03
mov bh, 0x00 ; page number 0
int 0x10
.end:
ret
svim_get_left_line_count:
@ -383,12 +398,40 @@ svim_get_left_line_count:
xor ax, ax ; Number of chars in the right side buffer
xor cx, cx ; This is our counter to the next line break
mov ax, [svim_counter_char_in_left_buffer]
mov bx, buffer_for_svim_base_left_of_cursor
mov bx, [buffer_for_svim_base_left_of_cursor]
add bx, ax
dec bx
.check_next:
cmp ax, 0 ; check if we have hit the absolut beginnig of the string
je .end
mov BYTE dl, [bx]
cmp BYTE dl, 10 ; See if we have hit an linebreak
je .end_line_break
dec bx ; dec one, to check the prev char, until we hit a line break.
dec ax
inc cx ; add one to the counter
jmp .check_next
.end_line_break:
;inc cx ; add one to the counter
.end:
mov WORD [svim_get_cursor_distance_to_next_line_break], cx
popa
ret
svim_get_right_line_count:
pusha
xor ax, ax ; Number of chars in the right side buffer
xor cx, cx ; This is our counter to the next line break
mov ax, [svim_counter_char_in_right_buffer]
mov bx, [buffer_for_svim_base_right_of_cursor]
add bx, ax
dec bx
.check_next:
cmp ax, 0 ; check if we have hit the absolut beginnig of the string
je .end
mov BYTE dl, [bx]
cmp BYTE dl, 13 ; See if we have hit an linebreak
je .end_line_break
dec bx ; dec one, to check the prev char, until we hit a line break.
@ -396,12 +439,20 @@ svim_get_left_line_count:
inc cx ; add one to the counter
jmp .check_next
.end_line_break:
inc cx ; add one to the counter
;inc cx ; add one to the counter
.end:
mov WORD [svim_get_cursor_distance_to_next_line_break], cx
popa
ret
get_cursor_position:
xor ax, ax
xor bx, bx
mov ah, 0x03
mov bh, 0x00 ; page number 0
int 0x10
ret
svim_redraw_window:
call os_clear_screen

Загрузка…
Отмена
Сохранить