ide: Assist/Annotations now updated when writing the code

git-svn-id: svn://ultimatepp.org/upp/trunk@7690 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-09-15 11:23:36 +00:00
parent 1e89c9f533
commit 4c216ffdf5
9 changed files with 39 additions and 1 deletions

View file

@ -213,7 +213,7 @@ void CSyntax::InitKeywords()
"RLOG", "RLOGF", "RDUMP", "RDUMPC", "RDUMPCC", "RDUMPCCC", "RDUMPM",
"LOGBEGIN", "LOGEND", "LOGBLOCK", "LOGHEXDUMP", "LOGSRCPOS",
"RLOGBEGIN", "RLOGEND", "RLOGBLOCK", "RLOGHEXDUMP", "RLOGSRCPOS", "RQUOTE",
"RTIMING", "TIMING", "LTIMING", "DTIMING", "RTIMESTOP", "TIMESTOP", "LTIMESTOP",
"RTIMING", "TIMING", "LTIMING", "DTIMING", "RTIMESTOP", "TIMESTOP", "LTIMESTOP", "DTIMESTOP",
"LOGHEX", "DUMPHEX", "DLOGHEX", "DDUMPHEX", "RLOGHEX", "RDUMPHEX", "LLOGHEX", "LDUMPHEX",
"DEBUGCODE",
NULL

View file

@ -91,6 +91,7 @@ void CodeEditor::PostInsert(int pos, const WString& text) {
Refresh();
else
CheckSyntaxRefresh(pos, text);
WhenUpdate();
}
void CodeEditor::PreRemove(int pos, int size) {
@ -109,6 +110,7 @@ void CodeEditor::PreRemove(int pos, int size) {
void CodeEditor::PostRemove(int pos, int size) {
if(check_edited)
bar.SetEdited(GetLine(pos));
WhenUpdate();
}
void CodeEditor::ClearLines() {

View file

@ -117,6 +117,7 @@ public:
LineInfoRem & GetLineInfoRem() { return li_removed; }
void SetLineInfoRem(LineInfoRem pick_ li) { li_removed = pick(li); }
void ClearAnnotations();
void SetAnnotation(int line, const Image& img, const String& ann);
String GetAnnotation(int line) const;
@ -340,6 +341,7 @@ public:
Callback WhenAnnotationRightClick;
Callback WhenOpenFindReplace;
Callback1<String&> WhenPaste;
Callback WhenUpdate;
FrameTop<Button> topsbbutton;
FrameTop<Button> topsbbutton1;
@ -456,6 +458,7 @@ public:
bool IsFindReplaceRestorePos() const { return do_ff_restore_pos; }
void Annotations(int width) { bar.Annotations(width); }
void ClearAnnotations() { bar.ClearAnnotations(); }
void SetAnnotation(int i, const Image& icon, const String& a) { bar.SetAnnotation(i, icon, a); }
String GetAnnotation(int i) const { return bar.GetAnnotation(i); }
int GetActiveAnnotationLine() const { return bar.GetActiveAnnotationLine(); }

View file

@ -358,12 +358,21 @@ String EditorBar::GetBreakpoint(int ln)
return ln < li.GetCount() ? li[ln].breakpoint : Null;
}
void EditorBar::ClearAnnotations()
{
for(int i = 0; i < li.GetCount(); i++) {
li[i].icon.Clear();
li[i].annotation.Clear();
}
}
void EditorBar::SetAnnotation(int line, const Image& img, const String& ann)
{
if(line >= 0 && line < li.GetCount()) {
li[line].icon = img;
li[line].annotation = ann;
}
Refresh();
}
String EditorBar::GetAnnotation(int line) const

View file

@ -81,6 +81,7 @@ void __LOGF__(const char *format, ...);
#define DTIMING(x) TIMING(x)
#define DLOGHEX(x) LOGHEX(x)
#define DDUMPHEX(x) DUMPHEX(x)
#define DTIMESTOP(x) TIMESTOP(x)
#else
@ -91,6 +92,7 @@ void __LOGF__(const char *format, ...);
#define DTIMING(x) @
#define DLOGHEX(x) @
#define DDUMPHEX(nx) @
#define DTIMESTOP(x) @
#define DEBUGCODE(x) LOG_NOP

View file

@ -4,6 +4,7 @@ void AssistEditor::Annotate(const String& filename)
{
int fi = GetCppFileIndex(filename);
CppBase& base = CodeBase();
ClearAnnotations();
for(int j = 0; j < base.GetCount(); j++) {
const Array<CppItem>& n = base[j];
for(int k = 0; k < n.GetCount(); k++) {

View file

@ -911,6 +911,10 @@ public:
bool CanToggleReadOnly();
void ToggleReadOnly();
void PosSync();
void EditFileAssistSync();
TimeCallback text_updated;
void TriggerAssistSync();
void DoEditKeys();
void AKEditor();

View file

@ -435,6 +435,8 @@ bool Ide::FileRemove()
}
void Ide::EditFile0(const String& path, byte charset, bool astext, const String& headername) {
text_updated.Kill();
AKEditor();
editor.CheckEdited(false);
editor.CloseAssist();
@ -545,6 +547,19 @@ void Ide::EditFile0(const String& path, byte charset, bool astext, const String&
editor.SyncNavigator();
}
void Ide::EditFileAssistSync()
{
ScanFile();
editor.Annotate(editfile);
editor.SyncNavigator();
}
void Ide::TriggerAssistSync()
{
if(editor.GetLength() < 500000) // Sanity
text_updated.KillSet(1000, THISBACK(EditFileAssistSync));
}
void Ide::EditAsText()
{
String path = editfile;

View file

@ -582,6 +582,8 @@ Ide::Ide()
error_count = 0;
warning_count = 0;
editor.WhenUpdate = THISBACK(TriggerAssistSync);
}
Ide::~Ide()