Add scrolling input buffer
This commit is contained in:
parent
9150f7ae6f
commit
34382d2a45
1 changed files with 21 additions and 2 deletions
23
src/ingest.c
23
src/ingest.c
|
|
@ -335,6 +335,7 @@ mode_normal(int ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
ingest.history_pos--;
|
ingest.history_pos--;
|
||||||
|
memset(ingest.inbuf, 0, sizeof(ingest.inbuf));
|
||||||
strcpy(ingest.inbuf, ingest.history[ingest.history_pos]);
|
strcpy(ingest.inbuf, ingest.history[ingest.history_pos]);
|
||||||
ingest.inlen = strlen(ingest.inbuf);
|
ingest.inlen = strlen(ingest.inbuf);
|
||||||
ingest.inpos = ingest.inlen;
|
ingest.inpos = ingest.inlen;
|
||||||
|
|
@ -346,11 +347,13 @@ mode_normal(int ch)
|
||||||
break;
|
break;
|
||||||
} else if (ingest.history_pos == ingest.history_len - 1) { /* load back temp storage */
|
} else if (ingest.history_pos == ingest.history_len - 1) { /* load back temp storage */
|
||||||
ingest.history_pos++;
|
ingest.history_pos++;
|
||||||
|
memset(ingest.inbuf, 0, sizeof(ingest.inbuf));
|
||||||
strcpy(ingest.inbuf, ingest.tmp_history);
|
strcpy(ingest.inbuf, ingest.tmp_history);
|
||||||
ingest.inlen = strlen(ingest.inbuf);
|
ingest.inlen = strlen(ingest.inbuf);
|
||||||
ingest.inpos = ingest.inlen;
|
ingest.inpos = ingest.inlen;
|
||||||
} else {
|
} else {
|
||||||
ingest.history_pos++;
|
ingest.history_pos++;
|
||||||
|
memset(ingest.inbuf, 0, sizeof(ingest.inbuf));
|
||||||
strcpy(ingest.inbuf, ingest.history[ingest.history_pos]);
|
strcpy(ingest.inbuf, ingest.history[ingest.history_pos]);
|
||||||
ingest.inlen = strlen(ingest.inbuf);
|
ingest.inlen = strlen(ingest.inbuf);
|
||||||
ingest.inpos = ingest.inlen;
|
ingest.inpos = ingest.inlen;
|
||||||
|
|
@ -599,6 +602,11 @@ static int
|
||||||
inbuf_load()
|
inbuf_load()
|
||||||
{
|
{
|
||||||
int cx, cy = -1;
|
int cx, cy = -1;
|
||||||
|
int win_len = getmaxx(ingest.input) + 1;
|
||||||
|
size_t prepend_len = ingest.prepend ? strlen(ingest.prepend) : 0;
|
||||||
|
int buffer_len = win_len - prepend_len;
|
||||||
|
int start = ingest.inlen > (win_len + prepend_len) ?
|
||||||
|
(ingest.inlen - win_len - prepend_len - 1) : 0;
|
||||||
|
|
||||||
pthread_mutex_lock(ingest.term_lock);
|
pthread_mutex_lock(ingest.term_lock);
|
||||||
|
|
||||||
|
|
@ -607,7 +615,18 @@ inbuf_load()
|
||||||
if (ingest.prepend)
|
if (ingest.prepend)
|
||||||
wprintw(ingest.input, "%s", ingest.prepend);
|
wprintw(ingest.input, "%s", ingest.prepend);
|
||||||
|
|
||||||
for (int i = 0; i < ingest.inlen; i++) {
|
if (start > 0) {
|
||||||
|
waddch(ingest.input, '$');
|
||||||
|
start++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start > ingest.inpos) {
|
||||||
|
start = ingest.inpos;
|
||||||
|
} else if ((start + buffer_len) < ingest.inpos) {
|
||||||
|
start = ingest.inpos - buffer_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = start; i < ingest.inlen; i++) {
|
||||||
if (i == ingest.inpos)
|
if (i == ingest.inpos)
|
||||||
getyx(ingest.input, cy, cx);
|
getyx(ingest.input, cy, cx);
|
||||||
waddch(ingest.input, ingest.inbuf[i]);
|
waddch(ingest.input, ingest.inbuf[i]);
|
||||||
|
|
@ -797,7 +816,7 @@ static void
|
||||||
update_cmd_pg_status()
|
update_cmd_pg_status()
|
||||||
{
|
{
|
||||||
if (ingest.cmd_pgs_n > 0) {
|
if (ingest.cmd_pgs_n > 0) {
|
||||||
bytenuts_set_status(STATUS_CMDPAGE, "pg.%d", ingest.cmd_pg_cur+1);
|
bytenuts_set_status(STATUS_CMDPAGE, "cmd pg.%d", ingest.cmd_pg_cur+1);
|
||||||
} else {
|
} else {
|
||||||
bytenuts_set_status(STATUS_CMDPAGE, "n/a");
|
bytenuts_set_status(STATUS_CMDPAGE, "n/a");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue