home *** CD-ROM | disk | FTP | other *** search
- #ifndef _InfoP_h
- #define _InfoP_h
-
- /* $Header: /usr1/ben/jkh/src/xinfo/RCS/InfoP.h,v 1.3 90/01/29 11:29:24 jkh Exp $ */
-
- /*
- *
- * Copyright 1989, 1990
- * Jordan K. Hubbard
- *
- * PCS Computer Systeme, GmbH.
- * Munich, West Germany
- *
- *
- * This file is part of GNU Info widget.
- *
- * The GNU Info widget is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 1, or (at your option)
- * any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this software; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *
- */
-
- /*
- *
- * $Log: InfoP.h,v $
- * Revision 1.3 90/01/29 11:29:24 jkh
- * *** empty log message ***
- *
- * Revision 1.2 90/01/28 11:18:05 jkh
- * Fixed comment header.
- *
- * Revision 1.1 90/01/27 22:43:36 jkh
- * Initial revision
- *
- *
- */
-
- /* max length of argument string */
- #define ARGLEN 128
-
- /* max generic string size */
- #define MAXSTR 128
-
- /* if no max pathlen, define arbitrarily */
- #ifndef MAXPATHLEN
- #define MAXPATHLEN 512
- #endif
-
- /* More explanatory macro names */
- #define Export
- #define Import extern
- #define Local static
- #ifdef __GNUC__
- #define Inline inline
- #else
- #define Inline
- #endif
-
- /* number of inits to bump tables up by during allocation */
- #define TABLE_INC 50
-
- /* special INFO separator character */
- #define INFO_CHAR '\037'
-
- /* Delete char */
- #define DEL_CHAR '\177'
-
- /* Indirect start token */
- #define INDIRECT_TOKEN "\037\nIndirect:\n"
-
- /* Tag table start token */
- #define TAGTABLE_TOKEN "\nTag Table:\n"
-
- /* Indirect tag table token */
- #define ITAGTABLE_TOKEN "(Indirect)\n"
-
- /* Tag table end token */
- #define TAGEND_TOKEN "\037\nEnd tag table\n"
-
- /* Node header tokens */
- #define NODE_TOKEN "Node: "
- #define PREV_TOKEN "Previous: "
- #define NEXT_TOKEN "Next: "
- #define UP_TOKEN "Up: "
-
- /* Menu start token */
- #define MENU_TOKEN "\n* Menu:"
-
- /* Menu seperator token */
- #define MENU_SEP_TOKEN "\n* "
-
- /* Footnote start token */
- #define NOTE_TOKEN "*note"
-
- /* End of a name */
- #define NAME_END_TOKEN "\t\n,."
-
- /* white space */
- #define WHITE "\t\n\f "
-
- /* delimiting characters that designate a node name */
- #define NAME "\t\n,."
-
- /* Table manipulation macros */
-
- #define ZERO_TABLE(tab) \
- (tab).size = (tab).idx = 0;\
- (tab).table = (ID_P)NULL
-
- #define FREE_TABLE(tab) \
- if ((tab).table) \
- XtFree((tab).table); \
- (tab).table = NULL
-
- #define ALLOC_TABLE(tab) \
- FREE_TABLE(tab); \
- (tab).size = TABLE_INC; \
- (tab).idx = 0; \
- (tab).table = (ID_P)XtMalloc(sizeof(ID) * TABLE_INC)
-
- #define MAYBE_BUMP_TABLE(tab) \
- if ((tab).idx == (tab).size) { \
- (tab).size += TABLE_INC; \
- (tab).table = (ID_P)XtRealloc((tab).table, (tab).size * sizeof(ID)); \
- }
-
- #define ROUND_TABLE(tab) \
- if ((tab).idx + 1 != (tab).size) { \
- (tab).size = (tab).idx + 1;\
- (tab).table = (ID_P)XtRealloc((tab).table, (tab).size * sizeof(ID)); \
- } \
- (tab).table[(tab).idx].tag.name = NULL; \
- (tab).table[(tab).idx].offset.length = 0
-
- #define ZERO_LIST(lst) \
- ZERO_TABLE((lst).t); \
- (lst).l = (Strings)NULL
-
- #define ALLOC_LIST(lst) \
- ALLOC_TABLE((lst).t); \
- (lst).l = (Strings)XtMalloc(sizeof(String) * TABLE_INC)
-
- #define FREE_TAG_TABLE(tab) \
- { \
- int i; \
- for (i = 0; i < IDX((tab)); i++) \
- XtFree(I_NAME((tab).table[i])); \
- XtFree((tab).table); \
- (tab).table = NULL; \
- }
-
- #define MAYBE_BUMP_LIST(lst) \
- if ((lst).t.idx == (lst).t.size) { \
- (lst).t.size += TABLE_INC; \
- (lst).t.table = (ID_P)XtRealloc((lst).t.table, (lst).t.size * \
- sizeof(ID)); \
- (lst).l = (Strings)XtRealloc((lst).l, (lst).t.size * \
- sizeof(String)); \
- }
-
- #define ROUND_LIST(lst) \
- if ((lst).t.idx + 1 != (lst).t.size) { \
- (lst).t.size = (lst).t.idx + 1;\
- (lst).t.table = (ID_P)XtRealloc((lst).t.table, (lst).t.size * \
- sizeof(ID)); \
- (lst).l = (Strings)XtRealloc((lst).l, (lst).t.size * \
- sizeof(String)); \
- } \
- (lst).t.table[(lst).t.idx].tag.name = NULL; \
- (lst).t.table[(lst).t.idx].offset.length = 0; \
- (lst).l[(lst).t.idx] = NULL
-
- #define IDX(tab) ((tab).idx)
- #define TPOS(tab) ((tab).table[IDX(tab)])
- #define LPOS(lst) ((lst).l[IDX((lst).t)])
- #define INCP(tab) (IDX(tab)++)
-
- /* Turn address s into ptr relative index */
- #define INTOFF(ptr, s) ((int)((s) - (ptr)))
-
- /* Make sure widget is outermost widget */
- #define TOP_WIDGET(ww) ((InfoWidget)(XtIsSubclass((ww), panedWidgetClass) ? \
- (ww) : XtParent((ww))));
-
- /* #include <X11/Xaw/Info.h> */
- #include "Info.h"
- #include <X11/Xaw/PanedP.h>
-
- typedef String *Strings;
-
- typedef struct {
- int nichts;
- } InfoClassPart;
-
- typedef struct _InfoClassRec {
- CoreClassPart core_class;
- CompositeClassPart composite_class;
- ConstraintClassPart constraint_class;
- PanedClassPart paned_class;
- InfoClassPart info_class;
- } InfoClassRec;
-
- extern InfoClassRec infoClassRec;
-
- /* A generic ID (tag/offset). */
- typedef union _id {
- struct { /* if it's a tag */
- String name;
- int offset;
- } tag;
- struct { /* if it's an offset */
- int start;
- int length;
- } offset;
- } ID, *ID_P;
-
- /* An array of ID's */
- typedef struct _table {
- int idx; /* where we are in the table */
- int size;
- ID_P table;
- } Table;
-
- /* a special string/ID associative table */
- typedef struct _idlist {
- Table t; /* ID array representation */
- Strings l; /* string array representation */
- } IDList;
-
- /* everything we'd like to know about a node */
- typedef struct _nodeinfo {
- String file; /* node's file name */
- String node; /* node's nodename */
- int start; /* starting position */
- int length; /* length of node */
- ID name; /* location of nodename */
- ID prev, up, next; /* locations of prev, up, next */
- ID text; /* location of text */
- IDList menu; /* menu information */
- IDList xref; /* cross references */
- struct _nodeinfo *nextNode; /* for history list */
- } NodeInfo;
-
- typedef struct {
- /* resources */
- String path; /* search path */
- String file; /* current info file */
- String node; /* current node name */
- String helpFile; /* help file */
- String printCmd; /* lpr command */
- XtCallbackList callback; /* quit callback */
-
- /* private state */
- String tempfile; /* for the node contents */
- String subFile; /* current split file (if any) */
- NodeInfo *history; /* the history list */
- Table indirect; /* indirect files */
- Table tags; /* indirect tags */
- String data; /* pointer to file contents */
- int size; /* size of file contents */
- int hdrSize; /* size of file header */
- char arg[ARGLEN]; /* command argument string */
- Widget fileLabel, nodeLabel; /* file and node labels */
- Widget prevCmd, upCmd, nextCmd; /* prev, up and next commands */
- Widget menuList; /* menu list */
- Widget xrefList; /* xref list */
- Widget nodeText; /* node text */
- Widget statusLabel; /* status area */
- Widget messageLabel; /* message area */
- Widget xrefCmd, gotoCmd, searchCmd;/* xref, goto and search commands */
- Widget argText; /* xref/goto/search arg text */
- Widget helpPopup; /* help popup */
- } InfoPart;
-
- typedef struct _InfoRec {
- CorePart core;
- CompositePart composite;
- ConstraintPart constraint;
- PanedPart paned;
- InfoPart info;
- } InfoRec;
-
- typedef struct {
- int null;
- } InfoConstraintsPart;
-
- typedef struct _InfoConstraintsRec {
- PanedConstraintsPart paned ;
- InfoConstraintsPart info;
- } InfoConstraintsRec, *InfoConstraints;
-
- /* special accessors for info widget */
- #define DATA(iw) ((iw)->info.data)
- #define DATASIZE(iw) ((iw)->info.size)
- #define HDRSIZE(iw) ((iw)->info.hdrSize)
- #define INDIRECT(iw) ((iw)->info.indirect)
- #define TAGTABLE(iw) ((iw)->info.tags)
- #define HISTORY(iw) ((iw)->info.history)
-
- /* misc */
- #define CURNODE(iw) HISTORY(iw)
-
- /* for search */
- #define START(iw) (DATA(iw))
- #define END(iw) (START(iw) + DATASIZE(iw))
- #define NSTART(iw, n) (START(iw) + (n)->start)
- #define NEND(iw, n) (NSTART(iw, n) + (n)->length)
- #define NSEARCH(iw, n, str) (search(iw,NSTART(iw,n),NEND(iw,n),str,False))
-
- /* for id's */
- #define I_NAME(i) ((i).tag.name)
- #define I_OFFSET(i) ((i).tag.offset)
- #define I_START(i) ((i).offset.start)
- #define I_LEN(i) ((i).offset.length)
-
- #endif /* _InfoP_h */
-