vte: allow setting margins

Support changing margin size of the terminal.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-05-30 20:49:39 +02:00
parent 3e6d31e958
commit cdc7834ba4
3 changed files with 38 additions and 1 deletions

View File

@ -1071,6 +1071,31 @@ unsigned int kmscon_console_get_height(struct kmscon_console *con)
return con->cells->size_y;
}
int kmscon_console_set_margins(struct kmscon_console *con,
unsigned int top, unsigned int bottom)
{
unsigned int upper, lower;
if (!con)
return -EINVAL;
if (!top)
top = 1;
if (bottom <= top) {
upper = 0;
lower = 0;
} else if (bottom > con->cells->size_y) {
upper = 0;
lower = 0;
} else {
upper = top - 1;
lower = con->cells->size_y - bottom;
}
return kmscon_buffer_set_margins(con->cells, upper, lower);
}
void kmscon_console_reset(struct kmscon_console *con)
{
if (!con)

View File

@ -60,6 +60,8 @@ unsigned int kmscon_console_get_width(struct kmscon_console *con);
unsigned int kmscon_console_get_height(struct kmscon_console *con);
int kmscon_console_resize(struct kmscon_console *con, unsigned int x,
unsigned int y, unsigned int height);
int kmscon_console_set_margins(struct kmscon_console *con,
unsigned int top, unsigned int bottom);
void kmscon_console_reset(struct kmscon_console *con);
void kmscon_console_set_flags(struct kmscon_console *con, unsigned int flags);
void kmscon_console_reset_flags(struct kmscon_console *con, unsigned int flags);

View File

@ -979,7 +979,7 @@ static void csi_dev_attr(struct kmscon_vte *vte)
static void do_csi(struct kmscon_vte *vte, uint32_t data)
{
int num, x, y;
int num, x, y, upper, lower;
if (vte->csi_argc < CSI_ARG_MAX)
vte->csi_argc++;
@ -1073,6 +1073,16 @@ static void do_csi(struct kmscon_vte *vte, uint32_t data)
case 'l': /* RM: Reset Mode */
csi_mode(vte, false);
break;
case 'r': /* DECSTBM */
/* set margin size */
upper = vte->csi_argv[0];
if (upper < 0)
upper = 0;
lower = vte->csi_argv[1];
if (lower < 0)
lower = 0;
kmscon_console_set_margins(vte->con, upper, lower);
break;
case 'c': /* DA */
/* device attributes */
csi_dev_attr(vte);