From 90cf048b8e5b2bfc0e3fcb31cdadffa1723c7203 Mon Sep 17 00:00:00 2001 From: Mark Edgar Date: Sat, 5 Oct 2013 11:49:35 +0200 Subject: [PATCH 3/3] New ttysend() function calls ttywrite() and techo(). Honor MODE_ECHO when pasting in selnotify(). --- st.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/st.c b/st.c index 39be94c..0ff9db3 100644 --- a/st.c +++ b/st.c @@ -371,6 +371,7 @@ static inline bool match(uint, uint); static void ttynew(void); static void ttyread(void); static void ttyresize(void); +static void ttysend(char *, size_t); static void ttywrite(const char *, size_t); static void xdraws(char *, Glyph, int, int, int, int); @@ -878,9 +879,7 @@ bpress(XEvent *e) { for(mk = mshortcuts; mk < mshortcuts + LEN(mshortcuts); mk++) { if(e->xbutton.button == mk->b && match(mk->mask, e->xbutton.state)) { - ttywrite(mk->s, strlen(mk->s)); - if(IS_SET(MODE_ECHO)) - techo(mk->s, strlen(mk->s)); + ttysend(mk->s, strlen(mk->s)); return; } } @@ -1016,7 +1015,7 @@ selnotify(XEvent *e) { if(IS_SET(MODE_BRCKTPASTE)) ttywrite("\033[200~", 6); - ttywrite((const char *)data, nitems * format / 8); + ttysend((char *)data, nitems * format / 8); if(IS_SET(MODE_BRCKTPASTE)) ttywrite("\033[201~", 6); XFree(data); @@ -1285,6 +1284,13 @@ ttywrite(const char *s, size_t n) { } void +ttysend(char *s, size_t n) { + ttywrite(s, n); + if(IS_SET(MODE_ECHO)) + techo(s, n); +} + +void ttyresize(void) { struct winsize w; @@ -3556,10 +3562,7 @@ kpress(XEvent *ev) { /* 2. custom keys from config.h */ if((customkey = kmap(ksym, e->state))) { - len = strlen(customkey); - ttywrite(customkey, len); - if(IS_SET(MODE_ECHO)) - techo(customkey, len); + ttysend(customkey, strlen(customkey)); return; } @@ -3578,9 +3581,7 @@ kpress(XEvent *ev) { len = 2; } } - ttywrite(buf, len); - if(IS_SET(MODE_ECHO)) - techo(buf, len); + ttysend(buf, len); } -- 1.8.4