diff --git a/stlio.c b/stlio.c index f02b020..67f1c2e 100644 --- a/stlio.c +++ b/stlio.c @@ -50,6 +50,15 @@ static void __char_set(u8* dest, u8 desire) { *dest = desire; } + +static inline void __put_ch(const char c) { + if(c == '\n') { + frame_buffer_newline(); + } + else { + write_char(c); + } +} u32 read(char* buffer, u32 size) { // try the timing thing again after this u32 bytes = 0; @@ -64,12 +73,12 @@ u32 read(char* buffer, u32 size) { if(pit_timer_ticks - kbd_time < 0x20 && state == KBD_RELEASE) { __char_set(&(buffer[bytes]), (u8)kbd_key); if(kbd_key == '\n') { - putch('\n'); - return bytes; + __put_ch('\n'); + return ++bytes; } bytes++; __char_set(&kbd_state, KBD_WAITING); // reset the kbd_state since we've now used it - putch(kbd_key); + __put_ch(kbd_key); } pit_timer_wait(1); }