Link to home
Start Free TrialLog in
Avatar of HHFBF
HHFBF

asked on

C/curses to GUI rejuvenation

How could one more easily transform a (huge) C program that uses the 'curses' library for keyboard and screen management into a GUI program without changing the program itself but just the calls to the curses routines?

The final program is intended to have a GUI look&feel, and ideally accept mouse input.

Would it be conceivably possible to write some sort of wrapper or middleware that mimics curses?

All calls to curses were nicely encapsulated into other functions so that the original program does not make any direct access to curses itself.

Since the original C program is server based, I presume the transformed version would also be server based which naturally lead to a web interface.
On the other hand, curses allows capturing keyboard input character by character, which resembles a client type language.

I appreciate the comments.
Avatar of sunnycoder
sunnycoder
Flag of India image

>Since the original C program is server based, I presume the transformed version would also be server based which
>naturally lead to a web interface.
What do you mean by server based?


>All calls to curses were nicely encapsulated into other functions so that the original program does not make any
>direct access to curses itself.
Excellent ... All you need to do now is to reimplement this wrapper library to get as close to GUI functionality as possible. Ofcourse there would be some mismatches - one cannot expect one to one correspondence between curses and a GUI library. Additionally you would have to add functions for missing functionality such as mouse handling. Finally you will have to edit the source code to take advantage of this added functionality. Some code might also get edited due to modification of existing calls to your wrapper library.
Avatar of cup
cup

The problem is what the curses programs draw.  It could draw a rectangle and put some text in it.  This could be

1) a button
2) an edit box
3) a listbox
4) some text with a box around it
5) an illustration of some sort

Problem is, each of these do something different when you click in the box.  You can't figure out what it is automatically.
Avatar of HHFBF

ASKER

I perfectly understand I would have to write a wrapper or "translator" that would mimic the curses functionality.
Question is "what would be the best, or/most viable, or candidate approach, language, library to achieve the necessary result (no rewriting, GUI look&feel, use of mouse)".

And yes, there are several screen elements that curses allows one to do but in essence curses does no more than capture the keyboard input and send it to the application. From that point on is up to application to decide what to do, which is part of the code.

In other words, we are after a GUI version of curses.

ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HHFBF

ASKER

I would ideally like to see a sample of the wrapper, a mini wrapper.

Ex: a 'hello world" in C/curses (printf("hello world");) running under GTK or Qt.