Neil wrote:
NH>  You could try writing your own version in Lua.
You have forced me to write it:

SciTEStartup.lua:
> -------------------------------------------------------------------------
function AutocompleteObject(char)
    if not (char == "." or char == ":" or char == " " or char == "(") then
        return false
    end

    -- get api file (not use pattern in prop! :(
    local api_filename = props['api.*.'..props['FileExt']]
    local api_file = io.open(api_filename)
    if not api_file then
        return false
    end

    -- get object name
    local object = GetWordLeft()
    local len_obj = string.len(object)
    if len_obj == 0 then
        return false
    end

    -- find methods and properties object's in api file (create UserList)
    local object_api = ''
    local user_list = {}
    for line in api_file:lines() do
        local api_object = string.sub(line,1,len_obj+1)
        if string.upper(api_object) == string.upper(object)..char then
            object_api = string.sub(api_object,1,len_obj)
            if not (char == " " or char == "(") then
                local str_method = string.sub(line,len_obj+2)
                local end_str = string.find(str_method,'[^a-zA-Z]')
                if end_str ~= nil then
                    str_method = string.sub(str_method, 1, end_str-1)
                end
                table.insert (user_list,str_method)
            end
        end
    end
    api_file:close()

    -- correct register of symbols (sample: wscript -> WScript)
    if object_api ~= '' then
        local s = pos - 1 - len_obj
        editor:SetSel(s, pos - 1)
        editor:ReplaceSel(object_api)
        editor:CharRight()
    end 

    -- show UserList
    local list_count = table.getn(user_list)
    if list_count > 0 then
        table.sort(user_list)
        local s = table.concat(user_list, " ")
        editor:UserListShow(10, s)
        return true
    else
        return false
    end
end

function GetWordLeft()
    pos = editor.CurrentPos
    editor:CharLeft()
    editor:WordLeftExtend()
    local sel_text = editor:GetSelText()
    editor:CharRight()
    editor:CharRight()
    sel_text = string.gsub(sel_text, ".*[.:]", '')
    return sel_text
end

function InsertProp(tp,sel_value)
    if tp == 10 then
        local pos_new = editor.CurrentPos
        if pos_new ~= pos then
            editor:SetSel(pos, pos_new)
            editor:DeleteBack()
        end
        editor:InsertText(-1, sel_value)
        pos = pos + string.len(sel_value)
        editor.CurrentPos = pos
        editor:CharRight()
        return true
    else
        return false
    end
end

-- ======================================================
function OnChar(charAdded)
    local ret = AutocompleteObject(charAdded)
    return ret
end

function OnUserListSelection(tp,sel_value)
    InsertProp(tp,sel_value)
end

> -------------------------------------------------------------------------

It is necessary to add to a file .properties (for example for LUA):
> ----------------------------------------------------
# Not it is possible api.$(file.patterns.lua)!
api.*.lua=$(SciteDefaultHome)\api\SciTELua.api
calltip.lua.parameters.start= ([
calltip.lua.parameters.separators=,
calltip.lua.word.characters=$(chars.alpha)$(chars.numeric)_-:.
autocomplete.lua.start.characters=.:
autocomplete.*.ignorecase=1
calltip.*.ignorecase=1
> ----------------------------------------------------

The full and correctly made api-files are necessary for good job.
Sample http://scite.ruteam.ru/engine/upfiles/mozers/SciTELua_api.zip

You can download SciTE-Ru from 
http://scite.ruteam.ru/scite/sborki/scite-ru-board
http://scite.ruteam.ru/engine/upfiles/mozers/SciTE_170_8Ru_100706.zip
there all is included and adjusted already.
As well there are lots of other interesting solutions.
(Warning: only russian face)

-- 
mozers
<http://scite.ruteam.ru>

_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to