Generic Scripter UI improvements task - Add auto-indent to scripter editor
ClosedPublic

Authored by brendanbd on Dec 20 2017, 11:00 PM.

Details

Summary

Add auto-indent functionality to scripter editor

This diff is marked up as against diff 3 in https://phabricator.kde.org/D9419 - that is https://phabricator.kde.org/D9419?id=24161

Test Plan

The return key has just been pressed (and processed by the editor)
now insert leading spaces to reflect an appropriate indent level
against the previous line.
This will depend on the end of the previous line. If it ends:

  • with a colon (:) then indent to a new indent level
  • with a comma (,) then this is an implied continuation line, probably in the middle of a function's parameter list
    • look for last open bracket on previous line (, [ or {
    • if found indent to that level + one character,
    • otherwise use previous line whitespace, this is probably a list or parameter list so line up with other elements
  • with a backslash (\) then this is a continuation line, probably on the RHS of an assignment
    • similar rules as for comma, but if there is an = character use that plus one indent level if that is greater
  • if it is an open bracket of some sort treat similarly to comma
  • anything else - a new line at the same indent level. This will preserve the indent level of whitespace lines. User can shift-tab to dedent as necessary

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.
brendanbd created this revision.Dec 20 2017, 11:00 PM
Restricted Application added a subscriber: woltherav. · View Herald TranscriptDec 20 2017, 11:00 PM
brendanbd requested review of this revision.Dec 20 2017, 11:00 PM
rempt accepted this revision.Jan 23 2018, 9:29 AM
This revision is now accepted and ready to land.Jan 23 2018, 9:29 AM
Closed by commit R37:bec922f9f5f1: Add auto-indent functionality to Python Scripter editor (authored by Brendan Bd <bunf2014@apps.opensourcelaw.biz>). · Explain WhyJan 26 2018, 5:40 AM
This revision was automatically updated to reflect the committed changes.