-- edit by kinn scite_Command { 'maintain tools |ShowMaintain|Ctrl+F8' } --print('test========='..lua_LoadPath()) local my_path=lua_LoadPath() local len = string.len local cmd_copy_lua_to_shareTmp=' ' local cmd_copy_lua_from_shareTmp=' ' local cmd_make_zip=' ' local cmd_update=' ' local dis_cmd_cpy={} local begcpyPos, endcpyPos,cmdStartcpyPos,cmdendcpyPos,cpToSharePos,cpFromSharePos,makeZipFromScite scite_OnInit(function(order1,order2) if order1==0 and order2 ==0 then local f = io.open(my_path.."/maintain_tool.cnf", "r") if not f then return false end for line in f:lines() do local field,Value=line:match('^([^=]+)=(.*)$') if field == 'begcpyPos' then begcpyPos=tonumber(Value) elseif field == 'endcpyPos' then endcpyPos=tonumber(Value) elseif field == 'cmdStartcpyPos' then cmdStartcpyPos=tonumber(Value) elseif field == 'cmdendcpyPos' then cmdendcpyPos=tonumber(Value) elseif field == 'cpToSharePos' then cpToSharePos=tonumber(Value) elseif field == 'cpFromSharePos' then cpFromSharePos=tonumber(Value) elseif field == 'makeZipFromScite' then makeZipFromScite=tonumber(Value) end end f:close() end return false end) scite_OnFinalise(function() local f = io.open(my_path.."/maintain_tool.cnf", "w") if not f then return false end if begcpyPos then f:write('begcpyPos='..begcpyPos..'\n') f:write('endcpyPos='..endcpyPos..'\n') f:write('cmdStartcpyPos='..cmdStartcpyPos..'\n') f:write('cmdendcpyPos='..cmdendcpyPos..'\n') f:write('cpToSharePos='..cpToSharePos..'\n') f:write('cpFromSharePos='..cpFromSharePos..'\n') f:write('makeZipFromScite='..makeZipFromScite..'\n') else --os.remove(my_path.."/ctagsdx.cnf") f:write() end f:close() return false end) function PosMaintainAdjust(diff) begcpyPos = begcpyPos+diff endcpyPos = endcpyPos+diff cmdStartcpyPos = cmdStartcpyPos+diff cmdendcpyPos = cmdendcpyPos+diff cpToSharePos = cpToSharePos +diff cpFromSharePos = cpFromSharePos+diff makeZipFromScite = makeZipFromScite+diff end function AdjustMaintainDelete(bPos,ePos) --print('AdjustMaintainDelete'..bPos..','..ePos..':'..begcpyPos..':'..endcpyPos) --pane.Focus and if begcpyPos and endcpyPos > begcpyPos then if ePos <= begcpyPos then local diff=(ePos-bPos) PosMaintainAdjust(-diff) elseif bPos >= endcpyPos then --print('-----') else begcpyPos=-1 endcpyPos=-1 end end end function AdjustMaintainAdd(count) if begcpyPos and endcpyPos > begcpyPos then if output.CurrentPos <= begcpyPos then PosMaintainAdjust(count) elseif output.CurrentPos < endcpyPos then --begcpyPos=begcpyPos+count begcpyPos=-1 endcpyPos=-1 --return true end end return false end scite_OnKey(function(keyval, shift,ctl,atl) --print(keyval) --print('start:'..output.SelectionStart..',end:'..output.SelectionEnd) if output.Focus and not shift and not ctl and not atl and ( keyval <37 or keyval > 40) then if output.SelectionStart cmdStartcpyPos and output.CurrentPos < cmdendcpyPos then if output.CurrentPos < cpToSharePos then copy_to_shareTmp() updateCpyContent() elseif output.CurrentPos < cpFromSharePos then copy_from_shareTmp() updateCpyContent() elseif output.CurrentPos < makeZipFromScite then make_zip_from_scite() updateCpyContent() elseif output.CurrentPos < cmdendcpyPos then updateCpyContent() end end return true end)