diff options
| author | 2022-01-02 00:17:47 +0200 | |
|---|---|---|
| committer | 2022-01-02 00:17:47 +0200 | |
| commit | bd3101517b7b2d0d81f2014eb3c2613e82b25def (patch) | |
| tree | 72cffbbcdc2be0f22987e1a4cb20892fbc3db052 /src/Editor.zig | |
| parent | changes (diff) | |
| download | es-bd3101517b7b2d0d81f2014eb3c2613e82b25def.tar.gz es-bd3101517b7b2d0d81f2014eb3c2613e82b25def.tar.xz es-bd3101517b7b2d0d81f2014eb3c2613e82b25def.zip | |
hierarchy changes
Diffstat (limited to 'src/Editor.zig')
| -rw-r--r-- | src/Editor.zig | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/Editor.zig b/src/Editor.zig index 42b5619..4b563ad 100644 --- a/src/Editor.zig +++ b/src/Editor.zig | |||
| @@ -1,16 +1,13 @@ | |||
| 1 | const linux = std.os.linux; | 1 | const es = @import("root"); |
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | 3 | ||
| 4 | const Allocator = std.mem.Allocator; | 4 | const Allocator = std.mem.Allocator; |
| 5 | const ArrayList = std.ArrayList; | 5 | const ArrayList = std.ArrayList; |
| 6 | const Buffer = @import("Buffer.zig"); | 6 | const Buffer = es.Buffer; |
| 7 | const Editor = @This(); | 7 | const Editor = @This(); |
| 8 | const files = @import("files.zig"); | 8 | const Key = es.Key; |
| 9 | const Key = @import("key.zig").Key; | 9 | const KeyState = es.key_state.KeyState; |
| 10 | const key_state = @import("key_state.zig"); | 10 | const StringBuilder = es.StringBuilder; |
| 11 | const KeyState = key_state.KeyState; | ||
| 12 | const STDIN_FILENO = std.os.STDIN_FILENO; | ||
| 13 | const StringBuilder = @import("StringBuilder.zig"); | ||
| 14 | const StringHashMap = std.StringHashMap; | 11 | const StringHashMap = std.StringHashMap; |
| 15 | 12 | ||
| 16 | allocator: Allocator, | 13 | allocator: Allocator, |
| @@ -42,7 +39,7 @@ pub fn init(allocator: Allocator) !Editor { | |||
| 42 | .statusmsg = null, | 39 | .statusmsg = null, |
| 43 | .statusmsg_time = 0, | 40 | .statusmsg_time = 0, |
| 44 | 41 | ||
| 45 | .current_state = key_state.defaultState, | 42 | .current_state = es.key_state.defaultState, |
| 46 | 43 | ||
| 47 | .key_buffer = ArrayList(Key).init(allocator), | 44 | .key_buffer = ArrayList(Key).init(allocator), |
| 48 | .should_exit = false, | 45 | .should_exit = false, |
| @@ -150,7 +147,7 @@ pub fn killCurrentBuffer(self: *Editor) !bool { | |||
| 150 | } | 147 | } |
| 151 | 148 | ||
| 152 | pub fn open(self: *Editor, name: []const u8) !void { | 149 | pub fn open(self: *Editor, name: []const u8) !void { |
| 153 | const file_path = try files.resolvePath(self.allocator, name); | 150 | const file_path = try es.files.resolvePath(self.allocator, name); |
| 154 | defer self.allocator.free(file_path); | 151 | defer self.allocator.free(file_path); |
| 155 | 152 | ||
| 156 | if (self.getBufferByPath(file_path)) |buffer| { | 153 | if (self.getBufferByPath(file_path)) |buffer| { |
| @@ -411,9 +408,9 @@ fn getCursorPosition(row: *usize, col: *usize) !void { | |||
| 411 | } | 408 | } |
| 412 | 409 | ||
| 413 | fn getWindowSize(rows: *usize, cols: *usize) !void { | 410 | fn getWindowSize(rows: *usize, cols: *usize) !void { |
| 414 | var ws: linux.winsize = undefined; | 411 | var ws: std.os.linux.winsize = undefined; |
| 415 | const rc = linux.ioctl(STDIN_FILENO, linux.T.IOCGWINSZ, @ptrToInt(&ws)); | 412 | const rc = std.os.linux.ioctl(std.os.STDIN_FILENO, std.os.linux.T.IOCGWINSZ, @ptrToInt(&ws)); |
| 416 | switch (linux.getErrno(rc)) { | 413 | switch (std.os.linux.getErrno(rc)) { |
| 417 | .SUCCESS => { | 414 | .SUCCESS => { |
| 418 | cols.* = ws.ws_col; | 415 | cols.* = ws.ws_col; |
| 419 | rows.* = ws.ws_row; | 416 | rows.* = ws.ws_row; |