mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-05 17:44:55 -06:00
ide: .log file highlighting
git-svn-id: svn://ultimatepp.org/upp/trunk@7774 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
d6e5740da6
commit
8358cb32fa
7 changed files with 67 additions and 1 deletions
|
|
@ -23,6 +23,11 @@ void CreateDiffSyntax(One<EditorSyntax>& e)
|
|||
e.Create<DiffSyntax>();
|
||||
}
|
||||
|
||||
void CreateLogSyntax(One<EditorSyntax>& e)
|
||||
{
|
||||
e.Create<LogSyntax>();
|
||||
}
|
||||
|
||||
INITBLOCK
|
||||
{
|
||||
RegisterCSyntax("cpp", CSyntax::HIGHLIGHT_CPP,
|
||||
|
|
@ -44,6 +49,8 @@ INITBLOCK
|
|||
EditorSyntax::Register("html", callback1(CreateTagSyntax, true), "*.html *.htm", "HTML (.html)");
|
||||
|
||||
EditorSyntax::Register("diff", callback(CreateDiffSyntax), "*.diff *.patch", "Diff");
|
||||
|
||||
EditorSyntax::Register("log", callback(CreateLogSyntax), "*.log", "Log (*.log)");
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -172,6 +172,7 @@ struct FindReplaceDlg : FrameBottom< WithIDEFindReplaceLayout<TopWindow> > {
|
|||
#include "CSyntax.h"
|
||||
#include "DiffSyntax.h"
|
||||
#include "TagSyntax.h"
|
||||
#include "LogSyntax.h"
|
||||
|
||||
class CodeEditor : public LineEdit,
|
||||
public HighlightSetup //TODO:SYNTAX
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@ file
|
|||
TagSyntax readonly separator,
|
||||
TagSyntax.h,
|
||||
TagSyntax.cpp,
|
||||
LogSyntax readonly separator,
|
||||
LogSyntax.h,
|
||||
LogSyntax.cpp,
|
||||
Editor readonly separator,
|
||||
EditorBar.cpp,
|
||||
FindReplace.cpp,
|
||||
|
|
|
|||
|
|
@ -14,5 +14,4 @@ protected:
|
|||
|
||||
private:
|
||||
HighlightOutput *hout;
|
||||
|
||||
};
|
||||
|
|
|
|||
47
uppsrc/CodeEditor/LogSyntax.cpp
Normal file
47
uppsrc/CodeEditor/LogSyntax.cpp
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include "CodeEditor.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
void LogSyntax::Highlight(const wchar *s, const wchar *end, HighlightOutput& hls, CodeEditor *editor, int line, int pos)
|
||||
{
|
||||
const HlStyle& ink = hl_style[INK_NORMAL];
|
||||
const HlStyle& paper = hl_style[PAPER_NORMAL];
|
||||
HlStyle err = hl_style[INK_ERROR];
|
||||
err.bold = true;
|
||||
bool hl_line = false;
|
||||
while(s < end) {
|
||||
if(IsDigit(*s)) {
|
||||
const wchar *s0 = s;
|
||||
bool fp = false;
|
||||
while(IsDigit(*s) || *s == '.' || *s == 'e') {
|
||||
fp = fp || *s == '.' || *s == 'e';
|
||||
s++;
|
||||
}
|
||||
hls.Put(int(s - s0), hl_style[fp ? INK_CONST_FLOAT : INK_CONST_INT]);
|
||||
}
|
||||
else
|
||||
if(IsAlpha(*s)) {
|
||||
static Index<String> rws;
|
||||
ONCELOCK {
|
||||
rws << "error" << "errors" << "warning" << "warnings" << "failed" << "exit" << "fatal"
|
||||
<< "failure" << "rejected";
|
||||
}
|
||||
String w;
|
||||
while(IsAlNum(*s))
|
||||
w.Cat(ToLower(*s++));
|
||||
bool hl = rws.Find(w) >= 0;
|
||||
hls.Put(w.GetCount(), hl ? err : ink);
|
||||
hl_line = hl_line || hl;
|
||||
}
|
||||
else {
|
||||
bool hl = findarg(*s, '[', ']', '(', ')', ':', '-', '=', '{', '}', '/', '<', '>', '*', '#', '@') >= 0;
|
||||
hls.Put(1, hl ? hl_style[INK_OPERATOR] : ink);
|
||||
s++;
|
||||
}
|
||||
|
||||
}
|
||||
if(hl_line)
|
||||
hls.SetPaper(0, hls.GetCount(), hl_style[PAPER_WARNING].color);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
8
uppsrc/CodeEditor/LogSyntax.h
Normal file
8
uppsrc/CodeEditor/LogSyntax.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class LogSyntax : public EditorSyntax {
|
||||
public:
|
||||
virtual void Highlight(const wchar *s, const wchar *end, HighlightOutput& hls,
|
||||
CodeEditor *editor, int line, int pos);
|
||||
|
||||
private:
|
||||
HighlightOutput *hout;
|
||||
};
|
||||
|
|
@ -79,6 +79,7 @@ public:
|
|||
void Put(int count, const HlStyle& ink, const HlStyle& paper);
|
||||
void Put(const HlStyle& ink) { Put(1, ink); }
|
||||
void Put(const HlStyle& ink, word flags) { Put(1, ink); v[pos - 1].flags = flags; }
|
||||
int GetCount() const { return v.GetCount(); }
|
||||
|
||||
const wchar *CString(const wchar *p);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue