untabify
This commit is contained in:
23
edit.jai
23
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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user