1
/* $Id: history.h,v 1.25 2004/01/04 01:42:29 miciah Exp $ */
3
#ifndef EL__SCHED_HISTORY_H
4
#define EL__SCHED_HISTORY_H
6
#include "sched/location.h"
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 */
16
/* The current location. This is moveable pivot pointing somewhere at
17
* the middle of @history. */
18
struct location *current;
22
void create_history(struct ses_history *history);
23
void destroy_history(struct ses_history *history);
24
void clean_unhistory(struct ses_history *history);
26
void compress_history(struct ses_history *history, struct location *loc);
30
add_to_history(struct ses_history *history, struct location *loc)
34
compress_history(history, loc);
37
if (!history->current) {
38
add_to_list(history->history, loc);
40
add_at_pos(history->current, loc);
43
history->current = loc;
47
del_from_history(struct ses_history *history, struct location *loc)
49
if (history->current == loc)
50
history->current = loc->prev;
52
if (history->current == (struct location *) &history->history)
53
history->current = loc->next;
55
if (history->current == (struct location *) &history->history)
56
history->current = NULL;
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);
71
void ses_history_move(struct session *ses);