Page 1 of 1
line break
Posted: Wed Feb 19, 2003 11:24 am
by Mastermind
I am writing a new kernel using C. Can anyone tell me how to insert line breaks? I have been using "\n" but it always showed up as wierd characters on the screen.
Oh yeah, I heard somewhere that you could use ANSI escape sequences... How do you type the escape character in WinXP??
Re:line break
Posted: Wed Feb 19, 2003 11:34 am
by Whatever5k
Everything is up to you...you have to define and write your printf() function which handles line breaks ('\n') and other functions...
printf()
Posted: Wed Feb 19, 2003 12:28 pm
by Mastermind
Sorry for being so dense... but how do you make your own printf()? I looked inside the stdio.h file but couldn't find anything useful...
Re:line break
Posted: Wed Feb 19, 2003 1:18 pm
by Tim
You're probably part-way there if you've got something to show up on screen. You should be keeping track of the row and column where the next character is to be outputted; when you see a '\n' in the string, set the row and column to point to the start of the next line.
Regarding escape sequences: again, they'll only be supported if you write code to handle them. You don't need to type the escape character (in fact, you can't); use the '\x1B' sequence.
Re:line break
Posted: Wed Feb 19, 2003 1:41 pm
by richie
Hello!
The best methode to see how escape sequences lokk like is to open your (compiled) kernel-file in a hex editor. There you can see how the compiler translated the escape sequences. Then you can write a print-function that takes care of these ascii-codes and threat them right (line-break, tab-stop, PC-Speaker-Beep, ...).
Start with a simple print-function that only can print strings. Later you can write a printf-function that although converts integers to string.
Re:line break
Posted: Wed Feb 19, 2003 9:14 pm
by Mastermind