diff options
author | sotech117 <michael_foiani@brown.edu> | 2024-03-03 02:00:59 +0000 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2024-03-03 02:00:59 +0000 |
commit | e8970e39cac119369177e32723c75ea585a94587 (patch) | |
tree | ed9513f584a5fad4e982791c3cd02c145f749e54 /kernel/drivers/tty/ldisc.c | |
parent | 8c2e0ce946012a4275e8dfa9d8dfd1d5a68d6e3e (diff) |
get text output to be displayed
Diffstat (limited to 'kernel/drivers/tty/ldisc.c')
-rw-r--r-- | kernel/drivers/tty/ldisc.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/kernel/drivers/tty/ldisc.c b/kernel/drivers/tty/ldisc.c index dd67706..5651601 100644 --- a/kernel/drivers/tty/ldisc.c +++ b/kernel/drivers/tty/ldisc.c @@ -207,10 +207,11 @@ void ldisc_key_pressed(ldisc_t *ldisc, char c) vterminal_write(ldisc_to_tty(ldisc), "\n", 1); // add the new char to the buffer - ldisc->ldisc_buffer[ldisc->ldisc_tail] = c; - ldisc->ldisc_tail = (ldisc->ldisc_tail + 1) % LDISC_BUFFER_SIZE; - // set the buffer to full - ldisc->ldisc_full = 1; + // ldisc->ldisc_buffer[ldisc->ldisc_tail] = c; + ldisc->ldisc_head = (ldisc->ldisc_head + 1) % LDISC_BUFFER_SIZE; + + // cook the buffer + ldisc->ldisc_cooked = ldisc->ldisc_head; // wake up the thread that is sleeping on the wait queue of the line discipline sched_wakeup_on(&ldisc->ldisc_read_queue, 0); @@ -218,16 +219,14 @@ void ldisc_key_pressed(ldisc_t *ldisc, char c) case EOT: // add the new char to the buffer - ldisc->ldisc_buffer[ldisc->ldisc_tail] = c; - ldisc->ldisc_tail = (ldisc->ldisc_tail + 1) % LDISC_BUFFER_SIZE; - // set the buffer to full - ldisc->ldisc_full = 1; + ldisc->ldisc_buffer[ldisc->ldisc_head] = c; + ldisc->ldisc_head = (ldisc->ldisc_head + 1) % LDISC_BUFFER_SIZE; // cook the buffer - ldisc->ldisc_cooked = ldisc->ldisc_tail; + ldisc->ldisc_cooked = ldisc->ldisc_head; // wake up the thread that is sleeping on the wait queue of the line discipline - sched_wakeup_on(&ldisc->ldisc_read_queue, 0); + // sched_wakeup_on(&ldisc->ldisc_read_queue, 0); break; case ETX: @@ -237,7 +236,20 @@ void ldisc_key_pressed(ldisc_t *ldisc, char c) default: // if none applies, fallback to vterminal_key_pressed - vterminal_key_pressed(ldisc_to_tty(ldisc)); + // vterminal_write(ldisc_to_tty(ldisc), &c, 1); + ldisc->ldisc_buffer[ldisc->ldisc_head] = c; + + // update the buffer if it's full + if ((ldisc->ldisc_head + 1) % LDISC_BUFFER_SIZE == ldisc->ldisc_tail) + { + ldisc->ldisc_full = 1; + } + else + { + ldisc->ldisc_head = (ldisc->ldisc_head + 1) % LDISC_BUFFER_SIZE; + } + + vterminal_key_pressed(&ldisc_to_tty(ldisc)->tty_vterminal); break; } |