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.
CScripting Languages

Avatar of undefined
Last Comment
HHFBF

8/22/2022 - Mon
sunnycoder

>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.
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.
ASKER
HHFBF

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.

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
sunnycoder

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
HHFBF

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.