Skip to content

Add semantic shell integration

Matan Ziv-Av requested to merge matan/konsole:semantic into master

This MR adds support for simplified version of semantic shell integration, as described here.

The first commit adds the infrastructure. It interprets the OSC 133 escape sequences, and keeps track of the current mode (out of three: prompt, user input and command output), where on the screen it started, where is the last character. It also keeps track for each character on screen to which mode it belongs, and for each line, which modes started on it.

It also, independently stores each line length (the rightmost column that was written to).

The remaining commits use this for various user interface enhancements:

  • shift+ctrl+pgup scrolls up to the next line with prompt.
  • When URL hints are shown, also show shell hints: prompt becomes darker, user input becomes brighter, and a thin line separates eac command output from the following prompt.
  • Filtered copy. When semantically marked text is selected, the context menu has options to copy to the clipboard only the user input (filtering out prompts and command outputs), or only output, or both.
  • In input lines longer than screen width of characters, up and down arrow keys move the cursor one line up or down, by sending the necessary amount of left/right arrow keys to the shell.

In order to use those, the shell needs to send the correct escape sequences at the correct places. For bash, something like this is necessary:

PS1='\[\e]133;L\a\]\[\e]133;A\a\]'$PS1'\[\e]133;B\a\]'
PS2='\[\e]133;A\a\]'$PS2'\[\e]133;B\a\]'
PS0='\[\e]133;C\a\]'

Merge request reports