Bug 474448

Summary: Wish: Allow cursor placement by mouse click in the current command
Product: [Applications] konsole Reporter: Oliver Sander <oliver.sander>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED WORKSFORME    
Severity: wishlist CC: ninjalj
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: attachment-256621-0.html

Description Oliver Sander 2023-09-12 12:30:30 UTC
I sometimes find myself working with very long command lines in konsole.  One example are compiler invocations which can easily get 700 letters long.  In my workflow, I copy them from the clipboard into Konsole and then I need to edit them.

The problem is that it is very tedious to move around in such long lines.  I can jump to the beginning and to the end of the line with the Pos1 and End keys.  To move around I can go left and right with the arrow-left and arrow-right keys, and that's apparently it.  Unfortunately, moving around in such a long line with the two arrow keys only can take a long time.

My wish is that when I click onto the current command line the Konsole cursor moves to the position of the mouse cursor, just as it does in Kate or LibreOffice.
Comment 1 tcanabrava 2023-09-12 15:21:15 UTC
Created attachment 161581 [details]
attachment-256621-0.html

O believe that there’s no such thing as “cursor” in konsole. This is
implemented by terminal applications (such as bash). It’s not something
that Konsole controls.

I believe we *could* try to do something for the common standard of prompts
(bash,fish, zsh) but it will probably be a hack around it.

I don’t really know your usecase, but we already offer the “quick actions”
plugins for larger commands - would that work?

You can copy the test to it, edit as a text editor would; and execute from
the plugin.

On Tue, 12 Sep 2023 at 14:30 Oliver Sander <bugzilla_noreply@kde.org> wrote:

> https://bugs.kde.org/show_bug.cgi?id=474448
>
>             Bug ID: 474448
>            Summary: Wish: Allow cursor placement by mouse click in the
>                     current command
>     Classification: Applications
>            Product: konsole
>            Version: unspecified
>           Platform: Debian stable
>                 OS: Linux
>             Status: REPORTED
>           Severity: wishlist
>           Priority: NOR
>          Component: general
>           Assignee: konsole-devel@kde.org
>           Reporter: oliver.sander@tu-dresden.de
>   Target Milestone: ---
>
> I sometimes find myself working with very long command lines in konsole.
> One
> example are compiler invocations which can easily get 700 letters long.
> In my
> workflow, I copy them from the clipboard into Konsole and then I need to
> edit
> them.
>
> The problem is that it is very tedious to move around in such long lines.
> I
> can jump to the beginning and to the end of the line with the Pos1 and End
> keys.  To move around I can go left and right with the arrow-left and
> arrow-right keys, and that's apparently it.  Unfortunately, moving around
> in
> such a long line with the two arrow keys only can take a long time.
>
> My wish is that when I click onto the current command line the Konsole
> cursor
> moves to the position of the mouse cursor, just as it does in Kate or
> LibreOffice.
>
> --
> You are receiving this mail because:
> You are the assignee for the bug.
Comment 2 Oliver Sander 2023-09-12 16:06:27 UTC
Thank you for your help.

I kinda do understand why this is difficult to implement.  From a user perspective, however, the behavior is puzzling:  There is something that looks like a cursor in an editor, but I cannot move it by mouse clicks.

Thanks for pointing me to the QuickCommands plugin.  It feels clunky compared to my original wish, but it will nevertheless be helpful for me.

I quickly found several bugs concerning the plugin (for example, shift-ctrl-F1 will only open it if the menu bar is not hidden).  If you care I can file separate bug reports.

Feel free to close this issue if you think that it is unimplementable.
Comment 3 ninjalj 2023-09-15 14:04:00 UTC
There's support for this via semantic shell integration:

https://docs.kde.org/trunk5/en/konsole/konsole/semantic-shell-integration.html
 
Currently, konsole only includes shell code to enable semantic shell integration on bash. However, the shell integration script from the wezterm terminal emulator (https://github.com/wez/wezterm/blob/main/assets/shell-integration/wezterm.sh) also (mostly) works on konsole, and provides integration for zsh in addition to bash.

Also note that shells may provide more ways to edit command lines, e.g: bash in emacs mode recognizes Alt+f and Alt+b to move forwards or backwards a word, and these commands can be prefixed by a count, e.g: ESC+12, to move 12 words.
Comment 4 Oliver Sander 2023-09-21 12:57:37 UTC
Oh, indeed!  I should have read the documentation even more thoroughly. 

It is a bit nonobvious to set up, but then it does exactly what I wanted.

Thank you both!