mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-02 07:15:31 -04:00
vt: don't try to move cursor outside the terminal
When we insert an auto-newline, we must make sure we don't try to move outside the terminal window. This can for example happen when a scrolling region have been configured, and the cursor is **outside** the scrolling region (i.e. it's in the bottom margin).
This commit is contained in:
parent
a81c65caa2
commit
0e5a69d869
1 changed files with 11 additions and 7 deletions
18
vt.c
18
vt.c
|
|
@ -12,6 +12,7 @@
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
#include "osc.h"
|
#include "osc.h"
|
||||||
|
|
||||||
|
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||||
|
|
||||||
#define UNHANDLED() LOG_DBG("unhandled: %s", esc_as_string(term, final))
|
#define UNHANDLED() LOG_DBG("unhandled: %s", esc_as_string(term, final))
|
||||||
|
|
@ -717,13 +718,16 @@ esc_dispatch(struct terminal *term, uint8_t final)
|
||||||
static inline void
|
static inline void
|
||||||
pre_print(struct terminal *term)
|
pre_print(struct terminal *term)
|
||||||
{
|
{
|
||||||
if (unlikely(term->cursor.lcf) && term->auto_margin) {
|
if (likely(!term->cursor.lcf))
|
||||||
if (term->cursor.point.row == term->scroll_region.end - 1) {
|
return;
|
||||||
term_scroll(term, 1);
|
if (unlikely(!term->auto_margin))
|
||||||
term_cursor_to(term, term->cursor.point.row, 0);
|
return;
|
||||||
} else
|
|
||||||
term_cursor_to(term, term->cursor.point.row + 1, 0);
|
if (term->cursor.point.row == term->scroll_region.end - 1) {
|
||||||
}
|
term_scroll(term, 1);
|
||||||
|
term_cursor_to(term, term->cursor.point.row, 0);
|
||||||
|
} else
|
||||||
|
term_cursor_to(term, min(term->cursor.point.row + 1, term->rows - 1), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue