193139Sru/* doc.h -- Structures associating function pointers with documentation. 2146515Sru $Id: doc.h,v 1.3 2004/04/11 17:56:45 karl Exp $ 321495Sjmacd 4146515Sru Copyright (C) 1993, 2001, 2004 Free Software Foundation, Inc. 521495Sjmacd 621495Sjmacd This program is free software; you can redistribute it and/or modify 721495Sjmacd it under the terms of the GNU General Public License as published by 821495Sjmacd the Free Software Foundation; either version 2, or (at your option) 921495Sjmacd any later version. 1021495Sjmacd 1121495Sjmacd This program is distributed in the hope that it will be useful, 1221495Sjmacd but WITHOUT ANY WARRANTY; without even the implied warranty of 1321495Sjmacd MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1421495Sjmacd GNU General Public License for more details. 1521495Sjmacd 1621495Sjmacd You should have received a copy of the GNU General Public License 1721495Sjmacd along with this program; if not, write to the Free Software 1821495Sjmacd Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 1921495Sjmacd 2021495Sjmacd Written by Brian Fox (bfox@ai.mit.edu). */ 2121495Sjmacd 2242660Smarkm#if !defined (DOC_H) 2342660Smarkm#define DOC_H 2421495Sjmacd 2542660Smarkm#include "info.h" /* for NAMED_FUNCTIONS, VFunction, etc. */ 2621495Sjmacd 2793139Sru#if defined (INFOKEY) 2893139Sru/* For each function, we keep track of the first defined key sequence 2993139Sru which invokes that function, for each different map. This is so that 3093139Sru the dynamic documentation generation in infodoc.c (a) doesn't have to 3193139Sru search through copious KEYMAP_ENTRYs, and, more importantly, (b) the 3293139Sru user and programmer can choose the preferred key sequence that is 3393139Sru printed for any given function -- it's just the first one that 3493139Sru appears in the user's infokey file or the default keymaps in 3593139Sru infomap.c. 3693139Sru 3793139Sru Each FUNCTION_DOC has a linked list of FUNCTION_KEYSEQ structs 3893139Sru hanging off it, which are created on startup when the user and/or 3993139Sru default keymaps are being parsed. */ 4093139Srutypedef struct function_keyseq 4193139Sru{ 4293139Sru struct function_keyseq *next; 4393139Sru struct keymap_entry *map; 4493139Sru char *keyseq; 4593139Sru} FUNCTION_KEYSEQ; 4693139Sru 4793139Sru#endif /* INFOKEY */ 4893139Sru 4993139Sru 5093139Sru/* An array of FUNCTION_DOC structures is defined in doc.c, which is 5193139Sru automagically generated by the makedoc utility, whose job is to scan 5293139Sru through the source files for command function declarations and 5393139Sru compile a list of all the ones it finds. This saves tedious 5493139Sru housekeeping and avoids errors of omission. */ 5593139Srutypedef struct 5693139Sru{ 5721495Sjmacd VFunction *func; 5821495Sjmacd#if defined (NAMED_FUNCTIONS) 5921495Sjmacd char *func_name; 6021495Sjmacd#endif /* NAMED_FUNCTIONS */ 6193139Sru#if defined (INFOKEY) 6293139Sru FUNCTION_KEYSEQ *keys; 6393139Sru#endif /* INFOKEY */ 6493139Sru char *doc; 6521495Sjmacd} FUNCTION_DOC; 6621495Sjmacd 6721495Sjmacdextern FUNCTION_DOC function_doc_array[]; 6821495Sjmacd 6993139Sru/* Under the old key-binding system, an info command is specified by 7093139Sru the pointer to its function. Under the new INFOKEY binding system, 7193139Sru it is specified by a pointer to the command's FUNCTION_DOC structure, 7293139Sru defined in doc.c, from which the pointer to the function can be 7393139Sru easily divined using the InfoFunction() extractor. */ 7493139Sru#if defined(INFOKEY) 7593139Srutypedef FUNCTION_DOC InfoCommand; 76146515Sru/* The cast to VFunction * prevents pgcc from complaining about 77146515Sru dereferencing a void *. */ 78146515Sru#define InfoFunction(ic) ((ic) ? (ic)->func : (VFunction *) NULL) 7993139Sru#define InfoCmd(fn) (&function_doc_array[A_##fn]) 8093139Sru#define DocInfoCmd(fd) ((fd) && (fd)->func ? (fd) : NULL) 8193139Sru#else /* !INFOKEY */ 8293139Srutypedef VFunction InfoCommand; 8393139Sru#define InfoFunction(vf) ((vf)) 8493139Sru#define InfoCmd(fn) fn 8593139Sru#define DocInfoCmd(fd) ((fd)->func) 8693139Sru#endif /* !INFOKEY */ 8793139Sru 88146515Sru#include "infomap.h" /* for Keymap. */ 89146515Sru 9021495Sjmacd#if defined (NAMED_FUNCTIONS) 91146515Sruextern char *function_name (InfoCommand *cmd); 92146515Sruextern InfoCommand *named_function (char *name); 9321495Sjmacd#endif /* NAMED_FUNCTIONS */ 94146515Sru 95146515Sruextern char *function_documentation (InfoCommand *cmd); 96146515Sruextern char *key_documentation (char key, Keymap map); 97146515Sruextern char *pretty_keyname (unsigned char key); 98146515Sruextern char *pretty_keyseq (char *keyseq); 99146515Sruextern char *where_is (Keymap map, InfoCommand *cmd); 100146515Sruextern char *replace_in_documentation (char *string, int help_is_only_window_p); 101146515Sruextern void dump_map_to_message_buffer (char *prefix, Keymap map); 102146515Sru 10342660Smarkm#endif /* !DOC_H */ 104