2024-11-18 09:53:55 +00:00
|
|
|
#include "line-ed.h"
|
|
|
|
|
#include "cursor.h"
|
|
|
|
|
#include "prompt.h"
|
|
|
|
|
|
2024-12-13 17:20:45 +00:00
|
|
|
void line_ed_coords_to_physical_coords(
|
|
|
|
|
struct line_ed *ed, size_t x, size_t y, size_t *out_x, size_t *out_y)
|
2024-11-18 09:53:55 +00:00
|
|
|
{
|
2024-12-13 17:20:45 +00:00
|
|
|
size_t prompt_len = 0;
|
2024-11-18 09:53:55 +00:00
|
|
|
if (ed->l_cursor_y == 0) {
|
|
|
|
|
prompt_len = prompt_length(ed, PROMPT_MAIN);
|
|
|
|
|
} else if (ed->l_cursor_y <= ed->l_continuations) {
|
|
|
|
|
prompt_len = prompt_length(ed, PROMPT_CONT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (y == 0) {
|
|
|
|
|
x += prompt_len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (out_x) {
|
|
|
|
|
*out_x = x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (out_y) {
|
|
|
|
|
*out_y = y;
|
|
|
|
|
}
|
|
|
|
|
}
|