1 /**************************************************************************** 2 Copyright (C) 1987-2015 by Jeffery P. Hansen 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along 15 with this program; if not, write to the Free Software Foundation, Inc., 16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 ****************************************************************************/ 18 #ifndef __text_h 19 #define __text_h 20 21 /***************************************************************************** 22 * 23 * A line of text with a link to the next line. 24 * 25 *****************************************************************************/ 26 typedef struct text_line { 27 char *text; /* Text on the line */ 28 struct text_line *next; /* Next line */ 29 } TextLine; 30 31 /***************************************************************************** 32 * 33 * A block of text lines 34 * 35 *****************************************************************************/ 36 typedef struct { 37 TextLine *tb_first; /* First line of text */ 38 TextLine *tb_last; /* Last line of text */ 39 int tb_curLine; /* Saved line number of cursor */ 40 int tb_curChar; /* Saved character number of cursor */ 41 } TextBlock; 42 43 /***************************************************************************** 44 * 45 * A position in the text buffer. 46 * 47 *****************************************************************************/ 48 typedef struct { 49 TextLine *tp_line; 50 int tp_pos; 51 } TextPos; 52 53 TextBlock *new_TextBlock(); 54 void delete_TextBlock(TextBlock *tb); 55 void TextBlock_copy(TextBlock *dst,TextBlock *src); 56 void TextBlock_copyRange(TextBlock *dst,TextLine *start,TextLine *stop); 57 void TextBlock_addLine(TextBlock *tb,const char *text); 58 void TextBlock_prependLine(TextBlock *tb,const char *text); 59 void TextBlock_flush(TextBlock *tb); 60 #define TextBlock_first(tb) (tb)->tb_first 61 62 void TextBlock_getStartTP(TextBlock *tb,TextPos *tp); 63 char *TextPos_getToken(TextPos *tp,char *buf); 64 65 #define TextLine_next(tl) (tl)->next 66 #define TextLine_text(tl) (tl)->text 67 68 #endif 69