mirror of
https://codeberg.org/fairyglade/ly.git
synced 2026-08-20 20:44:19 +02:00
zig fmt
This commit is contained in:
parent
e4a945f925
commit
9552ebd146
1 changed files with 13 additions and 18 deletions
|
|
@ -12,7 +12,6 @@ const LyLua = @embedFile("ly.lua");
|
|||
|
||||
const Lua = @This();
|
||||
|
||||
|
||||
instance: ?Widget = null,
|
||||
lua: *zlua.Lua,
|
||||
log: *LogFile,
|
||||
|
|
@ -68,15 +67,16 @@ pub fn init(
|
|||
|
||||
fn draw(self: *Lua) void {
|
||||
if (self.terminal_buffer.height != self.height or
|
||||
self.terminal_buffer.width != self.width) {
|
||||
self.terminal_buffer.width != self.width)
|
||||
{
|
||||
self.width = self.terminal_buffer.width;
|
||||
self.height = self.terminal_buffer.height;
|
||||
_ = self.lua.getGlobal("ly");
|
||||
_ =self.lua.pushString("width");
|
||||
self.lua.pushInteger(@intCast(self.terminal_buffer.width));
|
||||
_ = self.lua.pushString("width");
|
||||
self.lua.pushInteger(@intCast(self.terminal_buffer.width));
|
||||
self.lua.setTable(-3);
|
||||
_ =self.lua.pushString("height");
|
||||
self.lua.pushInteger(@intCast(self.terminal_buffer.height));
|
||||
_ = self.lua.pushString("height");
|
||||
self.lua.pushInteger(@intCast(self.terminal_buffer.height));
|
||||
self.lua.setTable(-3);
|
||||
self.lua.setGlobal("ly");
|
||||
}
|
||||
|
|
@ -89,18 +89,16 @@ fn draw(self: *Lua) void {
|
|||
};
|
||||
const bufferType = self.lua.getGlobal("_BUFFER");
|
||||
if (bufferType != .table) {
|
||||
self.log.err(self.io, "Lua", "global '_BUFFER' must be a table: got {}", .{bufferType})
|
||||
catch {};
|
||||
self.log.err(self.io, "Lua", "global '_BUFFER' must be a table: got {}", .{bufferType}) catch {};
|
||||
self.lua_error = true;
|
||||
return;
|
||||
}
|
||||
self.lua.pushNil();
|
||||
self.lua.pushNil();
|
||||
while (self.lua.next(-2)) {
|
||||
// expect the key to be an int
|
||||
// expect the value to be a table
|
||||
const pos = self.lua.toInteger(-2) catch {
|
||||
self.log.err(self.io, "Lua", "pos: cannot convert to integer", .{})
|
||||
catch {};
|
||||
self.log.err(self.io, "Lua", "pos: cannot convert to integer", .{}) catch {};
|
||||
self.lua_error = true;
|
||||
return;
|
||||
};
|
||||
|
|
@ -108,8 +106,7 @@ fn draw(self: *Lua) void {
|
|||
_ = self.lua.pushString("char");
|
||||
_ = self.lua.getTable(-2);
|
||||
const char = self.lua.toInteger(-1) catch {
|
||||
self.log.err(self.io, "Lua", "char: cannot convert to integer", .{})
|
||||
catch {};
|
||||
self.log.err(self.io, "Lua", "char: cannot convert to integer", .{}) catch {};
|
||||
self.lua_error = true;
|
||||
return;
|
||||
};
|
||||
|
|
@ -117,8 +114,7 @@ fn draw(self: *Lua) void {
|
|||
_ = self.lua.pushString("fg");
|
||||
_ = self.lua.getTable(-2);
|
||||
const fg = self.lua.toInteger(-1) catch {
|
||||
self.log.err(self.io, "Lua", "fg: cannot convert to integer", .{})
|
||||
catch {};
|
||||
self.log.err(self.io, "Lua", "fg: cannot convert to integer", .{}) catch {};
|
||||
self.lua_error = true;
|
||||
return;
|
||||
};
|
||||
|
|
@ -126,8 +122,7 @@ fn draw(self: *Lua) void {
|
|||
_ = self.lua.pushString("bg");
|
||||
_ = self.lua.getTable(-2);
|
||||
const bg = self.lua.toInteger(-1) catch {
|
||||
self.log.err(self.io, "Lua", "bg: cannot convert to integer", .{})
|
||||
catch {};
|
||||
self.log.err(self.io, "Lua", "bg: cannot convert to integer", .{}) catch {};
|
||||
self.lua_error = true;
|
||||
return;
|
||||
};
|
||||
|
|
@ -150,7 +145,7 @@ fn calculateTimeout(self: *Lua, _: *anyopaque) !?usize {
|
|||
if (self.lua_error) return null;
|
||||
const lyType = self.lua.getGlobal("ly"); // +1
|
||||
_ = self.lua.pushString("frame_delay"); // + 1
|
||||
if (lyType != .table) {
|
||||
if (lyType != .table) {
|
||||
try self.log.err(self.io, "Lua", "global 'ly' must be a table: got {}", .{lyType});
|
||||
self.lua_error = true;
|
||||
self.lua.pop(-1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue