untabify
This commit is contained in:
13
edit.jai
13
edit.jai
@@ -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 {
|
||||
@@ -422,4 +418,3 @@ array_remove_at :: (xs: *[..]$T, index: int) {
|
||||
|
||||
Input :: #import "Input";
|
||||
Simp :: #import "Simp";
|
||||
|
||||
|
||||
9
test.jai
9
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");
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -49,9 +49,6 @@ 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user