Debian Codegraph @

src/ksession.h

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 #ifndef KSESSION_H
24 #define KSESSION_H
25
26 #include <QObject>
27
28 // Konsole
29 #include "Session.h"
30 //#include "TerminalDisplay.h"
31
32 using namespace Konsole;
33
34 class KSession : public QObject
35 {
36 Q_OBJECT
37 Q_PROPERTY(QString kbScheme READ getKeyBindings WRITE setKeyBindings NOTIFY changedKeyBindings)
38 Q_PROPERTY(QString initialWorkingDirectory READ getInitialWorkingDirectory WRITE setInitialWorkingDirectory NOTIFY initialWorkingDirectoryChanged)
39 Q_PROPERTY(QString title READ getTitle WRITE setTitle NOTIFY titleChanged)
40 Q_PROPERTY(QString shellProgram WRITE setShellProgram)
41 Q_PROPERTY(QStringList shellProgramArgs WRITE setArgs)
42 Q_PROPERTY(QString history READ getHistory)
43 Q_PROPERTY(bool hasActiveProcess READ hasActiveProcess)
44 Q_PROPERTY(QString foregroundProcessName READ foregroundProcessName)
45 Q_PROPERTY(QString currentDir READ currentDir)
46
47 public:
48 KSession(QObject *parent = 0);
49 ~KSession();
50
51 public:
52 //bool setup();
53 void addView(TerminalDisplay *display);
54 void removeView(TerminalDisplay *display);
55
56 int getRandomSeed();
57 QString getKeyBindings();
58
59 //look-n-feel, if you don`t like defaults
60
61 //environment
62 void setEnvironment(const QStringList & environment);
63
64 //Initial working directory
65 void setInitialWorkingDirectory(const QString & dir);
66 QString getInitialWorkingDirectory();
67
68 //Text codec, default is UTF-8
69 void setTextCodec(QTextCodec * codec);
70
71 // History size for scrolling
72 void setHistorySize(int lines); //infinite if lines < 0
73 int historySize() const;
74
75 QString getHistory() const;
76
77 // Sets whether flow control is enabled
78 void setFlowControlEnabled(bool enabled);
79
80 // Returns whether flow control is enabled
81 bool flowControlEnabled(void);
82
83 /**
84 * Sets whether the flow control warning box should be shown
85 * when the flow control stop key (Ctrl+S) is pressed.
86 */
87 //void setFlowControlWarningEnabled(bool enabled);
88
89 /*! Get all available keyboard bindings
90 */
91 static QStringList availableKeyBindings();
92
93 //! Return current key bindings
94 QString keyBindings();
95
96 QString getTitle();
97
98 /**
99 * Returns \c true if the session has an active subprocess running in it
100 * spawned from the initial shell.
101 */
102 bool hasActiveProcess() const;
103
104 /**
105 * Returns the name of the terminal's foreground process.
106 */
107 QString foregroundProcessName();
108
109 /**
110 * Returns the current working directory of the process.
111 */
112 QString currentDir();
113
114 signals:
115 void started();
116 void finished();
117 void copyAvailable(bool);
118
119 void termGetFocus();
120 void termLostFocus();
121
122 void termKeyPressed(QKeyEvent *, bool);
123
124 void changedKeyBindings(QString kb);
125
126 void titleChanged();
127
128 void historySizeChanged();
129
130 void initialWorkingDirectoryChanged();
131
132 void matchFound(int startColumn, int startLine, int endColumn, int endLine);
133 void noMatchFound();
134
135 public slots:
136 /*! Set named key binding for given widget
137 */
138 void setKeyBindings(const QString & kb);
139 void setTitle(QString name);
140
141 void startShellProgram();
142
143 bool sendSignal(int signal);
144
145 // Shell program, default is /bin/bash
146 void setShellProgram(const QString & progname);
147
148 // Shell program args, default is none
149 void setArgs(const QStringList &args);
150
151 int getShellPID();
152 void changeDir(const QString & dir);
153
154 // Send some text to terminal
155 void sendText(QString text);
156 // Send some text to terminal
157 void sendKey(int rep, int key, int mod) const;
158
159 void clearScreen();
160
161 // Search history
162 void search(const QString &regexp, int startLine = 0, int startColumn = 0, bool forwards = true );
163
164 protected slots:
165 void sessionFinished();
166 void selectionChanged(bool textSelected);
167
168 private slots:
169 Session* createSession(QString name);
170 //Konsole::KTerminalDisplay* createTerminalDisplay(Konsole::Session *session, QQuickItem* parent);
171
172 private:
173 //Konsole::KTerminalDisplay *m_terminalDisplay;
174 QString _initialWorkingDirectory;
175 Session *m_session;
176
177 };
178
179 #endif // KSESSION_H