Sign in to follow this  
xdc

linux ncurses

Recommended Posts

xdc    113
what is underneath ncurses?
what is the 'win32' eqivalent in linux?

i want to program at the OS level in linux

any help, thanks

Share this post


Link to post
Share on other sites
frob    44911
>> what is underneath ncurses?
What is underneath is a rather complex library that handles hundreds of different raw terminal types.

>>what is the 'win32' eqivalent in linux?
The Unix world is fundamentally different from the Windows world. The Unix world revolves around networking, connections, terminals, and connectivity sessions. The Windows world generally revolves around a single graphical desktop per session.

There is [url="http://gnuwin32.sourceforge.net/packages/ncurses.htm"]ncurses for Windows[/url] if you are interested in providing the same text-based experience on the platform.

>> i want to program at the OS level in linux
The OS level -- the operating system level -- is the level for operating the hardware systems. Sure, you can do it. The kernel source and nearly every major driver source is available to you. What hardware do you want to operate? Or did you mean something else with that?

Share this post


Link to post
Share on other sites
xdc    113
so the kernel has console fuctions like, setconsolecursorposition, etc?

i dont want to learn any libraries,wraps,etc, i want to be able to develop them.
I was originially learning win32, but it isnt open source

Share this post


Link to post
Share on other sites
frob    44911
No, the Linux kernel does not have quite that kind of functionality.

Think more in terms of escape codes across serial connections and writing directly to video memory.

The kernel talks to hardware. It provides an abstraction so programmers don't need to know about every video card's memory layout or every TTY's escape codes, they can simply have a virtual terminal with a cursor position and text color and such.

If you are really interested in it, the source isn't too hard to find. Go to kernel.org and download the source tree.

Share this post


Link to post
Share on other sites
SiCrane    11839
There is a level somewhat between curses and the kernel which is occupied by [url=http://en.wikipedia.org/wiki/Termcap]termcap[/url] and [url=http://en.wikipedia.org/wiki/Terminfo]terminfo[/url] if you want to implement your own curses like library without drilling all the way down to the kernel.

Share this post


Link to post
Share on other sites
Katie    2244
Please don't do this. You're about to get sucked into a disaster of tears and pain.

"i want to program at the OS level in linux"

No you don't. Really, really, really, you don't. The only people who do this are people who are working on the OS. Everyone else uses the abstraction layers so they don't go insane and they do actually get some work done.

ncurses is good enough for people who implement shells, terminal media players, rogue-likes, interactive fiction games, tetris clones and a hundred others. It means their software runs reliably on thousands of configurations. It has had decades of development and debugging work by hundreds if not thousands of people.

Why would you give up all that? Because you imagine a performance gain? Painting a 1000 character display? Every screen refresh perhaps? On modern machines which are quite capable of repainting million-pixel displays at 50 or 60hz?

Why is this place so full of people who want to spend their time re-implementing these sorts of layers? Is it really just misguided masochism? Why do people want to faff about doing things like this instead of writing actual games?

Share this post


Link to post
Share on other sites
BitMaster    8651
[quote name='Katie' timestamp='1351961350' post='4996897']
Why is this place so full of people who want to spend their time re-implementing these sorts of layers? Is it really just misguided masochism? Why do people want to faff about doing things like this instead of writing actual games?
[/quote]

I don't think it's masochism. It's a combination of being new (to programming) and being young. Quite a few of the people starting like that will get shell-shocked and give up programming. Others will learn when to pick their battles and not try to reinvent every wheel and tiny cock and gear in the future. Some will decide that they like the fiddly engineering bits more than the game programming and we get people to work with the fiddly engineering bits. It's win-win for everyone. Well, except for the people completely giving it up.

I think it's fair to give people warning what they are about to get into, but if they want to dive head-first into the water, I'm not going to stand in their way. I did so too when I was much younger. It makes you appreciate having a mature and well-tested library for a boring task that still needs to be done. Edited by BitMaster

Share this post


Link to post
Share on other sites
Bregma    9202
[quote name='hit' timestamp='1351922078' post='4996781']
so the kernel has console fuctions like, setconsolecursorposition, etc?
[/quote]
The kernel does not support concepts like consoles or cursor positions, at least not directly.

The way it works in a POSIX system like Linux is a display (whether it's a physical terminal connected over an RS-232C serial port or a virtual terminal rendered on a video card, what Windows parlance calls a 'console') is represented by a special file called a 'device,' and more particularly a 'character special device.' You open the device, read from it, write to it, close it, and sometimes perform out-of-band control functions on it (the [font=courier new,courier,monospace]ioctl()[/font] system call).

The specifics of which device you use and what control codes you send vary from target device to target device (and OS to OS, but assuming you're using a recent Linux kernel, you're probably targeting a /dev/tty* device).

There are libraries ([font=courier new,courier,monospace]man termcap[/font]) that help hide some of the device-specific peculiarities. You can also read the source of the built-in TTY driver in the kernel itself if you want to do fun things with the 'system console'. Read the manual on [font=courier new,courier,monospace]ioctl()[/font] for some addition hints, and hardware manuals for the various hardware or emulated hardware of a terminal window.

Share this post


Link to post
Share on other sites
alvaro    21246
Bregma's post above is probably the most relevant. I wanted to add that, if you don't want to use ncurses, you can get some of its functionality by using [url="http://en.wikipedia.org/wiki/ANSI_escape_code"]ANSI escape codes[/url].

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this