Commit f016a0f8 authored by Kurt Hindenburg's avatar Kurt Hindenburg

Create new internal session->sendText() replacement method

Standardize all the internal Konsole sendText() calls into a new one.
In preparation for upcoming qdbus sendText changes.
parent 3dc500cb
......@@ -499,7 +499,7 @@ Session* MainWindow::createSSHSession(Profile::Ptr profile, const QUrl& url)
sshCommand += url.host();
}
session->sendText(sshCommand + '\r');
session->sendTextToTerminal(sshCommand, true);
// create view before starting the session process so that the session
// doesn't suffer a change in terminal size right after the session
......
......@@ -148,7 +148,7 @@ void Part::showShellInDir(const QString& dir)
void Part::sendInput(const QString& text)
{
Q_ASSERT(activeSession());
activeSession()->sendText(text);
activeSession()->sendTextToTerminal(text);
}
int Part::terminalProcessId()
......
......@@ -813,6 +813,15 @@ bool Session::closeInForceWay()
}
}
void Session::sendTextToTerminal(const QString& text, bool addNewline) const
{
if (addNewline) {
_emulation->sendText(text + '\n');
} else {
_emulation->sendText(text);
}
}
void Session::sendText(const QString& text) const
{
_emulation->sendText(text);
......@@ -820,7 +829,7 @@ void Session::sendText(const QString& text) const
void Session::runCommand(const QString& command) const
{
_emulation->sendText(command + '\n');
sendText(command + '\n');
}
void Session::sendMouseEvent(int buttons, int column, int line, int eventType)
......
......@@ -472,7 +472,10 @@ public slots:
/**
* Sends @p text to the current foreground terminal program.
* @addNewline if true, adds a newline "\n" to end of text
*/
void sendTextToTerminal(const QString& text, bool addNewline = false) const;
Q_SCRIPTABLE void sendText(const QString& text) const;
/**
......
......@@ -293,20 +293,19 @@ void SessionController::openUrl(const QUrl& url)
// Clear shell's command line
if (!_session->isForegroundProcessActive()
&& _bookmarkValidProgramsToClear.contains(_session->foregroundProcessName())) {
_session->emulation()->sendText(QChar(0x03)); // Ctrl+C
_session->emulation()->sendText(QChar('\n'));
_session->sendTextToTerminal(QChar(0x03), true); // Ctrl+C
}
// handle local paths
if (url.isLocalFile()) {
QString path = url.toLocalFile();
_session->emulation()->sendText("cd " + KShell::quoteArg(path) + '\r');
_session->sendTextToTerminal("cd " + KShell::quoteArg(path), true);
} else if (url.scheme().isEmpty()) {
// QUrl couldn't parse what the user entered into the URL field
// so just dump it to the shell
QString command = url.toDisplayString();
if (!command.isEmpty())
_session->emulation()->sendText(command + '\r');
_session->sendTextToTerminal(command, true);
} else if (url.scheme() == "ssh") {
QString sshCommand = "ssh ";
......@@ -319,8 +318,7 @@ void SessionController::openUrl(const QUrl& url)
if (!url.host().isEmpty()) {
sshCommand += url.host();
}
_session->sendText(sshCommand + '\r');
_session->sendTextToTerminal(sshCommand, true);
} else if (url.scheme() == "telnet") {
QString telnetCommand = "telnet ";
......@@ -335,7 +333,7 @@ void SessionController::openUrl(const QUrl& url)
telnetCommand += QString::number(url.port());
}
_session->sendText(telnetCommand + '\r');
_session->sendTextToTerminal(telnetCommand, true);
} else {
//TODO Implement handling for other Url types
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment