diff --git a/src/animations/Doom.zig b/src/animations/Doom.zig index 1583165..daa203a 100644 --- a/src/animations/Doom.zig +++ b/src/animations/Doom.zig @@ -74,7 +74,7 @@ pub fn draw(self: Doom) void { } } -fn initBuffer(buffer: []u8, width: u64) void { +fn initBuffer(buffer: []u8, width: usize) void { const length = buffer.len - width; const slice_start = buffer[0..length]; const slice_end = buffer[length..]; diff --git a/src/animations/Matrix.zig b/src/animations/Matrix.zig index 9ed242e..ba7e6e1 100644 --- a/src/animations/Matrix.zig +++ b/src/animations/Matrix.zig @@ -77,9 +77,9 @@ pub fn draw(self: *Matrix) void { if (self.frame > 4) self.frame = 1; self.count = 0; - var x: u64 = 0; + var x: usize = 0; while (x < self.terminal_buffer.width) : (x += 2) { - var tail: u64 = 0; + var tail: usize = 0; var line = &self.lines[x]; if (self.frame <= line.update) continue; @@ -95,7 +95,7 @@ pub fn draw(self: *Matrix) void { } } - var y: u64 = 0; + var y: usize = 0; var first_col = true; var seg_len: u64 = 0; height_it: while (y <= buf_height) : (y += 1) { @@ -142,13 +142,13 @@ pub fn draw(self: *Matrix) void { } } - var x: u64 = 0; + var x: usize = 0; while (x < buf_width) : (x += 2) { - var y: u64 = 1; + var y: usize = 1; while (y <= self.terminal_buffer.height) : (y += 1) { const dot = self.dots[buf_width * y + x]; - var fg: u16 = self.fg_ini; + var fg = self.fg_ini; if (dot.value == -1 or dot.value == ' ') { _ = termbox.tb_set_cell(@intCast(x), @intCast(y - 1), ' ', fg, termbox.TB_DEFAULT); @@ -161,16 +161,16 @@ pub fn draw(self: *Matrix) void { } } -fn initBuffers(dots: []Dot, lines: []Line, width: u64, height: u64, random: Random) void { - var y: u64 = 0; +fn initBuffers(dots: []Dot, lines: []Line, width: usize, height: usize, random: Random) void { + var y: usize = 0; while (y <= height) : (y += 1) { - var x: u64 = 0; + var x: usize = 0; while (x < width) : (x += 2) { dots[y * width + x].value = -1; } } - var x: u64 = 0; + var x: usize = 0; while (x < width) : (x += 2) { var line = lines[x]; const h: isize = @intCast(height); diff --git a/src/bigclock.zig b/src/bigclock.zig index 9054a75..cfe61f5 100644 --- a/src/bigclock.zig +++ b/src/bigclock.zig @@ -111,7 +111,7 @@ pub fn clockCell(animate: bool, char: u8, fg: u16, bg: u16) [SIZE]termbox.tb_cel return cells; } -pub fn alphaBlit(buffer: [*]termbox.tb_cell, x: u64, y: u64, tb_width: u64, tb_height: u64, cells: [SIZE]termbox.tb_cell) void { +pub fn alphaBlit(buffer: [*]termbox.tb_cell, x: usize, y: usize, tb_width: usize, tb_height: usize, cells: [SIZE]termbox.tb_cell) void { if (x + WIDTH >= tb_width or y + HEIGHT >= tb_height) return; for (0..HEIGHT) |yy| { diff --git a/src/config/Save.zig b/src/config/Save.zig index 972c2b7..6186f14 100644 --- a/src/config/Save.zig +++ b/src/config/Save.zig @@ -1,2 +1,2 @@ user: ?[]const u8 = null, -session_index: ?u64 = null, +session_index: ?usize = null, diff --git a/src/config/migrator.zig b/src/config/migrator.zig index 0ae6001..1295fa3 100644 --- a/src/config/migrator.zig +++ b/src/config/migrator.zig @@ -20,9 +20,9 @@ pub fn tryMigrateSaveFile(user_buf: *[32]u8, path: []const u8) Save { reader.streamUntilDelimiter(session_fbs.writer(), '\n', 20) catch {}; const session_index_str = session_fbs.getWritten(); - var session_index: ?u64 = null; + var session_index: ?usize = null; if (session_index_str.len > 0) { - session_index = std.fmt.parseUnsigned(u64, session_index_str, 10) catch return save; + session_index = std.fmt.parseUnsigned(usize, session_index_str, 10) catch return save; } save.session_index = session_index; diff --git a/src/interop.zig b/src/interop.zig index 23a90b9..23bb83e 100644 --- a/src/interop.zig +++ b/src/interop.zig @@ -26,10 +26,10 @@ pub const logincap = @cImport({ @cInclude("login_cap.h"); }); -pub const c_size = u64; +pub const c_size = usize; pub const c_uid = u32; pub const c_gid = u32; -pub const c_time = c_long; +pub const c_time = c_longlong; pub const tm = extern struct { tm_sec: c_int, tm_min: c_int, diff --git a/src/main.zig b/src/main.zig index 42e617f..d10437d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -299,8 +299,8 @@ pub fn main() !void { _ = termbox.tb_present(); // Required to update tb_width(), tb_height() and tb_cell_buffer() - const width: u64 = @intCast(termbox.tb_width()); - const height: u64 = @intCast(termbox.tb_height()); + const width: usize = @intCast(termbox.tb_width()); + const height: usize = @intCast(termbox.tb_height()); if (width != buffer.width) { buffer.width = width; @@ -398,7 +398,7 @@ pub fn main() !void { try info_line.draw(buffer); if (!config.hide_key_hints) { - var length: u64 = 0; + var length: usize = 0; buffer.drawLabel(config.shutdown_key, length, 0); length += config.shutdown_key.len + 1; @@ -453,7 +453,7 @@ pub fn main() !void { }; var lock_state_x = buffer.width - @min(buffer.width, lang.numlock.len); - const lock_state_y: u64 = if (config.clock != null) 1 else 0; + const lock_state_y: usize = if (config.clock != null) 1 else 0; if (lock_state.numlock) buffer.drawLabel(lang.numlock, lock_state_x, lock_state_y); diff --git a/src/tui/TerminalBuffer.zig b/src/tui/TerminalBuffer.zig index ebc8ca7..71bf8aa 100644 --- a/src/tui/TerminalBuffer.zig +++ b/src/tui/TerminalBuffer.zig @@ -11,8 +11,8 @@ const termbox = interop.termbox; const TerminalBuffer = @This(); random: Random, -width: u64, -height: u64, +width: usize, +height: usize, buffer: [*]termbox.tb_cell, fg: u16, bg: u16, @@ -27,15 +27,15 @@ box_chars: struct { left: u32, right: u32, }, -labels_max_length: u64, -box_x: u64, -box_y: u64, -box_width: u64, -box_height: u64, +labels_max_length: usize, +box_x: usize, +box_y: usize, +box_width: usize, +box_height: usize, margin_box_v: u8, margin_box_h: u8, -pub fn init(config: Config, labels_max_length: u64, random: Random) TerminalBuffer { +pub fn init(config: Config, labels_max_length: usize, random: Random) TerminalBuffer { return .{ .random = random, .width = @intCast(termbox.tb_width()), @@ -142,9 +142,9 @@ pub fn drawBoxCenter(self: *TerminalBuffer, show_borders: bool, blank_box: bool) } pub fn calculateComponentCoordinates(self: TerminalBuffer) struct { - x: u64, - y: u64, - visible_length: u64, + x: usize, + y: usize, + visible_length: usize, } { const x = self.box_x + self.margin_box_h + self.labels_max_length + 1; const y = self.box_y + self.margin_box_v; @@ -157,11 +157,11 @@ pub fn calculateComponentCoordinates(self: TerminalBuffer) struct { }; } -pub fn drawLabel(self: TerminalBuffer, text: []const u8, x: u64, y: u64) void { +pub fn drawLabel(self: TerminalBuffer, text: []const u8, x: usize, y: usize) void { drawColorLabel(text, x, y, self.fg, self.bg); } -pub fn drawColorLabel(text: []const u8, x: u64, y: u64, fg: u16, bg: u16) void { +pub fn drawColorLabel(text: []const u8, x: usize, y: usize, fg: u16, bg: u16) void { const yc: c_int = @intCast(y); const utf8view = std.unicode.Utf8View.init(text) catch return; var utf8 = utf8view.iterator(); @@ -172,7 +172,7 @@ pub fn drawColorLabel(text: []const u8, x: u64, y: u64, fg: u16, bg: u16) void { } } -pub fn drawConfinedLabel(self: TerminalBuffer, text: []const u8, x: u64, y: u64, max_length: u64) void { +pub fn drawConfinedLabel(self: TerminalBuffer, text: []const u8, x: usize, y: usize, max_length: usize) void { const yc: c_int = @intCast(y); const utf8view = std.unicode.Utf8View.init(text) catch return; var utf8 = utf8view.iterator(); @@ -184,7 +184,7 @@ pub fn drawConfinedLabel(self: TerminalBuffer, text: []const u8, x: u64, y: u64, } } -pub fn drawCharMultiple(self: TerminalBuffer, char: u8, x: u64, y: u64, length: u64) void { +pub fn drawCharMultiple(self: TerminalBuffer, char: u8, x: usize, y: usize, length: usize) void { const yc: c_int = @intCast(y); const cell = utils.initCell(char, self.fg, self.bg); diff --git a/src/tui/components/Desktop.zig b/src/tui/components/Desktop.zig index 98870d0..9151f97 100644 --- a/src/tui/components/Desktop.zig +++ b/src/tui/components/Desktop.zig @@ -35,13 +35,13 @@ pub const Entry = struct { @"Desktop Entry": DesktopEntry = DesktopEntry{} }; allocator: Allocator, buffer: *TerminalBuffer, environments: EnvironmentList, -current: u64, -visible_length: u64, -x: u64, -y: u64, +current: usize, +visible_length: usize, +x: usize, +y: usize, lang: Lang, -pub fn init(allocator: Allocator, buffer: *TerminalBuffer, max_length: u64, lang: Lang) !Desktop { +pub fn init(allocator: Allocator, buffer: *TerminalBuffer, max_length: usize, lang: Lang) !Desktop { return .{ .allocator = allocator, .buffer = buffer, @@ -64,7 +64,7 @@ pub fn deinit(self: Desktop) void { self.environments.deinit(); } -pub fn position(self: *Desktop, x: u64, y: u64, visible_length: u64) void { +pub fn position(self: *Desktop, x: usize, y: usize, visible_length: usize) void { self.x = x; self.y = y; self.visible_length = visible_length; diff --git a/src/tui/components/Text.zig b/src/tui/components/Text.zig index 412476a..e65e4a6 100644 --- a/src/tui/components/Text.zig +++ b/src/tui/components/Text.zig @@ -13,14 +13,14 @@ const Text = @This(); allocator: Allocator, buffer: *TerminalBuffer, text: DynamicString, -end: u64, -cursor: u64, -visible_start: u64, -visible_length: u64, -x: u64, -y: u64, +end: usize, +cursor: usize, +visible_start: usize, +visible_length: usize, +x: usize, +y: usize, -pub fn init(allocator: Allocator, buffer: *TerminalBuffer, max_length: u64) !Text { +pub fn init(allocator: Allocator, buffer: *TerminalBuffer, max_length: usize) !Text { const text = try DynamicString.initCapacity(allocator, max_length); return .{ @@ -40,7 +40,7 @@ pub fn deinit(self: Text) void { self.text.deinit(); } -pub fn position(self: *Text, x: u64, y: u64, visible_length: u64) void { +pub fn position(self: *Text, x: usize, y: usize, visible_length: usize) void { self.x = x; self.y = y; self.visible_length = visible_length;