mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
24 lines
451 B
C
24 lines
451 B
C
#include <stdio.h>
|
|
|
|
// Reads until a newline
|
|
// TODO: Use Read() Syscall
|
|
void reads(char* buffer) {
|
|
char c;
|
|
int len = 0;
|
|
|
|
while ((c = getc()) != '\n') {
|
|
if (c == '\b') {
|
|
if (len < 1) continue; // Can we backspace?
|
|
len--;
|
|
putc(c);
|
|
} else {
|
|
buffer[len++] = c;
|
|
putc(c);
|
|
}
|
|
}
|
|
|
|
putc(c); // Print the newline
|
|
buffer[len] = '\0'; // Null terminate
|
|
}
|
|
|