Scite Misc Scripts |
|
function ToggleBinaryValue() local StartPos = editor.CurrentPos editor:WordRight() editor:WordLeftExtend() local Word = editor:GetSelText() if Word == "FALSE" then editor:ReplaceSel("TRUE") end if Word == "TRUE" then editor:ReplaceSel("FALSE") end if Word == "false" then editor:ReplaceSel("true") end if Word == "true" then editor:ReplaceSel("false") end if Word == "False" then editor:ReplaceSel("True") end if Word == "True" then editor:ReplaceSel("False") end if Word == "YES" then editor:ReplaceSel("NO") end if Word == "NO" then editor:ReplaceSel("YES") end if Word == "yes" then editor:ReplaceSel("no") end if Word == "no" then editor:ReplaceSel("yes") end if Word == "0" then editor:ReplaceSel("1") end if Word == "1" then editor:ReplaceSel("0") end editor:GotoPos(StartPos) end
function NumPlusPlus() output:ClearAll() local StartPos = editor.CurrentPos local CurLine = editor:LineFromPosition(StartPos) local fs,fe = editor:findtext("\-*[0-9]+", SCFIND_REGEXP,StartPos) editor:SetSel(fs,fe) local Number = editor:GetSelText() editor:ReplaceSel(Number + 1) editor:GotoPos(fs) end function NumMinusMinus() output:ClearAll() local StartPos = editor.CurrentPos local CurLine = editor:LineFromPosition(StartPos) local fs,fe = editor:findtext("\-*[0-9]+", SCFIND_REGEXP,StartPos) editor:SetSel(fs,fe) local Number = editor:GetSelText() editor:ReplaceSel(Number - 1) editor:GotoPos(fe) end
function transpose_characters() local pos = editor.CurrentPos editor:GotoPos(pos-1) editor.Anchor = pos+1 local sel = editor:GetSelText() editor:ReplaceSel(string.sub(sel, 2, 2)..string.sub(sel, 1, 1)) editor:GotoPos(pos) end
command.name.12.*=InsertDate command.12.*=InsertDate command.subsystem.12.*=3 command.mode.12.*=savebefore:no command.shortcut.12.*=Ctrl+d
Add the following lines into Lua Startup Script:
function InsertDate() editor:AddText(os.date("%Y-%m-%d")) end
--Klaus Hummel--
This version replaces the current selection, if there is one:
-- replace current selection with text -- if there is none, insert at cursor position function replaceOrInsert(text) local sel = editor:GetSelText() if string.len(sel) ~= 0 then editor:ReplaceSel(text) else editor:AddText(text) end end -- insert the current date in YYYY-mm-dd format function insertDate() replaceOrInsert(os.date("%Y-%m-%d")) end
And another function for inserting the current time:
-- insert the current time in HH:MM:SS Timezone format function insertTime() replaceOrInsert(os.date("%H:%M:%S %Z")) end
--Chris Arndt--
function SciTECalculator() local expr = editor:GetSelText() if not expr or expr == "" then return end local f, msg = loadstring("return "..expr) if not f then print(">Calculator: cannot evaluate selection") return end editor:ReplaceSel(tostring(f())) end
--khman--
local findText = editor:GetSelText() local flag = 0 output:ClearAll() if string.len(findText) > 0 then trace('>find: '..findText..'\n') local s,e = editor:findtext(findText,flag,0) local m = editor:LineFromPosition(s) - 1 local count = 0 while s do local l = editor:LineFromPosition(s) if l ~= m then count = count + 1 local str = string.gsub(' '..editor:GetLine(l),'%s+',' ') local add = ':'..(l + 1)..':' local i = 8 - string.len(add) local ind = ' ' while (string.len(ind) < i) do ind = ind..' ' end trace(add..ind..str..'\n') m = l end s,e = editor:findtext(findText,flag,e+1) end trace('>result: '..count..'\n') else trace('! Select symbol and replay') end
--gans_A--