This commit is contained in:
2026-05-10 08:47:32 -04:00
parent d6bee8b2e2
commit 7c645a43ac
2 changed files with 16 additions and 24 deletions

View File

@@ -261,11 +261,8 @@ handle_arrow :: (using state: *State, using event: Input.Event) {
} }
case .ARROW_DOWN; case .ARROW_DOWN;
if cursor_y + first_line == lines.count - 1 { if cursor_y + first_line == lines.count - 1 {
print("End of file?\n"); // End of file?
print_vars(cursor_y, first_line, visible_lines.count, lines.count);
} else if cursor_y == visible_lines.count - 1 { } else if cursor_y == visible_lines.count - 1 {
print("increasing first line\n");
print_vars(cursor_y, visible_lines.count);
first_line = min(first_line + 1, lines.count); first_line = min(first_line + 1, lines.count);
} else { } else {
cursor_y += 1; cursor_y += 1;
@@ -295,12 +292,11 @@ handle_arrow :: (using state: *State, using event: Input.Event) {
} }
get_visible_lines :: (using state: State) -> [][..]u8 { get_visible_lines :: (using state: State) -> [][..]u8 {
#import "Print_vars";
if line_height <= 1 || window_height == 0 return .[]; if line_height <= 1 || window_height == 0 return .[];
num_lines_in_screen := window_height / line_height - 1; num_lines_in_screen := window_height / line_height - 1;
print("num_lines_in_screen: %\n", num_lines_in_screen); result := array_view(lines, first_line, num_lines_in_screen);
print("first_line: %\n", first_line); return result;
print("lines: %\n", lines);
return array_view(lines, first_line, num_lines_in_screen);
} }
string_to_line :: (str: string, cursor_char_index := -1) -> string, string { string_to_line :: (str: string, cursor_char_index := -1) -> string, string {
@@ -422,4 +418,3 @@ array_remove_at :: (xs: *[..]$T, index: int) {
Input :: #import "Input"; Input :: #import "Input";
Simp :: #import "Simp"; Simp :: #import "Simp";

View File

@@ -1,7 +1,7 @@
main :: () { main :: () {
print("\nBeginning tests...\n"); print("\nBeginning tests...\n");
//test_get_visible_lines(); test_get_visible_lines();
//test_handle_arrow_empty_lines(); test_handle_arrow_empty_lines();
test_handle_arrow_one_line(); test_handle_arrow_one_line();
print("Tests completed successfully\n"); print("Tests completed successfully\n");
} }
@@ -49,9 +49,6 @@ test_handle_arrow_one_line :: () {
assert(state.cursor_x == 0 && state.cursor_y == 0); assert(state.cursor_x == 0 && state.cursor_y == 0);
} }
print("lines: %\n", state.lines);
print("visible_lines: %\n", get_visible_lines(state));
handle_arrow(*state, .ARROW_RIGHT); handle_arrow(*state, .ARROW_RIGHT);
assert_test(state.cursor_x == 1 && state.cursor_y == 0); assert_test(state.cursor_x == 1 && state.cursor_y == 0);