From b398acfbd4895e6332df9357a0bde8f8bf2e1f90 Mon Sep 17 00:00:00 2001 From: Francisco Ballina Date: Mon, 19 Nov 2012 23:10:35 -0600 Subject: [PATCH] Add zoom. Add choice action after paste clipboard --- CMakeLists.txt.user | 146 ++++++++++++++++++++++++++++++++++++++++ lib/TerminalDisplay.cpp | 23 ++++++- lib/TerminalDisplay.h | 18 ++++- lib/qtermwidget.cpp | 12 ++++ lib/qtermwidget.h | 6 +- src/main.cpp | 6 +- 6 files changed, 206 insertions(+), 5 deletions(-) create mode 100644 CMakeLists.txt.user diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user new file mode 100644 index 0000000..30599a8 --- /dev/null +++ b/CMakeLists.txt.user @@ -0,0 +1,146 @@ + + + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + true + 1 + true + 1 + true + 2 + 8 + true + 1 + false + true + false + true + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop + + CMakeProjectManager.DefaultCMakeTarget + 0 + 0 + 0 + + /home/francisco/Documentos/Desarrollo/git/qtermwidget-build + ProjectExplorer.ToolChain.Gcc:{84586ad0-f048-47e8-813a-5e9c5be87284} + ProjectExplorer.ToolChain.Gcc:{84586ad0-f048-47e8-813a-5e9c5be87284} + + + + + false + true + Make + + CMakeProjectManager.MakeStep + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + + clean + + true + true + Make + + CMakeProjectManager.MakeStep + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + all + + CMakeProjectManager.CMakeBuildConfiguration + + 1 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + 2 + test + + false + + + test + + CMakeProjectManager.CMakeRunConfiguration. + 3768 + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.EnvironmentId + {4024c359-f0e5-499d-b6dc-dd7c55d4c58c} + + + ProjectExplorer.Project.Updater.FileVersion + 11 + + diff --git a/lib/TerminalDisplay.cpp b/lib/TerminalDisplay.cpp index 7811e18..5cc44af 100644 --- a/lib/TerminalDisplay.cpp +++ b/lib/TerminalDisplay.cpp @@ -337,6 +337,7 @@ TerminalDisplay::TerminalDisplay(QWidget *parent) ,_blendColor(qRgba(0,0,0,0xff)) ,_filterChain(new TerminalImageFilterChain()) ,_cursorShape(BlockCursor) +,mMotionAfterPasting(NoMoveScreenWindow) { // terminal applications are not designed with Right-To-Left in mind, // so the layout is forced to Left-To-Right @@ -2512,6 +2513,16 @@ void TerminalDisplay::setFlowControlWarningEnabled( bool enable ) outputSuspended(false); } +void TerminalDisplay::setMotionAfterPasting(MotionAfterPasting action) +{ + mMotionAfterPasting = action; +} + +int TerminalDisplay::motionAfterPasting() +{ + return mMotionAfterPasting; +} + void TerminalDisplay::keyPressEvent( QKeyEvent* event ) { bool emitKeyPressSignal = true; @@ -2580,7 +2591,17 @@ void TerminalDisplay::keyPressEvent( QKeyEvent* event ) || event->modifiers().testFlag(Qt::ControlModifier) || event->modifiers().testFlag(Qt::AltModifier))) { - scrollToEnd(); + switch(mMotionAfterPasting) + { + case MoveStartScreenWindow: + _screenWindow->scrollTo(0); + break; + case MoveEndScreenWindow: + scrollToEnd(); + break; + case NoMoveScreenWindow: + break; + } } } diff --git a/lib/TerminalDisplay.h b/lib/TerminalDisplay.h index 6e818d5..4e3f87c 100644 --- a/lib/TerminalDisplay.h +++ b/lib/TerminalDisplay.h @@ -51,6 +51,17 @@ class QWidget; namespace Konsole { + enum MotionAfterPasting + { + // No move screenwindow after pasting + NoMoveScreenWindow = 0, + // Move start of screenwindow after pasting + MoveStartScreenWindow = 1, + // Move end of screenwindow after pasting + MoveEndScreenWindow = 2 + }; + + extern unsigned short vt100_graphics[32]; class ScreenWindow; @@ -414,7 +425,10 @@ public: ScreenWindow* screenWindow() const; static bool HAVE_TRANSPARENCY; - + + void setMotionAfterPasting(MotionAfterPasting action); + int motionAfterPasting(); + public slots: /** @@ -794,6 +808,8 @@ private: QColor _cursorColor; + MotionAfterPasting mMotionAfterPasting; + struct InputMethodData { QString preeditString; diff --git a/lib/qtermwidget.cpp b/lib/qtermwidget.cpp index a21bd75..5dbd58b 100644 --- a/lib/qtermwidget.cpp +++ b/lib/qtermwidget.cpp @@ -329,6 +329,13 @@ void QTermWidget::pasteClipboard() m_impl->m_terminalDisplay->pasteClipboard(); } +void QTermWidget::setZoom(uint step) +{ + QFont font = m_impl->m_terminalDisplay->getVTFont(); + font.setPixelSize(font.pointSize() + step > 5 ? font.pointSize() + step: font.pointSize()); + m_impl->m_terminalDisplay->setVTFont(font); +} + void QTermWidget::setKeyBindings(const QString & kb) { m_impl->m_session->setKeyBindings(kb); @@ -373,3 +380,8 @@ void QTermWidget::setEnvironment(const QStringList& environment) { m_impl->m_session->setEnvironment(environment); } + +void QTermWidget::setMotionAfterPasting(int action) +{ + m_impl->m_terminalDisplay->setMotionAfterPasting((Konsole::MotionAfterPasting) action); +} diff --git a/lib/qtermwidget.h b/lib/qtermwidget.h index db3d699..68a5b10 100644 --- a/lib/qtermwidget.h +++ b/lib/qtermwidget.h @@ -38,7 +38,6 @@ public: ScrollBarRight=2 }; - //Creation of widget QTermWidget(int startnow, // 1 = start shell programm immediatelly QWidget * parent = 0); @@ -119,6 +118,8 @@ public: //! Return current key bindings QString keyBindings(); + + void setMotionAfterPasting(int); signals: void finished(); @@ -136,6 +137,9 @@ public slots: // Copies selection to clipboard void pasteClipboard(); + // Set zoom + void setZoom(uint step); + /*! Set named key binding for given widget */ void setKeyBindings(const QString & kb); diff --git a/src/main.cpp b/src/main.cpp index 25bccb0..0365897 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,12 +21,14 @@ #include #include #include +#include #include "qtermwidget.h" int main(int argc, char *argv[]) { - QApplication app(argc, argv); + setenv("TERM", "xterm", 1); + QApplication app(argc, argv); QMainWindow *mainWindow = new QMainWindow(); QTermWidget *console = new QTermWidget(); @@ -41,7 +43,7 @@ int main(int argc, char *argv[]) console->setTerminalFont(font); - //console->setColorScheme(COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW); + // console->setColorScheme(COLOR_SCHEME_BLACK_ON_LIGHT_YELLOW); console->setScrollBarPosition(QTermWidget::ScrollBarRight); foreach (QString arg, QApplication::arguments())