TheIDE: Help system now higlights search words and allows navigating them up/down

git-svn-id: svn://ultimatepp.org/upp/trunk@1916 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-01-21 21:06:12 +00:00
parent 64e426e240
commit d53a5e5e9e
8 changed files with 179 additions and 58 deletions

View file

@ -107,24 +107,24 @@ IMAGE_ID(SortUp)
IMAGE_ID(SortDown)
IMAGE_BEGIN_DATA
IMAGE_DATA(120,156,237,154,11,110,196,32,12,68,125,148,189,64,165,30,49,71,219,155,165,162,249,148,82,2,54,193,216,52,51,146)
IMAGE_DATA(165,86,221,45,111,50,94,2,100,233,69,47,138,180,146,189,172,25,86,67,134,53,169,39,50,164,227,143,102,200,141,255)
IMAGE_DATA(52,134,171,241,71,49,148,198,31,193,224,37,255,244,231,145,227,167,44,150,243,242,211,199,135,32,8,130,32,8,210,209)
IMAGE_DATA(39,125,88,35,64,16,228,88,203,66,235,81,214,44,82,5,230,117,221,234,253,126,79,181,169,139,217,83,15,203,178,184)
IMAGE_DATA(247,145,227,15,69,59,191,103,15,87,236,105,6,94,61,148,248,189,103,80,99,247,158,1,135,223,107,6,92,118,175,25)
IMAGE_DATA(164,252,209,156,255,93,225,119,175,25,228,174,61,101,14,166,189,102,208,194,239,37,131,210,189,170,198,239,33,131,59,252)
IMAGE_DATA(214,25,148,230,28,46,191,101,6,37,254,125,205,124,86,205,235,104,254,218,124,95,155,63,173,51,224,220,175,168,210,59)
IMAGE_DATA(86,25,112,239,181,71,15,121,91,23,113,249,15,166,82,239,140,206,64,178,206,57,152,184,175,29,145,129,148,95,90,154)
IMAGE_DATA(252,82,246,120,14,226,246,144,102,6,45,189,67,130,57,72,51,131,150,190,105,229,215,200,160,133,191,165,127,180,50,208)
IMAGE_DATA(254,220,150,248,123,120,24,201,159,246,207,76,25,228,216,123,127,142,41,179,54,238,89,41,187,206,189,224,239,24,90,213)
IMAGE_DATA(155,125,164,7,45,118,8,130,32,232,31,8,95,230,128,32,40,167,25,23,152,49,223,182,113,207,43,252,205,147,23,14)
IMAGE_DATA(51,199,139,21,123,11,247,149,143,209,236,53,166,112,126,21,87,205,43,109,155,97,115,246,141,37,95,245,247,233,122,224)
IMAGE_DATA(176,223,225,215,244,32,233,247,150,254,249,253,222,254,30,184,215,190,135,104,63,20,234,201,222,99,174,225,170,247,151,231)
IMAGE_DATA(36,215,254,170,247,185,253,255,243,127,108,248,75,62,90,248,251,28,70,131,31,252,247,248,165,243,207,29,126,157,7,98)
IMAGE_DATA(178,12,238,240,199,236,61,249,37,25,180,242,107,61,76,58,60,180,112,75,124,104,177,71,226,93,200,6,165,236,138,251)
IMAGE_DATA(130,153,217,79,15,189,246,95,6,236,167,135,86,31,241,195,122,203,51,138,125,188,179,106,231,15,241,107,189,156,175,36)
IMAGE_DATA(227,95,122,185,98,246,118,158,18,123,225,240,91,115,231,84,227,183,230,19,104,118,254,160,217,249,131,102,231,79,231,169)
IMAGE_DATA(41,53,59,63,4,65,16,228,67,95,214,84,170,141,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
IMAGE_DATA(120,156,237,154,235,109,195,48,12,132,57,74,22,40,208,17,61,154,55,83,161,250,81,85,213,131,164,69,145,74,121,0)
IMAGE_DATA(127,4,77,202,239,124,140,108,203,129,23,188,192,152,130,129,254,154,12,1,116,25,2,232,50,228,253,103,51,148,250,207)
IMAGE_DATA(100,168,245,159,197,208,234,63,131,161,215,95,154,193,106,254,179,251,215,94,207,232,159,191,182,178,38,255,215,254,46,151)
IMAGE_DATA(203,229,114,185,222,85,159,240,161,141,224,114,185,12,107,219,32,92,165,205,66,85,100,14,225,168,125,223,151,186,169,74)
IMAGE_DATA(217,115,15,219,182,153,247,81,226,143,5,39,191,101,15,53,246,60,3,171,30,90,252,214,51,232,177,91,207,0,195,111)
IMAGE_DATA(53,3,44,187,213,12,114,254,100,205,255,174,248,218,106,6,165,99,15,133,141,97,171,25,112,248,173,100,208,58,87,245)
IMAGE_DATA(248,45,100,240,132,95,59,131,214,154,131,229,215,204,160,197,127,94,51,223,213,243,58,155,191,183,222,247,214,79,237,12)
IMAGE_DATA(48,231,43,232,204,142,86,6,216,115,237,53,67,214,174,139,176,252,23,83,107,118,102,103,64,185,206,185,152,176,239,157)
IMAGE_DATA(145,1,149,159,90,146,252,84,246,116,13,194,206,144,100,6,156,217,1,194,26,36,153,1,103,110,184,252,18,25,112,248)
IMAGE_DATA(57,243,35,149,129,244,247,182,197,63,194,195,76,254,124,126,86,202,160,196,62,250,123,12,133,107,227,145,149,179,203,156)
IMAGE_DATA(11,254,246,144,170,209,236,51,61,72,177,187,92,46,151,235,13,228,63,230,112,185,92,37,173,120,129,153,242,29,55,238)
IMAGE_DATA(101,197,191,89,242,130,97,198,120,209,98,231,112,215,124,204,102,239,49,197,253,171,180,122,94,225,184,25,86,103,63,88)
IMAGE_DATA(202,213,255,156,172,7,12,251,19,126,73,15,148,121,231,204,207,239,207,142,247,128,61,246,35,4,231,166,208,72,246,17)
IMAGE_DATA(107,13,86,163,127,60,71,57,246,181,217,199,206,255,207,255,209,225,111,249,224,240,143,217,140,118,126,231,127,198,79,93)
IMAGE_DATA(127,158,240,203,60,16,163,101,240,132,63,101,31,201,79,201,128,203,47,245,48,233,242,192,225,166,248,144,98,79,132,59)
IMAGE_DATA(144,12,229,236,130,247,5,43,179,223,30,70,221,127,41,176,223,30,184,62,210,135,245,154,123,20,103,191,187,122,251,15)
IMAGE_DATA(233,123,173,236,175,100,253,171,94,106,204,214,246,83,82,47,24,126,109,238,146,122,252,218,124,4,173,206,31,181,58,127)
IMAGE_DATA(212,234,252,249,58,181,164,86,231,119,185,92,46,151,13,125,1,116,80,178,133,0,0,0,0,0,0,0,0,0,0,0)
IMAGE_END_DATA(576, 3)
IMAGE_BEGIN_DATA

View file

@ -171,7 +171,8 @@ void HelpWindow::SortTree(int id, int (*cmp)(const Value& k1, const Value& v1,
void HelpWindow::FinishTree()
{
tree.FindSetCursor(topic);
if(!tree.FindSetCursor(topic))
CurrentOrHome();
}
void HelpWindow::OpenDeep(int id)
@ -179,6 +180,55 @@ void HelpWindow::OpenDeep(int id)
tree.OpenDeep(id);
}
void HelpWindow::Ids(int pid, Vector<int>& r)
{
int n = tree.GetChildCount(pid);
for(int i = 0; i < n; i++) {
int id = tree.GetChild(pid, i);
if(!IsNull(tree.GetValue(id))) {
r.Add(id);
Ids(id, r);
}
}
}
Vector<int> HelpWindow::Ids()
{
Vector<int> r;
Ids(0, r);
return r;
}
bool HelpWindow::PrevNext(int d, bool allowempty)
{
Vector<int> r = Ids();
int id = tree.GetCursor();
if(id < 0)
return false;
int ii = FindIndex(r, id);
if(ii < 0)
return false;
for(;;) {
ii += d;
if(ii >= r.GetCount() || ii < 0)
return false;
if(!IsNull(tree.Get(r[ii])) || allowempty) {
tree.SetCursor(r[ii]);
return true;
}
}
}
bool HelpWindow::Next(bool allowempty)
{
return PrevNext(1, allowempty);
}
bool HelpWindow::Prev(bool allowempty)
{
return PrevNext(-1, allowempty);
}
void HelpWindow::Serialize(Stream& s)
{
s % zoom.m;
@ -195,8 +245,8 @@ void HelpWindow::TreeCursor()
void HelpWindow::CurrentOrHome()
{
if(~tree != current_link) {
if(tree.FindSetCursor(current_link))
if(~tree != current_link || IsNull(current_link)) {
if(!IsNull(current_link) && tree.FindSetCursor(current_link))
return;
for(int i = 0; i < tree.GetLineCount(); i++) {
Value k = tree.Get(tree.GetItemAtLine(i));
@ -206,6 +256,42 @@ void HelpWindow::CurrentOrHome()
}
}
Vector<int> HelpWindow::ScPositions(const Vector<int>& p)
{
Vector<int> r;
for(int i = 0; i < p.GetCount(); i++) {
int y = max(0, view.GetZoom() * view.Get().GetCaret(p[i], view.GetPage()).top - GetSize().cy / 2);
int ii = FindLowerBound(r, y);
if(ii == r.GetCount() || r[ii] != y)
r.Insert(ii, y);
}
return r;
}
bool HelpWindow::Up(const Vector<int>& poslist)
{
int q = view.GetSb();
Vector<int> p = ScPositions(poslist);
for(int i = p.GetCount() - 1; i >= 0; i--)
if(p[i] < q) {
view.SetSb(p[i]);
return view.GetSb() != q;
}
return false;
}
bool HelpWindow::Down(const Vector<int>& poslist)
{
int q = view.GetSb();
Vector<int> p = ScPositions(poslist);
for(int i = 0; i < p.GetCount(); i++)
if(p[i] > q) {
view.SetSb(p[i]);
return view.GetSb() != q;
}
return false;
}
HelpWindow::HelpWindow()
{
tree_view.Horz(tree, view);

View file

@ -31,11 +31,9 @@ private:
void EndSizeTracking();
void SetSb();
void Scroll();
Zoom GetZoom() const;
int GetPageCx(bool reduced = false) const;
int GetPointPos(Point p) const;
String GetLink(int pos, Point p) const;
Rect GetPage() const;
void RefreshSel();
void RefreshRange(int a, int b);
@ -61,6 +59,8 @@ public:
int GetSb() const { return sb; }
void SetSb(int i) { sb = i; }
int GetSbTotal() const { return sb.GetTotal(); }
Zoom GetZoom() const;
Rect GetPage() const;
void GotoLabel(const String& lbl, bool highlight = false);
void ClearHighlight() { highlight = Null; Refresh(); }
@ -177,6 +177,10 @@ private:
void SetZoom();
void Print();
Pos GetPos();
Vector<int> ScPositions(const Vector<int>& p);
void Ids(int pid, Vector<int>& r);
Vector<int> Ids();
bool PrevNext(int d, bool allowempty);
public:
virtual Topic AcquireTopic(const String& topic);
@ -198,6 +202,10 @@ public:
void OpenDeep(int id = 0);
void CurrentOrHome();
void ClearCurrentLink() { current_link.Clear(); }
bool Up(const Vector<int>& poslist);
bool Down(const Vector<int>& poslist);
bool Next(bool allowempty = false);
bool Prev(bool allowempty = false);
String GetCurrent() const { return topic; }
String GetCurrentLabel() const { return label; }