diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-04 12:03:25 +0100 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-04 12:03:25 +0100 | 
| commit | b85a42da521dac79a7cf478168c2777ea7897070 (patch) | |
| tree | fc00045687d6cc7f805f9d9659acf04915aee3de | |
| parent | b3dde9661dd2d29b365d91c348e4d779bd295843 (diff) | |
| download | jeyzuos-b85a42da521dac79a7cf478168c2777ea7897070.zip jeyzuos-b85a42da521dac79a7cf478168c2777ea7897070.tar.gz  | |
tty: support '\n', fix API to putc and puts
| -rw-r--r-- | kernel/tty.c | 22 | ||||
| -rw-r--r-- | kernel/tty.h | 4 | 
2 files changed, 16 insertions, 10 deletions
diff --git a/kernel/tty.c b/kernel/tty.c index 4cb2cf1..628a21e 100644 --- a/kernel/tty.c +++ b/kernel/tty.c @@ -40,7 +40,7 @@ static inline uint16_t make_vgaentry(char c, uint8_t color)      return ((uint16_t) c) | (((uint16_t) color) << VGA_COLOR_SHIFT);  } -static inline void tty_putentryat(char c, uint8_t color, size_t x, size_t y) +static inline void tty_putc_at(char c, uint8_t color, size_t x, size_t y)  {      const size_t i = y * VGA_WIDTH + x;      tty_buffer[i] = make_vgaentry(c, color); @@ -51,21 +51,27 @@ void tty_setcolor(uint8_t color)      tty_color = color;  } -void tty_putchar(char c) +void tty_putc(char c)  { -    tty_putentryat(c, tty_color, tty_col, tty_row); -    if (++tty_col == VGA_WIDTH) { +    if (c == '\n') +    {          tty_col = 0; -        if (++tty_row == VGA_HEIGHT) { -            tty_row = 0; +        tty_row++; +    } else { +        tty_putc_at(c, tty_color, tty_col, tty_row); +        if (++tty_col == VGA_WIDTH) { +            tty_col = 0; +            if (++tty_row == VGA_HEIGHT) { +                tty_row = 0; +            }          }      }  } -void tty_writestring(const char* data) +void tty_puts(const char* data)  {      for (const char* p = data; *p != 0; p++) -        tty_putchar(*p); +        tty_putc(*p);  }  void tty_init() diff --git a/kernel/tty.h b/kernel/tty.h index 3c4b09e..27dfe23 100644 --- a/kernel/tty.h +++ b/kernel/tty.h @@ -7,8 +7,8 @@ void tty_init();  void tty_setcolor(uint8_t color); -void tty_putchar(char c); +void tty_putc(char c); -void tty_writestring(const char* data); +void tty_puts(const char* data);  #endif  | 
