Merge branch 'master' into terminal
This commit is contained in:
commit
524372ed33
4 changed files with 23 additions and 10 deletions
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.syntax = .{
|
.syntax = .{
|
||||||
.url = "git+https://github.com/neurocyte/flow-syntax?ref=master#272a2d0b01f708dcd02d43c2ed997fd7b82d6224",
|
.url = "git+https://github.com/neurocyte/flow-syntax?ref=master#56929f0c523b59153e17919be2cd09d8bef32cd0",
|
||||||
.hash = "flow_syntax-0.7.2-X8jOoeFTAQAHSg9vmbAahKdrA8DDf0N-MJl8l09vMDZh",
|
.hash = "flow_syntax-0.7.2-X8jOoeFTAQBeP2Tn08Tw1jsMdifLEDBgPLqPqNelAupy",
|
||||||
},
|
},
|
||||||
.flags = .{
|
.flags = .{
|
||||||
.url = "git+https://github.com/neurocyte/flags?ref=main#984b27948da3e4e40a253f76c85b51ec1a9ada11",
|
.url = "git+https://github.com/neurocyte/flags?ref=main#984b27948da3e4e40a253f76c85b51ec1a9ada11",
|
||||||
|
|
|
||||||
|
|
@ -167,13 +167,12 @@ pub fn guess_file_type(file_path: ?[]const u8, content: []const u8) ?@This() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn guess(file_path: ?[]const u8, content: []const u8) ?@This() {
|
fn guess(file_path: ?[]const u8, content: []const u8) ?@This() {
|
||||||
if (guess_first_line(content)) |ft| return ft;
|
|
||||||
for (get_all_names()) |file_type_name| {
|
for (get_all_names()) |file_type_name| {
|
||||||
const file_type = get(file_type_name) catch unreachable orelse unreachable;
|
const file_type = get(file_type_name) catch unreachable orelse unreachable;
|
||||||
if (file_path) |fp| if (syntax.FileType.match_file_type(file_type.extensions orelse continue, fp))
|
if (file_path) |fp| if (syntax.FileType.match_file_type(file_type.extensions orelse continue, fp))
|
||||||
return file_type;
|
return file_type;
|
||||||
}
|
}
|
||||||
return null;
|
return guess_first_line(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn guess_first_line(content: []const u8) ?@This() {
|
fn guess_first_line(content: []const u8) ?@This() {
|
||||||
|
|
|
||||||
12
src/git.zig
12
src/git.zig
|
|
@ -385,10 +385,20 @@ fn get_git() ?[]const u8 {
|
||||||
|
|
||||||
pub fn blame(context_: usize, file_path: []const u8) !void {
|
pub fn blame(context_: usize, file_path: []const u8) !void {
|
||||||
const tag = @src().fn_name;
|
const tag = @src().fn_name;
|
||||||
|
const dir_path = std.fs.path.dirname(file_path) orelse ".";
|
||||||
|
const basename = std.fs.path.basename(file_path);
|
||||||
|
|
||||||
var arg: std.Io.Writer.Allocating = .init(allocator);
|
var arg: std.Io.Writer.Allocating = .init(allocator);
|
||||||
|
var arg2: std.Io.Writer.Allocating = .init(allocator);
|
||||||
defer arg.deinit();
|
defer arg.deinit();
|
||||||
try arg.writer.print("{s}", .{file_path});
|
defer arg2.deinit();
|
||||||
|
|
||||||
|
try arg.writer.print("{s}", .{basename});
|
||||||
|
try arg2.writer.print("{s}", .{dir_path});
|
||||||
|
|
||||||
try git(context_, .{
|
try git(context_, .{
|
||||||
|
"-C",
|
||||||
|
arg2.written(),
|
||||||
"blame",
|
"blame",
|
||||||
"--incremental",
|
"--incremental",
|
||||||
"HEAD",
|
"HEAD",
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ padding: ?usize,
|
||||||
leader: ?Leader,
|
leader: ?Leader,
|
||||||
style: ?DigitStyle,
|
style: ?DigitStyle,
|
||||||
mode: ?Mode,
|
mode: ?Mode,
|
||||||
|
col0: ?bool,
|
||||||
|
|
||||||
const Leader = enum {
|
const Leader = enum {
|
||||||
space,
|
space,
|
||||||
|
|
@ -45,15 +46,16 @@ const Self = @This();
|
||||||
const ButtonType = Button.Options(Self).ButtonType;
|
const ButtonType = Button.Options(Self).ButtonType;
|
||||||
|
|
||||||
pub fn create(allocator: Allocator, parent: Plane, event_handler: ?EventHandler, arg: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
pub fn create(allocator: Allocator, parent: Plane, event_handler: ?EventHandler, arg: ?[]const u8) @import("widget.zig").CreateError!Widget {
|
||||||
const padding: ?usize, const leader: ?Leader, const style: ?DigitStyle, const mode: ?Mode = if (arg) |fmt| blk: {
|
const padding: ?usize, const leader: ?Leader, const style: ?DigitStyle, const mode: ?Mode, const col0: ?bool = if (arg) |fmt| blk: {
|
||||||
var it = std.mem.splitScalar(u8, fmt, ',');
|
var it = std.mem.splitScalar(u8, fmt, ',');
|
||||||
break :blk .{
|
break :blk .{
|
||||||
if (it.next()) |size| std.fmt.parseInt(usize, size, 10) catch null else null,
|
if (it.next()) |size| std.fmt.parseInt(usize, size, 10) catch null else null,
|
||||||
if (it.next()) |leader| std.meta.stringToEnum(Leader, leader) orelse null else null,
|
if (it.next()) |leader| std.meta.stringToEnum(Leader, leader) orelse null else null,
|
||||||
if (it.next()) |style| std.meta.stringToEnum(DigitStyle, style) orelse null else null,
|
if (it.next()) |style| std.meta.stringToEnum(DigitStyle, style) orelse null else null,
|
||||||
if (it.next()) |mode| std.meta.stringToEnum(Mode, mode) orelse null else null,
|
if (it.next()) |mode| std.meta.stringToEnum(Mode, mode) orelse null else null,
|
||||||
|
if (it.next()) |col0| std.mem.eql(u8, col0, "true") else null,
|
||||||
};
|
};
|
||||||
} else .{ null, null, null, null };
|
} else .{ null, null, null, null, null };
|
||||||
|
|
||||||
return Button.create_widget(Self, allocator, parent, .{
|
return Button.create_widget(Self, allocator, parent, .{
|
||||||
.ctx = .{
|
.ctx = .{
|
||||||
|
|
@ -61,6 +63,7 @@ pub fn create(allocator: Allocator, parent: Plane, event_handler: ?EventHandler,
|
||||||
.leader = leader,
|
.leader = leader,
|
||||||
.style = style,
|
.style = style,
|
||||||
.mode = mode,
|
.mode = mode,
|
||||||
|
.col0 = col0,
|
||||||
},
|
},
|
||||||
.label = "",
|
.label = "",
|
||||||
.on_click = on_click,
|
.on_click = on_click,
|
||||||
|
|
@ -110,18 +113,19 @@ fn format(self: *Self) void {
|
||||||
};
|
};
|
||||||
writer.print("{s}{s} ", .{ eol_mode, indent_mode }) catch {};
|
writer.print("{s}{s} ", .{ eol_mode, indent_mode }) catch {};
|
||||||
|
|
||||||
|
const displayColumn = if (self.col0 orelse false) self.column else self.column + 1;
|
||||||
(blk: switch (self.mode orelse .default) {
|
(blk: switch (self.mode orelse .default) {
|
||||||
.default => writer.print("Ln {f}, Col {f} ", .{
|
.default => writer.print("Ln {f}, Col {f} ", .{
|
||||||
digits_fmt(self, self.line + 1),
|
digits_fmt(self, self.line + 1),
|
||||||
digits_fmt(self, self.column + 1),
|
digits_fmt(self, displayColumn),
|
||||||
}),
|
}),
|
||||||
.compact => writer.print(" {f}:{f} ", .{
|
.compact => writer.print(" {f}:{f} ", .{
|
||||||
digits_fmt(self, self.line + 1),
|
digits_fmt(self, self.line + 1),
|
||||||
digits_fmt(self, self.column + 1),
|
digits_fmt(self, displayColumn),
|
||||||
}),
|
}),
|
||||||
.total => writer.print(" {f}:{f}/{f} ", .{
|
.total => writer.print(" {f}:{f}/{f} ", .{
|
||||||
digits_fmt(self, self.line + 1),
|
digits_fmt(self, self.line + 1),
|
||||||
digits_fmt(self, self.column + 1),
|
digits_fmt(self, displayColumn),
|
||||||
digits_fmt(self, self.lines),
|
digits_fmt(self, self.lines),
|
||||||
}),
|
}),
|
||||||
.percent => {
|
.percent => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue