Add indent/dedent functionality to editor that ships with scripter script.
Previously tab key added 4 spaces whereever the cursor was. With this commit tab indents selected lines by 2 characters and shift-tab dedents by a the same amount. Empty lines are not indented and dedenting stops once code has reached left hand margin.
2 chars is hard coded but could be a setting later. Chose 2 chars because default editor window is relatively narrow
Details
- Reviewers
- None
- Group Reviewers
Krita - Maniphest Tasks
- T7627: Generic Scripter UI improvements task
- Commits
- R37:944047983146: Add indent/dedent to python editor in scripter
Run scripter
load or type a multiline script
move cursor to a line, press tab/shift-tab.
select 2 or more lines press tab/shift tab.
select empty lines or lines with only whitespace and press tab/shift-tab
In each case:
Confirm shift tab stops dedenting at left hand margin for each line independently
Confirm tab does not add indents to whitespace-only lines.
Move cursor to middle of text - no selection, press tab - line should indent, no whitespace should be inserted in middle of text
move cursor to end of line, press return press tab - should add whitespace to start typing indented code
Diff Detail
- Repository
- R37 Krita
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
I have added tab/shift tab functionality for the python-editor in scripter.
Not sure whether I am supposed to also open an issue in the bug tracker.
I am thinking of other ui improvements to the editor that may affect this file. Am not sure what I'm supposed to do to handle this conflict if it arises. What do I diff against?
Additional changes to allow case:
press return, tab to indent, start code
Previous wouldn't indent to avoid unecessary whitespace padding in selections.
incremental diff because git diff HEAD doesn't seem to be working for me
Previous patch introduced bug - pressing tab in the middle of text when there is no selection inserted whitespace in the middle of the code.
This checks that the cursor is at the end of the text block before inserting spaces
Note: This is an incremental diff. Also, the diff is marked up as against https://phabricator.kde.org/D9430 not as against the previous patch.
That's really cool! I'm really happy that someone is workink on this code. There's a lot a things to do and time it's running out on my researching project. Keep going :)