8000 Fix new-line handling in terminal driver · havensjg/osdev-demos@f10d743 · GitHub
[go: up one dir, main page]

Skip to content

Commit f10d743

Browse files
committed
Fix new-line handling in terminal driver
1 parent 64b26a7 commit f10d743

File tree

8 files changed

+8
-56
lines changed

8 files changed

+8
-56
lines changed

02-printf/src/terminal.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ void terminal_putchar(char c)
7979
/* wrap to next line */
8080
if (++terminal_column == VGA_WIDTH) {
8181
terminal_column = 0;
82-
83-
/* wrap around to top */
84-
if (++terminal_row == VGA_HEIGHT)
85-
terminal_row = 0;
82+
terminal_row++;
8683
}
8784
}
8885

03-interrupts/src/terminal.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ void terminal_putchar(char c)
7979
/* wrap to next line */
8080
if (++terminal_column == VGA_WIDTH) {
8181
terminal_column = 0;
82-
83-
/* wrap around to top */
84-
if (++terminal_row == VGA_HEIGHT)
85-
terminal_row = 0;
82+
terminal_row++;
8683
}
8784
}
8885

04-pitmillis/src/terminal.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ void terminal_putchar(char c)
7979
/* wrap to next line */
8080
if (++terminal_column == VGA_WIDTH) {
8181
terminal_column = 0;
82-
83-
/* wrap around to top */
84-
if (++terminal_row == VGA_HEIGHT)
85-
terminal_row = 0;
82+
terminal_row++;
8683
}
8784
}
8885

05-keyboard/src/terminal.c

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,6 @@ size_t terminal_column;
1111
uint8_t terminal_color;
1212
uint16_t* terminal_buffer;
1313

14-
/* Erases a character from the screen and backs up the cursor*/
15-
void terminal_backspace(void) {
16-
/* at the beginning of a row? */
17-
if (terminal_column == 0) {
18-
/* at the top left? can't backspace anymore */
19-
if (terminal_row == 0) {
20-
return;
21-
} else {
22-
/* not on the first row */
23-
terminal_row--;
24-
terminal_column = VGA_WIDTH - 1;
25-
}
26-
} else {
27-
/* in the middle of a row */
28-
terminal_column--;
29-
}
30-
31-
/* erase the character */
32-
terminal_putentryat(' ', terminal_color, terminal_column, terminal_row);
33-
34-
/* move cursor to its new position */
35-
terminal_set_cursor(terminal_column, terminal_row);
36-
}
37-
3814
/* Initialize the terminal output */
3915
void terminal_initialize(void)
4016
{
@@ -103,10 +79,7 @@ void terminal_putchar(char c)
10379
/* wrap to next line */
10480
if (++terminal_column == VGA_WIDTH) {
10581
terminal_column = 0;
106-
107-
/* wrap around to top */
108-
if (++terminal_row == VGA_HEIGHT)
109-
terminal_row = 0;
82+
terminal_row++;
11083
}
11184
}
11285

06-cmos/src/terminal.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ void terminal_putchar(char c)
7979
/* wrap to next line */
8080
if (++terminal_column == VGA_WIDTH) {
8181
terminal_column = 0;
82-
83-
/* wrap around to top */
84-
if (++terminal_row == VGA_HEIGHT)
85-
terminal_row = 0;
82+
terminal_row++;
8683
}
8784
}
8885

07-multiboot/src/terminal.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ void terminal_putchar(char c)
7979
/* wrap to next line */
8080
if (++terminal_column == VGA_WIDTH) {
8181
terminal_column = 0;
82-
83-
/* wrap around to top */
84-
if (++terminal_row == VGA_HEIGHT)
85-
terminal_row = 0;
82+
terminal_row++;
8683
}
8784
}
8885

08-pagealloc/src/terminal.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ void terminal_putchar(char c)
7979
/* wrap to next line */
8080
if (++terminal_column == VGA_WIDTH) {
8181
terminal_column = 0;
82-
83-
/* wrap around to top */
84-
if (++terminal_row == VGA_HEIGHT)
85-
terminal_row = 0;
82+
terminal_row++;
8683
}
8784
}
8885

09-malloc/src/terminal.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ void terminal_putchar(char c)
7979
/* wrap to next line */
8080
if (++terminal_column == VGA_WIDTH) {
8181
terminal_column = 0;
82-
83-
/* wrap around to top */
84-
if (++terminal_row == VGA_HEIGHT)
85-
terminal_row = 0;
82+
terminal_row++;
8683
}
8784
}
8885

0 commit comments

Comments
 (0)
0