Перейти из форума на сайт.

НовостиФайловые архивы
ПоискАктивные темыТоп лист
ПравилаКто в on-line?
Вход Забыли пароль? Первый раз на этом сайте? Регистрация
Компьютерный форум Ru.Board » Компьютеры » Программы » SciTE - Open Source Text Editor for Windows & Linux

Модерирует : gyra, Maz

Widok (09-10-2007 14:48): лимит страниц. продолжаем здесь  Версия для печати • ПодписатьсяДобавить в закладки
На первую страницук этому сообщениюк последнему сообщению

   

dB6



Full Member
Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору

Код:
 -- Expand abbreviations and show tooltip when appropriated.  by Jos van der Zande (JdeB)
-- changed yumax#301170722  
function Abbreviations()
    -- get current word
    from = editor:WordStartPosition(editor.CurrentPos-2)  
    to = editor:WordEndPosition(editor.CurrentPos-2)
    curword = editor:textrange(from, to)
    if string.sub(curword,1,1) == ' ' and string.sub(curword,2,2) == ' ' then  
        curword = string.sub(curword,3,-1)
        from = from - 2;
    end
     print(from..' '..to..'-'..curword..'-'..editor.CurrentPos)
    -- get possible replacement from abbrev.properties
    local repword = ""
    ext = props['FileExt']
--~     abbrev_file = props['abbrev.$(file.patterns.'..ext..')'];
    abbrev_file = props['abbrev.properties'];
--~      print(abbrev_file)
--~     local f = io.open(abbrev_file)
    local f = io.open(props['SciteDefaultHome'].."\\abbrev.properties")
     
    if f ~= nil then
        local Abbrevtxt = f:read('*a')
        if Abbrevtxt then
            f:close()
            local rep_start = string.find(Abbrevtxt,"\n" .. string.lower(curword) .. "=")
             
--             print('-'..Abbrevtxt..'-'..curword..'-',rep_start,"-\n" .. string.lower(curword)..'-')
            if rep_start ~= nil and rep_start ~= 0 then
               rep_start = rep_start + string.len(curword) + 2
               rep_end = string.find(Abbrevtxt .. "\n","\n",rep_start)-1
               repword = string.sub(Abbrevtxt .. "\n",rep_start,rep_end)
--                    _ALERT("rep_start:" ..rep_start.. "rep_end:"..rep_end )
            end
        end
    end
    -- if found process it
--     _ALERT("abbr:" .. curword .. "  replaced by: " .. repword .. "|" )
    if repword ~= nil and repword ~= "" then
        -- get indent info
        local s_indent = ""
         if editor.LineIndentation[editor:LineFromPosition(editor.CurrentPos)] then
            currentindent =  editor.LineIndentation[editor:LineFromPosition(editor.CurrentPos)]
--             _ALERT(currentindent)
            if editor.UseTabs then
                n_idents = editor.LineIndentation[editor:LineFromPosition(editor.CurrentPos)] / editor.TabWidth
                s_indent = string.rep("\t",n_idents)
            else
                n_idents = editor.LineIndentation[editor:LineFromPosition(editor.CurrentPos)]
                s_indent = string.rep(" ",n_idents)
            end
         end
        --end
        -- remove current word
        editor:remove(from, to +1)
        -- replace text \n for LF plus the indent info  
        repword =  string.gsub(repword, "\\n", "\n" .. s_indent)
        -- replace text \t for TAB
        repword =  string.gsub(repword, "\\t", "\t")
        -- find caret position in the word
        tcaretpos = string.find(repword,"|")  
        -- when string to insert contains | then calculate the pos and remove it
        if tcaretpos ~= nil and tcaretpos ~= 0 then
            caretposword = string.find(repword,"|") -1
            caretpos = from + string.find(repword,"|") -1
            repword = string.gsub(repword, "|", "")
        else
            -- set caret pos to the end of the inserted string
            caretposword = 0
            caretpos = from + string.len(repword)
        end
        editor:insert(from,repword)
        editor:GotoPos(caretpos)
        --
        -- try to create the tooltip()
        -- get keyword/function name  part infront of the (
        braceopenpos = string.find(repword,"%(")  
        braceclosepos = string.find(repword,"%)")  
        -- when string to insert contains | then calculate the pos and remove it
        --_ALERT(braceclosepos)
        if braceclosepos ~= nil and braceclosepos < caretposword then
            -- caret pos not inside the first function  
            repword = ""
        elseif braceopenpos then
            -- get keyword/function name  part infront of the |
            repword = string.sub(repword,1,braceopenpos-1)
        elseif caretposword ~= 0 then            
            repword = string.sub(repword,1,caretposword)
        else
            repword = ""
        end
        --_ALERT("repword:" .. repword )
        if repword ~= "" and braceopenpos then
            f = io.open(props['SciteDefaultHome'].."\\api\\au3.api")
            if f ~= nil then
                local apitxt = f:read('*a')
                if apitxt then
                    f:close()
                    local rep_start = string.find(string.lower(apitxt),"\n" .. string.lower(repword).."[\n ]")
                    if rep_start ~= nil then
                        rep_end = string.find(apitxt,"\n",rep_start+2)-1
                        repword = string.sub(apitxt,rep_start+1,rep_end)
                        -- put the description on the next line..
                        repword =  string.gsub(repword, "%)", "%)\n",1)
                        editor:CallTipShow(caretpos, repword)
                    end
                end
            end
        end
    end
end  

Всего записей: 408 | Зарегистр. 09-02-2003 | Отправлено: 13:32 18-04-2006 | Исправлено: dB6, 13:35 18-04-2006
   

На первую страницук этому сообщениюк последнему сообщению

Компьютерный форум Ru.Board » Компьютеры » Программы » SciTE - Open Source Text Editor for Windows & Linux
Widok (09-10-2007 14:48): лимит страниц. продолжаем здесь


Реклама на форуме Ru.Board.

Powered by Ikonboard "v2.1.7b" © 2000 Ikonboard.com
Modified by Ru.B0ard
© Ru.B0ard 2000-2024

BitCoin: 1NGG1chHtUvrtEqjeerQCKDMUi6S6CG4iC

Рейтинг.ru