Diffstat (limited to 'core/apps/embeddedkonsole/session.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/embeddedkonsole/session.cpp | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/core/apps/embeddedkonsole/session.cpp b/core/apps/embeddedkonsole/session.cpp new file mode 100644 index 0000000..520af86 --- a/dev/null +++ b/core/apps/embeddedkonsole/session.cpp | |||
@@ -0,0 +1,157 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | ||
2 | /* */ | ||
3 | /* Ported Konsole to Qt/Embedded */ | ||
4 | /* */ | ||
5 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | ||
6 | /* */ | ||
7 | /* -------------------------------------------------------------------------- */ | ||
8 | #include "session.h" | ||
9 | #include <qpushbutton.h> | ||
10 | // #include <kdebug.h> | ||
11 | |||
12 | #include <stdlib.h> | ||
13 | |||
14 | #define HERE fprintf(stderr,"%s(%d): here\n",__FILE__,__LINE__) | ||
15 | |||
16 | /*! \class TESession | ||
17 | |||
18 | Sessions are combinations of TEPTy and Emulations. | ||
19 | |||
20 | The stuff in here does not belong to the terminal emulation framework, | ||
21 | but to main.C. It serves it's duty by providing a single reference | ||
22 | to TEPTy/Emulation pairs. In fact, it is only there to demonstrate one | ||
23 | of the abilities of the framework - multible sessions. | ||
24 | */ | ||
25 | |||
26 | TESession::TESession(QMainWindow* main, TEWidget* te, const char* _pgm, QStrList & _args, const char *_term) : schema_no(0), font_no(3), pgm(_pgm), args(_args) | ||
27 | { | ||
28 | // sh = new TEPty(); | ||
29 | sh = new MyPty(); | ||
30 | em = new TEmuVt102(te); | ||
31 | |||
32 | term = _term; | ||
33 | |||
34 | sh->setSize(te->Lines(),te->Columns()); // not absolutely nessesary | ||
35 | QObject::connect( sh,SIGNAL(block_in(const char*,int)), | ||
36 | em,SLOT(onRcvBlock(const char*,int)) ); | ||
37 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), | ||
38 | sh,SLOT(setSize(int,int))); | ||
39 | |||
40 | // 'main' should do those connects itself, somehow. | ||
41 | // These aren't KTMW's slots, but konsole's.(David) | ||
42 | |||
43 | /* | ||
44 | QObject::connect( em,SIGNAL(ImageSizeChanged(int,int)), | ||
45 | main,SLOT(notifySize(int,int))); | ||
46 | */ | ||
47 | QObject::connect( em,SIGNAL(sndBlock(const char*,int)), | ||
48 | sh,SLOT(send_bytes(const char*,int)) ); | ||
49 | QObject::connect( em,SIGNAL(changeColumns(int)), | ||
50 | main,SLOT(changeColumns(int)) ); | ||
51 | /* | ||
52 | QObject::connect( em,SIGNAL(changeTitle(int, const QString&)), | ||
53 | main,SLOT(changeTitle(int, const QString&)) ); | ||
54 | */ | ||
55 | QObject::connect( sh,SIGNAL(done(int)), this,SLOT(done(int)) ); | ||
56 | } | ||
57 | |||
58 | |||
59 | |||
60 | void TESession::run() | ||
61 | { | ||
62 | //kdDebug() << "Running the session!" << pgm << "\n"; | ||
63 | sh->run(pgm,args,term.data(),FALSE); | ||
64 | } | ||
65 | |||
66 | void TESession::kill(int ) // signal) | ||
67 | { | ||
68 | // sh->kill(signal); | ||
69 | } | ||
70 | |||
71 | TESession::~TESession() | ||
72 | { | ||
73 | QObject::disconnect( sh, SIGNAL( done( int ) ), | ||
74 | this, SLOT( done( int ) ) ); | ||
75 | delete em; | ||
76 | delete sh; | ||
77 | } | ||
78 | |||
79 | void TESession::setConnect(bool c) | ||
80 | { | ||
81 | em->setConnect(c); | ||
82 | } | ||
83 | |||
84 | void TESession::done(int status) | ||
85 | { | ||
86 | emit done(this,status); | ||
87 | } | ||
88 | |||
89 | void TESession::terminate() | ||
90 | { | ||
91 | delete this; | ||
92 | } | ||
93 | |||
94 | TEmulation* TESession::getEmulation() | ||
95 | { | ||
96 | return em; | ||
97 | } | ||
98 | |||
99 | // following interfaces might be misplaced /// | ||
100 | |||
101 | int TESession::schemaNo() | ||
102 | { | ||
103 | return schema_no; | ||
104 | } | ||
105 | |||
106 | int TESession::keymap() | ||
107 | { | ||
108 | return keymap_no; | ||
109 | } | ||
110 | |||
111 | int TESession::fontNo() | ||
112 | { | ||
113 | return font_no; | ||
114 | } | ||
115 | |||
116 | const char* TESession::emuName() | ||
117 | { | ||
118 | return term.data(); | ||
119 | } | ||
120 | |||
121 | void TESession::setSchemaNo(int sn) | ||
122 | { | ||
123 | schema_no = sn; | ||
124 | } | ||
125 | |||
126 | void TESession::setKeymapNo(int kn) | ||
127 | { | ||
128 | keymap_no = kn; | ||
129 | em->setKeytrans(kn); | ||
130 | } | ||
131 | |||
132 | void TESession::setFontNo(int fn) | ||
133 | { | ||
134 | font_no = fn; | ||
135 | } | ||
136 | |||
137 | void TESession::setTitle(const QString& title) | ||
138 | { | ||
139 | this->title = title; | ||
140 | } | ||
141 | |||
142 | const QString& TESession::Title() | ||
143 | { | ||
144 | return title; | ||
145 | } | ||
146 | |||
147 | void TESession::setHistory(bool on) | ||
148 | { | ||
149 | em->setHistory( on ); | ||
150 | } | ||
151 | |||
152 | bool TESession::history() | ||
153 | { | ||
154 | return em->history(); | ||
155 | } | ||
156 | |||
157 | // #include "session.moc" | ||