summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/emulation_handler.h
blob: dabdb15a95054fba6514d38d2a990de20d6bbbee (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
102
103
104
105
106
107
108
109
110
111
112
#ifndef OPIE_EMULATION_HANDLER_H
#define OPIE_EMULATION_HANDLER_H

#include <qobject.h>
#include <qcolor.h>
#include <qcstring.h>

/*
 * Badly ibotty lacks the time to finish
 * his widget in time..
 * Never the less we've to have an EmulationWidget
 * This is why I'm taking the inferior not cleaned
 * up TE* KDE STUFF
 */

/**
 * This is the layer above the IOLayer*
 * This nice QObject here will get stuff from
 * got a slot and a signal
 * the signal for data
 * the slot for receiving
 * it'll set up the widget internally
 * and manage the communication between
 * the pre QByteArray world!
 */
class Profile;
class QWidget;
class QPushButton;
class TEWidget;
class QFile;
class TEmulation;
class QFont;
class QTextStream;
class Script;
class Logger;

class EmulationHandler : public QObject {
    Q_OBJECT
public:
    /**
     * simple c'tor the parent of the TEWdiget
     * and a name
     * and a Profile
     */
    EmulationHandler( const Profile&, QWidget* parent, const char* name = 0l );

    /**
     * delete all components
     */
    ~EmulationHandler();

    void load( const Profile& );
    QWidget* widget();
    TEmulation *emulation();
    void setColor( const QColor& fore, const QColor& back );
    QPushButton* cornerButton();

    /* Scripts */
    /* Create a new script and record all typed characters */
    void startRecording();

	void startLogging(const QString);

    /* Return whether we are currently recording a script */
    bool isRecording();

	/* Return whether we are currently recording a log */
	bool isLogging();
	
	QString logFileName();

    /* Return the current script (or NULL) */
    Script *script();

    /* Stop recording and remove the current script from memory */
    void clearScript();
    
    /* Stop logging and remove the current log from memory */
    void clearLog();

    /* Run a script by forwarding its keys to the EmulationLayer */
    void runScript(const Script *);

	/* Propagate change to widget */
	void setWrap(int columns);
	void setScrollbarLocation(int index);
signals:
    void send( const QByteArray& );
    void changeSize(int rows, int cols );


public slots:
    void recv( const QByteArray& );
    void paste();
    void copy();

private slots:
    void recvEmulation( const char*,  int len );
private:
    QFont font( int );
    QColor foreColor(int );
    QColor backColor(int );

private:
    TEWidget* m_teWid;
    TEmulation* m_teEmu;
    Script * m_script;
    Logger *m_log;
    QString m_logFileName;
};

#endif