Bug 457810 - Smarter "pipe to terminal" action
Summary: Smarter "pipe to terminal" action
Status: RESOLVED WAITINGFORINFO
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-12 19:59 UTC by Mehrad Mahmoudian
Modified: 2025-04-17 16:50 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mehrad Mahmoudian 2022-08-12 19:59:03 UTC
## Summary

At the moment the "pipe to terminal" behaves very primitively, and I'm suggesting a more advanced and modern way of working.

## Current behavior

At the moment, if a text is selected, it would be sent to the terminal. I no text was selected, it will send the whole content of the file. This is somewhat equivalent of `eval-region` and `eval-buffer` in Emacs, except it sends the strings to the terminal blindly and with a universal warning regardless of the state of the terminal.

## Proposal

### Context awareness

The only usage of sending anything to terminal/console is for interpretative languages that has some sort of REPL. For compiling languages this feature is totally useless. For this reason, it would be nice that Kate is context aware and shows warning if terminal is not in a REPL mode.

### Smarter sending

When scripting in any interpretative language, there are three type of running a user would like to do:
1. sending the selection
2. sending the current line or block
3. sending the whole file

The first type is very obvious, if a text was selected, only and only send that string. But if no text was not selected, send the line or block. Deciding if to send a line or block is actually very simple as it is already in Kate. If the current line is foldable (i.e in the gutter near the line number it has the triangle to fold it), run the whole block, if not, run the line.

As for the third type, usually a different key binding is used in all text editors and IDEs I have seen.

### Step forward

usually when someone is running a script line-by-line (or block-by-block), they want to run it, and move the cursor to the end of the next non-empty line to be able to run that. In many IDEs and editors, there are two keybindings, one that steps forward, and one that keeps the cursor at where it was. I personally almost never used/needed the latter and I have exclusively used the former.

I will be happy to elaborate more if something in your opinion is missing or if the picture I'm trying to paint here is vague and unclear.
Comment 1 Christoph Cullmann 2025-04-17 16:50:54 UTC
Thanks for that idea.

We don't have that level of integration with the terminal.
If one wants to enhance that, one would first patch Konsole to detect all that, which seems non trivial.

Patches are welcome, but I don't see us working on that.

https://kate-editor.org/post/2020/2020-07-18-contributing-via-gitlab-merge-requests/