2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #ifndef __gator_textcb_h
11 #define __gator_textcb_h 1
13 /*------------------------------------------------------------------------
16 * Definitions and interface for the gator circular buffer package for
17 * its scrollable text object.
19 *------------------------------------------------------------------------*/
21 #include <lock.h> /*AFS locks */
23 #define GATOR_TEXTCB_MAXINVERSIONS 10 /*Max highlight inversions */
26 * Description of the text hanging off each circular buffer entry.
28 struct gator_textcb_entry
{
29 int ID
; /*Overall ID (number) */
30 int highlight
; /*(Starting) highlight value */
31 int inversion
[GATOR_TEXTCB_MAXINVERSIONS
]; /*Highlighting inversions */
32 int numInversions
; /*Num of above inversions */
33 int charsUsed
; /*Num chars used */
34 char *textp
; /*Ptr to text buffer itself */
38 * Circular buffer header. Note: we actually allocate one more char
39 * per line than we admit, to make sure we can always null-
40 * terminate each line.
42 struct gator_textcb_hdr
{
43 struct Lock cbLock
; /*Lock for this circular buffer */
44 int maxEntriesStored
; /*Max num. text entries we store */
45 int maxCharsPerEntry
; /*Max characters in each entry */
46 int currEnt
; /*Entry currently being written */
47 int currEntIdx
; /*Index of current entry */
48 int oldestEnt
; /*Oldest entry stored */
49 int oldestEntIdx
; /*Index of oldest entry */
50 struct gator_textcb_entry
*entry
; /*Ptr to array of text entries */
51 char *blankLine
; /*Ptr to blank line */
55 * Operations for text circular buffers.
57 extern int gator_textcb_Init(int);
60 * Initialize this package. MUST BE THE FIRST ROUTINE CALLED!
63 * int a_debug : Should debugging output be turned on?
67 * Error code otherwise.
70 extern struct gator_textcb_hdr
*gator_textcb_Create(int, int);
73 * Create a new text circular buffer.
76 * int a_maxEntriesStored : How many entries should it have?
77 * int a_maxCharsPerEntry : Max chars in each entry.
80 * Ptr to the fully-initialized circular buffer hdr if successful,
81 * Null pointer otherwise.
84 extern int gator_textcb_Write(struct gator_textcb_hdr
*, char *a_textToWrite
,
88 * Write the given string to the text circular buffer. Line
89 * breaks are caused either by overflowing the current text
90 * line or via explicit '\n's.
93 * struct gator_textcb_hdr *a_cbhdr : Ptr to circ buff hdr.
94 * char *a_textToWrite : Ptr to text to insert.
95 * int a_numChars : Number of chars to write.
96 * int a_highlight : Use highlighting?
97 * int a_skip; : Force a skip to the next line?
100 * Zero if successful,
101 * Error code otherwise.
104 extern int gator_textcb_BlankLine(struct gator_textcb_hdr
*, int);
107 * Write out some number of blank lines to the given circular
111 * struct gator_textcb_hdr *a_cbhdr : Ptr to circ buff hdr.
112 * int a_numBlanks : Num. blank lines to write.
115 * Zero if successful,
116 * Error code otherwise.
119 extern int gator_textcb_Delete(struct gator_textcb_hdr
*a_cbhdr
);
122 * Delete the storage used by the given circular buffer, including
126 * struct gator_textcb_hdr *a_cbhdr : Ptr to the header of the
127 * circ buffer to reap.
130 * Zero if successful,
131 * Error code otherwise.
134 #endif /* __gator_textcb_h */