forked from qt-creator/qt-creator
Terminal: Enable TerminalProcessInterface
Adds a new helper app "process_stub" that replaces the previous. "process_stub_unix/win". The purpose was and is to allow processes to be "injected" into other hosts apps like terminals while still being able to control and debug them. A new base class called "TerminalInterface" is used for both the new Terminal plugin and the legacy TerminalProcess implementation. Fixes: QTCREATORBUG-16364 Change-Id: If21273fe53ad545d1a768c17c83db4bf2fd85395 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -162,6 +162,7 @@ void TerminalWidget::setupPty()
|
||||
this,
|
||||
[this] {
|
||||
m_process.reset();
|
||||
setupSurface();
|
||||
setupPty();
|
||||
},
|
||||
Qt::QueuedConnection);
|
||||
@@ -180,7 +181,8 @@ void TerminalWidget::setupPty()
|
||||
});
|
||||
|
||||
connect(m_process.get(), &QtcProcess::started, this, [this] {
|
||||
m_shellName = m_process->commandLine().executable().fileName();
|
||||
if (m_shellName.isEmpty())
|
||||
m_shellName = m_process->commandLine().executable().fileName();
|
||||
if (HostOsInfo::isWindowsHost() && m_shellName.endsWith(QTC_WIN_EXE_SUFFIX))
|
||||
m_shellName.chop(QStringLiteral(QTC_WIN_EXE_SUFFIX).size());
|
||||
|
||||
@@ -253,7 +255,7 @@ void TerminalWidget::setupActions()
|
||||
|
||||
void TerminalWidget::writeToPty(const QByteArray &data)
|
||||
{
|
||||
if (m_process)
|
||||
if (m_process && m_process->isRunning())
|
||||
m_process->writeRaw(data);
|
||||
}
|
||||
|
||||
@@ -504,6 +506,11 @@ bool TerminalWidget::setSelection(const std::optional<Selection> &selection)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TerminalWidget::setShellName(const QString &shellName)
|
||||
{
|
||||
m_shellName = shellName;
|
||||
}
|
||||
|
||||
QString TerminalWidget::shellName() const
|
||||
{
|
||||
return m_shellName;
|
||||
@@ -519,6 +526,29 @@ CommandLine TerminalWidget::currentCommand() const
|
||||
return m_currentCommand;
|
||||
}
|
||||
|
||||
std::optional<Id> TerminalWidget::identifier() const
|
||||
{
|
||||
return m_openParameters.identifier;
|
||||
}
|
||||
|
||||
QProcess::ProcessState TerminalWidget::processState() const
|
||||
{
|
||||
if (m_process)
|
||||
return m_process->state();
|
||||
|
||||
return QProcess::NotRunning;
|
||||
}
|
||||
|
||||
void TerminalWidget::restart(const OpenTerminalParameters &openParameters)
|
||||
{
|
||||
QTC_ASSERT(!m_process || !m_process->isRunning(), return);
|
||||
m_openParameters = openParameters;
|
||||
|
||||
m_process.reset();
|
||||
setupSurface();
|
||||
setupPty();
|
||||
}
|
||||
|
||||
QPoint TerminalWidget::viewportToGlobal(QPoint p) const
|
||||
{
|
||||
int y = p.y() - topMargin();
|
||||
@@ -776,6 +806,9 @@ int TerminalWidget::paintCell(QPainter &p,
|
||||
|
||||
void TerminalWidget::paintCursor(QPainter &p) const
|
||||
{
|
||||
if (!m_process || !m_process->isRunning())
|
||||
return;
|
||||
|
||||
auto cursor = m_surface->cursor();
|
||||
|
||||
const bool blinkState = !cursor.blink || m_cursorBlinkState
|
||||
@@ -1155,14 +1188,13 @@ void TerminalWidget::checkLinkAt(const QPoint &pos)
|
||||
const TextAndOffsets hit = textAt(pos);
|
||||
|
||||
if (hit.text.size() > 0) {
|
||||
QString t
|
||||
= Utils::chopIfEndsWith(QString::fromUcs4(hit.text.c_str(), hit.text.size()).trimmed(),
|
||||
':');
|
||||
QString t = chopIfEndsWith(QString::fromUcs4(hit.text.c_str(), hit.text.size()).trimmed(),
|
||||
':');
|
||||
if (t.startsWith("~/")) {
|
||||
t = QDir::homePath() + t.mid(1);
|
||||
}
|
||||
|
||||
Utils::Link link = Utils::Link::fromString(t, true);
|
||||
const Link link = Link::fromString(t, true);
|
||||
|
||||
if (link.hasValidTarget()
|
||||
&& (link.targetFilePath.scheme().toString().startsWith("http")
|
||||
|
||||
Reference in New Issue
Block a user