fix snarf

This commit is contained in:
rsc 2005-11-07 01:51:11 +00:00
parent ac963cb3f5
commit 3fd51250be
3 changed files with 36 additions and 4 deletions

View file

@ -322,7 +322,7 @@ button2menu(Window *w)
break; break;
case Paste: case Paste:
//XXX getsnarf(); riogetsnarf();
wpaste(w); wpaste(w);
wscrdraw(w); wscrdraw(w);
break; break;
@ -332,7 +332,7 @@ button2menu(Window *w)
break; break;
case Send: case Send:
//XXX getsnarf(); riogetsnarf();
wsnarf(w); wsnarf(w);
if(nsnarf == 0) if(nsnarf == 0)
break; break;
@ -505,3 +505,31 @@ rcinputproc(void *arg)
} }
} }
void
rioputsnarf(void)
{
char *s;
s = smprint("%.*S", nsnarf, snarf);
if(s){
putsnarf(s);
free(s);
}
}
void
riogetsnarf(void)
{
char *s;
int n, nb, nulls;
fprint(2, "getsnarf\n");
s = getsnarf();
if(s == nil)
return;
n = strlen(s)+1;
free(snarf);
snarf = runemalloc(n);
cvttorunes(s, n, snarf, &nb, &nsnarf, &nulls);
free(s);
}

View file

@ -35,3 +35,7 @@ void winterrupt(Window*);
#define runemalloc(n) malloc((n)*sizeof(Rune)) #define runemalloc(n) malloc((n)*sizeof(Rune))
#define runerealloc(a, n) realloc(a, (n)*sizeof(Rune)) #define runerealloc(a, n) realloc(a, (n)*sizeof(Rune))
#define runemove(a, b, n) memmove(a, b, (n)*sizeof(Rune)) #define runemove(a, b, n) memmove(a, b, (n)*sizeof(Rune))
void rioputsnarf(void);
void riogetsnarf(void);

View file

@ -772,7 +772,7 @@ wsnarf(Window *w)
snarf = runerealloc(snarf, nsnarf); snarf = runerealloc(snarf, nsnarf);
snarfversion++; /* maybe modified by parent */ snarfversion++; /* maybe modified by parent */
runemove(snarf, w->r+w->q0, nsnarf); runemove(snarf, w->r+w->q0, nsnarf);
//XXX putsnarf(); rioputsnarf();
} }
void void
@ -1034,7 +1034,7 @@ wselect(Window *w)
}else{ }else{
if(first){ if(first){
first = 0; first = 0;
getsnarf(); riogetsnarf();
} }
wpaste(w); wpaste(w);
} }