Merge branch 'master' into keybind

This commit is contained in:
CJ van den Berg 2024-11-25 16:34:30 +01:00
commit 0cb0f59de8
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 31 additions and 16 deletions

View file

@ -74,7 +74,9 @@ fn build_release(
) void { ) void {
const targets: []const std.Target.Query = &.{ const targets: []const std.Target.Query = &.{
.{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl }, .{ .cpu_arch = .x86_64, .os_tag = .linux, .abi = .musl },
.{ .cpu_arch = .x86, .os_tag = .linux, .abi = .musl },
.{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .musl }, .{ .cpu_arch = .aarch64, .os_tag = .linux, .abi = .musl },
.{ .cpu_arch = .arm, .os_tag = .linux, .abi = .musleabihf },
.{ .cpu_arch = .x86_64, .os_tag = .macos }, .{ .cpu_arch = .x86_64, .os_tag = .macos },
.{ .cpu_arch = .aarch64, .os_tag = .macos }, .{ .cpu_arch = .aarch64, .os_tag = .macos },
.{ .cpu_arch = .x86_64, .os_tag = .windows }, .{ .cpu_arch = .x86_64, .os_tag = .windows },
@ -147,7 +149,7 @@ pub fn build_exe(
var version_info = std.ArrayList(u8).init(b.allocator); var version_info = std.ArrayList(u8).init(b.allocator);
defer version_info.deinit(); defer version_info.deinit();
gen_version_info(b, version_info.writer()) catch { gen_version_info(b, target, version_info.writer()) catch {
version_info.clearAndFree(); version_info.clearAndFree();
version_info.appendSlice("unknown") catch {}; version_info.appendSlice("unknown") catch {};
}; };
@ -471,7 +473,11 @@ pub fn build_exe(
// b.default_step.dependOn(lint_step); // b.default_step.dependOn(lint_step);
} }
fn gen_version_info(b: *std.Build, writer: anytype) !void { fn gen_version_info(
b: *std.Build,
target: std.Build.ResolvedTarget,
writer: anytype,
) !void {
var code: u8 = 0; var code: u8 = 0;
const describe = try b.runAllowFail(&[_][]const u8{ "git", "describe", "--always", "--tags" }, &code, .Ignore); const describe = try b.runAllowFail(&[_][]const u8{ "git", "describe", "--always", "--tags" }, &code, .Ignore);
@ -484,10 +490,12 @@ fn gen_version_info(b: *std.Build, writer: anytype) !void {
const remote = std.mem.trimRight(u8, remote_, "\r\n "); const remote = std.mem.trimRight(u8, remote_, "\r\n ");
const log = std.mem.trimRight(u8, log_, "\r\n "); const log = std.mem.trimRight(u8, log_, "\r\n ");
const diff = std.mem.trimRight(u8, diff_, "\r\n "); const diff = std.mem.trimRight(u8, diff_, "\r\n ");
const target_triple = try target.result.zigTriple(b.allocator);
try writer.print("Flow Control: a programmer's text editor\n\nversion: {s}{s}\n", .{ try writer.print("Flow Control: a programmer's text editor\n\nversion: {s}{s}\ntarget: {s}\n", .{
version, version,
if (diff.len > 0) "-dirty" else "", if (diff.len > 0) "-dirty" else "",
target_triple,
}); });
if (branch.len > 0) if (branch.len > 0)

View file

@ -64,6 +64,7 @@ pub fn main() anyerror!void {
.no_syntax = "Disable syntax highlighting", .no_syntax = "Disable syntax highlighting",
.syntax_report_timing = "Report syntax highlighting time", .syntax_report_timing = "Report syntax highlighting time",
.exec = "Execute a command on startup", .exec = "Execute a command on startup",
.literal = "Disable :LINE and +LINE syntax",
.version = "Show build version and exit", .version = "Show build version and exit",
}; };
@ -74,6 +75,7 @@ pub fn main() anyerror!void {
.trace_level = 't', .trace_level = 't',
.language = 'l', .language = 'l',
.exec = 'e', .exec = 'e',
.literal = 'L',
.version = 'v', .version = 'v',
}; };
@ -92,6 +94,7 @@ pub fn main() anyerror!void {
no_syntax: bool, no_syntax: bool,
syntax_report_timing: bool, syntax_report_timing: bool,
exec: ?[]const u8, exec: ?[]const u8,
literal: bool,
version: bool, version: bool,
}; };
@ -211,7 +214,7 @@ pub fn main() anyerror!void {
for (positional_args.items) |arg| { for (positional_args.items) |arg| {
if (arg.len == 0) continue; if (arg.len == 0) continue;
if (arg[0] == '+') { if (!args.literal and arg[0] == '+') {
const line = try std.fmt.parseInt(usize, arg[1..], 10); const line = try std.fmt.parseInt(usize, arg[1..], 10);
if (prev) |p| { if (prev) |p| {
p.line = line; p.line = line;
@ -228,6 +231,7 @@ pub fn main() anyerror!void {
curr.line = line; curr.line = line;
line_next = null; line_next = null;
} }
if (!args.literal) {
var it = std.mem.splitScalar(u8, arg, ':'); var it = std.mem.splitScalar(u8, arg, ':');
curr.file = it.first(); curr.file = it.first();
if (it.next()) |line_| if (it.next()) |line_|
@ -241,6 +245,9 @@ pub fn main() anyerror!void {
if (it.next()) |col_| if (it.next()) |col_|
curr.end_column = std.fmt.parseInt(usize, col_, 10) catch null; curr.end_column = std.fmt.parseInt(usize, col_, 10) catch null;
} }
} else {
curr.file = arg;
}
} }
var have_project = false; var have_project = false;