gnunn1 / tilix

A tiling terminal emulator for Linux using GTK+ 3
https://gnunn1.github.io/tilix-web
Mozilla Public License 2.0
5.36k stars 293 forks source link

Feature request: strip trailing space when copying #2161

Open taoky opened 1 year ago

taoky commented 1 year ago

Currently, Tilix supports stripping trailing space on paste. However, it is sometimes cumbersome that some trailing spaces are copied from Tilix.

Example: on copying in Tilix (and other terminal emulators that doesn't support this feature[^1]), the following result may happen ($ is marked as the end of line)

user@hostname /b/grub> ls                                                                                                                    $
fonts/  grub.cfg  grubenv  locale/  themes/  x86_64-efi/$

Instead of this:

user@hostname /b/grub> ls$
fonts/  grub.cfg  grubenv  locale/  themes/  x86_64-efi/$

I have read some code of Tilix, and find out that it's VTE whom is responsible for copying selected texts (vte.copyClipboard() and vte.copyClipboardFormat(VteFormat.HTML)). However, there is nothing like VteFormat.TextWithoutTrailingSpace within VTE's API. So I guess this feature can only be implemented for text copying -- it sounds not like a good idea to implement this feature for "Copy as HTML". When this proposed option is on:

  1. Get selected text with VTE's API (and strip trailing space).
  2. Manually put it into clipboard instead of directly using vte.copyClipboard()

I'm not quite sure whether Tilix would accept this idea, and I'm also not quite familiar with D. However, if this is acceptable, I'm willing to give it a try and submit a PR if it works.

[^1]: As far as I know, Konsole and Xterm support stripping trailing space when copying.