diff --git a/lib/Character.h b/lib/Character.h index 9a0a42d..536cd63 100644 --- a/lib/Character.h +++ b/lib/Character.h @@ -45,8 +45,9 @@ static const int LINE_DOUBLEHEIGHT = (1 << 2); #define RE_UNDERLINE (1 << 2) #define RE_REVERSE (1 << 3) // Screen only #define RE_INTENSIVE (1 << 3) // Widget only -#define RE_CURSOR (1 << 4) -#define RE_EXTENDED_CHAR (1 << 5) +#define RE_ITALIC (1 << 4) +#define RE_CURSOR (1 << 5) +#define RE_EXTENDED_CHAR (1 << 6) /** * A single character in the terminal which consists of a unicode character diff --git a/lib/Vt102Emulation.cpp b/lib/Vt102Emulation.cpp index da2e223..7429c10 100644 --- a/lib/Vt102Emulation.cpp +++ b/lib/Vt102Emulation.cpp @@ -60,7 +60,8 @@ using namespace Konsole; Vt102Emulation::Vt102Emulation() : Emulation(), - _titleUpdateTimer(new QTimer(this)) + _titleUpdateTimer(new QTimer(this)), + _reportFocusEvents(false) { _titleUpdateTimer->setSingleShot(true); QObject::connect(_titleUpdateTimer , SIGNAL(timeout()) , this , SLOT(updateTitle())); @@ -555,6 +556,7 @@ void Vt102Emulation::processToken(int token, int p, int q) case TY_CSI_PS('m', 0) : _currentScreen->setDefaultRendition ( ); break; case TY_CSI_PS('m', 1) : _currentScreen-> setRendition (RE_BOLD ); break; //VT100 + case TY_CSI_PS('m', 3) : _currentScreen-> setRendition (RE_ITALIC ); break; //VT100 case TY_CSI_PS('m', 4) : _currentScreen-> setRendition (RE_UNDERLINE); break; //VT100 case TY_CSI_PS('m', 5) : _currentScreen-> setRendition (RE_BLINK ); break; //VT100 case TY_CSI_PS('m', 7) : _currentScreen-> setRendition (RE_REVERSE ); break; @@ -562,6 +564,7 @@ void Vt102Emulation::processToken(int token, int p, int q) case TY_CSI_PS('m', 11) : /* IGNORED: mapping related */ break; //LINUX case TY_CSI_PS('m', 12) : /* IGNORED: mapping related */ break; //LINUX case TY_CSI_PS('m', 22) : _currentScreen->resetRendition (RE_BOLD ); break; + case TY_CSI_PS('m', 23) : _currentScreen->resetRendition (RE_ITALIC ); break; //VT100 case TY_CSI_PS('m', 24) : _currentScreen->resetRendition (RE_UNDERLINE); break; case TY_CSI_PS('m', 25) : _currentScreen->resetRendition (RE_BLINK ); break; case TY_CSI_PS('m', 27) : _currentScreen->resetRendition (RE_REVERSE ); break; @@ -625,6 +628,8 @@ void Vt102Emulation::processToken(int token, int p, int q) case TY_CSI_PN('B' ) : _currentScreen->cursorDown (p ); break; //VT100 case TY_CSI_PN('C' ) : _currentScreen->cursorRight (p ); break; //VT100 case TY_CSI_PN('D' ) : _currentScreen->cursorLeft (p ); break; //VT100 + case TY_CSI_PN('E' ) : /* Not implemented: cursor next p lines */ break; //VT100 + case TY_CSI_PN('F' ) : /* Not implemented: cursor preceding p lines */ break; //VT100 case TY_CSI_PN('G' ) : _currentScreen->setCursorX (p ); break; //LINUX case TY_CSI_PN('H' ) : _currentScreen->setCursorYX (p, q); break; //VT100 case TY_CSI_PN('I' ) : _currentScreen->tab (p ); break; @@ -739,6 +744,24 @@ void Vt102Emulation::processToken(int token, int p, int q) case TY_CSI_PR('s', 1003) : saveMode (MODE_Mouse1003); break; //XTERM case TY_CSI_PR('r', 1003) : restoreMode (MODE_Mouse1003); break; //XTERM + case TY_CSI_PR('h', 1004) : _reportFocusEvents = true; break; + case TY_CSI_PR('l', 1004) : _reportFocusEvents = false; break; + + case TY_CSI_PR('h', 1005) : setMode (MODE_Mouse1005); break; //XTERM + case TY_CSI_PR('l', 1005) : resetMode (MODE_Mouse1005); break; //XTERM + case TY_CSI_PR('s', 1005) : saveMode (MODE_Mouse1005); break; //XTERM + case TY_CSI_PR('r', 1005) : restoreMode (MODE_Mouse1005); break; //XTERM + + case TY_CSI_PR('h', 1006) : setMode (MODE_Mouse1006); break; //XTERM + case TY_CSI_PR('l', 1006) : resetMode (MODE_Mouse1006); break; //XTERM + case TY_CSI_PR('s', 1006) : saveMode (MODE_Mouse1006); break; //XTERM + case TY_CSI_PR('r', 1006) : restoreMode (MODE_Mouse1006); break; //XTERM + + case TY_CSI_PR('h', 1015) : setMode (MODE_Mouse1015); break; //URXVT + case TY_CSI_PR('l', 1015) : resetMode (MODE_Mouse1015); break; //URXVT + case TY_CSI_PR('s', 1015) : saveMode (MODE_Mouse1015); break; //URXVT + case TY_CSI_PR('r', 1015) : restoreMode (MODE_Mouse1015); break; //URXVT + case TY_CSI_PR('h', 1034) : /* IGNORED: 8bitinput activation */ break; //XTERM case TY_CSI_PR('h', 1047) : setMode (MODE_AppScreen); break; //XTERM @@ -757,6 +780,11 @@ void Vt102Emulation::processToken(int token, int p, int q) case TY_CSI_PR('h', 1049) : saveCursor(); _screen[1]->clearEntireScreen(); setMode(MODE_AppScreen); break; //XTERM case TY_CSI_PR('l', 1049) : resetMode(MODE_AppScreen); restoreCursor(); break; //XTERM + case TY_CSI_PR('h', 2004) : setMode (MODE_BracketedPaste); break; //XTERM + case TY_CSI_PR('l', 2004) : resetMode (MODE_BracketedPaste); break; //XTERM + case TY_CSI_PR('s', 2004) : saveMode (MODE_BracketedPaste); break; //XTERM + case TY_CSI_PR('r', 2004) : restoreMode (MODE_BracketedPaste); break; //XTERM + //FIXME: weird DEC reset sequence case TY_CSI_PE('p' ) : /* IGNORED: reset ( ) */ break; @@ -883,6 +911,32 @@ void Vt102Emulation::sendMouseEvent( int cb, int cx, int cy , int eventType ) sendString(command); } +/** + * The focus lost event can be used by Vim (or other terminal applications) + * to recognize that the konsole window has lost focus. + * The escape sequence is also used by iTerm2. + * Vim needs the following plugin to be installed to convert the escape + * sequence into the FocusLost autocmd: https://github.com/sjl/vitality.vim + */ +void Vt102Emulation::focusLost(void) +{ + if (_reportFocusEvents) + sendString("\033[O"); +} + +/** + * The focus gained event can be used by Vim (or other terminal applications) + * to recognize that the konsole window has gained focus again. + * The escape sequence is also used by iTerm2. + * Vim needs the following plugin to be installed to convert the escape + * sequence into the FocusGained autocmd: https://github.com/sjl/vitality.vim + */ +void Vt102Emulation::focusGained(void) +{ + if (_reportFocusEvents) + sendString("\033[I"); +} + void Vt102Emulation::sendText( const QString& text ) { if (!text.isEmpty()) diff --git a/lib/Vt102Emulation.h b/lib/Vt102Emulation.h index 802cfc5..2f235fc 100644 --- a/lib/Vt102Emulation.h +++ b/lib/Vt102Emulation.h @@ -42,10 +42,14 @@ #define MODE_Mouse1001 (MODES_SCREEN+4) // Use Hilight mouse tracking #define MODE_Mouse1002 (MODES_SCREEN+5) // Use cell motion mouse tracking #define MODE_Mouse1003 (MODES_SCREEN+6) // Use all motion mouse tracking -#define MODE_Ansi (MODES_SCREEN+7) // Use US Ascii for character sets G0-G3 (DECANM) -#define MODE_132Columns (MODES_SCREEN+8) // 80 <-> 132 column mode switch (DECCOLM) -#define MODE_Allow132Columns (MODES_SCREEN+9) // Allow DECCOLM mode -#define MODE_total (MODES_SCREEN+10) +#define MODE_Mouse1005 (MODES_SCREEN+7) // Xterm-style extended coordinates +#define MODE_Mouse1006 (MODES_SCREEN+8) // 2nd Xterm-style extended coordinates +#define MODE_Mouse1015 (MODES_SCREEN+9) // Urxvt-style extended coordinates +#define MODE_Ansi (MODES_SCREEN+10) // Use US Ascii for character sets G0-G3 (DECANM) +#define MODE_132Columns (MODES_SCREEN+11) // 80 <-> 132 column mode switch (DECCOLM) +#define MODE_Allow132Columns (MODES_SCREEN+12) // Allow DECCOLM mode +#define MODE_BracketedPaste (MODES_SCREEN+13) // Xterm-style bracketed paste mode +#define MODE_total (MODES_SCREEN+14) namespace Konsole { @@ -91,6 +95,8 @@ public slots: virtual void sendText(const QString& text); virtual void sendKeyEvent(QKeyEvent*); virtual void sendMouseEvent(int buttons, int column, int line, int eventType); + virtual void focusLost() Q_DECL_OVERRIDE; + virtual void focusGained() Q_DECL_OVERRIDE; protected: // reimplemented from Emulation @@ -184,6 +190,8 @@ private: //output from the terminal QHash _pendingTitleUpdates; QTimer* _titleUpdateTimer; + + bool _reportFocusEvents; }; }