diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2018-02-22 00:42:23 -0600 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2018-02-25 21:53:24 -0600 |
commit | 52d6fb1ab1f7d41839edebb63c3408578cd44e3c (patch) | |
tree | d33c81682f014f242b1c4d138ede71d90ca39b8e /st.c | |
parent | cfc7acdfd923924ae150a32061fb95987697b159 (diff) | |
download | st-52d6fb1ab1f7d41839edebb63c3408578cd44e3c.tar.gz st-52d6fb1ab1f7d41839edebb63c3408578cd44e3c.zip |
Move terminal echo logic into st.c
The only thing differentiating ttywrite and ttysend was the potential
for echo; make this a parameter and remove ttysend.
Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 23 |
1 files changed, 9 insertions, 14 deletions
@@ -784,12 +784,15 @@ ttyread(void) | |||
784 | } | 784 | } |
785 | 785 | ||
786 | void | 786 | void |
787 | ttywrite(const char *s, size_t n) | 787 | ttywrite(const char *s, size_t n, int may_echo) |
788 | { | 788 | { |
789 | fd_set wfd, rfd; | 789 | fd_set wfd, rfd; |
790 | ssize_t r; | 790 | ssize_t r; |
791 | size_t lim = 256; | 791 | size_t lim = 256; |
792 | 792 | ||
793 | if (may_echo && IS_SET(MODE_ECHO)) | ||
794 | twrite(s, n, 1); | ||
795 | |||
793 | /* | 796 | /* |
794 | * Remember that we are using a pty, which might be a modem line. | 797 | * Remember that we are using a pty, which might be a modem line. |
795 | * Writing too much will clog the line. That's why we are doing this | 798 | * Writing too much will clog the line. That's why we are doing this |
@@ -841,14 +844,6 @@ write_error: | |||
841 | } | 844 | } |
842 | 845 | ||
843 | void | 846 | void |
844 | ttysend(char *s, size_t n) | ||
845 | { | ||
846 | ttywrite(s, n); | ||
847 | if (IS_SET(MODE_ECHO)) | ||
848 | twrite(s, n, 1); | ||
849 | } | ||
850 | |||
851 | void | ||
852 | ttyresize(int tw, int th) | 847 | ttyresize(int tw, int th) |
853 | { | 848 | { |
854 | struct winsize w; | 849 | struct winsize w; |
@@ -1570,7 +1565,7 @@ csihandle(void) | |||
1570 | break; | 1565 | break; |
1571 | case 'c': /* DA -- Device Attributes */ | 1566 | case 'c': /* DA -- Device Attributes */ |
1572 | if (csiescseq.arg[0] == 0) | 1567 | if (csiescseq.arg[0] == 0) |
1573 | ttywrite(vtiden, strlen(vtiden)); | 1568 | ttywrite(vtiden, strlen(vtiden), 0); |
1574 | break; | 1569 | break; |
1575 | case 'C': /* CUF -- Cursor <n> Forward */ | 1570 | case 'C': /* CUF -- Cursor <n> Forward */ |
1576 | case 'a': /* HPR -- Cursor <n> Forward */ | 1571 | case 'a': /* HPR -- Cursor <n> Forward */ |
@@ -1698,7 +1693,7 @@ csihandle(void) | |||
1698 | if (csiescseq.arg[0] == 6) { | 1693 | if (csiescseq.arg[0] == 6) { |
1699 | len = snprintf(buf, sizeof(buf),"\033[%i;%iR", | 1694 | len = snprintf(buf, sizeof(buf),"\033[%i;%iR", |
1700 | term.c.y+1, term.c.x+1); | 1695 | term.c.y+1, term.c.x+1); |
1701 | ttywrite(buf, len); | 1696 | ttywrite(buf, len, 0); |
1702 | } | 1697 | } |
1703 | break; | 1698 | break; |
1704 | case 'r': /* DECSTBM -- Set Scrolling Region */ | 1699 | case 'r': /* DECSTBM -- Set Scrolling Region */ |
@@ -1916,7 +1911,7 @@ iso14755(const Arg *arg) | |||
1916 | (*e != '\n' && *e != '\0')) | 1911 | (*e != '\n' && *e != '\0')) |
1917 | return; | 1912 | return; |
1918 | 1913 | ||
1919 | ttysend(uc, utf8encode(utf32, uc)); | 1914 | ttywrite(uc, utf8encode(utf32, uc), 1); |
1920 | } | 1915 | } |
1921 | 1916 | ||
1922 | void | 1917 | void |
@@ -2129,7 +2124,7 @@ tcontrolcode(uchar ascii) | |||
2129 | case 0x99: /* TODO: SGCI */ | 2124 | case 0x99: /* TODO: SGCI */ |
2130 | break; | 2125 | break; |
2131 | case 0x9a: /* DECID -- Identify Terminal */ | 2126 | case 0x9a: /* DECID -- Identify Terminal */ |
2132 | ttywrite(vtiden, strlen(vtiden)); | 2127 | ttywrite(vtiden, strlen(vtiden), 0); |
2133 | break; | 2128 | break; |
2134 | case 0x9b: /* TODO: CSI */ | 2129 | case 0x9b: /* TODO: CSI */ |
2135 | case 0x9c: /* TODO: ST */ | 2130 | case 0x9c: /* TODO: ST */ |
@@ -2201,7 +2196,7 @@ eschandle(uchar ascii) | |||
2201 | } | 2196 | } |
2202 | break; | 2197 | break; |
2203 | case 'Z': /* DECID -- Identify Terminal */ | 2198 | case 'Z': /* DECID -- Identify Terminal */ |
2204 | ttywrite(vtiden, strlen(vtiden)); | 2199 | ttywrite(vtiden, strlen(vtiden), 0); |
2205 | break; | 2200 | break; |
2206 | case 'c': /* RIS -- Reset to inital state */ | 2201 | case 'c': /* RIS -- Reset to inital state */ |
2207 | treset(); | 2202 | treset(); |