Mat Posted June 12, 2011 Posted June 12, 2011 (edited) @Mat I also think you should try to include any optional parameter values in the header creation. It doesn't do that currently. You mean the 'Default is ****' bit? $iParam - [Optional] An integer value. Default is 42. I was thinking that as well. I am in the process of writing the structure header creator as well Edit: Const isn't working either. Edit2: and the regex needs to be changed to do optional values. Edited June 12, 2011 by Mat AutoIt Project Listing
Developers Jos Posted June 12, 2011 Author Developers Posted June 12, 2011 (edited) Here's my go at it... turned out to be a bit more complex since I had to figure out how to get the new line position... one line, but a lot of Googling!Merged this into the Beta version of AutoItTools.lua .Slowly getting closer to make it "fools proof" Edited June 12, 2011 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.
wraithdu Posted June 12, 2011 Posted June 12, 2011 You mean the 'Default is ****' bit? Actually, I meant in the function syntax line, like _func ( [$var = "default"] )
Mat Posted June 12, 2011 Posted June 12, 2011 Ok. It works. No doubt you guys will find exceptions where this is broken (it's not pretty to say the least):expandcollapse popup-------------------------------------------------------------------------------- -- CreateFunctionHeader(s, p) -- -- Creates a function header for an AutoIt 3 function. -- -- Parameters: -- s - The name of a function. -- p - The parameters to the function. -- -- Returns: -- A string containing the function header. -------------------------------------------------------------------------------- function AutoItTools:CreateFunctionHeader(s, p) -- Change these <img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/smile.png' class='bbc_emoticon' alt=':)' /> local defAuthor = props['UDFCreator'] -- Initial Author value local defLineMax = 129 -- Max length of line. AutoIt standard is 129. local defSplit = 21 -- Default index for '-' after param. local nl = self:NewLineInUse() local outStart = "FUNCTION" local outName = "" local outDesc = "" local outSyntax = "" local outParams = "" local outReturn = "None" local outAuthor = defAuthor local outModify = "" local outRemarks = "" local outRelated = "" local outLink = "" local outExample = "No" local name = s local params = p outName = name if name:sub(0, 2) == "__" then outStart = "INTERNAL_USE_ONLY" end outSyntax = name .. "(" local paramSynt = "" local iOptionals = 0 local fBroken = false local sModifiers = "" if params ~= "" and params ~= nil then for byref, parameter, optional in string.gfind(params, "(%w-%s*%w*)%s*($[%w_]+)%s*[=]?%s*(.-)[,%)]") do if parameter ~= "" and parameter ~= nil then if outParams ~= "" then outParams = outParams .. nl .. ";" .. string.rep(" ", 18) end outParams = outParams .. parameter .. string.rep(" ", defSplit - string.len(parameter)) .. "- " sModifiers = "" if optional ~= "" and optional ~= nil then outParams = outParams .. "[optional] " if paramSynt ~= "" then paramSynt = paramSynt .. "[, " else paramSynt = paramSynt .. "[" end iOptionals = iOptionals + 1 else byref = string.gsub(byref:lower(), "%s", "") if byref ~= "" then if byref == "byref" then outParams = outParams .. "[in/out] " sModifiers = "Byref " else if byref == "const" then outParams = outParams .. "[const] " sModifiers = "Const " else if byref == "byrefconst" or byref == "constbyref" then outParams = outParams .. "[in/out and const] " sModifiers = "Const Byref " else print("Unrecognised parameter modifiers: '" .. byref .. "'") end end end end if paramSynt ~= "" then paramSynt = paramSynt .. ", " end end if fBroken then if string.len(paramSynt) + string.len(parameter) + iOptionals + 2 + 19 > defLineMax then outSyntax = outSyntax .. paramSynt .. nl .. ";" .. string.rep(" ", 18) paramSynt = "" fBroken = true end else if string.len(outSyntax) + string.len(paramSynt) + string.len(parameter) + iOptionals + 2 + 19 > defLineMax then outSyntax = outSyntax .. paramSynt .. nl .. ";" .. string.rep(" ", 18) paramSynt = "" fBroken = true end end paramSynt = paramSynt .. sModifiers .. parameter if optional ~= "" and optional ~= nil then paramSynt = paramSynt .. " = " .. optional end local paramtype = parameter:sub(2, 2) local isarray = false if paramtype == "a" then paramtype = parameter:sub(3, 3) isarray = true end local sAdd if paramtype == "i" then sAdd = "n integer" elseif paramtype == "f" then sAdd = " boolean" elseif paramtype == "b" then sAdd = " binary" elseif paramtype == "n" then sAdd = " floating point number" elseif paramtype == "s" then sAdd = " string" elseif paramtype == "h" then sAdd = " handle" elseif paramtype == "v" then sAdd = " variant" elseif paramtype == "p" then sAdd = " pointer" elseif paramtype == "t" then sAdd = " dll struct" else sAdd = "n unknown" end if isarray then outParams = outParams .. "An array of " .. sAdd .. "s." else outParams = outParams .. "A" .. sAdd .. " value." end if optional ~= "" and optional ~= nil then outParams = outParams .. " Default is " .. optional .. "." end end end else outParams = "None" end outSyntax = outSyntax .. paramSynt .. string.rep("]", iOptionals) .. ")" local res = "; #" .. outStart .. "# " .. string.rep("=", defLineMax - 5 - outStart:len()) .. nl res = res .. "; Name ..........: " .. outName .. nl res = res .. "; Description ...: " .. outDesc .. nl res = res .. "; Syntax ........: " .. outSyntax .. nl res = res .. "; Parameters ....: " .. outParams .. nl res = res .. "; Return values .: " .. outReturn .. nl res = res .. "; Author ........: " .. outAuthor .. nl res = res .. "; Modified ......: " .. outModify .. nl res = res .. "; Remarks .......: " .. outRemarks .. nl res = res .. "; Related .......: " .. outRelated .. nl res = res .. "; Link ..........: " .. outLink .. nl res = res .. "; Example .......: " .. outExample .. nl res = res .. "; " .. string.rep("=", defLineMax - 2) .. nl return res end -- CreateFunctionHeader() -------------------------------------------------------------------------------- -- InsertFunctionHeader() -- -- Generates a function header and inserts it into the document. -- -- Tool: AutoItTools.InsertFunctionHeader $(au3) savebefore:no,groupundo:yes Ctrl+Alt+H Insert Function Header -------------------------------------------------------------------------------- function AutoItTools:InsertUDFHeader() local line, pos = editor:GetCurLine() local pos = editor.CurrentPos - pos local lineNum = editor:LineFromPosition(pos) local from, to, name = line:find("[Ff][Uu][Nn][Cc][%s]*([%w%s_]*)") if to ~= nil then -- remove comments from the line from, to = line:find(";") while from ~= nil do -- print(pos+from .. " type:" .. editor.StyleAt[pos+from]) if editor.StyleAt[pos+from] == SCE_AU3_COMMENT then line = string.sub (line, 1 , from-1) -- remove comment from = nil -- exit loop else from, to = line:find(";",from+1) -- find next ; as this one is not a comment end end -- print(" line:" .. line) local pfrom, pto = line:find("%(") -- check for opening parenthesis if pto ~= nil then local i = 0 local tmp while line:find("%s+_%s*$") do -- found a line continuation line = line:gsub("%s+_%s*$", "") -- remove it i = i + 1 pos = editor:PositionFromLine(lineNum+i) -- set new position tmp = editor:GetLine(lineNum+i) -- remove comments from the line from, to = tmp:find(";") while from ~= nil do -- print(pos+from .. " type:" .. editor.StyleAt[pos+from]) if editor.StyleAt[pos+from] == SCE_AU3_COMMENT then tmp = string.sub (tmp, 1 , from-1) -- remove comment from = nil -- exit loop else from, to = tmp:find(";",from+1) -- find next ; as this one is not a comment end end tmp = tmp:gsub("^%s*", "") -- remove leading white space line = line .. tmp end editor:Home() line = line:gsub("[\r\n]", "") -- remove line breaks editor:AddText(self:CreateFunctionHeader(name, line)) else print("Argument list not found, unable to insert header.") end else from, to = line:find("[Gg][Ll][Oo][Bb][Aa][Ll]%s+[Cc][Oo][Nn][Ss][Tt]%s+$[Tt][Aa][Gg](%w+)%s*=%s*\"(.+)\"") if to ~= nil then -- It's a structure print("Not implemented: Structures") else print("Function or struct definition not found, unable to insert header.") end end end -- InsertUDFHeader()Changes: * Now recognises Const keyword * Now adds const + byref to the syntax line. * Now adds default values to syntax line. * Also adds default values to parameter listing as 'Default is ###.' * Now decides whether to use 'A' or 'An'. Pointless but ah well. AutoIt Project Listing
Developers Jos Posted June 12, 2011 Author Developers Posted June 12, 2011 (edited) Mat, are you still using your own version in a separate lua file because you are still using AutoItTools:InsertUDFHeader in stead of AutoItTools:CreateFunctionHeader(s, p) which was already stored in previous version? -- Tool: AutoItTools.InsertFunctionHeader $(au3) savebefore:no,groupundo:yes Ctrl+Alt+H Insert Function Header -------------------------------------------------------------------------------- function AutoItTools:InsertUDFHeader() It just makes it much harder to WinMerge. Thanks, Beta version updated. Jos Edited June 12, 2011 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.
Mat Posted June 12, 2011 Posted June 12, 2011 Ah yes, I forgot about that... My naming makes more sense to me because I am working on the structure version, so insert function header sounds slightly wrong. I've amended my version now. AutoIt Project Listing
Mat Posted June 12, 2011 Posted June 12, 2011 Me again Version with support for structs: expandcollapse popup-------------------------------------------------------------------------------- -- CreateFunctionHeader(s, p) -- -- Creates a function header for an AutoIt 3 function. -- -- Parameters: -- s - The name of a function. -- p - The parameters to the function. -- -- Returns: -- A string containing the function header. -------------------------------------------------------------------------------- function AutoItTools:CreateFunctionHeader(s, p) -- Change these :) local defAuthor = props['UDFCreator'] -- Initial Author value local defLineMax = 129 -- Max length of line. AutoIt standard is 129. local defSplit = 21 -- Default index for '-' after param. local nl = self:NewLineInUse() local outStart = "FUNCTION" local outName = s local outDesc = "" local outSyntax = "" local outParams = "" local outReturn = "None" local outAuthor = defAuthor local outModify = "" local outRemarks = "" local outRelated = "" local outLink = "" local outExample = "No" local name = s local params = p if name:sub(0, 2) == "__" then outStart = "INTERNAL_USE_ONLY" end outSyntax = name .. "(" local paramSynt = "" local iOptionals = 0 local fBroken = false local sModifiers = "" if params ~= "" and params ~= nil then for byref, parameter, optional in string.gfind(params, "(%w-%s*%w*)%s*($[%w_]+)%s*[=]?%s*(.-)[,%)]") do if parameter ~= "" and parameter ~= nil then if outParams ~= "" then outParams = outParams .. nl .. ";" .. string.rep(" ", 18) end outParams = outParams .. parameter .. string.rep(" ", defSplit - string.len(parameter)) .. "- " sModifiers = "" if optional ~= "" and optional ~= nil then outParams = outParams .. "[optional] " if paramSynt ~= "" then paramSynt = paramSynt .. "[, " else paramSynt = paramSynt .. "[" end iOptionals = iOptionals + 1 else byref = string.gsub(byref:lower(), "%s", "") if byref ~= "" then if byref == "byref" then outParams = outParams .. "[in/out] " sModifiers = "Byref " else if byref == "const" then outParams = outParams .. "[const] " sModifiers = "Const " else if byref == "byrefconst" or byref == "constbyref" then outParams = outParams .. "[in/out and const] " sModifiers = "Const Byref " else print("Unrecognised parameter modifiers: '" .. byref .. "'") end end end end if paramSynt ~= "" then paramSynt = paramSynt .. ", " end end if fBroken then if string.len(paramSynt) + string.len(parameter) + iOptionals + 2 + 19 > defLineMax then outSyntax = outSyntax .. paramSynt .. nl .. ";" .. string.rep(" ", 18) paramSynt = "" fBroken = true end else if string.len(outSyntax) + string.len(paramSynt) + string.len(parameter) + iOptionals + 2 + 19 > defLineMax then outSyntax = outSyntax .. paramSynt .. nl .. ";" .. string.rep(" ", 18) paramSynt = "" fBroken = true end end paramSynt = paramSynt .. sModifiers .. parameter if optional ~= "" and optional ~= nil then paramSynt = paramSynt .. " = " .. optional end local paramtype = parameter:sub(2, 2) local isarray = false if paramtype == "a" then paramtype = parameter:sub(3, 3) isarray = true end local sAdd if paramtype == "i" then sAdd = "n integer" elseif paramtype == "f" then sAdd = " boolean" elseif paramtype == "b" then sAdd = " binary" elseif paramtype == "n" then sAdd = " floating point number" elseif paramtype == "s" then sAdd = " string" elseif paramtype == "h" then sAdd = " handle" elseif paramtype == "v" then sAdd = " variant" elseif paramtype == "p" then sAdd = " pointer" elseif paramtype == "t" then sAdd = " dll struct" else sAdd = "n unknown" end if isarray then outParams = outParams .. "An array of " .. sAdd .. "s." else outParams = outParams .. "A" .. sAdd .. " value." end if optional ~= "" and optional ~= nil then outParams = outParams .. " Default is " .. optional .. "." end end end else outParams = "None" end outSyntax = outSyntax .. paramSynt .. string.rep("]", iOptionals) .. ")" local res = "; #" .. outStart .. "# " .. string.rep("=", defLineMax - 5 - outStart:len()) .. nl res = res .. "; Name ..........: " .. outName .. nl res = res .. "; Description ...: " .. outDesc .. nl res = res .. "; Syntax ........: " .. outSyntax .. nl res = res .. "; Parameters ....: " .. outParams .. nl res = res .. "; Return values .: " .. outReturn .. nl res = res .. "; Author ........: " .. outAuthor .. nl res = res .. "; Modified ......: " .. outModify .. nl res = res .. "; Remarks .......: " .. outRemarks .. nl res = res .. "; Related .......: " .. outRelated .. nl res = res .. "; Link ..........: " .. outLink .. nl res = res .. "; Example .......: " .. outExample .. nl res = res .. "; " .. string.rep("=", defLineMax - 2) .. nl return res end -- CreateFunctionHeader() -------------------------------------------------------------------------------- -- CreateStructureHeader(s, p) -- -- Creates a structure header for an AutoIt 3 struct. -- -- Parameters: -- s - The name of a structure. -- p - The complete structure definition. -- -- Returns: -- A string containing the structure header. -------------------------------------------------------------------------------- function AutoItTools:CreateStructureHeader(s, p) local defAuthor = props['UDFCreator'] -- Initial Author value local defLineMax = 129 -- Max length of line. AutoIt standard is 129. local defSplit = 21 -- Default index for '-' after param. local nl = self:NewLineInUse() local outStart = "STRUCTURE" local outName = s local outDesc = "" local outFields = "" local outAuthor = defAuthor local outRemarks = "" local outRelated = "" local str if p ~= "" and p ~= nil then p = p:sub(p:find("[\"']"), -1) for sect in string.gfind(p, "%s*(.-)%s*[;\"']") do if sect:match("[Aa][Ll][Ii][Gg][Nn]%s+%d+") then -- Align statement: Ignore else str = sect:match("^%s*&%s*$([%w_]+)%s&%s*$") if str ~= nil then -- Substruct if outFields ~= "" then outFields = outFields .. nl .. ";" .. string.rep(" ", 18) end outFields = outFields .. str .. string.rep(" ", defSplit - string.len(str)) .. "- A $" .. str .. " structure." else if sect == nil or sect == "" or sect:upper() == "STRUCT" or sect:upper() == "ENDSTRUCT" then -- Substruct or empty: Ignore else local datatype, name = sect:match("^(.-)%s+(.-)$") if outFields ~= "" then outFields = outFields .. nl .. ";" .. string.rep(" ", 18) end outFields = outFields .. name .. string.rep(" ", defSplit - string.len(name)) .. "- " if datatype:sub(1, 1):find("[AEIOUaeiou]") ~= nil then outFields = outFields .. "An " else outFields = outFields .. "A " end outFields = outFields .. datatype .. " value." end end end end end local res = "; #" .. outStart .. "# " .. string.rep("=", defLineMax - 5 - outStart:len()) .. nl res = res .. "; Name ..........: " .. outName .. nl res = res .. "; Description ...: " .. outDesc .. nl res = res .. "; Fields ........: " .. outFields .. nl res = res .. "; Author ........: " .. outAuthor .. nl res = res .. "; Remarks .......: " .. outRemarks .. nl res = res .. "; Related .......: " .. outRelated .. nl res = res .. "; " .. string.rep("=", defLineMax - 2) .. nl return res end -- CreateStructureHeader -------------------------------------------------------------------------------- -- InsertFunctionHeader() -- -- Generates a function header and inserts it into the document. -- -- Tool: AutoItTools.InsertFunctionHeader $(au3) savebefore:no,groupundo:yes Alt+U Insert Function Header -------------------------------------------------------------------------------- function AutoItTools:InsertFunctionHeader() local line, pos = editor:GetCurLine() local pos = editor.CurrentPos - pos local lineNum = editor:LineFromPosition(pos) local from, to, name = line:find("[Ff][Uu][Nn][Cc][%s]*([%w%s_]*)") local struct = false if to == nil then from, to, name = line:find("[Gg][Ll][Oo][Bb][Aa][Ll]%s+[Cc][Oo][Nn][Ss][Tt]%s+($[%w_]+)") struct = true if to == nil then print("Function or struct definition not found, unable to insert header.") return end end -- remove comments from the line from, to = line:find(";") while from ~= nil do -- print(pos+from .. " type:" .. editor.StyleAt[pos+from]) if editor.StyleAt[pos+from] == SCE_AU3_COMMENT then line = string.sub (line, 1 , from-1) -- remove comment from = nil -- exit loop else from, to = line:find(";",from+1) -- find next ; as this one is not a comment end end -- print(" line:" .. line) local pfrom, pto = line:find("%(") -- check for opening parenthesis if struct then pfrom, pto = line:find("[\"']") end if pto ~= nil then local i = 0 local tmp while line:find("%s+_%s*$") do -- found a line continuation line = line:gsub("%s+_%s*$", "") -- remove it i = i + 1 pos = editor:PositionFromLine(lineNum+i) -- set new position tmp = editor:GetLine(lineNum+i) -- remove comments from the line from, to = tmp:find(";") while from ~= nil do -- print(pos+from .. " type:" .. editor.StyleAt[pos+from]) if editor.StyleAt[pos+from] == SCE_AU3_COMMENT then tmp = string.sub (tmp, 1 , from-1) -- remove comment from = nil -- exit loop else from, to = tmp:find(";",from+1) -- find next ; as this one is not a comment end end tmp = tmp:gsub("^%s*", "") -- remove leading white space line = line .. tmp end editor:Home() line = line:gsub("[\r\n]", "") -- remove line breaks line = line:gsub("[\"']%s*&%s*[\"']", "") -- remove string joins if name:sub(1, 1) == "$" then editor:AddText(self:CreateStructureHeader(name, line)) else editor:AddText(self:CreateFunctionHeader(name, line)) end else print("Argument list not found, unable to insert header.") end end -- InsertFunctionHeader() It should work most of the time, with stuff like sub-structs, align and STRUCT statements etc. No doubt you guys will find out that it breaks when you give it ridiculous samples. AutoIt Project Listing
Developers Jos Posted June 12, 2011 Author Developers Posted June 12, 2011 For what it's worth I've been using SciTE for the past hour to work on a script and it doesn't seem any of *my* Lua scripts are broken. I am, of course, not using SciTE4AutoIt nor the official scripts though mine are similar/identical in many cases.Playing with the "File/Save as" I think that we should use the "all.files" filter when the file already has a name with extension and only used the "save.filter" for the new files. This allows you to check if the file is already there when using another extension than ".au3" without having to change the filter.thoughts? 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.
Developers Jos Posted June 12, 2011 Author Developers Posted June 12, 2011 Me again Version with support for structs:Beta version updated: AutoItTools.lua 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.
wraithdu Posted June 12, 2011 Posted June 12, 2011 Nice job. New version works with my earlier samples. I haven't had a chance to really try to break it yet, but it looks good!
Valik Posted June 12, 2011 Posted June 12, 2011 Playing with the "File/Save as" I think that we should use the "all.files" filter when the file already has a name with extension and only used the "save.filter" for the new files. This allows you to check if the file is already there when using another extension than ".au3" without having to change the filter.thoughts?Is this a new issue or just something you've observed that has really been there all along? How do you suggest to fix this, by modifying SciTE's source to add logic to see if a buffer is untitled or not and use the appropriate filter accordingly?
wraithdu Posted June 13, 2011 Posted June 13, 2011 (edited) @MatThere's a small language problem in the CreateFunctionHeader function. Essentially there's a space out of place in the datatype declaration that leads to output like 'A n integer value' and 'A n unknown'. Just put the space in the proper place in the sAdd var, and change line 428:outParams = outParams .. "A" .. sAdd .. " value." Edited June 13, 2011 by wraithdu
Mat Posted June 13, 2011 Posted June 13, 2011 @Mat There's a small language problem in the CreateFunctionHeader function. Essentially there's a space out of place in the datatype declaration that leads to output like 'A n integer value' and 'A n unknown'. Just put the space in the proper place in the sAdd var, and change line 428: outParams = outParams .. "A" .. sAdd .. " value."That's what mine is a few posts below, perhaps it wasn't merged (some mergers ignore whitespace IIRC)... But thats not the problem I just noticed When you have arrays it's now messed up big time since I did that fix This is how I should have done it in the first place: A simple regex to check the first character (it's how I did it for structs ) expandcollapse popup-------------------------------------------------------------------------------- -- CreateFunctionHeader(s, p) -- -- Creates a function header for an AutoIt 3 function. -- -- Parameters: -- s - The name of a function. -- p - The parameters to the function. -- -- Returns: -- A string containing the function header. -------------------------------------------------------------------------------- function AutoItTools:CreateFunctionHeader(s, p) -- Change these <img src='http://www.autoitscript.com/forum/public/style_emoticons/<#EMO_DIR#>/smile.png' class='bbc_emoticon' alt=':)' /> local defAuthor = props['UDFCreator'] -- Initial Author value local defLineMax = 129 -- Max length of line. AutoIt standard is 129. local defSplit = 21 -- Default index for '-' after param. local nl = self:NewLineInUse() local outStart = "FUNCTION" local outName = s local outDesc = "" local outSyntax = "" local outParams = "" local outReturn = "None" local outAuthor = defAuthor local outModify = "" local outRemarks = "" local outRelated = "" local outLink = "" local outExample = "No" local name = s local params = p if name:sub(0, 2) == "__" then outStart = "INTERNAL_USE_ONLY" end outSyntax = name .. "(" local paramSynt = "" local iOptionals = 0 local fBroken = false local sModifiers = "" if params ~= "" and params ~= nil then for byref, parameter, optional in string.gfind(params, "(%w-%s*%w*)%s*($[%w_]+)%s*[=]?%s*(.-)[,%)]") do if parameter ~= "" and parameter ~= nil then if outParams ~= "" then outParams = outParams .. nl .. ";" .. string.rep(" ", 18) end outParams = outParams .. parameter .. string.rep(" ", defSplit - string.len(parameter)) .. "- " sModifiers = "" if optional ~= "" and optional ~= nil then outParams = outParams .. "[optional] " if paramSynt ~= "" then paramSynt = paramSynt .. "[, " else paramSynt = paramSynt .. "[" end iOptionals = iOptionals + 1 else byref = string.gsub(byref:lower(), "%s", "") if byref ~= "" then if byref == "byref" then outParams = outParams .. "[in/out] " sModifiers = "Byref " else if byref == "const" then outParams = outParams .. "[const] " sModifiers = "Const " else if byref == "byrefconst" or byref == "constbyref" then outParams = outParams .. "[in/out and const] " sModifiers = "Const Byref " else print("Unrecognised parameter modifiers: '" .. byref .. "'") end end end end if paramSynt ~= "" then paramSynt = paramSynt .. ", " end end if fBroken then if string.len(paramSynt) + string.len(parameter) + iOptionals + 2 + 19 > defLineMax then outSyntax = outSyntax .. paramSynt .. nl .. ";" .. string.rep(" ", 18) paramSynt = "" fBroken = true end else if string.len(outSyntax) + string.len(paramSynt) + string.len(parameter) + iOptionals + 2 + 19 > defLineMax then outSyntax = outSyntax .. paramSynt .. nl .. ";" .. string.rep(" ", 18) paramSynt = "" fBroken = true end end paramSynt = paramSynt .. sModifiers .. parameter if optional ~= "" and optional ~= nil then paramSynt = paramSynt .. " = " .. optional end local paramtype = parameter:sub(2, 2) local isarray = false if paramtype == "a" then paramtype = parameter:sub(3, 3) isarray = true end local sAdd if paramtype == "i" then sAdd = "integer" elseif paramtype == "f" then sAdd = "boolean" elseif paramtype == "b" then sAdd = "binary" elseif paramtype == "n" then sAdd = "floating point number" elseif paramtype == "s" then sAdd = "string" elseif paramtype == "h" then sAdd = "handle" elseif paramtype == "v" then sAdd = "variant" elseif paramtype == "p" then sAdd = "pointer" elseif paramtype == "t" then sAdd = "dll struct" else sAdd = "unknown" end if isarray then outParams = outParams .. "An array of " .. sAdd .. "s." else if sAdd:sub(1, 1):find("[AEIOUaeiou]") ~= nil then outParams = outParams .. "An " .. sAdd .. " value." else outParams = outParams .. "A " .. sAdd .. " value." end end if optional ~= "" and optional ~= nil then outParams = outParams .. " Default is " .. optional .. "." end end end else outParams = "None" end outSyntax = outSyntax .. paramSynt .. string.rep("]", iOptionals) .. ")" local res = "; #" .. outStart .. "# " .. string.rep("=", defLineMax - 5 - outStart:len()) .. nl res = res .. "; Name ..........: " .. outName .. nl res = res .. "; Description ...: " .. outDesc .. nl res = res .. "; Syntax ........: " .. outSyntax .. nl res = res .. "; Parameters ....: " .. outParams .. nl res = res .. "; Return values .: " .. outReturn .. nl res = res .. "; Author ........: " .. outAuthor .. nl res = res .. "; Modified ......: " .. outModify .. nl res = res .. "; Remarks .......: " .. outRemarks .. nl res = res .. "; Related .......: " .. outRelated .. nl res = res .. "; Link ..........: " .. outLink .. nl res = res .. "; Example .......: " .. outExample .. nl res = res .. "; " .. string.rep("=", defLineMax - 2) .. nl return res end -- CreateFunctionHeader() -------------------------------------------------------------------------------- -- CreateStructureHeader(s, p) -- -- Creates a structure header for an AutoIt 3 struct. -- -- Parameters: -- s - The name of a structure. -- p - The complete structure definition. -- -- Returns: -- A string containing the structure header. -------------------------------------------------------------------------------- function AutoItTools:CreateStructureHeader(s, p) local defAuthor = props['UDFCreator'] -- Initial Author value local defLineMax = 129 -- Max length of line. AutoIt standard is 129. local defSplit = 21 -- Default index for '-' after param. local nl = self:NewLineInUse() local outStart = "STRUCTURE" local outName = s local outDesc = "" local outFields = "" local outAuthor = defAuthor local outRemarks = "" local outRelated = "" local str if p ~= "" and p ~= nil then p = p:sub(p:find("[\"']"), -1) for sect in string.gfind(p, "%s*(.-)%s*[;\"']") do if sect:match("[Aa][Ll][Ii][Gg][Nn]%s+%d+") then -- Align statement: Ignore else str = sect:match("^%s*&%s*$([%w_]+)%s&%s*$") if str ~= nil then -- Substruct if outFields ~= "" then outFields = outFields .. nl .. ";" .. string.rep(" ", 18) end outFields = outFields .. str .. string.rep(" ", defSplit - string.len(str)) .. "- A $" .. str .. " structure." else if sect == nil or sect == "" or sect:upper() == "STRUCT" or sect:upper() == "ENDSTRUCT" then -- Substruct or empty: Ignore else local datatype, name = sect:match("^(.-)%s+(.-)$") if outFields ~= "" then outFields = outFields .. nl .. ";" .. string.rep(" ", 18) end outFields = outFields .. name .. string.rep(" ", defSplit - string.len(name)) .. "- " if datatype:sub(1, 1):find("[AEIOUaeiou]") ~= nil then outFields = outFields .. "An " else outFields = outFields .. "A " end outFields = outFields .. datatype .. " value." end end end end end local res = "; #" .. outStart .. "# " .. string.rep("=", defLineMax - 5 - outStart:len()) .. nl res = res .. "; Name ..........: " .. outName .. nl res = res .. "; Description ...: " .. outDesc .. nl res = res .. "; Fields ........: " .. outFields .. nl res = res .. "; Author ........: " .. outAuthor .. nl res = res .. "; Remarks .......: " .. outRemarks .. nl res = res .. "; Related .......: " .. outRelated .. nl res = res .. "; " .. string.rep("=", defLineMax - 2) .. nl return res end -- CreateStructureHeader -------------------------------------------------------------------------------- -- InsertFunctionHeader() -- -- Generates a function header and inserts it into the document. -- -- Tool: AutoItTools.InsertFunctionHeader $(au3) savebefore:no,groupundo:yes Alt+U Insert Function Header -------------------------------------------------------------------------------- function AutoItTools:InsertFunctionHeader() local line, pos = editor:GetCurLine() local pos = editor.CurrentPos - pos local lineNum = editor:LineFromPosition(pos) local from, to, name = line:find("[Ff][Uu][Nn][Cc][%s]*([%w%s_]*)") local struct = false if to == nil then from, to, name = line:find("[Gg][Ll][Oo][Bb][Aa][Ll]%s+[Cc][Oo][Nn][Ss][Tt]%s+($[%w_]+)") struct = true if to == nil then print("Function or struct definition not found, unable to insert header.") return end end -- remove comments from the line from, to = line:find(";") while from ~= nil do -- print(pos+from .. " type:" .. editor.StyleAt[pos+from]) if editor.StyleAt[pos+from] == SCE_AU3_COMMENT then line = string.sub (line, 1 , from-1) -- remove comment from = nil -- exit loop else from, to = line:find(";",from+1) -- find next ; as this one is not a comment end end -- print(" line:" .. line) local pfrom, pto = line:find("%(") -- check for opening parenthesis if struct then pfrom, pto = line:find("[\"']") end if pto ~= nil then local i = 0 local tmp while line:find("%s+_%s*$") do -- found a line continuation line = line:gsub("%s+_%s*$", "") -- remove it i = i + 1 pos = editor:PositionFromLine(lineNum+i) -- set new position tmp = editor:GetLine(lineNum+i) -- remove comments from the line from, to = tmp:find(";") while from ~= nil do -- print(pos+from .. " type:" .. editor.StyleAt[pos+from]) if editor.StyleAt[pos+from] == SCE_AU3_COMMENT then tmp = string.sub (tmp, 1 , from-1) -- remove comment from = nil -- exit loop else from, to = tmp:find(";",from+1) -- find next ; as this one is not a comment end end tmp = tmp:gsub("^%s*", "") -- remove leading white space line = line .. tmp end editor:Home() line = line:gsub("[\r\n]", "") -- remove line breaks line = line:gsub("[\"']%s*&%s*[\"']", "") -- remove string joins if name:sub(1, 1) == "$" then editor:AddText(self:CreateStructureHeader(name, line)) else editor:AddText(self:CreateFunctionHeader(name, line)) end else print("Argument list not found, unable to insert header.") end end -- InsertFunctionHeader() AutoIt Project Listing
Developers Jos Posted June 13, 2011 Author Developers Posted June 13, 2011 That's what mine is a few posts below, perhaps it wasn't merged (some mergers ignore whitespace IIRC)... But thats not the problem I just noticed When you have arrays it's now messed up big time since I did that fix This is how I should have done it in the first place: A simple regex to check the first character (it's how I did it for structs )Made sure this time to have the proper setting in WinMerge and merged it into the current Beta available.I am sure you will check if done correctly. 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.
Developers Jos Posted June 14, 2011 Author Developers Posted June 14, 2011 Uploaded a Beta version of SciTE v 2.26 with our modification is it here for those who would like to give that a try.Just copy the 3 files to your SciTE directory. The 2 HTML files contain the updated Docs and History so you can see the changes made to SciTE since the latest v1.79 we currently use.So everybody is still happy with this new version of SciTE?Does it give any new goodies that are useful mentioning or need tweaking?I am planning to build and release an new SciTE4AutoIt3 installer toward the end of this month assuming everything is stable, so would like to know when anything needs to be changed before releasing it.Thanks,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.
guinness Posted June 14, 2011 Posted June 14, 2011 I'm loving the new SciTE, but haven't seen any new features just old bugs being fixed which I thought were features Though for the first time ever the SciTE screen went crazy when I was scrolling though KaFu's ICU Source Code towards the end, but I think this was a one off and perhaps SciTE Hopper (can be found in Examples) conflicting with one another as I haven't experienced this since. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Developers Jos Posted June 14, 2011 Author Developers Posted June 14, 2011 I'm loving the new SciTE, but haven't seen any new features just old bugs being fixed which I thought were features What BUG was bugging you before that is resolved now? I wasn't aware anything substantial was fixed. Though for the first time ever the SciTE screen went crazy when I was scrolling though KaFu's ICU Source Code towards the end, but I think this was a one off and perhaps SciTE Hopper (can be found in Examples) conflicting with one another as I haven't experienced this since.I have seen SciTEHopper being posted but haven't followed the developments and am not sure how dynamically it interacts with SciTE.It it really solving a need for you? 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.
guinness Posted June 14, 2011 Posted June 14, 2011 (edited) What BUG was bugging you before that is resolved now? I wasn't aware anything substantial was fixed.DoubleClicking on a Tab would close the file >> Now I just use the shortcut Ctrl+W.I have seen SciTEHopper being posted but haven't followed the developments and am not sure how dynamically it interacts with SciTE. It it really solving a need for you?Most definitely, I use it everyday as I can quickly select a Function without having to scroll through the entire Script manually. It interacts very well with SciTE, it can jump between regions too. I've even added to SciTEUser.properties with Ctrl+Alt+H as the HotKey because it one of those applications which makes SciTE4AutoIt3 that little be greater!!I have found one problem and thats with certain Filenames (before I rename them) it will fail but these are far and few between, plus the source code is still in its infancy. Edited June 14, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Developers Jos Posted June 14, 2011 Author Developers Posted June 14, 2011 Most definitely, I use it everyday as I can quickly select a Function without having to scroll through the entire Script manually.What do you mean exactly with Select? Isn't that already provided by the Autocomplete?(just curious here )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.
guinness Posted June 14, 2011 Posted June 14, 2011 hat do you mean exactly with Select?As in navigate to that desired Function in your Script, sorry bad choice of words there. It makes large Scripts with many Functions that little bit easier to navigate through. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Recommended Posts