refactor: clean-up flow logo rendering
This commit is contained in:
parent
b831d99d1c
commit
08e06bc8dd
7 changed files with 35 additions and 13 deletions
|
@ -17,7 +17,6 @@ pub var max_diff_lines: usize = 50000;
|
||||||
pub var max_syntax_lines: usize = 50000;
|
pub var max_syntax_lines: usize = 50000;
|
||||||
|
|
||||||
pub const application_name = "flow";
|
pub const application_name = "flow";
|
||||||
pub const application_logo = " ";
|
|
||||||
|
|
||||||
pub const std_options = .{
|
pub const std_options = .{
|
||||||
// .log_level = if (builtin.mode == .Debug) .debug else .warn,
|
// .log_level = if (builtin.mode == .Debug) .debug else .warn,
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub fn create(a: Allocator) !tui.Mode {
|
||||||
};
|
};
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = root.application_logo ++ root.application_name,
|
.name = root.application_name,
|
||||||
.description = "default",
|
.description = "default",
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub fn create(a: std.mem.Allocator) !tui.Mode {
|
||||||
};
|
};
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = root.application_logo ++ root.application_name,
|
.name = root.application_name,
|
||||||
.description = "home",
|
.description = "home",
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const tp = @import("thespian");
|
const tp = @import("thespian");
|
||||||
const root = @import("root");
|
|
||||||
|
|
||||||
const key = @import("renderer").input.key;
|
const key = @import("renderer").input.key;
|
||||||
const mod = @import("renderer").input.modifier;
|
const mod = @import("renderer").input.modifier;
|
||||||
|
@ -33,7 +32,7 @@ pub fn create(a: Allocator) !tui.Mode {
|
||||||
try self.commands.init(self);
|
try self.commands.init(self);
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = root.application_logo ++ "INSERT",
|
.name = "INSERT",
|
||||||
.description = "vim",
|
.description = "vim",
|
||||||
.line_numbers = if (tui.current().config.vim_insert_gutter_line_numbers_relative) .relative else .absolute,
|
.line_numbers = if (tui.current().config.vim_insert_gutter_line_numbers_relative) .relative else .absolute,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const tp = @import("thespian");
|
const tp = @import("thespian");
|
||||||
const root = @import("root");
|
|
||||||
|
|
||||||
const key = @import("renderer").input.key;
|
const key = @import("renderer").input.key;
|
||||||
const mod = @import("renderer").input.modifier;
|
const mod = @import("renderer").input.modifier;
|
||||||
|
@ -34,7 +33,7 @@ pub fn create(a: Allocator) !tui.Mode {
|
||||||
try self.commands.init(self);
|
try self.commands.init(self);
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = root.application_logo ++ "NORMAL",
|
.name = "NORMAL",
|
||||||
.description = "vim",
|
.description = "vim",
|
||||||
.line_numbers = if (tui.current().config.vim_normal_gutter_line_numbers_relative) .relative else .absolute,
|
.line_numbers = if (tui.current().config.vim_normal_gutter_line_numbers_relative) .relative else .absolute,
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
const tp = @import("thespian");
|
const tp = @import("thespian");
|
||||||
const root = @import("root");
|
|
||||||
|
|
||||||
const key = @import("renderer").input.key;
|
const key = @import("renderer").input.key;
|
||||||
const mod = @import("renderer").input.modifier;
|
const mod = @import("renderer").input.modifier;
|
||||||
|
@ -34,7 +33,7 @@ pub fn create(a: Allocator) !tui.Mode {
|
||||||
try self.commands.init(self);
|
try self.commands.init(self);
|
||||||
return .{
|
return .{
|
||||||
.handler = EventHandler.to_owned(self),
|
.handler = EventHandler.to_owned(self),
|
||||||
.name = root.application_logo ++ "VISUAL",
|
.name = "VISUAL",
|
||||||
.description = "vim",
|
.description = "vim",
|
||||||
.line_numbers = if (tui.current().config.vim_visual_gutter_line_numbers_relative) .relative else .absolute,
|
.line_numbers = if (tui.current().config.vim_visual_gutter_line_numbers_relative) .relative else .absolute,
|
||||||
.keybind_hints = &hints,
|
.keybind_hints = &hints,
|
||||||
|
|
|
@ -28,8 +28,10 @@ pub fn create(a: Allocator, parent: Plane, event_handler: ?Widget.EventHandler)
|
||||||
pub fn layout(_: *void, btn: *Button.State(void)) Widget.Layout {
|
pub fn layout(_: *void, btn: *Button.State(void)) Widget.Layout {
|
||||||
const name = tui.get_mode();
|
const name = tui.get_mode();
|
||||||
const width = btn.plane.egc_chunk_width(name, 0);
|
const width = btn.plane.egc_chunk_width(name, 0);
|
||||||
const padding: usize = if (is_mini_mode()) 3 else 2;
|
const logo = btn.plane.egc_chunk_width(left ++ symbol ++ right, 0);
|
||||||
return .{ .static = width + padding };
|
const padding: usize = 2;
|
||||||
|
const minimode_sep: usize = if (is_mini_mode()) 1 else 0;
|
||||||
|
return .{ .static = logo + width + padding + minimode_sep };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_mini_mode() bool {
|
fn is_mini_mode() bool {
|
||||||
|
@ -41,12 +43,16 @@ fn is_overlay_mode() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render(_: *void, self: *Button.State(void), theme: *const Widget.Theme) bool {
|
pub fn render(_: *void, self: *Button.State(void), theme: *const Widget.Theme) bool {
|
||||||
self.plane.set_base_style(" ", if (self.active) theme.editor_cursor else if (self.hover) theme.editor_selection else theme.statusbar_hover);
|
const base_style = if (self.active) theme.editor_cursor else if (self.hover) theme.editor_selection else theme.statusbar_hover;
|
||||||
|
self.plane.set_base_style(" ", base_style);
|
||||||
self.plane.on_styles(style.bold);
|
self.plane.on_styles(style.bold);
|
||||||
self.plane.erase();
|
self.plane.erase();
|
||||||
self.plane.home();
|
self.plane.home();
|
||||||
var buf: [31:0]u8 = undefined;
|
var buf: [31:0]u8 = undefined;
|
||||||
_ = self.plane.putstr(std.fmt.bufPrintZ(&buf, " {s} ", .{tui.get_mode()}) catch return false) catch {};
|
render_logo(self, theme, base_style);
|
||||||
|
self.plane.set_base_style(" ", base_style);
|
||||||
|
self.plane.on_styles(style.bold);
|
||||||
|
_ = self.plane.putstr(std.fmt.bufPrintZ(&buf, "{s} ", .{tui.get_mode()}) catch return false) catch {};
|
||||||
if (is_mini_mode())
|
if (is_mini_mode())
|
||||||
render_separator(self, theme);
|
render_separator(self, theme);
|
||||||
return false;
|
return false;
|
||||||
|
@ -58,6 +64,26 @@ fn render_separator(self: *Button.State(void), theme: *const Widget.Theme) void
|
||||||
_ = self.plane.putstr("") catch {};
|
_ = self.plane.putstr("") catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const left = " ";
|
||||||
|
const symbol = "";
|
||||||
|
const right = " ";
|
||||||
|
|
||||||
|
fn render_logo(self: *Button.State(void), theme: *const Widget.Theme, base_style: Widget.Theme.Style) void {
|
||||||
|
// const style_symbol: Widget.Theme.Style = if (tui.find_scope_style(theme, "number")) |sty| .{ .fg = sty.style.fg, .bg = base_style.bg, .fs = base_style.fs } else base_style;
|
||||||
|
const style_symbol = if (self.active) theme.editor_cursor else if (self.hover) theme.editor_selection else theme.statusbar_hover;
|
||||||
|
const style_braces: Widget.Theme.Style = if (tui.find_scope_style(theme, "punctuation")) |sty| .{ .fg = sty.style.fg, .bg = base_style.bg, .fs = base_style.fs } else base_style;
|
||||||
|
if (left.len > 0) {
|
||||||
|
self.plane.set_style(style_braces);
|
||||||
|
_ = self.plane.putstr(" " ++ left) catch {};
|
||||||
|
}
|
||||||
|
self.plane.set_style(style_symbol);
|
||||||
|
_ = self.plane.putstr(symbol) catch {};
|
||||||
|
if (right.len > 0) {
|
||||||
|
self.plane.set_style(style_braces);
|
||||||
|
_ = self.plane.putstr(right) catch {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn on_click(_: *void, _: *Button.State(void)) void {
|
fn on_click(_: *void, _: *Button.State(void)) void {
|
||||||
if (is_mini_mode()) {
|
if (is_mini_mode()) {
|
||||||
command.executeName("exit_mini_mode", .{}) catch {};
|
command.executeName("exit_mini_mode", .{}) catch {};
|
||||||
|
|
Loading…
Add table
Reference in a new issue