-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from Arnau478/module
Expose hevi as a module
- Loading branch information
Showing
10 changed files
with
446 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const std = @import("std"); | ||
const DisplayOptions = @This(); | ||
|
||
/// Whether to use color or not | ||
color: bool, | ||
/// If true, uses uppercase; otherwise lowercase | ||
uppercase: bool, | ||
/// Print the size of the file at the end | ||
show_size: bool, | ||
/// Show a column with the offset into the file | ||
show_offset: bool, | ||
/// Show a column with the ASCII interpretation | ||
show_ascii: bool, | ||
/// Skip lines if they're the same as the one before and after it | ||
skip_lines: bool, | ||
/// Override the binary parser that is used | ||
parser: ?OptionString = null, | ||
|
||
pub const OptionString = struct { | ||
is_allocated: bool = false, | ||
string: []const u8, | ||
|
||
pub fn safeSet(allocator: std.mem.Allocator, options: *DisplayOptions, s: []const u8) void { | ||
if (options.parser) |parser| { | ||
if (parser.is_allocated) allocator.free(parser.string); | ||
} | ||
|
||
options.parser = .{ .string = s }; | ||
} | ||
}; | ||
|
||
pub fn deinit(self: DisplayOptions, allocator: std.mem.Allocator) void { | ||
if (self.parser) |parser| { | ||
if (parser.is_allocated) allocator.free(parser.string); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.