Debian Codegraph @

src/ksession.cpp

raw symbols SCIP
1 /*
2 This file is part of Konsole QML plugin,
3 which is a terminal emulator from KDE.
4
5 Copyright 2013 by Dmitry Zagnoyko <[email protected]>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301 USA.
21 */
22
23 // Own
24 #include "ksession.h"cxx . . $ `<file>/src/ksession.h`/
25
26 // Qt
27 #include <QTextCodec>
28
29 // Konsole
30 #include "KeyboardTranslator.h"cxx . . $ `<file>/lib/KeyboardTranslator.h`/
31 #include "HistorySearch.h"cxx . . $ `<file>/lib/HistorySearch.h`/
32
33 KSessioncxx . . $ KSession#::KSessioncxx . . $ KSession#KSession(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) :
34 QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent), m_sessioncxx . . $ KSession#m_session.(createSessioncxx . . $ KSession#createSession(867a005158409b9e).(""cxx . . $ QString#QString(85c52e162fed56f9).))
35 {
36 connectcxx . . $ QObject#connect(158df1d9a01a3410).(m_sessioncxx . . $ KSession#m_session., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(started()), this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(started()));
37 connectcxx . . $ QObject#connect(158df1d9a01a3410).(m_sessioncxx . . $ KSession#m_session., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(finished()), this, SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(sessionFinished()));
38 connectcxx . . $ QObject#connect(158df1d9a01a3410).(m_sessioncxx . . $ KSession#m_session., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(titleChanged()), this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(titleChanged()));
39 }
40
41 KSessioncxx . . $ KSession#::~cxx . . $ KSession#`~KSession`(ced63f7c635d850d).KSessioncxx . . $ KSession#()
42 {
43 if (m_sessioncxx . . $ KSession#m_session.) {
44 m_sessioncxx . . $ KSession#m_session.->closecxx . . $ Konsole/Session#close(49f6e7a06ebc5aa8).();
45 m_sessioncxx . . $ KSession#m_session.->disconnectcxx . . $ QObject#disconnect(bb355c0e5cae20e4).();
46 delete m_sessioncxx . . $ KSession#m_session.;
47 }
48 }
49
50 void KSessioncxx . . $ KSession#::setTitlecxx . . $ KSession#setTitle(7df51288a9ebd664).(QStringcxx . . $ QString# name)
51 {
52 m_sessioncxx . . $ KSession#m_session.->setTitlecxx . . $ Konsole/Session#setTitle(3c5ac9fc232d1f59).(Sessioncxx . . $ Konsole/Session#::NameRolecxx . . $ Konsole/Session#NameRole., name);
53 }
54
55
56 Sessioncxx . . $ Konsole/Session# *KSessioncxx . . $ KSession#::createSessioncxx . . $ KSession#createSession(867a005158409b9e).(QStringcxx . . $ QString# name)
57 {
58 Sessioncxx . . $ Konsole/Session# *session = new Sessioncxx . . $ Konsole/Session#();
59
60 session->setTitlecxx . . $ Konsole/Session#setTitle(3c5ac9fc232d1f59).(Sessioncxx . . $ Konsole/Session#::NameRolecxx . . $ Konsole/Session#NameRole., name);
61
62 /* Thats a freaking bad idea!!!!
63 * /bin/bash is not there on every system
64 * better set it to the current $SHELL
65 * Maybe you can also make a list available and then let the widget-owner decide what to use.
66 * By setting it to $SHELL right away we actually make the first filecheck obsolete.
67 * But as iam not sure if you want to do anything else ill just let both checks in and set this to $SHELL anyway.
68 */
69
70 //cool-old-term: There is another check in the code. Not sure if useful.
71
72 QStringcxx . . $ QString# envshell = getenvcxx . . $ QString#QString(85c52e162fed56f9).("SHELL");
73 QStringcxx . . $ QString# shellProg = envshell !=cxx . . $ QString#`operator!=`(7d4bdb1abc417636). NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ? envshellcxx . . $ QString#QString(132dd6869045752b). : "/bin/bash"cxx . . $ QString#QString(85c52e162fed56f9).;
74 session->setProgramcxx . . $ Konsole/Session#setProgram(3520e46b33348bf6).(shellProg);
75
76 setenv("TERM", "xterm", 1);
77
78 //session->setProgram();
79
80 QStringListcxx . . $ QStringList# argscxx . . $ QStringList#QStringList(3520e46b33348bf6).(""cxx . . $ QString#QString(85c52e162fed56f9).);
81 session->setArgumentscxx . . $ Konsole/Session#setArguments(631c0101495f0328).(args);
82 session->setAutoClosecxx . . $ Konsole/Session#setAutoClose(b45ddcbc8423892c).(true);
83
84 session->setCodeccxx . . $ Konsole/Session#setCodec(ca93e7c01f42f36c).(QTextCodeccxx . . $ QTextCodec#::codecForNamecxx . . $ QTextCodec#codecForName(914382192c9ca379).("UTF-8"));
85
86 session->setFlowControlEnabledcxx . . $ Konsole/Session#setFlowControlEnabled(b45ddcbc8423892c).(true);
87 session->setHistoryTypecxx . . $ Konsole/Session#setHistoryType(8cdb70a5e6e0950).(HistoryTypeBuffercxx . . $ Konsole/HistoryTypeBuffer#(1000));
88
89 session->setDarkBackgroundcxx . . $ Konsole/Session#setDarkBackground(b45ddcbc8423892c).(true);
90
91 session->setKeyBindingscxx . . $ Konsole/Session#setKeyBindings(3520e46b33348bf6).(""cxx . . $ QString#QString(85c52e162fed56f9).);
92
93 return session;
94 }
95
96 /////////////////////////////////////////////////////////////////////////////////////
97 /////////////////////////////////////////////////////////////////////////////////////
98
99
100 int KSessioncxx . . $ KSession#::getRandomSeedcxx . . $ KSession#getRandomSeed(b126dc7c1de90089).()
101 {
102 return m_sessioncxx . . $ KSession#m_session.->sessionIdcxx . . $ Konsole/Session#sessionId(455f465bc33b4cdf).() * 31;
103 }
104
105 void KSessioncxx . . $ KSession#::addViewcxx . . $ KSession#addView(d1be2bc5a38bdd21).(TerminalDisplaycxx . . $ Konsole/TerminalDisplay# *display)
106 {
107 m_sessioncxx . . $ KSession#m_session.->addViewcxx . . $ Konsole/Session#addView(d1be2bc5a38bdd21).(display);
108 }
109
110 void KSessioncxx . . $ KSession#::removeViewcxx . . $ KSession#removeView(d1be2bc5a38bdd21).(TerminalDisplaycxx . . $ Konsole/TerminalDisplay# *display)
111 {
112 m_sessioncxx . . $ KSession#m_session.->removeViewcxx . . $ Konsole/Session#removeView(d1be2bc5a38bdd21).(display);
113 }
114
115 void KSessioncxx . . $ KSession#::sessionFinishedcxx . . $ KSession#sessionFinished(49f6e7a06ebc5aa8).()
116 {
117 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! finishedcxx . . $ KSession#finished(49f6e7a06ebc5aa8).();
118 }
119
120 void KSessioncxx . . $ KSession#::selectionChangedcxx . . $ KSession#selectionChanged(b45ddcbc8423892c).(bool textSelected)
121 {
122 Q_UNUSEDcxx . . $ `<external>/15045578679651060896/qglobal.h:117:9`!(textSelected)
123 }
124
125 void KSessioncxx . . $ KSession#::startShellProgramcxx . . $ KSession#startShellProgram(49f6e7a06ebc5aa8).()
126 {
127 if ( m_sessioncxx . . $ KSession#m_session.->isRunningcxx . . $ Konsole/Session#isRunning(50ce9a9e25b4a850).() ) {
128 return;
129 }
130
131 m_sessioncxx . . $ KSession#m_session.->runcxx . . $ Konsole/Session#run(49f6e7a06ebc5aa8).();
132 }
133
134 bool KSessioncxx . . $ KSession#::sendSignalcxx . . $ KSession#sendSignal(83c267b20bac841a).(int signal)
135 {
136 if ( !m_sessioncxx . . $ KSession#m_session.->isRunningcxx . . $ Konsole/Session#isRunning(50ce9a9e25b4a850).() ) {
137 return false;
138 }
139
140 return m_sessioncxx . . $ KSession#m_session.->sendSignalcxx . . $ Konsole/Session#sendSignal(83c267b20bac841a).(signal);
141 }
142
143 int KSessioncxx . . $ KSession#::getShellPIDcxx . . $ KSession#getShellPID(b126dc7c1de90089).()
144 {
145 return m_sessioncxx . . $ KSession#m_session.->processIdcxx . . $ Konsole/Session#processId(455f465bc33b4cdf).();
146 }
147
148 void KSessioncxx . . $ KSession#::changeDircxx . . $ KSession#changeDir(3520e46b33348bf6).(const QStringcxx . . $ QString# &dir)
149 {
150 /*
151 this is a very hackish way of trying to determine if the shell is in
152 the foreground before attempting to change the directory. It may not
153 be portable to anything other than Linux.
154 */
155 QStringcxx . . $ QString# strCmdcxx . . $ QString#QString(ced63f7c635d850d).;
156 strCmd.setNumcxx . . $ QString#setNum(6483560ce2afa901).(getShellPIDcxx . . $ KSession#getShellPID(b126dc7c1de90089).());
157 strCmd.prependcxx . . $ QString#prepend(d02845eef0c33901).("ps -j ");
158 strCmd.appendcxx . . $ QString#append(d02845eef0c33901).(" | tail -1 | awk '{ print $5 }' | grep -q \\+");
159 int retval = systemcxx . . $ system(5c4306d8553b3696).(strCmd.toStdStringcxx . . $ QString#toStdString(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).());
160
161 if (!retval) {
162 QStringcxx . . $ QString# cmd = "cd " +cxx . . $ operator+(c75c3ae4eb9af1a8). dir +cxx . . $ operator+(3d22f08efddf8107). "\n";
163 sendTextcxx . . $ KSession#sendText(7df51288a9ebd664).(cmdcxx . . $ QString#QString(132dd6869045752b).);
164 }
165 }
166
167 void KSessioncxx . . $ KSession#::setEnvironmentcxx . . $ KSession#setEnvironment(631c0101495f0328).(const QStringListcxx . . $ QStringList# &environment)
168 {
169 m_sessioncxx . . $ KSession#m_session.->setEnvironmentcxx . . $ Konsole/Session#setEnvironment(631c0101495f0328).(environment);
170 }
171
172
173 void KSessioncxx . . $ KSession#::setShellProgramcxx . . $ KSession#setShellProgram(3520e46b33348bf6).(const QStringcxx . . $ QString# &progname)
174 {
175 m_sessioncxx . . $ KSession#m_session.->setProgramcxx . . $ Konsole/Session#setProgram(3520e46b33348bf6).(progname);
176 }
177
178 void KSessioncxx . . $ KSession#::setInitialWorkingDirectorycxx . . $ KSession#setInitialWorkingDirectory(3520e46b33348bf6).(const QStringcxx . . $ QString# &dir)
179 {
180 if ( _initialWorkingDirectorycxx . . $ KSession#_initialWorkingDirectory. !=cxx . . $ `operator!=`(5bc2975d2d751687). dir ) {
181 _initialWorkingDirectorycxx . . $ KSession#_initialWorkingDirectory. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). dir;
182 m_sessioncxx . . $ KSession#m_session.->setInitialWorkingDirectorycxx . . $ Konsole/Session#setInitialWorkingDirectory(3520e46b33348bf6).(dir);
183 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! initialWorkingDirectoryChangedcxx . . $ KSession#initialWorkingDirectoryChanged(49f6e7a06ebc5aa8).();
184 } }
185
186 QStringcxx . . $ QString# KSessioncxx . . $ KSession#::getInitialWorkingDirectorycxx . . $ KSession#getInitialWorkingDirectory(4365c3963150523e).()
187 {
188 return _initialWorkingDirectorycxx . . $ QString#QString(132dd6869045752b).;
189 }
190
191 void KSessioncxx . . $ KSession#::setArgscxx . . $ KSession#setArgs(631c0101495f0328).(const QStringListcxx . . $ QStringList# &args)
192 {
193 m_sessioncxx . . $ KSession#m_session.->setArgumentscxx . . $ Konsole/Session#setArguments(631c0101495f0328).(args);
194 }
195
196 void KSessioncxx . . $ KSession#::setTextCodeccxx . . $ KSession#setTextCodec(1f30447839ed391).(QTextCodeccxx . . $ QTextCodec# *codec)
197 {
198 m_sessioncxx . . $ KSession#m_session.->setCodeccxx . . $ Konsole/Session#setCodec(ca93e7c01f42f36c).(codec);
199 }
200
201 void KSessioncxx . . $ KSession#::setHistorySizecxx . . $ KSession#setHistorySize(d4f767463ce0a6b3).(int lines)
202 {
203 if ( historySizecxx . . $ KSession#historySize(455f465bc33b4cdf).() != lines ) {
204 if (lines < 0)
205 m_sessioncxx . . $ KSession#m_session.->setHistoryTypecxx . . $ Konsole/Session#setHistoryType(8cdb70a5e6e0950).(HistoryTypeFilecxx . . $ Konsole/HistoryTypeFile#HistoryTypeFile(3520e46b33348bf6).());
206 else
207 m_sessioncxx . . $ KSession#m_session.->setHistoryTypecxx . . $ Konsole/Session#setHistoryType(8cdb70a5e6e0950).(HistoryTypeBuffercxx . . $ Konsole/HistoryTypeBuffer#(lines));
208 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! historySizeChangedcxx . . $ KSession#historySizeChanged(49f6e7a06ebc5aa8).();
209 }
210 }
211
212 int KSessioncxx . . $ KSession#::historySizecxx . . $ KSession#historySize(455f465bc33b4cdf).() const
213 {
214 if ( m_sessioncxx . . $ KSession#m_session.->historyTypecxx . . $ Konsole/Session#historyType(4823a4bab87d8bdc).().isUnlimitedcxx . . $ Konsole/HistoryType#isUnlimited(50ce9a9e25b4a850).() ) {
215 return -1;
216 } else {
217 return m_sessioncxx . . $ KSession#m_session.->historyTypecxx . . $ Konsole/Session#historyType(4823a4bab87d8bdc).().maximumLineCountcxx . . $ Konsole/HistoryType#maximumLineCount(455f465bc33b4cdf).();
218 }
219 }
220
221 QStringcxx . . $ QString# KSessioncxx . . $ KSession#::getHistorycxx . . $ KSession#getHistory(6ef7b6c27b00b43d).() const
222 {
223 QStringcxx . . $ QString# historycxx . . $ QString#QString(ced63f7c635d850d).;
224 QTextStreamcxx . . $ QTextStream# historyStreamcxx . . $ QTextStream#QTextStream(16e3d097052a73db).(&history);
225 PlainTextDecodercxx . . $ Konsole/PlainTextDecoder# historyDecodercxx . . $ Konsole/PlainTextDecoder#PlainTextDecoder(49f6e7a06ebc5aa8).;
226
227 historyDecoder.begincxx . . $ Konsole/PlainTextDecoder#begin(aca783e314870a73).(&historyStream);
228 m_sessioncxx . . $ KSession#m_session.->emulationcxx . . $ Konsole/Session#emulation(6c49a54d02df9d82).()->writeToStreamcxx . . $ Konsole/Emulation#writeToStream(fdbc605265f4e834).(&historyDecoder);
229 historyDecoder.endcxx . . $ Konsole/PlainTextDecoder#end(49f6e7a06ebc5aa8).();
230
231 return historycxx . . $ QString#QString(28715ad661ad3cec).;
232 }
233
234 void KSessioncxx . . $ KSession#::sendTextcxx . . $ KSession#sendText(7df51288a9ebd664).(QStringcxx . . $ QString# text)
235 {
236 m_sessioncxx . . $ KSession#m_session.->sendTextcxx . . $ Konsole/Session#sendText(7fba01612ab56717).(text);
237 }
238
239 void KSessioncxx . . $ KSession#::sendKeycxx . . $ KSession#sendKey(6ad14a2cad9708b7).(int rep, int key, int mod) const
240 {
241 //TODO implement or remove this function.
242 // Qt::KeyboardModifier kbm = Qt::KeyboardModifier(mod);
243
244 // QKeyEvent qkey(QEvent::KeyPress, key, kbm);
245
246 // while (rep > 0){
247 // m_session->sendKey(&qkey);
248 // --rep;
249 // }
250 }
251
252 void KSessioncxx . . $ KSession#::clearScreencxx . . $ KSession#clearScreen(49f6e7a06ebc5aa8).()
253 {
254 m_sessioncxx . . $ KSession#m_session.->emulationcxx . . $ Konsole/Session#emulation(6c49a54d02df9d82).()->clearEntireScreencxx . . $ Konsole/Emulation#clearEntireScreen(49f6e7a06ebc5aa8).();
255 }
256
257 void KSessioncxx . . $ KSession#::searchcxx . . $ KSession#search(7ae16150a604556).(const QStringcxx . . $ QString# &regexp, int startLine, int startColumn, bool forwards)
258 {
259 HistorySearchcxx . . $ HistorySearch# *history = new HistorySearchcxx . . $ HistorySearch#( QPointercxx . . $ QPointer#<Emulationcxx . . $ Konsole/Emulation#>(m_sessioncxx . . $ KSession#m_session.->emulationcxx . . $ Konsole/Session#emulation(6c49a54d02df9d82).()), QRegExpcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).(regexp), forwards, startColumn, startLine, this);
260 connectcxx . . $ QObject#connect(158df1d9a01a3410).( history, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(matchFound(int,int,int,int)), this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(matchFound(int,int,int,int)));
261 connectcxx . . $ QObject#connect(158df1d9a01a3410).( history, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(noMatchFound()), this, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(noMatchFound()));
262 history->searchcxx . . $ HistorySearch#search(49f6e7a06ebc5aa8).();
263 }
264
265 void KSessioncxx . . $ KSession#::setFlowControlEnabledcxx . . $ KSession#setFlowControlEnabled(b45ddcbc8423892c).(bool enabled)
266 {
267 m_sessioncxx . . $ KSession#m_session.->setFlowControlEnabledcxx . . $ Konsole/Session#setFlowControlEnabled(b45ddcbc8423892c).(enabled);
268 }
269
270 bool KSessioncxx . . $ KSession#::flowControlEnabledcxx . . $ KSession#flowControlEnabled(c9857a73d68e59ba).()
271 {
272 return m_sessioncxx . . $ KSession#m_session.->flowControlEnabledcxx . . $ Konsole/Session#flowControlEnabled(50ce9a9e25b4a850).();
273 }
274
275 void KSessioncxx . . $ KSession#::setKeyBindingscxx . . $ KSession#setKeyBindings(3520e46b33348bf6).(const QStringcxx . . $ QString# &kb)
276 {
277 m_sessioncxx . . $ KSession#m_session.->setKeyBindingscxx . . $ Konsole/Session#setKeyBindings(3520e46b33348bf6).(kb);
278 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! changedKeyBindingscxx . . $ KSession#changedKeyBindings(7df51288a9ebd664).(kbcxx . . $ QString#QString(132dd6869045752b).);
279 }
280
281 QStringcxx . . $ QString# KSessioncxx . . $ KSession#::getKeyBindingscxx . . $ KSession#getKeyBindings(4365c3963150523e).()
282 {
283 return m_sessioncxx . . $ KSession#m_session.->keyBindingscxx . . $ Konsole/Session#keyBindings(6ef7b6c27b00b43d).();
284 }
285
286 QStringListcxx . . $ QStringList# KSessioncxx . . $ KSession#::availableKeyBindingscxx . . $ KSession#availableKeyBindings(669a05bc42dd57cc).()
287 {
288 return KeyboardTranslatorManagercxx . . $ QStringList#QStringList(6fe09f9fe6e0f503).::instancecxx . . $ Konsole/KeyboardTranslatorManager#instance(c68e8ff900e8f73d).()->allTranslatorscxx . . $ Konsole/KeyboardTranslatorManager#allTranslators(346f0183abd8f69).();
289 }
290
291 QStringcxx . . $ QString# KSessioncxx . . $ KSession#::keyBindingscxx . . $ KSession#keyBindings(4365c3963150523e).()
292 {
293 return m_sessioncxx . . $ KSession#m_session.->keyBindingscxx . . $ Konsole/Session#keyBindings(6ef7b6c27b00b43d).();
294 }
295
296 QStringcxx . . $ QString# KSessioncxx . . $ KSession#::getTitlecxx . . $ KSession#getTitle(4365c3963150523e).()
297 {
298 return m_sessioncxx . . $ KSession#m_session.->userTitlecxx . . $ Konsole/Session#userTitle(6ef7b6c27b00b43d).();
299 }
300
301 bool KSessioncxx . . $ KSession#::hasActiveProcesscxx . . $ KSession#hasActiveProcess(50ce9a9e25b4a850).() const
302 {
303 return m_sessioncxx . . $ KSession#m_session.->processIdcxx . . $ Konsole/Session#processId(455f465bc33b4cdf).() != m_sessioncxx . . $ KSession#m_session.->foregroundProcessIdcxx . . $ Konsole/Session#foregroundProcessId(455f465bc33b4cdf).();
304 }
305
306 QStringcxx . . $ QString# KSessioncxx . . $ KSession#::foregroundProcessNamecxx . . $ KSession#foregroundProcessName(4365c3963150523e).()
307 {
308 return m_sessioncxx . . $ KSession#m_session.->foregroundProcessNamecxx . . $ Konsole/Session#foregroundProcessName(4365c3963150523e).();
309 }
310
311 QStringcxx . . $ QString# KSessioncxx . . $ KSession#::currentDircxx . . $ KSession#currentDir(4365c3963150523e).()
312 {
313 return m_sessioncxx . . $ KSession#m_session.->currentDircxx . . $ Konsole/Session#currentDir(4365c3963150523e).();
314 }