barnowl_perlaimdebianowlrelease-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change
on this file since 217a43e was
1aee7d9,
checked in by Erik Nygren <nygren@mit.edu>, 22 years ago
|
* Added RCS Id strings to all files.
* 'show keymaps' shows details of all keymaps after summary list.
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | #include "owl.h" |
---|
2 | |
---|
3 | static const char fileIdent[] = "$Id$"; |
---|
4 | |
---|
5 | void owl_history_init(owl_history *h) { |
---|
6 | owl_list_create(&(h->hist)); |
---|
7 | h->cur=0; |
---|
8 | h->touched=0; |
---|
9 | h->partial=0; |
---|
10 | } |
---|
11 | |
---|
12 | char *owl_history_get_prev(owl_history *h) { |
---|
13 | h->touched=1; |
---|
14 | |
---|
15 | if (owl_list_get_size(&(h->hist))==0) return(NULL); |
---|
16 | |
---|
17 | if (h->cur == owl_list_get_size(&(h->hist))-1) { |
---|
18 | return(NULL); |
---|
19 | } |
---|
20 | |
---|
21 | h->cur++; |
---|
22 | return(owl_list_get_element(&(h->hist), h->cur)); |
---|
23 | } |
---|
24 | |
---|
25 | char *owl_history_get_next(owl_history *h) { |
---|
26 | if (owl_list_get_size(&(h->hist))==0) return(NULL); |
---|
27 | |
---|
28 | if (h->cur==0) { |
---|
29 | return(NULL); |
---|
30 | } |
---|
31 | |
---|
32 | h->cur--; |
---|
33 | return(owl_list_get_element(&(h->hist), h->cur)); |
---|
34 | } |
---|
35 | |
---|
36 | void owl_history_store(owl_history *h, char *line) { |
---|
37 | int size; |
---|
38 | |
---|
39 | /* if partial is set, remove the first entry first */ |
---|
40 | if (h->partial) { |
---|
41 | owl_list_remove_element(&(h->hist), 0); |
---|
42 | } |
---|
43 | |
---|
44 | /* if we've reached the max history size, pop off the last element */ |
---|
45 | size=owl_list_get_size(&(h->hist)); |
---|
46 | if (size>OWL_HISTORYSIZE) { |
---|
47 | owl_free(owl_list_get_element(&(h->hist), size-1)); |
---|
48 | owl_list_remove_element(&(h->hist), size-1); |
---|
49 | } |
---|
50 | |
---|
51 | /* add the new line */ |
---|
52 | owl_list_prepend_element(&(h->hist), owl_strdup(line)); |
---|
53 | } |
---|
54 | |
---|
55 | void owl_history_set_partial(owl_history *h) { |
---|
56 | h->partial=1; |
---|
57 | } |
---|
58 | |
---|
59 | void owl_history_reset(owl_history *h) { |
---|
60 | h->cur=0; |
---|
61 | h->touched=0; |
---|
62 | h->partial=0; |
---|
63 | } |
---|
64 | |
---|
65 | int owl_history_is_touched(owl_history *h) { |
---|
66 | if (h->touched) return(1); |
---|
67 | return(0); |
---|
68 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.