Lines 690-695
Link Here
|
690 |
|
690 |
|
691 |
#endif |
691 |
#endif |
692 |
|
692 |
|
|
|
693 |
static inline void term_send_event(struct terminal *term, struct event *ev) |
694 |
{ |
695 |
((struct window *)&term->windows)->next->handler(term->windows.next, ev, 0); |
696 |
} |
697 |
|
698 |
static inline void term_send_ucs(struct terminal *term, struct event *ev, int u) |
699 |
{ |
700 |
unsigned char *recoded; |
701 |
|
702 |
if (u == 0xA0) u = ' '; |
703 |
recoded = u2cp(u, term->spec->charset); |
704 |
if (! recoded) recoded = "*"; |
705 |
while (*recoded) { |
706 |
ev->x = *recoded; |
707 |
term_send_event(term, ev); |
708 |
recoded ++; |
709 |
} |
710 |
} |
711 |
|
693 |
void in_term(struct terminal *term) |
712 |
void in_term(struct terminal *term) |
694 |
{ |
713 |
{ |
695 |
struct event *ev; |
714 |
struct event *ev; |
Lines 749-755
Link Here
|
749 |
goto send_redraw; |
768 |
goto send_redraw; |
750 |
} |
769 |
} |
751 |
else if (ev->ev == EV_KBD && ev->x == KBD_CTRL_C) ((struct window *)&term->windows)->prev->handler(term->windows.prev, ev, 0); |
770 |
else if (ev->ev == EV_KBD && ev->x == KBD_CTRL_C) ((struct window *)&term->windows)->prev->handler(term->windows.prev, ev, 0); |
752 |
else ((struct window *)&term->windows)->next->handler(term->windows.next, ev, 0); |
771 |
else if (ev->ev == EV_KBD) { |
|
|
772 |
if (term->utf_8.len) { |
773 |
if ((ev->x & 0xC0) == 0x80 && term->spec->utf_8_io) { |
774 |
term->utf_8.ucs <<= 6; |
775 |
term->utf_8.ucs |= ev->x & 0x3F; |
776 |
if (! --term->utf_8.len) { |
777 |
int u = term->utf_8.ucs; |
778 |
|
779 |
if (u < term->utf_8.min) u = UCS_NO_CHAR; |
780 |
term_send_ucs(term, ev, u); |
781 |
} |
782 |
goto mm; |
783 |
} else { |
784 |
term->utf_8.len = 0; |
785 |
term_send_ucs(term, ev, UCS_NO_CHAR); |
786 |
} |
787 |
} |
788 |
if (ev->x < 0x80 || ev->x > 0xFF || ! term->spec->utf_8_io) { |
789 |
term_send_event(term, ev); |
790 |
goto mm; |
791 |
} else if ((ev->x & 0xC0) == 0xC0 && (ev->x & 0xFE) != 0xFE) { |
792 |
int mask, len = 0, cov = 0x80; |
793 |
|
794 |
for (mask = 0x80; ev->x & mask; mask >>= 1) { |
795 |
len++; |
796 |
term->utf_8.min = cov; |
797 |
cov = 1 << (1 + 5 * len); |
798 |
} |
799 |
term->utf_8.len = len - 1; |
800 |
term->utf_8.ucs = ev->x & (mask - 1); |
801 |
goto mm; |
802 |
} |
803 |
term_send_ucs(term, ev, UCS_NO_CHAR); |
804 |
} else term_send_event(term, ev); |
753 |
} |
805 |
} |
754 |
if (ev->ev == EV_ABORT) { |
806 |
if (ev->ev == EV_ABORT) { |
755 |
destroy_terminal(term); |
807 |
destroy_terminal(term); |
Lines 769-774
Link Here
|
769 |
|
821 |
|
770 |
unsigned char frame_dumb[48] = " ||||++||++++++--|-+||++--|-+----++++++++ "; |
822 |
unsigned char frame_dumb[48] = " ||||++||++++++--|-+||++--|-+----++++++++ "; |
771 |
unsigned char frame_vt100[48] = "aaaxuuukkuxkjjjkmvwtqnttmlvwtqnvvwwmmllnnjla "; |
823 |
unsigned char frame_vt100[48] = "aaaxuuukkuxkjjjkmvwtqnttmlvwtqnvvwwmmllnnjla "; |
|
|
824 |
unsigned char frame_vt100_u[48] = { |
825 |
177,177,177,179,180,180,180,191, |
826 |
191,180,179,191,217,217,217,191, |
827 |
192,193,194,195,196,197,195,195, |
828 |
192,218,193,194,195,196,197,193, |
829 |
193,194,194,192,192,218,218,197, |
830 |
197,217,218,177, 32, 32, 32, 32 |
831 |
}; |
772 |
unsigned char frame_koi[48] = { |
832 |
unsigned char frame_koi[48] = { |
773 |
144,145,146,129,135,178,180,167, |
833 |
144,145,146,129,135,178,180,167, |
774 |
166,181,161,168,174,173,172,131, |
834 |
166,181,161,168,174,173,172,131, |
Lines 800-806
Link Here
|
800 |
unsigned char c = ch & 0xff; \ |
860 |
unsigned char c = ch & 0xff; \ |
801 |
unsigned char A = ch >> 8 & 0x7f; \ |
861 |
unsigned char A = ch >> 8 & 0x7f; \ |
802 |
if (s->mode == TERM_LINUX) { \ |
862 |
if (s->mode == TERM_LINUX) { \ |
803 |
if (s->m11_hack) { \ |
863 |
if (s->m11_hack && !s->utf_8_io) { \ |
804 |
if ((int)(ch >> 15) != mode) { \ |
864 |
if ((int)(ch >> 15) != mode) { \ |
805 |
if (!(mode = ch >> 15)) add_to_str(&a, &l, "\033[10m"); \ |
865 |
if (!(mode = ch >> 15)) add_to_str(&a, &l, "\033[10m"); \ |
806 |
else add_to_str(&a, &l, "\033[11m"); \ |
866 |
else add_to_str(&a, &l, "\033[11m"); \ |
Lines 809-820
Link Here
|
809 |
if (s->restrict_852 && (ch >> 15) && c >= 176 && c < 224) { \ |
869 |
if (s->restrict_852 && (ch >> 15) && c >= 176 && c < 224) { \ |
810 |
if (frame_restrict[c - 176]) c = frame_restrict[c - 176]; \ |
870 |
if (frame_restrict[c - 176]) c = frame_restrict[c - 176]; \ |
811 |
} \ |
871 |
} \ |
812 |
} else if (s->mode == TERM_VT100) { \ |
872 |
} else if (s->mode == TERM_VT100 && !s->utf_8_io) { \ |
813 |
if ((int)(ch >> 15) != mode) { \ |
873 |
if ((int)(ch >> 15) != mode) { \ |
814 |
if (!(mode = ch >> 15)) add_to_str(&a, &l, "\x0f"); \ |
874 |
if (!(mode = ch >> 15)) add_to_str(&a, &l, "\x0f"); \ |
815 |
else add_to_str(&a, &l, "\x0e"); \ |
875 |
else add_to_str(&a, &l, "\x0e"); \ |
816 |
} \ |
876 |
} \ |
817 |
if (mode && c >= 176 && c < 224) c = frame_vt100[c - 176]; \ |
877 |
if (mode && c >= 176 && c < 224) c = frame_vt100[c - 176]; \ |
|
|
878 |
} else if (s->mode == TERM_VT100 && (ch >> 15) && c >= 176 && c < 224) { \ |
879 |
c = frame_vt100_u[c - 176]; \ |
818 |
} else if (s->mode == TERM_KOI8 && (ch >> 15) && c >= 176 && c < 224) { c = frame_koi[c - 176];\ |
880 |
} else if (s->mode == TERM_KOI8 && (ch >> 15) && c >= 176 && c < 224) { c = frame_koi[c - 176];\ |
819 |
} else if (s->mode == TERM_FREEBSD && (ch >> 15) && c >= 176 && c < 224) { c = frame_freebsd[c - 176];\ |
881 |
} else if (s->mode == TERM_FREEBSD && (ch >> 15) && c >= 176 && c < 224) { c = frame_freebsd[c - 176];\ |
820 |
} else if (s->mode == TERM_DUMB && (ch >> 15) && c >= 176 && c < 224) c = frame_dumb[c - 176];\ |
882 |
} else if (s->mode == TERM_DUMB && (ch >> 15) && c >= 176 && c < 224) c = frame_dumb[c - 176];\ |
Lines 835-841
Link Here
|
835 |
if (attrib & 0100) add_to_str(&a, &l, ";1"); \ |
897 |
if (attrib & 0100) add_to_str(&a, &l, ";1"); \ |
836 |
add_to_str(&a, &l, "m"); \ |
898 |
add_to_str(&a, &l, "m"); \ |
837 |
} \ |
899 |
} \ |
838 |
if (c >= ' ' && c != 127/* && c != 155*/) add_chr_to_str(&a, &l, c); \ |
900 |
if (c >= ' ' && c != 127/* && c != 155*/) { \ |
|
|
901 |
int charset = s->charset; \ |
902 |
\ |
903 |
if (ch >> 15) { \ |
904 |
int frames_charset = (s->mode == TERM_LINUX || s->mode == TERM_VT100) \ |
905 |
? get_cp_index("cp437") \ |
906 |
: s->mode == TERM_KOI8 \ |
907 |
? get_cp_index("koi8-r") \ |
908 |
: -1; \ |
909 |
if (frames_charset != -1) charset = frames_charset; \ |
910 |
} \ |
911 |
if (s->utf_8_io) add_to_str(&a, &l, cp2utf_8(charset, c)); \ |
912 |
else add_chr_to_str(&a, &l, c); \ |
913 |
} \ |
839 |
else if (!c || c == 1) add_chr_to_str(&a, &l, ' '); \ |
914 |
else if (!c || c == 1) add_chr_to_str(&a, &l, ' '); \ |
840 |
else add_chr_to_str(&a, &l, '.'); \ |
915 |
else add_chr_to_str(&a, &l, '.'); \ |
841 |
cx++; \ |
916 |
cx++; \ |