summaryrefslogtreecommitdiffstats
path: root/lib/util/tdevshellwidget.h
blob: f6476814d6d05074566a50106da47a5276d82020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/***************************************************************************
 *   Copyright (C) 2006 by Jens Dagerbo                                    *
 *   jens.dagerbo@swipnet.se                                               *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/


#ifndef TDEVSHELLWIDGET_H
#define TDEVSHELLWIDGET_H

#include <tqstrlist.h>
#include <tqvbox.h>
#include <tqguardedptr.h>

class TDEProcess;
namespace KParts
{
	class ReadOnlyPart;
}

class TDevShellWidget : public TQVBox
{

Q_OBJECT
  

public:
	TDevShellWidget(TQWidget *parent = 0, const char *name = 0);
	virtual ~TDevShellWidget();

	/**
	 * Stores the shell name and arguments, that will be used in @ref activate()
	 * @param shell The shell name, for example 'irb' or '/bin/bash'
	 * @param arguments Any optional arguments
	 */
	void setShell( const TQString & shell, const TQStrList & arguments = TQStrList() );

	/**
	 * Executes the previously set shell. If @ref setShell wasn't called before
	 * konsolepart will decide what to use.
	 */
	void activate();

	/**
	 * Should we auto launch the shell again if it was terminated?
	 * @param doAutoActivate
	 */
	void setAutoReactivateOnClose( bool doAutoActivate );

	/**
	 * Send text to the running shell
	 * @param text The text to send to the shell
	 */
	void sendInput( const TQString & text );

	/**
	 * Call to check if the shell is currently running
	 * @return true if the shell is currently running
	 */
	bool isRunning();

signals:
	/**
	 * This signal will be emmitted when the started shell exits normally
	 * @param exitcode The return code of the process
	 */
	void shellExited( int exitcode );

	/**
	 * This signal will be emitted when the started shell is terminated by a signal
	 * @param signalcode The signal the process was killed with
	 */
	void shellSignalled( int signalcode );

	/**
	 *  This signal will be emitted when the process receives data
	 * @param text received data
	 */
	void receivedData( const TQString & );

private slots:
	void partDestroyed();
	void processExited( TDEProcess * );
	void setAutoReactivateOnCloseDelayed( );

private:
	TQGuardedPtr<KParts::ReadOnlyPart> m_konsolePart;
	TQString m_shellName;
	TQStrList m_shellArguments;
	bool m_doAutoActivate;
	bool m_isRunning;
};

#endif

// kate: space-indent off; indent-width 4; tab-width 4; show-tabs off;