Solved

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

Posted on 2004-09-08
1
234 Views
Last Modified: 2010-04-15
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
Comment
Question by:jimdgar
1 Comment
 
LVL 45

Accepted Solution

by:
sunnycoder earned 100 total points
ID: 12013351
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now