-- edit by kinn scite_Command { 'log selet |log_selet|Ctrl+8' } local log_path local default_path local tmpfile local tmpDir local files = {} local function get_log(fuc,f) print(f .. ':0:') scite.Open(f) editor:Colourise(0,-1) local s,e = editor:findtext(fuc,SCFIND_MATCHCASE,0) while s do local style = editor.StyleAt[e-1] if style == SCE_C_IDENTIFIER then s2,e2 = editor:findtext(';',SCFIND_MATCHCASE,e) local log_txt = editor:textrange(s,s2) print('---------------------------------------') local lineno = editor:LineFromPosition(s) lineno=lineno+1 print(lineno .. ":" .. log_txt) s,e = editor:findtext(fuc,SCFIND_MATCHCASE,e2) else s,e = editor:findtext(fuc,SCFIND_MATCHCASE,e) end end print('') print('') scite.MenuCommand(IDM_CLOSE) end --[[ defList ]]-- local function get_define(files) local findTxt = '#define' local defList={} for j,f in pairs(files) do print(f .. ':0:') scite.Open(f) editor:Colourise(0,-1) local s,e = editor:findtext(findTxt,SCFIND_MATCHCASE,0) while s do local style = editor.StyleAt[e-1] if style == SCE_C_PREPROCESSOR then -- continue \\ local ch='\\' e2=e while ch =='\\' do s2,e2 = editor:findtext("\n",SCFIND_MATCHCASE,e2) --print(s2-1) ch=char_at(s2-1) end -- delete comment style=editor.StyleAt[s2-1] while style ~=SCE_C_PREPROCESSOR do s2=s2-1 style = editor.StyleAt[s2-1] end local log_txt = editor:textrange(s,s2) -- delete \ \n " " log_txt=string.gsub(log_txt, "\\\n", "") log_txt=string.gsub(log_txt, "\"%s*\"", "") local def,exp=string.match(log_txt, "#define%s+([%w_]+)%s+(%S.*)$") if def ~= nil then exp=string.gsub(exp, "%((.*%S)%s*%)%s*$", "%1") exp=string.gsub(exp, "^%s*(%S.*)$", "%1") print('---------------------------------------') local lineno = editor:LineFromPosition(s) lineno=lineno+1 print(lineno .. ":" .. log_txt) print(lineno .. ":" .. def.."::"..exp) defList[def]={num=lineno,value=exp} end s,e = editor:findtext(findTxt,SCFIND_MATCHCASE,e2) else s,e = editor:findtext(findTxt,SCFIND_MATCHCASE,e) end end print('') scite.MenuCommand(IDM_CLOSE) end return defList end local function get_file(dir,list) --cpp --cmd = 'dir /aa /b '..dir..'*.cpp'..' > '..tmpfile local cmd = 'dir /aa /b '..dir..'*.h'..' > '..tmpfile print(cmd) os.execute(cmd) cmd = 'dir /aa /b '..dir..'*.cpp'..' >> '..tmpfile print(cmd) os.execute(cmd) f = io.open(tmpfile) if not f then return end for line in f:lines() do table.insert(list,dir..line) end f:close() end --[[ fuc(dir,list) ]]-- local function sub_dir(dir,list,fuc) tmpDir = default_path..'\\log_dir' local cmd = 'dir /ad-h /b '..dir..' > '..tmpDir print(cmd) os.execute(cmd) f = io.open(tmpDir) if not f then return end local subdirs = {} for line in f:lines() do table.insert(subdirs,dir..line..'\\') end f:close() for i,subdir in pairs(subdirs) do sub_dir(subdir,list,fuc) print(subdir..'---------------') end fuc(dir,list) end function log_selet() log_path='D:\\temp\\test\\src\\' default_path = props['SciteDefaultHome'] tmpfile = default_path..'\\log_select' local log_fuc= { "agwMngOpeSysLogError", "agwMngOpeSysLogWarn", "agwMngOpeSysLogInfo", "agwMngLogDebug", "agwMngLogInfo", "agwMngLogWarn", "agwMngLogError" } files = {} output:BeginUndoAction() sub_dir(log_path,files,get_file) local defines print('==========================') --get_log(fuc,file) defines=get_define(files) --print(file) for k,def in pairs(defines) do print(k..':'..def.num..':'..def.value) end output:EndUndoAction() --[[ for i,fuc in pairs(log_fuc) do for j,file in pairs(files) do --get_log(fuc,file) print(file) end print('************************') end --]] end -- returns the character at position p as a string function char_at(p) local asc=editor.CharAt[p] if asc >0 and asc < 128 then return string.char(asc) else return nil end end