home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume2 / xbrowser / part03 / xfilebrowser.h < prev   
Encoding:
C/C++ Source or Header  |  1989-01-03  |  5.5 KB  |  191 lines

  1. /*
  2.  * Systems Sciences Laboratory, Webster Research Center
  3.  *
  4.  * Copyright (c) 1988 Xerox Corporation.  All rights reserved.
  5.  *
  6.  * Copyright protection claimed includes all forms and matters of copyrightable
  7.  * material and information now allowed by statutory or judicial lay or
  8.  * herinafter granted, including without limitation, material generated from
  9.  * the software programs which are displayed on the screen such as icons,
  10.  * screen display looks, etc.
  11.  */
  12.  
  13.  
  14. #include <stdio.h>
  15. #include <sys/types.h>
  16. #include <sys/dir.h>
  17. #include <sys/stat.h>
  18.  
  19. #include <X11/Xlib.h>
  20. #include <X11/IntrinsicP.h>
  21.  
  22. #include <X11/cursorfont.h>
  23. #include <X11/Box.h>
  24. #include <X11/Label.h>
  25. #include <X11/StringDefs.h>
  26. #include <X11/Command.h>
  27. #include <X11/VPaned.h>
  28. #include <X11/Viewport.h>
  29. #include <X11/AsciiTextP.h>
  30. #include <X11/Shell.h>
  31. #include <X11/Dialog.h>
  32. #include "toggle.h"
  33. #include "option.h"
  34.  
  35.  
  36.  
  37.  
  38. #define max(a,b) (((a) > (b)) ? (a) : (b))
  39. #define min(a,b) (((a) < (b)) ? (a) : (b))
  40.  
  41. #define Feep()            XBell(curdisplay, 20)
  42.  
  43. #define MakeArg(n, v){      args[numargs].name = n;     \
  44.                     args[numargs].value = v;    \
  45.                     numargs++;             \
  46.               }
  47. #define MAXNAME 255
  48.  
  49.  
  50. /* data structures */
  51. typedef struct _lineelement {
  52.     XtTextPosition pa;    /* specifies start position of line */
  53.     XtTextPosition pe;    /* specifies end position of line */
  54.     int linenumber;        /* line number in text file */
  55.     struct _lineelement *next;
  56. } LineElement;
  57.  
  58. typedef struct _searchelement {
  59.     XtTextPosition pos1;    /* specifies start position in widget */
  60.     XtTextPosition pos2;    /* specifies end position in widget */
  61.     LineElement *lines;    /* list of linenumbers */
  62.     char name[MAXNAME + 1];    /* file name */
  63. } SearchElement;
  64.  
  65. struct afile {
  66.     u_short d_marked;    /* file marked for deletion */
  67.     char    d_type;        /* file type, e.g. 'd', 'c', 'f' */
  68.       u_short d_nl;        /* number of links */
  69.       u_short d_uid;        /* owner id */
  70.       u_short d_gid;        /* group id */
  71.       u_short d_nlink;        /* number of hard links */
  72.       char    d_access[12];    /* access rights */
  73.       u_long  d_size;        /* file size */
  74.       u_long  d_ctime;        /* last modification time */
  75.     XtTextPosition d_pos1;    /* start position of display */
  76.     XtTextPosition d_pos2;    /* end position of display */    
  77.       u_long  d_ino;        /* inode number of entry */
  78.       u_short d_reclen;    /* length of this record */
  79.       u_short d_namlen;    /* length of string in d_name */
  80.       char    d_name[MAXNAME + 1];    /* name must be no longer than this */
  81. };
  82.  
  83. typedef struct _dialogdata {
  84.     Widget w;    /* widget which requested dialog */
  85.     int start;    /* index to first selected file in files[] */
  86.     int end;    /* index to last selected file in files[] */
  87.     int current;    /* index to currently handled file in files[] */
  88.     char *answer;    /* dialog provided by user */
  89.     Boolean diag;    /* save standard diagnostics */
  90.     Boolean out;    /* save standard output */
  91.     int (*yes)();    /* yes function */
  92.     int (*no)();    /* no function */
  93.     int (*cancel)();    /* cancel function */
  94. } DialogData;
  95.  
  96. /*
  97.  * The DIRSIZ macro gives the minimum record length which will hold
  98.  * the directory entry.  This requires the amount of space in struct direct
  99.  * without the d_name field, plus enough space for the name with a terminating
  100.  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  101.  */
  102.  
  103. #define MYDIRSIZ(dp, length) \
  104.     ((sizeof (struct afile) - (MAXNAME+1)) + \
  105.         (((dp)->d_namlen+1 + 3 + length) &~ 3))
  106.  
  107.  
  108. /*    misc externs     */
  109. extern char *XtMalloc();
  110. extern char *XtRealloc();
  111. extern char *XtCalloc();
  112. extern char *index();
  113. extern char *rindex();
  114. extern char *getcwd();
  115.  
  116.  
  117. /*    externs in xfilebrowser.c    */
  118. extern char *filepattern;
  119. extern char *searchpattern;
  120. extern char *curdirectory;
  121. extern char *oldpattern;
  122. extern char *cmdline;
  123. extern int viewEdit;
  124.  
  125. extern struct afile **files;
  126. extern int numfiles;
  127. extern SearchElement **hitfiles;
  128. extern int numhitfiles;
  129. extern int allowedit;
  130.  
  131. extern Widget toplevel;
  132. extern Widget outer;
  133. extern Widget messwidget;
  134. extern Widget listwidget;
  135. extern Widget dirwidget;
  136. extern Widget fpatwindow;
  137. extern Widget grepwidget;
  138.  
  139. Widget quitbutton;    /* command button for quit */
  140. Widget listbutton;    /* command button for list */
  141. Widget editbutton;    /* command button for edit file selected
  142.             in directory listing */
  143. Widget parentdirbutton;    /* command button for selecting
  144.                 parent directory */
  145. Widget shellbutton;    /* command button for invoking shell */
  146. Widget copybutton;    /* command button for invoking copy */
  147. Widget renamebutton;    /* command button for invoking rename */
  148. Widget deletebutton;    /* command button for invoking delete on files */
  149.  
  150. Widget grepbutton;    /* command button for invoking grep on files */
  151. Widget grepwindow;    /* string box to specify the grep search pattern */
  152. Widget grepeditbutton;    /* command button for edit file selected
  153.             in list of searched files */
  154.  
  155. extern Display *curdisplay;
  156. extern XtTextSource messsource, listsource, grepsource;
  157.  
  158. /*    externals in util.c     */
  159. extern Widget makeCommandButton();
  160. extern Widget makeBooleanButton();
  161. extern Widget makeStringBox();
  162. extern int select_file();
  163. extern char *expand_tilde();
  164.  
  165. /*    externs in commands.c     */
  166. extern DoQuit();
  167. extern DoList();
  168. extern DoEdit();
  169. extern DoGrep();
  170. extern DoChangeDir();
  171. extern DoShell();
  172. extern DoParent();
  173. extern DoGrepEdit();
  174. extern DoCopy();
  175. extern DoRename();
  176. extern DoDelete();
  177.  
  178. /*    externs in ap.c     */
  179. extern XtTextSource TCreateApAsSource();
  180.  
  181. /*    externs in popup.c     */
  182. extern int create_confirm();
  183. extern int confirm_prompt();
  184. extern int check_confirm();
  185. extern int check_prompt();
  186.  
  187. /*    externs in scandir.c    */
  188. extern int check_option();
  189. extern int currentid;
  190.  
  191.