diff options
| -rw-r--r-- | build.zig | 24 | ||||
| -rw-r--r-- | src/Buffer.zig | 8 | ||||
| -rw-r--r-- | src/Config.zig | 7 |
3 files changed, 26 insertions, 13 deletions
| @@ -1,20 +1,28 @@ | |||
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub fn build(b: *std.build.Builder) void { | 3 | const Builder = std.build.Builder; |
| 4 | const SemanticVersion = std.SemanticVersion; | ||
| 5 | |||
| 6 | const version = "0.3.0"; | ||
| 7 | |||
| 8 | pub fn build(b: *Builder) void { | ||
| 4 | const target = b.standardTargetOptions(.{}); | 9 | const target = b.standardTargetOptions(.{}); |
| 5 | const mode = b.standardReleaseOptions(); | 10 | const mode = b.standardReleaseOptions(); |
| 6 | 11 | ||
| 7 | const options_step = b.addOptions(); | 12 | const options = b.addOptions(); |
| 8 | options_step.addOption(std.SemanticVersion, "es_version", .{ | 13 | options.addOption( |
| 9 | .major = 0, | 14 | SemanticVersion, |
| 10 | .minor = 3, | 15 | "es_version", |
| 11 | .patch = 0, | 16 | SemanticVersion.parse(version) catch unreachable, |
| 12 | }); | 17 | ); |
| 18 | options.addOption(usize, "default_line_limit", 100); | ||
| 19 | options.addOption(usize, "default_page_overlap", 2); | ||
| 20 | options.addOption(usize, "default_tab_stop", 8); | ||
| 13 | 21 | ||
| 14 | const exe = b.addExecutable("es", "src/main.zig"); | 22 | const exe = b.addExecutable("es", "src/main.zig"); |
| 15 | exe.setTarget(target); | 23 | exe.setTarget(target); |
| 16 | exe.setBuildMode(mode); | 24 | exe.setBuildMode(mode); |
| 17 | exe.addOptions("es-config", options_step); | 25 | exe.addOptions("es-config", options); |
| 18 | exe.install(); | 26 | exe.install(); |
| 19 | 27 | ||
| 20 | const run_cmd = exe.run(); | 28 | const run_cmd = exe.run(); |
diff --git a/src/Buffer.zig b/src/Buffer.zig index d7f051d..cb89935 100644 --- a/src/Buffer.zig +++ b/src/Buffer.zig | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | const es_config = @import("es-config"); | 1 | const conf = @import("es-config"); |
| 2 | const std = @import("std"); | 2 | const std = @import("std"); |
| 3 | 3 | ||
| 4 | const Allocator = std.mem.Allocator; | 4 | const Allocator = std.mem.Allocator; |
| @@ -193,7 +193,11 @@ pub fn drawRows(self: Buffer, writer: anytype, screenrows: usize, screencols: us | |||
| 193 | } | 193 | } |
| 194 | } | 194 | } |
| 195 | } else if (self.rows.items.len == 0 and y == screenrows / 3) { | 195 | } else if (self.rows.items.len == 0 and y == screenrows / 3) { |
| 196 | const welcome_data = try std.fmt.allocPrint(self.allocator, "ES -- version {}", .{es_config.es_version}); | 196 | const welcome_data = try std.fmt.allocPrint( |
| 197 | self.allocator, | ||
| 198 | "ES -- version {}", | ||
| 199 | .{conf.es_version}, | ||
| 200 | ); | ||
| 197 | defer self.allocator.free(welcome_data); | 201 | defer self.allocator.free(welcome_data); |
| 198 | var welcome = welcome_data; | 202 | var welcome = welcome_data; |
| 199 | if (welcome.len > screencols - 1) { | 203 | if (welcome.len > screencols - 1) { |
diff --git a/src/Config.zig b/src/Config.zig index 1f11b65..900c2aa 100644 --- a/src/Config.zig +++ b/src/Config.zig | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | // TODO: Change this to proper TOML in the future :) | 1 | // TODO: Change this to proper TOML in the future :) |
| 2 | 2 | ||
| 3 | const conf = @import("es-config"); | ||
| 3 | const std = @import("std"); | 4 | const std = @import("std"); |
| 4 | 5 | ||
| 5 | const Allocator = std.mem.Allocator; | 6 | const Allocator = std.mem.Allocator; |
| @@ -8,9 +9,9 @@ const Config = @This(); | |||
| 8 | 9 | ||
| 9 | const config_path = "arkta/es/es.ini"; | 10 | const config_path = "arkta/es/es.ini"; |
| 10 | 11 | ||
| 11 | line_limit: usize = 100, | 12 | line_limit: usize = conf.default_line_limit, |
| 12 | page_overlap: usize = 2, | 13 | page_overlap: usize = conf.default_page_overlap, |
| 13 | tab_stop: usize = 8, | 14 | tab_stop: usize = conf.default_tab_stop, |
| 14 | 15 | ||
| 15 | pub fn readConfig(allocator: Allocator) !Config { | 16 | pub fn readConfig(allocator: Allocator) !Config { |
| 16 | var config = Config{}; | 17 | var config = Config{}; |