void clear_row( size_t row ) and void print_char(char character)
GrooverMD opened this issue · 0 comments
GrooverMD commented
VS Code would not accept this, but I thought I'll have a craic at it (Irish pun intended)
void clear_row(size_t row) {
struct Char empty = (struct Char) {
character: ' ', ; error here "character is undefined"
color: color,
};
for (size_t col = 0; col < NUM_COLS; col++) {
buffer[col + NUM_COLS * row] = empty;
}
}
as a Pascal programmer I used the following construct
void clear_row( size_t row )
{
struct Char empty = ( struct Char )
{
empty.character = ' ',
empty.color = color,
};
for ( size_t col = 0; col < NUM_COLS; col++ )
{
buffer[col + NUM_COLS * row] = empty;
}
}
and under print_char(char character)
void print_char(char character)
{
if (character == '\n') {
print_newline();
return;
}
if (col > NUM_COLS)
{
print_newline();
}
buffer[col + NUM_COLS * row] = (struct Char)
{
buffer[col + NUM_COLS * row].character = (uint8_t) character,
buffer[col + NUM_COLS * row].color = color,
};
col++;
}
not sure if this is right but it works.