ref: 6f76d0030034303e753e359c05a7d630bbb42aed
parent: 2aff96f17c4127617a48f75032c13e19cd3eb4a9
author: kvik <kvik@a-b.xyz>
date: Sun Oct 4 18:45:22 EDT 2020
rio: move the code for 'send' into a function Makes the code a bit nicer and allows reusing wsend() in patches.
--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -210,6 +210,7 @@
void wscrdraw(Window*);
void wscroll(Window*, int);
void wselect(Window*);
+void wsend(Window*);
void wsendctlmesg(Window*, int, Rectangle, void*);
void wsetcursor(Window*, int);
void wsetname(Window*);
--- a/sys/src/cmd/rio/rio.c
+++ b/sys/src/cmd/rio/rio.c
@@ -775,21 +775,7 @@
break;
case Send:
- getsnarf();
- wsnarf(w);
- if(nsnarf == 0)
- break;
- if(w->rawing){
- waddraw(w, snarf, nsnarf);
- if(snarf[nsnarf-1]!='\n' && snarf[nsnarf-1]!='\004')
- waddraw(w, L"\n", 1);
- }else{
- winsert(w, snarf, nsnarf, w->nr);
- if(snarf[nsnarf-1]!='\n' && snarf[nsnarf-1]!='\004')
- winsert(w, L"\n", 1, w->nr);
- }
- wsetselect(w, w->nr, w->nr);
- wshow(w, w->nr);
+ wsend(w);
break;
case Scroll:
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -1798,3 +1798,23 @@
{
return runetobyte(w->r, w->nr, ip);
}
+
+void
+wsend(Window *w)
+{
+ getsnarf();
+ wsnarf(w);
+ if(nsnarf == 0)
+ return;
+ if(w->rawing){
+ waddraw(w, snarf, nsnarf);
+ if(snarf[nsnarf-1]!='\n' && snarf[nsnarf-1]!='\004')
+ waddraw(w, L"\n", 1);
+ }else{
+ winsert(w, snarf, nsnarf, w->nr);
+ if(snarf[nsnarf-1]!='\n' && snarf[nsnarf-1]!='\004')
+ winsert(w, L"\n", 1, w->nr);
+ }
+ wsetselect(w, w->nr, w->nr);
+ wshow(w, w->nr);
+}