1 /**************************************************************
2 **** memory.h: main data-types for storing file in memory ****
3 **** Free software under GNU license, written in 15/2/2000 ****
4 **** © T.Pierron, C.Guillaume. ****
5 **************************************************************/
10 #include <exec/types.h>
11 #include <exec/memory.h>
13 /*** Internal representation of a line of text: ***/
16 struct _Line
*next
,*prev
; /* linked list */
17 ULONG size
, max
; /* actual size and max before overflow */
18 STRPTR stream
; /* Start of buffer */
19 UBYTE flags
; /* See below */
24 /*** Valid flags for the previous field ***/
25 #define FIRSTSEL 1 /* Line begins a selection */
26 #define LASTSEL 2 /* Line ends a selection */
27 #define WHOLESEL 4 /* Entire line is selected */
29 /*** Granularity of mem allocation (power of 2) ***/
30 #define GRANULARITY 16
32 /*** Special code ***/
33 #define KERNEL_PANIC (ULONG)-1
35 LINE
*create_line (STRPTR
,ULONG size
); /* Create a new line of size bytes */
36 LINE
*new_line (LINE
*); /* Simplified line creation */
37 void free_line (LINE
*);
38 void trash_file (LINE
*); /* Trash all lines of a file */
39 BOOL
add_char (JBuf
,LINE
*,ULONG
,UBYTE
); /* Add a char to a line at pos */
40 BOOL
insert_str (JBuf
,LINE
*,ULONG
,STRPTR
,ULONG
); /* Like add_string, but doesn't care of \n */
41 BOOL
rem_chars (JBuf
,LINE
*,ULONG s
, ULONG e
); /* Remove chars between and incl. s, e (s<=e) */
42 BOOL
del_line (JBuf
,LINE
**,LINE
*); /* Remove an line */
43 BOOL
join_lines (JBuf
,LINE
*, LINE
*); /* Join to lines */
44 BOOL
split_line (JBuf
,LINE
*,ULONG
,ULONG
*,BYTE
); /* Split line in two parts with indent */
45 BOOL
replace_char (LINE
*,ULONG
,UBYTE
); /* Change char at pos */
46 ULONG
size_count (LINE
*,BYTE
); /* Count the bytes of a file */
48 BOOL
replace_chars(LINE
*,ULONG s
,ULONG e
,UBYTE (*change
)(UBYTE
));
51 BOOL
add_string (JBuf
, LINE
*, ULONG pos
, STRPTR
, ULONG len
, LONG
*buf
);
52 BOOL
add_block (JBuf
, LINE
*, ULONG pos
, STRPTR
, ULONG len
, LONG
*buf
);
53 /* buf will be set to the following values at the exit:
54 ** buf[0]: Horizontal position for the cursor
55 ** buf[1]: Number of lines modified in the display
56 ** buf[2]: Number of lines added to the buffer (rq: for add_string buf[1] == buf[2])