xenocara/app/xman/man.h

293 lines
10 KiB
C
Raw Normal View History

2006-11-25 13:07:29 -07:00
/*
Copyright (c) 1987, 1988 X Consortium
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the X Consortium shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the X Consortium.
*/
2013-09-28 10:22:59 -06:00
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
2006-11-25 13:07:29 -07:00
/* X toolkit header files */
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xaw/Cardinals.h>
/* Std system and C header files */
#include <stdio.h>
#include <limits.h>
#include <X11/Xfuncs.h>
#include <X11/Xos.h>
/* X include files */
#include <X11/Xatom.h>
/* Widget header files. */
#include <X11/Xaw/AsciiText.h>
#include <X11/Xaw/SmeBSB.h>
#include <X11/Xaw/Box.h>
#include <X11/Xaw/Command.h>
#include <X11/Xaw/Dialog.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/List.h>
#include <X11/Xaw/MenuButton.h>
#include <X11/Xaw/SimpleMenu.h>
#include <X11/Xaw/Paned.h>
#include <X11/Xaw/Viewport.h>
/* program specific header files. */
#include "ScrollByL.h"
#include "defs.h"
#define Error(x) { printf x ; exit(EXIT_FAILURE); }
#define Assertion(expr, msg) { if (!(expr)) { Error msg } }
#ifdef DEBUG
# define Log(x) { if(True) printf x; }
#else
# define Log(x) { if(False) printf x; }
#endif /* DEBUG */
2013-09-28 10:22:59 -06:00
/*
2006-11-25 13:07:29 -07:00
* Assigning values here allows the user of Bitwise Or.
*/
typedef struct _XmanFonts {
2013-09-28 10:22:59 -06:00
XFontStruct *directory; /* The font for the directory. */
2006-11-25 13:07:29 -07:00
} XmanFonts;
typedef struct _XmanCursors {
2013-09-28 10:22:59 -06:00
Cursor top, /* The top Cursor, default for xman. */
help, /* The top cursor for the help menu. */
manpage, /* The cursor for the Manpage. */
search_entry; /* The cursor for the text widget in the
search box. */
Pixel fg_color; /* foreground color of cursors. */
Pixel bg_color; /* background color of cursors. */
2006-11-25 13:07:29 -07:00
} XmanCursors;
typedef struct _ManPageWidgets {
2013-09-28 10:22:59 -06:00
Widget manpage, /* The manual page window (scrolled) */
directory, /* The widget in which all directories will
appear. */
*box; /* The boxes containing the sections. */
2006-11-25 13:07:29 -07:00
} ManPageWidgets;
typedef struct _MenuStruct {
2013-09-28 10:22:59 -06:00
caddr_t data;
int number;
XrmQuark quark;
2006-11-25 13:07:29 -07:00
} MenuStruct;
/*
* The manual sections and entries
*/
typedef struct tManual {
2013-09-28 10:22:59 -06:00
char *blabel; /* The button label. */
char **entries; /* The individual man page file names. */
char **entries_less_paths; /* Entry names only */
int nentries; /* how many (TOTAL) */
int nalloc; /* how much space allocated */
int flags; /* suffix, fold */
2006-11-25 13:07:29 -07:00
} Manual;
2013-09-28 10:22:59 -06:00
/* pseudo Globals that are specific to each manpage created. */
typedef struct _ManpageGlobals {
int current_directory; /* The directory currently being shown
on this manpage. */
Boolean dir_shown, /* True if the directory is then current
visible screen */
both_shown; /* If true then both the manpage and
the directory are to be shown. */
Widget label, /* The label widget at the top of the page. */
standby, /* The please standby widget. */
save, /* The "would you like to save?" widget. */
search_widget, /* The search widget popup. */
help_button, /* The help button. */
option_menu, /* The option menu. */
text_widget; /* text widget containing search string. */
/* Widgets (Objects really) for the command menu entries. */
Widget dir_entry, manpage_entry, help_entry,
search_entry, both_screens_entry, remove_entry,
open_entry, print_entry, version_entry, quit_entry;
2006-11-25 13:07:29 -07:00
#ifdef INCLUDE_XPRINT_SUPPORT
2013-09-28 10:22:59 -06:00
/* Print objects and data */
Widget printdialog_shell; /* Shell for the print dialog */
Widget printdialog; /* Print dialog */
#endif /*INCLUDE_XPRINT_SUPPORT */
/* Misc. */
2006-11-25 13:07:29 -07:00
2013-09-28 10:22:59 -06:00
char manpage_title[80]; /* The label to use for the current manpage. */
2006-11-25 13:07:29 -07:00
2013-09-28 10:22:59 -06:00
char save_file[80]; /* the name of the file to save formatted
page into. */
char tempfile[80]; /* the name of the file to copy the formatted
page from. */
Boolean compress; /* Compress file on save? */
Boolean gzip; /* Gzip file on save? */
Boolean bzip2; /* Bzip2 file on save? */
Boolean lzma;
Boolean deletetempfile; /* Need to delete tempfile when done? */
char **section_name; /* The name of each of the sections */
2006-11-25 13:07:29 -07:00
2013-09-28 10:22:59 -06:00
ManPageWidgets manpagewidgets; /* The manpage widgets. */
2006-11-25 13:07:29 -07:00
2013-09-28 10:22:59 -06:00
/* Things to remember when cleaning up when killing manpage. */
2006-11-25 13:07:29 -07:00
2013-09-28 10:22:59 -06:00
Widget This_Manpage; /* a pointer to the root of
this manpage. */
2006-11-25 13:07:29 -07:00
2013-09-28 10:22:59 -06:00
FILE *curr_file; /* Current file shown in manpage widget */
2006-11-25 13:07:29 -07:00
} ManpageGlobals;
/* Resource manager sets these. */
typedef struct _Xman_Resources {
2013-09-28 10:22:59 -06:00
XmanFonts fonts; /* The fonts used for the man pages. */
XmanCursors cursors; /* The cursors for xman. */
Boolean show_help_syntax; /* True if syntax message should be dumped to
stdout. */
Boolean both_shown_initial; /* The initial state of the manual pages
show two screens or only one. */
Boolean top_box_active; /* Put up the Top Box. */
Boolean clear_search_string; /* clear the search string each time it
is popped down? */
int directory_height; /* The default height of directory in
both_shown mode. */
char *help_file; /* The name of the help file. */
char *title; /* The title for topBox */
Boolean iconic; /* Should topBox come up in an iconic state */
2006-11-25 13:07:29 -07:00
} Xman_Resources;
/************************************************************
*
2013-09-28 10:22:59 -06:00
* Function Definitions
*
2006-11-25 13:07:29 -07:00
************************************************************/
/* Standard library function definitions. */
#include <stdlib.h>
/* buttons.c */
2013-09-28 10:22:59 -06:00
ManpageGlobals *InitPsuedoGlobals(void);
2006-11-25 13:07:29 -07:00
Widget CreateManpage(FILE * file);
2013-09-28 10:22:59 -06:00
void CreateManpageWidget(ManpageGlobals * man_globals, char *name,
Boolean full_instance);
void FormUpWidgets(Widget parent,
const char **full_size, const char **half_size);
void MakeDirectoryBox(ManpageGlobals * man_globals, Widget parent,
Widget * dir_disp, int section);
void MakeSaveWidgets(ManpageGlobals * man_globals, Widget parent);
2006-11-25 13:07:29 -07:00
void MakeTopBox(void);
/* handler.c */
void DirPopupCallback(Widget w, XtPointer pointer, XtPointer junk);
void DirectoryHandler(Widget w, XtPointer global_pointer, XtPointer ret_val);
void OptionCallback(Widget w, XtPointer pointer, XtPointer junk);
void Popup(Widget w, XtGrabKind grab_kind);
/* Action Routines. */
2013-09-28 10:22:59 -06:00
void CreateNewManpage(Widget w, XEvent * event, String * params,
Cardinal * num_params);
2006-11-25 13:07:29 -07:00
void GotoPage(Widget w, XEvent * event, String * params, Cardinal * num_params);
2013-09-28 10:22:59 -06:00
void PopupHelp(Widget w, XEvent * event, String * params,
Cardinal * num_params);
void PopupSearch(Widget w, XEvent * event, String * params,
Cardinal * num_params);
2006-11-25 13:07:29 -07:00
void Quit(Widget w, XEvent * event, String * params, Cardinal * num_params);
2013-09-28 10:22:59 -06:00
void RemoveThisManpage(Widget w, XEvent * event, String * params,
Cardinal * num_params);
void SaveFormattedPage(Widget w, XEvent * event, String * params,
Cardinal * num_params);
2006-11-25 13:07:29 -07:00
void Search(Widget w, XEvent * event, String * params, Cardinal * num_params);
2013-09-28 10:22:59 -06:00
2006-11-25 13:07:29 -07:00
#ifdef INCLUDE_XPRINT_SUPPORT
2013-09-28 10:22:59 -06:00
void PrintThisManpage(Widget w, XEvent * event, String * params,
Cardinal * num_params);
2006-11-25 13:07:29 -07:00
#endif /* INCLUDE_XPRINT_SUPPORT */
2013-09-28 10:22:59 -06:00
void ShowVersion(Widget w, XEvent * event, String * params,
Cardinal * num_params);
2006-11-25 13:07:29 -07:00
/* help.c */
Boolean MakeHelpWidget(void);
Boolean OpenHelpfile(ManpageGlobals * man_globals);
/* man.c */
Bool ReadManConfig(char manpath[]);
int Man(void);
/* misc.c */
2013-09-28 10:22:59 -06:00
#ifndef HAVE_MKSTEMP
_X_HIDDEN int Xmkstemp (char *template);
# define mkstemp Xmkstemp
#endif
FILE *FindManualFile(ManpageGlobals * man_globals, int section_num,
int entry_num);
ManpageGlobals *GetGlobals(Widget w);
2006-11-25 13:07:29 -07:00
void AddCursor(Widget w, Cursor cursor);
2013-09-28 10:22:59 -06:00
void ChangeLabel(Widget w, const char *str);
2006-11-25 13:07:29 -07:00
void OpenFile(ManpageGlobals * man_globals, FILE * file);
2013-09-28 10:22:59 -06:00
void PopupWarning(ManpageGlobals * man_globals, const char *string);
void PositionCenter(Widget widget, int x, int y, int above, int left,
int v_space, int h_space);
void PrintError(const char *string) _X_NORETURN;
2006-11-25 13:07:29 -07:00
void RemoveGlobals(Widget w);
void SaveGlobals(Widget w, ManpageGlobals * globals);
2013-09-28 10:22:59 -06:00
void ParseEntry(const char *entry, char *path, char *sect, char *page);
FILE *Format(ManpageGlobals * man_globals, const char *entry);
2006-11-25 13:07:29 -07:00
/* search */
2013-09-28 10:22:59 -06:00
FILE *DoSearch(ManpageGlobals * man_globals, int type);
2006-11-25 13:07:29 -07:00
void MakeSearchWidget(ManpageGlobals * man_globals, Widget parent);
/* tkfunctions.c */
int Width(Widget);
int Height(Widget);
int BorderWidth(Widget);
2013-09-28 10:22:59 -06:00
char *Name(Widget);