renderer/metal: handle preedit wider than our screen

This commit is contained in:
Mitchell Hashimoto
2023-11-15 09:53:51 -08:00
parent 50f0aaf26b
commit 7457b40a45
2 changed files with 9 additions and 2 deletions

View File

@@ -48,4 +48,12 @@ pub const Preedit = struct {
return result;
}
pub fn range(self: *const Preedit, start: usize, max: usize) [2]usize {
// If our preedit goes off the end of the screen, we adjust it so
// that it shifts left.
const end = start + self.width();
const offset = if (end > max) end - max else 0;
return .{ start -| offset, end -| offset };
}
};