}
m_Engine.LookFor(keyword, case_sensitive, whole_words_only);
m_Active = (m_CurIndex < m_MaxIndex);
- m_LastPage = wxEmptyString;
+ m_LastPage = NULL;
}
bool wxHtmlSearchStatus::Search()
wxFSFile *file;
int i = m_CurIndex; // shortcut
bool found = FALSE;
+ wxChar *thepage;
if (!m_Active) {
// sanity check. Illegal use, but we'll try to prevent a crash anyway
return FALSE;
}
- m_ContentsItem = NULL;
m_Name = wxEmptyString;
+ m_ContentsItem = NULL;
+ thepage = m_Data->m_Contents[i].m_Page;
- file = fsys.OpenFile(m_Data->m_Contents[i].m_Book -> GetBasePath() + m_Data->m_Contents[i].m_Page);
- if (file) {
- if (m_LastPage != file->GetLocation()) {
- m_LastPage = file->GetLocation();
- if (m_Engine.Scan(file -> GetStream())) {
- m_Name = m_Data->m_Contents[i].m_Name;
- m_ContentsItem = m_Data->m_Contents + i;
- found = TRUE;
- }
+ m_Active = (++m_CurIndex < m_MaxIndex);
+ // check if it is same page with different anchor:
+ if (m_LastPage != NULL)
+ {
+ wxChar *p1, *p2;
+ for (p1 = thepage, p2 = m_LastPage;
+ *p1 != 0 && *p1 != _T('#') && *p1 == *p2; p1++, p2++) {}
+
+ m_LastPage = thepage;
+
+ if (*p1 == 0 || *p1 == _T('#'))
+ return FALSE;
+ }
+ else m_LastPage = thepage;
+
+ file = fsys.OpenFile(m_Data->m_Contents[i].m_Book -> GetBasePath() + thepage);
+ if (file)
+ {
+ if (m_Engine.Scan(file -> GetStream())) {
+ m_Name = m_Data->m_Contents[i].m_Name;
+ m_ContentsItem = m_Data->m_Contents + i;
+ found = TRUE;
}
delete file;
}
- m_Active = (++m_CurIndex < m_MaxIndex);
return found;
}
}
m_HtmlWin -> Show(TRUE);
- //RefreshLists();
+ RefreshLists();
// showtime
if (m_NavigPan && m_Splitter) {
while (status.IsActive()) {
curi = status.GetCurIndex();
- if (curi % 10 == 0 && progress.Update(curi) == FALSE)
+ if (curi % 32 == 0 && progress.Update(curi) == FALSE)
break;
if (status.Search()) {
foundstr.Printf(_("Found %i matches"), ++foundcnt);
progress.Update(status.GetCurIndex(), foundstr);
m_SearchList -> Append(status.GetName(), status.GetContentsItem());
}
- wxYield();
}
m_SearchButton -> Enable(TRUE);
#define MAX_ROOTS 64
-void wxHtmlHelpFrame::CreateContents(bool show_progress)
+void wxHtmlHelpFrame::CreateContents()
{
if (! m_ContentsBox)
return ;
- wxProgressDialog *progress = NULL;
- wxString proginfo;
-
m_ContentsBox->Clear();
int cnt = m_Data->GetContentsCnt();
- int div = (cnt / PROGRESS_STEP) + 1;
int i;
wxHtmlContentsItem *it;
- if (show_progress)
- progress = new wxProgressDialog(_("Building contents tree..."), wxEmptyString,
- cnt, this, wxPD_APP_MODAL | wxPD_CAN_ABORT |
- wxPD_AUTO_HIDE);
-
wxTreeItemId roots[MAX_ROOTS];
bool imaged[MAX_ROOTS];
imaged[0] = TRUE;
for (it = m_Data->GetContents(), i = 0; i < cnt; i++, it++) {
- if (show_progress && ((i % div) == 0)) {
- proginfo.Printf(_("Added %d/%d items"), i, cnt);
- if (! progress->Update(i, proginfo))
- break;
- wxYield();
- }
roots[it -> m_Level + 1] = m_ContentsBox -> AppendItem(
roots[it -> m_Level], it -> m_Name, IMG_Page, -1,
new wxHtmlHelpTreeItemData(it));
imaged[it -> m_Level] = TRUE;
}
}
- if (show_progress)
- delete progress;
m_ContentsBox -> Expand(roots[0]);
}
-void wxHtmlHelpFrame::CreateIndex(bool show_progress)
+void wxHtmlHelpFrame::CreateIndex()
{
if (! m_IndexList)
return ;
- wxProgressDialog *progress = NULL;
- wxString proginfo;
-
m_IndexList->Clear();
int cnt = m_Data->GetIndexCnt();
m_IndexCountInfo -> SetLabel(cnttext);
if (cnt > INDEX_IS_SMALL) return;
- int div = (cnt / PROGRESS_STEP) + 1;
-
wxHtmlContentsItem* index = m_Data->GetIndex();
- if (show_progress)
- progress = new wxProgressDialog(_("Building index list..."), wxEmptyString,
- cnt, this, wxPD_APP_MODAL | wxPD_CAN_ABORT |
- wxPD_AUTO_HIDE);
- for (int i = 0; i < cnt; i++) {
- if (show_progress && ((i % div) == 0)) {
- proginfo.Printf(_("Added %d/%d items"), i, cnt);
- if (! progress->Update(i, proginfo))
- break;
- wxYield();
- }
+ for (int i = 0; i < cnt; i++)
m_IndexList -> Append(index[i].m_Name, (char*)(index + i));
- }
-
- if (show_progress)
- delete progress;
}
void wxHtmlHelpFrame::CreateSearch()
}
-void wxHtmlHelpFrame::RefreshLists(bool show_progress)
+void wxHtmlHelpFrame::RefreshLists()
{
- CreateContents(show_progress);
- CreateIndex(show_progress);
+ CreateContents();
+ CreateIndex();
CreateSearch();
}