rio: move the code for 'send' into a function
Makes the code a bit nicer and allows reusing wsend() in patches.
This commit is contained in:
parent
2aff96f17c
commit
6f76d00300
3 changed files with 22 additions and 15 deletions
|
@ -210,6 +210,7 @@ void wresize(Window*, Image*);
|
|||
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*);
|
||||
|
|
|
@ -775,21 +775,7 @@ button2menu(Window *w)
|
|||
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:
|
||||
|
|
|
@ -1798,3 +1798,23 @@ wcontents(Window *w, int *ip)
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue