diff options
Diffstat (limited to 'st.c')
| -rw-r--r-- | st.c | 25 |
1 files changed, 11 insertions, 14 deletions
| @@ -129,7 +129,6 @@ static void csireset(void); | |||
| 129 | 129 | ||
| 130 | static void tclearregion(int, int, int, int); | 130 | static void tclearregion(int, int, int, int); |
| 131 | static void tcursor(int); | 131 | static void tcursor(int); |
| 132 | static void twrapcursor(void); | ||
| 133 | static void tdeletechar(int); | 132 | static void tdeletechar(int); |
| 134 | static void tdeleteline(int); | 133 | static void tdeleteline(int); |
| 135 | static void tinsertblank(int); | 134 | static void tinsertblank(int); |
| @@ -337,7 +336,8 @@ treset(void) { | |||
| 337 | } | 336 | } |
| 338 | 337 | ||
| 339 | void | 338 | void |
| 340 | tnew(int col, int row) { /* screen size */ | 339 | tnew(int col, int row) { |
| 340 | /* screen size */ | ||
| 341 | term.row = row, term.col = col; | 341 | term.row = row, term.col = col; |
| 342 | term.top = 0, term.bot = term.row - 1; | 342 | term.top = 0, term.bot = term.row - 1; |
| 343 | /* mode */ | 343 | /* mode */ |
| @@ -438,16 +438,6 @@ tmoveto(int x, int y) { | |||
| 438 | } | 438 | } |
| 439 | 439 | ||
| 440 | void | 440 | void |
| 441 | twrapcursor(void) { | ||
| 442 | int y = term.c.y+1; | ||
| 443 | if(y > term.bot) { | ||
| 444 | tmoveto(0, term.bot); | ||
| 445 | tscroll(); | ||
| 446 | } else | ||
| 447 | tmoveto(0, y); | ||
| 448 | } | ||
| 449 | |||
| 450 | void | ||
| 451 | tsetchar(char c) { | 441 | tsetchar(char c) { |
| 452 | term.line[term.c.y][term.c.x] = term.c.attr; | 442 | term.line[term.c.y][term.c.x] = term.c.attr; |
| 453 | term.line[term.c.y][term.c.x].c = c; | 443 | term.line[term.c.y][term.c.x].c = c; |
| @@ -974,7 +964,7 @@ tputc(char c) { | |||
| 974 | if(term.c.x+1 < term.col) { | 964 | if(term.c.x+1 < term.col) { |
| 975 | tmoveto(term.c.x+1, term.c.y); | 965 | tmoveto(term.c.x+1, term.c.y); |
| 976 | } else if(IS_SET(MODE_WRAP)) | 966 | } else if(IS_SET(MODE_WRAP)) |
| 977 | twrapcursor(); | 967 | tnewline(); |
| 978 | break; | 968 | break; |
| 979 | } | 969 | } |
| 980 | } | 970 | } |
| @@ -995,13 +985,20 @@ tresize(int col, int row) { | |||
| 995 | if(col < 1 || row < 1) | 985 | if(col < 1 || row < 1) |
| 996 | return; | 986 | return; |
| 997 | 987 | ||
| 988 | /* free uneeded rows */ | ||
| 998 | for(i = row; i < term.row; i++) | 989 | for(i = row; i < term.row; i++) |
| 999 | free(term.line[i]); | 990 | free(term.line[i]); |
| 991 | |||
| 992 | /* resize to new height */ | ||
| 1000 | term.line = realloc(term.line, row * sizeof(Line)); | 993 | term.line = realloc(term.line, row * sizeof(Line)); |
| 994 | |||
| 995 | /* resize each row to new width, zero-pad if needed */ | ||
| 1001 | for(i = 0; i < minrow; i++) { | 996 | for(i = 0; i < minrow; i++) { |
| 1002 | term.line[i] = realloc(term.line[i], col * sizeof(Glyph)); | 997 | term.line[i] = realloc(term.line[i], col * sizeof(Glyph)); |
| 1003 | memset(term.line[i] + mincol, 0, (col - mincol) * sizeof(Glyph)); | 998 | memset(term.line[i] + mincol, 0, (col - mincol) * sizeof(Glyph)); |
| 1004 | } | 999 | } |
| 1000 | |||
| 1001 | /* allocate any new rows */ | ||
| 1005 | for(/* i == minrow */; i < row; i++) | 1002 | for(/* i == minrow */; i < row; i++) |
| 1006 | term.line[i] = calloc(col, sizeof(Glyph)); | 1003 | term.line[i] = calloc(col, sizeof(Glyph)); |
| 1007 | 1004 | ||
| @@ -1337,7 +1334,7 @@ run(void) { | |||
| 1337 | int | 1334 | int |
| 1338 | main(int argc, char *argv[]) { | 1335 | main(int argc, char *argv[]) { |
| 1339 | if(argc == 2 && !strncmp("-v", argv[1], 3)) | 1336 | if(argc == 2 && !strncmp("-v", argv[1], 3)) |
| 1340 | die("st-" VERSION ", © 2009 st engineers\n"); | 1337 | die("st-" VERSION ", (c) 2010 st engineers\n"); |
| 1341 | else if(argc != 1) | 1338 | else if(argc != 1) |
| 1342 | die("usage: st [-v]\n"); | 1339 | die("usage: st [-v]\n"); |
| 1343 | setlocale(LC_CTYPE, ""); | 1340 | setlocale(LC_CTYPE, ""); |
