BugFix Posted December 30, 2011 Share Posted December 30, 2011 (edited) Hi,with this LUA script you can hide temporary all comment lines in opened autoit script, or if needed delete them.It takes affect only for script lines which including only comment lines (or lines inside comment blocks). White space before is respected.Comments after other stuff will ignored.- Rename attached file to CommentsDelHide.lua- Save the script CommentsDelHide.lua into your folder: ..AutoIt3SciTELUA- Open the file ..USERSciTEUser.properties in editor- Insert above:#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-## START: DO NOT CHANGE ANYTHING AFTER THIS LINE #-#-#-#-#following lines:# 49 Delete Commentscommand.name.49.*=Delete Commentscommand.mode.49.*=subsystem:lua,savebefore:yescommand.is.filter.49.*.au3=0command.49.*=CommentsDeletecommand.shortcut.49.*.au3=Ctrl+Shift+L# 48 Hide Commentscommand.name.48.*=Hide Commentscommand.mode.48.*=subsystem:lua,savebefore:yescommand.is.filter.48.*.au3=0command.48.*=CommentsHidecommand.shortcut.48.*.au3=Ctrl+Shift+HYou can change shortcuts if you want.If you have no own entries here, start with number 36 instead 48.In your file ..AutoIt3SciTELUASciTEStartup.lua add following entry at end of file:LoadLuaFile("CommentsDelHide.lua")To hide comment lines use Ctrl+Shift+H (or other defined shortcut) in your autoit script.You can show the command lines again by:- Reload file (menu file) or- Change to another tab in SciTE and backTo delete this lines use Strg+Shift+L (or other defined shortcut) in your autoit script.expandcollapse popup-- TIME_STAMP 2011-12-30 21:40:48 v 0.3 -------------------------------------------------------------------------------- -- CommentsDelHide() -- -- Hide (default) or delete comment lines in opened AutoIt-script in SciTE -- -- Hided comments will shown again with reload file (menu file) or change to another tab and back -- -- PARAMAETER..[optional]..: _fDelete - false=HIDE COMMENT-LINES (default) / true=DELETE COMMENT-LINES -------------------------------------------------------------------------------- function CommentsDelHide(_fDelete) if _fDelete == nil then _fDelete = false end local function IsComment(pos) local tComment = {1,2} if tComment[editor.StyleAt[pos]] == nil then return false else return true end end local function IsWS(pos) if editor.StyleAt[pos] == 0 then return true else return false end end local function GetRange(tTable) local tRange = {} iStart = '' if table.getn(tTable) == 0 then return nil end for i = 1, table.getn(tTable) do if iStart == '' then iStart = tTable[i] end if i < table.getn(tTable) then if tTable[i+1] ~= tTable[i] +1 then table.insert(tRange, {iStart, tTable[i]}) iStart = '' else if i+1 == table.getn(tTable) then table.insert(tRange, {iStart, tTable[i+1]}) break end end else table.insert(tRange, {tTable[i], tTable[i]}) end end return tRange end local function PreZero(sText, iMax) return string.rep('0', iMax - string.len(sText))..sText end editor:GotoLine(0) local n = 0 local tCommLines = {} while editor.LineCount > n do editor:GotoLine(n) if IsComment(editor.CurrentPos) then table.insert(tCommLines, n) elseif IsWS(editor.CurrentPos) then editor:WordRight() if IsComment(editor.CurrentPos) then n = editor:LineFromPosition(editor.CurrentPos) table.insert(tCommLines, n) end end n = n +1 end editor:BeginUndoAction() if _fDelete then if table.getn(tCommLines) > 0 then for i = table.getn(tCommLines), 1, -1 do editor:GotoLine(tCommLines[i]) editor:LineDelete() end else print('!++ NO COMMENT LINES DETECT ++') end else local tRanges = GetRange(tCommLines) if tRanges == nil then print('!++ NO COMMENT LINES DETECT ++') end local max = string.len(tRanges[table.getn(tRanges)][2]) for i = 1, table.getn(tRanges) do print('++ HIDE LINE'..'....'..PreZero(tostring(tRanges[i][1] +1), max)..' TO '..PreZero(tostring(tRanges[i][2] +1), max)..' ++') editor:HideLines(tRanges[i][1],tRanges[i][2]) end end editor:EndUndoAction() end -- CommentsDelHide() function CommentsHide() CommentsDelHide() end function CommentsDelete() CommentsDelHide(true) endEdit: Shortcut Strg+Shift+L is a bad idea... - its used to delete lines. Change that to another one.CommentsDelHide.txt Edited December 31, 2011 by BugFix Best Regards BugFix Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now