Skip to content

Commit 19f68ec

Browse files
committed
Added some kind of formating
1 parent e996106 commit 19f68ec

File tree

9 files changed

+24
-3
lines changed

9 files changed

+24
-3
lines changed

OS.iso

0 Bytes
Binary file not shown.

build/OS.bin

301 Bytes
Binary file not shown.

build/full_kernel.bin

301 Bytes
Binary file not shown.

build/full_kernel.elf

-8 Bytes
Binary file not shown.

build/kernel.o

0 Bytes
Binary file not shown.

build/output.c.o

924 Bytes
Binary file not shown.

iso/floppy.img

0 Bytes
Binary file not shown.

kernel/kernel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern void main()
77

88
uint16_t offset = 0;
99

10-
offset = print("Hey! I like how its done, but I don't understand why it does not work sometimes. Finaly, I fixed it!",
10+
offset = print("Hey! I like how its done, but I don't understand why it does not work sometimes.\n\tFinaly, I fixed it!",
1111
(color_t){LIGHT_CYAN, BLUE},
1212
offset,
1313
tty_buffer);

kernel/lib/std/output.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,29 @@ uint16_t print(
1010
uint16_t index = 0;
1111
while (_s[index] != 0x00) // 0 byte is string terminator
1212
{
13-
_offset = print_char(_s[index], _c, _offset, _tty_buf);
14-
index++ ;
13+
switch (_s[index])
14+
{
15+
case '\n':
16+
_offset = set_cursor_position(
17+
(coords){0, _offset / VGA_WIDTH + 1});
18+
index++ ;
19+
break;
20+
case '\r':
21+
_offset = set_cursor_position(
22+
(coords){0, _offset / VGA_WIDTH});
23+
index++ ;
24+
break;
25+
case '\t':
26+
coords current_pos = get_cursor_position(_offset);
27+
current_pos.x -= current_pos.x % 4;
28+
current_pos.x += 4;
29+
_offset = set_cursor_position(current_pos);
30+
index++ ;
31+
break;
32+
default:
33+
_offset = print_char(_s[index], _c, _offset, _tty_buf);
34+
index++ ;
35+
};
1536
}
1637
return _offset;
1738
}

0 commit comments

Comments
 (0)