Skip to content

Commit

Permalink
Release 0.1.1
Browse files Browse the repository at this point in the history
- Added better error handling.
- Added new config style for error bar.
- Updated README to include config schema.
  • Loading branch information
BrookJeynes committed May 25, 2024
1 parent 95ee082 commit 255c831
Show file tree
Hide file tree
Showing 7 changed files with 267 additions and 154 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,54 @@ Configure `zfe` by editing the external configuration file located at either:
- `$HOME/.zfe/config.json`
- `$XDG_CONFIG_HOME/zfe/config.json`.

An example config file can be found [here](https://github.com/BrookJeynes/zfe/blob/main/example-config.json).

Config schema:
```
Config = struct {
.show_hidden: bool,
.sort_dirs: bool,
.show_images: bool,
.preview_file: bool,
.styles: Styles,
}
Styles = struct {
.selected_list_item: Style,
.list_item: Style,
.file_name: Style,
.file_information: Style
.error_bar: Style,
}
Style = struct {
.fg: Color,
.bg: Color,
.ul: Color,
.ul_style = .{
off,
single,
double,
curly,
dotted,
dashed,
}
.bold: bool,
.dim: bool,
.italic: bool,
.blink: bool,
.reverse: bool,
.invisible: bool,
.strikethrough: bool,
}
Color = enum{
default,
index: u8,
rgb: [3]u8,
}
```

## Keybinds
```
j / <Down> :Go down.
Expand Down
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const std = @import("std");
const builtin = @import("builtin");

const min_zig_string = "0.12.0";
const version = std.SemanticVersion{ .major = 0, .minor = 1, .patch = 0 };
const version = std.SemanticVersion{ .major = 0, .minor = 1, .patch = 1 };

const targets: []const std.Target.Query = &.{
.{ .cpu_arch = .aarch64, .os_tag = .macos },
Expand Down
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.{
.name = "zfe",
.version = "0.1.0",
.version = "0.1.1",

.minimum_zig_version = "0.12.0",

Expand Down
3 changes: 3 additions & 0 deletions src/config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const Styles = struct {
.fg = .{ .rgb = .{ 0, 0, 0 } },
.bg = .{ .rgb = .{ 255, 255, 255 } },
},
error_bar: vaxis.Style = vaxis.Style{
.bg = .{ .rgb = .{ 216, 74, 74 } },
},
};

pub var config: Config = Config{ .styles = Styles{} };
39 changes: 0 additions & 39 deletions src/list.zig
Original file line number Diff line number Diff line change
Expand Up @@ -78,44 +78,5 @@ pub fn List(comptime T: type) type {
self.selected = 0;
self.offset = 0;
}

// TODO: Move to view, the list should not have to care about this.
pub fn render(
self: *Self,
window: vaxis.Window,
comptime field: ?[]const u8,
style: ?vaxis.Style,
selected_item_style: ?vaxis.Style,
callback: ?*const fn (item_win: vaxis.Window) void,
) !void {
if (self.items.items.len != 0) {
for (self.items.items[self.offset..], 0..) |item, i| {
const is_selected = self.selected - self.offset == i;

if (i > window.height) {
continue;
}

const w = window.child(.{
.y_off = i,
.height = .{ .limit = 1 },
});
w.fill(vaxis.Cell{
.style = if (is_selected) selected_item_style orelse .{} else style orelse .{},
});

if (callback) |cb| {
cb(w);
}

_ = try w.print(&.{
.{
.text = if (field) |f| @field(item, f) else item,
.style = if (is_selected) selected_item_style orelse .{} else style orelse style orelse .{},
},
}, .{});
}
}
}
};
}
Loading

0 comments on commit 255c831

Please sign in to comment.