wip
This commit is contained in:
6
edit.jai
6
edit.jai
@@ -245,7 +245,7 @@ handle_arrow :: (state: *State, key_code: Input.Key_Code) {
|
||||
|
||||
handle_arrow :: (using state: *State, using event: Input.Event) {
|
||||
visible_lines := get_visible_lines(state);
|
||||
|
||||
if visible_lines.count == 0 return;
|
||||
|
||||
if key_code == {
|
||||
case .ARROW_UP;
|
||||
@@ -259,7 +259,8 @@ handle_arrow :: (using state: *State, using event: Input.Event) {
|
||||
case .ARROW_DOWN;
|
||||
if cursor_y == visible_lines.count - 1 {
|
||||
first_line = min(first_line + 1, lines.count);
|
||||
} else {
|
||||
} else if cursor_y + first_line + visible_lines.count >= lines.count {
|
||||
} else {
|
||||
cursor_y += 1;
|
||||
}
|
||||
|
||||
@@ -287,6 +288,7 @@ handle_arrow :: (using state: *State, using event: Input.Event) {
|
||||
}
|
||||
|
||||
get_visible_lines :: (using state: State) -> [][..]u8 {
|
||||
if line_height <= 1 || window_height == 0 return .[];
|
||||
num_lines_in_screen := window_height / line_height - 1;
|
||||
return array_view(lines, first_line, num_lines_in_screen);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user