dcop Posted October 19, 2008 Share Posted October 19, 2008 This feature is missing now in tools and I'm almost sure I had it recently and didnt upgrade. I'm using SciTE Version 1.76 Mar 30 2008 21:05:14 TIA, Dennis Link to comment Share on other sites More sharing options...
Developers Jos Posted October 19, 2008 Developers Share Posted October 19, 2008 (edited) We left it out after the total rewrite of the LUA functions, but I never use it anyways because Tidy does that for you as well. Here is the old info when you want to use it for yourself: Additional Tools option you could add to SciteUSer.properties: # 39 Clean up script by resetting indents and removing trailing spaces command.name.39.$(au3)=Cleanup Script WhiteSpace command.subsystem.39.$(au3)=3 command.39.$(au3)=InvokeTool AutoItTools.cleanDocWhitespace command.shortcut.39.$(au3)= command.save.before.39.$(au3)=2 Lua Functions (add at the bottom of file AutoItTools.LUA: expandcollapse popup--++++++++++++++++++++++++++++++++++++++++++++++++++ -- Clean up document option by Bruce Dodson -- function AutoItTools:cleanDocWhitespace() local trailingSpacesCount = self:stripTrailingSpaces(false) local fixedIndentationCount = self:fixIndentation(false) if (fixedIndentationCount == 0) and (trailingSpacesCount == 0) then print("Document was clean already; nothing to do.") end end -- function AutoItTools:stripTrailingSpaces(reportNoMatch) local count = 0 local fs,fe = editor:findtext("[ \\t]+$", SCFIND_REGEXP) if fe then repeat count = count + 1 editor:remove(fs,fe) fs,fe = editor:findtext("[ \\t]+$", SCFIND_REGEXP, fs) until not fe print("Removed trailing spaces from " .. count .. " line(s).") elseif reportNoMatch then print("Document was clean already; nothing to do.") end return count end -- function AutoItTools:fixIndentation(reportNoMatch) local tabWidth = editor.TabWidth print("Tabsize:" .. tabWidth) local count = 0 if editor.UseTabs then -- for each piece of indentation that includes at least one space for m in editor:match("^[\\t ]* [\\t ]*", SCFIND_REGEXP) do -- figure out the indentation size local indentSize = editor.LineIndentation[editor:LineFromPosition(m.pos)] local spaceCount = math.mod(indentSize, tabWidth) local tabCount = (indentSize - spaceCount) / tabWidth local fixedIndentation = string.rep('\t', tabCount) .. string.rep(' ', spaceCount) if fixedIndentation ~= m.text then m:replace(fixedIndentation) count = count + 1 end end else -- for each piece of indentation that includes at least one tab for m in editor:match("^[\\t ]*\t[\\t ]*", SCFIND_REGEXP) do -- just change all of the indentation to spaces m:replace(string.rep(' ', editor.LineIndentation[editor:LineFromPosition(m.pos)])) count = count + 1 end end if count > 0 then print("Fixed indentation for " .. count .. " line(s).") elseif reportNoMatch then print("Document was clean already; nothing to do.") end return count end Jos Edited October 19, 2008 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
dcop Posted October 19, 2008 Author Share Posted October 19, 2008 Great, thanx Jos....I thought it mysteriosly walked away. I'll use Tidy. Dennis 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