Fixed issues with tabs and newlines in putchar()
This commit is contained in:
@@ -29,6 +29,7 @@ struct cell_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct cell_t *screen = (struct cell_t*)0xFF8B8000;
|
struct cell_t *screen = (struct cell_t*)0xFF8B8000;
|
||||||
|
size_t cursor = 0;
|
||||||
|
|
||||||
const size_t tab_width = 4;
|
const size_t tab_width = 4;
|
||||||
const size_t line_width = 80;
|
const size_t line_width = 80;
|
||||||
@@ -38,19 +39,20 @@ int putchar(int c)
|
|||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case '\n':
|
case '\n':
|
||||||
screen += line_width;
|
cursor += line_width;
|
||||||
screen -= (size_t) screen % line_width;
|
cursor -= cursor % line_width;
|
||||||
break;
|
break;
|
||||||
case '\t':
|
case '\t':
|
||||||
screen += (tab_width) & ~(tab_width);
|
cursor += tab_width;
|
||||||
|
cursor -= cursor % tab_width;
|
||||||
break;
|
break;
|
||||||
case '\r':
|
case '\r':
|
||||||
screen -= line_width - 1;
|
cursor -= line_width - 1;
|
||||||
screen += line_width - ((size_t) screen % line_width);
|
cursor += line_width - (cursor % line_width);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
screen->c = (char) c;
|
screen[cursor].c = (char) c;
|
||||||
screen++;
|
cursor++;
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -60,6 +62,7 @@ int puts(const char *str)
|
|||||||
while(*str)
|
while(*str)
|
||||||
{
|
{
|
||||||
putchar(*str);
|
putchar(*str);
|
||||||
|
str++;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user