ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I came across the gtk tutorials and have been going through them and find it to be fairly simple. So I was just wondering what else is there for programming in C. Most of what I have found so far is c++ related.
(Note: I really don't care for learning how to write games/image manipulation programs. I am only wanting to learn how to write text based programs using unicode and ascii.)
Oh, and if someone might know the answer to this. What are the correct terms to search for tutorials on how to scroll the screen in the console? I had tried to learn this before using DOS many years ago, but I don't know if the interupt calls are still used the same way as they were back on an old 486.
Can your program function (assuming it did not need unicode) in the normal console?
If that is the case, then simply using a unicode aware terminal emulater in X should be all thats needed (I believe most emulaters need a argument passed that says to use unicode).
If thats not the case, then you will need a GUI toolkit. Only GTK is written in C, others are in C++. I believe Tk has C bindings tho, but I'm not aware of anyother toolkit thats even remotely popular that has plain C support.
And if your using interupts, stop. Look at Ncurses, if there is nothing about screen scrolling in there, then it probably cant be done and youll just have to implement it yourself. (note, I'm assuming your refering to scrolling the text console, if not, then use a scrolled window widget).
edit: Ah, there is also Cairo (not exactly a toolkit, and it'll require some extra low-level work with X to make it work fully) with Pango for text rendering.
Thanks. I downloaded the ncurses manual and will have a look at it when I can.
As for text based programming, no I don't have a program yet. I'd like to, I am getting rather bored with all the tutorials and command line programs. Heck, I'd at least like to know how to position the cursor on screen. I did find it once, but haven't found it again and have been searching for weeks.
Anyway, why I was looking into scrolling the screen. I haven't programmed using interrupts since about 99, and that was basically using the mouse via int86(&h33, AX, BX...) using ASIC or int86old(&h33, rect) using Qbasic, as well as the keyboard (which I think was at &h10 or &h11, too long ago to remember), and had only began learning how to scroll on an old 486 before switching to WinXP which Qbasic no longer worked on it.
I've only been using C and linux for a few months and don't quite know exactly how one accesses the screen, mouse, etc through the console using C and linux on a computer 1.2g to 2.0g, or if there is some other way that it is done. I've read that instead of accessing the devices by int86() one would rather use open("/dev/device", something). However, I'm beginning to think that Linux has other methods to access the devices...
Eh, my mind is still in 99, lol, and I really haven't a clue what I should read in order to access the devices. Anyway, I'll have a look at ncurses and see what it says...
Linux won't let you use interrupts unless you write your own kernel driver. You can move the cursor around the console using the standard escape sequences.
Any of the toolsets that are written for C++ can be invoked from C. Heck, I have been writing C++ classes that call gtk+ (and cairo and pango). Going back and forth between the two languages is not hard. In the worst case, you need stub routines that are callable by one language but call using the syntax of the other language. This is a frequent situation when using C to call C++.
You need to study /dev, /proc, and /sys. A lot of the information you want is found in those (particularly /dev).
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
A user interface in a text based console is not X. I think you are sufficiently aware of that if I look at your posts.
Ncurses is the way to go when programming a menu driven application, I can't really call it a GUI. I know exactly what you mean with the DOS applications using interrupts etc. I did it myself, you know what a mess it was, single user, single application, TSRs etc.
Funny because in that time Unix was already around with curses available, the predecessor of ncurses. You can do what you need, text based screen navigation, but in a really structured way without ever having to worry about hardware. Even if you SSH into another computer you still can use your ncurses based application. The most well-known curses applications might be the kernel config program (make menuconfig) and Midnight Commander (mc)
Anyhow, you might run into difficulties in this like catching keystrokes and testing the value, there is buffered and unbuffered input, you have to initialize the screen properly. But again, this all is highly structured, and once you master that, writing your application is pretty straightforward. You will find plenty examples on the internet. There is also a widget library avaible which greatly extends the ncurses toolkit. I forgot the name, but you google it easily. Use the keys 'ncurses widget toolkit'
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.