~ubuntu-branches/ubuntu/feisty/elinks/feisty-updates

« back to all changes in this revision

Viewing changes to src/sched/history.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-06-30 08:57:43 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060630085743-l81fgbw9dehvl1ds
Tags: 0.11.1-1ubuntu1
* Merge to Debian unstable.
* Removed gnutls12 porting, this is upstream now.
* Only Ubuntu changes left:
  - Killed type-handling.
  - Add X-Ubuntu-Gettext-Domain to .desktop files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: history.h,v 1.25 2004/01/04 01:42:29 miciah Exp $ */
2
 
 
3
 
#ifndef EL__SCHED_HISTORY_H
4
 
#define EL__SCHED_HISTORY_H
5
 
 
6
 
#include "sched/location.h"
7
 
 
8
 
struct session;
9
 
 
10
 
struct ses_history {
11
 
        /* The first list item is the first visited location. The last list
12
 
         * item is the last location in the unhistory. The @current location is
13
 
         * included in this list. */
14
 
        struct list_head history; /* -> struct location */
15
 
 
16
 
        /* The current location. This is moveable pivot pointing somewhere at
17
 
         * the middle of @history. */
18
 
        struct location *current;
19
 
};
20
 
 
21
 
 
22
 
void create_history(struct ses_history *history);
23
 
void destroy_history(struct ses_history *history);
24
 
void clean_unhistory(struct ses_history *history);
25
 
#ifdef BUG_309_FIX
26
 
void compress_history(struct ses_history *history, struct location *loc);
27
 
#endif
28
 
 
29
 
static inline void
30
 
add_to_history(struct ses_history *history, struct location *loc)
31
 
{
32
 
#ifdef BUG_309_FIX
33
 
        if (history->current)
34
 
                compress_history(history, loc);
35
 
#endif
36
 
 
37
 
        if (!history->current) {
38
 
                add_to_list(history->history, loc);
39
 
        } else {
40
 
                add_at_pos(history->current, loc);
41
 
        }
42
 
 
43
 
        history->current = loc;
44
 
}
45
 
 
46
 
static inline void
47
 
del_from_history(struct ses_history *history, struct location *loc)
48
 
{
49
 
        if (history->current == loc)
50
 
                history->current = loc->prev;
51
 
 
52
 
        if (history->current == (struct location *) &history->history)
53
 
                history->current = loc->next;
54
 
 
55
 
        if (history->current == (struct location *) &history->history)
56
 
                history->current = NULL;
57
 
        del_from_list(loc);
58
 
}
59
 
 
60
 
 
61
 
/* Note that this function is dangerous, and its results are sort of
62
 
 * unpredictable. If the document is cached and is permitted to be fetched from
63
 
 * the cache, the effect of this function is immediate and you end up with the
64
 
 * new location being cur_loc(). BUT if the cache entry cannot be used, the
65
 
 * effect is delayed to the next main loop iteration, as the TASK_HISTORY
66
 
 * session task (ses_history_move()) is executed not now but in the bottom-half
67
 
 * handler. So, you MUST NOT depend on cur_loc() having an arbitrary value
68
 
 * after call to this function (or the regents go_(un)back(), of course). */
69
 
void go_history(struct session *ses, struct location *loc);
70
 
 
71
 
void ses_history_move(struct session *ses);
72
 
 
73
 
#endif