Hi,
Le 30/11/2017 à 17:35, Mikhail V a écrit :
> On Thursday, November 30, 2017 at 10:56:53 PM UTC+1, Neil Hodgson wrote:
>
> […] E.g. manually setting precise vertical indentation can really
> improve readability.
I'm not sure, but maybe you'd be interested about what some refer as
"elastic tab stops". I'm not sure if it made it to Scintilla, but I
think some people we working on it.
> Python source code contains regions where indentation is
> structurally-significant and other regions such as multi-line
> strings where the indentation does not affect the code structure.
>
> Restricting selection as a mechanism for imposing editing modes
> has proved complex as projects trying to use the current
> ‘changeable’ style attribute have found.
>
>
> Yes one of the main obstacles to a purist solution are multi-line
> contents, e,g, this is valid syntax:
>
> def many (
> somelongvariable1,
> somelongvariable2,
> somelongvariable3,
> somelongvariable4 ) :
>
> Even more, I can mix preceding tabs and spaces in this example, and
> still it'll compile correct.
It's not indentation in the Python sense of it here, that's why you can
use anything. But understanding this means you actually understand
Python, which IMO is partly out of the scope of Scintilla, and thus the
liberty should be left to the application.
> But many users wonder how would one align things nicely here?
> There is no definite answer, but there are workarounds.
> Having a separate control character for user-defined tabs versus old
> U+0009 tabs,
> could IMO provide a purist solution to the problematic, still Python
> does not have it.
Python actually recommends 4 spaces per indentation levels, not one tab.
Other people recommend indenting with tabs and aligning with spaces
(generally, not specifically for Python), which kind of make sense to me
-- although it's not really what I use myself most of the time, but
that's another question.
Anyway, PEP8 suggests a few options for your above example:
https://www.python.org/dev/peps/pep-0008/#indentation
My favorite is the "visual indent" with the opening delimiter, but
indeed you might want to leave this up to the user… but if you're
already hiding the indentation editing from your user, you could as well
do all the "code style" (wide sense of "indentation") automagically.
Which suggests to me the only feature you want is a non-editable region,
and leave the whole control of its content to the application. Possibly
having a "non-editable indentation" option could make sense to ease
implementation of this, but that seem to be about it to me right now --
and as Neil mentioned, it might even be a problem for some of the
indentation that's actually not really indentation)
> Thanks for the feedback. As for prototyping, the things I personally
> could make: […]
You probably could try using Scintilla's support for readonly portions
of text as Neil mentioned some apps are trying to make use of:
http://scintilla.org/ScintillaDoc.html#SCI_STYLESETCHANGEABLE
I'm not sure of the challenges here, but I guess it'd be possible to
implement the "simple" extra API to increase/decrease/set indentation
level/size and leave it unmodifiable by editing in your app's side.
Regards,
Colomban