--[[-------------------------------------------------- new_file.lua mozers™ version 1.5 ---------------------------------------------- Заменяет стандартную команду SciTE "File|New" (Ctrl+N) Создает новый буфер в текущем каталоге с расширением текущего файла Благодаря этому, сразу же включаются все фичи лексера (подсветка, подсказки и пр.) ---------------------------------------------- Подключение: В файл SciTEStartup.lua добавьте строку: dofile (props["SciteDefaultHome"].."\\tools\\new_file.lua") --]]---------------------------------------------------- props["untitled.file.number"] = 0 local function FileExist(path) if (os.rename (path,path)) then return true else return false end end local function CreateUntitledFile() local file_ext = "."..props["FileExt"] if file_ext == "." then file_ext = props["default.file.ext"] end repeat local file_path = props["FileDir"].."\\"..'Untitled'..props["untitled.file.number"]..file_ext props["untitled.file.number"] = tonumber(props["untitled.file.number"]) + 1 if not FileExist(file_path) then io.output(file_path) io.write("") io.close() scite.Open(file_path) os.remove(file_path) return true end until false end -- Add user event handler OnMenuCommand local old_OnMenuCommand = OnMenuCommand function OnMenuCommand (msg, source) local result if old_OnMenuCommand then result = old_OnMenuCommand(msg, source) end if msg == IDM_NEW then if CreateUntitledFile() then return true end end return result end |