man.h revision 1abf7346
1/* $XConsortium: man.h,v 1.31 94/12/16 21:36:53 gildea Exp $ */ 2/* $XdotOrg: xc/programs/xman/man.h,v 1.6 2004/07/29 00:40:35 gisburn Exp $ */ 3/* 4 5Copyright (c) 1987, 1988 X Consortium 6 7Permission is hereby granted, free of charge, to any person obtaining 8a copy of this software and associated documentation files (the 9"Software"), to deal in the Software without restriction, including 10without limitation the rights to use, copy, modify, merge, publish, 11distribute, sublicense, and/or sell copies of the Software, and to 12permit persons to whom the Software is furnished to do so, subject to 13the following conditions: 14 15The above copyright notice and this permission notice shall be included 16in all copies or substantial portions of the Software. 17 18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR 22OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24OTHER DEALINGS IN THE SOFTWARE. 25 26Except as contained in this notice, the name of the X Consortium shall 27not be used in advertising or otherwise to promote the sale, use or 28other dealings in this Software without prior written authorization 29from the X Consortium. 30 31*/ 32/* $XFree86: xc/programs/xman/man.h,v 1.4 2001/07/25 15:05:27 dawes Exp $ */ 33 34 35/* X toolkit header files */ 36 37#include <X11/Intrinsic.h> 38#include <X11/StringDefs.h> 39#include <X11/Shell.h> 40 41#include <X11/Xaw/Cardinals.h> 42 43/* Std system and C header files */ 44 45#include <stdio.h> 46#include <limits.h> 47 48#include <X11/Xfuncs.h> 49#include <X11/Xos.h> 50 51/* X include files */ 52 53#include <X11/Xatom.h> 54 55/* Widget header files. */ 56 57#include <X11/Xaw/AsciiText.h> 58#include <X11/Xaw/SmeBSB.h> 59#include <X11/Xaw/Box.h> 60#include <X11/Xaw/Command.h> 61#include <X11/Xaw/Dialog.h> 62#include <X11/Xaw/Label.h> 63#include <X11/Xaw/List.h> 64#include <X11/Xaw/MenuButton.h> 65#include <X11/Xaw/SimpleMenu.h> 66#include <X11/Xaw/Paned.h> 67#include <X11/Xaw/Viewport.h> 68 69/* program specific header files. */ 70 71#include "ScrollByL.h" 72 73#include "version.h" 74#include "defs.h" 75 76/* Turn a NULL pointer string into an empty string */ 77#define NULLSTR(x) (((x)!=NULL)?(x):("")) 78 79#define Error(x) { printf x ; exit(EXIT_FAILURE); } 80#define Assertion(expr, msg) { if (!(expr)) { Error msg } } 81#ifdef DEBUG 82# define Log(x) { if(True) printf x; } 83#else 84# define Log(x) { if(False) printf x; } 85#endif /* DEBUG */ 86 87/* 88 * Assigning values here allows the user of Bitwise Or. 89 */ 90 91typedef struct _XmanFonts { 92 XFontStruct * directory; /* The font for the directory. */ 93} XmanFonts; 94 95typedef struct _XmanCursors { 96 Cursor top, /* The top Cursor, default for xman. */ 97 help, /* The top cursor for the help menu. */ 98 manpage, /* The cursor for the Manpage. */ 99 search_entry; /* The cursor for the text widget in the 100 search box.*/ 101 Pixel fg_color; /* foreground color of cursors. */ 102 Pixel bg_color; /* background color of cursors. */ 103} XmanCursors; 104 105typedef struct _ManPageWidgets { 106 Widget manpage, /* The manual page window (scrolled) */ 107 directory, /* The widget in which all directories will 108 appear. */ 109 *box; /* The boxes containing the sections. */ 110} ManPageWidgets; 111 112typedef struct _MenuStruct { 113 caddr_t data; 114 int number; 115 XrmQuark quark; 116} MenuStruct; 117 118/* 119 * The manual sections and entries 120 */ 121 122typedef struct tManual { 123 char * blabel; /* The button label. */ 124 char ** entries; /* The individual man page file names. */ 125 char ** entries_less_paths; /* Entry names only */ 126 int nentries; /* how many (TOTAL)*/ 127 int nalloc; /* how much space allocated */ 128 int flags; /* suffix, fold */ 129} Manual; 130 131/* psuedo Globals that are specific to each manpage created. */ 132 133typedef struct _ManpageGlobals{ 134 int current_directory; /* The directory currently being shown 135 on this manpage. */ 136 Boolean dir_shown, /* True if the directory is then current 137 visable screen */ 138 both_shown; /* If true then both the manpage and 139 the directory are to be shown.*/ 140 Widget label, /* The label widget at the top of the page. */ 141 standby, /* The please standby widget. */ 142 save, /* The "would you like to save?" widget. */ 143 search_widget, /* The search widget popup. */ 144 help_button, /* The help button. */ 145 option_menu, /* The option menu. */ 146 text_widget; /* text widget containing search string. */ 147 148 /* Widgets (Objects really) for the command menu entries. */ 149 150 Widget dir_entry, manpage_entry, help_entry, 151 search_entry, both_screens_entry, remove_entry, 152 open_entry, print_entry, version_entry, quit_entry; 153 154#ifdef INCLUDE_XPRINT_SUPPORT 155 /* Print objects and data */ 156 Widget printdialog_shell; /* Shell for the print dialog */ 157 Widget printdialog; /* Print dialog */ 158#endif /*INCLUDE_XPRINT_SUPPORT */ 159 /* Misc. */ 160 161 char manpage_title[80]; /* The label to use for the current manpage. */ 162 163 char save_file[80]; /* the name of the file to save fomatted 164 page into. */ 165 char tempfile[80]; /* the name of the file to copy the formatted 166 page from. */ 167 Boolean compress; /* Compress file on save? */ 168 Boolean gzip; /* Gzip file on save? */ 169 Boolean deletetempfile; /* Need to delete tempfile when done? */ 170 char ** section_name; /* The name of each of the sections */ 171 172 ManPageWidgets manpagewidgets; /* The manpage widgets. */ 173 174 /* Things to remember when cleaning up when killing manpage. */ 175 176 Widget This_Manpage; /* a pointer to the root of 177 this manpage. */ 178 179 FILE *curr_file; /* Current file shown in manpage widget */ 180} ManpageGlobals; 181 182 183/* Resource manager sets these. */ 184 185typedef struct _Xman_Resources { 186 XmanFonts fonts; /* The fonts used for the man pages. */ 187 XmanCursors cursors; /* The cursors for xman. */ 188 Boolean show_help_syntax; /* True if syntax message should be dumped to 189 stdout. */ 190 Boolean both_shown_initial; /* The initial state of the manual pages 191 show two screens or only one. */ 192 Boolean top_box_active; /* Put up the Top Box. */ 193 Boolean clear_search_string; /* clear the search string each time it 194 is popped down? */ 195 int directory_height; /* The default height of directory in 196 both_shown mode. */ 197 char * help_file; /* The name of the help file. */ 198 char * title; /* The title for topBox */ 199 Boolean iconic; /* Should topBox come up in an iconic state */ 200} Xman_Resources; 201 202/************************************************************ 203 * 204 * Function Defintions 205 * 206 ************************************************************/ 207 208/* 209 * This is easier than trying to find all calls to StrAlloc(). 210 */ 211 212#define StrAlloc(ptr) XtNewString(ptr) 213 214/* Standard library function definitions. */ 215#include <stdlib.h> 216 217/* buttons.c */ 218 219ManpageGlobals * InitPsuedoGlobals(void); 220Widget CreateManpage(FILE * file); 221void CreateManpageWidget(ManpageGlobals * man_globals, char * name, Boolean full_instance); 222void FormUpWidgets(Widget parent, char ** full_size, char ** half_size); 223void MakeDirectoryBox(ManpageGlobals *man_globals, Widget parent, Widget *dir_disp, int section); 224void MakeSaveWidgets(ManpageGlobals *man_globals, Widget parent); 225void MakeTopBox(void); 226 227/* handler.c */ 228 229void DirPopupCallback(Widget w, XtPointer pointer, XtPointer junk); 230void DirectoryHandler(Widget w, XtPointer global_pointer, XtPointer ret_val); 231void OptionCallback(Widget w, XtPointer pointer, XtPointer junk); 232void Popup(Widget w, XtGrabKind grab_kind); 233 234/* Action Routines. */ 235 236void CreateNewManpage(Widget w, XEvent * event, String * params, Cardinal * num_params); 237void GotoPage(Widget w, XEvent * event, String * params, Cardinal * num_params); 238void PopupHelp(Widget w, XEvent * event, String * params, Cardinal * num_params); 239void PopupSearch(Widget w, XEvent * event, String * params, Cardinal * num_params); 240void Quit(Widget w, XEvent * event, String * params, Cardinal * num_params); 241void RemoveThisManpage(Widget w, XEvent * event, String * params, Cardinal * num_params); 242void SaveFormattedPage(Widget w, XEvent * event, String * params, Cardinal * num_params); 243void Search(Widget w, XEvent * event, String * params, Cardinal * num_params); 244#ifdef INCLUDE_XPRINT_SUPPORT 245void PrintThisManpage(Widget w, XEvent * event, String * params, Cardinal * num_params); 246#endif /* INCLUDE_XPRINT_SUPPORT */ 247void ShowVersion(Widget w, XEvent * event, String * params, Cardinal * num_params); 248 249/* help.c */ 250 251Boolean MakeHelpWidget(void); 252Boolean OpenHelpfile(ManpageGlobals * man_globals); 253 254/* man.c */ 255Bool ReadManConfig(char manpath[]); 256int Man(void); 257 258/* misc.c */ 259FILE * FindManualFile(ManpageGlobals * man_globals, int section_num, int entry_num); 260ManpageGlobals * GetGlobals(Widget w); 261void AddCursor(Widget w, Cursor cursor); 262void ChangeLabel(Widget w, char * str); 263void OpenFile(ManpageGlobals * man_globals, FILE * file); 264void PopupWarning(ManpageGlobals * man_globals, char * string); 265void PositionCenter(Widget widget, int x, int y, int above, int left, int v_space, int h_space); 266void PrintError(char * string); 267void RemoveGlobals(Widget w); 268void SaveGlobals(Widget w, ManpageGlobals * globals); 269void ParseEntry(char *entry, char *path, char *sect, char *page); 270FILE * Format(ManpageGlobals * man_globals, char * entry); 271 272/* search */ 273FILE * DoSearch(ManpageGlobals * man_globals, int type); 274void MakeSearchWidget(ManpageGlobals * man_globals, Widget parent); 275 276/* tkfunctions.c */ 277 278int Width(Widget); 279int Height(Widget); 280int BorderWidth(Widget); 281char * Name(Widget); 282