From 5680f974ab28d436ef29bf562e124fbd3937b96d Mon Sep 17 00:00:00 2001 From: George Nachman Date: Thu, 14 May 2020 00:19:05 -0700 Subject: [PATCH] Add support for DECSCUSR 0 to reset cursor style & blink to user default. Issue 8769 --- sources/PTYSession.m | 5 +++++ sources/VT100Screen.m | 4 ++++ sources/VT100ScreenDelegate.h | 3 +++ sources/VT100Terminal.m | 14 ++++++++------ sources/VT100TerminalDelegate.h | 3 +++ 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/sources/PTYSession.m b/sources/PTYSession.m index 29cece3da9..8efd66f712 100644 --- a/sources/PTYSession.m +++ b/sources/PTYSession.m @@ -9285,6 +9285,11 @@ - (void)screenSetCursorBlinking:(BOOL)blink { [[self textview] setBlinkingCursor:blink]; } +- (void)screenResetCursorTypeAndBlink { + self.cursorTypeOverride = nil; + self.textview.blinkingCursor = [iTermProfilePreferences boolForKey:KEY_BLINKING_CURSOR inProfile:self.profile]; +} + - (void)screenGetCursorType:(ITermCursorType *)cursorTypeOut blinking:(BOOL *)blinking { *cursorTypeOut = self.cursorType; diff --git a/sources/VT100Screen.m b/sources/VT100Screen.m index b42537038b..5ae8a2eccf 100644 --- a/sources/VT100Screen.m +++ b/sources/VT100Screen.m @@ -3284,6 +3284,10 @@ - (void)terminalGetCursorType:(ITermCursorType *)cursorTypeOut [delegate_ screenGetCursorType:cursorTypeOut blinking:blinking]; } +- (void)terminalResetCursorTypeAndBlink { + [delegate_ screenResetCursorTypeAndBlink]; +} + - (void)terminalSetLeftMargin:(int)scrollLeft rightMargin:(int)scrollRight { if (currentGrid_.useScrollRegionCols) { currentGrid_.scrollRegionCols = VT100GridRangeMake(scrollLeft, diff --git a/sources/VT100ScreenDelegate.h b/sources/VT100ScreenDelegate.h index 7396836ea8..ff426cb454 100644 --- a/sources/VT100ScreenDelegate.h +++ b/sources/VT100ScreenDelegate.h @@ -49,6 +49,9 @@ - (void)screenGetCursorType:(ITermCursorType *)cursorTypeOut blinking:(BOOL *)blinking; +- (void)screenResetCursorTypeAndBlink; + + // Returns if the screen is permitted to resize the window. - (BOOL)screenShouldInitiateWindowResize; diff --git a/sources/VT100Terminal.m b/sources/VT100Terminal.m index 7c8923e140..20e46d6d4f 100644 --- a/sources/VT100Terminal.m +++ b/sources/VT100Terminal.m @@ -1676,28 +1676,30 @@ - (void)executeToken:(VT100Token *)token { case VT100CSI_DECSCUSR: switch (token.csi->p[0]) { case 0: + [delegate_ terminalResetCursorTypeAndBlink]; + break; case 1: - [delegate_ terminalSetCursorBlinking:true]; + [delegate_ terminalSetCursorBlinking:YES]; [delegate_ terminalSetCursorType:CURSOR_BOX]; break; case 2: - [delegate_ terminalSetCursorBlinking:false]; + [delegate_ terminalSetCursorBlinking:NO]; [delegate_ terminalSetCursorType:CURSOR_BOX]; break; case 3: - [delegate_ terminalSetCursorBlinking:true]; + [delegate_ terminalSetCursorBlinking:YES]; [delegate_ terminalSetCursorType:CURSOR_UNDERLINE]; break; case 4: - [delegate_ terminalSetCursorBlinking:false]; + [delegate_ terminalSetCursorBlinking:NO]; [delegate_ terminalSetCursorType:CURSOR_UNDERLINE]; break; case 5: - [delegate_ terminalSetCursorBlinking:true]; + [delegate_ terminalSetCursorBlinking:YES]; [delegate_ terminalSetCursorType:CURSOR_VERTICAL]; break; case 6: - [delegate_ terminalSetCursorBlinking:false]; + [delegate_ terminalSetCursorBlinking:NO]; [delegate_ terminalSetCursorType:CURSOR_VERTICAL]; break; } diff --git a/sources/VT100TerminalDelegate.h b/sources/VT100TerminalDelegate.h index 0665e1db95..d3f2de33c6 100644 --- a/sources/VT100TerminalDelegate.h +++ b/sources/VT100TerminalDelegate.h @@ -131,6 +131,9 @@ typedef NS_ENUM(int, VT100TerminalColorIndex) { // Changes whether the cursor blinks. - (void)terminalSetCursorBlinking:(BOOL)blinking; +// Reset type and blink to default +- (void)terminalResetCursorTypeAndBlink; + // Returns the current cursor style as a DECSCUSR param. - (void)terminalGetCursorType:(ITermCursorType *)cursorTypeOut blinking:(BOOL *)blinking;