• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Konsole

  • kde-4.14
  • applications
  • konsole
  • src
Session.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Konsole
3 
4  Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
5  Copyright 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
6  Copyright 2009 by Thomas Dreibholz <dreibh@iem.uni-due.de>
7 
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301 USA.
22 */
23 
24 // Own
25 #include "Session.h"
26 
27 // Standard
28 #include <stdlib.h>
29 #include <signal.h>
30 #include <unistd.h>
31 
32 // Qt
33 #include <QApplication>
34 #include <QtGui/QColor>
35 #include <QtCore/QDir>
36 #include <QtCore/QFile>
37 #include <QtCore/QStringList>
38 #include <QtDBus/QtDBus>
39 
40 // KDE
41 #include <KDebug>
42 #include <KLocalizedString>
43 #include <KNotification>
44 #include <KRun>
45 #include <KShell>
46 #include <KProcess>
47 #include <KStandardDirs>
48 #include <KConfigGroup>
49 
50 // Konsole
51 #include <sessionadaptor.h>
52 
53 #include "ProcessInfo.h"
54 #include "Pty.h"
55 #include "TerminalDisplay.h"
56 #include "ShellCommand.h"
57 #include "Vt102Emulation.h"
58 #include "ZModemDialog.h"
59 #include "History.h"
60 
61 using namespace Konsole;
62 
63 int Session::lastSessionId = 0;
64 
65 // HACK This is copied out of QUuid::createUuid with reseeding forced.
66 // Required because color schemes repeatedly seed the RNG...
67 // ...with a constant.
68 QUuid createUuid()
69 {
70  static const int intbits = sizeof(int) * 8;
71  static int randbits = 0;
72  if (!randbits) {
73  int max = RAND_MAX;
74  do {
75  ++randbits;
76  } while ((max = max >> 1));
77  }
78 
79  qsrand(uint(QDateTime::currentDateTime().toTime_t()));
80  qrand(); // Skip first
81 
82  QUuid result;
83  uint* data = &(result.data1);
84  int chunks = 16 / sizeof(uint);
85  while (chunks--) {
86  uint randNumber = 0;
87  for (int filled = 0; filled < intbits; filled += randbits)
88  randNumber |= qrand() << filled;
89  *(data + chunks) = randNumber;
90  }
91 
92  result.data4[0] = (result.data4[0] & 0x3F) | 0x80; // UV_DCE
93  result.data3 = (result.data3 & 0x0FFF) | 0x4000; // UV_Random
94 
95  return result;
96 }
97 
98 Session::Session(QObject* parent) :
99  QObject(parent)
100  , _shellProcess(0)
101  , _emulation(0)
102  , _monitorActivity(false)
103  , _monitorSilence(false)
104  , _notifiedActivity(false)
105  , _silenceSeconds(10)
106  , _autoClose(true)
107  , _closePerUserRequest(false)
108  , _addToUtmp(true)
109  , _flowControlEnabled(true)
110  , _sessionId(0)
111  , _sessionProcessInfo(0)
112  , _foregroundProcessInfo(0)
113  , _foregroundPid(0)
114  , _zmodemBusy(false)
115  , _zmodemProc(0)
116  , _zmodemProgress(0)
117  , _hasDarkBackground(false)
118 {
119  _uniqueIdentifier = createUuid();
120 
121  //prepare DBus communication
122  new SessionAdaptor(this);
123  _sessionId = ++lastSessionId;
124  QDBusConnection::sessionBus().registerObject(QLatin1String("/Sessions/") + QString::number(_sessionId), this);
125 
126  //create emulation backend
127  _emulation = new Vt102Emulation();
128 
129  connect(_emulation, SIGNAL(titleChanged(int,QString)),
130  this, SLOT(setUserTitle(int,QString)));
131  connect(_emulation, SIGNAL(stateSet(int)),
132  this, SLOT(activityStateSet(int)));
133  connect(_emulation, SIGNAL(zmodemDetected()),
134  this, SLOT(fireZModemDetected()));
135  connect(_emulation, SIGNAL(changeTabTextColorRequest(int)),
136  this, SIGNAL(changeTabTextColorRequest(int)));
137  connect(_emulation, SIGNAL(profileChangeCommandReceived(QString)),
138  this, SIGNAL(profileChangeCommandReceived(QString)));
139  connect(_emulation, SIGNAL(flowControlKeyPressed(bool)),
140  this, SLOT(updateFlowControlState(bool)));
141  connect(_emulation, SIGNAL(primaryScreenInUse(bool)),
142  this, SLOT(onPrimaryScreenInUse(bool)));
143  connect(_emulation, SIGNAL(selectionChanged(QString)),
144  this, SIGNAL(selectionChanged(QString)));
145  connect(_emulation, SIGNAL(imageResizeRequest(QSize)),
146  this, SIGNAL(resizeRequest(QSize)));
147 
148  //create new teletype for I/O with shell process
149  openTeletype(-1);
150 
151  //setup timer for monitoring session activity & silence
152  _silenceTimer = new QTimer(this);
153  _silenceTimer->setSingleShot(true);
154  connect(_silenceTimer, SIGNAL(timeout()), this, SLOT(silenceTimerDone()));
155 
156  _activityTimer = new QTimer(this);
157  _activityTimer->setSingleShot(true);
158  connect(_activityTimer, SIGNAL(timeout()), this, SLOT(activityTimerDone()));
159 }
160 
161 Session::~Session()
162 {
163  delete _foregroundProcessInfo;
164  delete _sessionProcessInfo;
165  delete _emulation;
166  delete _shellProcess;
167  delete _zmodemProc;
168 }
169 
170 void Session::openTeletype(int fd)
171 {
172  if (isRunning()) {
173  kWarning() << "Attempted to open teletype in a running session.";
174  return;
175  }
176 
177  delete _shellProcess;
178 
179  if (fd < 0)
180  _shellProcess = new Pty();
181  else
182  _shellProcess = new Pty(fd);
183 
184  _shellProcess->setUtf8Mode(_emulation->utf8());
185 
186  // connect the I/O between emulator and pty process
187  connect(_shellProcess, SIGNAL(receivedData(const char*,int)),
188  this, SLOT(onReceiveBlock(const char*,int)));
189  connect(_emulation, SIGNAL(sendData(const char*,int)),
190  _shellProcess, SLOT(sendData(const char*,int)));
191 
192  // UTF8 mode
193  connect(_emulation, SIGNAL(useUtf8Request(bool)),
194  _shellProcess, SLOT(setUtf8Mode(bool)));
195 
196  // get notified when the pty process is finished
197  connect(_shellProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
198  this, SLOT(done(int,QProcess::ExitStatus)));
199 
200  // emulator size
201  connect(_emulation, SIGNAL(imageSizeChanged(int,int)),
202  this, SLOT(updateWindowSize(int,int)));
203  connect(_emulation, SIGNAL(imageSizeInitialized()),
204  this, SLOT(run()));
205 }
206 
207 WId Session::windowId() const
208 {
209  // Returns a window ID for this session which is used
210  // to set the WINDOWID environment variable in the shell
211  // process.
212  //
213  // Sessions can have multiple views or no views, which means
214  // that a single ID is not always going to be accurate.
215  //
216  // If there are no views, the window ID is just 0. If
217  // there are multiple views, then the window ID for the
218  // top-level window which contains the first view is
219  // returned
220 
221  if (_views.count() == 0) {
222  return 0;
223  } else {
224  QWidget* window = _views.first();
225 
226  Q_ASSERT(window);
227 
228  while (window->parentWidget() != 0)
229  window = window->parentWidget();
230 
231  return window->winId();
232  }
233 }
234 
235 void Session::setDarkBackground(bool darkBackground)
236 {
237  _hasDarkBackground = darkBackground;
238 }
239 
240 bool Session::isRunning() const
241 {
242  return _shellProcess && (_shellProcess->state() == QProcess::Running);
243 }
244 
245 void Session::setCodec(QTextCodec* codec)
246 {
247  emulation()->setCodec(codec);
248 }
249 
250 bool Session::setCodec(QByteArray name)
251 {
252  QTextCodec* codec = QTextCodec::codecForName(name);
253 
254  if (codec) {
255  setCodec(codec);
256  return true;
257  } else {
258  return false;
259  }
260 }
261 
262 QByteArray Session::codec()
263 {
264  return _emulation->codec()->name();
265 }
266 
267 void Session::setProgram(const QString& program)
268 {
269  _program = ShellCommand::expand(program);
270 }
271 
272 void Session::setArguments(const QStringList& arguments)
273 {
274  _arguments = ShellCommand::expand(arguments);
275 }
276 
277 void Session::setInitialWorkingDirectory(const QString& dir)
278 {
279  _initialWorkingDir = KShell::tildeExpand(ShellCommand::expand(dir));
280 }
281 
282 QString Session::currentWorkingDirectory()
283 {
284  // only returned cached value
285  if (_currentWorkingDir.isEmpty())
286  updateWorkingDirectory();
287 
288  return _currentWorkingDir;
289 }
290 ProcessInfo* Session::updateWorkingDirectory()
291 {
292  updateSessionProcessInfo();
293 
294  const QString currentDir = _sessionProcessInfo->validCurrentDir();
295  if (currentDir != _currentWorkingDir) {
296  _currentWorkingDir = currentDir;
297  emit currentDirectoryChanged(_currentWorkingDir);
298  }
299 
300  return 0; // not used - for BIC in KDE 4.14.x
301 }
302 
303 QList<TerminalDisplay*> Session::views() const
304 {
305  return _views;
306 }
307 
308 void Session::addView(TerminalDisplay* widget)
309 {
310  Q_ASSERT(!_views.contains(widget));
311 
312  _views.append(widget);
313 
314  // connect emulation - view signals and slots
315  connect(widget, SIGNAL(keyPressedSignal(QKeyEvent*)),
316  _emulation, SLOT(sendKeyEvent(QKeyEvent*)));
317  connect(widget, SIGNAL(mouseSignal(int,int,int,int)),
318  _emulation, SLOT(sendMouseEvent(int,int,int,int)));
319  connect(widget, SIGNAL(sendStringToEmu(const char*)),
320  _emulation, SLOT(sendString(const char*)));
321 
322  // allow emulation to notify view when the foreground process
323  // indicates whether or not it is interested in mouse signals
324  connect(_emulation, SIGNAL(programUsesMouseChanged(bool)),
325  widget, SLOT(setUsesMouse(bool)));
326 
327  widget->setUsesMouse(_emulation->programUsesMouse());
328 
329  connect(_emulation, SIGNAL(programBracketedPasteModeChanged(bool)),
330  widget, SLOT(setBracketedPasteMode(bool)));
331 
332  widget->setBracketedPasteMode(_emulation->programBracketedPasteMode());
333 
334  widget->setScreenWindow(_emulation->createWindow());
335 
336  //connect view signals and slots
337  connect(widget, SIGNAL(changedContentSizeSignal(int,int)),
338  this, SLOT(onViewSizeChange(int,int)));
339 
340  connect(widget, SIGNAL(destroyed(QObject*)),
341  this, SLOT(viewDestroyed(QObject*)));
342 }
343 
344 void Session::viewDestroyed(QObject* view)
345 {
346  // the received QObject has already been destroyed, so using
347  // qobject_cast<> does not work here
348  TerminalDisplay* display = static_cast<TerminalDisplay*>(view);
349 
350  Q_ASSERT(_views.contains(display));
351 
352  removeView(display);
353 }
354 
355 void Session::removeView(TerminalDisplay* widget)
356 {
357  _views.removeAll(widget);
358 
359  disconnect(widget, 0, this, 0);
360 
361  // disconnect
362  // - key presses signals from widget
363  // - mouse activity signals from widget
364  // - string sending signals from widget
365  //
366  // ... and any other signals connected in addView()
367  disconnect(widget, 0, _emulation, 0);
368 
369  // disconnect state change signals emitted by emulation
370  disconnect(_emulation, 0, widget, 0);
371 
372  // close the session automatically when the last view is removed
373  if (_views.count() == 0) {
374  close();
375  }
376 }
377 
378 // Upon a KPty error, there is no description on what that error was...
379 // Check to see if the given program is executable.
380 QString Session::checkProgram(const QString& program)
381 {
382  QString exec = program;
383 
384  if (exec.isEmpty())
385  return QString();
386 
387  QFileInfo info(exec);
388  if (info.isAbsolute() && info.exists() && info.isExecutable()) {
389  return exec;
390  }
391 
392  exec = KRun::binaryName(exec, false);
393  exec = KShell::tildeExpand(exec);
394  QString pexec = KStandardDirs::findExe(exec);
395  if (pexec.isEmpty()) {
396  kError() << i18n("Could not find binary: ") << exec;
397  return QString();
398  }
399 
400  return exec;
401 }
402 
403 void Session::terminalWarning(const QString& message)
404 {
405  static const QByteArray warningText = i18nc("@info:shell Alert the user with red color text", "Warning: ").toLocal8Bit();
406  QByteArray messageText = message.toLocal8Bit();
407 
408  static const char redPenOn[] = "\033[1m\033[31m";
409  static const char redPenOff[] = "\033[0m";
410 
411  _emulation->receiveData(redPenOn, qstrlen(redPenOn));
412  _emulation->receiveData("\n\r\n\r", 4);
413  _emulation->receiveData(warningText.constData(), qstrlen(warningText.constData()));
414  _emulation->receiveData(messageText.constData(), qstrlen(messageText.constData()));
415  _emulation->receiveData("\n\r\n\r", 4);
416  _emulation->receiveData(redPenOff, qstrlen(redPenOff));
417 }
418 
419 QString Session::shellSessionId() const
420 {
421  QString friendlyUuid(_uniqueIdentifier.toString());
422  friendlyUuid.remove('-').remove('{').remove('}');
423 
424  return friendlyUuid;
425 }
426 
427 void Session::run()
428 {
429  // extra safeguard for potential bug.
430  if (isRunning()) {
431  kWarning() << "Attempted to re-run an already running session.";
432  return;
433  }
434 
435  //check that everything is in place to run the session
436  if (_program.isEmpty()) {
437  kWarning() << "Program to run not set.";
438  }
439  if (_arguments.isEmpty()) {
440  kWarning() << "No command line arguments specified.";
441  }
442  if (_uniqueIdentifier.isNull()) {
443  _uniqueIdentifier = createUuid();
444  }
445 
446  const int CHOICE_COUNT = 3;
447  // if '_program' is empty , fall back to default shell. If that is not set
448  // then fall back to /bin/sh
449 #ifndef _WIN32
450  QString programs[CHOICE_COUNT] = {_program, qgetenv("SHELL"), "/bin/sh"};
451 #else
452  // on windows, fall back to %COMSPEC% or to cmd.exe
453  QString programs[CHOICE_COUNT] = {_program, qgetenv("COMSPEC"), "cmd.exe"};
454 #endif
455  QString exec;
456  int choice = 0;
457  while (choice < CHOICE_COUNT) {
458  exec = checkProgram(programs[choice]);
459  if (exec.isEmpty())
460  choice++;
461  else
462  break;
463  }
464 
465  // if a program was specified via setProgram(), but it couldn't be found, print a warning
466  if (choice != 0 && choice < CHOICE_COUNT && !_program.isEmpty()) {
467  terminalWarning(i18n("Could not find '%1', starting '%2' instead. Please check your profile settings.", _program, exec));
468  // if none of the choices are available, print a warning
469  } else if (choice == CHOICE_COUNT) {
470  terminalWarning(i18n("Could not find an interactive shell to start."));
471  return;
472  }
473 
474  // if no arguments are specified, fall back to program name
475  QStringList arguments = _arguments.join(QChar(' ')).isEmpty() ?
476  QStringList() << exec :
477  _arguments;
478 
479  if (!_initialWorkingDir.isEmpty()) {
480  _shellProcess->setInitialWorkingDirectory(_initialWorkingDir);
481  } else {
482  _shellProcess->setInitialWorkingDirectory(QDir::currentPath());
483  }
484 
485  _shellProcess->setFlowControlEnabled(_flowControlEnabled);
486  _shellProcess->setEraseChar(_emulation->eraseChar());
487  _shellProcess->setUseUtmp(_addToUtmp);
488 
489  // this is not strictly accurate use of the COLORFGBG variable. This does not
490  // tell the terminal exactly which colors are being used, but instead approximates
491  // the color scheme as "black on white" or "white on black" depending on whether
492  // the background color is deemed dark or not
493  const QString backgroundColorHint = _hasDarkBackground ? "COLORFGBG=15;0" : "COLORFGBG=0;15";
494  addEnvironmentEntry(backgroundColorHint);
495 
496  addEnvironmentEntry(QString("SHELL_SESSION_ID=%1").arg(shellSessionId()));
497 
498  addEnvironmentEntry(QString("WINDOWID=%1").arg(QString::number(windowId())));
499 
500  const QString dbusService = QDBusConnection::sessionBus().baseService();
501  addEnvironmentEntry(QString("KONSOLE_DBUS_SERVICE=%1").arg(dbusService));
502 
503  const QString dbusObject = QString("/Sessions/%1").arg(QString::number(_sessionId));
504  addEnvironmentEntry(QString("KONSOLE_DBUS_SESSION=%1").arg(dbusObject));
505 
506  int result = _shellProcess->start(exec, arguments, _environment);
507  if (result < 0) {
508  terminalWarning(i18n("Could not start program '%1' with arguments '%2'.", exec, arguments.join(" ")));
509  terminalWarning(_shellProcess->errorString());
510  return;
511  }
512 
513  _shellProcess->setWriteable(false); // We are reachable via kwrited.
514 
515  emit started();
516 }
517 
518 void Session::setUserTitle(int what, const QString& caption)
519 {
520  //set to true if anything is actually changed (eg. old _nameTitle != new _nameTitle )
521  bool modified = false;
522 
523  if ((what == IconNameAndWindowTitle) || (what == WindowTitle)) {
524  if (_userTitle != caption) {
525  _userTitle = caption;
526  modified = true;
527  }
528  }
529 
530  if ((what == IconNameAndWindowTitle) || (what == IconName)) {
531  if (_iconText != caption) {
532  _iconText = caption;
533  modified = true;
534  }
535  }
536 
537  if (what == TextColor || what == BackgroundColor) {
538  QString colorString = caption.section(';', 0, 0);
539  QColor color = QColor(colorString);
540  if (color.isValid()) {
541  if (what == TextColor)
542  emit changeForegroundColorRequest(color);
543  else
544  emit changeBackgroundColorRequest(color);
545  }
546  }
547 
548  if (what == SessionName) {
549  if (_localTabTitleFormat != caption) {
550  _localTabTitleFormat = caption;
551  setTitle(Session::DisplayedTitleRole, caption);
552  modified = true;
553  }
554  }
555 
556  /* I don't believe this has ever worked in KDE 4.x
557  if (what == 31) {
558  QString cwd = caption;
559  cwd = cwd.replace(QRegExp("^~"), QDir::homePath());
560  emit openUrlRequest(cwd);
561  }*/
562 
563  /* The below use of 32 works but appears to non-standard.
564  It is from a commit from 2004 c20973eca8776f9b4f15bee5fdcb5a3205aa69de
565  */
566  // change icon via \033]32;Icon\007
567  if (what == SessionIcon) {
568  if (_iconName != caption) {
569  _iconName = caption;
570 
571  modified = true;
572  }
573  }
574 
575  if (what == ProfileChange) {
576  emit profileChangeCommandReceived(caption);
577  return;
578  }
579 
580  if (modified)
581  emit titleChanged();
582 }
583 
584 QString Session::userTitle() const
585 {
586  return _userTitle;
587 }
588 void Session::setTabTitleFormat(TabTitleContext context , const QString& format)
589 {
590  if (context == LocalTabTitle)
591  _localTabTitleFormat = format;
592  else if (context == RemoteTabTitle)
593  _remoteTabTitleFormat = format;
594 }
595 QString Session::tabTitleFormat(TabTitleContext context) const
596 {
597  if (context == LocalTabTitle)
598  return _localTabTitleFormat;
599  else if (context == RemoteTabTitle)
600  return _remoteTabTitleFormat;
601 
602  return QString();
603 }
604 
605 void Session::silenceTimerDone()
606 {
607  //FIXME: The idea here is that the notification popup will appear to tell the user than output from
608  //the terminal has stopped and the popup will disappear when the user activates the session.
609  //
610  //This breaks with the addition of multiple views of a session. The popup should disappear
611  //when any of the views of the session becomes active
612 
613  //FIXME: Make message text for this notification and the activity notification more descriptive.
614  if (_monitorSilence) {
615  KNotification::event("Silence", i18n("Silence in session '%1'", _nameTitle), QPixmap(),
616  QApplication::activeWindow(),
617  KNotification::CloseWhenWidgetActivated);
618  emit stateChanged(NOTIFYSILENCE);
619  } else {
620  emit stateChanged(NOTIFYNORMAL);
621  }
622 }
623 
624 void Session::activityTimerDone()
625 {
626  _notifiedActivity = false;
627 }
628 
629 void Session::updateFlowControlState(bool suspended)
630 {
631  if (suspended) {
632  if (flowControlEnabled()) {
633  foreach(TerminalDisplay * display, _views) {
634  if (display->flowControlWarningEnabled())
635  display->outputSuspended(true);
636  }
637  }
638  } else {
639  foreach(TerminalDisplay * display, _views) {
640  display->outputSuspended(false);
641  }
642  }
643 }
644 
645 void Session::onPrimaryScreenInUse(bool use)
646 {
647  emit primaryScreenInUse(use);
648 }
649 
650 void Session::activityStateSet(int state)
651 {
652  // TODO: should this hardcoded interval be user configurable?
653  const int activityMaskInSeconds = 15;
654 
655  if (state == NOTIFYBELL) {
656  emit bellRequest(i18n("Bell in session '%1'", _nameTitle));
657  } else if (state == NOTIFYACTIVITY) {
658  if (_monitorActivity && !_notifiedActivity) {
659  KNotification::event("Activity", i18n("Activity in session '%1'", _nameTitle), QPixmap(),
660  QApplication::activeWindow(),
661  KNotification::CloseWhenWidgetActivated);
662 
663  // mask activity notification for a while to avoid flooding
664  _notifiedActivity = true;
665  _activityTimer->start(activityMaskInSeconds * 1000);
666  }
667 
668  // reset the counter for monitoring continuous silence since there is activity
669  if (_monitorSilence) {
670  _silenceTimer->start(_silenceSeconds * 1000);
671  }
672  }
673 
674  if (state == NOTIFYACTIVITY && !_monitorActivity)
675  state = NOTIFYNORMAL;
676  if (state == NOTIFYSILENCE && !_monitorSilence)
677  state = NOTIFYNORMAL;
678 
679  emit stateChanged(state);
680 }
681 
682 void Session::onViewSizeChange(int /*height*/, int /*width*/)
683 {
684  updateTerminalSize();
685 }
686 
687 void Session::updateTerminalSize()
688 {
689  int minLines = -1;
690  int minColumns = -1;
691 
692  // minimum number of lines and columns that views require for
693  // their size to be taken into consideration ( to avoid problems
694  // with new view widgets which haven't yet been set to their correct size )
695  const int VIEW_LINES_THRESHOLD = 2;
696  const int VIEW_COLUMNS_THRESHOLD = 2;
697 
698  //select largest number of lines and columns that will fit in all visible views
699  foreach(TerminalDisplay* view, _views) {
700  if (view->isHidden() == false &&
701  view->lines() >= VIEW_LINES_THRESHOLD &&
702  view->columns() >= VIEW_COLUMNS_THRESHOLD) {
703  minLines = (minLines == -1) ? view->lines() : qMin(minLines , view->lines());
704  minColumns = (minColumns == -1) ? view->columns() : qMin(minColumns , view->columns());
705  view->processFilters();
706  }
707  }
708 
709  // backend emulation must have a _terminal of at least 1 column x 1 line in size
710  if (minLines > 0 && minColumns > 0) {
711  _emulation->setImageSize(minLines , minColumns);
712  }
713 }
714 void Session::updateWindowSize(int lines, int columns)
715 {
716  Q_ASSERT(lines > 0 && columns > 0);
717  _shellProcess->setWindowSize(columns, lines);
718 }
719 void Session::refresh()
720 {
721  // attempt to get the shell process to redraw the display
722  //
723  // this requires the program running in the shell
724  // to cooperate by sending an update in response to
725  // a window size change
726  //
727  // the window size is changed twice, first made slightly larger and then
728  // resized back to its normal size so that there is actually a change
729  // in the window size (some shells do nothing if the
730  // new and old sizes are the same)
731  //
732  // if there is a more 'correct' way to do this, please
733  // send an email with method or patches to konsole-devel@kde.org
734 
735  const QSize existingSize = _shellProcess->windowSize();
736  _shellProcess->setWindowSize(existingSize.width() + 1, existingSize.height());
737  usleep(500); // introduce small delay to avoid changing size too quickly
738  _shellProcess->setWindowSize(existingSize.width(), existingSize.height());
739 }
740 
741 void Session::sendSignal(int signal)
742 {
743  const ProcessInfo* process = getProcessInfo();
744  bool ok = false;
745  int pid;
746  pid = process->foregroundPid(&ok);
747 
748  if (ok) {
749  ::kill(pid, signal);
750  }
751 }
752 
753 bool Session::kill(int signal)
754 {
755  if (_shellProcess->pid() <= 0)
756  return false;
757 
758  int result = ::kill(_shellProcess->pid(), signal);
759 
760  if (result == 0) {
761  if (_shellProcess->waitForFinished(1000))
762  return true;
763  else
764  return false;
765  } else {
766  return false;
767  }
768 }
769 
770 void Session::close()
771 {
772  if (isRunning()) {
773  if (!closeInNormalWay())
774  closeInForceWay();
775  } else {
776  // terminal process has finished, just close the session
777  QTimer::singleShot(1, this, SIGNAL(finished()));
778  }
779 }
780 
781 bool Session::closeInNormalWay()
782 {
783  _autoClose = true;
784  _closePerUserRequest = true;
785 
786  // for the possible case where following events happen in sequence:
787  //
788  // 1). the terminal process crashes
789  // 2). the tab stays open and displays warning message
790  // 3). the user closes the tab explicitly
791  //
792  if (!isRunning()) {
793  emit finished();
794  return true;
795  }
796 
797  if (kill(SIGHUP)) {
798  return true;
799  } else {
800  kWarning() << "Process " << _shellProcess->pid() << " did not die with SIGHUP";
801  _shellProcess->closePty();
802  return (_shellProcess->waitForFinished(1000));
803  }
804 }
805 
806 bool Session::closeInForceWay()
807 {
808  _autoClose = true;
809  _closePerUserRequest = true;
810 
811  if (kill(SIGKILL)) {
812  return true;
813  } else {
814  kWarning() << "Process " << _shellProcess->pid() << " did not die with SIGKILL";
815  return false;
816  }
817 }
818 
819 void Session::sendText(const QString& text) const
820 {
821  _emulation->sendText(text);
822 }
823 
824 void Session::runCommand(const QString& command) const
825 {
826  _emulation->sendText(command + '\n');
827 }
828 
829 void Session::sendMouseEvent(int buttons, int column, int line, int eventType)
830 {
831  _emulation->sendMouseEvent(buttons, column, line, eventType);
832 }
833 
834 void Session::done(int exitCode, QProcess::ExitStatus exitStatus)
835 {
836  // This slot should be triggered only one time
837  disconnect(_shellProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
838  this, SLOT(done(int,QProcess::ExitStatus)));
839 
840  if (!_autoClose) {
841  _userTitle = i18nc("@info:shell This session is done", "Finished");
842  emit titleChanged();
843  return;
844  }
845 
846  if (_closePerUserRequest) {
847  emit finished();
848  return;
849  }
850 
851  QString message;
852 
853  if (exitCode != 0) {
854  if (exitStatus != QProcess::NormalExit)
855  message = i18n("Program '%1' crashed.", _program);
856  else
857  message = i18n("Program '%1' exited with status %2.", _program, exitCode);
858 
859  //FIXME: See comments in Session::silenceTimerDone()
860  KNotification::event("Finished", message , QPixmap(),
861  QApplication::activeWindow(),
862  KNotification::CloseWhenWidgetActivated);
863  }
864 
865  if (exitStatus != QProcess::NormalExit) {
866  // this seeming duplicated line is for the case when exitCode is 0
867  message = i18n("Program '%1' crashed.", _program);
868  terminalWarning(message);
869  } else {
870  emit finished();
871  }
872 }
873 
874 Emulation* Session::emulation() const
875 {
876  return _emulation;
877 }
878 
879 QString Session::keyBindings() const
880 {
881  return _emulation->keyBindings();
882 }
883 
884 QStringList Session::environment() const
885 {
886  return _environment;
887 }
888 
889 void Session::setEnvironment(const QStringList& environment)
890 {
891  _environment = environment;
892 }
893 
894 void Session::addEnvironmentEntry(const QString& entry)
895 {
896  _environment << entry;
897 }
898 
899 int Session::sessionId() const
900 {
901  return _sessionId;
902 }
903 
904 void Session::setKeyBindings(const QString& name)
905 {
906  _emulation->setKeyBindings(name);
907 }
908 
909 void Session::setTitle(TitleRole role , const QString& newTitle)
910 {
911  if (title(role) != newTitle) {
912  if (role == NameRole)
913  _nameTitle = newTitle;
914  else if (role == DisplayedTitleRole)
915  _displayTitle = newTitle;
916 
917  emit titleChanged();
918  }
919 }
920 
921 QString Session::title(TitleRole role) const
922 {
923  if (role == NameRole)
924  return _nameTitle;
925  else if (role == DisplayedTitleRole)
926  return _displayTitle;
927  else
928  return QString();
929 }
930 
931 ProcessInfo* Session::getProcessInfo()
932 {
933  ProcessInfo* process = 0;
934 
935  if (isForegroundProcessActive()) {
936  process = _foregroundProcessInfo;
937  } else {
938  updateSessionProcessInfo();
939  process = _sessionProcessInfo;
940  }
941 
942  return process;
943 }
944 
945 void Session::updateSessionProcessInfo()
946 {
947  Q_ASSERT(_shellProcess);
948 
949  bool ok;
950  // The checking for pid changing looks stupid, but it is needed
951  // at the moment to workaround the problem that processId() might
952  // return 0
953  if (!_sessionProcessInfo ||
954  (processId() != 0 && processId() != _sessionProcessInfo->pid(&ok))) {
955  delete _sessionProcessInfo;
956  _sessionProcessInfo = ProcessInfo::newInstance(processId());
957  _sessionProcessInfo->setUserHomeDir();
958  }
959  _sessionProcessInfo->update();
960 }
961 
962 bool Session::updateForegroundProcessInfo()
963 {
964  Q_ASSERT(_shellProcess);
965 
966  const int foregroundPid = _shellProcess->foregroundProcessGroup();
967  if (foregroundPid != _foregroundPid) {
968  delete _foregroundProcessInfo;
969  _foregroundProcessInfo = ProcessInfo::newInstance(foregroundPid);
970  _foregroundPid = foregroundPid;
971  }
972 
973  if (_foregroundProcessInfo) {
974  _foregroundProcessInfo->update();
975  return _foregroundProcessInfo->isValid();
976  } else {
977  return false;
978  }
979 }
980 
981 bool Session::isRemote()
982 {
983  ProcessInfo* process = getProcessInfo();
984 
985  bool ok = false;
986  return (process->name(&ok) == "ssh" && ok);
987 }
988 
989 QString Session::getDynamicTitle()
990 {
991  // update current directory from process
992  updateWorkingDirectory();
993  ProcessInfo* process = getProcessInfo();
994 
995  // format tab titles using process info
996  bool ok = false;
997  QString title;
998  if (process->name(&ok) == "ssh" && ok) {
999  SSHProcessInfo sshInfo(*process);
1000  title = sshInfo.format(tabTitleFormat(Session::RemoteTabTitle));
1001  } else {
1002  title = process->format(tabTitleFormat(Session::LocalTabTitle));
1003  }
1004 
1005  return title;
1006 }
1007 
1008 KUrl Session::getUrl()
1009 {
1010  QString path;
1011 
1012  updateSessionProcessInfo();
1013  if (_sessionProcessInfo->isValid()) {
1014  bool ok = false;
1015 
1016  // check if foreground process is bookmark-able
1017  if (isForegroundProcessActive()) {
1018  // for remote connections, save the user and host
1019  // bright ideas to get the directory at the other end are welcome :)
1020  if (_foregroundProcessInfo->name(&ok) == "ssh" && ok) {
1021  SSHProcessInfo sshInfo(*_foregroundProcessInfo);
1022 
1023  path = "ssh://" + sshInfo.userName() + '@' + sshInfo.host();
1024 
1025  QString port = sshInfo.port();
1026  if (!port.isEmpty() && port != "22") {
1027  path.append(':' + port);
1028  }
1029  } else {
1030  path = _foregroundProcessInfo->currentDir(&ok);
1031  if (!ok)
1032  path.clear();
1033  }
1034  } else { // otherwise use the current working directory of the shell process
1035  path = _sessionProcessInfo->currentDir(&ok);
1036  if (!ok)
1037  path.clear();
1038  }
1039  }
1040 
1041  return KUrl(path);
1042 }
1043 
1044 void Session::setIconName(const QString& iconName)
1045 {
1046  if (iconName != _iconName) {
1047  _iconName = iconName;
1048  emit titleChanged();
1049  }
1050 }
1051 
1052 void Session::setIconText(const QString& iconText)
1053 {
1054  _iconText = iconText;
1055 }
1056 
1057 QString Session::iconName() const
1058 {
1059  return _iconName;
1060 }
1061 
1062 QString Session::iconText() const
1063 {
1064  return _iconText;
1065 }
1066 
1067 void Session::setHistoryType(const HistoryType& hType)
1068 {
1069  _emulation->setHistory(hType);
1070 }
1071 
1072 const HistoryType& Session::historyType() const
1073 {
1074  return _emulation->history();
1075 }
1076 
1077 void Session::clearHistory()
1078 {
1079  _emulation->clearHistory();
1080 }
1081 
1082 QStringList Session::arguments() const
1083 {
1084  return _arguments;
1085 }
1086 
1087 QString Session::program() const
1088 {
1089  return _program;
1090 }
1091 
1092 bool Session::isMonitorActivity() const
1093 {
1094  return _monitorActivity;
1095 }
1096 bool Session::isMonitorSilence() const
1097 {
1098  return _monitorSilence;
1099 }
1100 
1101 void Session::setMonitorActivity(bool monitor)
1102 {
1103  if (_monitorActivity == monitor)
1104  return;
1105 
1106  _monitorActivity = monitor;
1107  _notifiedActivity = false;
1108 
1109  // This timer is meaningful only after activity has been notified
1110  _activityTimer->stop();
1111 
1112  activityStateSet(NOTIFYNORMAL);
1113 }
1114 
1115 void Session::setMonitorSilence(bool monitor)
1116 {
1117  if (_monitorSilence == monitor)
1118  return;
1119 
1120  _monitorSilence = monitor;
1121  if (_monitorSilence) {
1122  _silenceTimer->start(_silenceSeconds * 1000);
1123  } else {
1124  _silenceTimer->stop();
1125  }
1126 
1127  activityStateSet(NOTIFYNORMAL);
1128 }
1129 
1130 void Session::setMonitorSilenceSeconds(int seconds)
1131 {
1132  _silenceSeconds = seconds;
1133  if (_monitorSilence) {
1134  _silenceTimer->start(_silenceSeconds * 1000);
1135  }
1136 }
1137 
1138 void Session::setAddToUtmp(bool add)
1139 {
1140  _addToUtmp = add;
1141 }
1142 
1143 void Session::setAutoClose(bool close)
1144 {
1145  _autoClose = close;
1146 }
1147 
1148 bool Session::autoClose() const
1149 {
1150  return _autoClose;
1151 }
1152 
1153 void Session::setFlowControlEnabled(bool enabled)
1154 {
1155  _flowControlEnabled = enabled;
1156 
1157  if (_shellProcess)
1158  _shellProcess->setFlowControlEnabled(_flowControlEnabled);
1159 
1160  emit flowControlEnabledChanged(enabled);
1161 }
1162 bool Session::flowControlEnabled() const
1163 {
1164  if (_shellProcess)
1165  return _shellProcess->flowControlEnabled();
1166  else
1167  return _flowControlEnabled;
1168 }
1169 void Session::fireZModemDetected()
1170 {
1171  if (!_zmodemBusy) {
1172  QTimer::singleShot(10, this, SIGNAL(zmodemDetected()));
1173  _zmodemBusy = true;
1174  }
1175 }
1176 
1177 void Session::cancelZModem()
1178 {
1179  _shellProcess->sendData("\030\030\030\030", 4); // Abort
1180  _zmodemBusy = false;
1181 }
1182 
1183 void Session::startZModem(const QString& zmodem, const QString& dir, const QStringList& list)
1184 {
1185  _zmodemBusy = true;
1186  _zmodemProc = new KProcess();
1187  _zmodemProc->setOutputChannelMode(KProcess::SeparateChannels);
1188 
1189  *_zmodemProc << zmodem << "-v" << list;
1190 
1191  if (!dir.isEmpty())
1192  _zmodemProc->setWorkingDirectory(dir);
1193 
1194  connect(_zmodemProc, SIGNAL(readyReadStandardOutput()),
1195  this, SLOT(zmodemReadAndSendBlock()));
1196  connect(_zmodemProc, SIGNAL(readyReadStandardError()),
1197  this, SLOT(zmodemReadStatus()));
1198  connect(_zmodemProc, SIGNAL(finished(int,QProcess::ExitStatus)),
1199  this, SLOT(zmodemFinished()));
1200 
1201  _zmodemProc->start();
1202 
1203  disconnect(_shellProcess, SIGNAL(receivedData(const char*,int)),
1204  this, SLOT(onReceiveBlock(const char*,int)));
1205  connect(_shellProcess, SIGNAL(receivedData(const char*,int)),
1206  this, SLOT(zmodemReceiveBlock(const char*,int)));
1207 
1208  _zmodemProgress = new ZModemDialog(QApplication::activeWindow(), false,
1209  i18n("ZModem Progress"));
1210 
1211  connect(_zmodemProgress, SIGNAL(user1Clicked()),
1212  this, SLOT(zmodemFinished()));
1213 
1214  _zmodemProgress->show();
1215 }
1216 
1217 void Session::zmodemReadAndSendBlock()
1218 {
1219  _zmodemProc->setReadChannel(QProcess::StandardOutput);
1220  QByteArray data = _zmodemProc->readAll();
1221 
1222  if (data.count() == 0)
1223  return;
1224 
1225  _shellProcess->sendData(data.constData(), data.count());
1226 }
1227 
1228 void Session::zmodemReadStatus()
1229 {
1230  _zmodemProc->setReadChannel(QProcess::StandardError);
1231  QByteArray msg = _zmodemProc->readAll();
1232  while (!msg.isEmpty()) {
1233  int i = msg.indexOf('\015');
1234  int j = msg.indexOf('\012');
1235  QByteArray txt;
1236  if ((i != -1) && ((j == -1) || (i < j))) {
1237  msg = msg.mid(i + 1);
1238  } else if (j != -1) {
1239  txt = msg.left(j);
1240  msg = msg.mid(j + 1);
1241  } else {
1242  txt = msg;
1243  msg.truncate(0);
1244  }
1245  if (!txt.isEmpty())
1246  _zmodemProgress->addProgressText(QString::fromLocal8Bit(txt));
1247  }
1248 }
1249 
1250 void Session::zmodemReceiveBlock(const char* data, int len)
1251 {
1252  QByteArray bytes(data, len);
1253 
1254  _zmodemProc->write(bytes);
1255 }
1256 
1257 void Session::zmodemFinished()
1258 {
1259  /* zmodemFinished() is called by QProcess's finished() and
1260  ZModemDialog's user1Clicked(). Therefore, an invocation by
1261  user1Clicked() will recursively invoke this function again
1262  when the KProcess is deleted! */
1263  if (_zmodemProc) {
1264  KProcess* process = _zmodemProc;
1265  _zmodemProc = 0; // Set _zmodemProc to 0 avoid recursive invocations!
1266  _zmodemBusy = false;
1267  delete process; // Now, the KProcess may be disposed safely.
1268 
1269  disconnect(_shellProcess, SIGNAL(receivedData(const char*,int)),
1270  this , SLOT(zmodemReceiveBlock(const char*,int)));
1271  connect(_shellProcess, SIGNAL(receivedData(const char*,int)),
1272  this, SLOT(onReceiveBlock(const char*,int)));
1273 
1274  _shellProcess->sendData("\030\030\030\030", 4); // Abort
1275  _shellProcess->sendData("\001\013\n", 3); // Try to get prompt back
1276  _zmodemProgress->transferDone();
1277  }
1278 }
1279 
1280 void Session::onReceiveBlock(const char* buf, int len)
1281 {
1282  _emulation->receiveData(buf, len);
1283 }
1284 
1285 QSize Session::size()
1286 {
1287  return _emulation->imageSize();
1288 }
1289 
1290 void Session::setSize(const QSize& size)
1291 {
1292  if ((size.width() <= 1) || (size.height() <= 1))
1293  return;
1294 
1295  emit resizeRequest(size);
1296 }
1297 
1298 QSize Session::preferredSize() const
1299 {
1300  return _preferredSize;
1301 }
1302 
1303 void Session::setPreferredSize(const QSize& size)
1304 {
1305  _preferredSize = size;
1306 }
1307 
1308 int Session::processId() const
1309 {
1310  return _shellProcess->pid();
1311 }
1312 
1313 void Session::setTitle(int role , const QString& title)
1314 {
1315  switch (role) {
1316  case 0:
1317  this->setTitle(Session::NameRole, title);
1318  break;
1319  case 1:
1320  this->setTitle(Session::DisplayedTitleRole, title);
1321 
1322  // without these, that title will be overridden by the expansion of
1323  // title format shortly after, which will confuses users.
1324  _localTabTitleFormat = title;
1325  _remoteTabTitleFormat = title;
1326 
1327  break;
1328  }
1329 }
1330 
1331 QString Session::title(int role) const
1332 {
1333  switch (role) {
1334  case 0:
1335  return this->title(Session::NameRole);
1336  case 1:
1337  return this->title(Session::DisplayedTitleRole);
1338  default:
1339  return QString();
1340  }
1341 }
1342 
1343 void Session::setTabTitleFormat(int context , const QString& format)
1344 {
1345  switch (context) {
1346  case 0:
1347  this->setTabTitleFormat(Session::LocalTabTitle, format);
1348  break;
1349  case 1:
1350  this->setTabTitleFormat(Session::RemoteTabTitle, format);
1351  break;
1352  }
1353 }
1354 
1355 QString Session::tabTitleFormat(int context) const
1356 {
1357  switch (context) {
1358  case 0:
1359  return this->tabTitleFormat(Session::LocalTabTitle);
1360  case 1:
1361  return this->tabTitleFormat(Session::RemoteTabTitle);
1362  default:
1363  return QString();
1364  }
1365 }
1366 
1367 void Session::setHistorySize(int lines)
1368 {
1369  if (lines < 0) {
1370  setHistoryType(HistoryTypeFile());
1371  } else if (lines == 0) {
1372  setHistoryType(HistoryTypeNone());
1373  } else {
1374  setHistoryType(CompactHistoryType(lines));
1375  }
1376 }
1377 
1378 int Session::historySize() const
1379 {
1380  const HistoryType& currentHistory = historyType();
1381 
1382  if (currentHistory.isEnabled()) {
1383  if (currentHistory.isUnlimited()) {
1384  return -1;
1385  } else {
1386  return currentHistory.maximumLineCount();
1387  }
1388  } else {
1389  return 0;
1390  }
1391 }
1392 
1393 int Session::foregroundProcessId()
1394 {
1395  int pid;
1396 
1397  bool ok = false;
1398  pid = getProcessInfo()->pid(&ok);
1399  if (!ok)
1400  pid = -1;
1401 
1402  return pid;
1403 }
1404 
1405 bool Session::isForegroundProcessActive()
1406 {
1407  // foreground process info is always updated after this
1408  return updateForegroundProcessInfo() && (processId() != _foregroundPid);
1409 }
1410 
1411 QString Session::foregroundProcessName()
1412 {
1413  QString name;
1414 
1415  if (updateForegroundProcessInfo()) {
1416  bool ok = false;
1417  name = _foregroundProcessInfo->name(&ok);
1418  if (!ok)
1419  name.clear();
1420  }
1421 
1422  return name;
1423 }
1424 
1425 void Session::saveSession(KConfigGroup& group)
1426 {
1427  group.writePathEntry("WorkingDir", currentWorkingDirectory());
1428  group.writeEntry("LocalTab", tabTitleFormat(LocalTabTitle));
1429  group.writeEntry("RemoteTab", tabTitleFormat(RemoteTabTitle));
1430  group.writeEntry("SessionGuid", _uniqueIdentifier.toString());
1431  group.writeEntry("Encoding", QString(codec()));
1432 }
1433 
1434 void Session::restoreSession(KConfigGroup& group)
1435 {
1436  QString value;
1437 
1438  value = group.readPathEntry("WorkingDir", QString());
1439  if (!value.isEmpty()) setInitialWorkingDirectory(value);
1440  value = group.readEntry("LocalTab");
1441  if (!value.isEmpty()) setTabTitleFormat(LocalTabTitle, value);
1442  value = group.readEntry("RemoteTab");
1443  if (!value.isEmpty()) setTabTitleFormat(RemoteTabTitle, value);
1444  value = group.readEntry("SessionGuid");
1445  if (!value.isEmpty()) _uniqueIdentifier = QUuid(value);
1446  value = group.readEntry("Encoding");
1447  if (!value.isEmpty()) setCodec(value.toUtf8());
1448 }
1449 
1450 SessionGroup::SessionGroup(QObject* parent)
1451  : QObject(parent), _masterMode(0)
1452 {
1453 }
1454 SessionGroup::~SessionGroup()
1455 {
1456 }
1457 int SessionGroup::masterMode() const
1458 {
1459  return _masterMode;
1460 }
1461 QList<Session*> SessionGroup::sessions() const
1462 {
1463  return _sessions.keys();
1464 }
1465 bool SessionGroup::masterStatus(Session* session) const
1466 {
1467  return _sessions[session];
1468 }
1469 
1470 void SessionGroup::addSession(Session* session)
1471 {
1472  connect(session, SIGNAL(finished()), this, SLOT(sessionFinished()));
1473  _sessions.insert(session, false);
1474 }
1475 void SessionGroup::removeSession(Session* session)
1476 {
1477  disconnect(session, SIGNAL(finished()), this, SLOT(sessionFinished()));
1478  setMasterStatus(session, false);
1479  _sessions.remove(session);
1480 }
1481 void SessionGroup::sessionFinished()
1482 {
1483  Session* session = qobject_cast<Session*>(sender());
1484  Q_ASSERT(session);
1485  removeSession(session);
1486 }
1487 void SessionGroup::setMasterMode(int mode)
1488 {
1489  _masterMode = mode;
1490 }
1491 QList<Session*> SessionGroup::masters() const
1492 {
1493  return _sessions.keys(true);
1494 }
1495 void SessionGroup::setMasterStatus(Session* session , bool master)
1496 {
1497  const bool wasMaster = _sessions[session];
1498 
1499  if (wasMaster == master) {
1500  // No status change -> nothing to do.
1501  return;
1502  }
1503  _sessions[session] = master;
1504 
1505  if (master) {
1506  connect(session->emulation(), SIGNAL(sendData(const char*,int)),
1507  this, SLOT(forwardData(const char*,int)));
1508  } else {
1509  disconnect(session->emulation(), SIGNAL(sendData(const char*,int)),
1510  this, SLOT(forwardData(const char*,int)));
1511  }
1512 }
1513 void SessionGroup::forwardData(const char* data, int size)
1514 {
1515  static bool _inForwardData = false;
1516  if (_inForwardData) { // Avoid recursive calls among session groups!
1517  // A recursive call happens when a master in group A calls forwardData()
1518  // in group B. If one of the destination sessions in group B is also a
1519  // master of a group including the master session of group A, this would
1520  // again call forwardData() in group A, and so on.
1521  return;
1522  }
1523 
1524  _inForwardData = true;
1525  foreach(Session* other, _sessions.keys()) {
1526  if (!_sessions[other]) {
1527  other->emulation()->sendString(data, size);
1528  }
1529  }
1530  _inForwardData = false;
1531 }
1532 
1533 #include "Session.moc"
1534 
Session.h
Konsole::NOTIFYSILENCE
Definition: Emulation.h:65
Konsole::Session::run
void run()
Starts the terminal session.
Definition: Session.cpp:427
Konsole::Session::keyBindings
QString keyBindings() const
Returns the name of the key bindings used by this session.
Konsole::Emulation::setHistory
void setHistory(const HistoryType &)
Sets the history store used by this emulation.
Definition: Emulation.cpp:137
QWidget
Konsole::Session::startZModem
void startZModem(const QString &rz, const QString &dir, const QStringList &list)
Definition: Session.cpp:1183
Konsole::Session::setMonitorActivity
Q_SCRIPTABLE void setMonitorActivity(bool)
Enables monitoring for activity in the session.
Definition: Session.cpp:1101
Konsole::Session::WindowTitle
Definition: Session.h:355
Konsole::Session
Represents a terminal session consisting of a pseudo-teletype and a terminal emulation.
Definition: Session.h:78
Konsole::Session::restoreSession
void restoreSession(KConfigGroup &group)
Definition: Session.cpp:1434
QString::append
QString & append(QChar ch)
Konsole::Session::foregroundProcessId
Q_SCRIPTABLE int foregroundProcessId()
Returns the process id of the terminal's foreground process.
Definition: Session.cpp:1393
Konsole::Pty::sendData
void sendData(const char *buffer, int length)
Sends data to the process currently controlling the teletype ( whose id is returned by foregroundProc...
Definition: Pty.cpp:74
Konsole::Session::setEnvironment
Q_SCRIPTABLE void setEnvironment(const QStringList &environment)
Sets the environment for this session.
Definition: Session.cpp:889
Konsole::Pty::foregroundProcessGroup
int foregroundProcessGroup() const
Returns the process id of the teletype's current foreground process.
Definition: Pty.cpp:282
QWidget::isHidden
bool isHidden() const
QSize::width
int width() const
Konsole::Session::currentDirectoryChanged
void currentDirectoryChanged(const QString &dir)
Emitted when the current working directory of this session changes.
Konsole::HistoryType::isEnabled
virtual bool isEnabled() const =0
Returns true if the history is enabled ( can store lines of output ) or false otherwise.
Konsole::Session::size
QSize size()
Returns the terminal session's window size in lines and columns.
Konsole::Session::setAddToUtmp
void setAddToUtmp(bool)
Specifies whether a utmp entry should be created for the pty used by this session.
Definition: Session.cpp:1138
Konsole::Emulation::setImageSize
virtual void setImageSize(int lines, int columns)
Change the size of the emulation's image.
Definition: Emulation.cpp:338
Konsole::Session::shellSessionId
Q_SCRIPTABLE QString shellSessionId() const
Returns the "friendly" version of the QUuid of this session.
Definition: Session.cpp:419
QTextCodec::name
virtual QByteArray name() const =0
Konsole::ShellCommand::expand
static QString expand(const QString &text)
Expands environment variables in text .
Definition: ShellCommand.cpp:74
Konsole::Session::sendMouseEvent
Q_SCRIPTABLE void sendMouseEvent(int buttons, int column, int line, int eventType)
Sends a mouse event of type eventType emitted by button buttons on column/line to the current foregro...
Definition: Session.cpp:829
Konsole::Session::processId
Q_SCRIPTABLE int processId() const
Returns the process id of the terminal process.
Konsole::Pty::start
int start(const QString &program, const QStringList &arguments, const QStringList &environment)
Starts the terminal process.
Definition: Pty.cpp:225
QByteArray
Konsole::Session::historySize
Q_SCRIPTABLE int historySize() const
Returns the history capacity of this session.
Definition: Session.cpp:1378
Konsole::Session::sessionId
int sessionId() const
Returns the unique ID for this session.
Definition: Session.cpp:899
Konsole::ProcessInfo::currentDir
QString currentDir(bool *ok) const
Returns the current working directory of the process.
Definition: ProcessInfo.cpp:300
Konsole::HistoryType::maximumLineCount
virtual int maximumLineCount() const =0
Returns the maximum number of lines which this history type can store or -1 if the history can store ...
Konsole::Session::openTeletype
void openTeletype(int masterFd)
Connect to an existing terminal.
Definition: Session.cpp:170
Konsole::TerminalDisplay::processFilters
void processFilters()
Updates the filters in the display's filter chain.
Definition: TerminalDisplay.cpp:944
Konsole::Pty::setEraseChar
void setEraseChar(char eraseChar)
Sets the special character for erasing previous not-yet-erased character.
Definition: Pty.cpp:156
Konsole::HistoryTypeNone
Definition: History.h:348
QObject::sender
QObject * sender() const
QChar
Konsole::Session::titleChanged
void titleChanged()
Emitted when the session's title has changed.
Konsole::Pty::closePty
void closePty()
Close the underlying pty master/slave pair.
Definition: Pty.cpp:277
Konsole::ZModemDialog
Definition: ZModemDialog.h:29
Konsole::Session::setPreferredSize
void setPreferredSize(const QSize &size)
Definition: Session.cpp:1303
Konsole::Emulation::imageSize
QSize imageSize() const
Returns the size of the screen image which the emulation produces.
Definition: Emulation.cpp:378
Konsole::Session::setCodec
void setCodec(QTextCodec *codec)
Definition: Session.cpp:245
Konsole::Pty::windowSize
QSize windowSize() const
Returns the size of the window used by this teletype.
Definition: Pty.cpp:100
Konsole::TerminalDisplay::outputSuspended
void outputSuspended(bool suspended)
Causes the widget to display or hide a message informing the user that terminal output has been suspe...
Definition: TerminalDisplay.cpp:2884
QDBusConnection::registerObject
bool registerObject(const QString &path, QObject *object, QFlags< QDBusConnection::RegisterOption > options)
QByteArray::isEmpty
bool isEmpty() const
Konsole::SessionGroup::sessions
QList< Session * > sessions() const
Returns the list of sessions currently in the group.
Definition: Session.cpp:1461
Konsole::Session::refresh
void refresh()
Attempts to get the shell program to redraw the current display area.
Definition: Session.cpp:719
Konsole::TerminalDisplay::setBracketedPasteMode
void setBracketedPasteMode(bool bracketedPasteMode)
Definition: TerminalDisplay.cpp:2686
Konsole::Session::DisplayedTitleRole
The title of the session which is displayed in tabs etc.
Definition: Session.h:255
QUuid
Konsole::CompactHistoryType
Definition: History.h:373
Konsole::ProcessInfo::foregroundPid
int foregroundPid(bool *ok) const
Returns the id of the current foreground process.
Definition: ProcessInfo.cpp:226
Konsole::SessionGroup::masterStatus
bool masterStatus(Session *session) const
Returns the master status of a session.
Definition: Session.cpp:1465
QDBusConnection::sessionBus
QDBusConnection sessionBus()
Konsole::Session::TitleRole
TitleRole
This enum describes the available title roles.
Definition: Session.h:251
Konsole::Session::IconNameAndWindowTitle
Definition: Session.h:353
QStringList::join
QString join(const QString &separator) const
Konsole::Session::tabTitleFormat
QString tabTitleFormat(TabTitleContext context) const
Returns the format used by this session for tab titles.
Definition: Session.cpp:595
QString::remove
QString & remove(int position, int n)
Konsole::Pty::setWindowSize
void setWindowSize(int columns, int lines)
Sets the size of the window (in columns and lines of characters) used by this teletype.
Definition: Pty.cpp:91
QDir::currentPath
QString currentPath()
Konsole::Session::setProgram
void setProgram(const QString &program)
Sets the program to be executed when run() is called.
Definition: Session.cpp:267
Konsole::Emulation::sendText
virtual void sendText(const QString &text)=0
Interprets a sequence of characters and sends the result to the terminal.
Konsole::Session::arguments
QStringList arguments() const
Returns the arguments passed to the shell process when run() is called.
Definition: Session.cpp:1082
Konsole::Emulation::eraseChar
virtual char eraseChar() const
Returns the special character used for erasing character.
Definition: Emulation.cpp:333
ShellCommand.h
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
Konsole::Session::setDarkBackground
void setDarkBackground(bool darkBackground)
Sets whether the session has a dark background or not.
Definition: Session.cpp:235
Konsole::Session::views
QList< TerminalDisplay * > views() const
Returns the views connected to this session.
Definition: Session.cpp:303
ProcessInfo.h
QDBusConnection::baseService
QString baseService() const
Konsole::Session::currentWorkingDirectory
QString currentWorkingDirectory()
Returns the current directory of the foreground process in the session.
Definition: Session.cpp:282
Konsole::Emulation::setCodec
void setCodec(const QTextCodec *)
Sets the codec used to decode incoming characters.
Definition: Emulation.cpp:149
Konsole::Session::setHistoryType
void setHistoryType(const HistoryType &type)
Sets the type of history store used by this session.
Definition: Session.cpp:1067
Konsole::ProcessInfo::newInstance
static ProcessInfo * newInstance(int pid, bool readEnvironment=false)
Constructs a new instance of a suitable ProcessInfo sub-class for the current platform which provides...
Definition: ProcessInfo.cpp:1165
Konsole::Session::userTitle
QString userTitle() const
Return the session title set by the user (ie.
Definition: Session.cpp:584
Konsole::Session::codec
Q_SCRIPTABLE QByteArray codec()
Returns the codec used to decode incoming characters in this terminal emulation.
Definition: Session.cpp:262
Konsole::ProcessInfo::pid
int pid(bool *ok) const
Returns the process id.
Definition: ProcessInfo.cpp:212
Konsole::ProcessInfo::update
void update()
Updates the information about the process.
Definition: ProcessInfo.cpp:96
Konsole::SSHProcessInfo::userName
QString userName() const
Returns the user name which the user initially logged into on the remote computer.
Definition: ProcessInfo.cpp:1119
Konsole::TerminalDisplay::flowControlWarningEnabled
bool flowControlWarningEnabled() const
Returns true if the flow control warning box is enabled.
Definition: TerminalDisplay.h:506
Konsole::Pty
The Pty class is used to start the terminal process, send data to it, receive data from it and manipu...
Definition: Pty.h:52
Konsole::Emulation::programBracketedPasteMode
bool programBracketedPasteMode() const
Definition: Emulation.cpp:70
QString::clear
void clear()
Konsole::TerminalDisplay::setUsesMouse
void setUsesMouse(bool usesMouse)
Sets whether the program whose output is being displayed in the view is interested in mouse events...
Definition: TerminalDisplay.cpp:2676
Konsole::Session::primaryScreenInUse
void primaryScreenInUse(bool use)
Emitted when the active screen is switched, to indicate whether the primary screen is in use...
Konsole::Session::autoClose
bool autoClose() const
See setAutoClose()
Definition: Session.cpp:1148
Konsole::Session::resizeRequest
void resizeRequest(const QSize &size)
Emitted when the terminal process requests a change in the size of the terminal window.
Konsole::Session::bellRequest
void bellRequest(const QString &message)
Emitted when a bell event occurs in the session.
Konsole::Session::setMonitorSilence
Q_SCRIPTABLE void setMonitorSilence(bool)
Enables monitoring for silence in the session.
Definition: Session.cpp:1115
Konsole::NOTIFYACTIVITY
The emulation is currently receiving data from its terminal input.
Definition: Emulation.h:62
Konsole::Session::setTabTitleFormat
void setTabTitleFormat(TabTitleContext context, const QString &format)
Sets the format used by this session for tab titles.
Definition: Session.cpp:588
QObject::name
const char * name() const
Konsole::Session::~Session
~Session()
Definition: Session.cpp:161
Konsole::Session::profileChangeCommandReceived
void profileChangeCommandReceived(const QString &text)
Emitted when a profile change command is received from the terminal.
Konsole::Session::historyType
const HistoryType & historyType() const
Returns the type of history store used by this session.
Definition: Session.cpp:1072
QByteArray::indexOf
int indexOf(char ch, int from) const
History.h
Konsole::Session::isRunning
bool isRunning() const
Returns true if the session is currently running.
Definition: Session.cpp:240
QApplication::activeWindow
QWidget * activeWindow()
Konsole::Emulation::sendMouseEvent
virtual void sendMouseEvent(int buttons, int column, int line, int eventType)
Converts information about a mouse event into an xterm-compatible escape sequence and emits the chara...
Definition: Emulation.cpp:216
QString::number
QString number(int n, int base)
QString::fromLocal8Bit
QString fromLocal8Bit(const char *str, int size)
Konsole::SessionGroup::masterMode
int masterMode() const
Returns a bitwise OR of the active MasterMode flags for this group.
Definition: Session.cpp:1457
Konsole::ProcessInfo::setUserHomeDir
void setUserHomeDir()
Forces the user home directory to be calculated.
Definition: ProcessInfo.cpp:280
Konsole::ProcessInfo::name
QString name(bool *ok) const
Returns the name of the current process.
Definition: ProcessInfo.cpp:233
Konsole::Session::closeInNormalWay
bool closeInNormalWay()
Kill the terminal process in normal way.
Definition: Session.cpp:781
TerminalDisplay.h
Konsole::TerminalDisplay::lines
int lines() const
Returns the number of lines of text which can be displayed in the widget.
Definition: TerminalDisplay.h:268
QTimer
Konsole::Session::isRemote
bool isRemote()
Returns true if the session currently contains a connection to a remote computer. ...
Definition: Session.cpp:981
Konsole::Session::changeTabTextColorRequest
void changeTabTextColorRequest(int)
Requests that the color the text for any tabs associated with this session should be changed;...
Konsole::Session::emulation
Emulation * emulation() const
Returns the terminal emulation instance being used to encode / decode characters to / from the proces...
Definition: Session.cpp:874
QObject
Konsole::SSHProcessInfo
Lightweight class which provides additional information about SSH processes.
Definition: ProcessInfo.h:406
Konsole::Session::flowControlEnabledChanged
void flowControlEnabledChanged(bool enabled)
Emitted when the flow control state changes.
QList::isEmpty
bool isEmpty() const
Konsole::ProcessInfo
Takes a snapshot of the state of a process and provides access to information such as the process nam...
Definition: ProcessInfo.h:74
QString::isEmpty
bool isEmpty() const
Konsole::Session::setTitle
void setTitle(TitleRole role, const QString &title)
Sets the session's title for the specified role to title.
Definition: Session.cpp:909
Konsole::SessionGroup::setMasterStatus
void setMasterStatus(Session *session, bool master)
Sets whether a particular session is a master within the group.
Definition: Session.cpp:1495
QByteArray::constData
const char * constData() const
Vt102Emulation.h
Konsole::Emulation::keyBindings
QString keyBindings() const
Returns the name of the emulation's current key bindings.
Definition: Emulation.cpp:179
Konsole::Session::TextColor
Definition: Session.h:356
Konsole::Session::iconText
QString iconText() const
Returns the text of the icon associated with this session.
Definition: Session.cpp:1062
Konsole::NOTIFYBELL
The terminal program has triggered a bell event to get the user's attention.
Definition: Emulation.h:57
Konsole::ProcessInfo::format
QString format(const QString &text) const
Parses an input string, looking for markers beginning with a '' character and returns a string with t...
Definition: ProcessInfo.cpp:120
Konsole::Session::setIconName
void setIconName(const QString &iconName)
Sets the name of the icon associated with this session.
Definition: Session.cpp:1044
Konsole::Emulation::programUsesMouse
bool programUsesMouse() const
Returns true if the active terminal program wants mouse input events.
Definition: Emulation.cpp:60
Konsole::Emulation
Base class for terminal emulation back-ends.
Definition: Emulation.h:117
Konsole::NOTIFYNORMAL
The emulation is currently receiving user input.
Definition: Emulation.h:52
Konsole::Session::setInitialWorkingDirectory
void setInitialWorkingDirectory(const QString &dir)
Sets the initial working directory for the session when it is run This has no effect once the session...
Definition: Session.cpp:277
Konsole::Session::addView
void addView(TerminalDisplay *widget)
Adds a new view for this session.
Definition: Session.cpp:308
QByteArray::count
int count(char ch) const
QByteArray::truncate
void truncate(int pos)
Konsole::Session::RemoteTabTitle
Tab title format used session currently contains a connection to a remote computer (via SSH) ...
Definition: Session.h:166
Konsole::Emulation::createWindow
ScreenWindow * createWindow()
Creates a new window onto the output from this emulation.
Definition: Emulation.cpp:80
Konsole::SSHProcessInfo::host
QString host() const
Returns the host which the user has connected to.
Definition: ProcessInfo.cpp:1123
QWidget::winId
WId winId() const
QString
QList
QColor
QTextCodec
Konsole::Session::getUrl
KUrl getUrl()
Return URL for the session.
Definition: Session.cpp:1008
Konsole::Session::stateChanged
void stateChanged(int state)
Emitted when the activity state of this session changes.
QByteArray::mid
QByteArray mid(int pos, int len) const
Konsole::TerminalDisplay::columns
int columns() const
Returns the number of characters of text which can be displayed on each line in the widget...
Definition: TerminalDisplay.h:278
QStringList
Konsole::SessionGroup::setMasterMode
void setMasterMode(int mode)
Specifies which activity in the group's master sessions is propagated to all sessions in the group...
Definition: Session.cpp:1487
Konsole::Session::setKeyBindings
void setKeyBindings(const QString &name)
Sets the key bindings used by this session.
Definition: Session.cpp:904
QPixmap
Konsole::SessionGroup::removeSession
void removeSession(Session *session)
Removes a session from the group.
Definition: Session.cpp:1475
QFileInfo
QString::toLocal8Bit
QByteArray toLocal8Bit() const
Konsole::Session::SessionName
Definition: Session.h:358
Konsole::Session::environment
Q_SCRIPTABLE QStringList environment() const
Returns the environment of this session as a list of strings like VARIABLE=VALUE. ...
Definition: Session.cpp:884
Konsole::Session::finished
void finished()
Emitted when the terminal process exits.
QSize
Pty.h
Konsole::SessionGroup::SessionGroup
SessionGroup(QObject *parent)
Constructs an empty session group.
Definition: Session.cpp:1450
Konsole::ProcessInfo::validCurrentDir
QString validCurrentDir() const
Returns the current working directory of the process (or its parent)
Definition: ProcessInfo.cpp:101
QTimer::stop
void stop()
Konsole::Pty::setInitialWorkingDirectory
void setInitialWorkingDirectory(const QString &dir)
Sets the initial working directory.
Definition: Pty.cpp:182
Konsole::HistoryTypeFile
Definition: History.h:359
Konsole::Session::close
void close()
Closes the terminal session.
Definition: Session.cpp:770
Konsole::Session::isForegroundProcessActive
bool isForegroundProcessActive()
Returns true if the user has started a program in the session.
Definition: Session.cpp:1405
Konsole::Session::setHistorySize
Q_SCRIPTABLE void setHistorySize(int lines)
Sets the history capacity of this session.
Definition: Session.cpp:1367
Konsole::Session::started
void started()
Emitted when the terminal process starts.
Konsole::ProcessInfo::isValid
bool isValid() const
Returns true if the process state was read successfully.
Definition: ProcessInfo.cpp:207
ZModemDialog.h
Konsole::Session::sendSignal
void sendSignal(int signal)
Definition: Session.cpp:741
Konsole::SessionGroup::~SessionGroup
~SessionGroup()
Destroys the session group and removes all connections between master and slave sessions.
Definition: Session.cpp:1454
Konsole::HistoryType
Definition: History.h:319
Konsole::Session::title
QString title(TitleRole role) const
Returns the session's title for the specified role.
Definition: Session.cpp:921
Konsole::Vt102Emulation
Provides an xterm compatible terminal emulation based on the DEC VT102 terminal.
Definition: Vt102Emulation.h:76
QKeyEvent
QByteArray::left
QByteArray left(int len) const
Konsole::Pty::flowControlEnabled
bool flowControlEnabled() const
Queries the terminal state and returns true if Xon/Xoff flow control is enabled.
Definition: Pty.cpp:122
Konsole::ZModemDialog::transferDone
void transferDone()
To indicate the process is finished.
Definition: ZModemDialog.cpp:58
Konsole::Session::isMonitorActivity
Q_SCRIPTABLE bool isMonitorActivity() const
Returns true if monitoring for activity is enabled.
Definition: Session.cpp:1092
Konsole::Session::changeBackgroundColorRequest
void changeBackgroundColorRequest(const QColor &)
Requests that the background color of views on this session should be changed.
Konsole::Session::clearHistory
void clearHistory()
Clears the history store used by this session.
Definition: Session.cpp:1077
QDateTime::currentDateTime
QDateTime currentDateTime()
Konsole::Session::NameRole
The name of the session.
Definition: Session.h:253
Konsole::Session::setIconText
void setIconText(const QString &iconText)
Sets the text of the icon associated with this session.
Definition: Session.cpp:1052
Konsole::Session::LocalTabTitle
Default tab title format.
Definition: Session.h:161
QLatin1String
Konsole::SSHProcessInfo::format
QString format(const QString &input) const
Operates in the same way as ProcessInfo::format(), except that the set of markers understood is diffe...
Definition: ProcessInfo.cpp:1135
Konsole::Emulation::clearHistory
void clearHistory()
Clears the history scroll.
Definition: Emulation.cpp:133
Konsole::TerminalDisplay::setScreenWindow
void setScreenWindow(ScreenWindow *window)
Sets the terminal screen section which is displayed in this widget.
Definition: TerminalDisplay.cpp:107
QWidget::parentWidget
QWidget * parentWidget() const
Konsole::Pty::setFlowControlEnabled
void setFlowControlEnabled(bool on)
Enables or disables Xon/Xoff flow control.
Definition: Pty.cpp:105
Konsole::Session::cancelZModem
void cancelZModem()
Definition: Session.cpp:1177
Konsole::SessionGroup::addSession
void addSession(Session *session)
Adds a session to the group.
Definition: Session.cpp:1470
QTextCodec::codecForName
QTextCodec * codecForName(const QByteArray &name)
Konsole::Session::setArguments
void setArguments(const QStringList &arguments)
Sets the command line arguments which the session's program will be passed when run() is called...
Definition: Session.cpp:272
QSize::height
int height() const
Konsole::Session::isMonitorSilence
Q_SCRIPTABLE bool isMonitorSilence() const
Returns true if monitoring for inactivity (silence) in the session is enabled.
Definition: Session.cpp:1096
createUuid
QUuid createUuid()
Definition: Session.cpp:68
Konsole::Session::setAutoClose
void setAutoClose(bool close)
Specifies whether to close the session automatically when the terminal process terminates.
Definition: Session.cpp:1143
Konsole::Session::IconName
Definition: Session.h:354
Konsole::HistoryType::isUnlimited
bool isUnlimited() const
Returns true if the history size is unlimited.
Definition: History.h:343
Konsole::Session::preferredSize
QSize preferredSize() const
Definition: Session.cpp:1298
Konsole::Emulation::receiveData
void receiveData(const char *buffer, int len)
Processes an incoming stream of characters.
Definition: Emulation.cpp:225
Konsole::Session::changeForegroundColorRequest
void changeForegroundColorRequest(const QColor &)
Requests that the text color of views on this session should be changed to color. ...
QString::section
QString section(QChar sep, int start, int end, QFlags< QString::SectionFlag > flags) const
Konsole::Emulation::setKeyBindings
void setKeyBindings(const QString &name)
Sets the key bindings used to key events ( received through sendKeyEvent() ) into character streams t...
Definition: Emulation.cpp:171
QTimer::start
void start(int msec)
Konsole::Emulation::codec
const QTextCodec * codec() const
Returns the codec used to decode incoming characters.
Definition: Emulation.h:169
Konsole::Session::setFlowControlEnabled
Q_SCRIPTABLE void setFlowControlEnabled(bool enabled)
Sets whether flow control is enabled for this terminal session.
Definition: Session.cpp:1153
Konsole::Session::SessionIcon
Definition: Session.h:359
Konsole::Session::addEnvironmentEntry
void addEnvironmentEntry(const QString &entry)
Adds one entry for the environment of this session entry should be like VARIABLE=VALUE.
Definition: Session.cpp:894
Konsole::Session::selectionChanged
void selectionChanged(const QString &text)
Emitted when the text selection is changed.
Konsole::Session::Session
Session(QObject *parent=0)
Constructs a new session.
Definition: Session.cpp:98
Konsole::Session::foregroundProcessName
QString foregroundProcessName()
Returns the name of the current foreground process.
Definition: Session.cpp:1411
Konsole::Session::setSize
void setSize(const QSize &size)
Emits a request to resize the session to accommodate the specified window size.
Definition: Session.cpp:1290
Konsole::Session::TabTitleContext
TabTitleContext
This enum describes the contexts for which separate tab title formats may be specified.
Definition: Session.h:159
Konsole::Session::zmodemDetected
void zmodemDetected()
Emitted when the request for data transmission through ZModem protocol is detected.
Konsole::Emulation::history
const HistoryType & history() const
Returns the history store used by this emulation.
Definition: Emulation.cpp:144
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Konsole::Session::flowControlEnabled
Q_SCRIPTABLE bool flowControlEnabled() const
Returns whether flow control is enabled for this terminal session.
Definition: Session.cpp:1162
Konsole::Emulation::utf8
bool utf8() const
Convenience method.
Definition: Emulation.h:180
Konsole::ZModemDialog::addProgressText
void addProgressText(const QString &)
Adds a line of text to the progress window.
Definition: ZModemDialog.cpp:50
Konsole::Session::ProfileChange
Definition: Session.h:360
Konsole::TerminalDisplay
A widget which displays output from a terminal emulation and sends input keypresses and mouse activit...
Definition: TerminalDisplay.h:63
Konsole::Session::sendText
Q_SCRIPTABLE void sendText(const QString &text) const
Sends text to the current foreground terminal program.
Definition: Session.cpp:819
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Konsole::Session::setUserTitle
void setUserTitle(int what, const QString &caption)
Changes the session title or other customizable aspects of the terminal emulation display...
Definition: Session.cpp:518
QUuid::toString
QString toString() const
Konsole::Session::runCommand
Q_SCRIPTABLE void runCommand(const QString &command) const
Sends command to the current foreground terminal program.
Definition: Session.cpp:824
Konsole::Session::iconName
QString iconName() const
Returns the name of the icon associated with this session.
Definition: Session.cpp:1057
Konsole::Session::setMonitorSilenceSeconds
Q_SCRIPTABLE void setMonitorSilenceSeconds(int seconds)
See setMonitorSilence()
Definition: Session.cpp:1130
Konsole::Session::BackgroundColor
Definition: Session.h:357
QObject::destroyed
void destroyed(QObject *obj)
Konsole::Session::saveSession
void saveSession(KConfigGroup &group)
Definition: Session.cpp:1425
Konsole::Session::program
QString program() const
Returns the program name of the shell process started when run() is called.
Definition: Session.cpp:1087
QColor::isValid
bool isValid() const
Konsole::SSHProcessInfo::port
QString port() const
Returns the port on host which the user has connected to.
Definition: ProcessInfo.cpp:1127
Konsole::Session::removeView
void removeView(TerminalDisplay *widget)
Removes a view from this session.
Definition: Session.cpp:355
Konsole::Pty::setWriteable
void setWriteable(bool writeable)
Control whether the pty device is writeable by group members.
Definition: Pty.cpp:261
QTimer::setSingleShot
void setSingleShot(bool singleShot)
QUuid::isNull
bool isNull() const
Konsole::Session::getDynamicTitle
QString getDynamicTitle()
Returns a title generated from tab format and process information.
Definition: Session.cpp:989
Konsole::Pty::setUtf8Mode
void setUtf8Mode(bool on)
Put the pty into UTF-8 mode on systems which support it.
Definition: Pty.cpp:135
Konsole::Session::closeInForceWay
bool closeInForceWay()
kill terminal process in force way.
Definition: Session.cpp:806
QString::toUtf8
QByteArray toUtf8() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:27 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Konsole

Skip menu "Konsole"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal