vte: implement origin mode

Convert the old relative-addressing mode of the console layer into origin
mode flag.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-05-30 18:00:06 +02:00
parent cce9a5df15
commit 320b838644
3 changed files with 12 additions and 6 deletions

View File

@ -98,7 +98,6 @@ struct kmscon_console {
/* console cells */
struct kmscon_buffer *cells;
bool rel_addr; /* is relative addressing used? */
/* cursor */
unsigned int cursor_x;
@ -962,7 +961,7 @@ static inline unsigned int to_abs_x(struct kmscon_console *con, unsigned int x)
static inline unsigned int to_abs_y(struct kmscon_console *con, unsigned int y)
{
if (!con->rel_addr)
if (!(con->cells->flags & KMSCON_CONSOLE_REL_ORIGIN))
return y;
return con->cells->mtop_y + y;
@ -1130,7 +1129,7 @@ void kmscon_console_move_to(struct kmscon_console *con, unsigned int x,
con->cursor_y = to_abs_y(con, y);
if (con->cursor_y >= last) {
if (con->rel_addr)
if (con->cells->flags & KMSCON_CONSOLE_REL_ORIGIN)
con->cursor_y = last - 1;
else if (con->cursor_y >= con->cells->size_y)
con->cursor_y = con->cells->size_y - 1;
@ -1148,7 +1147,7 @@ void kmscon_console_move_up(struct kmscon_console *con, unsigned int num,
if (num > con->cells->size_y)
num = con->cells->size_y;
if (con->rel_addr) {
if (con->cells->flags & KMSCON_CONSOLE_REL_ORIGIN) {
diff = con->cursor_y - con->cells->mtop_y;
if (num > diff) {
num -= diff;
@ -1182,7 +1181,7 @@ void kmscon_console_move_down(struct kmscon_console *con, unsigned int num,
if (num > con->cells->size_y)
num = con->cells->size_y;
if (con->rel_addr) {
if (con->cells->flags & KMSCON_CONSOLE_REL_ORIGIN) {
diff = last - 1 - con->cursor_y;
if (num > diff) {
num -= diff;

View File

@ -46,6 +46,7 @@ struct kmscon_console;
#define KMSCON_CONSOLE_INSERT 0x01
#define KMSCON_CONSOLE_WRAP 0x02
#define KMSCON_CONSOLE_REL_ORIGIN 0x04
int kmscon_console_new(struct kmscon_console **out);
void kmscon_console_ref(struct kmscon_console *con);

View File

@ -129,7 +129,7 @@ enum parser_action {
#define FLAG_SEND_RECEIVE_MODE 0x00000100 /* Disable local echo */
#define FLAG_TEXT_CURSOR_MODE 0x00000200 /* Show cursor; TODO: implement */
#define FLAG_INVERSE_SCREEN_MODE 0x00000400 /* Inverse colors; TODO: implement */
#define FLAG_ORIGIN_MODE 0x00000800 /* Relative origin for cursor; TODO: implement */
#define FLAG_ORIGIN_MODE 0x00000800 /* Relative origin for cursor */
#define FLAG_AUTO_WRAP_MODE 0x00001000 /* Auto line wrap mode */
#define FLAG_AUTO_REPEAT_MODE 0x00002000 /* Auto repeat key press; TODO: implement */
#define FLAG_NATIONAL_CHARSET_MODE 0x00004000 /* Send keys from nation charsets; TODO: implement */
@ -910,6 +910,12 @@ static void csi_mode(struct kmscon_vte *vte, bool set)
continue;
case 6: /* DECOM */
set_reset_flag(vte, set, FLAG_ORIGIN_MODE);
if (set)
kmscon_console_set_flags(vte->con,
KMSCON_CONSOLE_REL_ORIGIN);
else
kmscon_console_reset_flags(vte->con,
KMSCON_CONSOLE_REL_ORIGIN);
continue;
case 7: /* DECAWN */
set_reset_flag(vte, set, FLAG_AUTO_WRAP_MODE);