It's been many years since I've looked into this. Maybe when I was just getting into C++. But is it still possible to achieve MS-DOS like graphics on a command line interface? Obviously with some small hacks that you can achieve the color scheme. However I'm looking more into menu options. I.e. radio controls menu select.
And yes I know you can also achieve this probably a little bit easier using SDL. But I was just curious if anyone else has accomplish this and has some details posted on the Internet or can possibly point me in the right direction. If this is not as easy to achieve anymore on windows 10 I'll just go on and find something else to do for fun.
Thanks.
Yes, absolutely. You can either use functions such as Set/GetConsoleScreenBufferInformationEx or you can enable VT-100 escape sequences and use those (you'll remember this as ANSI.sys in DOS).
That's the more portable method, as the only windows-specific part should be enabling VT-100 mode, everything else should be the same on Linux.
SetConsoleMode: https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx
Or to read and write the console buffer directly:
Console APIs: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682073(v=vs.85).aspx
Related
first I want to apologize for my bad English and second for this topic, I didnt find anything like this so I create it.
My problem is:
I want to create a game where I want to use conio2.h, but problem is, that I cant find it on the internet. Still I find something with Linux, but I need it on windows. Im using CodeBlocks, it is good program but it doesnt have this library
Can you help me guys?
Conio is an old MS-DOS header. You will not find it in modern compilers. For Unix/Linux systems, you can use curses, Windows Systems have their own libraries and functions.
You may want to ask a question on how to do something specific you are having problems with and posting some code.
For example, setting the cursor position can be done with SetConsoleCursorPosition .
I have been looking through previous questions regarding this topic and so far none of them answer my question. I am looking for a way (without libraries) to build my own TUI from the ground up. I want to start off with a simple program that reads a directory and displays the contents with the ability to use arrow keys to move up and down highlighting one item. As simple as this may seem this would be all the help I need to get started on the rest of my project.
All I need is for someone to point me in the right direction for clearing and printing to the screen and not using a print statement or external library. Any help would be greatly appreciated.
Well, to be honest, you can. But as others will tell you, curses is the right tool for the job.
That said, this isn't the 80s anymore. <overgeneralization>Everybody uses Xterm.</overgeneralization> Xterm uses ANSI VT100 control codes, mimicking the classic DEC VT-100. If you target this, you should be reasonably ok and portable.
But curses is really nice. It does a lot of the hard work for you (and there's plenty of hard work left to keep you busy).
I'm having a problem for a SDL project, I'd like to show text on the window and allow the user to input text. As much as I know, there is no simple way to achieve that. Do you hava any suggestion?
Note: I use C programming langage. I know there is a library called SDL_ttf which doesn't seems to make the job I want.
I have to be honest, as I was reading your question, SDL_ttf immediately sprang to mind. It's not too hard to use and there are plenty of docs available.
What it sounds like you are looking for, is a library that provides a simple console interface, where your main programming interaction is to write(...) and read(...) text and it handles display, scrolling and so on.
This project has a lot of code showing how to implement a simple 'console' in SDL, and it does use SDL_ttf to do so.
I'm not convinced you are going to avoid it, unless you grab someone's library that hides it away from you like this one but you are going to have less control over the display and interactivity this provides.
I must go with benosteen, SDL_ttf is a really good option. For my part, I used this tutorial to make it work in my project. It's really simple and straightforward.
EDIT:
I had some troubles with the Blending functionality of SDL_ttf, but I managed to make it work after QuasarDonkey found the problem in this question.
Have a look for a straight forward example on how to use it and create text surface.
So being new to the C language i want to program a simple window or GUI. are there any good web pages or books i could get to learn how to do this? I've searched around on the net and haven't come up with anything! or if someone could send me on the right track like what to #include and maybe some important commands that i will need that would be awesome! thanks!
Check out GTK. You didn't say what OS you are using. GTK is cross platform, but easiest to use on Linux.
You need a gui toolkit, you can either use one built into your OS (eg the Win32 API on windows) or pick a platform independant one
Qt http://qt.nokia.com/ is probably the most popular full featured one, or you can start with something quicker and easy like http://www.fltk.org/
Hi i want to make a text editor using c. I don't want to make any GUI, the text editor is going to be a console application. I would like to ask if there are any libraries which implement some basic functionality for example, i want to execute a function when user presses ctr+s.
You're going to want to look into the curses library. There are versions of it for most Unix-like systems as well as for console programs in Windows (and probably programs running under PowerShell, but not sure).
This library has functions for reading key presses, moving around the screen, and drawing window-ish borders with either ASCII or terminal graphics characters in a platform/terminal independent way. Some versions even have the ability to work with mice.
There's lots more that curses can help you do, but you'll have trouble appreciating it until you read more in depth about it and see some examples in action (and actually realize that they are using curses).
The most popular version for free *nix systems is ncurses and the windows version is called pdcurses.
Use ncurses and take a look at the the source code for vim.
Curses and other such libraries are a good place to start.
http://en.wikipedia.org/wiki/Curses_%28programming_library%29
You can find a simple ncurses-based text editor on my webpage here:
http://www.melvilletheatre.com/articles/cstuff/1.html