Nice, thanks Chris.
Regarding the matching of brace/bracket: how about adding this (which
should hopefully cover most other use cases):
If after pressing CTRL-E, your backup handling code triggers, then it
does exactly what it does now, with one further/final check:
* Is the cursor *now* on an opening bracket/brace? If so, then done
(current behavior already).
* If not, then look for the last opening bracket/brace on the line
that it's now on (perhaps optionally - to be thorough - one that isn't
within a trailing comment), and move the cursor to its position.
* If the above doesn't find an opening bracket/brace, then leave the
cursor at the beginning of the line - done.
If the followup worked, then further pressing of CTRL-E will then
automatically revert to the original CTRL-E handler.
This will then also handle typical cases of e.g.:
function name(p1, foo(), 'ex') {/*...*/} //Matches the opening brace here.
if ( //Matches this opening bracket.
a == b &&
c !== d &&
//bunch of other conditions...
) ...; //...
I can foresee some cases where this won't find the "right" opening
bracket/brace for that indentation level, and trying to handle
everything would be too much trouble (or not work for everything
anyway due the variety of languages to be dealt with), but if the
simple cases - which are likely the majority anyway - were to all
work, then those that don't, shouldn't be a problem.
Either way - with or without this further extension - I'll make very
good use of it. :-)
Cheers,
Ric.
On Thu, Apr 18, 2013 at 4:18 AM, Rosuav <
ros...@gmail.com> wrote:
> On Tuesday, 16 April 2013 11:55:16 UTC+10, Ric Borg wrote:
>> Is anyone interested in adding this?
>> (I use Scite, but I don't know how to add to or extend its features,
>> and am too busy with other projects to go investigating at this time.)
>
> After some discussion about the matter, I told Ric (my boss at work) that there was a reasonable chance that I might just up and do this, at home, as an excuse to figure out how much I can do with Lua in SciTE. Turns out that happened, except for the part about Lua... the Ctrl-E handler is written in C++, so that's where the edit is.
>
> I'm not sure how to attach files in Google Groups, so I may have to send a separate list email later; in any case, the patch is a fairly simple insertion of code, no external edits required. Alternatively, the patch is here:
http://rosuav.com/SciTE_ctrl_e.patch
>
> The concept is as follows: When Ctrl-E is pressed (IDM_MATCHBRACE / GoMatchingBrace() - same thing happens with IDM_SELECTTOBRACE), if there's no brace/bracket to match, the current cursor column is recorded. It then scans upward through the buffer until it finds a line whose indent is less than the column we're scanning AND has content in it, and puts the cursor on that line.
>
> The original theory of holding Shift to move downward conflicts conceptually with Ctrl-Shift-E to select the region, and also doesn't play so nicely with Python, so I didn't implement that. It'd be easy enough to do, though (just change "--line;" to "if (select) ++line; else --line;"), if anyone thinks it'd be better that way.
>
> Ric, I'll apply the patch to the build we use on Friday, so you can try this out.
>
> Chris Angelico
>
> --
> You received this message because you are subscribed to the Google Groups "scite-interest" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
scite-interes...@googlegroups.com.
> To post to this group, send email to
scite-i...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/scite-interest?hl=en.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
>