mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
add ncinput_shovel for GPM #1405
This commit is contained in:
parent
e245fa0fb2
commit
1463049d32
@ -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){
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user