From 7c645a43ac0fe362145037746ec52b70ff8fe410 Mon Sep 17 00:00:00 2001 From: Grant Horner Date: Sun, 10 May 2026 08:47:32 -0400 Subject: [PATCH] untabify --- edit.jai | 23 +++++++++-------------- test.jai | 17 +++++++---------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/edit.jai b/edit.jai index 35afdac..a3541b2 100644 --- a/edit.jai +++ b/edit.jai @@ -14,13 +14,13 @@ MS_PER_FRAME :: 1000 / FPS; State :: struct { file_name: string; - + cursor_x: int; cursor_y: int; - + window_width: int; window_height: int; - + buffer: string; lines: [..][..]u8; line_height: int; @@ -251,7 +251,7 @@ handle_arrow :: (using state: *State, using event: Input.Event) { if visible_lines.count == 0 return; if key_code == { - case .ARROW_UP; + case .ARROW_UP; if cursor_y == 0 && first_line == 0 return; if cursor_y == 0 { @@ -261,11 +261,8 @@ handle_arrow :: (using state: *State, using event: Input.Event) { } case .ARROW_DOWN; if cursor_y + first_line == lines.count - 1 { - print("End of file?\n"); - print_vars(cursor_y, first_line, visible_lines.count, lines.count); + // End of file? } 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); } else { cursor_y += 1; @@ -295,12 +292,11 @@ handle_arrow :: (using state: *State, using event: Input.Event) { } get_visible_lines :: (using state: State) -> [][..]u8 { + #import "Print_vars"; if line_height <= 1 || window_height == 0 return .[]; num_lines_in_screen := window_height / line_height - 1; - print("num_lines_in_screen: %\n", num_lines_in_screen); - print("first_line: %\n", first_line); - print("lines: %\n", lines); - return array_view(lines, first_line, num_lines_in_screen); + result := array_view(lines, first_line, num_lines_in_screen); + return result; } string_to_line :: (str: string, cursor_char_index := -1) -> string, string { @@ -340,7 +336,7 @@ string_to_line :: (str: string, cursor_char_index := -1) -> string, string { append(current_builder, s); current_builder = *suffix_builder; start = char_index + 1; - } + } } @@ -422,4 +418,3 @@ array_remove_at :: (xs: *[..]$T, index: int) { Input :: #import "Input"; Simp :: #import "Simp"; - diff --git a/test.jai b/test.jai index 6340116..0bafb0c 100644 --- a/test.jai +++ b/test.jai @@ -1,7 +1,7 @@ main :: () { print("\nBeginning tests...\n"); - //test_get_visible_lines(); - //test_handle_arrow_empty_lines(); + test_get_visible_lines(); + test_handle_arrow_empty_lines(); test_handle_arrow_one_line(); print("Tests completed successfully\n"); } @@ -11,7 +11,7 @@ test_get_visible_lines :: () { state.line_height = 10; state.window_height = 100; assert_test(get_visible_lines(state).count == 0); - + line: [..]u8; array_add(*line, array_view("foo")); array_add(*state.lines, line); @@ -26,7 +26,7 @@ test_handle_arrow_empty_lines :: () { codes := Input.Key_Code.[.ARROW_DOWN, .ARROW_UP, .ARROW_LEFT, .ARROW_RIGHT]; for codes { - handle_arrow(*state, .{key_code=it}); + handle_arrow(*state, .{key_code=it}); assert(state.cursor_x == 0 && state.cursor_y == 0, "%: cursor_x % & cursor_y %", it, state.cursor_x, state.cursor_y); } @@ -40,7 +40,7 @@ test_handle_arrow_one_line :: () { state.cursor_x = 0; state.line_height = 10; state.window_height = 100; - + add_line(*state, "foo bar"); codes := Input.Key_Code.[.ARROW_DOWN, .ARROW_UP, .ARROW_LEFT]; @@ -49,18 +49,15 @@ test_handle_arrow_one_line :: () { 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); - assert_test(state.cursor_x == 1 && state.cursor_y == 0); + assert_test(state.cursor_x == 1 && state.cursor_y == 0); print("test_handle_arrow_one_line completed successfully\n"); } assert_test :: (value: bool, $call := #caller_code, loc := #caller_location) { if value == true return; - assert(false, "%\nValue is false.", #run get_expression(call), value, loc = loc); + assert(false, "%\nValue is false.", #run get_expression(call), value, loc = loc); } get_expression :: (call := #caller_code) -> string {