mozers
Silver Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору save_settings.lua Код: -- Save SciTE Settings -- Version: 1.0 -- Autor: mozers™ --------------------------------------------------- -- При завершении работы SciTE (через меню или по шорткату) -- cохраняет размер и положение окна SciTE и другие текущие установки, измененные через меню -- Для работы требуется скрипт tools\save_settings.js -- Подключение: -- Добавьте в SciTEStartup.lua строку -- require (props["SciteDefaultHome"].."\\tools\\save_settings.lua") -- Задайте в файле .properties шорткаты для завершения работы SciTE -- user.shortcuts=\ -- Alt+X|IDM_QUIT|\ -- Alt+F4|IDM_QUIT| --------------------------------------------------- local function SaveSettings() if props['save.session'] == '1' then os.exec('wscript.exe "'..props["SciteDefaultHome"]..'\\tools\\save_settings.js"') os.msgbox ('Your settings are successfully saved!') end end local function fNOT (val) if val=='0' then return '1' elseif val=='1' then return '0' end end -- Добавляем свой обработчик события OnMenuCommand local old_OnMenuCommand = OnMenuCommand function OnMenuCommand(cmd, source) if old_OnMenuCommand then old_OnMenuCommand(cmd, source) end if cmd == 140 then -- IDM_QUIT SaveSettings() elseif cmd == 408 then -- IDM_VIEWTOOLBAR props['toolbar.visible'] = fNOT(props['toolbar.visible']) elseif cmd == 410 then -- IDM_VIEWTABBAR props['tabbar.visible'] = fNOT(props['tabbar.visible']) elseif cmd == 411 then -- IDM_VIEWSTATUSBAR props['statusbar.visible'] = fNOT(props['statusbar.visible']) elseif cmd == 402 then -- IDM_VIEWSPACE props['view.whitespace'] = fNOT(props['view.whitespace']) elseif cmd == 403 then -- IDM_VIEWEOL props['view.eol'] = fNOT(props['view.eol']) elseif cmd == 404 then -- IDM_VIEWGUIDES props['view.indentation.guides'] = fNOT(props['view.indentation.guides']) elseif cmd == 407 then -- IDM_LINENUMBERMARGIN props['line.margin.visible'] = fNOT(props['line.margin.visible']) elseif cmd == 413 then -- IDM_OPENFILESHERE props['check.if.already.open'] = fNOT(props['check.if.already.open']) elseif cmd == 401 then -- IDM_SPLITVERTICAL props['split.vertical'] = fNOT(props['split.vertical']) elseif cmd == 414 then -- IDM_WRAP props['wrap'] = fNOT(props['wrap']) elseif cmd == 415 then -- IDM_WRAPOUTPUT props['output.wrap'] = fNOT(props['output.wrap']) end end | Данный код внедрен в форум с помощью скрипта vladvro save_settings.js Код: // Save SciTE Settings // Version: 1.0 // Autor: mozers™ // ------------------------------------------------ // При завершении работы SciTE (через меню или по шорткату) // cохраняет размер и положение окна SciTE и другие текущие установки, измененные через меню // Вызывается из скрипта tools\save_settings.lua // Для работы требуется SciTE Helper <http://scite.ruteam.ru/poleznye-utility/scite-helper-dlya-upravleniya-redaktorom-iz-skriptov-i-programm> // ------------------------------------------------ var fso = new ActiveXObject("Scripting.FileSystemObject"); var ForReading = 1, ForWriting = 2, ForAppending = 8; var SciTE=new ActiveXObject("SciTE.Helper"); var props_file = SciTE.Props('SciteDefaultHome')+'\\SciTEGlobal.properties'; SaveProp('position.left', SciTE.Left); SaveProp('position.top', SciTE.Top); SaveProp('position.width', SciTE.Width); SaveProp('position.height', SciTE.Height); SaveProp('toolbar.visible', SciTE.Props('toolbar.visible')); SaveProp('tabbar.visible', SciTE.Props('tabbar.visible')); SaveProp('statusbar.visible', SciTE.Props('statusbar.visible')); SaveProp('view.whitespace', SciTE.Props('view.whitespace')); SaveProp('view.eol', SciTE.Props('view.eol')); SaveProp('view.indentation.guides', SciTE.Props('view.indentation.guides')); SaveProp('line.margin.visible', SciTE.Props('line.margin.visible')); SaveProp('check.if.already.open', SciTE.Props('check.if.already.open')); SaveProp('split.vertical', SciTE.Props('split.vertical')); SaveProp('wrap', SciTE.Props('wrap')); SaveProp('output.wrap', SciTE.Props('output.wrap')); function SaveProp(key, value){ var file = fso.OpenTextFile(props_file, ForReading); var text = file.ReadAll(); file.Close(); var re = new RegExp("(\n[\t ]*?"+key+"=).*?\n","ig"); text=text.replace(re,"$1"+value+"\n"); var file = fso.OpenTextFile(props_file, ForWriting); file.Write(text); file.Close(); } | Данный код внедрен в форум с помощью скрипта vladvro |