mirror of https://github.com/fairyglade/ly.git
Some fixes
This commit is contained in:
parent
c502754880
commit
79c77991e7
|
@ -412,12 +412,15 @@ pub fn main() !void {
|
|||
break :draw_lock_state;
|
||||
};
|
||||
|
||||
var lock_state_x = buffer.width - lang.numlock.len;
|
||||
var lock_state_x = buffer.width - @min(buffer.width, lang.numlock.len);
|
||||
const lock_state_y: u64 = if (config.clock != null) 1 else 0;
|
||||
|
||||
if (lock_state.numlock) buffer.drawLabel(lang.numlock, lock_state_x, lock_state_y);
|
||||
lock_state_x -= lang.capslock.len + 1;
|
||||
if (lock_state.capslock) buffer.drawLabel(lang.capslock, lock_state_x, lock_state_y);
|
||||
|
||||
if (lock_state_x >= lang.capslock.len + 1) {
|
||||
lock_state_x -= lang.capslock.len + 1;
|
||||
if (lock_state.capslock) buffer.drawLabel(lang.capslock, lock_state_x, lock_state_y);
|
||||
}
|
||||
}
|
||||
|
||||
desktop.draw();
|
||||
|
|
|
@ -171,16 +171,14 @@ pub fn drawLabel(self: TerminalBuffer, text: []const u8, x: u64, y: u64) void {
|
|||
}
|
||||
|
||||
pub fn drawConfinedLabel(self: TerminalBuffer, text: []const u8, x: u64, y: u64, max_length: u64) void {
|
||||
var confined_text = text;
|
||||
if (text.len > max_length) confined_text = text[0..max_length];
|
||||
|
||||
const yc: c_int = @intCast(y);
|
||||
const utf8view = std.unicode.Utf8View.init(confined_text) catch return;
|
||||
const utf8view = std.unicode.Utf8View.init(text) catch return;
|
||||
var utf8 = utf8view.iterator();
|
||||
|
||||
var i = x;
|
||||
var i: usize = 0;
|
||||
while (utf8.nextCodepoint()) |codepoint| : (i += 1) {
|
||||
_ = termbox.tb_set_cell(@intCast(i), yc, codepoint, self.fg, self.bg);
|
||||
if (i >= max_length) break;
|
||||
_ = termbox.tb_set_cell(@intCast(i + x), yc, codepoint, self.fg, self.bg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue