Back to index

tetex-bin  3.0
doc.h
Go to the documentation of this file.
00001 /* doc.h -- Structures associating function pointers with documentation.
00002    $Id: doc.h,v 1.3 2004/04/11 17:56:45 karl Exp $
00003 
00004    Copyright (C) 1993, 2001, 2004 Free Software Foundation, Inc.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2, or (at your option)
00009    any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 
00020    Written by Brian Fox (bfox@ai.mit.edu). */
00021 
00022 #if !defined (DOC_H)
00023 #define DOC_H
00024 
00025 #include "info.h" /* for NAMED_FUNCTIONS, VFunction, etc.  */
00026 
00027 #if defined (INFOKEY)
00028 /* For each function, we keep track of the first defined key sequence
00029    which invokes that function, for each different map.  This is so that
00030    the dynamic documentation generation in infodoc.c (a) doesn't have to
00031    search through copious KEYMAP_ENTRYs, and, more importantly, (b) the
00032    user and programmer can choose the preferred key sequence that is
00033    printed for any given function -- it's just the first one that
00034    appears in the user's infokey file or the default keymaps in
00035    infomap.c.
00036 
00037    Each FUNCTION_DOC has a linked list of FUNCTION_KEYSEQ structs
00038    hanging off it, which are created on startup when the user and/or
00039    default keymaps are being parsed.  */
00040 typedef struct function_keyseq
00041 {
00042   struct function_keyseq *next;
00043   struct keymap_entry *map;
00044   char *keyseq;
00045 } FUNCTION_KEYSEQ;
00046 
00047 #endif /* INFOKEY */
00048 
00049 
00050 /* An array of FUNCTION_DOC structures is defined in doc.c, which is
00051    automagically generated by the makedoc utility, whose job is to scan
00052    through the source files for command function declarations and
00053    compile a list of all the ones it finds.  This saves tedious
00054    housekeeping and avoids errors of omission.  */
00055 typedef struct
00056 {
00057   VFunction *func;
00058 #if defined (NAMED_FUNCTIONS)
00059   char *func_name;
00060 #endif /* NAMED_FUNCTIONS */
00061 #if defined (INFOKEY)
00062   FUNCTION_KEYSEQ *keys;
00063 #endif /* INFOKEY */
00064    char *doc;
00065 } FUNCTION_DOC;
00066 
00067 extern FUNCTION_DOC function_doc_array[];
00068 
00069 /* Under the old key-binding system, an info command is specified by
00070    the pointer to its function.  Under the new INFOKEY binding system, 
00071    it is specified by a pointer to the command's FUNCTION_DOC structure,
00072    defined in doc.c, from which the pointer to the function can be
00073    easily divined using the InfoFunction() extractor.  */
00074 #if defined(INFOKEY)
00075 typedef FUNCTION_DOC InfoCommand;
00076 /* The cast to VFunction * prevents pgcc from complaining about
00077    dereferencing a void *.  */
00078 #define InfoFunction(ic) ((ic) ? (ic)->func : (VFunction *) NULL)
00079 #define InfoCmd(fn) (&function_doc_array[A_##fn])
00080 #define DocInfoCmd(fd) ((fd) && (fd)->func ? (fd) : NULL)
00081 #else /* !INFOKEY */
00082 typedef VFunction InfoCommand;
00083 #define InfoFunction(vf) ((vf))
00084 #define InfoCmd(fn) fn
00085 #define DocInfoCmd(fd) ((fd)->func)
00086 #endif /* !INFOKEY */
00087 
00088 #include "infomap.h" /* for Keymap.  */
00089 
00090 #if defined (NAMED_FUNCTIONS)
00091 extern char *function_name (InfoCommand *cmd);
00092 extern InfoCommand *named_function (char *name);
00093 #endif /* NAMED_FUNCTIONS */
00094 
00095 extern char *function_documentation (InfoCommand *cmd);
00096 extern char *key_documentation (char key, Keymap map);
00097 extern char *pretty_keyname (unsigned char key);
00098 extern char *pretty_keyseq (char *keyseq);
00099 extern char *where_is (Keymap map, InfoCommand *cmd);
00100 extern char *replace_in_documentation (char *string, int help_is_only_window_p);
00101 extern void dump_map_to_message_buffer (char *prefix, Keymap map);
00102 
00103 #endif /* !DOC_H */