From b4b11ae71912f796acf96feae04dc05493e2fe34 Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sat, 3 Aug 2019 12:52:38 +0800 Subject: [PATCH] feat: add sendKeyEvent() api --- lib/Session.cpp | 5 +++++ lib/Session.h | 2 ++ lib/qtermwidget.cpp | 5 +++++ lib/qtermwidget.h | 3 +++ 4 files changed, 15 insertions(+) diff --git a/lib/Session.cpp b/lib/Session.cpp index 71a3b87..2973faa 100644 --- a/lib/Session.cpp +++ b/lib/Session.cpp @@ -568,6 +568,11 @@ void Session::sendText(const QString & text) const _emulation->sendText(text); } +void Session::sendKeyEvent(QKeyEvent* e) const +{ + _emulation->sendKeyEvent(e); +} + Session::~Session() { delete _emulation; diff --git a/lib/Session.h b/lib/Session.h index 992b9f5..a09a2d2 100644 --- a/lib/Session.h +++ b/lib/Session.h @@ -314,6 +314,8 @@ public: */ void sendText(const QString & text) const; + void sendKeyEvent(QKeyEvent* e) const; + /** * Returns the process id of the terminal process. * This is the id used by the system API to refer to the process. diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index 750a608..ea515ac 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -507,6 +507,11 @@ void QTermWidget::sendText(const QString &text) m_impl->m_session->sendText(text); } +void QTermWidget::sendKeyEvent(QKeyEvent *e) +{ + m_impl->m_session->sendKeyEvent(e); +} + void QTermWidget::resizeEvent(QResizeEvent*) { //qDebug("global window resizing...with %d %d", this->size().width(), this->size().height()); diff --git a/lib/qtermwidget.h b/lib/qtermwidget.h index e4cb42e..80e5609 100644 --- a/lib/qtermwidget.h +++ b/lib/qtermwidget.h @@ -125,6 +125,9 @@ public: // Send some text to terminal void sendText(const QString & text); + // Send key event to terminal + void sendKeyEvent(QKeyEvent* e); + // Sets whether flow control is enabled void setFlowControlEnabled(bool enabled);