1 /***********************************************************************/
5 /* Jacob Navia, after Xavier Leroy */
7 /* Copyright 2001 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../LICENSE. */
12 /***********************************************************************/
14 /***********************************************************************/
15 /* Changes made by Chris Watford to enhance the source editor */
16 /* Began 14 Sept 2003 - watford@uiuc.edu */
17 /***********************************************************************/
22 /*------------------------------------------------------------------------
23 Procedure: AddToHistory ID:2
24 Author: Chris Watford watford@uiuc.edu
25 Purpose: Adds an edit buffer to the history control
26 Input: Pointer to the edit buffer to add
29 --------------------------------------------------------------------------
31 15 Sept 2003 - Chris Watford watford@uiuc.edu
33 - Got it to add the edit buffer to the history
34 17 Sept 2003 - Chris Watford watford@uiuc.edu
35 - Added doubly link list support
36 ------------------------------------------------------------------------*/
37 void AddToHistory(EditBuffer
*edBuf
)
39 StatementHistory
*newLine
;
45 } else if (edBuf
->LineCount
== 0 || edBuf
->Lines
== NULL
) {
46 // fix any possible errors that may come from this
52 // setup newline and add as the front of the linked list
53 newLine
= SafeMalloc(sizeof(StatementHistory
));
54 newLine
->Next
= History
;
56 newLine
->Statement
= edBuf
;
60 History
->Prev
= newLine
;
65 // search for the new history tail
66 for(HistoryTail
= (HistoryTail
!= NULL
? HistoryTail
: History
); HistoryTail
->Next
!= NULL
; HistoryTail
= HistoryTail
->Next
);
69 /*------------------------------------------------------------------------
70 Procedure: GetHistoryLine ID:2
71 Author: Chris Watford watford@uiuc.edu
72 Purpose: Returns an entry from the history table
73 Input: Index of the history entry to return
74 Output: The history entry as a single line
76 --------------------------------------------------------------------------
78 15 Sept 2003 - Chris Watford watford@uiuc.edu
80 17 Sept 2003 - Chris Watford watford@uiuc.edu
81 - Added doubly link list support
82 ------------------------------------------------------------------------*/
83 char *GetHistoryLine(int n
)
85 StatementHistory
*histentry
= History
;
88 // traverse linked list looking for member n
89 for (i
= 0; ((i
< n
) && (histentry
!= NULL
)); i
++, histentry
= histentry
->Next
);
91 // figure out what to return
92 if (histentry
!= NULL
)
94 return editbuffer_getasline(histentry
->Statement
);