Diffstat (limited to 'noncore/apps/opie-reader/Navigation.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/Navigation.cpp | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/noncore/apps/opie-reader/Navigation.cpp b/noncore/apps/opie-reader/Navigation.cpp index 36e33b4..a886d88 100644 --- a/noncore/apps/opie-reader/Navigation.cpp +++ b/noncore/apps/opie-reader/Navigation.cpp | |||
@@ -1,81 +1,8 @@ | |||
1 | #ifdef _WINDOWS | 1 | #ifdef _WINDOWS |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #endif | 3 | #endif |
4 | #include "Navigation.h" | 4 | #include "Navigation.h" |
5 | //#include <stdio.h> | ||
6 | |||
7 | /* | ||
8 | void saveposn(size_t posn) | ||
9 | save/push position to history buffer for future use of back() function | ||
10 | */ | ||
11 | void CNavigation::saveposn(size_t posn) | ||
12 | { | ||
13 | //printf("saving position %u, depth %u\n",posn,historycurrent); | ||
14 | history[historycurrent] = posn; | ||
15 | historycurrent=(historycurrent+1)%NAVIGATION_HISTORY_SIZE; | ||
16 | if (historycurrent==historystart) | ||
17 | // circular buffer full, forget oldest record | ||
18 | historystart=(historystart+1)%NAVIGATION_HISTORY_SIZE; | ||
19 | // no forward possible after saveposn | ||
20 | historyend = historycurrent; | ||
21 | } | ||
22 | |||
23 | /* | ||
24 | void writeposn(size_t posn) | ||
25 | overwrite current (unused) position | ||
26 | useful for saving current position before using back button | ||
27 | */ | ||
28 | void CNavigation::writeposn(size_t posn) | ||
29 | { | ||
30 | //printf("witing position %u, depth %u\n",posn,historycurrent); | ||
31 | history[historycurrent] = posn; | ||
32 | } | ||
33 | |||
34 | /* | ||
35 | bool back(size_t& posn) | ||
36 | go back in history | ||
37 | restore last position saved with saveposn() and return true | ||
38 | return false if there is nothing saved in history | ||
39 | */ | ||
40 | bool CNavigation::back(size_t& posn) | ||
41 | { | ||
42 | if (historycurrent!=historystart) { | ||
43 | // buffer is not empty | ||
44 | if (historycurrent==0) | ||
45 | historycurrent=NAVIGATION_HISTORY_SIZE-1; | ||
46 | else | ||
47 | historycurrent--; | ||
48 | posn=history[historycurrent]; | ||
49 | //printf("back(): going back to %u depth %u\n",posn,historycurrent); | ||
50 | return true; | ||
51 | |||
52 | } else { | ||
53 | // circular buffer empty | ||
54 | //printf("back(): empty history\n"); | ||
55 | return false; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | /* | ||
60 | bool forward(size_t& posn) | ||
61 | go forward in history, if possible | ||
62 | undo calling of back() | ||
63 | */ | ||
64 | bool CNavigation::forward(size_t& posn) | ||
65 | { | ||
66 | if (historycurrent!=historyend) { | ||
67 | // [historycurrent] = current position | ||
68 | // [historycurrent+1] = position we need | ||
69 | historycurrent=(historycurrent+1)%NAVIGATION_HISTORY_SIZE; | ||
70 | posn = history[historycurrent]; | ||
71 | //printf("forward(): going to position %d\n",posn); | ||
72 | return true; | ||
73 | } else { | ||
74 | //printf("forward(): there is no future :)\n"); | ||
75 | return false; | ||
76 | } | ||
77 | } | ||
78 | 5 | ||
79 | void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 6 | void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
80 | { | 7 | { |
81 | len = srclen+sizeof(size_t)*(3+NAVIGATION_HISTORY_SIZE); | 8 | len = srclen+sizeof(size_t)*(3+NAVIGATION_HISTORY_SIZE); |
@@ -89,14 +16,8 @@ void CNavigation::setSaveData(unsigned char*& data, unsigned short& len, unsigne | |||
89 | p += sizeof(size_t); | 16 | p += sizeof(size_t); |
90 | memcpy(p, &historycurrent, sizeof(size_t)); | 17 | memcpy(p, &historycurrent, sizeof(size_t)); |
91 | p += sizeof(size_t); | 18 | p += sizeof(size_t); |
92 | memcpy(p, history, sizeof(size_t)*NAVIGATION_HISTORY_SIZE); | 19 | memcpy(p, history, sizeof(size_t)*NAVIGATION_HISTORY_SIZE); |
93 | /* | ||
94 | printf("<%u,%u,%u>\n", historystart, historyend, historycurrent); | ||
95 | for (int i = historystart; i <= historyend; i++) | ||
96 | printf("<%u> ", history[i]); | ||
97 | printf("\n"); | ||
98 | */ | ||
99 | } | 20 | } |
100 | 21 | ||
101 | void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen) | 22 | void CNavigation::putSaveData(unsigned char*& src, unsigned short& srclen) |
102 | { | 23 | { |