From 769d0e586ae4fdd3bcf5397e29148bf53d978d66 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 21 Oct 2014 13:20:53 -0400 Subject: implement scroll up and scroll down escape sequences --- src/parser.c | 668 +++++++++++++++++++++++++++++++---------------------------- src/parser.h | 2 +- src/parser.l | 28 +++ src/screen.c | 206 +++++++++--------- src/screen.h | 2 + 5 files changed, 488 insertions(+), 418 deletions(-) diff --git a/src/parser.c b/src/parser.c index 89831fa..cb8b367 100644 --- a/src/parser.c +++ b/src/parser.c @@ -351,8 +351,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 58 -#define YY_END_OF_BUFFER 59 +#define YY_NUM_RULES 60 +#define YY_END_OF_BUFFER 61 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -360,25 +360,25 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[152] = +static yyconst flex_int16_t yy_accept[154] = { 0, - 0, 0, 59, 56, 1, 2, 3, 4, 5, 6, - 7, 8, 50, 43, 57, 45, 46, 47, 54, 55, - 55, 55, 55, 55, 14, 15, 9, 10, 11, 48, - 49, 12, 13, 0, 0, 0, 43, 0, 0, 0, - 44, 46, 47, 0, 39, 0, 40, 0, 41, 0, - 42, 51, 52, 48, 48, 48, 48, 16, 17, 18, + 0, 0, 61, 58, 1, 2, 3, 4, 5, 6, + 7, 8, 52, 45, 59, 47, 48, 49, 56, 57, + 57, 57, 57, 57, 14, 15, 9, 10, 11, 50, + 51, 12, 13, 0, 0, 0, 45, 0, 0, 0, + 46, 48, 49, 0, 41, 0, 42, 0, 43, 0, + 44, 53, 54, 50, 50, 50, 50, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 0, 0, 0, 53, 49, - 49, 49, 49, 0, 0, 0, 0, 0, 0, 0, - 47, 48, 48, 48, 34, 35, 0, 0, 49, 49, - - 49, 0, 0, 0, 0, 48, 0, 48, 0, 36, - 49, 0, 0, 0, 37, 49, 0, 0, 0, 38, - 49, 0, 0, 0, 0, 48, 48, 0, 48, 0, - 0, 0, 0, 0, 0, 48, 0, 30, 31, 48, - 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, - 0 + 29, 30, 31, 32, 33, 34, 35, 0, 0, 0, + 55, 51, 51, 51, 51, 0, 0, 0, 0, 0, + 0, 0, 49, 50, 50, 50, 36, 37, 0, 0, + + 51, 51, 51, 0, 0, 0, 0, 50, 0, 50, + 0, 38, 51, 0, 0, 0, 39, 51, 0, 0, + 0, 40, 51, 0, 0, 0, 0, 50, 50, 0, + 50, 0, 0, 0, 0, 0, 0, 50, 0, 32, + 33, 50, 0, 0, 0, 50, 50, 50, 50, 50, + 50, 50, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -391,248 +391,256 @@ static yyconst flex_int32_t yy_ec[256] = 19, 19, 19, 19, 20, 21, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 22, 22, 33, 34, 22, 35, 36, 37, 38, 22, 22, 39, - 22, 22, 22, 22, 22, 22, 22, 40, 22, 22, - 41, 22, 42, 22, 22, 22, 22, 22, 43, 44, - - 22, 22, 45, 46, 22, 22, 22, 47, 48, 22, - 22, 22, 22, 49, 22, 22, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 1, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, - - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 51, 51, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 53, - 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, - 54, 54, 54, 54, 54 + 22, 22, 40, 41, 22, 22, 22, 42, 22, 22, + 43, 22, 44, 22, 22, 22, 22, 22, 45, 46, + + 22, 22, 47, 48, 22, 22, 22, 49, 50, 22, + 22, 22, 22, 51, 22, 22, 22, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 1, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, + + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 54, 54, 54, 54, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 55, + 55, 55, 55, 55, 55, 55, 55, 56, 56, 56, + 56, 56, 56, 56, 56 } ; -static yyconst flex_int32_t yy_meta[55] = +static yyconst flex_int32_t yy_meta[57] = { 0, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 3, 5, 6, 6, 3, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 5, 5, 3, 3, 7, - 8, 8, 8, 7 + 3, 3, 3, 3, 3, 3, 3, 5, 5, 3, + 3, 7, 8, 8, 8, 7 } ; -static yyconst flex_int16_t yy_base[171] = +static yyconst flex_int16_t yy_base[173] = { 0, - 0, 54, 408, 676, 676, 676, 676, 676, 676, 676, - 676, 676, 108, 14, 676, 357, 356, 355, 676, 676, - 0, 5, 10, 15, 676, 676, 676, 676, 676, 161, - 29, 676, 676, 354, 353, 352, 17, 350, 349, 347, - 20, 346, 344, 21, 676, 26, 676, 63, 676, 72, - 676, 676, 676, 192, 676, 241, 294, 676, 676, 676, - 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - 676, 676, 676, 676, 676, 336, 327, 325, 676, 40, - 216, 229, 232, 316, 315, 314, 313, 312, 311, 310, - 308, 70, 332, 56, 676, 676, 304, 294, 47, 219, - - 222, 293, 291, 278, 276, 364, 209, 208, 266, 676, - 235, 259, 228, 216, 676, 238, 215, 213, 204, 676, - 254, 203, 188, 186, 173, 398, 252, 285, 302, 172, - 170, 161, 108, 51, 46, 432, 300, 676, 676, 317, - 40, 39, 38, 466, 315, 500, 534, 332, 353, 372, - 676, 583, 589, 595, 599, 603, 607, 612, 618, 626, - 631, 636, 643, 650, 655, 658, 661, 663, 666, 669 + 0, 56, 410, 704, 704, 704, 704, 704, 704, 704, + 704, 704, 112, 14, 704, 357, 356, 355, 704, 704, + 0, 5, 10, 15, 704, 704, 704, 704, 704, 167, + 29, 704, 704, 354, 353, 350, 17, 341, 340, 339, + 20, 337, 328, 21, 704, 26, 704, 65, 704, 74, + 704, 704, 704, 200, 704, 251, 306, 704, 704, 704, + 704, 704, 704, 704, 704, 704, 704, 704, 704, 704, + 704, 704, 704, 704, 704, 704, 704, 327, 326, 324, + 704, 40, 224, 227, 239, 316, 305, 299, 298, 297, + 288, 286, 276, 24, 346, 58, 704, 704, 269, 268, + + 48, 230, 233, 251, 250, 224, 223, 380, 279, 72, + 221, 704, 236, 213, 212, 211, 704, 264, 197, 196, + 194, 704, 299, 191, 190, 188, 182, 416, 206, 196, + 314, 176, 112, 53, 52, 48, 46, 452, 212, 704, + 704, 327, 40, 39, 38, 488, 312, 524, 560, 331, + 354, 367, 704, 611, 617, 623, 627, 631, 635, 640, + 646, 654, 659, 664, 671, 678, 683, 686, 689, 691, + 694, 697 } ; -static yyconst flex_int16_t yy_def[171] = +static yyconst flex_int16_t yy_def[173] = { 0, - 152, 152, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 153, 151, 151, 151, 151, 151, 151, - 154, 155, 156, 157, 151, 151, 151, 151, 151, 151, - 158, 151, 151, 151, 151, 151, 153, 151, 151, 151, - 159, 151, 151, 154, 151, 155, 151, 156, 151, 157, - 151, 151, 151, 30, 151, 160, 160, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 158, - 158, 158, 158, 151, 151, 151, 151, 151, 151, 151, - 151, 161, 57, 57, 151, 151, 151, 151, 162, 163, - - 164, 151, 151, 151, 151, 93, 151, 165, 151, 151, - 162, 151, 151, 151, 151, 163, 151, 151, 151, 151, - 164, 151, 151, 151, 151, 93, 166, 167, 93, 151, - 151, 151, 151, 151, 151, 93, 168, 151, 151, 93, - 151, 151, 151, 93, 169, 93, 93, 170, 93, 93, - 0, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151 + 154, 154, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 155, 153, 153, 153, 153, 153, 153, + 156, 157, 158, 159, 153, 153, 153, 153, 153, 153, + 160, 153, 153, 153, 153, 153, 155, 153, 153, 153, + 161, 153, 153, 156, 153, 157, 153, 158, 153, 159, + 153, 153, 153, 30, 153, 162, 162, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 160, 160, 160, 160, 153, 153, 153, 153, 153, + 153, 153, 153, 163, 57, 57, 153, 153, 153, 153, + + 164, 165, 166, 153, 153, 153, 153, 95, 153, 167, + 153, 153, 164, 153, 153, 153, 153, 165, 153, 153, + 153, 153, 166, 153, 153, 153, 153, 95, 168, 169, + 95, 153, 153, 153, 153, 153, 153, 95, 170, 153, + 153, 95, 153, 153, 153, 95, 171, 95, 95, 172, + 95, 95, 0, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153 } ; -static yyconst flex_int16_t yy_nxt[731] = +static yyconst flex_int16_t yy_nxt[761] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 44, 44, 44, 44, 44, 46, 46, 46, 46, 46, 48, 48, 48, 48, 48, 50, 50, 50, 50, 50, - 79, 44, 44, 44, 44, 44, 46, 46, 46, 46, - 46, 79, 151, 151, 81, 82, 83, 151, 110, 15, - 16, 17, 18, 15, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 38, 39, 40, 38, 39, 40, - 38, 39, 40, 48, 48, 48, 48, 48, 108, 84, - 85, 86, 50, 50, 50, 50, 50, 121, 116, 111, - 84, 85, 86, 107, 107, 143, 107, 112, 113, 114, - - 121, 72, 73, 15, 16, 17, 18, 15, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 20, 21, - 22, 23, 24, 20, 20, 20, 20, 25, 26, 20, - 20, 20, 27, 28, 20, 20, 20, 20, 20, 20, - 20, 20, 20, 20, 20, 29, 20, 20, 30, 31, - 32, 20, 33, 20, 20, 20, 20, 142, 34, 35, - 36, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, - 54, 54, 53, 55, 56, 56, 53, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - - 70, 53, 53, 53, 71, 53, 72, 73, 74, 75, - 116, 76, 77, 78, 92, 53, 53, 79, 53, 141, - 115, 111, 80, 120, 128, 128, 128, 128, 128, 128, - 79, 107, 107, 79, 107, 135, 110, 134, 99, 115, + 81, 44, 44, 44, 44, 44, 46, 46, 46, 46, + 46, 81, 153, 153, 83, 84, 85, 109, 109, 112, + 109, 15, 16, 17, 18, 15, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 38, 39, 40, 38, + 39, 40, 38, 39, 40, 48, 48, 48, 48, 48, + 110, 86, 87, 88, 50, 50, 50, 50, 50, 123, + 118, 113, 86, 87, 88, 109, 109, 145, 109, 123, + + 114, 115, 116, 144, 118, 74, 75, 15, 16, 17, + 18, 15, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 20, 21, 22, 23, 24, 20, 20, 20, + 20, 25, 26, 20, 20, 20, 27, 28, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 29, + 20, 20, 20, 20, 30, 31, 32, 20, 33, 20, + 20, 20, 20, 143, 34, 35, 36, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 52, 53, 53, 53, + 53, 53, 54, 54, 54, 54, 54, 54, 53, 55, + 56, 56, 53, 57, 58, 59, 60, 61, 62, 63, + + 64, 65, 66, 67, 68, 69, 70, 71, 72, 53, + 53, 53, 73, 53, 74, 75, 76, 77, 139, 78, + 79, 80, 94, 53, 53, 81, 53, 113, 81, 109, + 109, 117, 109, 82, 122, 109, 109, 112, 109, 137, + 81, 136, 123, 140, 141, 135, 101, 134, 118, 102, 53, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 100, 121, 133, 101, 120, 93, 93, 93, 93, - 93, 93, 132, 55, 116, 131, 84, 85, 86, 117, - 118, 119, 122, 123, 124, 107, 107, 130, 107, 84, - 85, 86, 84, 85, 86, 112, 113, 114, 117, 118, - 119, 76, 77, 78, 52, 52, 52, 52, 52, 52, - - 52, 52, 52, 52, 122, 123, 124, 137, 111, 94, - 94, 94, 94, 94, 94, 53, 55, 140, 140, 140, - 140, 140, 140, 107, 107, 41, 107, 20, 95, 96, - 138, 139, 140, 140, 140, 140, 140, 140, 107, 107, - 125, 107, 80, 109, 76, 77, 78, 93, 93, 93, - 93, 93, 93, 53, 108, 107, 107, 41, 107, 105, - 41, 104, 20, 103, 102, 80, 53, 53, 150, 150, - 150, 150, 150, 150, 98, 148, 97, 72, 73, 126, - 126, 126, 126, 126, 126, 53, 127, 150, 150, 150, - 150, 150, 150, 91, 148, 41, 90, 64, 89, 41, - - 74, 88, 87, 20, 43, 42, 41, 151, 151, 151, - 151, 74, 75, 126, 126, 126, 126, 126, 126, 74, - 127, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 64, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 74, 75, 144, 144, 144, - 144, 144, 144, 151, 145, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 74, - 75, 144, 144, 144, 144, 144, 144, 151, 145, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 74, 75, 147, 147, 147, 147, 147, - 147, 151, 148, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 74, 75, 147, - 147, 147, 147, 147, 147, 151, 148, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 74, 75, 14, 14, 14, 14, 14, 14, 14, - 14, 37, 37, 37, 37, 151, 37, 45, 45, 45, - - 45, 47, 47, 47, 47, 49, 49, 49, 49, 51, - 51, 51, 51, 80, 80, 80, 80, 80, 151, 80, - 41, 41, 41, 41, 151, 41, 53, 53, 53, 53, - 53, 53, 151, 53, 106, 151, 106, 111, 111, 111, - 111, 111, 151, 111, 116, 116, 116, 116, 116, 151, - 116, 121, 121, 121, 121, 121, 151, 121, 129, 151, - 129, 136, 151, 136, 128, 128, 128, 151, 128, 146, - 151, 146, 149, 151, 149, 3, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151 + 52, 103, 133, 132, 113, 117, 95, 95, 95, 95, + 95, 95, 53, 55, 41, 20, 86, 87, 88, 86, + 87, 88, 119, 120, 121, 124, 125, 126, 114, 115, + 116, 86, 87, 88, 130, 130, 130, 130, 130, 130, + + 122, 127, 82, 78, 79, 80, 52, 52, 52, 52, + 52, 52, 52, 52, 52, 52, 119, 120, 121, 111, + 53, 96, 96, 96, 96, 96, 96, 41, 55, 142, + 142, 142, 142, 142, 142, 109, 109, 107, 109, 41, + 97, 98, 142, 142, 142, 142, 142, 142, 106, 20, + 105, 124, 125, 126, 109, 109, 104, 109, 78, 79, + 80, 95, 95, 95, 95, 95, 95, 82, 110, 152, + 152, 152, 152, 152, 152, 100, 150, 99, 53, 93, + 53, 53, 152, 152, 152, 152, 152, 152, 41, 150, + 92, 91, 41, 74, 75, 128, 128, 128, 128, 128, + + 128, 90, 129, 76, 89, 20, 43, 42, 41, 153, + 153, 153, 153, 64, 153, 153, 76, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 76, + 77, 128, 128, 128, 128, 128, 128, 153, 129, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 64, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 76, 77, 146, 146, 146, + 146, 146, 146, 153, 147, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + + 153, 76, 77, 146, 146, 146, 146, 146, 146, 153, + 147, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 76, 77, 149, + 149, 149, 149, 149, 149, 153, 150, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 76, 77, 149, 149, 149, 149, 149, + 149, 153, 150, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + + 153, 153, 153, 153, 153, 153, 153, 153, 153, 76, + 77, 14, 14, 14, 14, 14, 14, 14, 14, 37, + 37, 37, 37, 153, 37, 45, 45, 45, 45, 47, + 47, 47, 47, 49, 49, 49, 49, 51, 51, 51, + 51, 82, 82, 82, 82, 82, 153, 82, 41, 41, + 41, 41, 153, 41, 53, 53, 53, 53, 53, 53, + 153, 53, 108, 153, 108, 113, 113, 113, 113, 113, + 153, 113, 118, 118, 118, 118, 118, 153, 118, 123, + 123, 123, 123, 123, 153, 123, 131, 153, 131, 138, + 153, 138, 130, 130, 130, 153, 130, 148, 153, 148, + + 151, 153, 151, 3, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153 } ; -static yyconst flex_int16_t yy_chk[731] = +static yyconst flex_int16_t yy_chk[761] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 31, 44, 44, 44, 44, 44, 46, 46, 46, 46, - 46, 80, 0, 0, 31, 31, 31, 0, 99, 1, - 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 14, 14, 14, 37, 37, 37, - 41, 41, 41, 48, 48, 48, 48, 48, 94, 31, - 31, 31, 50, 50, 50, 50, 50, 143, 142, 141, - 80, 80, 80, 92, 92, 135, 92, 99, 99, 99, - - 134, 94, 94, 2, 2, 2, 2, 2, 13, 13, + 46, 82, 0, 0, 31, 31, 31, 94, 94, 101, + 94, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 14, 14, 14, 37, + 37, 37, 41, 41, 41, 48, 48, 48, 48, 48, + 96, 31, 31, 31, 50, 50, 50, 50, 50, 145, + 144, 143, 82, 82, 82, 110, 110, 137, 110, 136, + + 101, 101, 101, 135, 134, 96, 96, 2, 2, 2, + 2, 2, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 133, 13, 13, - 13, 30, 30, 30, 30, 30, 30, 30, 30, 30, + 13, 13, 13, 133, 13, 13, 13, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 132, 30, 30, 30, 54, 54, 54, 81, 54, 131, - 100, 130, 125, 101, 107, 107, 107, 107, 107, 107, - 82, 108, 108, 83, 108, 124, 111, 123, 81, 116, + 30, 30, 30, 30, 30, 30, 30, 30, 130, 30, + 30, 30, 54, 54, 54, 83, 54, 132, 84, 129, + 129, 102, 129, 127, 103, 139, 139, 113, 139, 126, + 85, 125, 124, 130, 130, 121, 83, 120, 119, 84, 54, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 82, 122, 119, 83, 121, 56, 56, 56, 56, - 56, 56, 118, 56, 117, 114, 81, 81, 81, 100, - 100, 100, 101, 101, 101, 127, 127, 113, 127, 82, - 82, 82, 83, 83, 83, 111, 111, 111, 116, 116, - 116, 56, 56, 56, 57, 57, 57, 57, 57, 57, - - 57, 57, 57, 57, 121, 121, 121, 128, 112, 57, - 57, 57, 57, 57, 57, 109, 57, 129, 129, 129, - 129, 129, 129, 137, 137, 105, 137, 104, 57, 57, - 128, 128, 140, 140, 140, 140, 140, 140, 145, 145, - 103, 145, 102, 98, 57, 57, 57, 93, 93, 93, - 93, 93, 93, 97, 93, 148, 148, 91, 148, 90, - 89, 88, 87, 86, 85, 84, 93, 93, 149, 149, - 149, 149, 149, 149, 78, 149, 77, 93, 93, 106, - 106, 106, 106, 106, 106, 76, 106, 150, 150, 150, - 150, 150, 150, 43, 150, 42, 40, 106, 39, 38, - - 149, 36, 35, 34, 18, 17, 16, 3, 0, 0, - 0, 106, 106, 126, 126, 126, 126, 126, 126, 150, - 126, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 126, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 126, 126, 136, 136, 136, - 136, 136, 136, 0, 136, 0, 0, 0, 0, 0, + 56, 85, 116, 115, 114, 118, 56, 56, 56, 56, + 56, 56, 111, 56, 107, 106, 83, 83, 83, 84, + 84, 84, 102, 102, 102, 103, 103, 103, 113, 113, + 113, 85, 85, 85, 109, 109, 109, 109, 109, 109, + + 123, 105, 104, 56, 56, 56, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 57, 118, 118, 118, 100, + 99, 57, 57, 57, 57, 57, 57, 93, 57, 131, + 131, 131, 131, 131, 131, 147, 147, 92, 147, 91, + 57, 57, 142, 142, 142, 142, 142, 142, 90, 89, + 88, 123, 123, 123, 150, 150, 87, 150, 57, 57, + 57, 95, 95, 95, 95, 95, 95, 86, 95, 151, + 151, 151, 151, 151, 151, 80, 151, 79, 78, 43, + 95, 95, 152, 152, 152, 152, 152, 152, 42, 152, + 40, 39, 38, 95, 95, 108, 108, 108, 108, 108, + + 108, 36, 108, 151, 35, 34, 18, 17, 16, 3, + 0, 0, 0, 108, 0, 0, 152, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 108, + 108, 128, 128, 128, 128, 128, 128, 0, 128, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 128, 128, 138, 138, 138, + 138, 138, 138, 0, 138, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 136, - 136, 144, 144, 144, 144, 144, 144, 0, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 138, 138, 146, 146, 146, 146, 146, 146, 0, + 146, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 144, 144, 146, 146, 146, 146, 146, - 146, 0, 146, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 146, 146, 148, + 148, 148, 148, 148, 148, 0, 148, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 146, 146, 147, - 147, 147, 147, 147, 147, 0, 147, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 148, 148, 149, 149, 149, 149, 149, + 149, 0, 149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 147, 147, 152, 152, 152, 152, 152, 152, 152, - 152, 153, 153, 153, 153, 0, 153, 154, 154, 154, - - 154, 155, 155, 155, 155, 156, 156, 156, 156, 157, - 157, 157, 157, 158, 158, 158, 158, 158, 0, 158, - 159, 159, 159, 159, 0, 159, 160, 160, 160, 160, - 160, 160, 0, 160, 161, 0, 161, 162, 162, 162, - 162, 162, 0, 162, 163, 163, 163, 163, 163, 0, - 163, 164, 164, 164, 164, 164, 0, 164, 165, 0, - 165, 166, 0, 166, 167, 167, 168, 0, 168, 169, - 0, 169, 170, 0, 170, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, 151, 151, 151, 151 + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 149, + 149, 154, 154, 154, 154, 154, 154, 154, 154, 155, + 155, 155, 155, 0, 155, 156, 156, 156, 156, 157, + 157, 157, 157, 158, 158, 158, 158, 159, 159, 159, + 159, 160, 160, 160, 160, 160, 0, 160, 161, 161, + 161, 161, 0, 161, 162, 162, 162, 162, 162, 162, + 0, 162, 163, 0, 163, 164, 164, 164, 164, 164, + 0, 164, 165, 165, 165, 165, 165, 0, 165, 166, + 166, 166, 166, 166, 0, 166, 167, 0, 167, 168, + 0, 168, 169, 169, 170, 0, 170, 171, 0, 171, + + 172, 0, 172, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153 } ; /* The intent behind this definition is that it'll catch @@ -654,7 +662,7 @@ static yyconst flex_int16_t yy_chk[731] = #define YY_EXIT_FAILURE (UNUSED(yyscanner), 2) #define YY_NO_INPUT 1 -#line 87 "src/parser.l" +#line 89 "src/parser.l" static void vt100_parser_handle_bel(VT100Screen *vt); static void vt100_parser_handle_bs(VT100Screen *vt); static void vt100_parser_handle_tab(VT100Screen *vt); @@ -683,6 +691,8 @@ static void vt100_parser_handle_el(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_il(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_dl(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_dch(VT100Screen *vt, char *buf, size_t len); +static void vt100_parser_handle_su(VT100Screen *vt, char *buf, size_t len); +static void vt100_parser_handle_sd(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_ech(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_vpa(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_sm(VT100Screen *vt, char *buf, size_t len); @@ -696,7 +706,7 @@ static void vt100_parser_handle_osc1(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_osc2(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_ascii(VT100Screen *vt, char *text, size_t len); static void vt100_parser_handle_text(VT100Screen *vt, char *text, size_t len); -#line 700 "src/parser.c" +#line 710 "src/parser.c" #define INITIAL 0 @@ -944,10 +954,10 @@ YY_DECL } { -#line 130 "src/parser.l" +#line 134 "src/parser.l" -#line 951 "src/parser.c" +#line 961 "src/parser.c" while ( 1 ) /* loops until end-of-file is reached */ { @@ -974,13 +984,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 152 ) + if ( yy_current_state >= 154 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } - while ( yy_current_state != 151 ); + while ( yy_current_state != 153 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -1002,251 +1012,261 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 132 "src/parser.l" +#line 136 "src/parser.l" vt100_parser_handle_bel(yyextra); YY_BREAK case 2: YY_RULE_SETUP -#line 133 "src/parser.l" +#line 137 "src/parser.l" vt100_parser_handle_bs(yyextra); YY_BREAK case 3: YY_RULE_SETUP -#line 134 "src/parser.l" +#line 138 "src/parser.l" vt100_parser_handle_tab(yyextra); YY_BREAK case 4: /* rule 4 can match eol */ -#line 136 "src/parser.l" +#line 140 "src/parser.l" case 5: /* rule 5 can match eol */ -#line 137 "src/parser.l" +#line 141 "src/parser.l" case 6: /* rule 6 can match eol */ YY_RULE_SETUP -#line 137 "src/parser.l" +#line 141 "src/parser.l" vt100_parser_handle_lf(yyextra); YY_BREAK case 7: YY_RULE_SETUP -#line 138 "src/parser.l" +#line 142 "src/parser.l" vt100_parser_handle_cr(yyextra); YY_BREAK case 8: YY_RULE_SETUP -#line 139 "src/parser.l" +#line 143 "src/parser.l" /* ignored */ YY_BREAK case 9: YY_RULE_SETUP -#line 141 "src/parser.l" +#line 145 "src/parser.l" vt100_parser_handle_deckpam(yyextra); YY_BREAK case 10: YY_RULE_SETUP -#line 142 "src/parser.l" +#line 146 "src/parser.l" vt100_parser_handle_deckpnm(yyextra); YY_BREAK case 11: YY_RULE_SETUP -#line 143 "src/parser.l" +#line 147 "src/parser.l" vt100_parser_handle_ri(yyextra); YY_BREAK case 12: YY_RULE_SETUP -#line 144 "src/parser.l" +#line 148 "src/parser.l" vt100_parser_handle_ris(yyextra); YY_BREAK case 13: YY_RULE_SETUP -#line 145 "src/parser.l" +#line 149 "src/parser.l" vt100_parser_handle_vb(yyextra); YY_BREAK case 14: YY_RULE_SETUP -#line 146 "src/parser.l" +#line 150 "src/parser.l" vt100_parser_handle_decsc(yyextra); YY_BREAK case 15: YY_RULE_SETUP -#line 147 "src/parser.l" +#line 151 "src/parser.l" vt100_parser_handle_decrc(yyextra); YY_BREAK case 16: YY_RULE_SETUP -#line 149 "src/parser.l" +#line 153 "src/parser.l" vt100_parser_handle_ich(yyextra, yytext, yyleng); YY_BREAK case 17: YY_RULE_SETUP -#line 150 "src/parser.l" +#line 154 "src/parser.l" vt100_parser_handle_cuu(yyextra, yytext, yyleng); YY_BREAK case 18: YY_RULE_SETUP -#line 151 "src/parser.l" +#line 155 "src/parser.l" vt100_parser_handle_cud(yyextra, yytext, yyleng); YY_BREAK case 19: YY_RULE_SETUP -#line 152 "src/parser.l" +#line 156 "src/parser.l" vt100_parser_handle_cuf(yyextra, yytext, yyleng); YY_BREAK case 20: YY_RULE_SETUP -#line 153 "src/parser.l" +#line 157 "src/parser.l" vt100_parser_handle_cub(yyextra, yytext, yyleng); YY_BREAK case 21: YY_RULE_SETUP -#line 154 "src/parser.l" +#line 158 "src/parser.l" vt100_parser_handle_cha(yyextra, yytext, yyleng); YY_BREAK case 22: YY_RULE_SETUP -#line 155 "src/parser.l" +#line 159 "src/parser.l" vt100_parser_handle_cup(yyextra, yytext, yyleng); YY_BREAK case 23: YY_RULE_SETUP -#line 156 "src/parser.l" +#line 160 "src/parser.l" vt100_parser_handle_ed(yyextra, yytext, yyleng); YY_BREAK case 24: YY_RULE_SETUP -#line 157 "src/parser.l" +#line 161 "src/parser.l" vt100_parser_handle_el(yyextra, yytext, yyleng); YY_BREAK case 25: YY_RULE_SETUP -#line 158 "src/parser.l" +#line 162 "src/parser.l" vt100_parser_handle_il(yyextra, yytext, yyleng); YY_BREAK case 26: YY_RULE_SETUP -#line 159 "src/parser.l" +#line 163 "src/parser.l" vt100_parser_handle_dl(yyextra, yytext, yyleng); YY_BREAK case 27: YY_RULE_SETUP -#line 160 "src/parser.l" +#line 164 "src/parser.l" vt100_parser_handle_dch(yyextra, yytext, yyleng); YY_BREAK case 28: YY_RULE_SETUP -#line 161 "src/parser.l" -vt100_parser_handle_ech(yyextra, yytext, yyleng); +#line 165 "src/parser.l" +vt100_parser_handle_su(yyextra, yytext, yyleng); YY_BREAK case 29: YY_RULE_SETUP -#line 162 "src/parser.l" -vt100_parser_handle_vpa(yyextra, yytext, yyleng); +#line 166 "src/parser.l" +vt100_parser_handle_sd(yyextra, yytext, yyleng); YY_BREAK case 30: YY_RULE_SETUP -#line 163 "src/parser.l" -vt100_parser_handle_sm(yyextra, yytext, yyleng); +#line 167 "src/parser.l" +vt100_parser_handle_ech(yyextra, yytext, yyleng); YY_BREAK case 31: YY_RULE_SETUP -#line 164 "src/parser.l" -vt100_parser_handle_rm(yyextra, yytext, yyleng); +#line 168 "src/parser.l" +vt100_parser_handle_vpa(yyextra, yytext, yyleng); YY_BREAK case 32: YY_RULE_SETUP -#line 165 "src/parser.l" -vt100_parser_handle_sgr(yyextra, yytext, yyleng); +#line 169 "src/parser.l" +vt100_parser_handle_sm(yyextra, yytext, yyleng); YY_BREAK case 33: YY_RULE_SETUP -#line 166 "src/parser.l" -vt100_parser_handle_csr(yyextra, yytext, yyleng); +#line 170 "src/parser.l" +vt100_parser_handle_rm(yyextra, yytext, yyleng); YY_BREAK case 34: YY_RULE_SETUP -#line 168 "src/parser.l" -vt100_parser_handle_decsed(yyextra, yytext, yyleng); +#line 171 "src/parser.l" +vt100_parser_handle_sgr(yyextra, yytext, yyleng); YY_BREAK case 35: YY_RULE_SETUP -#line 169 "src/parser.l" -vt100_parser_handle_decsel(yyextra, yytext, yyleng); +#line 172 "src/parser.l" +vt100_parser_handle_csr(yyextra, yytext, yyleng); YY_BREAK case 36: YY_RULE_SETUP -#line 171 "src/parser.l" -vt100_parser_handle_osc0(yyextra, yytext, yyleng); +#line 174 "src/parser.l" +vt100_parser_handle_decsed(yyextra, yytext, yyleng); YY_BREAK case 37: YY_RULE_SETUP -#line 172 "src/parser.l" -vt100_parser_handle_osc1(yyextra, yytext, yyleng); +#line 175 "src/parser.l" +vt100_parser_handle_decsel(yyextra, yytext, yyleng); YY_BREAK case 38: YY_RULE_SETUP -#line 173 "src/parser.l" -vt100_parser_handle_osc2(yyextra, yytext, yyleng); +#line 177 "src/parser.l" +vt100_parser_handle_osc0(yyextra, yytext, yyleng); YY_BREAK case 39: -#line 176 "src/parser.l" +YY_RULE_SETUP +#line 178 "src/parser.l" +vt100_parser_handle_osc1(yyextra, yytext, yyleng); + YY_BREAK case 40: -#line 177 "src/parser.l" +YY_RULE_SETUP +#line 179 "src/parser.l" +vt100_parser_handle_osc2(yyextra, yytext, yyleng); + YY_BREAK case 41: -#line 178 "src/parser.l" +#line 182 "src/parser.l" case 42: +#line 183 "src/parser.l" +case 43: +#line 184 "src/parser.l" +case 44: YY_RULE_SETUP -#line 178 "src/parser.l" +#line 184 "src/parser.l" /* ignored */ YY_BREAK -case 43: +case 45: YY_RULE_SETUP -#line 180 "src/parser.l" +#line 186 "src/parser.l" vt100_parser_handle_ascii(yyextra, yytext, yyleng); YY_BREAK -case 44: +case 46: YY_RULE_SETUP -#line 181 "src/parser.l" +#line 187 "src/parser.l" vt100_parser_handle_text(yyextra, yytext, yyleng); YY_BREAK -case 45: -#line 184 "src/parser.l" -case 46: -#line 185 "src/parser.l" case 47: -#line 186 "src/parser.l" +#line 190 "src/parser.l" case 48: -#line 187 "src/parser.l" +#line 191 "src/parser.l" case 49: -#line 188 "src/parser.l" +#line 192 "src/parser.l" case 50: +#line 193 "src/parser.l" +case 51: +#line 194 "src/parser.l" +case 52: YY_RULE_SETUP -#line 188 "src/parser.l" +#line 194 "src/parser.l" return yyleng; YY_BREAK case YY_STATE_EOF(INITIAL): -#line 190 "src/parser.l" +#line 196 "src/parser.l" return 0; YY_BREAK -case 51: -/* rule 51 can match eol */ +case 53: +/* rule 53 can match eol */ YY_RULE_SETUP -#line 192 "src/parser.l" +#line 198 "src/parser.l" { fprintf(stderr, "unhandled CSI sequence: \\033%s\\%03hho\n", yytext + 1, yytext[yyleng - 1]); } YY_BREAK -case 52: +case 54: YY_RULE_SETUP -#line 198 "src/parser.l" +#line 204 "src/parser.l" { fprintf(stderr, "unhandled CSI sequence: \\033%s\n", yytext + 1); } YY_BREAK -case 53: +case 55: YY_RULE_SETUP -#line 202 "src/parser.l" +#line 208 "src/parser.l" { if (!strncmp(yytext, "\e]50;", 5)) { // osx terminal.app private stuff // not interested in non-portable extensions @@ -1262,17 +1282,17 @@ YY_RULE_SETUP } } YY_BREAK -case 54: -/* rule 54 can match eol */ +case 56: +/* rule 56 can match eol */ YY_RULE_SETUP -#line 217 "src/parser.l" +#line 223 "src/parser.l" { fprintf(stderr, "unhandled escape sequence: \\%03hho\n", yytext[1]); } YY_BREAK -case 55: +case 57: YY_RULE_SETUP -#line 221 "src/parser.l" +#line 227 "src/parser.l" { switch (yytext[1]) { case '(': // character sets @@ -1285,27 +1305,27 @@ YY_RULE_SETUP } } YY_BREAK -case 56: -/* rule 56 can match eol */ +case 58: +/* rule 58 can match eol */ YY_RULE_SETUP -#line 233 "src/parser.l" +#line 239 "src/parser.l" { fprintf(stderr, "unhandled control character: \\%03hho\n", yytext[0]); } YY_BREAK -case 57: +case 59: YY_RULE_SETUP -#line 237 "src/parser.l" +#line 243 "src/parser.l" { fprintf(stderr, "invalid utf8 byte: \\%03hho\n", yytext[0]); } YY_BREAK -case 58: +case 60: YY_RULE_SETUP -#line 241 "src/parser.l" +#line 247 "src/parser.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 1309 "src/parser.c" +#line 1329 "src/parser.c" case YY_END_OF_BUFFER: { @@ -1599,7 +1619,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 152 ) + if ( yy_current_state >= 154 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1628,11 +1648,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 152 ) + if ( yy_current_state >= 154 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 151); + yy_is_jam = (yy_current_state == 153); (void)yyg; return yy_is_jam ? 0 : yy_current_state; @@ -2397,7 +2417,7 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 241 "src/parser.l" +#line 247 "src/parser.l" @@ -2671,6 +2691,28 @@ static void vt100_parser_handle_dch(VT100Screen *vt, char *buf, size_t len) vt100_screen_delete_characters(vt, params[0]); } +static void vt100_parser_handle_su(VT100Screen *vt, char *buf, size_t len) +{ + int params[VT100_PARSER_CSI_MAX_PARAMS] = { 1 }, nparams; + + vt100_parser_extract_csi_params(buf + 2, len - 3, params, &nparams); + if (params[0] == 0) { + params[0] = 1; + } + vt100_screen_scroll_up(vt, params[0]); +} + +static void vt100_parser_handle_sd(VT100Screen *vt, char *buf, size_t len) +{ + int params[VT100_PARSER_CSI_MAX_PARAMS] = { 1 }, nparams; + + vt100_parser_extract_csi_params(buf + 2, len - 3, params, &nparams); + if (params[0] == 0) { + params[0] = 1; + } + vt100_screen_scroll_down(vt, params[0]); +} + static void vt100_parser_handle_ech(VT100Screen *vt, char *buf, size_t len) { int params[VT100_PARSER_CSI_MAX_PARAMS] = { 1 }, nparams; diff --git a/src/parser.h b/src/parser.h index 0545145..a269622 100644 --- a/src/parser.h +++ b/src/parser.h @@ -330,7 +330,7 @@ extern int vt100_parser_yylex (yyscan_t yyscanner); #undef YY_DECL #endif -#line 241 "src/parser.l" +#line 247 "src/parser.l" #line 337 "src/parser.h" diff --git a/src/parser.l b/src/parser.l index 773aa95..4a72b0e 100644 --- a/src/parser.l +++ b/src/parser.l @@ -64,6 +64,8 @@ EL {CSI}{CSIPARAM1}K IL {CSI}{CSIPARAM1}L DL {CSI}{CSIPARAM1}M DCH {CSI}{CSIPARAM1}P +SU {CSI}{CSIPARAM1}S +SD {CSI}{CSIPARAM1}T ECH {CSI}{CSIPARAM1}X VPA {CSI}{CSIPARAM1}d SM {CSI}{SMPARAMS}h @@ -112,6 +114,8 @@ static void vt100_parser_handle_el(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_il(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_dl(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_dch(VT100Screen *vt, char *buf, size_t len); +static void vt100_parser_handle_su(VT100Screen *vt, char *buf, size_t len); +static void vt100_parser_handle_sd(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_ech(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_vpa(VT100Screen *vt, char *buf, size_t len); static void vt100_parser_handle_sm(VT100Screen *vt, char *buf, size_t len); @@ -158,6 +162,8 @@ static void vt100_parser_handle_text(VT100Screen *vt, char *text, size_t len); {IL} vt100_parser_handle_il(yyextra, yytext, yyleng); {DL} vt100_parser_handle_dl(yyextra, yytext, yyleng); {DCH} vt100_parser_handle_dch(yyextra, yytext, yyleng); +{SU} vt100_parser_handle_su(yyextra, yytext, yyleng); +{SD} vt100_parser_handle_sd(yyextra, yytext, yyleng); {ECH} vt100_parser_handle_ech(yyextra, yytext, yyleng); {VPA} vt100_parser_handle_vpa(yyextra, yytext, yyleng); {SM} vt100_parser_handle_sm(yyextra, yytext, yyleng); @@ -510,6 +516,28 @@ static void vt100_parser_handle_dch(VT100Screen *vt, char *buf, size_t len) vt100_screen_delete_characters(vt, params[0]); } +static void vt100_parser_handle_su(VT100Screen *vt, char *buf, size_t len) +{ + int params[VT100_PARSER_CSI_MAX_PARAMS] = { 1 }, nparams; + + vt100_parser_extract_csi_params(buf + 2, len - 3, params, &nparams); + if (params[0] == 0) { + params[0] = 1; + } + vt100_screen_scroll_up(vt, params[0]); +} + +static void vt100_parser_handle_sd(VT100Screen *vt, char *buf, size_t len) +{ + int params[VT100_PARSER_CSI_MAX_PARAMS] = { 1 }, nparams; + + vt100_parser_extract_csi_params(buf + 2, len - 3, params, &nparams); + if (params[0] == 0) { + params[0] = 1; + } + vt100_screen_scroll_down(vt, params[0]); +} + static void vt100_parser_handle_ech(VT100Screen *vt, char *buf, size_t len) { int params[VT100_PARSER_CSI_MAX_PARAMS] = { 1 }, nparams; diff --git a/src/screen.c b/src/screen.c index acf6f61..ac2c3c9 100644 --- a/src/screen.c +++ b/src/screen.c @@ -19,8 +19,6 @@ static void vt100_screen_push_string(char **strp, size_t *lenp, size_t append_len); static void vt100_screen_ensure_capacity(VT100Screen *vt, int size); static struct vt100_row *vt100_screen_row_at(VT100Screen *vt, int row); -static void vt100_screen_scroll_down(VT100Screen *vt, int count); -static void vt100_screen_scroll_up(VT100Screen *vt, int count); static int vt100_screen_scroll_region_is_active(VT100Screen *vt); static int vt100_screen_row_max_col(VT100Screen *vt, int row); @@ -514,6 +512,108 @@ void vt100_screen_erase_characters(VT100Screen *vt, int count) vt->dirty = 1; } +void vt100_screen_scroll_down(VT100Screen *vt, int count) +{ + struct vt100_row *row; + int i; + + if (vt100_screen_scroll_region_is_active(vt) || vt->alternate) { + int bottom = vt->grid->scroll_bottom, top = vt->grid->scroll_top; + + if (bottom - top + 1 > count) { + for (i = 0; i < count; ++i) { + row = vt100_screen_row_at(vt, top + i); + free(row->cells); + } + row = vt100_screen_row_at(vt, top); + memmove( + row, row + count, + (bottom - top + 1 - count) * sizeof(struct vt100_row)); + for (i = 0; i < count; ++i) { + row = vt100_screen_row_at(vt, bottom - i); + row->cells = calloc( + vt->grid->max.col, sizeof(struct vt100_cell)); + row->wrapped = 0; + } + } + else { + for (i = 0; i < bottom - top + 1; ++i) { + row = vt100_screen_row_at(vt, top + i); + memset( + row->cells, 0, + vt->grid->max.col * sizeof(struct vt100_cell)); + row->wrapped = 0; + } + } + } + else { + int scrollback = vt->scrollback_length; + + if (vt->grid->row_count + count > scrollback) { + int overflow = vt->grid->row_count + count - scrollback; + + vt100_screen_ensure_capacity(vt, scrollback); + for (i = 0; i < overflow; ++i) { + free(vt->grid->rows[i].cells); + } + memmove( + &vt->grid->rows[0], &vt->grid->rows[overflow], + (scrollback - overflow) * sizeof(struct vt100_row)); + for (i = scrollback - count; i < scrollback; ++i) { + vt->grid->rows[i].cells = calloc( + vt->grid->max.col, sizeof(struct vt100_cell)); + } + vt->grid->row_count = scrollback; + vt->grid->row_top = scrollback - vt->grid->max.row; + } + else { + vt100_screen_ensure_capacity(vt, vt->grid->row_count + count); + for (i = 0; i < count; ++i) { + row = vt100_screen_row_at(vt, i + vt->grid->max.row); + row->cells = calloc( + vt->grid->max.col, sizeof(struct vt100_cell)); + } + vt->grid->row_count += count; + vt->grid->row_top += count; + } + } + + vt->dirty = 1; +} + +void vt100_screen_scroll_up(VT100Screen *vt, int count) +{ + struct vt100_row *row; + int bottom = vt->grid->scroll_bottom, top = vt->grid->scroll_top; + int i; + + if (bottom - top + 1 > count) { + for (i = 0; i < count; ++i) { + row = vt100_screen_row_at(vt, bottom - i); + free(row->cells); + } + row = vt100_screen_row_at(vt, top); + memmove( + row + count, row, + (bottom - top + 1 - count) * sizeof(struct vt100_row)); + for (i = 0; i < count; ++i) { + row = vt100_screen_row_at(vt, top + i); + row->cells = calloc(vt->grid->max.col, sizeof(struct vt100_cell)); + row->wrapped = 0; + } + } + else { + for (i = 0; i < bottom - top + 1; ++i) { + row = vt100_screen_row_at(vt, top + i); + memset( + row->cells, 0, vt->grid->max.col * sizeof(struct vt100_cell)); + row->wrapped = 0; + } + } + + vt->dirty = 1; +} + void vt100_screen_set_scroll_region( VT100Screen *vt, int top, int bottom, int left, int right) { @@ -969,108 +1069,6 @@ static struct vt100_row *vt100_screen_row_at(VT100Screen *vt, int row) return &vt->grid->rows[row + vt->grid->row_top]; } -static void vt100_screen_scroll_down(VT100Screen *vt, int count) -{ - struct vt100_row *row; - int i; - - if (vt100_screen_scroll_region_is_active(vt) || vt->alternate) { - int bottom = vt->grid->scroll_bottom, top = vt->grid->scroll_top; - - if (bottom - top + 1 > count) { - for (i = 0; i < count; ++i) { - row = vt100_screen_row_at(vt, top + i); - free(row->cells); - } - row = vt100_screen_row_at(vt, top); - memmove( - row, row + count, - (bottom - top + 1 - count) * sizeof(struct vt100_row)); - for (i = 0; i < count; ++i) { - row = vt100_screen_row_at(vt, bottom - i); - row->cells = calloc( - vt->grid->max.col, sizeof(struct vt100_cell)); - row->wrapped = 0; - } - } - else { - for (i = 0; i < bottom - top + 1; ++i) { - row = vt100_screen_row_at(vt, top + i); - memset( - row->cells, 0, - vt->grid->max.col * sizeof(struct vt100_cell)); - row->wrapped = 0; - } - } - } - else { - int scrollback = vt->scrollback_length; - - if (vt->grid->row_count + count > scrollback) { - int overflow = vt->grid->row_count + count - scrollback; - - vt100_screen_ensure_capacity(vt, scrollback); - for (i = 0; i < overflow; ++i) { - free(vt->grid->rows[i].cells); - } - memmove( - &vt->grid->rows[0], &vt->grid->rows[overflow], - (scrollback - overflow) * sizeof(struct vt100_row)); - for (i = scrollback - count; i < scrollback; ++i) { - vt->grid->rows[i].cells = calloc( - vt->grid->max.col, sizeof(struct vt100_cell)); - } - vt->grid->row_count = scrollback; - vt->grid->row_top = scrollback - vt->grid->max.row; - } - else { - vt100_screen_ensure_capacity(vt, vt->grid->row_count + count); - for (i = 0; i < count; ++i) { - row = vt100_screen_row_at(vt, i + vt->grid->max.row); - row->cells = calloc( - vt->grid->max.col, sizeof(struct vt100_cell)); - } - vt->grid->row_count += count; - vt->grid->row_top += count; - } - } - - vt->dirty = 1; -} - -static void vt100_screen_scroll_up(VT100Screen *vt, int count) -{ - struct vt100_row *row; - int bottom = vt->grid->scroll_bottom, top = vt->grid->scroll_top; - int i; - - if (bottom - top + 1 > count) { - for (i = 0; i < count; ++i) { - row = vt100_screen_row_at(vt, bottom - i); - free(row->cells); - } - row = vt100_screen_row_at(vt, top); - memmove( - row + count, row, - (bottom - top + 1 - count) * sizeof(struct vt100_row)); - for (i = 0; i < count; ++i) { - row = vt100_screen_row_at(vt, top + i); - row->cells = calloc(vt->grid->max.col, sizeof(struct vt100_cell)); - row->wrapped = 0; - } - } - else { - for (i = 0; i < bottom - top + 1; ++i) { - row = vt100_screen_row_at(vt, top + i); - memset( - row->cells, 0, vt->grid->max.col * sizeof(struct vt100_cell)); - row->wrapped = 0; - } - } - - vt->dirty = 1; -} - static int vt100_screen_scroll_region_is_active(VT100Screen *vt) { return vt->grid->scroll_top != 0 diff --git a/src/screen.h b/src/screen.h index 24133e1..1d7a4fe 100644 --- a/src/screen.h +++ b/src/screen.h @@ -139,6 +139,8 @@ void vt100_screen_insert_lines(VT100Screen *vt, int count); void vt100_screen_delete_characters(VT100Screen *vt, int count); void vt100_screen_delete_lines(VT100Screen *vt, int count); void vt100_screen_erase_characters(VT100Screen *vt, int count); +void vt100_screen_scroll_down(VT100Screen *vt, int count); +void vt100_screen_scroll_up(VT100Screen *vt, int count); void vt100_screen_set_scroll_region( VT100Screen *vt, int top, int bottom, int left, int right); void vt100_screen_reset_text_attributes(VT100Screen *vt); -- cgit v1.2.3-54-g00ecf