/******************************************************************************
Copyright (C) 2005 Matteo Lucarelli

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
******************************************************************************/

// NEED: `fltk-config --ldflags`

#if !defined(UIshowexec_H_INCLUDED)
#define UIshowexec_H_INCLUDED

// #define...

#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Text_Display.H>

class UIshowexec
{
public:

	UIshowexec(int dimx,int dimy,			// window dimension
	           const char* command,			// command to execute
	           const char* label=NULL,		// windows title
	           unsigned char font=FL_COURIER,	// font (fltk)
	           unsigned char fontsize=12);		// font size
	           
	virtual ~UIshowexec();
	
	void cb_wMain();
	static void cb_wMain_link(Fl_Widget*, void *o){((UIshowexec*)o)->cb_wMain();}
	
	void cb_Data(int fd);
	static void cb_Data_link(int fd,void *o){((UIshowexec*)o)->cb_Data(fd);}
	
	pid_t m_pid;

private:

	Fl_Double_Window *m_wMain;
	Fl_Text_Display *m_display;
	Fl_Text_Buffer *m_buffer;
	
	int m_pipe[2]; 
};

#endif // !defined(UIshowexec_H_INCLUDED)