summaryrefslogtreecommitdiff
path: root/src/Editor.zig
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2022-01-02 00:17:47 +0200
committerGravatar Uko Kokņevičs2022-01-02 00:17:47 +0200
commitbd3101517b7b2d0d81f2014eb3c2613e82b25def (patch)
tree72cffbbcdc2be0f22987e1a4cb20892fbc3db052 /src/Editor.zig
parentchanges (diff)
downloades-bd3101517b7b2d0d81f2014eb3c2613e82b25def.tar.gz
es-bd3101517b7b2d0d81f2014eb3c2613e82b25def.tar.xz
es-bd3101517b7b2d0d81f2014eb3c2613e82b25def.zip
hierarchy changes
Diffstat (limited to 'src/Editor.zig')
-rw-r--r--src/Editor.zig23
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 @@
1const linux = std.os.linux; 1const es = @import("root");
2const std = @import("std"); 2const std = @import("std");
3 3
4const Allocator = std.mem.Allocator; 4const Allocator = std.mem.Allocator;
5const ArrayList = std.ArrayList; 5const ArrayList = std.ArrayList;
6const Buffer = @import("Buffer.zig"); 6const Buffer = es.Buffer;
7const Editor = @This(); 7const Editor = @This();
8const files = @import("files.zig"); 8const Key = es.Key;
9const Key = @import("key.zig").Key; 9const KeyState = es.key_state.KeyState;
10const key_state = @import("key_state.zig"); 10const StringBuilder = es.StringBuilder;
11const KeyState = key_state.KeyState;
12const STDIN_FILENO = std.os.STDIN_FILENO;
13const StringBuilder = @import("StringBuilder.zig");
14const StringHashMap = std.StringHashMap; 11const StringHashMap = std.StringHashMap;
15 12
16allocator: Allocator, 13allocator: 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
152pub fn open(self: *Editor, name: []const u8) !void { 149pub 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
413fn getWindowSize(rows: *usize, cols: *usize) !void { 410fn 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;