diff --git a/README.md b/README.md index 67be48d..0604c3b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,11 @@ https://github.com/neurocyte/flow/assets/1552770/97aae817-c209-4c08-bc65-0a0bf1f - Linux, MacOS, Windows, Android (Termux) or FreeBSD. - A UTF-8 locale -# Download +# Download / Install + +```shell +curl -fsSL https://flow-control.dev/install | sh +``` Binary release builds are found here: [neurocyte/flow/releases](https://github.com/neurocyte/flow/releases) @@ -21,6 +25,8 @@ Nightly binary builds are found here: [neurocyte/flow-nightly/releases](https:// Or check your favorite local system package repository. +[![Packaging status](https://repology.org/badge/vertical-allrepos/flow-control.svg)](https://repology.org/project/flow-control/versions) + # Building Make sure your system meets the requirements listed above. diff --git a/build.zig b/build.zig index 3536614..e6af465 100644 --- a/build.zig +++ b/build.zig @@ -509,6 +509,7 @@ pub fn build_exe( exe.root_module.addImport("renderer", renderer_mod); exe.root_module.addImport("input", input_mod); exe.root_module.addImport("syntax", syntax_mod); + exe.root_module.addImport("color", color_mod); exe.root_module.addImport("version_info", b.createModule(.{ .root_source_file = version_info_file })); if (target.result.os.tag == .windows) { diff --git a/src/list_languages.zig b/src/list_languages.zig index 8da59d4..f752224 100644 --- a/src/list_languages.zig +++ b/src/list_languages.zig @@ -1,6 +1,7 @@ const std = @import("std"); const syntax = @import("syntax"); const builtin = @import("builtin"); +const RGB = @import("color").RGB; const bin_path = @import("bin_path.zig"); @@ -23,14 +24,19 @@ pub fn list(allocator: std.mem.Allocator, writer: anytype, tty_config: std.io.tt } try tty_config.setColor(writer, .yellow); - try write_string(writer, "Language", max_language_len + 1); + try write_string(writer, " Language", max_language_len + 1 + 4); try write_string(writer, "Extensions", max_extensions_len + 1 + checkmark_width); try write_string(writer, "Language Server", max_langserver_len + 1 + checkmark_width); - try write_string(writer, "Formatter", max_formatter_len); + try write_string(writer, "Formatter", null); try tty_config.setColor(writer, .reset); try writer.writeAll("\n"); for (syntax.FileType.file_types) |file_type| { + try writer.writeAll(" "); + try setColorRgb(writer, file_type.color); + try writer.writeAll(file_type.icon); + try tty_config.setColor(writer, .reset); + try writer.writeAll(" "); try write_string(writer, file_type.name, max_language_len + 1); try write_segmented(writer, file_type.extensions, ",", max_extensions_len + 1, tty_config); @@ -42,7 +48,7 @@ pub fn list(allocator: std.mem.Allocator, writer: anytype, tty_config: std.io.tt if (file_type.formatter) |formatter| try write_checkmark(writer, can_execute(allocator, formatter[0]), tty_config); - try write_segmented(writer, file_type.formatter, " ", max_formatter_len, tty_config); + try write_segmented(writer, file_type.formatter, " ", null, tty_config); try writer.writeAll("\n"); } } @@ -58,9 +64,9 @@ fn args_string_length(args_: ?[]const []const u8) usize { return len; } -fn write_string(writer: anytype, string: []const u8, pad: usize) !void { +fn write_string(writer: anytype, string: []const u8, pad: ?usize) !void { try writer.writeAll(string); - try write_padding(writer, string.len, pad); + if (pad) |pad_| try write_padding(writer, string.len, pad_); } fn write_checkmark(writer: anytype, success: bool, tty_config: std.io.tty.Config) !void { @@ -72,7 +78,7 @@ fn write_segmented( writer: anytype, args_: ?[]const []const u8, sep: []const u8, - pad: usize, + pad: ?usize, tty_config: std.io.tty.Config, ) !void { const args = args_ orelse return; @@ -87,7 +93,7 @@ fn write_segmented( try writer.writeAll(arg); } try tty_config.setColor(writer, .reset); - try write_padding(writer, len, pad); + if (pad) |pad_| try write_padding(writer, len, pad_); } fn write_padding(writer: anytype, len: usize, pad_len: usize) !void { @@ -99,3 +105,9 @@ fn can_execute(allocator: std.mem.Allocator, binary_name: []const u8) bool { defer if (resolved_binary_path) |path| allocator.free(path); return resolved_binary_path != null; } + +fn setColorRgb(writer: anytype, color: u24) !void { + const fg_rgb_legacy = "\x1b[38;2;{d};{d};{d}m"; + const rgb = RGB.from_u24(color); + try writer.print(fg_rgb_legacy, .{ rgb.r, rgb.g, rgb.b }); +}