diff options
author | FRIGN <dev@frign.de> | 2015-07-10 10:29:53 +0200 |
---|---|---|
committer | Christoph Lohmann <20h@r-36.net> | 2015-07-10 13:58:31 +0200 |
commit | f1307d91e2ec351a4a8b7352be8b5f6e4cb24294 (patch) | |
tree | 4c6c0fbbb257532d5ffab49afb3c6a4f3df596b1 /st.c | |
parent | 13233574ed1ead29bb7e99e71a0665e62c640617 (diff) | |
download | st-f1307d91e2ec351a4a8b7352be8b5f6e4cb24294.tar.gz st-f1307d91e2ec351a4a8b7352be8b5f6e4cb24294.zip |
Don't treat clauses like functions
and add a space between the keyword and the parentheses.
Signed-off-by: Christoph Lohmann <20h@r-36.net>
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 764 |
1 files changed, 382 insertions, 382 deletions
@@ -554,9 +554,9 @@ xwrite(int fd, const char *s, size_t len) | |||
554 | { | 554 | { |
555 | size_t aux = len; | 555 | size_t aux = len; |
556 | 556 | ||
557 | while(len > 0) { | 557 | while (len > 0) { |
558 | ssize_t r = write(fd, s, len); | 558 | ssize_t r = write(fd, s, len); |
559 | if(r < 0) | 559 | if (r < 0) |
560 | return r; | 560 | return r; |
561 | len -= r; | 561 | len -= r; |
562 | s += r; | 562 | s += r; |
@@ -569,7 +569,7 @@ xmalloc(size_t len) | |||
569 | { | 569 | { |
570 | void *p = malloc(len); | 570 | void *p = malloc(len); |
571 | 571 | ||
572 | if(!p) | 572 | if (!p) |
573 | die("Out of memory\n"); | 573 | die("Out of memory\n"); |
574 | 574 | ||
575 | return p; | 575 | return p; |
@@ -578,7 +578,7 @@ xmalloc(size_t len) | |||
578 | void * | 578 | void * |
579 | xrealloc(void *p, size_t len) | 579 | xrealloc(void *p, size_t len) |
580 | { | 580 | { |
581 | if((p = realloc(p, len)) == NULL) | 581 | if ((p = realloc(p, len)) == NULL) |
582 | die("Out of memory\n"); | 582 | die("Out of memory\n"); |
583 | 583 | ||
584 | return p; | 584 | return p; |
@@ -587,7 +587,7 @@ xrealloc(void *p, size_t len) | |||
587 | char * | 587 | char * |
588 | xstrdup(char *s) | 588 | xstrdup(char *s) |
589 | { | 589 | { |
590 | if((s = strdup(s)) == NULL) | 590 | if ((s = strdup(s)) == NULL) |
591 | die("Out of memory\n"); | 591 | die("Out of memory\n"); |
592 | 592 | ||
593 | return s; | 593 | return s; |
@@ -600,17 +600,17 @@ utf8decode(char *c, Rune *u, size_t clen) | |||
600 | Rune udecoded; | 600 | Rune udecoded; |
601 | 601 | ||
602 | *u = UTF_INVALID; | 602 | *u = UTF_INVALID; |
603 | if(!clen) | 603 | if (!clen) |
604 | return 0; | 604 | return 0; |
605 | udecoded = utf8decodebyte(c[0], &len); | 605 | udecoded = utf8decodebyte(c[0], &len); |
606 | if(!BETWEEN(len, 1, UTF_SIZ)) | 606 | if (!BETWEEN(len, 1, UTF_SIZ)) |
607 | return 1; | 607 | return 1; |
608 | for(i = 1, j = 1; i < clen && j < len; ++i, ++j) { | 608 | for (i = 1, j = 1; i < clen && j < len; ++i, ++j) { |
609 | udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type); | 609 | udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type); |
610 | if(type != 0) | 610 | if (type != 0) |
611 | return j; | 611 | return j; |
612 | } | 612 | } |
613 | if(j < len) | 613 | if (j < len) |
614 | return 0; | 614 | return 0; |
615 | *u = udecoded; | 615 | *u = udecoded; |
616 | utf8validate(u, len); | 616 | utf8validate(u, len); |
@@ -620,8 +620,8 @@ utf8decode(char *c, Rune *u, size_t clen) | |||
620 | Rune | 620 | Rune |
621 | utf8decodebyte(char c, size_t *i) | 621 | utf8decodebyte(char c, size_t *i) |
622 | { | 622 | { |
623 | for(*i = 0; *i < LEN(utfmask); ++(*i)) | 623 | for (*i = 0; *i < LEN(utfmask); ++(*i)) |
624 | if(((uchar)c & utfmask[*i]) == utfbyte[*i]) | 624 | if (((uchar)c & utfmask[*i]) == utfbyte[*i]) |
625 | return (uchar)c & ~utfmask[*i]; | 625 | return (uchar)c & ~utfmask[*i]; |
626 | return 0; | 626 | return 0; |
627 | } | 627 | } |
@@ -632,9 +632,9 @@ utf8encode(Rune u, char *c) | |||
632 | size_t len, i; | 632 | size_t len, i; |
633 | 633 | ||
634 | len = utf8validate(&u, 0); | 634 | len = utf8validate(&u, 0); |
635 | if(len > UTF_SIZ) | 635 | if (len > UTF_SIZ) |
636 | return 0; | 636 | return 0; |
637 | for(i = len - 1; i != 0; --i) { | 637 | for (i = len - 1; i != 0; --i) { |
638 | c[i] = utf8encodebyte(u, 0); | 638 | c[i] = utf8encodebyte(u, 0); |
639 | u >>= 6; | 639 | u >>= 6; |
640 | } | 640 | } |
@@ -655,10 +655,10 @@ utf8strchr(char *s, Rune u) | |||
655 | size_t i, j, len; | 655 | size_t i, j, len; |
656 | 656 | ||
657 | len = strlen(s); | 657 | len = strlen(s); |
658 | for(i = 0, j = 0; i < len; i += j) { | 658 | for (i = 0, j = 0; i < len; i += j) { |
659 | if(!(j = utf8decode(&s[i], &r, len - i))) | 659 | if (!(j = utf8decode(&s[i], &r, len - i))) |
660 | break; | 660 | break; |
661 | if(r == u) | 661 | if (r == u) |
662 | return &(s[i]); | 662 | return &(s[i]); |
663 | } | 663 | } |
664 | return NULL; | 664 | return NULL; |
@@ -667,9 +667,9 @@ utf8strchr(char *s, Rune u) | |||
667 | size_t | 667 | size_t |
668 | utf8validate(Rune *u, size_t i) | 668 | utf8validate(Rune *u, size_t i) |
669 | { | 669 | { |
670 | if(!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF)) | 670 | if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF)) |
671 | *u = UTF_INVALID; | 671 | *u = UTF_INVALID; |
672 | for(i = 1; *u > utfmax[i]; ++i) | 672 | for (i = 1; *u > utfmax[i]; ++i) |
673 | ; | 673 | ; |
674 | return i; | 674 | return i; |
675 | } | 675 | } |
@@ -684,7 +684,7 @@ selinit(void) | |||
684 | sel.primary = NULL; | 684 | sel.primary = NULL; |
685 | sel.clipboard = NULL; | 685 | sel.clipboard = NULL; |
686 | sel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0); | 686 | sel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0); |
687 | if(sel.xtarget == None) | 687 | if (sel.xtarget == None) |
688 | sel.xtarget = XA_STRING; | 688 | sel.xtarget = XA_STRING; |
689 | } | 689 | } |
690 | 690 | ||
@@ -711,10 +711,10 @@ tlinelen(int y) | |||
711 | { | 711 | { |
712 | int i = term.col; | 712 | int i = term.col; |
713 | 713 | ||
714 | if(term.line[y][i - 1].mode & ATTR_WRAP) | 714 | if (term.line[y][i - 1].mode & ATTR_WRAP) |
715 | return i; | 715 | return i; |
716 | 716 | ||
717 | while(i > 0 && term.line[y][i - 1].u == ' ') | 717 | while (i > 0 && term.line[y][i - 1].u == ' ') |
718 | --i; | 718 | --i; |
719 | 719 | ||
720 | return i; | 720 | return i; |
@@ -725,7 +725,7 @@ selnormalize(void) | |||
725 | { | 725 | { |
726 | int i; | 726 | int i; |
727 | 727 | ||
728 | if(sel.type == SEL_REGULAR && sel.ob.y != sel.oe.y) { | 728 | if (sel.type == SEL_REGULAR && sel.ob.y != sel.oe.y) { |
729 | sel.nb.x = sel.ob.y < sel.oe.y ? sel.ob.x : sel.oe.x; | 729 | sel.nb.x = sel.ob.y < sel.oe.y ? sel.ob.x : sel.oe.x; |
730 | sel.ne.x = sel.ob.y < sel.oe.y ? sel.oe.x : sel.ob.x; | 730 | sel.ne.x = sel.ob.y < sel.oe.y ? sel.oe.x : sel.ob.x; |
731 | } else { | 731 | } else { |
@@ -751,10 +751,10 @@ selnormalize(void) | |||
751 | int | 751 | int |
752 | selected(int x, int y) | 752 | selected(int x, int y) |
753 | { | 753 | { |
754 | if(sel.mode == SEL_EMPTY) | 754 | if (sel.mode == SEL_EMPTY) |
755 | return 0; | 755 | return 0; |
756 | 756 | ||
757 | if(sel.type == SEL_RECTANGULAR) | 757 | if (sel.type == SEL_RECTANGULAR) |
758 | return BETWEEN(y, sel.nb.y, sel.ne.y) | 758 | return BETWEEN(y, sel.nb.y, sel.ne.y) |
759 | && BETWEEN(x, sel.nb.x, sel.ne.x); | 759 | && BETWEEN(x, sel.nb.x, sel.ne.x); |
760 | 760 | ||
@@ -770,7 +770,7 @@ selsnap(int *x, int *y, int direction) | |||
770 | int delim, prevdelim; | 770 | int delim, prevdelim; |
771 | Glyph *gp, *prevgp; | 771 | Glyph *gp, *prevgp; |
772 | 772 | ||
773 | switch(sel.snap) { | 773 | switch (sel.snap) { |
774 | case SNAP_WORD: | 774 | case SNAP_WORD: |
775 | /* | 775 | /* |
776 | * Snap around if the word wraps around at the end or | 776 | * Snap around if the word wraps around at the end or |
@@ -778,20 +778,20 @@ selsnap(int *x, int *y, int direction) | |||
778 | */ | 778 | */ |
779 | prevgp = &term.line[*y][*x]; | 779 | prevgp = &term.line[*y][*x]; |
780 | prevdelim = ISDELIM(prevgp->u); | 780 | prevdelim = ISDELIM(prevgp->u); |
781 | for(;;) { | 781 | for (;;) { |
782 | newx = *x + direction; | 782 | newx = *x + direction; |
783 | newy = *y; | 783 | newy = *y; |
784 | if(!BETWEEN(newx, 0, term.col - 1)) { | 784 | if (!BETWEEN(newx, 0, term.col - 1)) { |
785 | newy += direction; | 785 | newy += direction; |
786 | newx = (newx + term.col) % term.col; | 786 | newx = (newx + term.col) % term.col; |
787 | if (!BETWEEN(newy, 0, term.row - 1)) | 787 | if (!BETWEEN(newy, 0, term.row - 1)) |
788 | break; | 788 | break; |
789 | 789 | ||
790 | if(direction > 0) | 790 | if (direction > 0) |
791 | yt = *y, xt = *x; | 791 | yt = *y, xt = *x; |
792 | else | 792 | else |
793 | yt = newy, xt = newx; | 793 | yt = newy, xt = newx; |
794 | if(!(term.line[yt][xt].mode & ATTR_WRAP)) | 794 | if (!(term.line[yt][xt].mode & ATTR_WRAP)) |
795 | break; | 795 | break; |
796 | } | 796 | } |
797 | 797 | ||
@@ -800,7 +800,7 @@ selsnap(int *x, int *y, int direction) | |||
800 | 800 | ||
801 | gp = &term.line[newy][newx]; | 801 | gp = &term.line[newy][newx]; |
802 | delim = ISDELIM(gp->u); | 802 | delim = ISDELIM(gp->u); |
803 | if(!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim | 803 | if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim |
804 | || (delim && gp->u != prevgp->u))) | 804 | || (delim && gp->u != prevgp->u))) |
805 | break; | 805 | break; |
806 | 806 | ||
@@ -817,16 +817,16 @@ selsnap(int *x, int *y, int direction) | |||
817 | * previous line will be selected. | 817 | * previous line will be selected. |
818 | */ | 818 | */ |
819 | *x = (direction < 0) ? 0 : term.col - 1; | 819 | *x = (direction < 0) ? 0 : term.col - 1; |
820 | if(direction < 0) { | 820 | if (direction < 0) { |
821 | for(; *y > 0; *y += direction) { | 821 | for (; *y > 0; *y += direction) { |
822 | if(!(term.line[*y-1][term.col-1].mode | 822 | if (!(term.line[*y-1][term.col-1].mode |
823 | & ATTR_WRAP)) { | 823 | & ATTR_WRAP)) { |
824 | break; | 824 | break; |
825 | } | 825 | } |
826 | } | 826 | } |
827 | } else if(direction > 0) { | 827 | } else if (direction > 0) { |
828 | for(; *y < term.row-1; *y += direction) { | 828 | for (; *y < term.row-1; *y += direction) { |
829 | if(!(term.line[*y][term.col-1].mode | 829 | if (!(term.line[*y][term.col-1].mode |
830 | & ATTR_WRAP)) { | 830 | & ATTR_WRAP)) { |
831 | break; | 831 | break; |
832 | } | 832 | } |
@@ -849,8 +849,8 @@ getbuttoninfo(XEvent *e) | |||
849 | selnormalize(); | 849 | selnormalize(); |
850 | 850 | ||
851 | sel.type = SEL_REGULAR; | 851 | sel.type = SEL_REGULAR; |
852 | for(type = 1; type < LEN(selmasks); ++type) { | 852 | for (type = 1; type < LEN(selmasks); ++type) { |
853 | if(match(selmasks[type], state)) { | 853 | if (match(selmasks[type], state)) { |
854 | sel.type = type; | 854 | sel.type = type; |
855 | break; | 855 | break; |
856 | } | 856 | } |
@@ -867,51 +867,51 @@ mousereport(XEvent *e) | |||
867 | static int ox, oy; | 867 | static int ox, oy; |
868 | 868 | ||
869 | /* from urxvt */ | 869 | /* from urxvt */ |
870 | if(e->xbutton.type == MotionNotify) { | 870 | if (e->xbutton.type == MotionNotify) { |
871 | if(x == ox && y == oy) | 871 | if (x == ox && y == oy) |
872 | return; | 872 | return; |
873 | if(!IS_SET(MODE_MOUSEMOTION) && !IS_SET(MODE_MOUSEMANY)) | 873 | if (!IS_SET(MODE_MOUSEMOTION) && !IS_SET(MODE_MOUSEMANY)) |
874 | return; | 874 | return; |
875 | /* MOUSE_MOTION: no reporting if no button is pressed */ | 875 | /* MOUSE_MOTION: no reporting if no button is pressed */ |
876 | if(IS_SET(MODE_MOUSEMOTION) && oldbutton == 3) | 876 | if (IS_SET(MODE_MOUSEMOTION) && oldbutton == 3) |
877 | return; | 877 | return; |
878 | 878 | ||
879 | button = oldbutton + 32; | 879 | button = oldbutton + 32; |
880 | ox = x; | 880 | ox = x; |
881 | oy = y; | 881 | oy = y; |
882 | } else { | 882 | } else { |
883 | if(!IS_SET(MODE_MOUSESGR) && e->xbutton.type == ButtonRelease) { | 883 | if (!IS_SET(MODE_MOUSESGR) && e->xbutton.type == ButtonRelease) { |
884 | button = 3; | 884 | button = 3; |
885 | } else { | 885 | } else { |
886 | button -= Button1; | 886 | button -= Button1; |
887 | if(button >= 3) | 887 | if (button >= 3) |
888 | button += 64 - 3; | 888 | button += 64 - 3; |
889 | } | 889 | } |
890 | if(e->xbutton.type == ButtonPress) { | 890 | if (e->xbutton.type == ButtonPress) { |
891 | oldbutton = button; | 891 | oldbutton = button; |
892 | ox = x; | 892 | ox = x; |
893 | oy = y; | 893 | oy = y; |
894 | } else if(e->xbutton.type == ButtonRelease) { | 894 | } else if (e->xbutton.type == ButtonRelease) { |
895 | oldbutton = 3; | 895 | oldbutton = 3; |
896 | /* MODE_MOUSEX10: no button release reporting */ | 896 | /* MODE_MOUSEX10: no button release reporting */ |
897 | if(IS_SET(MODE_MOUSEX10)) | 897 | if (IS_SET(MODE_MOUSEX10)) |
898 | return; | 898 | return; |
899 | if (button == 64 || button == 65) | 899 | if (button == 64 || button == 65) |
900 | return; | 900 | return; |
901 | } | 901 | } |
902 | } | 902 | } |
903 | 903 | ||
904 | if(!IS_SET(MODE_MOUSEX10)) { | 904 | if (!IS_SET(MODE_MOUSEX10)) { |
905 | button += ((state & ShiftMask ) ? 4 : 0) | 905 | button += ((state & ShiftMask ) ? 4 : 0) |
906 | + ((state & Mod4Mask ) ? 8 : 0) | 906 | + ((state & Mod4Mask ) ? 8 : 0) |
907 | + ((state & ControlMask) ? 16 : 0); | 907 | + ((state & ControlMask) ? 16 : 0); |
908 | } | 908 | } |
909 | 909 | ||
910 | if(IS_SET(MODE_MOUSESGR)) { | 910 | if (IS_SET(MODE_MOUSESGR)) { |
911 | len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c", | 911 | len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c", |
912 | button, x+1, y+1, | 912 | button, x+1, y+1, |
913 | e->xbutton.type == ButtonRelease ? 'm' : 'M'); | 913 | e->xbutton.type == ButtonRelease ? 'm' : 'M'); |
914 | } else if(x < 223 && y < 223) { | 914 | } else if (x < 223 && y < 223) { |
915 | len = snprintf(buf, sizeof(buf), "\033[M%c%c%c", | 915 | len = snprintf(buf, sizeof(buf), "\033[M%c%c%c", |
916 | 32+button, 32+x+1, 32+y+1); | 916 | 32+button, 32+x+1, 32+y+1); |
917 | } else { | 917 | } else { |
@@ -927,20 +927,20 @@ bpress(XEvent *e) | |||
927 | struct timespec now; | 927 | struct timespec now; |
928 | Mousekey *mk; | 928 | Mousekey *mk; |
929 | 929 | ||
930 | if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { | 930 | if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { |
931 | mousereport(e); | 931 | mousereport(e); |
932 | return; | 932 | return; |
933 | } | 933 | } |
934 | 934 | ||
935 | for(mk = mshortcuts; mk < mshortcuts + LEN(mshortcuts); mk++) { | 935 | for (mk = mshortcuts; mk < mshortcuts + LEN(mshortcuts); mk++) { |
936 | if(e->xbutton.button == mk->b | 936 | if (e->xbutton.button == mk->b |
937 | && match(mk->mask, e->xbutton.state)) { | 937 | && match(mk->mask, e->xbutton.state)) { |
938 | ttysend(mk->s, strlen(mk->s)); | 938 | ttysend(mk->s, strlen(mk->s)); |
939 | return; | 939 | return; |
940 | } | 940 | } |
941 | } | 941 | } |
942 | 942 | ||
943 | if(e->xbutton.button == Button1) { | 943 | if (e->xbutton.button == Button1) { |
944 | clock_gettime(CLOCK_MONOTONIC, &now); | 944 | clock_gettime(CLOCK_MONOTONIC, &now); |
945 | 945 | ||
946 | /* Clear previous selection, logically and visually. */ | 946 | /* Clear previous selection, logically and visually. */ |
@@ -954,16 +954,16 @@ bpress(XEvent *e) | |||
954 | * If the user clicks below predefined timeouts specific | 954 | * If the user clicks below predefined timeouts specific |
955 | * snapping behaviour is exposed. | 955 | * snapping behaviour is exposed. |
956 | */ | 956 | */ |
957 | if(TIMEDIFF(now, sel.tclick2) <= tripleclicktimeout) { | 957 | if (TIMEDIFF(now, sel.tclick2) <= tripleclicktimeout) { |
958 | sel.snap = SNAP_LINE; | 958 | sel.snap = SNAP_LINE; |
959 | } else if(TIMEDIFF(now, sel.tclick1) <= doubleclicktimeout) { | 959 | } else if (TIMEDIFF(now, sel.tclick1) <= doubleclicktimeout) { |
960 | sel.snap = SNAP_WORD; | 960 | sel.snap = SNAP_WORD; |
961 | } else { | 961 | } else { |
962 | sel.snap = 0; | 962 | sel.snap = 0; |
963 | } | 963 | } |
964 | selnormalize(); | 964 | selnormalize(); |
965 | 965 | ||
966 | if(sel.snap != 0) | 966 | if (sel.snap != 0) |
967 | sel.mode = SEL_READY; | 967 | sel.mode = SEL_READY; |
968 | tsetdirt(sel.nb.y, sel.ne.y); | 968 | tsetdirt(sel.nb.y, sel.ne.y); |
969 | sel.tclick2 = sel.tclick1; | 969 | sel.tclick2 = sel.tclick1; |
@@ -978,17 +978,17 @@ getsel(void) | |||
978 | int y, bufsize, lastx, linelen; | 978 | int y, bufsize, lastx, linelen; |
979 | Glyph *gp, *last; | 979 | Glyph *gp, *last; |
980 | 980 | ||
981 | if(sel.ob.x == -1) | 981 | if (sel.ob.x == -1) |
982 | return NULL; | 982 | return NULL; |
983 | 983 | ||
984 | bufsize = (term.col+1) * (sel.ne.y-sel.nb.y+1) * UTF_SIZ; | 984 | bufsize = (term.col+1) * (sel.ne.y-sel.nb.y+1) * UTF_SIZ; |
985 | ptr = str = xmalloc(bufsize); | 985 | ptr = str = xmalloc(bufsize); |
986 | 986 | ||
987 | /* append every set & selected glyph to the selection */ | 987 | /* append every set & selected glyph to the selection */ |
988 | for(y = sel.nb.y; y <= sel.ne.y; y++) { | 988 | for (y = sel.nb.y; y <= sel.ne.y; y++) { |
989 | linelen = tlinelen(y); | 989 | linelen = tlinelen(y); |
990 | 990 | ||
991 | if(sel.type == SEL_RECTANGULAR) { | 991 | if (sel.type == SEL_RECTANGULAR) { |
992 | gp = &term.line[y][sel.nb.x]; | 992 | gp = &term.line[y][sel.nb.x]; |
993 | lastx = sel.ne.x; | 993 | lastx = sel.ne.x; |
994 | } else { | 994 | } else { |
@@ -996,11 +996,11 @@ getsel(void) | |||
996 | lastx = (sel.ne.y == y) ? sel.ne.x : term.col-1; | 996 | lastx = (sel.ne.y == y) ? sel.ne.x : term.col-1; |
997 | } | 997 | } |
998 | last = &term.line[y][MIN(lastx, linelen-1)]; | 998 | last = &term.line[y][MIN(lastx, linelen-1)]; |
999 | while(last >= gp && last->u == ' ') | 999 | while (last >= gp && last->u == ' ') |
1000 | --last; | 1000 | --last; |
1001 | 1001 | ||
1002 | for( ; gp <= last; ++gp) { | 1002 | for ( ; gp <= last; ++gp) { |
1003 | if(gp->mode & ATTR_WDUMMY) | 1003 | if (gp->mode & ATTR_WDUMMY) |
1004 | continue; | 1004 | continue; |
1005 | 1005 | ||
1006 | ptr += utf8encode(gp->u, ptr); | 1006 | ptr += utf8encode(gp->u, ptr); |
@@ -1015,7 +1015,7 @@ getsel(void) | |||
1015 | * st. | 1015 | * st. |
1016 | * FIXME: Fix the computer world. | 1016 | * FIXME: Fix the computer world. |
1017 | */ | 1017 | */ |
1018 | if((y < sel.ne.y || lastx >= linelen) && !(last->mode & ATTR_WRAP)) | 1018 | if ((y < sel.ne.y || lastx >= linelen) && !(last->mode & ATTR_WRAP)) |
1019 | *ptr++ = '\n'; | 1019 | *ptr++ = '\n'; |
1020 | } | 1020 | } |
1021 | *ptr = 0; | 1021 | *ptr = 0; |
@@ -1042,7 +1042,7 @@ selnotify(XEvent *e) | |||
1042 | if (xsev->property == None) | 1042 | if (xsev->property == None) |
1043 | return; | 1043 | return; |
1044 | do { | 1044 | do { |
1045 | if(XGetWindowProperty(xw.dpy, xw.win, xsev->property, ofs, | 1045 | if (XGetWindowProperty(xw.dpy, xw.win, xsev->property, ofs, |
1046 | BUFSIZ/4, False, AnyPropertyType, | 1046 | BUFSIZ/4, False, AnyPropertyType, |
1047 | &type, &format, &nitems, &rem, | 1047 | &type, &format, &nitems, &rem, |
1048 | &data)) { | 1048 | &data)) { |
@@ -1059,19 +1059,19 @@ selnotify(XEvent *e) | |||
1059 | */ | 1059 | */ |
1060 | repl = data; | 1060 | repl = data; |
1061 | last = data + nitems * format / 8; | 1061 | last = data + nitems * format / 8; |
1062 | while((repl = memchr(repl, '\n', last - repl))) { | 1062 | while ((repl = memchr(repl, '\n', last - repl))) { |
1063 | *repl++ = '\r'; | 1063 | *repl++ = '\r'; |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | if(IS_SET(MODE_BRCKTPASTE)) | 1066 | if (IS_SET(MODE_BRCKTPASTE)) |
1067 | ttywrite("\033[200~", 6); | 1067 | ttywrite("\033[200~", 6); |
1068 | ttysend((char *)data, nitems * format / 8); | 1068 | ttysend((char *)data, nitems * format / 8); |
1069 | if(IS_SET(MODE_BRCKTPASTE)) | 1069 | if (IS_SET(MODE_BRCKTPASTE)) |
1070 | ttywrite("\033[201~", 6); | 1070 | ttywrite("\033[201~", 6); |
1071 | XFree(data); | 1071 | XFree(data); |
1072 | /* number of 32-bit chunks returned */ | 1072 | /* number of 32-bit chunks returned */ |
1073 | ofs += nitems * format / 32; | 1073 | ofs += nitems * format / 32; |
1074 | } while(rem > 0); | 1074 | } while (rem > 0); |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | void | 1077 | void |
@@ -1086,10 +1086,10 @@ clipcopy(const Arg *dummy) | |||
1086 | { | 1086 | { |
1087 | Atom clipboard; | 1087 | Atom clipboard; |
1088 | 1088 | ||
1089 | if(sel.clipboard != NULL) | 1089 | if (sel.clipboard != NULL) |
1090 | free(sel.clipboard); | 1090 | free(sel.clipboard); |
1091 | 1091 | ||
1092 | if(sel.primary != NULL) { | 1092 | if (sel.primary != NULL) { |
1093 | sel.clipboard = xstrdup(sel.primary); | 1093 | sel.clipboard = xstrdup(sel.primary); |
1094 | clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); | 1094 | clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); |
1095 | XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime); | 1095 | XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime); |
@@ -1109,7 +1109,7 @@ clippaste(const Arg *dummy) | |||
1109 | void | 1109 | void |
1110 | selclear(XEvent *e) | 1110 | selclear(XEvent *e) |
1111 | { | 1111 | { |
1112 | if(sel.ob.x == -1) | 1112 | if (sel.ob.x == -1) |
1113 | return; | 1113 | return; |
1114 | sel.mode = SEL_IDLE; | 1114 | sel.mode = SEL_IDLE; |
1115 | sel.ob.x = -1; | 1115 | sel.ob.x = -1; |
@@ -1137,22 +1137,22 @@ selrequest(XEvent *e) | |||
1137 | xev.property = None; | 1137 | xev.property = None; |
1138 | 1138 | ||
1139 | xa_targets = XInternAtom(xw.dpy, "TARGETS", 0); | 1139 | xa_targets = XInternAtom(xw.dpy, "TARGETS", 0); |
1140 | if(xsre->target == xa_targets) { | 1140 | if (xsre->target == xa_targets) { |
1141 | /* respond with the supported type */ | 1141 | /* respond with the supported type */ |
1142 | string = sel.xtarget; | 1142 | string = sel.xtarget; |
1143 | XChangeProperty(xsre->display, xsre->requestor, xsre->property, | 1143 | XChangeProperty(xsre->display, xsre->requestor, xsre->property, |
1144 | XA_ATOM, 32, PropModeReplace, | 1144 | XA_ATOM, 32, PropModeReplace, |
1145 | (uchar *) &string, 1); | 1145 | (uchar *) &string, 1); |
1146 | xev.property = xsre->property; | 1146 | xev.property = xsre->property; |
1147 | } else if(xsre->target == sel.xtarget || xsre->target == XA_STRING) { | 1147 | } else if (xsre->target == sel.xtarget || xsre->target == XA_STRING) { |
1148 | /* | 1148 | /* |
1149 | * xith XA_STRING non ascii characters may be incorrect in the | 1149 | * xith XA_STRING non ascii characters may be incorrect in the |
1150 | * requestor. It is not our problem, use utf8. | 1150 | * requestor. It is not our problem, use utf8. |
1151 | */ | 1151 | */ |
1152 | clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); | 1152 | clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); |
1153 | if(xsre->selection == XA_PRIMARY) { | 1153 | if (xsre->selection == XA_PRIMARY) { |
1154 | seltext = sel.primary; | 1154 | seltext = sel.primary; |
1155 | } else if(xsre->selection == clipboard) { | 1155 | } else if (xsre->selection == clipboard) { |
1156 | seltext = sel.clipboard; | 1156 | seltext = sel.clipboard; |
1157 | } else { | 1157 | } else { |
1158 | fprintf(stderr, | 1158 | fprintf(stderr, |
@@ -1160,7 +1160,7 @@ selrequest(XEvent *e) | |||
1160 | xsre->selection); | 1160 | xsre->selection); |
1161 | return; | 1161 | return; |
1162 | } | 1162 | } |
1163 | if(seltext != NULL) { | 1163 | if (seltext != NULL) { |
1164 | XChangeProperty(xsre->display, xsre->requestor, | 1164 | XChangeProperty(xsre->display, xsre->requestor, |
1165 | xsre->property, xsre->target, | 1165 | xsre->property, xsre->target, |
1166 | 8, PropModeReplace, | 1166 | 8, PropModeReplace, |
@@ -1170,7 +1170,7 @@ selrequest(XEvent *e) | |||
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | /* all done, send a notification to the listener */ | 1172 | /* all done, send a notification to the listener */ |
1173 | if(!XSendEvent(xsre->display, xsre->requestor, 1, 0, (XEvent *) &xev)) | 1173 | if (!XSendEvent(xsre->display, xsre->requestor, 1, 0, (XEvent *) &xev)) |
1174 | fprintf(stderr, "Error sending SelectionNotify event\n"); | 1174 | fprintf(stderr, "Error sending SelectionNotify event\n"); |
1175 | } | 1175 | } |
1176 | 1176 | ||
@@ -1188,15 +1188,15 @@ xsetsel(char *str, Time t) | |||
1188 | void | 1188 | void |
1189 | brelease(XEvent *e) | 1189 | brelease(XEvent *e) |
1190 | { | 1190 | { |
1191 | if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { | 1191 | if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { |
1192 | mousereport(e); | 1192 | mousereport(e); |
1193 | return; | 1193 | return; |
1194 | } | 1194 | } |
1195 | 1195 | ||
1196 | if(e->xbutton.button == Button2) { | 1196 | if (e->xbutton.button == Button2) { |
1197 | selpaste(NULL); | 1197 | selpaste(NULL); |
1198 | } else if(e->xbutton.button == Button1) { | 1198 | } else if (e->xbutton.button == Button1) { |
1199 | if(sel.mode == SEL_READY) { | 1199 | if (sel.mode == SEL_READY) { |
1200 | getbuttoninfo(e); | 1200 | getbuttoninfo(e); |
1201 | selcopy(e->xbutton.time); | 1201 | selcopy(e->xbutton.time); |
1202 | } else | 1202 | } else |
@@ -1211,12 +1211,12 @@ bmotion(XEvent *e) | |||
1211 | { | 1211 | { |
1212 | int oldey, oldex, oldsby, oldsey; | 1212 | int oldey, oldex, oldsby, oldsey; |
1213 | 1213 | ||
1214 | if(IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { | 1214 | if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) { |
1215 | mousereport(e); | 1215 | mousereport(e); |
1216 | return; | 1216 | return; |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | if(!sel.mode) | 1219 | if (!sel.mode) |
1220 | return; | 1220 | return; |
1221 | 1221 | ||
1222 | sel.mode = SEL_READY; | 1222 | sel.mode = SEL_READY; |
@@ -1226,7 +1226,7 @@ bmotion(XEvent *e) | |||
1226 | oldsey = sel.ne.y; | 1226 | oldsey = sel.ne.y; |
1227 | getbuttoninfo(e); | 1227 | getbuttoninfo(e); |
1228 | 1228 | ||
1229 | if(oldey != sel.oe.y || oldex != sel.oe.x) | 1229 | if (oldey != sel.oe.y || oldex != sel.oe.x) |
1230 | tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey)); | 1230 | tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey)); |
1231 | } | 1231 | } |
1232 | 1232 | ||
@@ -1249,8 +1249,8 @@ execsh(void) | |||
1249 | char buf[sizeof(long) * 8 + 1]; | 1249 | char buf[sizeof(long) * 8 + 1]; |
1250 | 1250 | ||
1251 | errno = 0; | 1251 | errno = 0; |
1252 | if((pw = getpwuid(getuid())) == NULL) { | 1252 | if ((pw = getpwuid(getuid())) == NULL) { |
1253 | if(errno) | 1253 | if (errno) |
1254 | die("getpwuid:%s\n", strerror(errno)); | 1254 | die("getpwuid:%s\n", strerror(errno)); |
1255 | else | 1255 | else |
1256 | die("who are you?\n"); | 1256 | die("who are you?\n"); |
@@ -1260,9 +1260,9 @@ execsh(void) | |||
1260 | sh = (pw->pw_shell[0]) ? pw->pw_shell : shell; | 1260 | sh = (pw->pw_shell[0]) ? pw->pw_shell : shell; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | if(opt_cmd) | 1263 | if (opt_cmd) |
1264 | prog = opt_cmd[0]; | 1264 | prog = opt_cmd[0]; |
1265 | else if(utmp) | 1265 | else if (utmp) |
1266 | prog = utmp; | 1266 | prog = utmp; |
1267 | else | 1267 | else |
1268 | prog = sh; | 1268 | prog = sh; |
@@ -1297,10 +1297,10 @@ sigchld(int a) | |||
1297 | int stat; | 1297 | int stat; |
1298 | pid_t p; | 1298 | pid_t p; |
1299 | 1299 | ||
1300 | if((p = waitpid(pid, &stat, WNOHANG)) < 0) | 1300 | if ((p = waitpid(pid, &stat, WNOHANG)) < 0) |
1301 | die("Waiting for pid %hd failed: %s\n", pid, strerror(errno)); | 1301 | die("Waiting for pid %hd failed: %s\n", pid, strerror(errno)); |
1302 | 1302 | ||
1303 | if(pid != p) | 1303 | if (pid != p) |
1304 | return; | 1304 | return; |
1305 | 1305 | ||
1306 | if (!WIFEXITED(stat) || WEXITSTATUS(stat)) | 1306 | if (!WIFEXITED(stat) || WEXITSTATUS(stat)) |
@@ -1315,13 +1315,13 @@ stty(void) | |||
1315 | char cmd[_POSIX_ARG_MAX], **p, *q, *s; | 1315 | char cmd[_POSIX_ARG_MAX], **p, *q, *s; |
1316 | size_t n, siz; | 1316 | size_t n, siz; |
1317 | 1317 | ||
1318 | if((n = strlen(stty_args)) > sizeof(cmd)-1) | 1318 | if ((n = strlen(stty_args)) > sizeof(cmd)-1) |
1319 | die("incorrect stty parameters\n"); | 1319 | die("incorrect stty parameters\n"); |
1320 | memcpy(cmd, stty_args, n); | 1320 | memcpy(cmd, stty_args, n); |
1321 | q = cmd + n; | 1321 | q = cmd + n; |
1322 | siz = sizeof(cmd) - n; | 1322 | siz = sizeof(cmd) - n; |
1323 | for(p = opt_cmd; p && (s = *p); ++p) { | 1323 | for (p = opt_cmd; p && (s = *p); ++p) { |
1324 | if((n = strlen(s)) > siz-1) | 1324 | if ((n = strlen(s)) > siz-1) |
1325 | die("stty parameter length too long\n"); | 1325 | die("stty parameter length too long\n"); |
1326 | *q++ = ' '; | 1326 | *q++ = ' '; |
1327 | q = memcpy(q, s, n); | 1327 | q = memcpy(q, s, n); |
@@ -1339,18 +1339,18 @@ ttynew(void) | |||
1339 | int m, s; | 1339 | int m, s; |
1340 | struct winsize w = {term.row, term.col, 0, 0}; | 1340 | struct winsize w = {term.row, term.col, 0, 0}; |
1341 | 1341 | ||
1342 | if(opt_io) { | 1342 | if (opt_io) { |
1343 | term.mode |= MODE_PRINT; | 1343 | term.mode |= MODE_PRINT; |
1344 | iofd = (!strcmp(opt_io, "-")) ? | 1344 | iofd = (!strcmp(opt_io, "-")) ? |
1345 | 1 : open(opt_io, O_WRONLY | O_CREAT, 0666); | 1345 | 1 : open(opt_io, O_WRONLY | O_CREAT, 0666); |
1346 | if(iofd < 0) { | 1346 | if (iofd < 0) { |
1347 | fprintf(stderr, "Error opening %s:%s\n", | 1347 | fprintf(stderr, "Error opening %s:%s\n", |
1348 | opt_io, strerror(errno)); | 1348 | opt_io, strerror(errno)); |
1349 | } | 1349 | } |
1350 | } | 1350 | } |
1351 | 1351 | ||
1352 | if (opt_line) { | 1352 | if (opt_line) { |
1353 | if((cmdfd = open(opt_line, O_RDWR)) < 0) | 1353 | if ((cmdfd = open(opt_line, O_RDWR)) < 0) |
1354 | die("open line failed: %s\n", strerror(errno)); | 1354 | die("open line failed: %s\n", strerror(errno)); |
1355 | close(0); | 1355 | close(0); |
1356 | dup(cmdfd); | 1356 | dup(cmdfd); |
@@ -1359,10 +1359,10 @@ ttynew(void) | |||
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | /* seems to work fine on linux, openbsd and freebsd */ | 1361 | /* seems to work fine on linux, openbsd and freebsd */ |
1362 | if(openpty(&m, &s, NULL, NULL, &w) < 0) | 1362 | if (openpty(&m, &s, NULL, NULL, &w) < 0) |
1363 | die("openpty failed: %s\n", strerror(errno)); | 1363 | die("openpty failed: %s\n", strerror(errno)); |
1364 | 1364 | ||
1365 | switch(pid = fork()) { | 1365 | switch (pid = fork()) { |
1366 | case -1: | 1366 | case -1: |
1367 | die("fork failed\n"); | 1367 | die("fork failed\n"); |
1368 | break; | 1368 | break; |
@@ -1372,7 +1372,7 @@ ttynew(void) | |||
1372 | dup2(s, 0); | 1372 | dup2(s, 0); |
1373 | dup2(s, 1); | 1373 | dup2(s, 1); |
1374 | dup2(s, 2); | 1374 | dup2(s, 2); |
1375 | if(ioctl(s, TIOCSCTTY, NULL) < 0) | 1375 | if (ioctl(s, TIOCSCTTY, NULL) < 0) |
1376 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); | 1376 | die("ioctl TIOCSCTTY failed: %s\n", strerror(errno)); |
1377 | close(s); | 1377 | close(s); |
1378 | close(m); | 1378 | close(m); |
@@ -1397,13 +1397,13 @@ ttyread(void) | |||
1397 | int ret; | 1397 | int ret; |
1398 | 1398 | ||
1399 | /* append read bytes to unprocessed bytes */ | 1399 | /* append read bytes to unprocessed bytes */ |
1400 | if((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) | 1400 | if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0) |
1401 | die("Couldn't read from shell: %s\n", strerror(errno)); | 1401 | die("Couldn't read from shell: %s\n", strerror(errno)); |
1402 | 1402 | ||
1403 | /* process every complete utf8 char */ | 1403 | /* process every complete utf8 char */ |
1404 | buflen += ret; | 1404 | buflen += ret; |
1405 | ptr = buf; | 1405 | ptr = buf; |
1406 | while((charsize = utf8decode(ptr, &unicodep, buflen))) { | 1406 | while ((charsize = utf8decode(ptr, &unicodep, buflen))) { |
1407 | tputc(unicodep); | 1407 | tputc(unicodep); |
1408 | ptr += charsize; | 1408 | ptr += charsize; |
1409 | buflen -= charsize; | 1409 | buflen -= charsize; |
@@ -1416,7 +1416,7 @@ ttyread(void) | |||
1416 | void | 1416 | void |
1417 | ttywrite(const char *s, size_t n) | 1417 | ttywrite(const char *s, size_t n) |
1418 | { | 1418 | { |
1419 | if(xwrite(cmdfd, s, n) == -1) | 1419 | if (xwrite(cmdfd, s, n) == -1) |
1420 | die("write error on tty: %s\n", strerror(errno)); | 1420 | die("write error on tty: %s\n", strerror(errno)); |
1421 | } | 1421 | } |
1422 | 1422 | ||
@@ -1427,8 +1427,8 @@ ttysend(char *s, size_t n) | |||
1427 | Rune u; | 1427 | Rune u; |
1428 | 1428 | ||
1429 | ttywrite(s, n); | 1429 | ttywrite(s, n); |
1430 | if(IS_SET(MODE_ECHO)) | 1430 | if (IS_SET(MODE_ECHO)) |
1431 | while((len = utf8decode(s, &u, n)) > 0) { | 1431 | while ((len = utf8decode(s, &u, n)) > 0) { |
1432 | techo(u); | 1432 | techo(u); |
1433 | n -= len; | 1433 | n -= len; |
1434 | s += len; | 1434 | s += len; |
@@ -1444,7 +1444,7 @@ ttyresize(void) | |||
1444 | w.ws_col = term.col; | 1444 | w.ws_col = term.col; |
1445 | w.ws_xpixel = xw.tw; | 1445 | w.ws_xpixel = xw.tw; |
1446 | w.ws_ypixel = xw.th; | 1446 | w.ws_ypixel = xw.th; |
1447 | if(ioctl(cmdfd, TIOCSWINSZ, &w) < 0) | 1447 | if (ioctl(cmdfd, TIOCSWINSZ, &w) < 0) |
1448 | fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno)); | 1448 | fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno)); |
1449 | } | 1449 | } |
1450 | 1450 | ||
@@ -1453,9 +1453,9 @@ tattrset(int attr) | |||
1453 | { | 1453 | { |
1454 | int i, j; | 1454 | int i, j; |
1455 | 1455 | ||
1456 | for(i = 0; i < term.row-1; i++) { | 1456 | for (i = 0; i < term.row-1; i++) { |
1457 | for(j = 0; j < term.col-1; j++) { | 1457 | for (j = 0; j < term.col-1; j++) { |
1458 | if(term.line[i][j].mode & attr) | 1458 | if (term.line[i][j].mode & attr) |
1459 | return 1; | 1459 | return 1; |
1460 | } | 1460 | } |
1461 | } | 1461 | } |
@@ -1471,7 +1471,7 @@ tsetdirt(int top, int bot) | |||
1471 | LIMIT(top, 0, term.row-1); | 1471 | LIMIT(top, 0, term.row-1); |
1472 | LIMIT(bot, 0, term.row-1); | 1472 | LIMIT(bot, 0, term.row-1); |
1473 | 1473 | ||
1474 | for(i = top; i <= bot; i++) | 1474 | for (i = top; i <= bot; i++) |
1475 | term.dirty[i] = 1; | 1475 | term.dirty[i] = 1; |
1476 | } | 1476 | } |
1477 | 1477 | ||
@@ -1480,9 +1480,9 @@ tsetdirtattr(int attr) | |||
1480 | { | 1480 | { |
1481 | int i, j; | 1481 | int i, j; |
1482 | 1482 | ||
1483 | for(i = 0; i < term.row-1; i++) { | 1483 | for (i = 0; i < term.row-1; i++) { |
1484 | for(j = 0; j < term.col-1; j++) { | 1484 | for (j = 0; j < term.col-1; j++) { |
1485 | if(term.line[i][j].mode & attr) { | 1485 | if (term.line[i][j].mode & attr) { |
1486 | tsetdirt(i, i); | 1486 | tsetdirt(i, i); |
1487 | break; | 1487 | break; |
1488 | } | 1488 | } |
@@ -1502,9 +1502,9 @@ tcursor(int mode) | |||
1502 | static TCursor c[2]; | 1502 | static TCursor c[2]; |
1503 | int alt = IS_SET(MODE_ALTSCREEN); | 1503 | int alt = IS_SET(MODE_ALTSCREEN); |
1504 | 1504 | ||
1505 | if(mode == CURSOR_SAVE) { | 1505 | if (mode == CURSOR_SAVE) { |
1506 | c[alt] = term.c; | 1506 | c[alt] = term.c; |
1507 | } else if(mode == CURSOR_LOAD) { | 1507 | } else if (mode == CURSOR_LOAD) { |
1508 | term.c = c[alt]; | 1508 | term.c = c[alt]; |
1509 | tmoveto(c[alt].x, c[alt].y); | 1509 | tmoveto(c[alt].x, c[alt].y); |
1510 | } | 1510 | } |
@@ -1522,7 +1522,7 @@ treset(void) | |||
1522 | }, .x = 0, .y = 0, .state = CURSOR_DEFAULT}; | 1522 | }, .x = 0, .y = 0, .state = CURSOR_DEFAULT}; |
1523 | 1523 | ||
1524 | memset(term.tabs, 0, term.col * sizeof(*term.tabs)); | 1524 | memset(term.tabs, 0, term.col * sizeof(*term.tabs)); |
1525 | for(i = tabspaces; i < term.col; i += tabspaces) | 1525 | for (i = tabspaces; i < term.col; i += tabspaces) |
1526 | term.tabs[i] = 1; | 1526 | term.tabs[i] = 1; |
1527 | term.top = 0; | 1527 | term.top = 0; |
1528 | term.bot = term.row - 1; | 1528 | term.bot = term.row - 1; |
@@ -1530,7 +1530,7 @@ treset(void) | |||
1530 | memset(term.trantbl, CS_USA, sizeof(term.trantbl)); | 1530 | memset(term.trantbl, CS_USA, sizeof(term.trantbl)); |
1531 | term.charset = 0; | 1531 | term.charset = 0; |
1532 | 1532 | ||
1533 | for(i = 0; i < 2; i++) { | 1533 | for (i = 0; i < 2; i++) { |
1534 | tmoveto(0, 0); | 1534 | tmoveto(0, 0); |
1535 | tcursor(CURSOR_SAVE); | 1535 | tcursor(CURSOR_SAVE); |
1536 | tclearregion(0, 0, term.col-1, term.row-1); | 1536 | tclearregion(0, 0, term.col-1, term.row-1); |
@@ -1570,7 +1570,7 @@ tscrolldown(int orig, int n) | |||
1570 | tsetdirt(orig, term.bot-n); | 1570 | tsetdirt(orig, term.bot-n); |
1571 | tclearregion(0, term.bot-n+1, term.col-1, term.bot); | 1571 | tclearregion(0, term.bot-n+1, term.col-1, term.bot); |
1572 | 1572 | ||
1573 | for(i = term.bot; i >= orig+n; i--) { | 1573 | for (i = term.bot; i >= orig+n; i--) { |
1574 | temp = term.line[i]; | 1574 | temp = term.line[i]; |
1575 | term.line[i] = term.line[i-n]; | 1575 | term.line[i] = term.line[i-n]; |
1576 | term.line[i-n] = temp; | 1576 | term.line[i-n] = temp; |
@@ -1590,7 +1590,7 @@ tscrollup(int orig, int n) | |||
1590 | tclearregion(0, orig, term.col-1, orig+n-1); | 1590 | tclearregion(0, orig, term.col-1, orig+n-1); |
1591 | tsetdirt(orig+n, term.bot); | 1591 | tsetdirt(orig+n, term.bot); |
1592 | 1592 | ||
1593 | for(i = orig; i <= term.bot-n; i++) { | 1593 | for (i = orig; i <= term.bot-n; i++) { |
1594 | temp = term.line[i]; | 1594 | temp = term.line[i]; |
1595 | term.line[i] = term.line[i+n]; | 1595 | term.line[i] = term.line[i+n]; |
1596 | term.line[i+n] = temp; | 1596 | term.line[i+n] = temp; |
@@ -1602,25 +1602,25 @@ tscrollup(int orig, int n) | |||
1602 | void | 1602 | void |
1603 | selscroll(int orig, int n) | 1603 | selscroll(int orig, int n) |
1604 | { | 1604 | { |
1605 | if(sel.ob.x == -1) | 1605 | if (sel.ob.x == -1) |
1606 | return; | 1606 | return; |
1607 | 1607 | ||
1608 | if(BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) { | 1608 | if (BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) { |
1609 | if((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) { | 1609 | if ((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) { |
1610 | selclear(NULL); | 1610 | selclear(NULL); |
1611 | return; | 1611 | return; |
1612 | } | 1612 | } |
1613 | if(sel.type == SEL_RECTANGULAR) { | 1613 | if (sel.type == SEL_RECTANGULAR) { |
1614 | if(sel.ob.y < term.top) | 1614 | if (sel.ob.y < term.top) |
1615 | sel.ob.y = term.top; | 1615 | sel.ob.y = term.top; |
1616 | if(sel.oe.y > term.bot) | 1616 | if (sel.oe.y > term.bot) |
1617 | sel.oe.y = term.bot; | 1617 | sel.oe.y = term.bot; |
1618 | } else { | 1618 | } else { |
1619 | if(sel.ob.y < term.top) { | 1619 | if (sel.ob.y < term.top) { |
1620 | sel.ob.y = term.top; | 1620 | sel.ob.y = term.top; |
1621 | sel.ob.x = 0; | 1621 | sel.ob.x = 0; |
1622 | } | 1622 | } |
1623 | if(sel.oe.y > term.bot) { | 1623 | if (sel.oe.y > term.bot) { |
1624 | sel.oe.y = term.bot; | 1624 | sel.oe.y = term.bot; |
1625 | sel.oe.x = term.col; | 1625 | sel.oe.x = term.col; |
1626 | } | 1626 | } |
@@ -1634,7 +1634,7 @@ tnewline(int first_col) | |||
1634 | { | 1634 | { |
1635 | int y = term.c.y; | 1635 | int y = term.c.y; |
1636 | 1636 | ||
1637 | if(y == term.bot) { | 1637 | if (y == term.bot) { |
1638 | tscrollup(term.top, 1); | 1638 | tscrollup(term.top, 1); |
1639 | } else { | 1639 | } else { |
1640 | y++; | 1640 | y++; |
@@ -1649,22 +1649,22 @@ csiparse(void) | |||
1649 | long int v; | 1649 | long int v; |
1650 | 1650 | ||
1651 | csiescseq.narg = 0; | 1651 | csiescseq.narg = 0; |
1652 | if(*p == '?') { | 1652 | if (*p == '?') { |
1653 | csiescseq.priv = 1; | 1653 | csiescseq.priv = 1; |
1654 | p++; | 1654 | p++; |
1655 | } | 1655 | } |
1656 | 1656 | ||
1657 | csiescseq.buf[csiescseq.len] = '\0'; | 1657 | csiescseq.buf[csiescseq.len] = '\0'; |
1658 | while(p < csiescseq.buf+csiescseq.len) { | 1658 | while (p < csiescseq.buf+csiescseq.len) { |
1659 | np = NULL; | 1659 | np = NULL; |
1660 | v = strtol(p, &np, 10); | 1660 | v = strtol(p, &np, 10); |
1661 | if(np == p) | 1661 | if (np == p) |
1662 | v = 0; | 1662 | v = 0; |
1663 | if(v == LONG_MAX || v == LONG_MIN) | 1663 | if (v == LONG_MAX || v == LONG_MIN) |
1664 | v = -1; | 1664 | v = -1; |
1665 | csiescseq.arg[csiescseq.narg++] = v; | 1665 | csiescseq.arg[csiescseq.narg++] = v; |
1666 | p = np; | 1666 | p = np; |
1667 | if(*p != ';' || csiescseq.narg == ESC_ARG_SIZ) | 1667 | if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ) |
1668 | break; | 1668 | break; |
1669 | p++; | 1669 | p++; |
1670 | } | 1670 | } |
@@ -1684,7 +1684,7 @@ tmoveto(int x, int y) | |||
1684 | { | 1684 | { |
1685 | int miny, maxy; | 1685 | int miny, maxy; |
1686 | 1686 | ||
1687 | if(term.c.state & CURSOR_ORIGIN) { | 1687 | if (term.c.state & CURSOR_ORIGIN) { |
1688 | miny = term.top; | 1688 | miny = term.top; |
1689 | maxy = term.bot; | 1689 | maxy = term.bot; |
1690 | } else { | 1690 | } else { |
@@ -1713,16 +1713,16 @@ tsetchar(Rune u, Glyph *attr, int x, int y) | |||
1713 | /* | 1713 | /* |
1714 | * The table is proudly stolen from rxvt. | 1714 | * The table is proudly stolen from rxvt. |
1715 | */ | 1715 | */ |
1716 | if(term.trantbl[term.charset] == CS_GRAPHIC0 && | 1716 | if (term.trantbl[term.charset] == CS_GRAPHIC0 && |
1717 | BETWEEN(u, 0x41, 0x7e) && vt100_0[u - 0x41]) | 1717 | BETWEEN(u, 0x41, 0x7e) && vt100_0[u - 0x41]) |
1718 | utf8decode(vt100_0[u - 0x41], &u, UTF_SIZ); | 1718 | utf8decode(vt100_0[u - 0x41], &u, UTF_SIZ); |
1719 | 1719 | ||
1720 | if(term.line[y][x].mode & ATTR_WIDE) { | 1720 | if (term.line[y][x].mode & ATTR_WIDE) { |
1721 | if(x+1 < term.col) { | 1721 | if (x+1 < term.col) { |
1722 | term.line[y][x+1].u = ' '; | 1722 | term.line[y][x+1].u = ' '; |
1723 | term.line[y][x+1].mode &= ~ATTR_WDUMMY; | 1723 | term.line[y][x+1].mode &= ~ATTR_WDUMMY; |
1724 | } | 1724 | } |
1725 | } else if(term.line[y][x].mode & ATTR_WDUMMY) { | 1725 | } else if (term.line[y][x].mode & ATTR_WDUMMY) { |
1726 | term.line[y][x-1].u = ' '; | 1726 | term.line[y][x-1].u = ' '; |
1727 | term.line[y][x-1].mode &= ~ATTR_WIDE; | 1727 | term.line[y][x-1].mode &= ~ATTR_WIDE; |
1728 | } | 1728 | } |
@@ -1738,9 +1738,9 @@ tclearregion(int x1, int y1, int x2, int y2) | |||
1738 | int x, y, temp; | 1738 | int x, y, temp; |
1739 | Glyph *gp; | 1739 | Glyph *gp; |
1740 | 1740 | ||
1741 | if(x1 > x2) | 1741 | if (x1 > x2) |
1742 | temp = x1, x1 = x2, x2 = temp; | 1742 | temp = x1, x1 = x2, x2 = temp; |
1743 | if(y1 > y2) | 1743 | if (y1 > y2) |
1744 | temp = y1, y1 = y2, y2 = temp; | 1744 | temp = y1, y1 = y2, y2 = temp; |
1745 | 1745 | ||
1746 | LIMIT(x1, 0, term.col-1); | 1746 | LIMIT(x1, 0, term.col-1); |
@@ -1748,11 +1748,11 @@ tclearregion(int x1, int y1, int x2, int y2) | |||
1748 | LIMIT(y1, 0, term.row-1); | 1748 | LIMIT(y1, 0, term.row-1); |
1749 | LIMIT(y2, 0, term.row-1); | 1749 | LIMIT(y2, 0, term.row-1); |
1750 | 1750 | ||
1751 | for(y = y1; y <= y2; y++) { | 1751 | for (y = y1; y <= y2; y++) { |
1752 | term.dirty[y] = 1; | 1752 | term.dirty[y] = 1; |
1753 | for(x = x1; x <= x2; x++) { | 1753 | for (x = x1; x <= x2; x++) { |
1754 | gp = &term.line[y][x]; | 1754 | gp = &term.line[y][x]; |
1755 | if(selected(x, y)) | 1755 | if (selected(x, y)) |
1756 | selclear(NULL); | 1756 | selclear(NULL); |
1757 | gp->fg = term.c.attr.fg; | 1757 | gp->fg = term.c.attr.fg; |
1758 | gp->bg = term.c.attr.bg; | 1758 | gp->bg = term.c.attr.bg; |
@@ -1799,14 +1799,14 @@ tinsertblank(int n) | |||
1799 | void | 1799 | void |
1800 | tinsertblankline(int n) | 1800 | tinsertblankline(int n) |
1801 | { | 1801 | { |
1802 | if(BETWEEN(term.c.y, term.top, term.bot)) | 1802 | if (BETWEEN(term.c.y, term.top, term.bot)) |
1803 | tscrolldown(term.c.y, n); | 1803 | tscrolldown(term.c.y, n); |
1804 | } | 1804 | } |
1805 | 1805 | ||
1806 | void | 1806 | void |
1807 | tdeleteline(int n) | 1807 | tdeleteline(int n) |
1808 | { | 1808 | { |
1809 | if(BETWEEN(term.c.y, term.top, term.bot)) | 1809 | if (BETWEEN(term.c.y, term.top, term.bot)) |
1810 | tscrollup(term.c.y, n); | 1810 | tscrollup(term.c.y, n); |
1811 | } | 1811 | } |
1812 | 1812 | ||
@@ -1828,7 +1828,7 @@ tdefcolor(int *attr, int *npar, int l) | |||
1828 | g = attr[*npar + 3]; | 1828 | g = attr[*npar + 3]; |
1829 | b = attr[*npar + 4]; | 1829 | b = attr[*npar + 4]; |
1830 | *npar += 4; | 1830 | *npar += 4; |
1831 | if(!BETWEEN(r, 0, 255) || !BETWEEN(g, 0, 255) || !BETWEEN(b, 0, 255)) | 1831 | if (!BETWEEN(r, 0, 255) || !BETWEEN(g, 0, 255) || !BETWEEN(b, 0, 255)) |
1832 | fprintf(stderr, "erresc: bad rgb color (%u,%u,%u)\n", | 1832 | fprintf(stderr, "erresc: bad rgb color (%u,%u,%u)\n", |
1833 | r, g, b); | 1833 | r, g, b); |
1834 | else | 1834 | else |
@@ -1842,7 +1842,7 @@ tdefcolor(int *attr, int *npar, int l) | |||
1842 | break; | 1842 | break; |
1843 | } | 1843 | } |
1844 | *npar += 2; | 1844 | *npar += 2; |
1845 | if(!BETWEEN(attr[*npar], 0, 255)) | 1845 | if (!BETWEEN(attr[*npar], 0, 255)) |
1846 | fprintf(stderr, "erresc: bad fgcolor %d\n", attr[*npar]); | 1846 | fprintf(stderr, "erresc: bad fgcolor %d\n", attr[*npar]); |
1847 | else | 1847 | else |
1848 | idx = attr[*npar]; | 1848 | idx = attr[*npar]; |
@@ -1866,8 +1866,8 @@ tsetattr(int *attr, int l) | |||
1866 | int i; | 1866 | int i; |
1867 | int32_t idx; | 1867 | int32_t idx; |
1868 | 1868 | ||
1869 | for(i = 0; i < l; i++) { | 1869 | for (i = 0; i < l; i++) { |
1870 | switch(attr[i]) { | 1870 | switch (attr[i]) { |
1871 | case 0: | 1871 | case 0: |
1872 | term.c.attr.mode &= ~( | 1872 | term.c.attr.mode &= ~( |
1873 | ATTR_BOLD | | 1873 | ATTR_BOLD | |
@@ -1943,13 +1943,13 @@ tsetattr(int *attr, int l) | |||
1943 | term.c.attr.bg = defaultbg; | 1943 | term.c.attr.bg = defaultbg; |
1944 | break; | 1944 | break; |
1945 | default: | 1945 | default: |
1946 | if(BETWEEN(attr[i], 30, 37)) { | 1946 | if (BETWEEN(attr[i], 30, 37)) { |
1947 | term.c.attr.fg = attr[i] - 30; | 1947 | term.c.attr.fg = attr[i] - 30; |
1948 | } else if(BETWEEN(attr[i], 40, 47)) { | 1948 | } else if (BETWEEN(attr[i], 40, 47)) { |
1949 | term.c.attr.bg = attr[i] - 40; | 1949 | term.c.attr.bg = attr[i] - 40; |
1950 | } else if(BETWEEN(attr[i], 90, 97)) { | 1950 | } else if (BETWEEN(attr[i], 90, 97)) { |
1951 | term.c.attr.fg = attr[i] - 90 + 8; | 1951 | term.c.attr.fg = attr[i] - 90 + 8; |
1952 | } else if(BETWEEN(attr[i], 100, 107)) { | 1952 | } else if (BETWEEN(attr[i], 100, 107)) { |
1953 | term.c.attr.bg = attr[i] - 100 + 8; | 1953 | term.c.attr.bg = attr[i] - 100 + 8; |
1954 | } else { | 1954 | } else { |
1955 | fprintf(stderr, | 1955 | fprintf(stderr, |
@@ -1968,7 +1968,7 @@ tsetscroll(int t, int b) | |||
1968 | 1968 | ||
1969 | LIMIT(t, 0, term.row-1); | 1969 | LIMIT(t, 0, term.row-1); |
1970 | LIMIT(b, 0, term.row-1); | 1970 | LIMIT(b, 0, term.row-1); |
1971 | if(t > b) { | 1971 | if (t > b) { |
1972 | temp = t; | 1972 | temp = t; |
1973 | t = b; | 1973 | t = b; |
1974 | b = temp; | 1974 | b = temp; |
@@ -1983,16 +1983,16 @@ tsetmode(int priv, int set, int *args, int narg) | |||
1983 | int *lim, mode; | 1983 | int *lim, mode; |
1984 | int alt; | 1984 | int alt; |
1985 | 1985 | ||
1986 | for(lim = args + narg; args < lim; ++args) { | 1986 | for (lim = args + narg; args < lim; ++args) { |
1987 | if(priv) { | 1987 | if (priv) { |
1988 | switch(*args) { | 1988 | switch (*args) { |
1989 | case 1: /* DECCKM -- Cursor key */ | 1989 | case 1: /* DECCKM -- Cursor key */ |
1990 | MODBIT(term.mode, set, MODE_APPCURSOR); | 1990 | MODBIT(term.mode, set, MODE_APPCURSOR); |
1991 | break; | 1991 | break; |
1992 | case 5: /* DECSCNM -- Reverse video */ | 1992 | case 5: /* DECSCNM -- Reverse video */ |
1993 | mode = term.mode; | 1993 | mode = term.mode; |
1994 | MODBIT(term.mode, set, MODE_REVERSE); | 1994 | MODBIT(term.mode, set, MODE_REVERSE); |
1995 | if(mode != term.mode) | 1995 | if (mode != term.mode) |
1996 | redraw(); | 1996 | redraw(); |
1997 | break; | 1997 | break; |
1998 | case 6: /* DECOM -- Origin */ | 1998 | case 6: /* DECOM -- Origin */ |
@@ -2054,13 +2054,13 @@ tsetmode(int priv, int set, int *args, int narg) | |||
2054 | if (!allowaltscreen) | 2054 | if (!allowaltscreen) |
2055 | break; | 2055 | break; |
2056 | alt = IS_SET(MODE_ALTSCREEN); | 2056 | alt = IS_SET(MODE_ALTSCREEN); |
2057 | if(alt) { | 2057 | if (alt) { |
2058 | tclearregion(0, 0, term.col-1, | 2058 | tclearregion(0, 0, term.col-1, |
2059 | term.row-1); | 2059 | term.row-1); |
2060 | } | 2060 | } |
2061 | if(set ^ alt) /* set is always 1 or 0 */ | 2061 | if (set ^ alt) /* set is always 1 or 0 */ |
2062 | tswapscreen(); | 2062 | tswapscreen(); |
2063 | if(*args != 1049) | 2063 | if (*args != 1049) |
2064 | break; | 2064 | break; |
2065 | /* FALLTHROUGH */ | 2065 | /* FALLTHROUGH */ |
2066 | case 1048: | 2066 | case 1048: |
@@ -2085,7 +2085,7 @@ tsetmode(int priv, int set, int *args, int narg) | |||
2085 | break; | 2085 | break; |
2086 | } | 2086 | } |
2087 | } else { | 2087 | } else { |
2088 | switch(*args) { | 2088 | switch (*args) { |
2089 | case 0: /* Error (IGNORED) */ | 2089 | case 0: /* Error (IGNORED) */ |
2090 | break; | 2090 | break; |
2091 | case 2: /* KAM -- keyboard action */ | 2091 | case 2: /* KAM -- keyboard action */ |
@@ -2116,7 +2116,7 @@ csihandle(void) | |||
2116 | char buf[40]; | 2116 | char buf[40]; |
2117 | int len; | 2117 | int len; |
2118 | 2118 | ||
2119 | switch(csiescseq.mode[0]) { | 2119 | switch (csiescseq.mode[0]) { |
2120 | default: | 2120 | default: |
2121 | unknown: | 2121 | unknown: |
2122 | fprintf(stderr, "erresc: unknown csi "); | 2122 | fprintf(stderr, "erresc: unknown csi "); |
@@ -2137,7 +2137,7 @@ csihandle(void) | |||
2137 | tmoveto(term.c.x, term.c.y+csiescseq.arg[0]); | 2137 | tmoveto(term.c.x, term.c.y+csiescseq.arg[0]); |
2138 | break; | 2138 | break; |
2139 | case 'i': /* MC -- Media Copy */ | 2139 | case 'i': /* MC -- Media Copy */ |
2140 | switch(csiescseq.arg[0]) { | 2140 | switch (csiescseq.arg[0]) { |
2141 | case 0: | 2141 | case 0: |
2142 | tdump(); | 2142 | tdump(); |
2143 | break; | 2143 | break; |
@@ -2156,7 +2156,7 @@ csihandle(void) | |||
2156 | } | 2156 | } |
2157 | break; | 2157 | break; |
2158 | case 'c': /* DA -- Device Attributes */ | 2158 | case 'c': /* DA -- Device Attributes */ |
2159 | if(csiescseq.arg[0] == 0) | 2159 | if (csiescseq.arg[0] == 0) |
2160 | ttywrite(vtiden, sizeof(vtiden) - 1); | 2160 | ttywrite(vtiden, sizeof(vtiden) - 1); |
2161 | break; | 2161 | break; |
2162 | case 'C': /* CUF -- Cursor <n> Forward */ | 2162 | case 'C': /* CUF -- Cursor <n> Forward */ |
@@ -2177,7 +2177,7 @@ csihandle(void) | |||
2177 | tmoveto(0, term.c.y-csiescseq.arg[0]); | 2177 | tmoveto(0, term.c.y-csiescseq.arg[0]); |
2178 | break; | 2178 | break; |
2179 | case 'g': /* TBC -- Tabulation clear */ | 2179 | case 'g': /* TBC -- Tabulation clear */ |
2180 | switch(csiescseq.arg[0]) { | 2180 | switch (csiescseq.arg[0]) { |
2181 | case 0: /* clear current tab stop */ | 2181 | case 0: /* clear current tab stop */ |
2182 | term.tabs[term.c.x] = 0; | 2182 | term.tabs[term.c.x] = 0; |
2183 | break; | 2183 | break; |
@@ -2205,16 +2205,16 @@ csihandle(void) | |||
2205 | break; | 2205 | break; |
2206 | case 'J': /* ED -- Clear screen */ | 2206 | case 'J': /* ED -- Clear screen */ |
2207 | selclear(NULL); | 2207 | selclear(NULL); |
2208 | switch(csiescseq.arg[0]) { | 2208 | switch (csiescseq.arg[0]) { |
2209 | case 0: /* below */ | 2209 | case 0: /* below */ |
2210 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); | 2210 | tclearregion(term.c.x, term.c.y, term.col-1, term.c.y); |
2211 | if(term.c.y < term.row-1) { | 2211 | if (term.c.y < term.row-1) { |
2212 | tclearregion(0, term.c.y+1, term.col-1, | 2212 | tclearregion(0, term.c.y+1, term.col-1, |
2213 | term.row-1); | 2213 | term.row-1); |
2214 | } | 2214 | } |
2215 | break; | 2215 | break; |
2216 | case 1: /* above */ | 2216 | case 1: /* above */ |
2217 | if(term.c.y > 1) | 2217 | if (term.c.y > 1) |
2218 | tclearregion(0, 0, term.col-1, term.c.y-1); | 2218 | tclearregion(0, 0, term.col-1, term.c.y-1); |
2219 | tclearregion(0, term.c.y, term.c.x, term.c.y); | 2219 | tclearregion(0, term.c.y, term.c.x, term.c.y); |
2220 | break; | 2220 | break; |
@@ -2226,7 +2226,7 @@ csihandle(void) | |||
2226 | } | 2226 | } |
2227 | break; | 2227 | break; |
2228 | case 'K': /* EL -- Clear line */ | 2228 | case 'K': /* EL -- Clear line */ |
2229 | switch(csiescseq.arg[0]) { | 2229 | switch (csiescseq.arg[0]) { |
2230 | case 0: /* right */ | 2230 | case 0: /* right */ |
2231 | tclearregion(term.c.x, term.c.y, term.col-1, | 2231 | tclearregion(term.c.x, term.c.y, term.col-1, |
2232 | term.c.y); | 2232 | term.c.y); |
@@ -2289,7 +2289,7 @@ csihandle(void) | |||
2289 | } | 2289 | } |
2290 | break; | 2290 | break; |
2291 | case 'r': /* DECSTBM -- Set Scrolling Region */ | 2291 | case 'r': /* DECSTBM -- Set Scrolling Region */ |
2292 | if(csiescseq.priv) { | 2292 | if (csiescseq.priv) { |
2293 | goto unknown; | 2293 | goto unknown; |
2294 | } else { | 2294 | } else { |
2295 | DEFAULT(csiescseq.arg[0], 1); | 2295 | DEFAULT(csiescseq.arg[0], 1); |
@@ -2327,15 +2327,15 @@ csidump(void) | |||
2327 | uint c; | 2327 | uint c; |
2328 | 2328 | ||
2329 | printf("ESC["); | 2329 | printf("ESC["); |
2330 | for(i = 0; i < csiescseq.len; i++) { | 2330 | for (i = 0; i < csiescseq.len; i++) { |
2331 | c = csiescseq.buf[i] & 0xff; | 2331 | c = csiescseq.buf[i] & 0xff; |
2332 | if(isprint(c)) { | 2332 | if (isprint(c)) { |
2333 | putchar(c); | 2333 | putchar(c); |
2334 | } else if(c == '\n') { | 2334 | } else if (c == '\n') { |
2335 | printf("(\\n)"); | 2335 | printf("(\\n)"); |
2336 | } else if(c == '\r') { | 2336 | } else if (c == '\r') { |
2337 | printf("(\\r)"); | 2337 | printf("(\\r)"); |
2338 | } else if(c == 0x1b) { | 2338 | } else if (c == 0x1b) { |
2339 | printf("(\\e)"); | 2339 | printf("(\\e)"); |
2340 | } else { | 2340 | } else { |
2341 | printf("(%02x)", c); | 2341 | printf("(%02x)", c); |
@@ -2360,23 +2360,23 @@ strhandle(void) | |||
2360 | strparse(); | 2360 | strparse(); |
2361 | par = (narg = strescseq.narg) ? atoi(strescseq.args[0]) : 0; | 2361 | par = (narg = strescseq.narg) ? atoi(strescseq.args[0]) : 0; |
2362 | 2362 | ||
2363 | switch(strescseq.type) { | 2363 | switch (strescseq.type) { |
2364 | case ']': /* OSC -- Operating System Command */ | 2364 | case ']': /* OSC -- Operating System Command */ |
2365 | switch(par) { | 2365 | switch (par) { |
2366 | case 0: | 2366 | case 0: |
2367 | case 1: | 2367 | case 1: |
2368 | case 2: | 2368 | case 2: |
2369 | if(narg > 1) | 2369 | if (narg > 1) |
2370 | xsettitle(strescseq.args[1]); | 2370 | xsettitle(strescseq.args[1]); |
2371 | return; | 2371 | return; |
2372 | case 4: /* color set */ | 2372 | case 4: /* color set */ |
2373 | if(narg < 3) | 2373 | if (narg < 3) |
2374 | break; | 2374 | break; |
2375 | p = strescseq.args[2]; | 2375 | p = strescseq.args[2]; |
2376 | /* FALLTHROUGH */ | 2376 | /* FALLTHROUGH */ |
2377 | case 104: /* color reset, here p = NULL */ | 2377 | case 104: /* color reset, here p = NULL */ |
2378 | j = (narg > 1) ? atoi(strescseq.args[1]) : -1; | 2378 | j = (narg > 1) ? atoi(strescseq.args[1]) : -1; |
2379 | if(xsetcolorname(j, p)) { | 2379 | if (xsetcolorname(j, p)) { |
2380 | fprintf(stderr, "erresc: invalid color %s\n", p); | 2380 | fprintf(stderr, "erresc: invalid color %s\n", p); |
2381 | } else { | 2381 | } else { |
2382 | /* | 2382 | /* |
@@ -2410,14 +2410,14 @@ strparse(void) | |||
2410 | strescseq.narg = 0; | 2410 | strescseq.narg = 0; |
2411 | strescseq.buf[strescseq.len] = '\0'; | 2411 | strescseq.buf[strescseq.len] = '\0'; |
2412 | 2412 | ||
2413 | if(*p == '\0') | 2413 | if (*p == '\0') |
2414 | return; | 2414 | return; |
2415 | 2415 | ||
2416 | while(strescseq.narg < STR_ARG_SIZ) { | 2416 | while (strescseq.narg < STR_ARG_SIZ) { |
2417 | strescseq.args[strescseq.narg++] = p; | 2417 | strescseq.args[strescseq.narg++] = p; |
2418 | while((c = *p) != ';' && c != '\0') | 2418 | while ((c = *p) != ';' && c != '\0') |
2419 | ++p; | 2419 | ++p; |
2420 | if(c == '\0') | 2420 | if (c == '\0') |
2421 | return; | 2421 | return; |
2422 | *p++ = '\0'; | 2422 | *p++ = '\0'; |
2423 | } | 2423 | } |
@@ -2430,17 +2430,17 @@ strdump(void) | |||
2430 | uint c; | 2430 | uint c; |
2431 | 2431 | ||
2432 | printf("ESC%c", strescseq.type); | 2432 | printf("ESC%c", strescseq.type); |
2433 | for(i = 0; i < strescseq.len; i++) { | 2433 | for (i = 0; i < strescseq.len; i++) { |
2434 | c = strescseq.buf[i] & 0xff; | 2434 | c = strescseq.buf[i] & 0xff; |
2435 | if(c == '\0') { | 2435 | if (c == '\0') { |
2436 | return; | 2436 | return; |
2437 | } else if(isprint(c)) { | 2437 | } else if (isprint(c)) { |
2438 | putchar(c); | 2438 | putchar(c); |
2439 | } else if(c == '\n') { | 2439 | } else if (c == '\n') { |
2440 | printf("(\\n)"); | 2440 | printf("(\\n)"); |
2441 | } else if(c == '\r') { | 2441 | } else if (c == '\r') { |
2442 | printf("(\\r)"); | 2442 | printf("(\\r)"); |
2443 | } else if(c == 0x1b) { | 2443 | } else if (c == 0x1b) { |
2444 | printf("(\\e)"); | 2444 | printf("(\\e)"); |
2445 | } else { | 2445 | } else { |
2446 | printf("(%02x)", c); | 2446 | printf("(%02x)", c); |
@@ -2458,7 +2458,7 @@ strreset(void) | |||
2458 | void | 2458 | void |
2459 | tprinter(char *s, size_t len) | 2459 | tprinter(char *s, size_t len) |
2460 | { | 2460 | { |
2461 | if(iofd != -1 && xwrite(iofd, s, len) < 0) { | 2461 | if (iofd != -1 && xwrite(iofd, s, len) < 0) { |
2462 | fprintf(stderr, "Error writing in %s:%s\n", | 2462 | fprintf(stderr, "Error writing in %s:%s\n", |
2463 | opt_io, strerror(errno)); | 2463 | opt_io, strerror(errno)); |
2464 | close(iofd); | 2464 | close(iofd); |
@@ -2489,7 +2489,7 @@ tdumpsel(void) | |||
2489 | { | 2489 | { |
2490 | char *ptr; | 2490 | char *ptr; |
2491 | 2491 | ||
2492 | if((ptr = getsel())) { | 2492 | if ((ptr = getsel())) { |
2493 | tprinter(ptr, strlen(ptr)); | 2493 | tprinter(ptr, strlen(ptr)); |
2494 | free(ptr); | 2494 | free(ptr); |
2495 | } | 2495 | } |
@@ -2503,8 +2503,8 @@ tdumpline(int n) | |||
2503 | 2503 | ||
2504 | bp = &term.line[n][0]; | 2504 | bp = &term.line[n][0]; |
2505 | end = &bp[MIN(tlinelen(n), term.col) - 1]; | 2505 | end = &bp[MIN(tlinelen(n), term.col) - 1]; |
2506 | if(bp != end || bp->u != ' ') { | 2506 | if (bp != end || bp->u != ' ') { |
2507 | for( ;bp <= end; ++bp) | 2507 | for ( ;bp <= end; ++bp) |
2508 | tprinter(buf, utf8encode(bp->u, buf)); | 2508 | tprinter(buf, utf8encode(bp->u, buf)); |
2509 | } | 2509 | } |
2510 | tprinter("\n", 1); | 2510 | tprinter("\n", 1); |
@@ -2515,7 +2515,7 @@ tdump(void) | |||
2515 | { | 2515 | { |
2516 | int i; | 2516 | int i; |
2517 | 2517 | ||
2518 | for(i = 0; i < term.row; ++i) | 2518 | for (i = 0; i < term.row; ++i) |
2519 | tdumpline(i); | 2519 | tdumpline(i); |
2520 | } | 2520 | } |
2521 | 2521 | ||
@@ -2524,13 +2524,13 @@ tputtab(int n) | |||
2524 | { | 2524 | { |
2525 | uint x = term.c.x; | 2525 | uint x = term.c.x; |
2526 | 2526 | ||
2527 | if(n > 0) { | 2527 | if (n > 0) { |
2528 | while(x < term.col && n--) | 2528 | while (x < term.col && n--) |
2529 | for(++x; x < term.col && !term.tabs[x]; ++x) | 2529 | for (++x; x < term.col && !term.tabs[x]; ++x) |
2530 | /* nothing */ ; | 2530 | /* nothing */ ; |
2531 | } else if(n < 0) { | 2531 | } else if (n < 0) { |
2532 | while(x > 0 && n++) | 2532 | while (x > 0 && n++) |
2533 | for(--x; x > 0 && !term.tabs[x]; --x) | 2533 | for (--x; x > 0 && !term.tabs[x]; --x) |
2534 | /* nothing */ ; | 2534 | /* nothing */ ; |
2535 | } | 2535 | } |
2536 | term.c.x = LIMIT(x, 0, term.col-1); | 2536 | term.c.x = LIMIT(x, 0, term.col-1); |
@@ -2539,12 +2539,12 @@ tputtab(int n) | |||
2539 | void | 2539 | void |
2540 | techo(Rune u) | 2540 | techo(Rune u) |
2541 | { | 2541 | { |
2542 | if(ISCONTROL(u)) { /* control code */ | 2542 | if (ISCONTROL(u)) { /* control code */ |
2543 | if(u & 0x80) { | 2543 | if (u & 0x80) { |
2544 | u &= 0x7f; | 2544 | u &= 0x7f; |
2545 | tputc('^'); | 2545 | tputc('^'); |
2546 | tputc('['); | 2546 | tputc('['); |
2547 | } else if(u != '\n' && u != '\r' && u != '\t') { | 2547 | } else if (u != '\n' && u != '\r' && u != '\t') { |
2548 | u ^= 0x40; | 2548 | u ^= 0x40; |
2549 | tputc('^'); | 2549 | tputc('^'); |
2550 | } | 2550 | } |
@@ -2559,7 +2559,7 @@ tdeftran(char ascii) | |||
2559 | static int vcs[] = {CS_GRAPHIC0, CS_USA}; | 2559 | static int vcs[] = {CS_GRAPHIC0, CS_USA}; |
2560 | char *p; | 2560 | char *p; |
2561 | 2561 | ||
2562 | if((p = strchr(cs, ascii)) == NULL) { | 2562 | if ((p = strchr(cs, ascii)) == NULL) { |
2563 | fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii); | 2563 | fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii); |
2564 | } else { | 2564 | } else { |
2565 | term.trantbl[term.icharset] = vcs[p - cs]; | 2565 | term.trantbl[term.icharset] = vcs[p - cs]; |
@@ -2571,9 +2571,9 @@ tdectest(char c) | |||
2571 | { | 2571 | { |
2572 | int x, y; | 2572 | int x, y; |
2573 | 2573 | ||
2574 | if(c == '8') { /* DEC screen alignment test. */ | 2574 | if (c == '8') { /* DEC screen alignment test. */ |
2575 | for(x = 0; x < term.col; ++x) { | 2575 | for (x = 0; x < term.col; ++x) { |
2576 | for(y = 0; y < term.row; ++y) | 2576 | for (y = 0; y < term.row; ++y) |
2577 | tsetchar('E', &term.c.attr, x, y); | 2577 | tsetchar('E', &term.c.attr, x, y); |
2578 | } | 2578 | } |
2579 | } | 2579 | } |
@@ -2604,7 +2604,7 @@ tstrsequence(uchar c) | |||
2604 | void | 2604 | void |
2605 | tcontrolcode(uchar ascii) | 2605 | tcontrolcode(uchar ascii) |
2606 | { | 2606 | { |
2607 | switch(ascii) { | 2607 | switch (ascii) { |
2608 | case '\t': /* HT */ | 2608 | case '\t': /* HT */ |
2609 | tputtab(1); | 2609 | tputtab(1); |
2610 | return; | 2610 | return; |
@@ -2621,11 +2621,11 @@ tcontrolcode(uchar ascii) | |||
2621 | tnewline(IS_SET(MODE_CRLF)); | 2621 | tnewline(IS_SET(MODE_CRLF)); |
2622 | return; | 2622 | return; |
2623 | case '\a': /* BEL */ | 2623 | case '\a': /* BEL */ |
2624 | if(term.esc & ESC_STR_END) { | 2624 | if (term.esc & ESC_STR_END) { |
2625 | /* backwards compatibility to xterm */ | 2625 | /* backwards compatibility to xterm */ |
2626 | strhandle(); | 2626 | strhandle(); |
2627 | } else { | 2627 | } else { |
2628 | if(!(xw.state & WIN_FOCUSED)) | 2628 | if (!(xw.state & WIN_FOCUSED)) |
2629 | xseturgency(1); | 2629 | xseturgency(1); |
2630 | if (bellvolume) | 2630 | if (bellvolume) |
2631 | XkbBell(xw.dpy, xw.win, bellvolume, (Atom)NULL); | 2631 | XkbBell(xw.dpy, xw.win, bellvolume, (Atom)NULL); |
@@ -2688,7 +2688,7 @@ tcontrolcode(uchar ascii) | |||
2688 | int | 2688 | int |
2689 | eschandle(uchar ascii) | 2689 | eschandle(uchar ascii) |
2690 | { | 2690 | { |
2691 | switch(ascii) { | 2691 | switch (ascii) { |
2692 | case '[': | 2692 | case '[': |
2693 | term.esc |= ESC_CSI; | 2693 | term.esc |= ESC_CSI; |
2694 | return 0; | 2694 | return 0; |
@@ -2714,7 +2714,7 @@ eschandle(uchar ascii) | |||
2714 | term.esc |= ESC_ALTCHARSET; | 2714 | term.esc |= ESC_ALTCHARSET; |
2715 | return 0; | 2715 | return 0; |
2716 | case 'D': /* IND -- Linefeed */ | 2716 | case 'D': /* IND -- Linefeed */ |
2717 | if(term.c.y == term.bot) { | 2717 | if (term.c.y == term.bot) { |
2718 | tscrollup(term.top, 1); | 2718 | tscrollup(term.top, 1); |
2719 | } else { | 2719 | } else { |
2720 | tmoveto(term.c.x, term.c.y+1); | 2720 | tmoveto(term.c.x, term.c.y+1); |
@@ -2727,7 +2727,7 @@ eschandle(uchar ascii) | |||
2727 | term.tabs[term.c.x] = 1; | 2727 | term.tabs[term.c.x] = 1; |
2728 | break; | 2728 | break; |
2729 | case 'M': /* RI -- Reverse index */ | 2729 | case 'M': /* RI -- Reverse index */ |
2730 | if(term.c.y == term.top) { | 2730 | if (term.c.y == term.top) { |
2731 | tscrolldown(term.top, 1); | 2731 | tscrolldown(term.top, 1); |
2732 | } else { | 2732 | } else { |
2733 | tmoveto(term.c.x, term.c.y-1); | 2733 | tmoveto(term.c.x, term.c.y-1); |
@@ -2754,7 +2754,7 @@ eschandle(uchar ascii) | |||
2754 | tcursor(CURSOR_LOAD); | 2754 | tcursor(CURSOR_LOAD); |
2755 | break; | 2755 | break; |
2756 | case '\\': /* ST -- String Terminator */ | 2756 | case '\\': /* ST -- String Terminator */ |
2757 | if(term.esc & ESC_STR_END) | 2757 | if (term.esc & ESC_STR_END) |
2758 | strhandle(); | 2758 | strhandle(); |
2759 | break; | 2759 | break; |
2760 | default: | 2760 | default: |
@@ -2774,12 +2774,12 @@ tputc(Rune u) | |||
2774 | Glyph *gp; | 2774 | Glyph *gp; |
2775 | 2775 | ||
2776 | len = utf8encode(u, c); | 2776 | len = utf8encode(u, c); |
2777 | if((width = wcwidth(u)) == -1) { | 2777 | if ((width = wcwidth(u)) == -1) { |
2778 | memcpy(c, "\357\277\275", 4); /* UTF_INVALID */ | 2778 | memcpy(c, "\357\277\275", 4); /* UTF_INVALID */ |
2779 | width = 1; | 2779 | width = 1; |
2780 | } | 2780 | } |
2781 | 2781 | ||
2782 | if(IS_SET(MODE_PRINT)) | 2782 | if (IS_SET(MODE_PRINT)) |
2783 | tprinter(c, len); | 2783 | tprinter(c, len); |
2784 | control = ISCONTROL(u); | 2784 | control = ISCONTROL(u); |
2785 | 2785 | ||
@@ -2789,12 +2789,12 @@ tputc(Rune u) | |||
2789 | * receives a ESC, a SUB, a ST or any other C1 control | 2789 | * receives a ESC, a SUB, a ST or any other C1 control |
2790 | * character. | 2790 | * character. |
2791 | */ | 2791 | */ |
2792 | if(term.esc & ESC_STR) { | 2792 | if (term.esc & ESC_STR) { |
2793 | if(u == '\a' || u == 030 || u == 032 || u == 033 || | 2793 | if (u == '\a' || u == 030 || u == 032 || u == 033 || |
2794 | ISCONTROLC1(u)) { | 2794 | ISCONTROLC1(u)) { |
2795 | term.esc &= ~(ESC_START|ESC_STR); | 2795 | term.esc &= ~(ESC_START|ESC_STR); |
2796 | term.esc |= ESC_STR_END; | 2796 | term.esc |= ESC_STR_END; |
2797 | } else if(strescseq.len + len < sizeof(strescseq.buf) - 1) { | 2797 | } else if (strescseq.len + len < sizeof(strescseq.buf) - 1) { |
2798 | memmove(&strescseq.buf[strescseq.len], c, len); | 2798 | memmove(&strescseq.buf[strescseq.len], c, len); |
2799 | strescseq.len += len; | 2799 | strescseq.len += len; |
2800 | return; | 2800 | return; |
@@ -2821,16 +2821,16 @@ tputc(Rune u) | |||
2821 | * because they can be embedded inside a control sequence, and | 2821 | * because they can be embedded inside a control sequence, and |
2822 | * they must not cause conflicts with sequences. | 2822 | * they must not cause conflicts with sequences. |
2823 | */ | 2823 | */ |
2824 | if(control) { | 2824 | if (control) { |
2825 | tcontrolcode(u); | 2825 | tcontrolcode(u); |
2826 | /* | 2826 | /* |
2827 | * control codes are not shown ever | 2827 | * control codes are not shown ever |
2828 | */ | 2828 | */ |
2829 | return; | 2829 | return; |
2830 | } else if(term.esc & ESC_START) { | 2830 | } else if (term.esc & ESC_START) { |
2831 | if(term.esc & ESC_CSI) { | 2831 | if (term.esc & ESC_CSI) { |
2832 | csiescseq.buf[csiescseq.len++] = u; | 2832 | csiescseq.buf[csiescseq.len++] = u; |
2833 | if(BETWEEN(u, 0x40, 0x7E) | 2833 | if (BETWEEN(u, 0x40, 0x7E) |
2834 | || csiescseq.len >= \ | 2834 | || csiescseq.len >= \ |
2835 | sizeof(csiescseq.buf)-1) { | 2835 | sizeof(csiescseq.buf)-1) { |
2836 | term.esc = 0; | 2836 | term.esc = 0; |
@@ -2838,9 +2838,9 @@ tputc(Rune u) | |||
2838 | csihandle(); | 2838 | csihandle(); |
2839 | } | 2839 | } |
2840 | return; | 2840 | return; |
2841 | } else if(term.esc & ESC_ALTCHARSET) { | 2841 | } else if (term.esc & ESC_ALTCHARSET) { |
2842 | tdeftran(u); | 2842 | tdeftran(u); |
2843 | } else if(term.esc & ESC_TEST) { | 2843 | } else if (term.esc & ESC_TEST) { |
2844 | tdectest(u); | 2844 | tdectest(u); |
2845 | } else { | 2845 | } else { |
2846 | if (!eschandle(u)) | 2846 | if (!eschandle(u)) |
@@ -2854,34 +2854,34 @@ tputc(Rune u) | |||
2854 | */ | 2854 | */ |
2855 | return; | 2855 | return; |
2856 | } | 2856 | } |
2857 | if(sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y)) | 2857 | if (sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y)) |
2858 | selclear(NULL); | 2858 | selclear(NULL); |
2859 | 2859 | ||
2860 | gp = &term.line[term.c.y][term.c.x]; | 2860 | gp = &term.line[term.c.y][term.c.x]; |
2861 | if(IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) { | 2861 | if (IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) { |
2862 | gp->mode |= ATTR_WRAP; | 2862 | gp->mode |= ATTR_WRAP; |
2863 | tnewline(1); | 2863 | tnewline(1); |
2864 | gp = &term.line[term.c.y][term.c.x]; | 2864 | gp = &term.line[term.c.y][term.c.x]; |
2865 | } | 2865 | } |
2866 | 2866 | ||
2867 | if(IS_SET(MODE_INSERT) && term.c.x+width < term.col) | 2867 | if (IS_SET(MODE_INSERT) && term.c.x+width < term.col) |
2868 | memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph)); | 2868 | memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph)); |
2869 | 2869 | ||
2870 | if(term.c.x+width > term.col) { | 2870 | if (term.c.x+width > term.col) { |
2871 | tnewline(1); | 2871 | tnewline(1); |
2872 | gp = &term.line[term.c.y][term.c.x]; | 2872 | gp = &term.line[term.c.y][term.c.x]; |
2873 | } | 2873 | } |
2874 | 2874 | ||
2875 | tsetchar(u, &term.c.attr, term.c.x, term.c.y); | 2875 | tsetchar(u, &term.c.attr, term.c.x, term.c.y); |
2876 | 2876 | ||
2877 | if(width == 2) { | 2877 | if (width == 2) { |
2878 | gp->mode |= ATTR_WIDE; | 2878 | gp->mode |= ATTR_WIDE; |
2879 | if(term.c.x+1 < term.col) { | 2879 | if (term.c.x+1 < term.col) { |
2880 | gp[1].u = '\0'; | 2880 | gp[1].u = '\0'; |
2881 | gp[1].mode = ATTR_WDUMMY; | 2881 | gp[1].mode = ATTR_WDUMMY; |
2882 | } | 2882 | } |
2883 | } | 2883 | } |
2884 | if(term.c.x+width < term.col) { | 2884 | if (term.c.x+width < term.col) { |
2885 | tmoveto(term.c.x+width, term.c.y); | 2885 | tmoveto(term.c.x+width, term.c.y); |
2886 | } else { | 2886 | } else { |
2887 | term.c.state |= CURSOR_WRAPNEXT; | 2887 | term.c.state |= CURSOR_WRAPNEXT; |
@@ -2897,7 +2897,7 @@ tresize(int col, int row) | |||
2897 | int *bp; | 2897 | int *bp; |
2898 | TCursor c; | 2898 | TCursor c; |
2899 | 2899 | ||
2900 | if(col < 1 || row < 1) { | 2900 | if (col < 1 || row < 1) { |
2901 | fprintf(stderr, | 2901 | fprintf(stderr, |
2902 | "tresize: error resizing to %dx%d\n", col, row); | 2902 | "tresize: error resizing to %dx%d\n", col, row); |
2903 | return; | 2903 | return; |
@@ -2908,7 +2908,7 @@ tresize(int col, int row) | |||
2908 | * tscrollup would work here, but we can optimize to | 2908 | * tscrollup would work here, but we can optimize to |
2909 | * memmove because we're freeing the earlier lines | 2909 | * memmove because we're freeing the earlier lines |
2910 | */ | 2910 | */ |
2911 | for(i = 0; i <= term.c.y - row; i++) { | 2911 | for (i = 0; i <= term.c.y - row; i++) { |
2912 | free(term.line[i]); | 2912 | free(term.line[i]); |
2913 | free(term.alt[i]); | 2913 | free(term.alt[i]); |
2914 | } | 2914 | } |
@@ -2917,7 +2917,7 @@ tresize(int col, int row) | |||
2917 | memmove(term.line, term.line + i, row * sizeof(Line)); | 2917 | memmove(term.line, term.line + i, row * sizeof(Line)); |
2918 | memmove(term.alt, term.alt + i, row * sizeof(Line)); | 2918 | memmove(term.alt, term.alt + i, row * sizeof(Line)); |
2919 | } | 2919 | } |
2920 | for(i += row; i < term.row; i++) { | 2920 | for (i += row; i < term.row; i++) { |
2921 | free(term.line[i]); | 2921 | free(term.line[i]); |
2922 | free(term.alt[i]); | 2922 | free(term.alt[i]); |
2923 | } | 2923 | } |
@@ -2932,23 +2932,23 @@ tresize(int col, int row) | |||
2932 | term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs)); | 2932 | term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs)); |
2933 | 2933 | ||
2934 | /* resize each row to new width, zero-pad if needed */ | 2934 | /* resize each row to new width, zero-pad if needed */ |
2935 | for(i = 0; i < minrow; i++) { | 2935 | for (i = 0; i < minrow; i++) { |
2936 | term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph)); | 2936 | term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph)); |
2937 | term.alt[i] = xrealloc(term.alt[i], col * sizeof(Glyph)); | 2937 | term.alt[i] = xrealloc(term.alt[i], col * sizeof(Glyph)); |
2938 | } | 2938 | } |
2939 | 2939 | ||
2940 | /* allocate any new rows */ | 2940 | /* allocate any new rows */ |
2941 | for(/* i == minrow */; i < row; i++) { | 2941 | for (/* i == minrow */; i < row; i++) { |
2942 | term.line[i] = xmalloc(col * sizeof(Glyph)); | 2942 | term.line[i] = xmalloc(col * sizeof(Glyph)); |
2943 | term.alt[i] = xmalloc(col * sizeof(Glyph)); | 2943 | term.alt[i] = xmalloc(col * sizeof(Glyph)); |
2944 | } | 2944 | } |
2945 | if(col > term.col) { | 2945 | if (col > term.col) { |
2946 | bp = term.tabs + term.col; | 2946 | bp = term.tabs + term.col; |
2947 | 2947 | ||
2948 | memset(bp, 0, sizeof(*term.tabs) * (col - term.col)); | 2948 | memset(bp, 0, sizeof(*term.tabs) * (col - term.col)); |
2949 | while(--bp > term.tabs && !*bp) | 2949 | while (--bp > term.tabs && !*bp) |
2950 | /* nothing */ ; | 2950 | /* nothing */ ; |
2951 | for(bp += tabspaces; bp < term.tabs + col; bp += tabspaces) | 2951 | for (bp += tabspaces; bp < term.tabs + col; bp += tabspaces) |
2952 | *bp = 1; | 2952 | *bp = 1; |
2953 | } | 2953 | } |
2954 | /* update terminal size */ | 2954 | /* update terminal size */ |
@@ -2960,11 +2960,11 @@ tresize(int col, int row) | |||
2960 | tmoveto(term.c.x, term.c.y); | 2960 | tmoveto(term.c.x, term.c.y); |
2961 | /* Clearing both screens (it makes dirty all lines) */ | 2961 | /* Clearing both screens (it makes dirty all lines) */ |
2962 | c = term.c; | 2962 | c = term.c; |
2963 | for(i = 0; i < 2; i++) { | 2963 | for (i = 0; i < 2; i++) { |
2964 | if(mincol < col && 0 < minrow) { | 2964 | if (mincol < col && 0 < minrow) { |
2965 | tclearregion(mincol, 0, col - 1, minrow - 1); | 2965 | tclearregion(mincol, 0, col - 1, minrow - 1); |
2966 | } | 2966 | } |
2967 | if(0 < col && minrow < row) { | 2967 | if (0 < col && minrow < row) { |
2968 | tclearregion(0, minrow, col - 1, row - 1); | 2968 | tclearregion(0, minrow, col - 1, row - 1); |
2969 | } | 2969 | } |
2970 | tswapscreen(); | 2970 | tswapscreen(); |
@@ -2997,9 +2997,9 @@ xloadcolor(int i, const char *name, Color *ncolor) | |||
2997 | { | 2997 | { |
2998 | XRenderColor color = { .alpha = 0xffff }; | 2998 | XRenderColor color = { .alpha = 0xffff }; |
2999 | 2999 | ||
3000 | if(!name) { | 3000 | if (!name) { |
3001 | if(BETWEEN(i, 16, 255)) { /* 256 color */ | 3001 | if (BETWEEN(i, 16, 255)) { /* 256 color */ |
3002 | if(i < 6*6*6+16) { /* same colors as xterm */ | 3002 | if (i < 6*6*6+16) { /* same colors as xterm */ |
3003 | color.red = sixd_to_16bit( ((i-16)/36)%6 ); | 3003 | color.red = sixd_to_16bit( ((i-16)/36)%6 ); |
3004 | color.green = sixd_to_16bit( ((i-16)/6) %6 ); | 3004 | color.green = sixd_to_16bit( ((i-16)/6) %6 ); |
3005 | color.blue = sixd_to_16bit( ((i-16)/1) %6 ); | 3005 | color.blue = sixd_to_16bit( ((i-16)/1) %6 ); |
@@ -3022,14 +3022,14 @@ xloadcols(void) | |||
3022 | static int loaded; | 3022 | static int loaded; |
3023 | Color *cp; | 3023 | Color *cp; |
3024 | 3024 | ||
3025 | if(loaded) { | 3025 | if (loaded) { |
3026 | for (cp = dc.col; cp < &dc.col[LEN(dc.col)]; ++cp) | 3026 | for (cp = dc.col; cp < &dc.col[LEN(dc.col)]; ++cp) |
3027 | XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); | 3027 | XftColorFree(xw.dpy, xw.vis, xw.cmap, cp); |
3028 | } | 3028 | } |
3029 | 3029 | ||
3030 | for(i = 0; i < LEN(dc.col); i++) | 3030 | for (i = 0; i < LEN(dc.col); i++) |
3031 | if(!xloadcolor(i, NULL, &dc.col[i])) { | 3031 | if (!xloadcolor(i, NULL, &dc.col[i])) { |
3032 | if(colorname[i]) | 3032 | if (colorname[i]) |
3033 | die("Could not allocate color '%s'\n", colorname[i]); | 3033 | die("Could not allocate color '%s'\n", colorname[i]); |
3034 | else | 3034 | else |
3035 | die("Could not allocate color %d\n", i); | 3035 | die("Could not allocate color %d\n", i); |
@@ -3042,11 +3042,11 @@ xsetcolorname(int x, const char *name) | |||
3042 | { | 3042 | { |
3043 | Color ncolor; | 3043 | Color ncolor; |
3044 | 3044 | ||
3045 | if(!BETWEEN(x, 0, LEN(dc.col))) | 3045 | if (!BETWEEN(x, 0, LEN(dc.col))) |
3046 | return 1; | 3046 | return 1; |
3047 | 3047 | ||
3048 | 3048 | ||
3049 | if(!xloadcolor(x, name, &ncolor)) | 3049 | if (!xloadcolor(x, name, &ncolor)) |
3050 | return 1; | 3050 | return 1; |
3051 | 3051 | ||
3052 | XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]); | 3052 | XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]); |
@@ -3092,12 +3092,12 @@ xhints(void) | |||
3092 | sizeh->width_inc = xw.cw; | 3092 | sizeh->width_inc = xw.cw; |
3093 | sizeh->base_height = 2 * borderpx; | 3093 | sizeh->base_height = 2 * borderpx; |
3094 | sizeh->base_width = 2 * borderpx; | 3094 | sizeh->base_width = 2 * borderpx; |
3095 | if(xw.isfixed) { | 3095 | if (xw.isfixed) { |
3096 | sizeh->flags |= PMaxSize | PMinSize; | 3096 | sizeh->flags |= PMaxSize | PMinSize; |
3097 | sizeh->min_width = sizeh->max_width = xw.w; | 3097 | sizeh->min_width = sizeh->max_width = xw.w; |
3098 | sizeh->min_height = sizeh->max_height = xw.h; | 3098 | sizeh->min_height = sizeh->max_height = xw.h; |
3099 | } | 3099 | } |
3100 | if(xw.gm & (XValue|YValue)) { | 3100 | if (xw.gm & (XValue|YValue)) { |
3101 | sizeh->flags |= USPosition | PWinGravity; | 3101 | sizeh->flags |= USPosition | PWinGravity; |
3102 | sizeh->x = xw.l; | 3102 | sizeh->x = xw.l; |
3103 | sizeh->y = xw.t; | 3103 | sizeh->y = xw.t; |
@@ -3112,7 +3112,7 @@ xhints(void) | |||
3112 | int | 3112 | int |
3113 | xgeommasktogravity(int mask) | 3113 | xgeommasktogravity(int mask) |
3114 | { | 3114 | { |
3115 | switch(mask & (XNegative|YNegative)) { | 3115 | switch (mask & (XNegative|YNegative)) { |
3116 | case 0: | 3116 | case 0: |
3117 | return NorthWestGravity; | 3117 | return NorthWestGravity; |
3118 | case XNegative: | 3118 | case XNegative: |
@@ -3130,10 +3130,10 @@ xloadfont(Font *f, FcPattern *pattern) | |||
3130 | FcResult result; | 3130 | FcResult result; |
3131 | 3131 | ||
3132 | match = FcFontMatch(NULL, pattern, &result); | 3132 | match = FcFontMatch(NULL, pattern, &result); |
3133 | if(!match) | 3133 | if (!match) |
3134 | return 1; | 3134 | return 1; |
3135 | 3135 | ||
3136 | if(!(f->match = XftFontOpenPattern(xw.dpy, match))) { | 3136 | if (!(f->match = XftFontOpenPattern(xw.dpy, match))) { |
3137 | FcPatternDestroy(match); | 3137 | FcPatternDestroy(match); |
3138 | return 1; | 3138 | return 1; |
3139 | } | 3139 | } |
@@ -3159,25 +3159,25 @@ xloadfonts(char *fontstr, double fontsize) | |||
3159 | double fontval; | 3159 | double fontval; |
3160 | float ceilf(float); | 3160 | float ceilf(float); |
3161 | 3161 | ||
3162 | if(fontstr[0] == '-') { | 3162 | if (fontstr[0] == '-') { |
3163 | pattern = XftXlfdParse(fontstr, False, False); | 3163 | pattern = XftXlfdParse(fontstr, False, False); |
3164 | } else { | 3164 | } else { |
3165 | pattern = FcNameParse((FcChar8 *)fontstr); | 3165 | pattern = FcNameParse((FcChar8 *)fontstr); |
3166 | } | 3166 | } |
3167 | 3167 | ||
3168 | if(!pattern) | 3168 | if (!pattern) |
3169 | die("st: can't open font %s\n", fontstr); | 3169 | die("st: can't open font %s\n", fontstr); |
3170 | 3170 | ||
3171 | if(fontsize > 1) { | 3171 | if (fontsize > 1) { |
3172 | FcPatternDel(pattern, FC_PIXEL_SIZE); | 3172 | FcPatternDel(pattern, FC_PIXEL_SIZE); |
3173 | FcPatternDel(pattern, FC_SIZE); | 3173 | FcPatternDel(pattern, FC_SIZE); |
3174 | FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize); | 3174 | FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize); |
3175 | usedfontsize = fontsize; | 3175 | usedfontsize = fontsize; |
3176 | } else { | 3176 | } else { |
3177 | if(FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) == | 3177 | if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) == |
3178 | FcResultMatch) { | 3178 | FcResultMatch) { |
3179 | usedfontsize = fontval; | 3179 | usedfontsize = fontval; |
3180 | } else if(FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval) == | 3180 | } else if (FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval) == |
3181 | FcResultMatch) { | 3181 | FcResultMatch) { |
3182 | usedfontsize = -1; | 3182 | usedfontsize = -1; |
3183 | } else { | 3183 | } else { |
@@ -3194,14 +3194,14 @@ xloadfonts(char *fontstr, double fontsize) | |||
3194 | FcConfigSubstitute(0, pattern, FcMatchPattern); | 3194 | FcConfigSubstitute(0, pattern, FcMatchPattern); |
3195 | FcDefaultSubstitute(pattern); | 3195 | FcDefaultSubstitute(pattern); |
3196 | 3196 | ||
3197 | if(xloadfont(&dc.font, pattern)) | 3197 | if (xloadfont(&dc.font, pattern)) |
3198 | die("st: can't open font %s\n", fontstr); | 3198 | die("st: can't open font %s\n", fontstr); |
3199 | 3199 | ||
3200 | if(usedfontsize < 0) { | 3200 | if (usedfontsize < 0) { |
3201 | FcPatternGetDouble(dc.font.match->pattern, | 3201 | FcPatternGetDouble(dc.font.match->pattern, |
3202 | FC_PIXEL_SIZE, 0, &fontval); | 3202 | FC_PIXEL_SIZE, 0, &fontval); |
3203 | usedfontsize = fontval; | 3203 | usedfontsize = fontval; |
3204 | if(fontsize == 0) | 3204 | if (fontsize == 0) |
3205 | defaultfontsize = fontval; | 3205 | defaultfontsize = fontval; |
3206 | } | 3206 | } |
3207 | 3207 | ||
@@ -3211,17 +3211,17 @@ xloadfonts(char *fontstr, double fontsize) | |||
3211 | 3211 | ||
3212 | FcPatternDel(pattern, FC_SLANT); | 3212 | FcPatternDel(pattern, FC_SLANT); |
3213 | FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); | 3213 | FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC); |
3214 | if(xloadfont(&dc.ifont, pattern)) | 3214 | if (xloadfont(&dc.ifont, pattern)) |
3215 | die("st: can't open font %s\n", fontstr); | 3215 | die("st: can't open font %s\n", fontstr); |
3216 | 3216 | ||
3217 | FcPatternDel(pattern, FC_WEIGHT); | 3217 | FcPatternDel(pattern, FC_WEIGHT); |
3218 | FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD); | 3218 | FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD); |
3219 | if(xloadfont(&dc.ibfont, pattern)) | 3219 | if (xloadfont(&dc.ibfont, pattern)) |
3220 | die("st: can't open font %s\n", fontstr); | 3220 | die("st: can't open font %s\n", fontstr); |
3221 | 3221 | ||
3222 | FcPatternDel(pattern, FC_SLANT); | 3222 | FcPatternDel(pattern, FC_SLANT); |
3223 | FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); | 3223 | FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN); |
3224 | if(xloadfont(&dc.bfont, pattern)) | 3224 | if (xloadfont(&dc.bfont, pattern)) |
3225 | die("st: can't open font %s\n", fontstr); | 3225 | die("st: can't open font %s\n", fontstr); |
3226 | 3226 | ||
3227 | FcPatternDestroy(pattern); | 3227 | FcPatternDestroy(pattern); |
@@ -3232,7 +3232,7 @@ xunloadfont(Font *f) | |||
3232 | { | 3232 | { |
3233 | XftFontClose(xw.dpy, f->match); | 3233 | XftFontClose(xw.dpy, f->match); |
3234 | FcPatternDestroy(f->pattern); | 3234 | FcPatternDestroy(f->pattern); |
3235 | if(f->set) | 3235 | if (f->set) |
3236 | FcFontSetDestroy(f->set); | 3236 | FcFontSetDestroy(f->set); |
3237 | } | 3237 | } |
3238 | 3238 | ||
@@ -3240,7 +3240,7 @@ void | |||
3240 | xunloadfonts(void) | 3240 | xunloadfonts(void) |
3241 | { | 3241 | { |
3242 | /* Free the loaded fonts in the font cache. */ | 3242 | /* Free the loaded fonts in the font cache. */ |
3243 | while(frclen > 0) | 3243 | while (frclen > 0) |
3244 | XftFontClose(xw.dpy, frc[--frclen].font); | 3244 | XftFontClose(xw.dpy, frc[--frclen].font); |
3245 | 3245 | ||
3246 | xunloadfont(&dc.font); | 3246 | xunloadfont(&dc.font); |
@@ -3273,7 +3273,7 @@ xzoomreset(const Arg *arg) | |||
3273 | { | 3273 | { |
3274 | Arg larg; | 3274 | Arg larg; |
3275 | 3275 | ||
3276 | if(defaultfontsize > 0) { | 3276 | if (defaultfontsize > 0) { |
3277 | larg.f = defaultfontsize; | 3277 | larg.f = defaultfontsize; |
3278 | xzoomabs(&larg); | 3278 | xzoomabs(&larg); |
3279 | } | 3279 | } |
@@ -3287,13 +3287,13 @@ xinit(void) | |||
3287 | Window parent; | 3287 | Window parent; |
3288 | pid_t thispid = getpid(); | 3288 | pid_t thispid = getpid(); |
3289 | 3289 | ||
3290 | if(!(xw.dpy = XOpenDisplay(NULL))) | 3290 | if (!(xw.dpy = XOpenDisplay(NULL))) |
3291 | die("Can't open display\n"); | 3291 | die("Can't open display\n"); |
3292 | xw.scr = XDefaultScreen(xw.dpy); | 3292 | xw.scr = XDefaultScreen(xw.dpy); |
3293 | xw.vis = XDefaultVisual(xw.dpy, xw.scr); | 3293 | xw.vis = XDefaultVisual(xw.dpy, xw.scr); |
3294 | 3294 | ||
3295 | /* font */ | 3295 | /* font */ |
3296 | if(!FcInit()) | 3296 | if (!FcInit()) |
3297 | die("Could not init fontconfig.\n"); | 3297 | die("Could not init fontconfig.\n"); |
3298 | 3298 | ||
3299 | usedfont = (opt_font == NULL)? font : opt_font; | 3299 | usedfont = (opt_font == NULL)? font : opt_font; |
@@ -3306,9 +3306,9 @@ xinit(void) | |||
3306 | /* adjust fixed window geometry */ | 3306 | /* adjust fixed window geometry */ |
3307 | xw.w = 2 * borderpx + term.col * xw.cw; | 3307 | xw.w = 2 * borderpx + term.col * xw.cw; |
3308 | xw.h = 2 * borderpx + term.row * xw.ch; | 3308 | xw.h = 2 * borderpx + term.row * xw.ch; |
3309 | if(xw.gm & XNegative) | 3309 | if (xw.gm & XNegative) |
3310 | xw.l += DisplayWidth(xw.dpy, xw.scr) - xw.w - 2; | 3310 | xw.l += DisplayWidth(xw.dpy, xw.scr) - xw.w - 2; |
3311 | if(xw.gm & YNegative) | 3311 | if (xw.gm & YNegative) |
3312 | xw.t += DisplayWidth(xw.dpy, xw.scr) - xw.h - 2; | 3312 | xw.t += DisplayWidth(xw.dpy, xw.scr) - xw.h - 2; |
3313 | 3313 | ||
3314 | /* Events */ | 3314 | /* Events */ |
@@ -3340,11 +3340,11 @@ xinit(void) | |||
3340 | xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); | 3340 | xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap); |
3341 | 3341 | ||
3342 | /* input methods */ | 3342 | /* input methods */ |
3343 | if((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { | 3343 | if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { |
3344 | XSetLocaleModifiers("@im=local"); | 3344 | XSetLocaleModifiers("@im=local"); |
3345 | if((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { | 3345 | if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) { |
3346 | XSetLocaleModifiers("@im="); | 3346 | XSetLocaleModifiers("@im="); |
3347 | if((xw.xim = XOpenIM(xw.dpy, | 3347 | if ((xw.xim = XOpenIM(xw.dpy, |
3348 | NULL, NULL, NULL)) == NULL) { | 3348 | NULL, NULL, NULL)) == NULL) { |
3349 | die("XOpenIM failed. Could not open input" | 3349 | die("XOpenIM failed. Could not open input" |
3350 | " device.\n"); | 3350 | " device.\n"); |
@@ -3354,7 +3354,7 @@ xinit(void) | |||
3354 | xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing | 3354 | xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing |
3355 | | XIMStatusNothing, XNClientWindow, xw.win, | 3355 | | XIMStatusNothing, XNClientWindow, xw.win, |
3356 | XNFocusWindow, xw.win, NULL); | 3356 | XNFocusWindow, xw.win, NULL); |
3357 | if(xw.xic == NULL) | 3357 | if (xw.xic == NULL) |
3358 | die("XCreateIC failed. Could not obtain input method.\n"); | 3358 | die("XCreateIC failed. Could not obtain input method.\n"); |
3359 | 3359 | ||
3360 | /* white cursor, black outline */ | 3360 | /* white cursor, black outline */ |
@@ -3395,28 +3395,28 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x | |||
3395 | FcCharSet *fccharset; | 3395 | FcCharSet *fccharset; |
3396 | int i, f, numspecs = 0; | 3396 | int i, f, numspecs = 0; |
3397 | 3397 | ||
3398 | for(i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) { | 3398 | for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) { |
3399 | /* Fetch rune and mode for current glyph. */ | 3399 | /* Fetch rune and mode for current glyph. */ |
3400 | rune = glyphs[i].u; | 3400 | rune = glyphs[i].u; |
3401 | mode = glyphs[i].mode; | 3401 | mode = glyphs[i].mode; |
3402 | 3402 | ||
3403 | /* Skip dummy wide-character spacing. */ | 3403 | /* Skip dummy wide-character spacing. */ |
3404 | if(mode == ATTR_WDUMMY) | 3404 | if (mode == ATTR_WDUMMY) |
3405 | continue; | 3405 | continue; |
3406 | 3406 | ||
3407 | /* Determine font for glyph if different from previous glyph. */ | 3407 | /* Determine font for glyph if different from previous glyph. */ |
3408 | if(prevmode != mode) { | 3408 | if (prevmode != mode) { |
3409 | prevmode = mode; | 3409 | prevmode = mode; |
3410 | font = &dc.font; | 3410 | font = &dc.font; |
3411 | frcflags = FRC_NORMAL; | 3411 | frcflags = FRC_NORMAL; |
3412 | runewidth = xw.cw * ((mode & ATTR_WIDE) ? 2.0f : 1.0f); | 3412 | runewidth = xw.cw * ((mode & ATTR_WIDE) ? 2.0f : 1.0f); |
3413 | if((mode & ATTR_ITALIC) && (mode & ATTR_BOLD)) { | 3413 | if ((mode & ATTR_ITALIC) && (mode & ATTR_BOLD)) { |
3414 | font = &dc.ibfont; | 3414 | font = &dc.ibfont; |
3415 | frcflags = FRC_ITALICBOLD; | 3415 | frcflags = FRC_ITALICBOLD; |
3416 | } else if(mode & ATTR_ITALIC) { | 3416 | } else if (mode & ATTR_ITALIC) { |
3417 | font = &dc.ifont; | 3417 | font = &dc.ifont; |
3418 | frcflags = FRC_ITALIC; | 3418 | frcflags = FRC_ITALIC; |
3419 | } else if(mode & ATTR_BOLD) { | 3419 | } else if (mode & ATTR_BOLD) { |
3420 | font = &dc.bfont; | 3420 | font = &dc.bfont; |
3421 | frcflags = FRC_BOLD; | 3421 | frcflags = FRC_BOLD; |
3422 | } | 3422 | } |
@@ -3425,7 +3425,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x | |||
3425 | 3425 | ||
3426 | /* Lookup character index with default font. */ | 3426 | /* Lookup character index with default font. */ |
3427 | glyphidx = XftCharIndex(xw.dpy, font->match, rune); | 3427 | glyphidx = XftCharIndex(xw.dpy, font->match, rune); |
3428 | if(glyphidx) { | 3428 | if (glyphidx) { |
3429 | specs[numspecs].font = font->match; | 3429 | specs[numspecs].font = font->match; |
3430 | specs[numspecs].glyph = glyphidx; | 3430 | specs[numspecs].glyph = glyphidx; |
3431 | specs[numspecs].x = (short)xp; | 3431 | specs[numspecs].x = (short)xp; |
@@ -3436,21 +3436,21 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x | |||
3436 | } | 3436 | } |
3437 | 3437 | ||
3438 | /* Fallback on font cache, search the font cache for match. */ | 3438 | /* Fallback on font cache, search the font cache for match. */ |
3439 | for(f = 0; f < frclen; f++) { | 3439 | for (f = 0; f < frclen; f++) { |
3440 | glyphidx = XftCharIndex(xw.dpy, frc[f].font, rune); | 3440 | glyphidx = XftCharIndex(xw.dpy, frc[f].font, rune); |
3441 | /* Everything correct. */ | 3441 | /* Everything correct. */ |
3442 | if(glyphidx && frc[f].flags == frcflags) | 3442 | if (glyphidx && frc[f].flags == frcflags) |
3443 | break; | 3443 | break; |
3444 | /* We got a default font for a not found glyph. */ | 3444 | /* We got a default font for a not found glyph. */ |
3445 | if(!glyphidx && frc[f].flags == frcflags | 3445 | if (!glyphidx && frc[f].flags == frcflags |
3446 | && frc[f].unicodep == rune) { | 3446 | && frc[f].unicodep == rune) { |
3447 | break; | 3447 | break; |
3448 | } | 3448 | } |
3449 | } | 3449 | } |
3450 | 3450 | ||
3451 | /* Nothing was found. Use fontconfig to find matching font. */ | 3451 | /* Nothing was found. Use fontconfig to find matching font. */ |
3452 | if(f >= frclen) { | 3452 | if (f >= frclen) { |
3453 | if(!font->set) | 3453 | if (!font->set) |
3454 | font->set = FcFontSort(0, font->pattern, | 3454 | font->set = FcFontSort(0, font->pattern, |
3455 | 1, 0, &fcres); | 3455 | 1, 0, &fcres); |
3456 | fcsets[0] = font->set; | 3456 | fcsets[0] = font->set; |
@@ -3480,7 +3480,7 @@ xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x | |||
3480 | /* | 3480 | /* |
3481 | * Overwrite or create the new cache entry. | 3481 | * Overwrite or create the new cache entry. |
3482 | */ | 3482 | */ |
3483 | if(frclen >= LEN(frc)) { | 3483 | if (frclen >= LEN(frc)) { |
3484 | frclen = LEN(frc) - 1; | 3484 | frclen = LEN(frc) - 1; |
3485 | XftFontClose(xw.dpy, frc[frclen].font); | 3485 | XftFontClose(xw.dpy, frc[frclen].font); |
3486 | frc[frclen].unicodep = 0; | 3486 | frc[frclen].unicodep = 0; |
@@ -3522,16 +3522,16 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i | |||
3522 | XRectangle r; | 3522 | XRectangle r; |
3523 | 3523 | ||
3524 | /* Determine foreground and background colors based on mode. */ | 3524 | /* Determine foreground and background colors based on mode. */ |
3525 | if(base.fg == defaultfg) { | 3525 | if (base.fg == defaultfg) { |
3526 | if(base.mode & ATTR_ITALIC) | 3526 | if (base.mode & ATTR_ITALIC) |
3527 | base.fg = defaultitalic; | 3527 | base.fg = defaultitalic; |
3528 | else if((base.mode & ATTR_ITALIC) && (base.mode & ATTR_BOLD)) | 3528 | else if ((base.mode & ATTR_ITALIC) && (base.mode & ATTR_BOLD)) |
3529 | base.fg = defaultitalic; | 3529 | base.fg = defaultitalic; |
3530 | else if(base.mode & ATTR_UNDERLINE) | 3530 | else if (base.mode & ATTR_UNDERLINE) |
3531 | base.fg = defaultunderline; | 3531 | base.fg = defaultunderline; |
3532 | } | 3532 | } |
3533 | 3533 | ||
3534 | if(IS_TRUECOL(base.fg)) { | 3534 | if (IS_TRUECOL(base.fg)) { |
3535 | colfg.alpha = 0xffff; | 3535 | colfg.alpha = 0xffff; |
3536 | colfg.red = TRUERED(base.fg); | 3536 | colfg.red = TRUERED(base.fg); |
3537 | colfg.green = TRUEGREEN(base.fg); | 3537 | colfg.green = TRUEGREEN(base.fg); |
@@ -3542,7 +3542,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i | |||
3542 | fg = &dc.col[base.fg]; | 3542 | fg = &dc.col[base.fg]; |
3543 | } | 3543 | } |
3544 | 3544 | ||
3545 | if(IS_TRUECOL(base.bg)) { | 3545 | if (IS_TRUECOL(base.bg)) { |
3546 | colbg.alpha = 0xffff; | 3546 | colbg.alpha = 0xffff; |
3547 | colbg.green = TRUEGREEN(base.bg); | 3547 | colbg.green = TRUEGREEN(base.bg); |
3548 | colbg.red = TRUERED(base.bg); | 3548 | colbg.red = TRUERED(base.bg); |
@@ -3554,11 +3554,11 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i | |||
3554 | } | 3554 | } |
3555 | 3555 | ||
3556 | /* Change basic system colors [0-7] to bright system colors [8-15] */ | 3556 | /* Change basic system colors [0-7] to bright system colors [8-15] */ |
3557 | if((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7)) | 3557 | if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7)) |
3558 | fg = &dc.col[base.fg + 8]; | 3558 | fg = &dc.col[base.fg + 8]; |
3559 | 3559 | ||
3560 | if(IS_SET(MODE_REVERSE)) { | 3560 | if (IS_SET(MODE_REVERSE)) { |
3561 | if(fg == &dc.col[defaultfg]) { | 3561 | if (fg == &dc.col[defaultfg]) { |
3562 | fg = &dc.col[defaultbg]; | 3562 | fg = &dc.col[defaultbg]; |
3563 | } else { | 3563 | } else { |
3564 | colfg.red = ~fg->color.red; | 3564 | colfg.red = ~fg->color.red; |
@@ -3570,7 +3570,7 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i | |||
3570 | fg = &revfg; | 3570 | fg = &revfg; |
3571 | } | 3571 | } |
3572 | 3572 | ||
3573 | if(bg == &dc.col[defaultbg]) { | 3573 | if (bg == &dc.col[defaultbg]) { |
3574 | bg = &dc.col[defaultfg]; | 3574 | bg = &dc.col[defaultfg]; |
3575 | } else { | 3575 | } else { |
3576 | colbg.red = ~bg->color.red; | 3576 | colbg.red = ~bg->color.red; |
@@ -3583,13 +3583,13 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i | |||
3583 | } | 3583 | } |
3584 | } | 3584 | } |
3585 | 3585 | ||
3586 | if(base.mode & ATTR_REVERSE) { | 3586 | if (base.mode & ATTR_REVERSE) { |
3587 | temp = fg; | 3587 | temp = fg; |
3588 | fg = bg; | 3588 | fg = bg; |
3589 | bg = temp; | 3589 | bg = temp; |
3590 | } | 3590 | } |
3591 | 3591 | ||
3592 | if((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) { | 3592 | if ((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) { |
3593 | colfg.red = fg->color.red / 2; | 3593 | colfg.red = fg->color.red / 2; |
3594 | colfg.green = fg->color.green / 2; | 3594 | colfg.green = fg->color.green / 2; |
3595 | colfg.blue = fg->color.blue / 2; | 3595 | colfg.blue = fg->color.blue / 2; |
@@ -3597,24 +3597,24 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i | |||
3597 | fg = &revfg; | 3597 | fg = &revfg; |
3598 | } | 3598 | } |
3599 | 3599 | ||
3600 | if(base.mode & ATTR_BLINK && term.mode & MODE_BLINK) | 3600 | if (base.mode & ATTR_BLINK && term.mode & MODE_BLINK) |
3601 | fg = bg; | 3601 | fg = bg; |
3602 | 3602 | ||
3603 | if(base.mode & ATTR_INVISIBLE) | 3603 | if (base.mode & ATTR_INVISIBLE) |
3604 | fg = bg; | 3604 | fg = bg; |
3605 | 3605 | ||
3606 | /* Intelligent cleaning up of the borders. */ | 3606 | /* Intelligent cleaning up of the borders. */ |
3607 | if(x == 0) { | 3607 | if (x == 0) { |
3608 | xclear(0, (y == 0)? 0 : winy, borderpx, | 3608 | xclear(0, (y == 0)? 0 : winy, borderpx, |
3609 | winy + xw.ch + ((y >= term.row-1)? xw.h : 0)); | 3609 | winy + xw.ch + ((y >= term.row-1)? xw.h : 0)); |
3610 | } | 3610 | } |
3611 | if(x + charlen >= term.col) { | 3611 | if (x + charlen >= term.col) { |
3612 | xclear(winx + width, (y == 0)? 0 : winy, xw.w, | 3612 | xclear(winx + width, (y == 0)? 0 : winy, xw.w, |
3613 | ((y >= term.row-1)? xw.h : (winy + xw.ch))); | 3613 | ((y >= term.row-1)? xw.h : (winy + xw.ch))); |
3614 | } | 3614 | } |
3615 | if(y == 0) | 3615 | if (y == 0) |
3616 | xclear(winx, 0, winx + width, borderpx); | 3616 | xclear(winx, 0, winx + width, borderpx); |
3617 | if(y == term.row-1) | 3617 | if (y == term.row-1) |
3618 | xclear(winx, winy + xw.ch, winx + width, xw.h); | 3618 | xclear(winx, winy + xw.ch, winx + width, xw.h); |
3619 | 3619 | ||
3620 | /* Clean up the region we want to draw to. */ | 3620 | /* Clean up the region we want to draw to. */ |
@@ -3631,12 +3631,12 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i | |||
3631 | XftDrawGlyphFontSpec(xw.draw, fg, specs, len); | 3631 | XftDrawGlyphFontSpec(xw.draw, fg, specs, len); |
3632 | 3632 | ||
3633 | /* Render underline and strikethrough. */ | 3633 | /* Render underline and strikethrough. */ |
3634 | if(base.mode & ATTR_UNDERLINE) { | 3634 | if (base.mode & ATTR_UNDERLINE) { |
3635 | XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1, | 3635 | XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1, |
3636 | width, 1); | 3636 | width, 1); |
3637 | } | 3637 | } |
3638 | 3638 | ||
3639 | if(base.mode & ATTR_STRUCK) { | 3639 | if (base.mode & ATTR_STRUCK) { |
3640 | XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3, | 3640 | XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3, |
3641 | width, 1); | 3641 | width, 1); |
3642 | } | 3642 | } |
@@ -3667,9 +3667,9 @@ xdrawcursor(void) | |||
3667 | curx = term.c.x; | 3667 | curx = term.c.x; |
3668 | 3668 | ||
3669 | /* adjust position if in dummy */ | 3669 | /* adjust position if in dummy */ |
3670 | if(term.line[oldy][oldx].mode & ATTR_WDUMMY) | 3670 | if (term.line[oldy][oldx].mode & ATTR_WDUMMY) |
3671 | oldx--; | 3671 | oldx--; |
3672 | if(term.line[term.c.y][curx].mode & ATTR_WDUMMY) | 3672 | if (term.line[term.c.y][curx].mode & ATTR_WDUMMY) |
3673 | curx--; | 3673 | curx--; |
3674 | 3674 | ||
3675 | g.u = term.line[term.c.y][term.c.x].u; | 3675 | g.u = term.line[term.c.y][term.c.x].u; |
@@ -3677,16 +3677,16 @@ xdrawcursor(void) | |||
3677 | /* remove the old cursor */ | 3677 | /* remove the old cursor */ |
3678 | xdrawglyph(term.line[oldy][oldx], oldx, oldy); | 3678 | xdrawglyph(term.line[oldy][oldx], oldx, oldy); |
3679 | 3679 | ||
3680 | if(IS_SET(MODE_HIDE)) | 3680 | if (IS_SET(MODE_HIDE)) |
3681 | return; | 3681 | return; |
3682 | 3682 | ||
3683 | /* draw the new one */ | 3683 | /* draw the new one */ |
3684 | if(xw.state & WIN_FOCUSED) { | 3684 | if (xw.state & WIN_FOCUSED) { |
3685 | switch (xw.cursor) { | 3685 | switch (xw.cursor) { |
3686 | case 0: /* Blinking Block */ | 3686 | case 0: /* Blinking Block */ |
3687 | case 1: /* Blinking Block (Default) */ | 3687 | case 1: /* Blinking Block (Default) */ |
3688 | case 2: /* Steady Block */ | 3688 | case 2: /* Steady Block */ |
3689 | if(IS_SET(MODE_REVERSE)) { | 3689 | if (IS_SET(MODE_REVERSE)) { |
3690 | g.mode |= ATTR_REVERSE; | 3690 | g.mode |= ATTR_REVERSE; |
3691 | g.fg = defaultcs; | 3691 | g.fg = defaultcs; |
3692 | g.bg = defaultfg; | 3692 | g.bg = defaultfg; |
@@ -3776,11 +3776,11 @@ drawregion(int x1, int y1, int x2, int y2) | |||
3776 | XftGlyphFontSpec* specs; | 3776 | XftGlyphFontSpec* specs; |
3777 | int ena_sel = sel.ob.x != -1 && sel.alt == IS_SET(MODE_ALTSCREEN); | 3777 | int ena_sel = sel.ob.x != -1 && sel.alt == IS_SET(MODE_ALTSCREEN); |
3778 | 3778 | ||
3779 | if(!(xw.state & WIN_VISIBLE)) | 3779 | if (!(xw.state & WIN_VISIBLE)) |
3780 | return; | 3780 | return; |
3781 | 3781 | ||
3782 | for(y = y1; y < y2; y++) { | 3782 | for (y = y1; y < y2; y++) { |
3783 | if(!term.dirty[y]) | 3783 | if (!term.dirty[y]) |
3784 | continue; | 3784 | continue; |
3785 | 3785 | ||
3786 | xtermclear(0, y, term.col, y); | 3786 | xtermclear(0, y, term.col, y); |
@@ -3790,25 +3790,25 @@ drawregion(int x1, int y1, int x2, int y2) | |||
3790 | numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y); | 3790 | numspecs = xmakeglyphfontspecs(specs, &term.line[y][x1], x2 - x1, x1, y); |
3791 | 3791 | ||
3792 | i = ox = 0; | 3792 | i = ox = 0; |
3793 | for(x = x1; x < x2 && i < numspecs; x++) { | 3793 | for (x = x1; x < x2 && i < numspecs; x++) { |
3794 | new = term.line[y][x]; | 3794 | new = term.line[y][x]; |
3795 | if(new.mode == ATTR_WDUMMY) | 3795 | if (new.mode == ATTR_WDUMMY) |
3796 | continue; | 3796 | continue; |
3797 | if(ena_sel && selected(x, y)) | 3797 | if (ena_sel && selected(x, y)) |
3798 | new.mode ^= ATTR_REVERSE; | 3798 | new.mode ^= ATTR_REVERSE; |
3799 | if(i > 0 && ATTRCMP(base, new)) { | 3799 | if (i > 0 && ATTRCMP(base, new)) { |
3800 | xdrawglyphfontspecs(specs, base, i, ox, y); | 3800 | xdrawglyphfontspecs(specs, base, i, ox, y); |
3801 | specs += i; | 3801 | specs += i; |
3802 | numspecs -= i; | 3802 | numspecs -= i; |
3803 | i = 0; | 3803 | i = 0; |
3804 | } | 3804 | } |
3805 | if(i == 0) { | 3805 | if (i == 0) { |
3806 | ox = x; | 3806 | ox = x; |
3807 | base = new; | 3807 | base = new; |
3808 | } | 3808 | } |
3809 | i++; | 3809 | i++; |
3810 | } | 3810 | } |
3811 | if(i > 0) | 3811 | if (i > 0) |
3812 | xdrawglyphfontspecs(specs, base, i, ox, y); | 3812 | xdrawglyphfontspecs(specs, base, i, ox, y); |
3813 | } | 3813 | } |
3814 | xdrawcursor(); | 3814 | xdrawcursor(); |
@@ -3856,19 +3856,19 @@ focus(XEvent *ev) | |||
3856 | { | 3856 | { |
3857 | XFocusChangeEvent *e = &ev->xfocus; | 3857 | XFocusChangeEvent *e = &ev->xfocus; |
3858 | 3858 | ||
3859 | if(e->mode == NotifyGrab) | 3859 | if (e->mode == NotifyGrab) |
3860 | return; | 3860 | return; |
3861 | 3861 | ||
3862 | if(ev->type == FocusIn) { | 3862 | if (ev->type == FocusIn) { |
3863 | XSetICFocus(xw.xic); | 3863 | XSetICFocus(xw.xic); |
3864 | xw.state |= WIN_FOCUSED; | 3864 | xw.state |= WIN_FOCUSED; |
3865 | xseturgency(0); | 3865 | xseturgency(0); |
3866 | if(IS_SET(MODE_FOCUS)) | 3866 | if (IS_SET(MODE_FOCUS)) |
3867 | ttywrite("\033[I", 3); | 3867 | ttywrite("\033[I", 3); |
3868 | } else { | 3868 | } else { |
3869 | XUnsetICFocus(xw.xic); | 3869 | XUnsetICFocus(xw.xic); |
3870 | xw.state &= ~WIN_FOCUSED; | 3870 | xw.state &= ~WIN_FOCUSED; |
3871 | if(IS_SET(MODE_FOCUS)) | 3871 | if (IS_SET(MODE_FOCUS)) |
3872 | ttywrite("\033[O", 3); | 3872 | ttywrite("\033[O", 3); |
3873 | } | 3873 | } |
3874 | } | 3874 | } |
@@ -3892,31 +3892,31 @@ kmap(KeySym k, uint state) | |||
3892 | int i; | 3892 | int i; |
3893 | 3893 | ||
3894 | /* Check for mapped keys out of X11 function keys. */ | 3894 | /* Check for mapped keys out of X11 function keys. */ |
3895 | for(i = 0; i < LEN(mappedkeys); i++) { | 3895 | for (i = 0; i < LEN(mappedkeys); i++) { |
3896 | if(mappedkeys[i] == k) | 3896 | if (mappedkeys[i] == k) |
3897 | break; | 3897 | break; |
3898 | } | 3898 | } |
3899 | if(i == LEN(mappedkeys)) { | 3899 | if (i == LEN(mappedkeys)) { |
3900 | if((k & 0xFFFF) < 0xFD00) | 3900 | if ((k & 0xFFFF) < 0xFD00) |
3901 | return NULL; | 3901 | return NULL; |
3902 | } | 3902 | } |
3903 | 3903 | ||
3904 | for(kp = key; kp < key + LEN(key); kp++) { | 3904 | for (kp = key; kp < key + LEN(key); kp++) { |
3905 | if(kp->k != k) | 3905 | if (kp->k != k) |
3906 | continue; | 3906 | continue; |
3907 | 3907 | ||
3908 | if(!match(kp->mask, state)) | 3908 | if (!match(kp->mask, state)) |
3909 | continue; | 3909 | continue; |
3910 | 3910 | ||
3911 | if(IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0) | 3911 | if (IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0) |
3912 | continue; | 3912 | continue; |
3913 | if(term.numlock && kp->appkey == 2) | 3913 | if (term.numlock && kp->appkey == 2) |
3914 | continue; | 3914 | continue; |
3915 | 3915 | ||
3916 | if(IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0) | 3916 | if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0) |
3917 | continue; | 3917 | continue; |
3918 | 3918 | ||
3919 | if(IS_SET(MODE_CRLF) ? kp->crlf < 0 : kp->crlf > 0) | 3919 | if (IS_SET(MODE_CRLF) ? kp->crlf < 0 : kp->crlf > 0) |
3920 | continue; | 3920 | continue; |
3921 | 3921 | ||
3922 | return kp->s; | 3922 | return kp->s; |
@@ -3936,30 +3936,30 @@ kpress(XEvent *ev) | |||
3936 | Status status; | 3936 | Status status; |
3937 | Shortcut *bp; | 3937 | Shortcut *bp; |
3938 | 3938 | ||
3939 | if(IS_SET(MODE_KBDLOCK)) | 3939 | if (IS_SET(MODE_KBDLOCK)) |
3940 | return; | 3940 | return; |
3941 | 3941 | ||
3942 | len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status); | 3942 | len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status); |
3943 | /* 1. shortcuts */ | 3943 | /* 1. shortcuts */ |
3944 | for(bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { | 3944 | for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) { |
3945 | if(ksym == bp->keysym && match(bp->mod, e->state)) { | 3945 | if (ksym == bp->keysym && match(bp->mod, e->state)) { |
3946 | bp->func(&(bp->arg)); | 3946 | bp->func(&(bp->arg)); |
3947 | return; | 3947 | return; |
3948 | } | 3948 | } |
3949 | } | 3949 | } |
3950 | 3950 | ||
3951 | /* 2. custom keys from config.h */ | 3951 | /* 2. custom keys from config.h */ |
3952 | if((customkey = kmap(ksym, e->state))) { | 3952 | if ((customkey = kmap(ksym, e->state))) { |
3953 | ttysend(customkey, strlen(customkey)); | 3953 | ttysend(customkey, strlen(customkey)); |
3954 | return; | 3954 | return; |
3955 | } | 3955 | } |
3956 | 3956 | ||
3957 | /* 3. composed string from input method */ | 3957 | /* 3. composed string from input method */ |
3958 | if(len == 0) | 3958 | if (len == 0) |
3959 | return; | 3959 | return; |
3960 | if(len == 1 && e->state & Mod1Mask) { | 3960 | if (len == 1 && e->state & Mod1Mask) { |
3961 | if(IS_SET(MODE_8BIT)) { | 3961 | if (IS_SET(MODE_8BIT)) { |
3962 | if(*buf < 0177) { | 3962 | if (*buf < 0177) { |
3963 | c = *buf | 0x80; | 3963 | c = *buf | 0x80; |
3964 | len = utf8encode(c, buf); | 3964 | len = utf8encode(c, buf); |
3965 | } | 3965 | } |
@@ -3980,14 +3980,14 @@ cmessage(XEvent *e) | |||
3980 | * See xembed specs | 3980 | * See xembed specs |
3981 | * http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html | 3981 | * http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html |
3982 | */ | 3982 | */ |
3983 | if(e->xclient.message_type == xw.xembed && e->xclient.format == 32) { | 3983 | if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) { |
3984 | if(e->xclient.data.l[1] == XEMBED_FOCUS_IN) { | 3984 | if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) { |
3985 | xw.state |= WIN_FOCUSED; | 3985 | xw.state |= WIN_FOCUSED; |
3986 | xseturgency(0); | 3986 | xseturgency(0); |
3987 | } else if(e->xclient.data.l[1] == XEMBED_FOCUS_OUT) { | 3987 | } else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) { |
3988 | xw.state &= ~WIN_FOCUSED; | 3988 | xw.state &= ~WIN_FOCUSED; |
3989 | } | 3989 | } |
3990 | } else if(e->xclient.data.l[0] == xw.wmdeletewin) { | 3990 | } else if (e->xclient.data.l[0] == xw.wmdeletewin) { |
3991 | /* Send SIGHUP to shell */ | 3991 | /* Send SIGHUP to shell */ |
3992 | kill(pid, SIGHUP); | 3992 | kill(pid, SIGHUP); |
3993 | exit(0); | 3993 | exit(0); |
@@ -3999,9 +3999,9 @@ cresize(int width, int height) | |||
3999 | { | 3999 | { |
4000 | int col, row; | 4000 | int col, row; |
4001 | 4001 | ||
4002 | if(width != 0) | 4002 | if (width != 0) |
4003 | xw.w = width; | 4003 | xw.w = width; |
4004 | if(height != 0) | 4004 | if (height != 0) |
4005 | xw.h = height; | 4005 | xw.h = height; |
4006 | 4006 | ||
4007 | col = (xw.w - 2 * borderpx) / xw.cw; | 4007 | col = (xw.w - 2 * borderpx) / xw.cw; |
@@ -4015,7 +4015,7 @@ cresize(int width, int height) | |||
4015 | void | 4015 | void |
4016 | resize(XEvent *e) | 4016 | resize(XEvent *e) |
4017 | { | 4017 | { |
4018 | if(e->xconfigure.width == xw.w && e->xconfigure.height == xw.h) | 4018 | if (e->xconfigure.width == xw.w && e->xconfigure.height == xw.h) |
4019 | return; | 4019 | return; |
4020 | 4020 | ||
4021 | cresize(e->xconfigure.width, e->xconfigure.height); | 4021 | cresize(e->xconfigure.width, e->xconfigure.height); |
@@ -4039,13 +4039,13 @@ run(void) | |||
4039 | * this is not unnecessary.It does not only filter the key event, | 4039 | * this is not unnecessary.It does not only filter the key event, |
4040 | * but some clientmessage for input method as well. | 4040 | * but some clientmessage for input method as well. |
4041 | */ | 4041 | */ |
4042 | if(XFilterEvent(&ev, None)) | 4042 | if (XFilterEvent(&ev, None)) |
4043 | continue; | 4043 | continue; |
4044 | if(ev.type == ConfigureNotify) { | 4044 | if (ev.type == ConfigureNotify) { |
4045 | w = ev.xconfigure.width; | 4045 | w = ev.xconfigure.width; |
4046 | h = ev.xconfigure.height; | 4046 | h = ev.xconfigure.height; |
4047 | } | 4047 | } |
4048 | } while(ev.type != MapNotify); | 4048 | } while (ev.type != MapNotify); |
4049 | 4049 | ||
4050 | ttynew(); | 4050 | ttynew(); |
4051 | cresize(w, h); | 4051 | cresize(w, h); |
@@ -4053,26 +4053,26 @@ run(void) | |||
4053 | clock_gettime(CLOCK_MONOTONIC, &last); | 4053 | clock_gettime(CLOCK_MONOTONIC, &last); |
4054 | lastblink = last; | 4054 | lastblink = last; |
4055 | 4055 | ||
4056 | for(xev = actionfps;;) { | 4056 | for (xev = actionfps;;) { |
4057 | FD_ZERO(&rfd); | 4057 | FD_ZERO(&rfd); |
4058 | FD_SET(cmdfd, &rfd); | 4058 | FD_SET(cmdfd, &rfd); |
4059 | FD_SET(xfd, &rfd); | 4059 | FD_SET(xfd, &rfd); |
4060 | 4060 | ||
4061 | if(pselect(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, tv, NULL) < 0) { | 4061 | if (pselect(MAX(xfd, cmdfd)+1, &rfd, NULL, NULL, tv, NULL) < 0) { |
4062 | if(errno == EINTR) | 4062 | if (errno == EINTR) |
4063 | continue; | 4063 | continue; |
4064 | die("select failed: %s\n", strerror(errno)); | 4064 | die("select failed: %s\n", strerror(errno)); |
4065 | } | 4065 | } |
4066 | if(FD_ISSET(cmdfd, &rfd)) { | 4066 | if (FD_ISSET(cmdfd, &rfd)) { |
4067 | ttyread(); | 4067 | ttyread(); |
4068 | if(blinktimeout) { | 4068 | if (blinktimeout) { |
4069 | blinkset = tattrset(ATTR_BLINK); | 4069 | blinkset = tattrset(ATTR_BLINK); |
4070 | if(!blinkset) | 4070 | if (!blinkset) |
4071 | MODBIT(term.mode, 0, MODE_BLINK); | 4071 | MODBIT(term.mode, 0, MODE_BLINK); |
4072 | } | 4072 | } |
4073 | } | 4073 | } |
4074 | 4074 | ||
4075 | if(FD_ISSET(xfd, &rfd)) | 4075 | if (FD_ISSET(xfd, &rfd)) |
4076 | xev = actionfps; | 4076 | xev = actionfps; |
4077 | 4077 | ||
4078 | clock_gettime(CLOCK_MONOTONIC, &now); | 4078 | clock_gettime(CLOCK_MONOTONIC, &now); |
@@ -4081,35 +4081,35 @@ run(void) | |||
4081 | tv = &drawtimeout; | 4081 | tv = &drawtimeout; |
4082 | 4082 | ||
4083 | dodraw = 0; | 4083 | dodraw = 0; |
4084 | if(blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) { | 4084 | if (blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) { |
4085 | tsetdirtattr(ATTR_BLINK); | 4085 | tsetdirtattr(ATTR_BLINK); |
4086 | term.mode ^= MODE_BLINK; | 4086 | term.mode ^= MODE_BLINK; |
4087 | lastblink = now; | 4087 | lastblink = now; |
4088 | dodraw = 1; | 4088 | dodraw = 1; |
4089 | } | 4089 | } |
4090 | deltatime = TIMEDIFF(now, last); | 4090 | deltatime = TIMEDIFF(now, last); |
4091 | if(deltatime > 1000 / (xev ? xfps : actionfps)) { | 4091 | if (deltatime > 1000 / (xev ? xfps : actionfps)) { |
4092 | dodraw = 1; | 4092 | dodraw = 1; |
4093 | last = now; | 4093 | last = now; |
4094 | } | 4094 | } |
4095 | 4095 | ||
4096 | if(dodraw) { | 4096 | if (dodraw) { |
4097 | while(XPending(xw.dpy)) { | 4097 | while (XPending(xw.dpy)) { |
4098 | XNextEvent(xw.dpy, &ev); | 4098 | XNextEvent(xw.dpy, &ev); |
4099 | if(XFilterEvent(&ev, None)) | 4099 | if (XFilterEvent(&ev, None)) |
4100 | continue; | 4100 | continue; |
4101 | if(handler[ev.type]) | 4101 | if (handler[ev.type]) |
4102 | (handler[ev.type])(&ev); | 4102 | (handler[ev.type])(&ev); |
4103 | } | 4103 | } |
4104 | 4104 | ||
4105 | draw(); | 4105 | draw(); |
4106 | XFlush(xw.dpy); | 4106 | XFlush(xw.dpy); |
4107 | 4107 | ||
4108 | if(xev && !FD_ISSET(xfd, &rfd)) | 4108 | if (xev && !FD_ISSET(xfd, &rfd)) |
4109 | xev--; | 4109 | xev--; |
4110 | if(!FD_ISSET(cmdfd, &rfd) && !FD_ISSET(xfd, &rfd)) { | 4110 | if (!FD_ISSET(cmdfd, &rfd) && !FD_ISSET(xfd, &rfd)) { |
4111 | if(blinkset) { | 4111 | if (blinkset) { |
4112 | if(TIMEDIFF(now, lastblink) \ | 4112 | if (TIMEDIFF(now, lastblink) \ |
4113 | > blinktimeout) { | 4113 | > blinktimeout) { |
4114 | drawtimeout.tv_nsec = 1000; | 4114 | drawtimeout.tv_nsec = 1000; |
4115 | } else { | 4115 | } else { |
@@ -4157,7 +4157,7 @@ main(int argc, char *argv[]) | |||
4157 | opt_class = EARGF(usage()); | 4157 | opt_class = EARGF(usage()); |
4158 | break; | 4158 | break; |
4159 | case 'e': | 4159 | case 'e': |
4160 | if(argc > 0) | 4160 | if (argc > 0) |
4161 | --argc, ++argv; | 4161 | --argc, ++argv; |
4162 | goto run; | 4162 | goto run; |
4163 | case 'f': | 4163 | case 'f': |
@@ -4188,10 +4188,10 @@ main(int argc, char *argv[]) | |||
4188 | } ARGEND; | 4188 | } ARGEND; |
4189 | 4189 | ||
4190 | run: | 4190 | run: |
4191 | if(argc > 0) { | 4191 | if (argc > 0) { |
4192 | /* eat all remaining arguments */ | 4192 | /* eat all remaining arguments */ |
4193 | opt_cmd = argv; | 4193 | opt_cmd = argv; |
4194 | if(!opt_title && !opt_line) | 4194 | if (!opt_title && !opt_line) |
4195 | opt_title = basename(xstrdup(argv[0])); | 4195 | opt_title = basename(xstrdup(argv[0])); |
4196 | } | 4196 | } |
4197 | setlocale(LC_CTYPE, ""); | 4197 | setlocale(LC_CTYPE, ""); |