Bug 456736 - Kate KCommandBar Ctrl+Alt+I Improvements
Summary: Kate KCommandBar Ctrl+Alt+I Improvements
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: general (show other bugs)
Version: 22.04.2
Platform: Other Other
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-15 01:38 UTC by Chris Holland
Modified: 2024-08-01 19:52 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Holland 2022-07-15 01:38:47 UTC
Via: https://old.reddit.com/r/kde/comments/vyuynb/which_ide_or_editor_do_kde_programmers_use_to/ig5gpvd/?context=3

Kate doesn't have a simple "Word Wrap: Toggle". There's:
"Kate Part: Apply Word Wrap" (nope)
"Kate Part: Static Word Wrap" (nope)
"Kate Part: Dynamic Word Wrap" (works as a toggle) but the naming is terrible. There's no indication that it's a toggle in the name, nor a checkmark.

Ah, I forgot to test selecting Syntax. Hmm, seems that all "set syntax" options are duplicated. There's two "3D: STL".
Also, "Configuration: INI" doesn't indicate that you are setting the syntax.

Git support hasn't been implemented yet, but I guess I'll mention to to look into SublimeText's GitAddSelectedHunkCommand but that's way down the line.
https://github.com/kemayo/sublime-text-git/blob/master/git/add.py#L47

Ability to quickly set Indentation via KCommandBar is also a 3rd party plugin.
https://github.com/fjl/Sublime-Missing-Palette-Commands/blob/st3/Missing.sublime-commands#L166
There's also a few interesting commands in there like "Split Into Lines", though Kate seems to already have VSCode's "Insert cursor at end of each line selected" (Shift+Alt+I).
https://stackoverflow.com/questions/54130822/how-to-split-selection-into-lines

Not sure if this is Kate or KCommandBar, but the Command Palette seems to be full of "Kate Part:" and "Kate Project Manager:" prefixes... but those labels aren't searchable. The above labels aren't very useful either. Should be "Git: Checkout Branch" instead of "Kate Project Manager: Checkout Git Branch" (though I understand Git is a WIP).


Links: https://api.kde.org/frameworks/kconfigwidgets/html/classKCommandBar.html
Comment 1 Waqar Ahmed 2022-07-15 06:48:15 UTC
Hi, thanks for your interest.

> Git support hasn't been implemented yet, but I guess I'll mention to to look into SublimeText's GitAddSelectedHunkCommand but that's way down the line.
> https://github.com/kemayo/sublime-text-git/blob/master/git/add.py#L47

Which git features did you not find? We have most of the common features. See https://invent.kde.org/utilities/kate/-/issues/24

> Kate doesn't have a simple "Word Wrap: Toggle". There's:
> "Kate Part: Apply Word Wrap" (nope)
> "Kate Part: Static Word Wrap" (nope)
> "Kate Part: Dynamic Word Wrap" (works as a toggle) but the naming is terrible. There's no indication that it's a toggle in the name, nor a checkmark

> Ah, I forgot to test selecting Syntax. Hmm, seems that all "set syntax" options are duplicated. There's two "3D: STL".
> Also, "Configuration: INI" doesn't indicate that you are setting the syntax.

True, its confusing. The reason there are two is because one is Mode and the other is Highlighting. They have slightly different roles.

Because all the three types of wraps you mention, fall under the "Word Wrap" category and if you check the main menu, you will find these options listed under View->Word Wrap -> ....

Thus its hard to name it just "word wrap". Dynamic word wrap is not as terrible a name as you think, its used commonly for the feature it implements. Maybe there are other better names though, not sure.

> Ability to quickly set Indentation via KCommandBar is also a 3rd party plugin.

Not sure what you mean by 3rd party plugin. You can change the indentation in the statusbar (for the open document only). Kate has auto indent detection so I don't bother with changing indent settings anymore.

> There's also a few interesting commands in there like "Split Into Lines", though Kate seems to already have VSCode's "Insert cursor at end of each line selected" (Shift+Alt+I).
> https://stackoverflow.com/questions/54130822/how-to-split-selection-into-lines

Split into lines is already available indirectly: 
- Select
- Alt Shift I
- Shift Home (will select to line start) or Home and then Shift+End

Since kate is scriptable, See: https://docs.kde.org/trunk5/en/kate/katepart/dev-scripting.html#dev-scripting-api
You can extend kate to add your commands etc. Multicursors aren't yet exposed in the scripting api but you can lodge your reasoning here: https://invent.kde.org/frameworks/ktexteditor/-/issues/12

> Not sure if this is Kate or KCommandBar, but the Command Palette seems to be full of "Kate Part:" and "Kate Project Manager:" prefixes... but those labels aren't searchable. The above labels aren't very useful either. Should be "Git: Checkout Branch" instead of "Kate Project Manager: Checkout Git Branch" (though I understand Git is a WIP).

The reason for "Prefix:" is that actions come from different plugins / menus so we prefix them with that menu/plugin name to add context to the name of the action.

Git is not a WIP since at least 1.5 years now. See the issue I linked at the top of thread.
Comment 2 Chris Holland 2022-07-15 22:06:46 UTC
> Which git features did you not find? We have most of the common features. See https://invent.kde.org/utilities/kate/-/issues/24

See: https://i.imgur.com/Bauese2.png
See: https://old.reddit.com/r/kde/comments/vyuynb/which_ide_or_editor_do_kde_programmers_use_to/ig56mrj/?context=2

None of them appear in the KCommandBar except:

* Git: Gitk (gui app)
* Git: git blame (gui app)
* Kate Project Manager: Checkout Git Branch

SublimeText and VSCodium have:
https://gist.github.com/Zren/c0282057009270035ff42f0d9cfac9a0

> True, its confusing. The reason there are two is because one is Mode and the other is Highlighting. They have slightly different roles.

Uhg, so syntax switches both the color/format+autocomplete+snippets, but highlight only switches the color/format? They definitely need to be labeled in KCommandBar. Actually, just hide the Highlight actions from KCommandBar, because that feature is way too niche imo.

> Because all the three types of wraps you mention, fall under the "Word Wrap" category and if you check the main menu, you will find these options listed under View->Word Wrap -> ....

Not every "setting" should be quickly accessed. Only the quick word wrap toggle imo.

Sublime only exposes:
Wrap at ruler
Word Wrap: Toggle

VSCodium:
View: Toggle Word Wrap

However in sublime's menu is:
Edit > Wrap > Wrap Paragraph at Ruler
Edit > Wrap > Wrap Paragraph at 70 characters
Edit > Wrap > Wrap Paragraph at 72 characters
Edit > Wrap > Wrap Paragraph at 78 characters
Edit > Wrap > Wrap Paragraph at 80 characters
Edit > Wrap > Wrap Paragraph at 100 characters
Edit > Wrap > Wrap Paragraph at 120 characters
View > Word Wrap
View > Word Wrap Column > Automatic
View > Word Wrap Column > 70
View > Word Wrap Column > 72
View > Word Wrap Column > 78
View > Word Wrap Column > 80
View > Word Wrap Column > 100
View > Word Wrap Column > 120

And VSCodium has this in it's settings:
https://i.imgur.com/xNXuvh8.png

> Not sure what you mean by 3rd party plugin. You can change the indentation in the statusbar (for the open document only). Kate has auto indent detection so I don't bother with changing indent settings anymore.

I'd honestly forgotten it showed in the statusbar in ST and VSCodium. I've not touched it since installing Sublime 3rd party plugin "Missing Commands" which adds the "Tab Width 2/4" custom commands to Sublime. I sometimes adjust the autodetect from Tab Width 2 > 4 which is nice to do from the keyboard. It typically happens in markdown, where md lists are 2 spaces, but code tags are 4 spaces.

Kate doesn't seem to have Convert to Spaces/Tabs though which both Sublime and VSCodium have by default. I'll need to lookup if there's a feature request for it.
Comment 3 Waqar Ahmed 2022-07-15 22:26:31 UTC
Yes, most of the git actions aren't available in the command bar. This has been fixed in master.

Besides that, not going to hide anything from the command bar, unless it makes no sense at all. In your opinion they may not be necessary, but that's not true for everyone. CommandBar is supposed to allow you to access every action in the main menu. You only care about dynamic word wrap but someone else might want static word wrap instead. 

Also, note that these actions that you see in the menu, especially those that are related to configuration are _different_ from what's in the settings dialog. These actions usually only apply to the current visible view/editor/document and not all your open documents. So for e.g changing the color scheme, will only change it for the current document, not all others. 

Also, note that for everything you see (and more) in the command bar, you can add shortcuts for stuff that you want to use often. 

> Kate doesn't seem to have Convert to Spaces 

What do you mean? 
- Convert an existing document with tabs to spaces? That would be just search and replace. 
- Tab presses otherwise are automatically converted to spaces
Comment 4 Chris Holland 2022-07-16 00:06:08 UTC
> You only care about dynamic word wrap but someone else might want static word wrap instead. 

I was more concerned on how to turn word wrap off. I guess the user is suppose to already know where it is in the menubar before they know about KCommandBar Ctrl+Alt+I so they know what to select. I assumed it was radiobutton, but it turns out it's 2 checkboxes. The heck is Static Wrap... oh it's the ruler.

Both Sublime and VSCode seem to call "Static Wrap" rulers.
https://stackoverflow.com/questions/25900954/80-characters-right-margin-line-in-sublime-text-3
https://stackoverflow.com/questions/29968499/vertical-rulers-in-visual-studio-code

Perhaps this:
View: Toggle Word Wrap
View: Toggle Wrap At Ruler
View: Toggle Ruler or Show/Hide Ruler

The main issues stem from KCommandBar not supporting a checked property / checkbox. Since it doesn't seem to have separate text for the MenuBar Action and KCommandBar. "Toggle Word Wrap" might look weird in the MenuBar.

Is it possible to automate adding a "Toggle " prefix or suffix to the action name in KCommandBar if it has action.checkable=true?

> Convert an existing document with tabs to spaces? That would be just search and replace. 

Yes that. A naive "    " => "\t" replace would replace indents in comments, and possible in code strings "Blah    Blah". Since you're editing every since line, it might not show up easily on a diff. To properly replace indentation you'd need to use "^(\t|\s{4})*(\s{4})" => "\1\t" or something complicated like that. In any case, it's one of those commands that's a nice to have that both ST and VSCodium have by default.
Comment 5 Waqar Ahmed 2022-07-16 08:04:33 UTC
For the command bar improvements/suggestions and other renamings, I would suggest you to open an issue in the Kate repo instead because this needs discussion and more people might be able to participate that way.

For the tab replacement, that is a proper feature request, so it can stay on Bugzilla. Though a separate issue for it would be nice. If you know Javascript, you can try to implement such a thing and maybe contribute :)

Repo: https://invent.kde.org/utilities/kate
Comment 6 Bug Janitor Service 2024-07-31 12:06:02 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/ktexteditor/-/merge_requests/708
Comment 7 Christoph Cullmann 2024-08-01 19:52:13 UTC
Git commit 62bfaa50055a589ad923caf58726249ea0b9e6c6 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 01/08/2024 at 19:47.
Pushed by cullmann into branch 'master'.

Add actions to convert spaces to tabs and vice versa

M  +3    -1    src/data/katepart5ui.rc
M  +22   -0    src/view/kateview.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/62bfaa50055a589ad923caf58726249ea0b9e6c6