summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-02-24 12:03:09 +0100
committerTor Andersson <tor.andersson@artifex.com>2015-10-06 11:21:23 +0200
commit3e487212fa31c4a3bcc8d470b8c90fc1c02b6f81 (patch)
tree2a4c311a401ba2c3b879617e2595db556b31e653
parentf35145115c1ddca1e6be698911168cce213c0241 (diff)
downloadmupdf-3e487212fa31c4a3bcc8d470b8c90fc1c02b6f81.tar.xz
glut: Add navigation history and numbered bookmarks.
<N>m to save a bookmark. <N>t to return to a bookmark. 'm' to save the current page in the navigation stack. 't' to return to the previous navigation point. Hyperlinks, <N>g, and <N>t will automatically save the current page in the navigation stack before jumping to the new page. Conflicts: platform/glut/glut-main.c
-rw-r--r--platform/glut/glut-main.c42
1 files changed, 40 insertions, 2 deletions
diff --git a/platform/glut/glut-main.c b/platform/glut/glut-main.c
index a612232c..cb089087 100644
--- a/platform/glut/glut-main.c
+++ b/platform/glut/glut-main.c
@@ -203,6 +203,23 @@ static float oldrotate = 0, currentrotate = 0;
static int showoutline = 0;
static int showlinks = 0;
+static int history_count = 0;
+static int history[256];
+static int marks[10];
+
+static void push_history(void)
+{
+ if (history_count + 1 >= nelem(history))
+ {
+ memmove(history, history + 1, sizeof *history * (nelem(history) - 1));
+ history[history_count] = currentpage;
+ }
+ else
+ {
+ history[history_count++] = currentpage;
+ }
+}
+
static void draw_string(float x, float y, const char *s)
{
int c;
@@ -287,6 +304,7 @@ static int draw_outline_imp(fz_outline *node, int end, int x0, int x1, int x, in
if (!ui.active && ui.down)
{
ui.active = node;
+ push_history();
currentpage = p;
glutPostRedisplay(); /* we changed the current page, so force a redraw */
}
@@ -383,9 +401,14 @@ static void draw_links(fz_link *link, int xofs, int yofs, float zoom, float rota
if (ui.hot == link)
{
if (link->dest.kind == FZ_LINK_GOTO)
+ {
+ push_history();
currentpage = link->dest.ld.gotor.page;
+ }
else if (link->dest.kind == FZ_LINK_URI)
+ {
open_browser(link->dest.ld.uri.uri);
+ }
}
glutPostRedisplay();
}
@@ -622,6 +645,21 @@ static void keyboard(unsigned char key, int x, int y)
switch (key)
{
+ case 'm':
+ if (number == 0)
+ push_history();
+ else if (number > 0 && number < nelem(marks))
+ marks[number] = currentpage;
+ break;
+ case 't':
+ if (number == 0 && history_count > 0)
+ currentpage = history[--history_count];
+ else if (number > 0 && number < nelem(marks))
+ {
+ push_history();
+ currentpage = marks[number];
+ }
+ break;
case 'f': toggle_fullscreen(); break;
case 'W': auto_zoom_w(); break;
case 'H': auto_zoom_h(); break;
@@ -633,8 +671,8 @@ static void keyboard(unsigned char key, int x, int y)
case '.': currentpage += fz_maxi(number, 1); break;
case 'b': number = fz_maxi(number, 1); while (number--) smart_move_backward(); break;
case ' ': number = fz_maxi(number, 1); while (number--) smart_move_forward(); break;
- case 'g': currentpage = number - 1; break;
- case 'G': currentpage = fz_count_pages(ctx, doc) - 1; break;
+ case 'g': push_history(); currentpage = number - 1; break;
+ case 'G': push_history(); currentpage = fz_count_pages(ctx, doc) - 1; break;
case '+': currentzoom = zoom_in(currentzoom); break;
case '-': currentzoom = zoom_out(currentzoom); break;
case '[': currentrotate += 90; break;