Joseph Pranevich | 791cd6a | 1998-12-02 19:58:08 +0000 | [diff] [blame] | 1 | /* tty.c */ |
Joseph Pranevich | ebc0e5e | 1999-02-14 11:15:47 +0000 | [diff] [blame] | 2 | /* Copyright 1999 - Joseph Pranevich */ |
Joseph Pranevich | 791cd6a | 1998-12-02 19:58:08 +0000 | [diff] [blame] | 3 | |
| 4 | /* This is the console driver for TTY-based consoles, i.e. consoles |
| 5 | without cursor placement, etc. It's also a pretty decent starting |
| 6 | point for other driers. |
| 7 | */ |
| 8 | |
| 9 | /* When creating new drivers, you need to assign all the functions that |
| 10 | that driver supports into the driver struct. If it is a supplementary |
| 11 | driver, it should make sure to perserve the old values. */ |
| 12 | |
| 13 | #include <stdio.h> |
| 14 | #include "console.h" |
| 15 | #include "config.h" |
Jim Aston | 2e1cafa | 1999-03-14 16:35:05 +0000 | [diff] [blame] | 16 | #include "windef.h" |
Joseph Pranevich | 791cd6a | 1998-12-02 19:58:08 +0000 | [diff] [blame] | 17 | void TTY_Start() |
| 18 | { |
| 19 | /* This should be the root driver so we can ignore anything |
| 20 | already in the struct. */ |
| 21 | |
| 22 | driver.norefresh = FALSE; |
| 23 | |
| 24 | driver.write = TTY_Write; |
| 25 | driver.getKeystroke = TTY_GetKeystroke; |
| 26 | } |
| 27 | |
| 28 | void TTY_Write(char output, int fg, int bg, int attribute) |
| 29 | { |
| 30 | /* We can discard all extended information. */ |
Joseph Pranevich | 5576838 | 1998-12-09 15:43:03 +0000 | [diff] [blame] | 31 | fprintf(driver.console_out, "%c", output); |
Joseph Pranevich | 791cd6a | 1998-12-02 19:58:08 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Ove Kaaven | 408b085 | 1999-01-31 09:22:58 +0000 | [diff] [blame] | 34 | void TTY_GetKeystroke(char *scan, char *ch) |
Joseph Pranevich | 791cd6a | 1998-12-02 19:58:08 +0000 | [diff] [blame] | 35 | { |
| 36 | /* All we have are character input things, nothing for extended */ |
| 37 | /* This is just the TTY driver, after all. We'll cope. */ |
Joseph Pranevich | 5576838 | 1998-12-09 15:43:03 +0000 | [diff] [blame] | 38 | *ch = fgetc(driver.console_in); |
Joseph Pranevich | 791cd6a | 1998-12-02 19:58:08 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | |