fix: make popup rendering deterministic
This commit is contained in:
29
popup_layout.c
Normal file
29
popup_layout.c
Normal 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));
|
||||
}
|
||||
Reference in New Issue
Block a user