aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers/tty
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/tty')
-rw-r--r--kernel/drivers/tty/ldisc.c34
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;
}