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
Related
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
I've written a code in linux OS which produces prog.out as output file.
Now I've to write GUI for the code.
what are best ways to write it?
PS - I wanted to choose between Java Swings and openGL.
Which is best for writing a simple GUI and integrating it with my C- Application
Thanks in advance
OpenGL is a rendering library, not a UI toolkit. Comparing it to Swing doesn't make sense. And you can't choose Swing for a C application, unless you'd rather do the UI in Java and interact with a C "backend".
For a pure C solution, the best choice would probably be the GTK+ toolkit.
Try Anjuta...
http://projects.gnome.org/anjuta/
If you are prepared to use another language (you mention Java) then you may find C++ and Qt to be a good fit. Linking to the existing C code will be trivial and Qt works well on a great many platforms should you ever wish to support other platforms in addition to Linux.
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.
hi every one i want ask that i have made a program and i have store a data in csv file. now i want a gui which includes buttons which upon pressing opens a a file and plot a graph.is there a way through which i can add gui in my program using gcc.and also i want to ask how can i make a moving graph just like ECG.
thank alot.
Have you looked into using a toolkit like GTK+, if not i would suggest you check it out. GTK+ is written natively in C so i think it should work for you.
Rephrasing your quesiton:
You have a C program that stores data in a csv file. You wish to display this information as a graph but don't know how to build a GUI or graphical display. Further, you want animation (it would be good if you linked to what "ECG" is) probably to display temporal aspects.
If I have this right, I suggest you learn the GTK and Cairo libraries and use those to build your GUI. Build GUI's is tedious and unrewarding work (to me), particularly in C. I'd think hard about if you really want to bother making a GUI instead of doing something simple like calling out to gnuplot to build the graph as a file that the user can open, though this won't get you any animation.
I suggest you switch your project to C++ and use Qt for your GUI.
If gcc is not a requirement, then check out SciPy or Octave.
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/