stermp.h, trying to port conio.h to Linux

This time I want to rescue an old project. I started it long ago. These days I’ve been reading some source codes in facebook using conio.h so I hope this could be interesting for anyone.

Of course there are some libraries that allow us to to write strings in colors and get/set position on screen and keys without echoing and pressing Enter, or we can do it without them, using ANSI codes directly but we would have to do a lot of changes in the source code.

I tried to keep the name of the functions the same, we use:

clrscr() : To clean screen

textbackground(color) : To change background color

textcolor(color) : To change text color

gotoxy(x,y) : Go to specific position

wherex() : To get X position

wherey() : To get Y position

getch() : To get a key press without ENTER

getche() : Like getch but echoing character on screen

kbhit() : To know if a key has been pressed without stopping execution. Returns true or false

We can see I’m calling term_init() and term_defaults() but they are just to restore terminal after the execution ends.
You can download the source code on github. Just include stermp.h in your code and include stermp.h and stermp.c in your project.