Solved

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

Posted on 2004-09-08
1
253 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them 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.

789 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