Jump to content

autocomplete - how to add "closers" (e.g. add "endif" when completing "if")


Recommended Posts

Hi.

Here's what I'm trying to do in SciTe:

I type "For"

Autocomplete box opens with "For" selected

I hit a hotkey, and the matching "Next" is typed on the next line.

I found a way to do this with "Func", but it only works if I type "Fun" then hit the {SPACE} key. "Fu" {SPACE} doesn't work, nor does "Func" {SPACE}.

Here's what autocomplete types when I type "fun" {SPACE}

Func _()
EndFunc

Id like this for "Do...Until", "While...Wend", ect...

Possible?

Link to comment
Share on other sites

  • Developers

Hi.

Here's what I'm trying to do in SciTe:

I type "For"

Autocomplete box opens with "For" selected

I hit a hotkey, and the matching "Next" is typed on the next line.

I found a way to do this with "Func", but it only works if I type "Fun" then hit the {SPACE} key. "Fu" {SPACE} doesn't work, nor does "Func" {SPACE}.

Here's what autocomplete types when I type "fun" {SPACE}

Func _()
EndFunc

Id like this for "Do...Until", "While...Wend", ect...

Possible?

Are you talking about the abbreviations option in stead of autocomplete?

When typing fun the text changes to red and then the space will auto expand to whatever is defined in the abbrev.properties file.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

here's a stab at it

... works most of the time

Opt("WinTitleMatchMode", 4)

HotKeySet("{ESC}", "Terminate")
HotKeySet("{F9}", "ShowMe")

While 1
    Sleep(100)
WEnd

Func ShowMe()
    $SciTE = '[CLASS:SciTEWindow]'
    $script = StringToBinary(ControlGetText($SciTE, '', '[CLASS:Scintilla; INSTANCE:1]'), 2)
    $script = BinaryToString($script, 1)
    $Split = StringSplit($script, @CRLF)
    $script = $Split[$Split[0]]

    Switch $script ; Add all the inputs you want here
        Case "Do"
            $stext = "Until"
        Case "While"
            $stext = "Wend"
        Case "Func"
            $stext = "EndFunc"
        Case "For"
            $stext = "Next"
        Case Else
            $stext = ""
    EndSwitch

    If $stext <> "" Then ControlSend("classname=SciTEWindow", "", "[CLASS:Scintilla; INSTANCE:1]", @CRLF & $stext & @CRLF & @CRLF)
EndFunc   ;==>ShowMe

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Developers

Very interesting find, typing "fun" and hitting the space key really does gives a prototype for a function.

This is the Abbreviations we (Mhz&I) have setup by adding an extra Lexer keyword, a LUA script and the abbrev.properties file.

Its documented in the SciTE4AutoIt3 helpfile that comes with the full install.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

This is the Abbreviations we (Mhz&I) have setup by adding an extra Lexer keyword, a LUA script and the abbrev.properties file.

Its documented in the SciTE4AutoIt3 helpfile that comes with the full install.

Jos

Whoa! I can't believe I missed this. It's beautiful. Thanks.

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...