howto redirect command line to ada gtk.text_buffer ?
Hi friends,
currently I'm using this procedure in order to display the output of a command line program in an (ada) gtk.text buffer. After the program is launched (in this example /bin/ls), the output goes into a text file (see comment A). Finally the file content is sent to the text_buffer (see comment B).
procedure button_callback
(
widget : access gtk.widget.gtk_widget_record'class;
data : string_access
)
is
pragma unreferenced (widget);
begin
if data.all = "START" then
Create( result_file, Name => result_file_name);
-- launch external command
Spawn
(
Program_Name => "/bin/ls",
Args => ( 1=> new String'("-l")),
Output_File => result_file_name, -- comment A
Success => var_success,
Return_Code => Result
);
close(result_file);
-- comment B
-- display the file result_file_name in the text buffer
gtk.text_buffer.set_text (textbuf, read_result_file);
end button_callback;
The drawback is that I can't see the program output at runtime as it is required for the command line program "top" or the like.
What do I have to change ?
Thank you all !
Last edited by Mario Blunk; 01-31-2013 at 04:26 AM.
|