[PATCH 24/45] [WinHelp]: properly handle multiple files in the history
Eric Pouech
eric.pouech at orange.fr
Sun Mar 23 04:19:45 CDT 2008
- changing history display depending on current file
- add to history only if the added page is different from current
A+
---
programs/winhelp/winhelp.c | 39 +++++++++++++++++++++++++++++----------
1 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c
index 3a96bf1..7f75caf 100644
--- a/programs/winhelp/winhelp.c
+++ b/programs/winhelp/winhelp.c
@@ -477,14 +477,11 @@ void WINHELP_LayoutMainWindow(WINHELP_WINDOW* win)
static void WINHELP_AddHistory(WINHELP_WINDOW* win, HLPFILE_PAGE* page)
{
- unsigned i, num;
+ unsigned num;
/* FIXME: when using back, we shouldn't update the history... */
- for (i = 0; i < Globals.history.index; i++)
- if (Globals.history.set[i].page == page) break;
-
- /* if the new page is already in the history, do nothing */
- if (i == Globals.history.index)
+ /* add to history only if different from top of history */
+ if (!Globals.history.index || Globals.history.set[0].page != page)
{
num = sizeof(Globals.history.set) / sizeof(Globals.history.set[0]);
/* we're full, remove latest entry */
@@ -499,8 +496,8 @@ static void WINHELP_AddHistory(WINHELP_WINDOW* win, HLPFILE_PAGE* page)
Globals.history.set[0].wininfo = win->info;
Globals.history.index++;
page->file->wRefCount++;
- if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE);
}
+ if (win->hHistoryWnd) InvalidateRect(win->hHistoryWnd, NULL, TRUE);
num = sizeof(win->back.set) / sizeof(win->back.set[0]);
if (win->back.index == num)
@@ -1143,9 +1140,31 @@ static LRESULT CALLBACK WINHELP_HistoryWndProc(HWND hWnd, UINT msg, WPARAM wPara
for (i = 0; i < Globals.history.index; i++)
{
- TextOut(hDc, 0, i * tm.tmHeight,
- Globals.history.set[i].page->lpszTitle,
- strlen(Globals.history.set[i].page->lpszTitle));
+ if (Globals.history.set[i].page->file == Globals.active_win->page->file)
+ {
+ TextOut(hDc, 0, i * tm.tmHeight,
+ Globals.history.set[i].page->lpszTitle,
+ strlen(Globals.history.set[i].page->lpszTitle));
+ }
+ else
+ {
+ char buffer[1024];
+ const char* ptr1;
+ const char* ptr2;
+ unsigned len;
+
+ ptr1 = strrchr(Globals.history.set[i].page->file->lpszPath, '\\');
+ if (!ptr1) ptr1 = Globals.history.set[i].page->file->lpszPath;
+ else ptr1++;
+ ptr2 = strrchr(ptr1, '.');
+ len = ptr2 ? ptr2 - ptr1 : strlen(ptr1);
+ if (len > sizeof(buffer)) len = sizeof(buffer);
+ memcpy(buffer, ptr1, len);
+ if (len < sizeof(buffer)) buffer[len++] = ':';
+ strncpy(&buffer[len], Globals.history.set[i].page->lpszTitle, sizeof(buffer) - len);
+ buffer[sizeof(buffer) - 1] = '\0';
+ TextOut(hDc, 0, i * tm.tmHeight, buffer, strlen(buffer));
+ }
}
EndPaint(hWnd, &ps);
break;
More information about the wine-patches
mailing list