diff --git a/src/Emulation.h b/src/Emulation.h --- a/src/Emulation.h +++ b/src/Emulation.h @@ -436,7 +436,7 @@ * @p shape cursor shape * @p isBlinking if true, the cursor will be set to blink */ - void setCursorStyleRequest(Enum::CursorShapeEnum shape = Enum::BlockCursor, bool isBlinking = false); + void setCursorStyleRequest(Enum::CursorStyleEnum style = Enum::BlockSteady); /** * Emitted when reset() is called to reset the cursor style to the * current profile cursor shape and blinking settings. diff --git a/src/Enumeration.h b/src/Enumeration.h --- a/src/Enumeration.h +++ b/src/Enumeration.h @@ -87,6 +87,30 @@ UnderlineCursor = 2 }; + /** This enum describes the styles used to draw the cursor in terminal + * displays, and which can be changed via DECSCUSR escape sequences. + * Basically each style is a combination of cursor shape and blinking + * settings. + */ + enum CursorStyleEnum { + /** Use a solid rectangular blinking block to draw the cursor. */ + BlockBlink = 1, + /** Use a solid rectangular steady block to draw the cursor. */ + BlockSteady = 2, + /** Draw a blinking line underneath the cursor's position. */ + UnderlineBlink = 3, + /** Draw a steady line underneath the cursor's position. */ + UnderlineSteady = 4, + /** Use a blinking 'I' shape, similar to that used in text editing + * applications, to draw the cursor. + */ + IBeamBlink = 5, + /** Use a steady 'I' shape, similar to that used in text editing + * applications, to draw the cursor. + */ + IBeamSteady = 6 + }; + /** This enum describes the behavior of triple click action . */ enum TripleClickModeEnum { /** Select the whole line underneath the cursor. */ diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -264,11 +264,10 @@ Enum::CursorShapeEnum keyboardCursorShape() const; /** - * Sets the Cursor Style (DECSCUSR) via escape sequences - * @p shape cursor shape - * @p isBlinking if true, the cursor will be set to blink + * Sets the Cursor Style (DECSCUSR) via escape sequences, defaults to + * drawing a steady solid rectangular block cursor. */ - void setCursorStyle(Enum::CursorShapeEnum shape, bool isBlinking); + void setCursorStyle(Enum::CursorStyleEnum style = Enum::BlockSteady); /** * Resets the cursor style to the current profile cursor shape and * blinking settings diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -769,10 +769,40 @@ return _cursorShape; } -void TerminalDisplay::setCursorStyle(Enum::CursorShapeEnum shape, bool isBlinking) +void TerminalDisplay::setCursorStyle(Enum::CursorStyleEnum style) { - setKeyboardCursorShape(shape); + Enum::CursorShapeEnum shape = Enum::BlockCursor; + bool isBlinking = false; + + switch(style) { + case Enum::BlockBlink: + shape = Enum::BlockCursor; + isBlinking = true; + break; + case Enum::BlockSteady: + shape = Enum::BlockCursor; + isBlinking = false; + break; + case Enum::UnderlineBlink: + shape = Enum::UnderlineCursor; + isBlinking = true; + break; + case Enum::UnderlineSteady: + shape = Enum::UnderlineCursor; + isBlinking = false; + break; + case Enum::IBeamBlink: + shape = Enum::IBeamCursor; + isBlinking = true; + break; + case Enum::IBeamSteady: + shape = Enum::IBeamCursor; + isBlinking = false; + break; + } + + setKeyboardCursorShape(shape); setBlinkingCursorEnabled(isBlinking); // when the cursor shape and blinking state are changed via the diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp --- a/src/Vt102Emulation.cpp +++ b/src/Vt102Emulation.cpp @@ -897,14 +897,14 @@ // Set Cursor Style (DECSCUSR), VT520, with the extra xterm sequences // the first one is a special case, 'ESC[ q', which mimics 'ESC[1 q' - case token_csi_sp ('q' ) : emit setCursorStyleRequest(Enum::BlockCursor, true); break; - case token_csi_psp('q', 0) : emit setCursorStyleRequest(Enum::BlockCursor, true); break; - case token_csi_psp('q', 1) : emit setCursorStyleRequest(Enum::BlockCursor, true); break; - case token_csi_psp('q', 2) : emit setCursorStyleRequest(Enum::BlockCursor, false); break; - case token_csi_psp('q', 3) : emit setCursorStyleRequest(Enum::UnderlineCursor, true); break; - case token_csi_psp('q', 4) : emit setCursorStyleRequest(Enum::UnderlineCursor, false); break; - case token_csi_psp('q', 5) : emit setCursorStyleRequest(Enum::IBeamCursor, true); break; - case token_csi_psp('q', 6) : emit setCursorStyleRequest(Enum::IBeamCursor, false); break; + case token_csi_sp ('q' ) : emit setCursorStyleRequest(Enum::BlockBlink ) ; break; + case token_csi_psp('q', 0) : emit setCursorStyleRequest(Enum::BlockBlink ) ; break; + case token_csi_psp('q', 1) : emit setCursorStyleRequest(Enum::BlockBlink ) ; break; + case token_csi_psp('q', 2) : emit setCursorStyleRequest(Enum::BlockSteady ) ; break; + case token_csi_psp('q', 3) : emit setCursorStyleRequest(Enum::UnderlineBlink ) ; break; + case token_csi_psp('q', 4) : emit setCursorStyleRequest(Enum::UnderlineSteady) ; break; + case token_csi_psp('q', 5) : emit setCursorStyleRequest(Enum::IBeamBlink ) ; break; + case token_csi_psp('q', 6) : emit setCursorStyleRequest(Enum::IBeamSteady ) ; break; //FIXME: weird DEC reset sequence case token_csi_pe('p' ) : /* IGNORED: reset ( ) */ break;