Bug 347323 - Add support for changing cursor shape with extended DECSCUSR escape sequences
Summary: Add support for changing cursor shape with extended DECSCUSR escape sequences
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist with 60 votes (vote)
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-06 16:08 UTC by Shmerl
Modified: 2018-12-28 06:36 UTC (History)
15 users (show)

See Also:
Latest Commit:
Version Fixed In: 18.08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shmerl 2015-05-06 16:08:35 UTC
Current cursor shape changing (as implemented in bug #103399) uses non standard sequences, which parallel iTerm.

However various terminals now allow changing the cursor shape with extended DECSCUSR sequences. These sequences work in xterm (and should work also in gnome-terminal according to https://bugzilla.gnome.org/show_bug.cgi?id=720821):

# blinking block
printf '\e[1 q'
# steady block
printf '\e[2 q'
# blinking underscore
printf '\e[3 q'
# steady underscore
printf '\e[4 q'
# blinking bar
printf '\e[5 q'
# steady bar
printf '\e[6 q'

It would be good for Konsole to support them as well.

Reproducible: Always
Comment 1 Egmont Koblinger 2017-07-12 19:36:30 UTC
Yup gnome-terminal also supports these sequences.

Note that while more "standard" than the iTerm2 ones, these sequences kinda suck because most of the time an app wants to touch only the shape or only the blinking property, not both, which cannot be done with these sequences. It's a better design to have separate sequences for the two. Also, for each, there should be a way to revert to the terminal emulator's default as specified in its config.

The '\e[1 q' .. '\e[6 q' sequences are implemented in xterm and vte (gnome-terminal etc.) identically.

In xterm, the number 0 or omitting the number is the same as number 1.

In vte we intentionally differ, the number 0 or omitting the number means to revert to the default (the shape is taken from profile prefs, blinking is from GNOME-wide setting).
Comment 2 Scott Newton 2017-07-13 05:58:56 UTC
Related to this:
(tried sending this to the konsole-devel list but haven't seen it appear yet)

Don't know if any of you use neovim in konsole but it broke the other day. The 
fix apparently involves working around konsole not reporting if it supports 
DECSCUSR or not.

https://github.com/neovim/neovim/pull/6997/files
https://github.com/neovim/neovim/issues/7002

+ 
+ // Some terminals can not currently be trusted to report if they support 
+ // DECSCUSR or not. So we need to have a blacklist for when we should not 
+ // trust the reported features. 
+ if( (vte_version != 0 && vte_version < 3900) || konsole ) { 
+ data->unibi_ext.reset_cursor_style = -1; 
+ data->unibi_ext.set_cursor_style = -1; 
+ }
Comment 3 Radics Péter 2017-08-29 13:04:11 UTC
Would be nice if someone could pick this up, as a recent vim update also triggers the lack of DECSCUSR support in konsole.  See https://github.com/vim/vim/issues/2008 for details.
Comment 4 Ahmad Samir 2018-04-14 12:33:54 UTC
Should be fixed with this patch, which is being reviewed:
https://phabricator.kde.org/D12193
Comment 5 Kurt Hindenburg 2018-04-19 13:38:20 UTC
Git commit 7c2a1164be14ae912d166ee79d07cc45cb5e3aba by Kurt Hindenburg, on behalf of Ahmad Samir.
Committed on 19/04/2018 at 13:38.
Pushed by hindenburg into branch 'master'.

Add support for Set Cursor Style (DECSCUSR) escape sequences

Summary:
This follows the XTerm escape sequences, which include a couple more
shapes than what VT520 supports.
FIXED-IN: 18.08

Test Plan:
To test the escape sequences:
printf '\e[ q'		#blinking block
printf '\e[0 q'		# blinking block
printf '\e[1 q'		# blinking block
printf '\e[2 q'		# steady block
printf '\e[3 q'		# blinking underscore
printf '\e[4 q'		# steady underscore
printf '\e[5 q'		# blinking ibeam/bar
printf '\e[6 q'		# steady ibeam/bar

Executing `reset` in terminal will reset the cursor shape and blinking
settings to the current profile values.

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D12193

M  +14   -0    src/Emulation.h
M  +3    -0    src/Session.cpp
M  +30   -0    src/TerminalDisplay.cpp
M  +12   -0    src/TerminalDisplay.h
M  +34   -0    src/Vt102Emulation.cpp

https://commits.kde.org/konsole/7c2a1164be14ae912d166ee79d07cc45cb5e3aba
Comment 6 Ahmad Samir 2018-04-19 20:25:51 UTC
FWIW, I've filed[1] at neovim upstream, to bring this change to their attention; since now the workarounds/excludes they added for konsole in their code can be versioned.

As for vim[2], upstream didn't add in quirks for konsole, so no change is needed there AFAICT.

[1] https://github.com/neovim/neovim/issues/8300
[2] https://github.com/vim/vim/issues/2008
Comment 7 Kurt Hindenburg 2018-05-05 00:38:33 UTC
Git commit b0d3d83eca4f523a9e4acd3989da6be96033536a by Kurt Hindenburg, on behalf of Ahmad Samir.
Committed on 05/05/2018 at 00:38.
Pushed by hindenburg into branch 'master'.

Export KONSOLE_VERSION as an environment variable

Summary:
The env var is exported as a numeric string (by removing the dots from
the version string), this has the benefit of making it simpler to compare
the version in shell arithmetic expressions.

This should help programms like neovim check if konsole has support
for terminal capabilities (e.g. DECSCUSR) by using a condition that
checks the konsole version. See also:
https://github.com/neovim/neovim/issues/8300

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: #konsole

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D12621

M  +1    -0    src/SessionManager.cpp

https://commits.kde.org/konsole/b0d3d83eca4f523a9e4acd3989da6be96033536a
Comment 8 Shmerl 2018-12-20 19:43:16 UTC
Which konsole version will this be available in?
Comment 9 Ahmad Samir 2018-12-28 06:32:04 UTC
(In reply to Shmerl from comment #8)
> Which konsole version will this be available in?
(Look at the "Version Fixed In" field in this bug report, 18.08).
Comment 10 Shmerl 2018-12-28 06:36:13 UTC
Thanks for the pointer! Looks like Debian testing has been stuck with 18.04.0 for quite some time already.