mirror of
https://github.com/fairyglade/ly.git
synced 2026-03-21 22:43:38 +00:00
Split UI code into ly-ui library
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
22
build.zig
22
build.zig
@@ -72,36 +72,18 @@ pub fn build(b: *std.Build) !void {
|
||||
.use_llvm = true,
|
||||
});
|
||||
|
||||
const ly_core = b.dependency("ly_core", .{ .target = target, .optimize = optimize });
|
||||
exe.root_module.addImport("ly-core", ly_core.module("ly-core"));
|
||||
|
||||
const zigini = b.dependency("zigini", .{ .target = target, .optimize = optimize });
|
||||
exe.root_module.addImport("zigini", zigini.module("zigini"));
|
||||
const ly_ui = b.dependency("ly_ui", .{ .target = target, .optimize = optimize });
|
||||
exe.root_module.addImport("ly-ui", ly_ui.module("ly-ui"));
|
||||
|
||||
exe.root_module.addOptions("build_options", build_options);
|
||||
|
||||
const clap = b.dependency("clap", .{ .target = target, .optimize = optimize });
|
||||
exe.root_module.addImport("clap", clap.module("clap"));
|
||||
|
||||
const termbox_dep = b.dependency("termbox2", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
exe.linkSystemLibrary("pam");
|
||||
if (enable_x11_support) exe.linkSystemLibrary("xcb");
|
||||
exe.linkLibC();
|
||||
|
||||
const translate_c = b.addTranslateC(.{
|
||||
.root_source_file = termbox_dep.path("termbox2.h"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
translate_c.defineCMacroRaw("TB_IMPL");
|
||||
translate_c.defineCMacro("TB_OPT_ATTR_W", "32"); // Enable 24-bit color support + styling (32-bit)
|
||||
const termbox2 = translate_c.addModule("termbox2");
|
||||
exe.root_module.addImport("termbox2", termbox2);
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
|
||||
@@ -4,21 +4,13 @@
|
||||
.fingerprint = 0xa148ffcc5dc2cb59,
|
||||
.minimum_zig_version = "0.15.0",
|
||||
.dependencies = .{
|
||||
.ly_core = .{
|
||||
.path = "ly-core",
|
||||
.ly_ui = .{
|
||||
.path = "ly-ui",
|
||||
},
|
||||
.clap = .{
|
||||
.url = "git+https://github.com/Hejsil/zig-clap#5289e0753cd274d65344bef1c114284c633536ea",
|
||||
.hash = "clap-0.11.0-oBajB-HnAQDPCKYzwF7rO3qDFwRcD39Q0DALlTSz5H7e",
|
||||
},
|
||||
.zigini = .{
|
||||
.url = "git+https://github.com/AnErrupTion/zigini?ref=zig-0.15.0#9281f47702b57779e831d7618e158abb8eb4d4a2",
|
||||
.hash = "zigini-0.3.3-36M0FRJJAADZVq5HPm-hYKMpFFTr0OgjbEYcK2ijKZ5n",
|
||||
},
|
||||
.termbox2 = .{
|
||||
.url = "git+https://github.com/AnErrupTion/termbox2?ref=master#496730697c662893eec43192f48ff616c2539da6",
|
||||
.hash = "N-V-__8AAOEWBQDt5tNdIzIFY6n8DdZsCP-6MyLoNS20wgpA",
|
||||
},
|
||||
},
|
||||
.paths = .{""},
|
||||
}
|
||||
|
||||
7
ly-core/src/enums.zig
Normal file
7
ly-core/src/enums.zig
Normal file
@@ -0,0 +1,7 @@
|
||||
pub const DisplayServer = enum {
|
||||
wayland,
|
||||
shell,
|
||||
xinitrc,
|
||||
x11,
|
||||
custom,
|
||||
};
|
||||
@@ -1,10 +1,14 @@
|
||||
const std = @import("std");
|
||||
const ini = @import("zigini");
|
||||
|
||||
pub const ini = @import("zigini");
|
||||
|
||||
pub const interop = @import("interop.zig");
|
||||
pub const UidRange = @import("UidRange.zig");
|
||||
pub const LogFile = @import("LogFile.zig");
|
||||
pub const SharedError = @import("SharedError.zig");
|
||||
pub const SavedUsers = @import("SavedUsers.zig");
|
||||
pub const Environment = @import("Environment.zig");
|
||||
pub const DisplayServer = @import("enums.zig").DisplayServer;
|
||||
|
||||
pub fn IniParser(comptime Struct: type) type {
|
||||
return struct {
|
||||
|
||||
37
ly-ui/build.zig
Normal file
37
ly-ui/build.zig
Normal file
@@ -0,0 +1,37 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const mod = b.addModule("ly-ui", .{
|
||||
.root_source_file = b.path("src/root.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const ly_core = b.dependency("ly_core", .{ .target = target, .optimize = optimize });
|
||||
mod.addImport("ly-core", ly_core.module("ly-core"));
|
||||
|
||||
const termbox_dep = b.dependency("termbox2", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const translate_c = b.addTranslateC(.{
|
||||
.root_source_file = termbox_dep.path("termbox2.h"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
translate_c.defineCMacroRaw("TB_IMPL");
|
||||
translate_c.defineCMacro("TB_OPT_ATTR_W", "32"); // Enable 24-bit color support + styling (32-bit)
|
||||
const termbox2 = translate_c.addModule("termbox2");
|
||||
mod.addImport("termbox2", termbox2);
|
||||
|
||||
const mod_tests = b.addTest(.{
|
||||
.root_module = mod,
|
||||
});
|
||||
const run_mod_tests = b.addRunArtifact(mod_tests);
|
||||
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&run_mod_tests.step);
|
||||
}
|
||||
20
ly-ui/build.zig.zon
Normal file
20
ly-ui/build.zig.zon
Normal file
@@ -0,0 +1,20 @@
|
||||
.{
|
||||
.name = .ly_ui,
|
||||
.version = "1.0.0",
|
||||
.fingerprint = 0x8d11bf85a74ec803,
|
||||
.minimum_zig_version = "0.15.0",
|
||||
.dependencies = .{
|
||||
.ly_core = .{
|
||||
.path = "../ly-core",
|
||||
},
|
||||
.termbox2 = .{
|
||||
.url = "git+https://github.com/AnErrupTion/termbox2?ref=master#496730697c662893eec43192f48ff616c2539da6",
|
||||
.hash = "N-V-__8AAOEWBQDt5tNdIzIFY6n8DdZsCP-6MyLoNS20wgpA",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
"src",
|
||||
},
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
const Environment = @import("../../Environment.zig");
|
||||
const ly_core = @import("ly-core");
|
||||
const Environment = ly_core.Environment;
|
||||
|
||||
const keyboard = @import("../keyboard.zig");
|
||||
const TerminalBuffer = @import("../TerminalBuffer.zig");
|
||||
const Widget = @import("../Widget.zig");
|
||||
@@ -9,6 +11,7 @@ const generic = @import("generic.zig");
|
||||
const UserList = @import("UserList.zig");
|
||||
|
||||
const Env = struct {
|
||||
// TODO: Remove dependency on Environment
|
||||
environment: Environment,
|
||||
index: usize,
|
||||
};
|
||||
@@ -1,7 +1,9 @@
|
||||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
const SavedUsers = @import("../../config/SavedUsers.zig");
|
||||
const ly_core = @import("ly-core");
|
||||
const SavedUsers = ly_core.SavedUsers;
|
||||
|
||||
const keyboard = @import("../keyboard.zig");
|
||||
const TerminalBuffer = @import("../TerminalBuffer.zig");
|
||||
const Widget = @import("../Widget.zig");
|
||||
16
ly-ui/src/root.zig
Normal file
16
ly-ui/src/root.zig
Normal file
@@ -0,0 +1,16 @@
|
||||
pub const ly_core = @import("ly-core");
|
||||
|
||||
pub const Cell = @import("Cell.zig");
|
||||
pub const keyboard = @import("keyboard.zig");
|
||||
pub const Position = @import("Position.zig");
|
||||
pub const TerminalBuffer = @import("TerminalBuffer.zig");
|
||||
pub const Widget = @import("Widget.zig");
|
||||
|
||||
pub const BigLabel = @import("components/BigLabel.zig");
|
||||
pub const CenteredBox = @import("components/CenteredBox.zig");
|
||||
pub const CyclableLabel = @import("components/generic.zig").CyclableLabel;
|
||||
pub const InfoLine = @import("components/InfoLine.zig");
|
||||
pub const Label = @import("components/Label.zig");
|
||||
pub const Session = @import("components/Session.zig");
|
||||
pub const Text = @import("components/Text.zig");
|
||||
pub const UserList = @import("components/UserList.zig");
|
||||
@@ -1,9 +1,10 @@
|
||||
const std = @import("std");
|
||||
const math = std.math;
|
||||
|
||||
const Cell = @import("../tui/Cell.zig");
|
||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||
const Widget = @import("../tui/Widget.zig");
|
||||
const ly_ui = @import("ly-ui");
|
||||
const Cell = ly_ui.Cell;
|
||||
const TerminalBuffer = ly_ui.TerminalBuffer;
|
||||
const Widget = ly_ui.Widget;
|
||||
|
||||
const Cascade = @This();
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
const std = @import("std");
|
||||
const math = std.math;
|
||||
|
||||
const ly_core = @import("ly-core");
|
||||
const ly_ui = @import("ly-ui");
|
||||
const Cell = ly_ui.Cell;
|
||||
const TerminalBuffer = ly_ui.TerminalBuffer;
|
||||
const Widget = ly_ui.Widget;
|
||||
|
||||
const ly_core = ly_ui.ly_core;
|
||||
const interop = ly_core.interop;
|
||||
const TimeOfDay = interop.TimeOfDay;
|
||||
|
||||
const Cell = @import("../tui/Cell.zig");
|
||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||
const Widget = @import("../tui/Widget.zig");
|
||||
|
||||
const ColorMix = @This();
|
||||
|
||||
const Vec2 = @Vector(2, f32);
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
const ly_core = @import("ly-core");
|
||||
const ly_ui = @import("ly-ui");
|
||||
const Cell = ly_ui.Cell;
|
||||
const TerminalBuffer = ly_ui.TerminalBuffer;
|
||||
const Widget = ly_ui.Widget;
|
||||
|
||||
const ly_core = ly_ui.ly_core;
|
||||
const interop = ly_core.interop;
|
||||
const TimeOfDay = interop.TimeOfDay;
|
||||
|
||||
const Cell = @import("../tui/Cell.zig");
|
||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||
const Widget = @import("../tui/Widget.zig");
|
||||
|
||||
const Doom = @This();
|
||||
|
||||
pub const STEPS = 12;
|
||||
|
||||
@@ -4,18 +4,20 @@ const Json = std.json;
|
||||
const eql = std.mem.eql;
|
||||
const flate = std.compress.flate;
|
||||
|
||||
const ly_core = @import("ly-core");
|
||||
const ly_ui = @import("ly-ui");
|
||||
const Cell = ly_ui.Cell;
|
||||
const TerminalBuffer = ly_ui.TerminalBuffer;
|
||||
const Color = TerminalBuffer.Color;
|
||||
const Styling = TerminalBuffer.Styling;
|
||||
const Widget = ly_ui.Widget;
|
||||
|
||||
const ly_core = ly_ui.ly_core;
|
||||
const interop = ly_core.interop;
|
||||
const TimeOfDay = interop.TimeOfDay;
|
||||
const LogFile = ly_core.LogFile;
|
||||
|
||||
const enums = @import("../enums.zig");
|
||||
const DurOffsetAlignment = enums.DurOffsetAlignment;
|
||||
const Cell = @import("../tui/Cell.zig");
|
||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||
const Color = TerminalBuffer.Color;
|
||||
const Styling = TerminalBuffer.Styling;
|
||||
const Widget = @import("../tui/Widget.zig");
|
||||
|
||||
fn read_decompress_file(allocator: Allocator, file_path: []const u8) ![]u8 {
|
||||
const file_buffer = std.fs.cwd().openFile(file_path, .{}) catch {
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
const ly_core = @import("ly-core");
|
||||
const ly_ui = @import("ly-ui");
|
||||
const Cell = ly_ui.Cell;
|
||||
const TerminalBuffer = ly_ui.TerminalBuffer;
|
||||
const Widget = ly_ui.Widget;
|
||||
|
||||
const ly_core = ly_ui.ly_core;
|
||||
const interop = ly_core.interop;
|
||||
const TimeOfDay = interop.TimeOfDay;
|
||||
|
||||
const Cell = @import("../tui/Cell.zig");
|
||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||
const Widget = @import("../tui/Widget.zig");
|
||||
|
||||
const GameOfLife = @This();
|
||||
|
||||
// Visual styles - using block characters like other animations
|
||||
|
||||
@@ -2,14 +2,15 @@ const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Random = std.Random;
|
||||
|
||||
const ly_core = @import("ly-core");
|
||||
const ly_ui = @import("ly-ui");
|
||||
const Cell = ly_ui.Cell;
|
||||
const TerminalBuffer = ly_ui.TerminalBuffer;
|
||||
const Widget = ly_ui.Widget;
|
||||
|
||||
const ly_core = ly_ui.ly_core;
|
||||
const interop = ly_core.interop;
|
||||
const TimeOfDay = interop.TimeOfDay;
|
||||
|
||||
const Cell = @import("../tui/Cell.zig");
|
||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||
const Widget = @import("../tui/Widget.zig");
|
||||
|
||||
pub const FRAME_DELAY: usize = 8;
|
||||
|
||||
// Characters change mid-scroll
|
||||
|
||||
@@ -3,15 +3,14 @@ const Md5 = std.crypto.hash.Md5;
|
||||
const builtin = @import("builtin");
|
||||
const build_options = @import("build_options");
|
||||
|
||||
const ly_core = @import("ly-core");
|
||||
const ly_core = @import("ly-ui").ly_core;
|
||||
const interop = ly_core.interop;
|
||||
const SharedError = ly_core.SharedError;
|
||||
const LogFile = ly_core.LogFile;
|
||||
const Environment = ly_core.Environment;
|
||||
const utmp = interop.utmp;
|
||||
const Utmp = utmp.utmpx;
|
||||
|
||||
const Environment = @import("Environment.zig");
|
||||
|
||||
pub const AuthOptions = struct {
|
||||
tty: u8,
|
||||
service_name: [:0]const u8,
|
||||
|
||||
@@ -5,16 +5,17 @@
|
||||
const std = @import("std");
|
||||
var temporary_allocator = std.heap.page_allocator;
|
||||
|
||||
const ini = @import("zigini");
|
||||
const ly_core = @import("ly-core");
|
||||
const IniParser = ly_core.IniParser;
|
||||
|
||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||
const ly_ui = @import("ly-ui");
|
||||
const TerminalBuffer = ly_ui.TerminalBuffer;
|
||||
const Color = TerminalBuffer.Color;
|
||||
const Styling = TerminalBuffer.Styling;
|
||||
const ly_core = ly_ui.ly_core;
|
||||
const IniParser = ly_core.IniParser;
|
||||
const SavedUsers = ly_core.SavedUsers;
|
||||
const ini = ly_core.ini;
|
||||
|
||||
const Config = @import("Config.zig");
|
||||
const OldSave = @import("OldSave.zig");
|
||||
const SavedUsers = @import("SavedUsers.zig");
|
||||
|
||||
const color_properties = [_][]const u8{
|
||||
"bg",
|
||||
|
||||
@@ -9,14 +9,6 @@ pub const Animation = enum {
|
||||
dur_file,
|
||||
};
|
||||
|
||||
pub const DisplayServer = enum {
|
||||
wayland,
|
||||
shell,
|
||||
xinitrc,
|
||||
x11,
|
||||
custom,
|
||||
};
|
||||
|
||||
pub const Input = enum {
|
||||
info_line,
|
||||
session,
|
||||
|
||||
36
src/main.zig
36
src/main.zig
@@ -6,14 +6,29 @@ const builtin = @import("builtin");
|
||||
const build_options = @import("build_options");
|
||||
|
||||
const clap = @import("clap");
|
||||
const ini = @import("zigini");
|
||||
const Ini = ini.Ini;
|
||||
const ly_core = @import("ly-core");
|
||||
const ly_ui = @import("ly-ui");
|
||||
const Position = ly_ui.Position;
|
||||
const BigLabel = ly_ui.BigLabel;
|
||||
const CenteredBox = ly_ui.CenteredBox;
|
||||
const InfoLine = ly_ui.InfoLine;
|
||||
const Label = ly_ui.Label;
|
||||
const Session = ly_ui.Session;
|
||||
const Text = ly_ui.Text;
|
||||
const UserList = ly_ui.UserList;
|
||||
const TerminalBuffer = ly_ui.TerminalBuffer;
|
||||
const Widget = ly_ui.Widget;
|
||||
const ly_core = ly_ui.ly_core;
|
||||
const interop = ly_core.interop;
|
||||
const UidRange = ly_core.UidRange;
|
||||
const LogFile = ly_core.LogFile;
|
||||
const SharedError = ly_core.SharedError;
|
||||
const IniParser = ly_core.IniParser;
|
||||
const SavedUsers = ly_core.SavedUsers;
|
||||
const DisplayServer = ly_core.DisplayServer;
|
||||
const Environment = ly_core.Environment;
|
||||
const Entry = Environment.Entry;
|
||||
const ini = ly_core.ini;
|
||||
const Ini = ini.Ini;
|
||||
|
||||
const Cascade = @import("animations/Cascade.zig");
|
||||
const ColorMix = @import("animations/ColorMix.zig");
|
||||
@@ -26,21 +41,6 @@ const Config = @import("config/Config.zig");
|
||||
const Lang = @import("config/Lang.zig");
|
||||
const migrator = @import("config/migrator.zig");
|
||||
const OldSave = @import("config/OldSave.zig");
|
||||
const SavedUsers = @import("config/SavedUsers.zig");
|
||||
const enums = @import("enums.zig");
|
||||
const DisplayServer = enums.DisplayServer;
|
||||
const Environment = @import("Environment.zig");
|
||||
const Entry = Environment.Entry;
|
||||
const Position = @import("tui/Position.zig");
|
||||
const BigLabel = @import("tui/components/BigLabel.zig");
|
||||
const CenteredBox = @import("tui/components/CenteredBox.zig");
|
||||
const InfoLine = @import("tui/components/InfoLine.zig");
|
||||
const Label = @import("tui/components/Label.zig");
|
||||
const Session = @import("tui/components/Session.zig");
|
||||
const Text = @import("tui/components/Text.zig");
|
||||
const UserList = @import("tui/components/UserList.zig");
|
||||
const TerminalBuffer = @import("tui/TerminalBuffer.zig");
|
||||
const Widget = @import("tui/Widget.zig");
|
||||
|
||||
const ly_version_str = "Ly version " ++ build_options.version;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user