[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

C/Motif/*nix: how to append text in an output window?

I've created a simple Scrolled Text area for displaying information to the user during runtime of my app.  How can I append text to this text area?  Essentially I want to use it like a scrollable xterm.  In Java, this is two easy steps once the text area is created:
               OutputWindow.append (text);
               OutputWindow.setCaretPosition ();   // to auto scroll down to the bottom

All the examples I've seen for Motif require creating a buffer yourself, appending new text to the buffer (and managing the allocated space), then using XmTextSetString (output_window,buffer);  Is there an easier way, maybe equivalent to how Java does it?
0
jimdgar
Asked:
jimdgar
1 Solution
 
sunnycoderCommented:
Hi jimdgar,

Java handles memory management for you. C is not so generous. It expects the programmer to handle its own memory mangement. I do not think you will find the exact Java equivalent APIs in C. There will be some sort of memory management involved on your part at some point.

That been said, I have not worked with X-Motif but I have worked with few GUI libs like Qt and Gtk and usual method is to create a buffer, put in a string and then call a SetString kind of function. It is upto the programmer to free the allocated memory later.

sunnycoder
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now