mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-21 22:04:56 -06:00
Developing T++ annotations
git-svn-id: svn://ultimatepp.org/upp/trunk@559 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6532cf1694
commit
e1f7351e1f
10 changed files with 77 additions and 19 deletions
|
|
@ -1011,6 +1011,7 @@ CodeEditor::CodeEditor() {
|
|||
found = notfoundfw = notfoundbk = foundsel = false;
|
||||
bar.WhenBreakpoint = THISBACK(ForwardWhenBreakpoint);
|
||||
bar.WhenAnnotationMove = Proxy(WhenAnnotationMove);
|
||||
bar.WhenAnnotationClick = Proxy(WhenAnnotationClick);
|
||||
highlight = HIGHLIGHT_NONE;
|
||||
hilite_scope = 0;
|
||||
hilite_bracket = 2;
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ private:
|
|||
public:
|
||||
Callback1<int> WhenBreakpoint;
|
||||
Callback WhenAnnotationMove;
|
||||
Callback WhenAnnotationClick;
|
||||
|
||||
void InsertLines(int i, int count);
|
||||
void RemoveLines(int i, int count);
|
||||
|
|
@ -371,6 +372,7 @@ public:
|
|||
Callback1<const String&> WhenDbgView;
|
||||
Callback WhenLeftDown;
|
||||
Callback WhenAnnotationMove;
|
||||
Callback WhenAnnotationClick;
|
||||
|
||||
FrameTop<Button> topsbbutton;
|
||||
FrameTop<Button> topsbbutton1;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ uses
|
|||
file
|
||||
CodeEditor.h,
|
||||
hl_color.i,
|
||||
EditorBar.cpp,
|
||||
Syntax.cpp,
|
||||
EditorBar.cpp,
|
||||
Highlight.cpp,
|
||||
FindReplace.cpp,
|
||||
Lang.cpp,
|
||||
|
|
|
|||
|
|
@ -161,8 +161,10 @@ void EditorBar::MouseMove(Point p, dword flags)
|
|||
int pa = active_annotation;
|
||||
if(p.x > GetSize().cx - annotations)
|
||||
active_annotation = p.y / editor->GetFont().Info().GetHeight() + editor->GetScrollPos().y;
|
||||
if(active_annotation >= editor->GetLineCount())
|
||||
active_annotation = -1;
|
||||
else
|
||||
active_annotation = -1;
|
||||
if(active_annotation >= editor->GetLineCount())
|
||||
active_annotation = -1;
|
||||
if(pa != active_annotation)
|
||||
WhenAnnotationMove();
|
||||
if(editor)
|
||||
|
|
@ -179,6 +181,9 @@ void EditorBar::MouseLeave()
|
|||
|
||||
void EditorBar::LeftDown(Point p, dword flags)
|
||||
{
|
||||
if(p.x > GetSize().cx - annotations)
|
||||
WhenAnnotationClick();
|
||||
else
|
||||
if(editor)
|
||||
editor->LeftDown(Point(0, p.y), flags);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,8 @@ topic "Point";
|
|||
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
|
||||
[b42;2 $$9,9#13035079074754324216151401829390:normal]
|
||||
[{_}
|
||||
[s0; [*_@3 ERROR: Expected number: `@3;2 `$`$6,6#622449434]]
|
||||
[s0;*_@3 &]
|
||||
[s5;:Any`:`:Any`(pick`_ Any`&`): [* Any]([@(0.128.128) pick`_]_[* Any][@(0.0.255) `&]_[*@3 s])&]
|
||||
[s2;%% Pick constructor. Transfers content of source Any while destroying
|
||||
its content by picking.&]
|
||||
[s7; [*C@3 s][%% -|Source Any.][*_@3 ERROR: Expected number: `@3;2 `$`$6,6#622449434]]
|
||||
|
|
@ -41,21 +41,30 @@ bool IsBeginEnd(RichText& txt, int i)
|
|||
return false;
|
||||
}
|
||||
|
||||
void AssistEditor::SyncAnnotationPopup()
|
||||
bool AssistEditor::GetAnnotationRefs(Vector<String>& tl, String& coderef)
|
||||
{
|
||||
if(annotation_popup.IsOpen())
|
||||
annotation_popup.Close();
|
||||
int q = GetActiveAnnotationLine();
|
||||
if(q < 0)
|
||||
return;
|
||||
String coderef = GetAnnotation(q);
|
||||
return false;
|
||||
coderef = GetAnnotation(q);
|
||||
if(IsNull(coderef))
|
||||
return false;
|
||||
tl = GetRefLinks(coderef);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AssistEditor::SyncAnnotationPopup()
|
||||
{
|
||||
String coderef;
|
||||
Vector<String> tl;
|
||||
if(!GetAnnotationRefs(tl, coderef))
|
||||
return;
|
||||
Vector<String> l = GetRefLinks(coderef);
|
||||
if(l.GetCount()) {
|
||||
if(tl.GetCount()) {
|
||||
static String last_path;
|
||||
static RichText topic_text;
|
||||
String path = GetTopicPath(l[0]);
|
||||
String path = GetTopicPath(tl[0]);
|
||||
if(path != last_path)
|
||||
topic_text = ParseQTF(ReadTopic(LoadFile(path)).text);
|
||||
|
||||
|
|
@ -75,7 +84,7 @@ void AssistEditor::SyncAnnotationPopup()
|
|||
}
|
||||
else
|
||||
annotation_popup.SetQTF("[A1 [@b* " + DeQtf(coderef) + "]&Not documented yet - click to document");
|
||||
Rect r = GetLineScreenRect(q);
|
||||
Rect r = GetLineScreenRect(GetActiveAnnotationLine());
|
||||
int h = annotation_popup.GetHeight(580);
|
||||
h = min(h, 550);
|
||||
int y = r.top - h - 16;
|
||||
|
|
@ -84,3 +93,29 @@ void AssistEditor::SyncAnnotationPopup()
|
|||
annotation_popup.SetRect(r.left, y, 600, h + 16);
|
||||
annotation_popup.Ctrl::PopUp(this, false, false, true);
|
||||
}
|
||||
|
||||
void AssistEditor::OpenTopic(String topic)
|
||||
{
|
||||
if(theide)
|
||||
theide->OpenTopic(topic);
|
||||
}
|
||||
|
||||
void AssistEditor::EditAnnotation()
|
||||
{
|
||||
String coderef;
|
||||
Vector<String> tl;
|
||||
if(!GetAnnotationRefs(tl, coderef))
|
||||
return;
|
||||
SetCursor(GetPos(GetActiveAnnotationLine()));
|
||||
if(tl.GetCount() > 1) {
|
||||
MenuBar bar;
|
||||
for(int i = 0; i < tl.GetCount(); i++)
|
||||
bar.Add(tl[i], THISBACK1(OpenTopic, tl[i] + '#' + coderef));
|
||||
bar.Execute();
|
||||
return;
|
||||
}
|
||||
if(tl.GetCount()) {
|
||||
OpenTopic(tl[0] + '#' + coderef);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ AssistEditor::AssistEditor()
|
|||
navigator = NAV_BROWSER;
|
||||
|
||||
WhenAnnotationMove = THISBACK(SyncAnnotationPopup);
|
||||
WhenAnnotationClick = THISBACK(EditAnnotation);
|
||||
Annotations(12);
|
||||
annotation_popup.Background(White);
|
||||
annotation_popup.SetFrame(BlackFrame());
|
||||
|
|
|
|||
|
|
@ -62,14 +62,19 @@ void CodeBrowser::Load()
|
|||
}
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < fi.GetCount(); i++) {
|
||||
String s = GetCppFile(fi[i]);
|
||||
s = '<' + GetFileName(GetFileFolder(s)) + '/' + GetFileName(s) + '>';
|
||||
if(MatchCib(s, match) && HasItem(fi[i], find)) {
|
||||
txt.Add(s);
|
||||
ndx.Add(fi[i]);
|
||||
}
|
||||
if(find.GetCount()) {
|
||||
txt.Add("<globals>");
|
||||
ndx.Add(Null);
|
||||
}
|
||||
else
|
||||
for(int i = 0; i < fi.GetCount(); i++) {
|
||||
String s = GetCppFile(fi[i]);
|
||||
s = '<' + GetFileName(GetFileFolder(s)) + '/' + GetFileName(s) + '>';
|
||||
if(MatchCib(s, match)) {
|
||||
txt.Add(s);
|
||||
ndx.Add(fi[i]);
|
||||
}
|
||||
}
|
||||
IndexSort(txt, ndx, ScopeLess());
|
||||
Value key = scope.GetKey();
|
||||
int sc = scope.GetCursorSc();
|
||||
|
|
|
|||
|
|
@ -43,8 +43,10 @@ void TopicEditor::Open(const String& _grouppath)
|
|||
|
||||
void TopicEditor::GoTo(const String& _topic, const String& link)
|
||||
{
|
||||
if(topic.FindSetCursor(_topic) && !IsNull(link))
|
||||
if(topic.FindSetCursor(_topic) && !IsNull(link)) {
|
||||
editor.Select(editor.GetLength(), 0);
|
||||
editor.GotoLabel(link);
|
||||
}
|
||||
}
|
||||
|
||||
String TopicEditor::GetCurrentTopicPath()
|
||||
|
|
|
|||
|
|
@ -459,8 +459,11 @@ struct AssistEditor : CodeEditor {
|
|||
bool IsBrowser() const { return navigator == NAV_BROWSER; }
|
||||
void Navigator(int navigator);
|
||||
|
||||
bool GetAnnotationRefs(Vector<String>& tl, String& coderef);
|
||||
void SyncAnnotationPopup();
|
||||
void EditAnnotation();
|
||||
void Annotate(const String& filename);
|
||||
void OpenTopic(String topic);
|
||||
|
||||
void SerializeNavigator(Stream& s);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue