Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Improved auto-complete for SciTE


  • Please log in to reply
43 replies to this topic
Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Update (v0.5):
[*:uvmajp09]Fixed CASE_CORRECT feature sometimes inserting the wrong word; e.g inserting Disable after typing disabled.

malikos42
  • Members
  • 1 posts
  • Last active: Jul 12 2012 04:46 PM
  • Joined: 12 Jul 2012
Thanks for the info.

stevenp
  • Members
  • 197 posts
  • Last active: Sep 23 2014 05:47 PM
  • Joined: 28 Aug 2006
recently an error was pop-up in the Output pane:
...\Documents\AutoHotkey\SciTE/UserLuaScript.lua:222: Pane function / readable property / indexed writable property name expected
is there a way to suppress such errors?
"Simplifying complexity is not simple"

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
The error message tells you there's something wrong with the script. I wouldn't want to suppress it.

I believe you already know the solution to this particular problem. For anyone else:

With the new version of SciTE, it looks like editor:GetLexerLanguage() will need to be changed to editor.LexerLanguage.



Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

The next step would be to denote a type of the symbol - an icon to indicate whether it is a function or a variable in the auto-completion list

I believe this can be done via Lua, but it is not something I consider important.

Is there a way to set auto-completion list height?

Yes! :)

Find this line:
editor:AutoCShow(len, list)
Above it, add the following:
editor.AutoCMaxHeight = 15
While you're at it, may as well add:
editor.AutoCCaseInsensitiveBehaviour = 1 -- Do NOT pre-select the first case-sensitive match
This requires Scintilla 3.1.0 or later; the latest SciTE4AutoHotkey will do. This bug ticket describes the problem with the default behaviour. Unfortunately there doesn't appear to be a SciTE property for it yet.

FYI, SciTE Pane API.

stevenp
  • Members
  • 197 posts
  • Last active: Sep 23 2014 05:47 PM
  • Joined: 28 Aug 2006
It's great that you know SciTE API so good.
Thanks for the help and the directions!
"Simplifying complexity is not simple"

stevenp
  • Members
  • 197 posts
  • Last active: Sep 23 2014 05:47 PM
  • Joined: 28 Aug 2006
error messages keep coming when selecting items with the arrow-keys in the auto-completion list
changingeditor:GetLexerLanguage() to editor.LexerLanguage doesn't suppress them (latest scite4autohotkey july 22 build)
...strator\Documents\AutoHotkey\SciTE/UserLuaScript.lua:222: Pane function / readable property / indexed writable property name expected
...strator\Documents\AutoHotkey\SciTE/UserLuaScript.lua:222: Pane function / readable property / indexed writable property name expected
...strator\Documents\AutoHotkey\SciTE/UserLuaScript.lua:216: Pane function / readable property / indexed writable property name expected
...strator\Documents\AutoHotkey\SciTE/UserLuaScript.lua:216: Pane function / readable property / indexed writable property name expected

"Simplifying complexity is not simple"

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
Same problem - they changed some "Get" and "Set" functions to properties. Just find those lines (double-click them in the output pane), remove "Get" or "Set" and (), and change : to ..

stevenp
  • Members
  • 197 posts
  • Last active: Sep 23 2014 05:47 PM
  • Joined: 28 Aug 2006
Changed editor:AutoCGetCurrent() to editor.AutoCCurrent and errors gone
Another issue introduced with UserLuaScript.lua - when the end of the list is reached with arrow keys, the cursor is moving. It would be great when the last item of the list is reached then the first item in the list will be selected and vice versa.
"Simplifying complexity is not simple"

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

when the end of the list is reached with arrow keys, the cursor is moving.

That's the whole point of the AutoCCurrent checks, as indicated in the comments.

editor.AutoCCurrent is read-only, but I suppose you could figure out which item is at the top/bottom and call editor:AutoCSelect(item).

stevenp
  • Members
  • 197 posts
  • Last active: Sep 23 2014 05:47 PM
  • Joined: 28 Aug 2006

editor:AutoCSelect(string text) -- Select the item in the auto-completion list that starts with a string.

can't use editor:AutoCSelect(0) because the parameter is not an index, but a string
tried to use editor:AutoCSelect(menuItems[1]), but this returns an error:

UserLuaScript.lua:230: attempt to index global 'menuItems' (a nil value)


"Simplifying complexity is not simple"

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
1. That's why I said "figure out which item".
2. menuItems is a local variable. You'd need to do something about that first.

stevenp
  • Members
  • 197 posts
  • Last active: Sep 23 2014 05:47 PM
  • Joined: 28 Aug 2006
Tried changing local menuItems = {} to global menuItems = {} with no luck.
I'm totally newbie in lua scripting, could you please help with this?
hopefully at least the editor.AutoCSelect() is already correct
elseif key == 0x26 then -- VK_UP
        if editor.AutoCCurrent == 0 then
            -- User is probably trying to move the caret, since they're
            -- already at the top of the list.
            -- selecting Last item
            editor.AutoCSelect(#menuItems-1)
        end
    elseif key == 0x28 then -- VK_DOWN
        if editor.AutoCCurrent == lastAutoCItem then
            -- As above, but for the bottom of the list.
            -- selecting First item
            editor:AutoCSelect(menuItems[1])
        end

"Simplifying complexity is not simple"

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
I've updated the script to work with the latest SciTE, and made further changes:
[*:mxj89ks8]Added WRAP_ARROW_KEYS option.
[*:mxj89ks8]When CASE_CORRECT is true, case-correction happens immediately if CASE_CORRECT_INSTANT is also true, even if there are other matching items. This was previously the default behaviour, but turned out to be annoying.
For stevep's reference: <!-- m -->http://lua-users.org...i/ScopeTutorial<!-- m -->

stevenp
  • Members
  • 197 posts
  • Last active: Sep 23 2014 05:47 PM
  • Joined: 28 Aug 2006
Thanks!
Hopefully there'll be no need for new changes, I'm pretty happy with it now.
"Simplifying complexity is not simple"