--▽▽UTF-8▽▽ --diff.lua --[[ copyleft by jinzhongjie(xjinzhongjie@hotmail.com).any one who want change the code plese tell wirter. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. ]] --local buffers = {} local find = string.find local function adjust_Order(org_file,diff_file,dist_file) local org_file_len=0 local org_file_line={} local f = io.open(org_file) for line in f:lines() do org_file_line[org_file_len]=line org_file_len=org_file_len+1 end f:close() local dist_file_line_ind=0 local dist_file_line={} local diff_file_line_read={} scite.Open(diff_file) local pos=0 while pos < org_file_len do local parse_line=org_file_line[pos] parse_line=string.gsub(parse_line, "%[", "\\[") parse_line=string.gsub(parse_line, "%]", "\\]") parse_line=string.gsub(parse_line, "%d+/%d+/%d+ %d+:%d+:%d+ %d+.%d+.%d.%d ", "[0-9/:. ]+") parse_line=string.gsub(parse_line, " %d+: %a+ %d+ %d+:%d+:%d+.%d+ %a+: ", "[0-9: ]+\\w+[0-9/:. ]+\\w+[: ]+") parse_line=string.gsub(parse_line, "%(([^()]+)%)", "([\\w-]+)") --([0-9a-zA-Z-]+) local s,e e=0 while e do s,e = editor:findtext(parse_line,SCFIND_MATCHCASE+SCFIND_REGEXP,e) if s then local linePos= editor:LineFromPosition(s) if not diff_file_line_read[linePos] then diff_file_line_read[linePos]=true dist_file_line[pos]=linePos --editor:GetLine(linePos) --:sub(1,-2) --dist_file_line_ind=dist_file_line_ind+1 break end end end pos=pos+1 end local dist_f = io.open(dist_file, "w") if not dist_f then return false end pos=0 --editor.LineCount while pos < org_file_len do if dist_file_line[pos] then local line=editor:GetLine(dist_file_line[pos]) dist_f:write(line:sub(1,-3).."\n") --:sub(1,-2) else dist_f:write("\n") end pos=pos+1 end pos=0 while pos < editor.LineCount do if not diff_file_line_read[pos] then local line=editor:GetLine(pos) if line then dist_f:write(line:sub(1,-3).."\n") --:sub(1,-2) end end pos=pos+1 end dist_f:close() end scite_OnOutputLine (function (line) local line = strip_prompt(line) local dir=string.match(line, "^%S+%s+(%S.+)$") local _,_,val = find(line,'^%s*([^=%s]+)%s*') local sta=command_status() if sta=='dead' then if val == 'diff' then local org_file,diff_file,dist_file=string.match(dir, "^(%S+)%s+(%S+)%s+(%S+)$") adjust_Order(org_file,diff_file,dist_file) return true end else return false end return false end)