fix: make popup rendering deterministic

This commit is contained in:
2026-08-12 15:59:52 +09:00
parent 9c43bcb75c
commit 4120f90736
13 changed files with 698 additions and 86 deletions

29
popup_layout.c Normal file
View File

@@ -0,0 +1,29 @@
#include "dat.h"
#include "popup_layout.h"
int
popupcells(Rune *r, int n)
{
int i, w;
w = 0;
for(i = 0; i < n; i++)
if(r[i] != 0xfe0e && r[i] != 0xfe0f)
w++;
return w;
}
void
popupposition(Caret *caret, int pointerx, int pointery, int screenw,
int screenh, int w, int h, int *x, int *y)
{
if(caret->valid){
*x = caret->x;
*y = caret->y + max(caret->h, 0);
}else{
*x = pointerx + 10;
*y = pointery + 10;
}
*x = max(0, min(*x, screenw - w));
*y = max(0, min(*y, screenh - h));
}