add ncinput_shovel for GPM #1405

This commit is contained in:
nick black 2021-09-01 19:40:51 -04:00
parent e245fa0fb2
commit 1463049d32
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 28 additions and 5 deletions

View File

@ -535,6 +535,29 @@ handle_queued_input(ncinputlayer* nc, ncinput* ni,
return ret;
}
int ncinput_shovel(ncinputlayer* ni, const unsigned char* buf, size_t len){
int ret = -1;
pthread_mutex_lock(&ni->lock);
size_t space = input_queue_space(ni);
if(len < space){
size_t spaceback = sizeof(ni->inputbuf) / sizeof(*ni->inputbuf) - ni->inputbuf_write_at;
memcpy(ni->inputbuf + ni->inputbuf_write_at, buf, spaceback);
len -= spaceback;
ni->inputbuf_write_at += spaceback;
if(len){
memcpy(ni->inputbuf, buf + spaceback, len);
ni->inputbuf_write_at = len;
}
ni->inputbuf_occupied += len + spaceback;
ret = 0;
}
pthread_mutex_unlock(&ni->lock);
if(ret < 0){
logwarn("dropped %lluB event\n", (long long unsigned)len);
}
return ret;
}
// this is the only function which actually reads, and it can be called from
// either our context (looking for cursor reports) or the user's. all it does
// is attempt to fill up the input ringbuffer, exiting either when that
@ -1788,6 +1811,7 @@ scan_for_clrs(ncinputlayer* ni){
void ncinput_extract_clrs(tinfo* ti){
ncinputlayer* ni = &ti->input;
do{
// FIXME doesn't this need locking?
if(ni->inputbuf_occupied){
scan_for_clrs(ni);
if(ni->creport_queue){

View File

@ -60,6 +60,8 @@ int cbreak_mode(struct tinfo* ti);
// appropriate. we can be interrupted by a new user context.
void ncinput_extract_clrs(struct tinfo* ti);
int ncinput_shovel(struct ncinputlayer* ni, const unsigned char* buf, size_t len);
#ifdef __cplusplus
}
#endif

View File

@ -1164,11 +1164,8 @@ rasterize_core(notcurses* nc, const ncpile* p, fbuf* f, unsigned phase){
}
rvec[damageidx].s.damaged = 0;
rvec[damageidx].s.p_beats_sprixel = 0;
++nc->rstate.x;
if(srccell->width >= 2){
x += srccell->width - 1;
nc->rstate.x += srccell->width - 1;
}
nc->rstate.x += srccell->width;
x += srccell->width - 1;
}
//fprintf(stderr, "damageidx: %ld\n", damageidx);
}