format
Parameters
- self:*TextLayoutWidget
- *TextLayoutWidget
- fmt:[]const u8
- []const u8
- args:anytype
- anytype
- opts:Options
- Options
Source
Implementation
pub fn format(self: *TextLayoutWidget, comptime fmt: []const u8, args: anytype, opts: Options) void {
comptime if (!std.unicode.utf8ValidateSlice(fmt)) @compileError("Format strings must be valid utf-8");
const cw = dvui.currentWindow();
const l = std.fmt.allocPrint(cw.lifo(), fmt, args) catch |err| blk: {
dvui.logError(@src(), err, "Failed to print", .{});
break :blk fmt;
};
defer if (l.ptr != fmt.ptr) cw.lifo().free(l);
self.addText(l, opts);
}