LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-21-2010, 03:05 AM   #1
cwilliams10
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Rep: Reputation: 0
How to get 2 text windows with a single program


Hi,
Running Ubuntu and writing simple C programs.
I need 2 text windows, the one I have started in, and a second to display some debug information.
I can start a second screen using popen("/usr/X11R6/bin/xterm" "w"), and I get my new text window.
However, it is running a shell and I can't send any info to it!
Is there a better way to do this?

Thanks for any help you can give me.

Regards,

Chris.
 
Old 04-21-2010, 06:13 AM   #2
rylan76
Senior Member
 
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,552

Rep: Reputation: 103Reputation: 103
Are you talking about doing this FROM your C program, or while you are editing code?

If it is while your are editing code, have you taken a look at the EMACS editor?

It is specifically designed to have code in one text window, and GDB output / interface in another.

Last edited by rylan76; 04-21-2010 at 06:14 AM.
 
Old 04-21-2010, 06:50 AM   #3
cwilliams10
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Part of my own program, NOT part of the editing process.
When running a program in the console you can output text etc.
What I want is to open a second text window, with the functionality of xterm, that is I want it to recognise the ESC codes etc, so that I can output some debug info / status screens whilst still typing and getting messages in the original screen.

Chris.
 
Old 04-21-2010, 09:02 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I think you need to understand the difference between opening a window (what you want), and launching a program (what you're doing). To open a window (assuming using X), you must use X toolkit functions and primitives, and explicitly write text strings to the window. There may be more streamlined ways of doing this by using one of the desktop libraries/toolkits such as GTK (Gnome) or Qt (KDE). I'm not very familiar with any of these libraries; maybe someone who is can fill in more of the details.
--- rod.
 
Old 04-21-2010, 12:52 PM   #5
cwilliams10
LQ Newbie
 
Registered: Apr 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Solved: How to get 2 text windows

I have a resonable solution to the problem:
I can start a new xterm with say popen();
Then if I do 'who' I can see the new terminal name such as /dev/pts/1

I then do
term = fopen("/dev/pts/1", "w");
fprintf(term,"This is some text");

and it comes up in my new window, including using ESC commands to clear the screen etc.

I need to automatically scan the result of 'who' but thats a minor problem.

Thanks for peoples help.

Chris.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
insert a single quote is text file with sed eln01 Programming 7 05-10-2007 11:02 AM
in Pascal: how to exec a program, discard text output or send to text file Valkyrie_of_valhalla Programming 6 05-02-2007 09:50 AM
How to read a single line from a text file into a shell script. SkipHuffman Linux - Software 2 08-16-2006 02:10 PM
Removing Text in a single line starting with one pattern ending on another mgwheeler Programming 13 08-03-2004 04:36 PM
reading a single line of a text file davi_cabral Linux - Software 1 10-29-2003 12:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration