Compare commits

...

3 Commits

Author SHA1 Message Date
2cbe9c9492 support \r 2024-09-07 01:59:31 +02:00
a33a1c96fa support \n 2024-09-07 01:59:20 +02:00
792f8f1283 add: isprint 2024-09-07 01:56:52 +02:00
3 changed files with 15 additions and 0 deletions

View File

@ -9,7 +9,9 @@ int isdigit(int c);
/*
int isgraph(int c);
int islower(int c);
*/
int isprint(int c);
/*
int ispunct(int c);
int isspace(int c);
int isupper(int c);

4
src/ctype/isprint.c Normal file
View File

@ -0,0 +1,4 @@
int isprint(int c)
{
return (32 <= c && c < 127);
}

View File

@ -1,5 +1,6 @@
#include "terminal.h"
#include "string.h"
#include "ctype.h"
#include <stdbool.h>
#include <stddef.h>
@ -50,6 +51,14 @@ void terminal_putentryat(char c, uint8_t color, size_t x, size_t y)
int terminal_putchar(char c)
{
if (c == '\r')
terminal_row = 0;
else if (c == '\n') {
terminal_column = 0;
terminal_row++;
}
if (!isprint(c))
return 1;
terminal_putentryat(c, terminal_color, terminal_column, terminal_row);
if (++terminal_column == VGA_WIDTH) {
terminal_column = 0;