From 0e35037be6964da39dd1b0953bcec3dc8ff51e60 Mon Sep 17 00:00:00 2001 From: Jekyll Wu Date: Fri, 16 Mar 2012 16:38:51 +0800 Subject: [PATCH] Merge Profile::CursorShapeEnum and TerminalDisplay::KeyboardCursorShape into Enum::CursorShapeEnum --- src/Enumeration.h | 14 ++++++++++++++ src/Profile.cpp | 2 +- src/Profile.h | 14 -------------- src/TerminalDisplay.cpp | 12 ++++++------ src/TerminalDisplay.h | 24 +++--------------------- src/ViewManager.cpp | 12 ++++++------ 6 files changed, 30 insertions(+), 48 deletions(-) diff --git a/src/Enumeration.h b/src/Enumeration.h index 17d1d7ffc..120dc66e5 100644 --- a/src/Enumeration.h +++ b/src/Enumeration.h @@ -62,6 +62,20 @@ public: ScrollBarHidden = 2 }; + /** This enum describes the shapes used to draw the cursor in terminal + * displays. + */ + enum CursorShapeEnum { + /** Use a solid rectangular block to draw the cursor. */ + BlockCursor = 0, + /** Use an 'I' shape, similar to that used in text editing + * applications, to draw the cursor. + */ + IBeamCursor = 1, + /** Draw a line underneath the cursor's position. */ + UnderlineCursor = 2 + }; + }; } diff --git a/src/Profile.cpp b/src/Profile.cpp index 270c7bd6e..8ed41f125 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -170,7 +170,7 @@ FallbackProfile::FallbackProfile() setProperty(BlinkingCursorEnabled, false); setProperty(BidiRenderingEnabled, true); - setProperty(CursorShape, BlockCursor); + setProperty(CursorShape, Enum::BlockCursor); setProperty(UseCustomCursorColor, false); setProperty(CustomCursorColor, Qt::black); setProperty(BellMode, NotifyBell); diff --git a/src/Profile.h b/src/Profile.h index dc7a9cda3..9e487af9a 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -211,20 +211,6 @@ public: MenuIndex }; - /** This enum describes the shapes used to draw the cursor in terminal - * displays. - */ - enum CursorShapeEnum { - /** Use a solid rectangular block to draw the cursor. */ - BlockCursor = 0, - /** Use an 'I' shape, similar to that used in text editing - * applications, to draw the cursor. - */ - IBeamCursor = 1, - /** Draw a line underneath the cursor's position. */ - UnderlineCursor = 2 - }; - /** This enum describes the behavior of triple click action . */ enum TripleClickModeEnum { /** Select the whole line underneath the cursor. */ diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 88be6699f..cab1187ef 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -301,7 +301,7 @@ TerminalDisplay::TerminalDisplay(QWidget* parent) , _lineSpacing(0) , _blendColor(qRgba(0, 0, 0, 0xff)) , _filterChain(new TerminalImageFilterChain()) - , _cursorShape(BlockCursor) + , _cursorShape(Enum::BlockCursor) , _antialiasText(true) , _sessionController(0) { @@ -505,11 +505,11 @@ void TerminalDisplay::drawLineCharString(QPainter& painter, int x, int y, const painter.setPen(originalPen); } -void TerminalDisplay::setKeyboardCursorShape(KeyboardCursorShape shape) +void TerminalDisplay::setKeyboardCursorShape(Enum::CursorShapeEnum shape) { _cursorShape = shape; } -TerminalDisplay::KeyboardCursorShape TerminalDisplay::keyboardCursorShape() const +Enum::CursorShapeEnum TerminalDisplay::keyboardCursorShape() const { return _cursorShape; } @@ -601,7 +601,7 @@ void TerminalDisplay::drawCursor(QPainter& painter, QColor cursorColor = _cursorColor.isValid() ? _cursorColor : foregroundColor; painter.setPen(cursorColor); - if (_cursorShape == BlockCursor) { + if (_cursorShape == Enum::BlockCursor) { // draw the cursor outline, adjusting the area so that // it is draw entirely inside 'rect' int penWidth = qMax(1, painter.pen().width()); @@ -620,13 +620,13 @@ void TerminalDisplay::drawCursor(QPainter& painter, invertCharacterColor = true; } } - } else if (_cursorShape == UnderlineCursor) + } else if (_cursorShape == Enum::UnderlineCursor) painter.drawLine(cursorRect.left(), cursorRect.bottom(), cursorRect.right(), cursorRect.bottom()); - else if (_cursorShape == IBeamCursor) + else if (_cursorShape == Enum::IBeamCursor) painter.drawLine(cursorRect.left(), cursorRect.top(), cursorRect.left(), diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h index 6cb911925..6c39d1b5e 100644 --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -197,24 +197,6 @@ public: void setSessionController(SessionController* controller); - /** - * This enum describes the available shapes for the keyboard cursor. - * See setKeyboardCursorShape() - */ - enum KeyboardCursorShape { - /** A rectangular block which covers the entire area of the cursor character. */ - BlockCursor, - /** - * A single flat line which occupies the space at the bottom of the cursor - * character's area. - */ - UnderlineCursor, - /** - * An cursor shaped like the capital letter 'I', similar to the IBeam - * cursor used in Qt/KDE text editors. - */ - IBeamCursor - }; /** * Sets the shape of the keyboard cursor. This is the cursor drawn * at the position in the terminal where keyboard input will appear. @@ -225,11 +207,11 @@ public: * * Defaults to BlockCursor */ - void setKeyboardCursorShape(KeyboardCursorShape shape); + void setKeyboardCursorShape(Enum::CursorShapeEnum shape); /** * Returns the shape of the keyboard cursor. See setKeyboardCursorShape() */ - KeyboardCursorShape keyboardCursorShape() const; + Enum::CursorShapeEnum keyboardCursorShape() const; /** * Sets the color used to draw the keyboard cursor. @@ -831,7 +813,7 @@ private: TerminalImageFilterChain* _filterChain; QRegion _mouseOverHotspotArea; - KeyboardCursorShape _cursorShape; + Enum::CursorShapeEnum _cursorShape; // custom cursor color. if this is invalid then the foreground // color of the character under the cursor is used diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 14db731f2..f3da6ef5b 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -813,12 +813,12 @@ void ViewManager::applyProfileToView(TerminalDisplay* view , const Profile::Ptr // cursor shape int cursorShape = profile->property(Profile::CursorShape); - if (cursorShape == Profile::BlockCursor) - view->setKeyboardCursorShape(TerminalDisplay::BlockCursor); - else if (cursorShape == Profile::IBeamCursor) - view->setKeyboardCursorShape(TerminalDisplay::IBeamCursor); - else if (cursorShape == Profile::UnderlineCursor) - view->setKeyboardCursorShape(TerminalDisplay::UnderlineCursor); + if (cursorShape == Enum::BlockCursor) + view->setKeyboardCursorShape(Enum::BlockCursor); + else if (cursorShape == Enum::IBeamCursor) + view->setKeyboardCursorShape(Enum::IBeamCursor); + else if (cursorShape == Enum::UnderlineCursor) + view->setKeyboardCursorShape(Enum::UnderlineCursor); // cursor color bool useCustomColor = profile->property(Profile::UseCustomCursorColor);