line break

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Mastermind

line break

Post 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??
Whatever5k

Re:line break

Post by Whatever5k »

Everything is up to you...you have to define and write your printf() function which handles line breaks ('\n') and other functions...
Mastermind

printf()

Post 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...
Tim

Re:line break

Post 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.
richie

Re:line break

Post 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.
Mastermind

Re:line break

Post by Mastermind »

:) :) Thanks Tim Robinson and Richie for the help! :) :)
Post Reply