diff options
| -rw-r--r-- | st.c | 30 |
1 files changed, 11 insertions, 19 deletions
| @@ -392,8 +392,10 @@ ttyread(void) { | |||
| 392 | 392 | ||
| 393 | if((ret = read(cmdfd, buf, LEN(buf))) < 0) | 393 | if((ret = read(cmdfd, buf, LEN(buf))) < 0) |
| 394 | die("Couldn't read from shell: %s\n", SERRNO); | 394 | die("Couldn't read from shell: %s\n", SERRNO); |
| 395 | else | 395 | else { |
| 396 | printf("ttyread %d\n", ret); | ||
| 396 | tputs(buf, ret); | 397 | tputs(buf, ret); |
| 398 | } | ||
| 397 | } | 399 | } |
| 398 | 400 | ||
| 399 | void | 401 | void |
| @@ -589,21 +591,16 @@ tinsertblankline(int n) { | |||
| 589 | Line blank; | 591 | Line blank; |
| 590 | int bot = term.bot; | 592 | int bot = term.bot; |
| 591 | 593 | ||
| 592 | if(term.c.y > term.bot) | 594 | if(term.c.y < term.top || term.c.y > term.bot) |
| 593 | bot = term.row - 1; | ||
| 594 | else if(term.c.y < term.top) | ||
| 595 | bot = term.top - 1; | ||
| 596 | if(term.c.y + n >= bot) { | ||
| 597 | tclearregion(0, term.c.y, term.col-1, bot); | ||
| 598 | return; | 595 | return; |
| 599 | } | 596 | |
| 597 | LIMIT(n, 0, bot-term.c.y+1); | ||
| 598 | tclearregion(0, bot-n+1, term.col-1, bot); | ||
| 600 | for(i = bot; i >= term.c.y+n; i--) { | 599 | for(i = bot; i >= term.c.y+n; i--) { |
| 601 | /* swap deleted line <-> blanked line */ | 600 | /* swap deleted line <-> blanked line */ |
| 602 | blank = term.line[i]; | 601 | blank = term.line[i]; |
| 603 | term.line[i] = term.line[i-n]; | 602 | term.line[i] = term.line[i-n]; |
| 604 | term.line[i-n] = blank; | 603 | term.line[i-n] = blank; |
| 605 | /* blank it */ | ||
| 606 | memset(blank, 0, term.col * sizeof(Glyph)); | ||
| 607 | } | 604 | } |
| 608 | } | 605 | } |
| 609 | 606 | ||
| @@ -613,21 +610,16 @@ tdeleteline(int n) { | |||
| 613 | Line blank; | 610 | Line blank; |
| 614 | int bot = term.bot; | 611 | int bot = term.bot; |
| 615 | 612 | ||
| 616 | if(term.c.y > term.bot) | 613 | if(term.c.y < term.top || term.c.y > term.bot) |
| 617 | bot = term.row - 1; | ||
| 618 | else if(term.c.y < term.top) | ||
| 619 | bot = term.top - 1; | ||
| 620 | if(term.c.y + n >= bot) { | ||
| 621 | tclearregion(0, term.c.y, term.col-1, bot); | ||
| 622 | return; | 614 | return; |
| 623 | } | 615 | |
| 616 | LIMIT(n, 0, bot-term.c.y+1); | ||
| 617 | tclearregion(0, term.c.y, term.col-1, term.c.y+n-1); | ||
| 624 | for(i = term.c.y; i <= bot-n; i++) { | 618 | for(i = term.c.y; i <= bot-n; i++) { |
| 625 | /* swap deleted line <-> blanked line */ | 619 | /* swap deleted line <-> blanked line */ |
| 626 | blank = term.line[i]; | 620 | blank = term.line[i]; |
| 627 | term.line[i] = term.line[i+n]; | 621 | term.line[i] = term.line[i+n]; |
| 628 | term.line[i+n] = blank; | 622 | term.line[i+n] = blank; |
| 629 | /* blank it */ | ||
| 630 | memset(blank, 0, term.col * sizeof(Glyph)); | ||
| 631 | } | 623 | } |
| 632 | } | 624 | } |
| 633 | 625 | ||
