/*
 * This file is part of DesktopBSD, see the README file.
 *
 * Author: Peter Hofer <ph@desktopbsd.net>
 *         (C) 2004, 2005
 *
 * Copyright: BSD, see the COPYING file included in this distribution
 *
 */

#ifndef __TERMINALDISPLAY_H
#define __TERMINALDISPLAY_H

#include <qtextedit.h>

class QProcess;
class TerminalFormatter;

/** This class displays the output of a QProcess
  * specified with setProcess().
  */
class  TerminalDisplay : protected QTextEdit {
	Q_OBJECT

public:
	TerminalDisplay(QWidget *parent = 0,  const char *name = 0);

	void  clear();
	void  setProcess(QProcess  *process);
	void	setFormatter(TerminalFormatter *f);
	void  removeFormatter() { setFormatter(NULL); }
	void	setClearOnSetProcess(bool v) { clearOnSetProcess = v; }

public slots:
	void	show() { QTextEdit::show(); }
	void	hide() { QTextEdit::hide(); }

private slots:
	void  readStdout();
	void  processExited();

private:
	QProcess				*process;
	TerminalFormatter	*formatter;
	bool					 clearOnSetProcess;
};

#endif /* __TERMINALDISPLAY_H */
