1 /* 2 * HT Editor 3 * infoview.h 4 * 5 * Copyright (C) 1999-2002 Stefan Weyergraf 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 20 21 #ifndef __INFOVIEW_H__ 22 #define __INFOVIEW_H__ 23 24 #include "textedit.h" 25 #include "textfile.h" 26 27 #define MAGIC_HT_HELP "$$HTHELP" 28 29 /* 30 * CLASS info_node 31 */ 32 33 class info_node: public Object { 34 public: 35 FileOfs start; 36 uint len; 37 Container *xrefs; 38 39 info_node(FileOfs start); 40 ~info_node(); 41 }; 42 43 /* 44 * CLASS ht_info_lexer 45 */ 46 47 class ht_info_lexer: public ht_syntax_lexer { 48 public: 49 Container *xrefs; 50 uint cx, cy; 51 ht_view *pal_from; 52 53 void init(ht_view *pal_from); 54 /* overwritten */ 55 virtual vcp getcolor_syntax(uint pal_index); 56 virtual lexer_state getinitstate(); 57 virtual lexer_token geterrortoken(); 58 virtual const char *getname(); 59 virtual lexer_token gettoken(void *buf, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len); 60 virtual vcp gettoken_color(lexer_token t); 61 /* new */ 62 void set_xrefs(Container *xrefs); 63 void set_cursor(uint cx, uint cy); 64 }; 65 66 /* 67 * CLASS ht_info_textfile 68 */ 69 70 class ht_info_textfile: public ht_ltextfile { 71 protected: 72 uint start, end; 73 74 virtual ht_ltextfile_line *fetch_line(uint line) const; 75 public: 76 ht_info_textfile(File *streamfile, bool own_streamfile, ht_syntax_lexer *lexer); 77 /* overwritten */ 78 virtual uint linecount() const; 79 /* new */ 80 void set_node(uint ofs, uint len); 81 }; 82 83 /* 84 * CLASS ht_info_viewer 85 */ 86 87 class ht_info_viewer: public ht_text_viewer { 88 protected: 89 char *cwd; 90 char *file; 91 char *node; 92 Container *xrefs; 93 Container *history; 94 95 int find_node(const char *infofile, const char *node); 96 bool igotonode(const char *file, const char *node, bool add2hist); 97 uint readfile(char *fn, char **text); 98 public: 99 void init(Bounds *b); 100 virtual void done(); 101 /* overwritten */ 102 virtual void draw(); 103 virtual const char *defaultpalette(); 104 virtual int get_pindicator_str(char *buf, int max_len); 105 virtual void handlemsg(htmsg *msg); 106 /* new */ 107 virtual bool gotonode(const char *file, const char *node); 108 }; 109 110 #endif /* __INFOVIEW_H__ */ 111