2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 * See the COPYING file for license information.
18 * Guillaume Chazarain <gfc@altern.org>
21 /*********************
23 *********************/
27 extern options_struct
*options
;
30 static GList
*node
; /* Currrent position in the list. */
32 static gint count
; /* Number of elements in the list. */
33 static gboolean used
; /* Whether the history has been initialized. */
35 void init_history(void)
37 if (options
->history_size
!= 0) {
45 /* Returns item->next. */
46 static GList
*free_item(GList
* item
)
54 g_list_delete_link(list
, item
);
58 static void free_list(GList
* item
)
61 item
= free_item(item
);
64 static void clean_list(void)
66 while (count
> options
->history_size
) {
69 list
= free_item(list
);
75 void append_history(void)
79 if (used
== FALSE
|| options
->history_size
== 0)
82 item
= g_list_alloc();
83 item
->data
= g_new(gfloat
, 8);
85 matrix_cpy(item
->data
, NULL
);
93 if (node
->next
!= NULL
)
94 free_list(node
->next
);
102 if (options
->history_size
> 0)
106 static void set_state(GList
* item
)
108 if (item
!= NULL
&& item
->data
!= NULL
) {
110 matrix_cpy(NULL
, item
->data
);
111 refresh(REFRESH_IMAGE
| REFRESH_STATUS
);
117 set_state(g_list_previous(node
));
122 set_state(g_list_next(node
));
125 void clear_history(void)