{"id":13741522,"url":"https://github.com/joachimschmidt557/linenoize","last_synced_at":"2025-04-09T09:05:24.004Z","repository":{"id":42499536,"uuid":"237222216","full_name":"joachimschmidt557/linenoize","owner":"joachimschmidt557","description":"A port of linenoise to zig","archived":false,"fork":false,"pushed_at":"2025-03-30T10:50:11.000Z","size":111,"stargazers_count":62,"open_issues_count":5,"forks_count":11,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-30T11:28:33.299Z","etag":null,"topics":["readline","zig","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joachimschmidt557.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-30T13:46:37.000Z","updated_at":"2025-03-30T10:50:15.000Z","dependencies_parsed_at":"2024-01-17T21:33:13.215Z","dependency_job_id":"6e23b007-2a9e-4184-934a-6ee2f9f8009f","html_url":"https://github.com/joachimschmidt557/linenoize","commit_stats":{"total_commits":91,"total_committers":12,"mean_commits":7.583333333333333,"dds":0.2417582417582418,"last_synced_commit":"4f62f310d70b0b602f519d0ba95a7d3176ba8103"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joachimschmidt557%2Flinenoize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joachimschmidt557%2Flinenoize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joachimschmidt557%2Flinenoize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joachimschmidt557%2Flinenoize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joachimschmidt557","download_url":"https://codeload.github.com/joachimschmidt557/linenoize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008630,"owners_count":21032556,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["readline","zig","zig-package"],"created_at":"2024-08-03T04:00:59.925Z","updated_at":"2025-04-09T09:05:23.984Z","avatar_url":"https://github.com/joachimschmidt557.png","language":"Zig","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# linenoize\n\nA port of [linenoise](https://github.com/antirez/linenoise) to zig\naiming to be a simple readline for command-line applications written\nin zig. It is written in pure zig and doesn't require\nlibc. `linenoize` works with the latest stable zig version (0.14.0).\n\nIn addition to being a full-fledged zig library, `linenoize` also\nserves as a drop-in replacement for linenoise. As a proof of concept,\nthe example application from linenoise can be built with `zig build\nc-example`.\n\n## Features\n\n- Line editing\n- Completions\n- Hints\n- History\n- Multi line mode\n- Mask input mode\n\n### Supported platforms\n\n- Linux\n- macOS\n- Windows\n\n## Add linenoize to a project\n\nAdd linenoize as a dependency to your project:\n```bash\nzig fetch --save git+https://github.com/joachimschmidt557/linenoize.git#v0.1.0\n```\n\nThen add the following code to your `build.zig` file:\n```zig\nconst linenoize = b.dependency(\"linenoize\", .{\n    .target = target,\n    .optimize = optimize,\n}).module(\"linenoise\");\nexe.root_module.addImport(\"linenoize\", linenoize);\n```\n\n## Examples\n\n### Minimal example\n\n```zig\nconst std = @import(\"std\");\nconst Linenoise = @import(\"linenoise\").Linenoise;\n\npub fn main() !void {\n    const allocator = std.heap.page_allocator;\n\n    var ln = Linenoise.init(allocator);\n    defer ln.deinit();\n\n    while (try ln.linenoise(\"hello\u003e \")) |input| {\n        defer allocator.free(input);\n        std.debug.print(\"input: {s}\\n\", .{input});\n        try ln.history.add(input);\n    }\n}\n```\n\n### Example of more features\n\n``` zig\nconst std = @import(\"std\");\nconst Allocator = std.mem.Allocator;\nconst ArrayList = std.ArrayList;\n\nconst log = std.log.scoped(.main);\n\nconst Linenoise = @import(\"linenoise\").Linenoise;\n\nfn completion(allocator: Allocator, buf: []const u8) ![]const []const u8 {\n    if (std.mem.eql(u8, \"z\", buf)) {\n        var result = ArrayList([]const u8).init(allocator);\n        try result.append(try allocator.dupe(u8, \"zig\"));\n        try result.append(try allocator.dupe(u8, \"ziglang\"));\n        return result.toOwnedSlice();\n    } else {\n        return \u0026[_][]const u8{};\n    }\n}\n\nfn hints(allocator: Allocator, buf: []const u8) !?[]const u8 {\n    if (std.mem.eql(u8, \"hello\", buf)) {\n        return try allocator.dupe(u8, \" World\");\n    } else {\n        return null;\n    }\n}\n\nvar debug_allocator: std.heap.DebugAllocator(.{}) = .init;\n\npub fn main() !void {\n    defer _ = debug_allocator.deinit();\n    const allocator = debug_allocator.allocator();\n\n    var ln = Linenoise.init(allocator);\n    defer ln.deinit();\n\n    // Load history and save history later\n    ln.history.load(\"history.txt\") catch log.err(\"Failed to load history\", .{});\n    defer ln.history.save(\"history.txt\") catch log.err(\"Failed to save history\", .{});\n\n    // Set up hints callback\n    ln.hints_callback = hints;\n\n    // Set up completions callback\n    ln.completions_callback = completion;\n\n    // Enable mask mode\n    // ln.mask_mode = true;\n\n    // Enable multiline mode\n    // ln.multiline_mode = true;\n\n    while (try ln.linenoise(\"hellö\u003e \")) |input| {\n        defer allocator.free(input);\n        log.info(\"input: {s}\", .{input});\n        try ln.history.add(input);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoachimschmidt557%2Flinenoize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoachimschmidt557%2Flinenoize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoachimschmidt557%2Flinenoize/lists"}