home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume16 / pan / part05 < prev    next >
Encoding:
Text File  |  1992-03-06  |  31.3 KB  |  1,027 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!think.com!mips!msi!dcmartin
  3. From: jeff@rd1.interlan.com (Jeff Bailey)
  4. Subject: v16i141: pan - Post A Note (for Open Windows), Part05/06
  5. Message-ID: <1992Mar6.200408.8349@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-16i137-pan@uunet.UU.NET>
  10. Date: Fri, 6 Mar 1992 20:04:08 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: jeff@rd1.interlan.com (Jeff Bailey)
  14. Posting-number: Volume 16, Issue 141
  15. Archive-name: pan/part05
  16.  
  17.  
  18. ---- Cut Here and feed the following to sh ----
  19. #!/bin/sh
  20. # This is part 05 of a multipart archive
  21. # ============= pan.man ==============
  22. if test -f 'pan.man' -a X"$1" != X"-c"; then
  23.     echo 'x - skipping pan.man (File already exists)'
  24. else
  25. echo 'x - extracting pan.man (Text)'
  26. sed 's/^X//' << 'SHAR_EOF' > 'pan.man' &&
  27. .TH pan l "January 17, 1991"
  28. .SH NAME
  29. pan \- Post A Note Open Look program
  30. .SH SYNTAX
  31. \fBpan\fP [args...]
  32. .SH DESCRIPTION
  33. The \fBpan\fP program keeps track of multiple text notes.  Each note
  34. has its own window and associated attributes.  The position, size, and
  35. visibility of each note is maintained across invocations along with the
  36. note text.
  37. .LP
  38. A note may be in one of three states: Visible, Hidden, or Veiled.
  39. A visible note has a window mapped to the display.  A hidden note is not
  40. mapped to the display.  A veiled note is a note which has been dismissed
  41. via the window manager's window menu.  It is not mapped, but the permanent
  42. state is still "Visible".  This feature allows a note to be unmapped, but
  43. made visible automatically upon the next invocation of \fBpan\fP.  A veiled
  44. note may be exposed just like a hidden note.
  45. .LP
  46. The \fBpan\fP program accepts all standard Open Look command line arguments.
  47. .LP
  48. In addition, \fBpan\fP accepts the following command line arguments:
  49. .LP
  50. \fB-d<directory>\fP
  51. .RS
  52. Set the initial pan directory.  This overrides the X resource
  53. \fBinitialDirectory\fP.
  54. .RE
  55. .LP
  56. All notes are automatically saved to disk when the pointer moves outside
  57. of the note window, or upon loss of the keyboard focus.  Note that saving
  58. to disk is only done if changes have been made.
  59. .LP
  60. The \fBpan\fP program has one base window from which many functions may be
  61. accessed.  Each note consists of a separate window which may or may not be
  62. mapped to the display.  The base window has the following buttons:
  63. .LP
  64. \fBNew Note\fP
  65. .RS
  66. Clicking on this button with mouse button 1 causes a new blank note to
  67. be created and made visible.  This new note is created in the default folder.
  68. .LP
  69. Clicking on this button and holding with mouse button 3 will bring up a menu
  70. of folders in which a new note may be created.
  71. .RE
  72. .LP
  73. \fBHide Notes\fP
  74. .RS
  75. Clicking on this button causes all visible notes to be unmapped from the 
  76. display.
  77. .RE
  78. .LP
  79. \fBExpose Notes\fP
  80. .RS
  81. This button has a menu attached to it.  Clicking with mouse button 1
  82. selects the default action.  Pressing mouse button 3 brings up
  83. a menu.  The menu items are:
  84. .LP
  85. \fBAll\fP
  86. .RS
  87. Expose (make visible) all notes.  This is the default action.
  88. .RE
  89. .LP
  90. \fB<Folders>\fP
  91. .RS
  92. An additional entry for each folder is displayed.  By moving the pointer right,
  93. a menu of all hidden notes in that folder is displayed.  The first entry is
  94. the item "All".  Selecting this will expose all notes in the folder.  The
  95. remaining items are individual notes within the folder.
  96. .RE
  97. .RE
  98. .LP
  99. \fBAction\fP
  100. .RS
  101. This button has a menu attached to it.  Clicking with mouse button 1
  102. selects the default action.  Pressing mouse button 3 brings up
  103. a menu.  The menu items are:
  104. .LP
  105. \fBQuit\fB
  106. .RS
  107. Cause \fBpan\fP to exit.  This is the default action.
  108. .RE
  109. .LP
  110. \fBCreate Folder\fP
  111. .RS
  112. Selecting this menu item brings up another window that allows a folder
  113. name to be entered.  When this is done, \fBpan\fP will create a new
  114. folder.
  115. .RE
  116. .LP
  117. \fBMove Note\fP
  118. .RS
  119. This menu item will bring up a window with 3 lists.  The first list is the
  120. folder \fBfrom\fP which to move notes.  The second list is the folder
  121. \fBto\fP which notes will be moved.  The third list is the list of notes
  122. in the source folder.  Select the appropriate source and destination folders,
  123. then select the note or notes to be moved and click on the "Apply" button.  The
  124. selected notes will be moved to the destination folder.
  125. .RE
  126. .LP
  127. \fBPrint Note\fP
  128. .RS
  129. This menu item will bring up a menu of all folders, similar to the \fBExpose\fP
  130. menu.  
  131. Sliding the pointer to the right while holding
  132. mouse button 3 down reveals a list of all notes in the selected folder.
  133. Highlight the one
  134. to be printed and release the mouse button to cause the note to be printed.
  135. .RE
  136. .LP
  137. \fBDestroy Folder\fP
  138. .RS
  139. This menu item will pop up a window with a list of all available folders.
  140. Selecting a folder and then clicking the "Apply" button will cause all
  141. notes in that folder to be destroyed.  The folder itself will then be
  142. destroyed.  \fIThis is an extremely destructive function and should be
  143. used with great care.\fP
  144. .RE
  145. .RE
  146. .LP
  147. \fBSearch:\fP
  148. .RS
  149. This is a text entry field.  It can be used to enter a regular expression.
  150. Upon pressing the \fIreturn\fP key, \fBpan\fP will search for a note with
  151. a title matching the RE and expose it if there is a single match.  If more
  152. than one note matches, a list window will be displayed allowing multiple
  153. selections of notes to expose.
  154. .RE
  155. .SH NOTE WINDOWS
  156. Each note window contains the following items:
  157. .LP
  158. \fBTitle\fP
  159. .RS
  160. This is a scrolling text entry item.  A note title may be entered here.  \fBThe
  161. title does not become active until the return key is pressed.\fP
  162. .RE
  163. .LP
  164. \fBHide\fP
  165. .RS
  166. Clicking on this button will cause this note to be hidden.
  167. .RE
  168. .LP
  169. \fBDestroy\fP
  170. .RS
  171. Clicking on this button will cause this note to be destroyed.  There is
  172. no way to recover a note after this action is taken.
  173. .RE
  174. .SH RESOURCES
  175. The \fBpan\fP program will query the X server for resource information.
  176. The following items of information are examined by \fBpan\fP:
  177. .LP
  178. \fBpan.initialDirectory\fP
  179. .RS
  180. This resource may be defined with a directory name.  \fBPan\fP will read
  181. this directory for notes upon startup instead of reading the default directory.
  182. Note that the \fB-d\fP command line argument can override this.
  183. .LP
  184. The current default directory is "$HOME/.pan".  It will be created 
  185. automatically by \fBpan\fP if necessary.  Note that a directory other than the
  186. default will \fBnot\fP be automatically created.
  187. .RE
  188. .LP
  189. \fBpan.printCommand\fP
  190. .RS
  191. This resource may be defined to be a command that will cause a note to
  192. be printed.
  193. .LP
  194. The current default command is "/usr/ucb/lpr $FILE".  Another command, including
  195. flags may be substituted.  Two special variables are available:  $FILE, and 
  196. $NOTETITLE.  The first will contain the full path and file name of the note
  197. selected to be printed.  The second will contain the full title of the note
  198. selected to be printed.  If a postscript printer is available, a nicely
  199. formatted printout may be obtained by using 'mp -o -s "$NOTETITLE" $FILE | lpr'.
  200. .RE
  201. .LP
  202. \fBpan.confirmDestroy\fP
  203. .RS
  204. This resource controls whether \fBpan\fP will display a confirmation notice
  205. when the destroy button on a note is selected.  This is a boolean resource.
  206. .LP
  207. The default value is False.
  208. .RE
  209. .LP
  210. \fBpan.noticeBeep\fP
  211. .RS
  212. This resource controls whether notices displayed by \fBpan\fP will be 
  213. accompanied by an audible beep.  It is a boolean resource.
  214. .LP
  215. The current default is True.
  216. .RE
  217. .LP
  218. \fBpan.iconTransparent\fP
  219. .RS
  220. This resource controls whether or not the icons used by \fBpan\fP have
  221. a transparent background.  This is a boolean resource.
  222. .LP
  223. The default value is False.
  224. .RE
  225. .LP
  226. \fBpan.folderOrder\fP
  227. .RS
  228. This is a string resource.  It consists of a comma separated list of folder
  229. names.  This resource allows the order in which folders appear in the menus
  230. to be specified.  Any folders not explicitly mentioned are added to the
  231. end of the list in the order in which they are encountered when reading
  232. the directory.
  233. .LP
  234. The default value is "Miscellaneous".
  235. .RE
  236. .LP
  237. \fBpan.defaultSearch\fP
  238. .RS
  239. This resource allows the specification of a default search string to appear
  240. in the "Search:" field in the base window.
  241. .LP
  242. The default value is "".
  243. .RE
  244. .SH NOTES
  245. The \fBpan\fP program will accept drag and drop files from the Open Look
  246. file manager.  The full path name of the file or directory will be inserted
  247. into the note (the file's contents will \fBnot\fP be loaded).  For
  248. this feature to work, the file icon must be dropped directly into the text
  249. subwindow of the note.  Dropping the icon anywhere else will not have
  250. any effect.  This feature is provided to allow a path name to be easily
  251. generated from the file manager.  It may then be highlighted, copied, and
  252. pasted into any application window that supports Open Look style selection
  253. operations.
  254. .LP
  255. If the note file directories are examined, occasionally files with names
  256. ending in a "%" character will be seen.  These files are created automatically
  257. by the Open Look text subwindow package, and are simply old versions of the
  258. note files being edited.
  259. .SH WINDOW CLASS
  260. \fBPan\fP supports three different window classes for use with window manager
  261. properties such as minimal decor.  The first is "PanMain".  This is the class
  262. for the main window.  The second is "PanNote".  This is the class for all
  263. notes.  The third is "Pan" (assuming the executable name is not changed).
  264. This is used for all pop up windows, such as the create folder window.
  265. Note that the third class, "Pan", is only set under Open Windows V3.0.
  266. .SH FILES
  267. Default note directory:
  268. .RS
  269. $HOME/.pan
  270. .RE
  271. .LP
  272. Note files:
  273. .RS
  274. Note_%d_%d
  275. .br
  276. Note_%d_%d.info
  277. .LP
  278. where the "%d" instances are replaced by unique id numbers.
  279. .RE
  280. .SH FILE FORMAT
  281. The "Note_%d_%d" file is a plain ASCII file containing the note text.  Lines
  282. are delimited by the newline character.
  283. .LP
  284. The "Note_%d_%d.info" file is a plain ASCII file currently containing 3 lines.
  285. .LP
  286. The first line contains 4 whitespace separated numbers followed by a
  287. text word.  The 4 numbers describe the note window's start x, start y,
  288. width, and height.  The text word is either "VISIBLE" or "HIDDEN" describing
  289. whether the note is mapped to the display by default or not.
  290. .LP
  291. The second line of the file contains the note title.
  292. .LP
  293. The third line is an ASCII representation of the decimal number returned 
  294. by time(3) describing the note's creation date and time.
  295. .LP
  296. An example might be:
  297. .nf
  298. X
  299. 4    424    349    206    HIDDEN
  300. Note title
  301. 664129826
  302. X
  303. .fi
  304. .SH BUGS
  305. When \fBpan\fP is compiled and run under Open Windows V3.0, the drag and
  306. drop feature \fBloads\fP the file into the note.
  307. .LP
  308. Occasionally, when a new note is created, the focus is initially in the text
  309. sub-window instead of in the title panel item.
  310. .LP
  311. The text sub-window package in xview creates files ending with a "%" character
  312. and doesn't delete them.  Periodically it is a good idea to remove them by
  313. hand to recover disk space.
  314. .SH AUTHOR
  315. Jeffrey Bailey
  316. SHAR_EOF
  317. chmod 0644 pan.man ||
  318. echo 'restore of pan.man failed'
  319. Wc_c="`wc -c < 'pan.man'`"
  320. test 10032 -eq "$Wc_c" ||
  321.     echo 'pan.man: original size 10032, current size' "$Wc_c"
  322. fi
  323. # ============= parser.c ==============
  324. if test -f 'parser.c' -a X"$1" != X"-c"; then
  325.     echo 'x - skipping parser.c (File already exists)'
  326. else
  327. echo 'x - extracting parser.c (Text)'
  328. sed 's/^X//' << 'SHAR_EOF' > 'parser.c' &&
  329. /*
  330. Post A Note V2.4
  331. Copyright (c) 1992, Jeffrey W. Bailey
  332. All rights reserved.
  333. X
  334. Permission is granted to distribute this program in exact, complete
  335. source form, which includes this copyright notice, as long as no fee
  336. other than media and distribution cost is charged.
  337. X
  338. This program may not be used in whole, or in part, in any other manner
  339. without prior written permission from the author.
  340. X
  341. This program may not be distributed in modified form without prior
  342. written permission from the author.  In other words, patches may be
  343. distributed, but modified source may not be distributed.
  344. X
  345. If there are any questions, comments or suggestions, the author may be
  346. contacted at:
  347. X
  348. X    jeff@rd1.interlan.com
  349. X
  350. X    or
  351. X
  352. X    Jeffrey Bailey
  353. X    Racal-Datacom, Inc.
  354. X    Mail Stop E-110
  355. X    1601 N. Harrison Parkway
  356. X    Sunrise, FL  33323-2899
  357. */
  358. X
  359. #include <stdio.h>
  360. #include <ctype.h>
  361. X
  362. extern char *malloc();
  363. static char *instr();
  364. X
  365. /*
  366. X    Component structure for each token on the linked list.
  367. */
  368. struct ps_component
  369. X    {
  370. X    struct ps_component *ps_prev; /* Pointer to previous node */
  371. X    struct ps_component *ps_next; /* Pointer to next node */
  372. X    char *ps_text;          /* Pointer to token text */
  373. X    char ps_start_delim;      /* Character delimiter for start of token */
  374. X    char ps_end_delim;          /* Character delimiter for end of token */
  375. X    };
  376. X
  377. /*
  378. X
  379. X    Name:  parse_string()
  380. X
  381. X    Calling sequence is:
  382. X
  383. X        string  - pointer to string to be parsed
  384. X        delim   - pointer to string of delimiters
  385. X        d_quote - 1 or 0 allowing/disallowing double quoting
  386. X        s_quote - 1 or 0 allowing/disallowing single quoting
  387. X        esc     - 1 or 0 allowing/disallowing escaping
  388. X
  389. X    Returns:  A pointer to the first node in the linked list; NULL on failure
  390. X              *OR* if the string contains no tokens.
  391. X
  392. X    Note that this routine is implemented as a somewhat complex state machine.
  393. */
  394. X
  395. struct ps_component *parse_string(string, delim, d_quote, s_quote, esc)
  396. X    char *string, *delim;
  397. X    int  d_quote, s_quote, esc;
  398. X    {
  399. X    struct ps_component *start, *ps_add_node();
  400. X    char *point1, *point2, *t_string, *t_component;
  401. X    int  beg_escape = 0;
  402. X    int  in_escape = 0;
  403. X    int  in_d_quote = 0;
  404. X    int  in_s_quote = 0;
  405. X    int  in_component = 0;
  406. X    int  is_delim = 0;
  407. X    int  is_quote = 0;
  408. X    int  beg_component = 1;
  409. X    char temp [2];
  410. X    char t_start_delim;
  411. X
  412. X    t_start_delim = NULL;
  413. X    temp [1] = 0;
  414. X    start = NULL;
  415. X
  416. X    /* Skip leading delimiters */
  417. X    point1 = string;
  418. X    temp [0] = *point1;
  419. X    while(*point1 != NULL && instr(delim, temp) != NULL)
  420. X        {
  421. X        t_start_delim = *point1;
  422. X        temp [0] = *++point1;
  423. X        }
  424. X
  425. X    /* quick check for null string */
  426. X    if(!strlen(point1)) return(NULL);
  427. X
  428. X    /* allocate temp storage */
  429. X    t_string = malloc(strlen(point1) + 1);
  430. X    if(t_string == NULL) return(NULL);
  431. X    strcpy(t_string, point1);
  432. X    t_component = malloc(strlen(t_string) + 1);
  433. X    if(t_component == NULL)
  434. X        {
  435. X        free(t_string);
  436. X        return(NULL);
  437. X        }
  438. X    *t_component = 0;
  439. X    point1 = t_string;
  440. X    point2 = t_component;
  441. X
  442. X    /* parse the string */
  443. X    while(*point1 != NULL)
  444. X        {
  445. X        /* handle the escape character logic */
  446. X        in_escape = 0;
  447. X        if(beg_escape) in_escape = 1;
  448. X        beg_escape = 0;
  449. X        is_quote = 0;
  450. X
  451. X        /* is the next char a delimiter? */
  452. X        temp [0] = *point1;
  453. X        if(instr(delim, temp) != NULL) is_delim = 1;
  454. X            else is_delim = 0;
  455. X
  456. X        /* if an escape char and not already escaped */
  457. X        if(*point1 == '\\' && !in_escape && esc) beg_escape = 1;
  458. X
  459. X        /* if a double quote, not in single quote, and not escaped */
  460. X        if(*point1 == '"' && !in_s_quote && !in_escape)
  461. X            {
  462. X            /* if not escaped, in double quote, and it is a double quote */
  463. X            if(d_quote && in_d_quote && !beg_escape)
  464. X                {
  465. X                is_quote = 1;
  466. X                in_d_quote = 0;
  467. X                *point2 = 0;
  468. X                start = ps_add_node(start, t_component,
  469. X                                                '"', *point1);
  470. X                point2 = t_component;
  471. X                }
  472. X            else
  473. X                if(d_quote && !in_d_quote) /* beginning double quote */
  474. X                    {
  475. X                    is_quote = 1;
  476. X                    in_d_quote = 1;
  477. X                    beg_component = 1;
  478. X                    }
  479. X            }
  480. X        /* if a single quote, not in double quote, and not escaped */
  481. X        if(*point1 == '\'' && !in_d_quote && !in_escape)
  482. X            {
  483. X            /* if not escaped, in single quote, and it is a single quote */
  484. X            if(s_quote && in_s_quote && !beg_escape)
  485. X                {
  486. X                is_quote = 1;
  487. X                in_s_quote = 0;
  488. X                *point2 = 0;
  489. X                start = ps_add_node(start, t_component,
  490. X                                                '\'', *point1);
  491. X                point2 = t_component;
  492. X                }
  493. X            else
  494. X                if(s_quote && !in_s_quote) /* beginning single quote */
  495. X                    {
  496. X                    is_quote = 1;
  497. X                    in_s_quote = 1;
  498. X                    beg_component = 1;
  499. X                    }
  500. X            }
  501. X        /* if delimiter, not in quotes and not escaped, or is a quote */
  502. X        if( (is_delim && !in_d_quote && !in_s_quote && !in_escape) || is_quote)
  503. X            {
  504. X            /* at the beginning of a component */
  505. X            beg_component = 1;
  506. X            in_component = 0;
  507. X            *point2 = 0;
  508. X            if(strlen(t_component)) start = ps_add_node(start, t_component,
  509. X                                            t_start_delim, *point1);
  510. X            /* store the start delimiter */
  511. X            t_start_delim = *point1;
  512. X            point2 = t_component;
  513. X            }
  514. X        else
  515. X            {
  516. X            if(beg_component) /* if start of component, mark as in comp. */
  517. X                {
  518. X                in_component = 1;
  519. X                beg_component = 0;
  520. X                }
  521. X            /* copy while in component */
  522. X            if(in_component && !beg_escape)
  523. X                {
  524. X                *point2 = *point1;
  525. X                point2++;
  526. X                }
  527. X            }
  528. X        point1++;
  529. X        }
  530. X    /* if still in component, terminate and add it to the list */
  531. X    if(in_component)
  532. X        {
  533. X        *point2 = 0;
  534. X        if(strlen(t_component)) start = ps_add_node(start, t_component,
  535. X                                        t_start_delim, *point1);
  536. X        }
  537. X    /* free temp storage */
  538. X    free(t_string);
  539. X    free(t_component);
  540. X    return(start);
  541. X    }
  542. X
  543. /*
  544. X    Name: ps_add_node()
  545. X
  546. X    Description:  private routine called to build list
  547. */
  548. X
  549. static struct ps_component *ps_add_node(start, text, start_delim, end_delim)
  550. X    struct ps_component *start;
  551. X    char *text;
  552. X    char start_delim, end_delim;
  553. X    {
  554. X    struct ps_component *hold, *current, *prev;
  555. X
  556. X    hold = (struct ps_component *) malloc(sizeof(struct ps_component));
  557. X    if(hold == NULL) return(NULL);
  558. X    hold->ps_text = malloc(strlen(text) + 1);
  559. X    if(hold->ps_text == NULL) return(NULL);
  560. X    strcpy(hold->ps_text, text);
  561. X    hold->ps_start_delim = start_delim;
  562. X    hold->ps_end_delim = end_delim;
  563. X    current = start;
  564. X    prev = current;
  565. X    while(current != NULL)
  566. X        {
  567. X        prev = current;
  568. X        current = current->ps_next;
  569. X        }
  570. X    if(prev == NULL)
  571. X        {
  572. X        start = hold;
  573. X        hold->ps_prev = NULL;
  574. X        hold->ps_next = NULL;
  575. X        }
  576. X    else
  577. X        {
  578. X        prev->ps_next = hold;
  579. X        hold->ps_prev = prev;
  580. X        hold->ps_next = NULL;
  581. X        }
  582. X    return(start);
  583. X    }
  584. X
  585. /*
  586. X    Name:  free_ps_list()
  587. X
  588. X    Description:  Routine to free a list built by parse_string.  Pass the
  589. X                  address of the first node in the list.
  590. */
  591. X
  592. free_ps_list(start)
  593. X    struct ps_component *start;
  594. X    {
  595. X    struct ps_component *current, *hold;
  596. X
  597. X    current = start;
  598. X    while(current != NULL)
  599. X        {
  600. X        hold = current->ps_next;
  601. X        if(current->ps_text != NULL) free(current->ps_text);
  602. X        free(current);
  603. X        current = hold;
  604. X        }
  605. X    return(1);
  606. X    }
  607. SHAR_EOF
  608. chmod 0644 parser.c ||
  609. echo 'restore of parser.c failed'
  610. Wc_c="`wc -c < 'parser.c'`"
  611. test 8055 -eq "$Wc_c" ||
  612.     echo 'parser.c: original size 8055, current size' "$Wc_c"
  613. fi
  614. # ============= rmfolder.c ==============
  615. if test -f 'rmfolder.c' -a X"$1" != X"-c"; then
  616.     echo 'x - skipping rmfolder.c (File already exists)'
  617. else
  618. echo 'x - extracting rmfolder.c (Text)'
  619. sed 's/^X//' << 'SHAR_EOF' > 'rmfolder.c' &&
  620. /*
  621. Post A Note V2.4
  622. Copyright (c) 1992, Jeffrey W. Bailey
  623. All rights reserved.
  624. X
  625. Permission is granted to distribute this program in exact, complete
  626. source form, which includes this copyright notice, as long as no fee
  627. other than media and distribution cost is charged.
  628. X
  629. This program may not be used in whole, or in part, in any other manner
  630. without prior written permission from the author.
  631. X
  632. This program may not be distributed in modified form without prior
  633. written permission from the author.  In other words, patches may be
  634. distributed, but modified source may not be distributed.
  635. X
  636. If there are any questions, comments or suggestions, the author may be
  637. contacted at:
  638. X
  639. X    jeff@rd1.interlan.com
  640. X
  641. X    or
  642. X
  643. X    Jeffrey Bailey
  644. X    Racal-Datacom, Inc.
  645. X    Mail Stop E-110
  646. X    1601 N. Harrison Parkway
  647. X    Sunrise, FL  33323-2899
  648. */
  649. X
  650. #include "pan.h"
  651. X
  652. extern char *malloc();
  653. extern char *getenv();
  654. X
  655. extern int errno;
  656. extern char *sys_errlist[];
  657. X
  658. int applydestroy(), destroydone();
  659. Panel_item fldrlist;
  660. X
  661. destroyfolder(menu, mitem)
  662. X    Menu menu;
  663. X    Menu_item mitem;
  664. X    {
  665. X    struct SubDir *sp;
  666. X    Display *dpy;
  667. X    Xv_Screen screen;
  668. X    int  screen_num;
  669. X    int  screen_height;
  670. X    int  screen_width;
  671. X    int  row;
  672. X    Rect rect;
  673. X    Panel destroy_panel;
  674. X
  675. X    destroy_mitem = mitem;
  676. X    dpy = (Display *) xv_get(main_frame, XV_DISPLAY);
  677. X    screen = (Xv_Screen) xv_get(main_frame, XV_SCREEN);
  678. X    screen_num = xv_get(screen, SCREEN_NUMBER);
  679. X    screen_height = DisplayHeight(dpy, screen_num);
  680. X    screen_width = DisplayWidth(dpy, screen_num);
  681. X    frame_get_rect(main_frame, &rect);
  682. X    rect.r_left += DESTROYSPACING;
  683. X    if((rect.r_left + DESTROYWIDTH) > (screen_width - DESTROYSPACING))
  684. X        rect.r_left = screen_width - DESTROYWIDTH - DESTROYSPACING;
  685. X    if((rect.r_top + rect.r_height + 2 * DESTROYSPACING + DESTROYHEIGHT) < 
  686. X       screen_height)
  687. X        rect.r_top += (rect.r_height + DESTROYSPACING);
  688. X    else
  689. X        rect.r_top -= (DESTROYHEIGHT + 2 * DESTROYSPACING);
  690. X    destroy_frame = xv_create(main_frame, FRAME_CMD,
  691. X                           XV_LABEL, "Destroy Folder",
  692. X                           XV_X, rect.r_left,
  693. X                           XV_Y, rect.r_top,
  694. X                           XV_WIDTH, DESTROYWIDTH,
  695. X                           XV_HEIGHT, DESTROYHEIGHT,
  696. X                           FRAME_NO_CONFIRM, TRUE,
  697. X                           FRAME_DONE_PROC, destroydone,
  698. X                           NULL);
  699. X    if(destroy_frame == NULL)
  700. X        {
  701. X        notice_prompt(main_frame, NULL,
  702. X            NOTICE_MESSAGE_STRINGS,
  703. X                "Unable to create sub-frame (internal error)",
  704. X                NULL,
  705. X            NOTICE_BUTTON_YES, "Acknowledge",
  706. X            NOTICE_NO_BEEPING, noticenobeep,
  707. X            NULL);
  708. X        return;
  709. X        }
  710. X    xv_set(destroy_frame, XV_SHOW, TRUE, NULL);
  711. X
  712. X    destroy_panel = (Panel) xv_get(destroy_frame, FRAME_CMD_PANEL);
  713. X    xv_set(destroy_panel, WIN_RETAINED, FALSE, NULL);
  714. X
  715. X    (void) xv_create(destroy_panel, PANEL_MESSAGE,
  716. X        XV_X, xv_col(destroy_panel, 0),
  717. X        XV_Y, xv_row(destroy_panel, 0),
  718. X        PANEL_LABEL_STRING, "Destroy Folder",
  719. X        NULL);
  720. X    fldrlist = xv_create(destroy_panel, PANEL_LIST,
  721. X        XV_X, xv_col(destroy_panel, 0),
  722. X        XV_Y, xv_row(destroy_panel, 1),
  723. X        PANEL_LIST_DISPLAY_ROWS, 7,
  724. X        PANEL_LIST_WIDTH, xv_col(destroy_panel, 15),
  725. X        PANEL_CHOOSE_ONE, TRUE,
  726. X        NULL);
  727. X    row = 0;
  728. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  729. X    while(sp != NULL)
  730. X        {
  731. X        xv_set(fldrlist,
  732. X            PANEL_LIST_INSERT, row,
  733. X            PANEL_LIST_STRING, row, sp->subdir, 
  734. X            PANEL_LIST_CLIENT_DATA, row, sp, 
  735. X            NULL);
  736. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  737. X        row++;
  738. X        }
  739. X
  740. X
  741. X    destroy_item =  xv_create(destroy_panel, PANEL_BUTTON,
  742. X                 XV_X, DESTROYWIDTH / 2 - 30,
  743. X                 XV_Y, DESTROYHEIGHT - 30,
  744. X                 PANEL_LABEL_STRING, "Apply",
  745. X                 PANEL_NOTIFY_PROC, applydestroy,
  746. X                 NULL);
  747. X
  748. X    window_fit_height(destroy_panel);
  749. X
  750. X    (void) xv_set(mitem, MENU_INACTIVE, TRUE, NULL);
  751. X    destroy_up = 1;
  752. X    }
  753. X
  754. destroydone()
  755. X    {
  756. X    xv_destroy_safe(destroy_frame);
  757. X    (void) xv_set(destroy_mitem, MENU_INACTIVE, FALSE, NULL);
  758. X    destroy_up = 0;
  759. X    }
  760. X
  761. applydestroy(item, event)
  762. X    Panel_item item;
  763. X    Event *event;
  764. X    {
  765. X    Menu_item mitem;
  766. X    struct SubDir *sp;
  767. X    struct Note *np;
  768. X    int  i, row;
  769. X    DIR *dp;
  770. X    struct dirent *ent;
  771. X    char buf[MAXBUFLEN];
  772. X
  773. X    row = xv_get(fldrlist, PANEL_LIST_NROWS);
  774. X    for(i = 0; i < row; i++)
  775. X        {
  776. X        if(xv_get(fldrlist, PANEL_LIST_SELECTED, i))
  777. X            {
  778. X            sp = (struct SubDir *) xv_get(fldrlist, PANEL_LIST_CLIENT_DATA, i);
  779. X            }
  780. X        }
  781. X
  782. #ifdef CONFIDENT
  783. X    if(confirmdestroy)
  784. X        {
  785. #endif
  786. X        if(notice_prompt(destroy_frame, NULL,
  787. X                     NOTICE_MESSAGE_STRINGS, "Really destroy this folder?",
  788. X                         sp->subdir,
  789. X                         "(This action will destroy all notes in the folder)",
  790. X                         NULL,
  791. X                     NOTICE_BUTTON_YES, "Yes",
  792. X                     NOTICE_BUTTON_NO, "No",
  793. X                     NOTICE_NO_BEEPING, noticenobeep,
  794. X                     NULL) == NOTICE_NO)
  795. X            {
  796. X            if(xv_get(destroy_frame, FRAME_CMD_PUSHPIN_IN) == FALSE)
  797. X                {
  798. X                xv_destroy_safe(destroy_frame);
  799. X                (void) xv_set(destroy_mitem, MENU_INACTIVE, FALSE, NULL);
  800. X                destroy_up = 0;
  801. X                }
  802. X            return;
  803. X            }
  804. #ifdef CONFIDENT
  805. X        }
  806. #endif
  807. X
  808. X    np = (struct Note *) LLM_first(&sp->note_rt);
  809. X    while(np != NULL)
  810. X        {
  811. X        if(np->mapped)
  812. X            {
  813. X            textsw_reset(np->textsw, 0, 0);
  814. X            put_win(np);
  815. X            np->mapped = 0;
  816. X            }
  817. X        np = (struct Note *) LLM_next(&sp->note_rt);
  818. X        }
  819. X
  820. X    dp = opendir(sp->subdir);
  821. X    if(dp == NULL)
  822. X        {
  823. X        notice_prompt(main_frame, NULL,
  824. X            NOTICE_MESSAGE_STRINGS,
  825. X                "Couldn't read directory",
  826. X                sp->subdir,
  827. X                sys_errlist[errno],
  828. X                NULL,
  829. X            NOTICE_BUTTON_YES, "Acknowledge",
  830. X            NOTICE_NO_BEEPING, noticenobeep,
  831. X            NULL);
  832. X        if(xv_get(destroy_frame, FRAME_CMD_PUSHPIN_IN) == FALSE)
  833. X            {
  834. X            xv_destroy_safe(destroy_frame);
  835. X            (void) xv_set(destroy_mitem, MENU_INACTIVE, FALSE, NULL);
  836. X            destroy_up = 0;
  837. X            }
  838. X        return;
  839. X        }
  840. X    while((ent = readdir(dp)) != NULL)
  841. X        {
  842. X        if(strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0)
  843. X            {
  844. X            sprintf(buf, "%s/%s", sp->subdir, ent->d_name);
  845. X            unlink(buf);
  846. X            }
  847. X        }
  848. X    closedir(dp);
  849. X    if(rmdir(sp->subdir) < 0)
  850. X        {
  851. X        notice_prompt(main_frame, NULL,
  852. X            NOTICE_MESSAGE_STRINGS,
  853. X                "Couldn't remove directory",
  854. X                sp->subdir,
  855. X                sys_errlist[errno],
  856. X                NULL,
  857. X            NOTICE_BUTTON_YES, "Acknowledge",
  858. X            NOTICE_NO_BEEPING, noticenobeep,
  859. X            NULL);
  860. X        }
  861. X
  862. X    mitem = xv_find(main_newnote, MENUITEM, MENU_STRING, sp->subdir, NULL);
  863. X    if(mitem != NULL)
  864. X        {
  865. X        (void) xv_set(main_newnote, MENU_REMOVE_ITEM, mitem, NULL);
  866. X        xv_destroy_safe(mitem);
  867. X        }
  868. X    mitem = xv_find(main_expose, MENUITEM, MENU_STRING, sp->subdir, NULL);
  869. X    if(mitem != NULL)
  870. X        {
  871. X        (void) xv_set(main_expose, MENU_REMOVE_ITEM, mitem, NULL);
  872. X        xv_destroy_safe(mitem);
  873. X        }
  874. X    mitem = xv_find(main_print, MENUITEM, MENU_STRING, sp->subdir, NULL);
  875. X    if(mitem != NULL)
  876. X        {
  877. X        (void) xv_set(main_print, MENU_REMOVE_ITEM, mitem, NULL);
  878. X        xv_destroy_safe(mitem);
  879. X        }
  880. X
  881. X    LLM_free(&sp->note_rt);
  882. X    LLM_delete(&subdir_rt, sp);
  883. X
  884. X    refresh_popups();
  885. X    if(xv_get(destroy_frame, FRAME_CMD_PUSHPIN_IN) == FALSE)
  886. X        {
  887. X        xv_destroy_safe(destroy_frame);
  888. X        (void) xv_set(destroy_mitem, MENU_INACTIVE, FALSE, NULL);
  889. X        destroy_up = 0;
  890. X        }
  891. X    }
  892. X
  893. refresh_destroy()
  894. X    {
  895. X    int  row, i;
  896. X    struct SubDir *sp;
  897. X
  898. X    if(!destroy_up) return;
  899. X
  900. X    xv_set(fldrlist, XV_SHOW, FALSE, NULL);
  901. X
  902. X    row = xv_get(fldrlist, PANEL_LIST_NROWS);
  903. X    for(i = row - 1; i >= 0; i--)
  904. X        xv_set(fldrlist, PANEL_LIST_DELETE, i, NULL);
  905. X
  906. X    row = 0;
  907. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  908. X    while(sp != NULL)
  909. X        {
  910. X        xv_set(fldrlist,
  911. X            PANEL_LIST_INSERT, row,
  912. X            PANEL_LIST_STRING, row, sp->subdir, 
  913. X            PANEL_LIST_CLIENT_DATA, row, sp, 
  914. X            NULL);
  915. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  916. X        row++;
  917. X        }
  918. X
  919. X    xv_set(fldrlist, XV_SHOW, TRUE, NULL);
  920. X    }
  921. SHAR_EOF
  922. chmod 0644 rmfolder.c ||
  923. echo 'restore of rmfolder.c failed'
  924. Wc_c="`wc -c < 'rmfolder.c'`"
  925. test 8786 -eq "$Wc_c" ||
  926.     echo 'rmfolder.c: original size 8786, current size' "$Wc_c"
  927. fi
  928. # ============= rmnote.c ==============
  929. if test -f 'rmnote.c' -a X"$1" != X"-c"; then
  930.     echo 'x - skipping rmnote.c (File already exists)'
  931. else
  932. echo 'x - extracting rmnote.c (Text)'
  933. sed 's/^X//' << 'SHAR_EOF' > 'rmnote.c' &&
  934. /*
  935. Post A Note V2.4
  936. Copyright (c) 1992, Jeffrey W. Bailey
  937. All rights reserved.
  938. X
  939. Permission is granted to distribute this program in exact, complete
  940. source form, which includes this copyright notice, as long as no fee
  941. other than media and distribution cost is charged.
  942. X
  943. This program may not be used in whole, or in part, in any other manner
  944. without prior written permission from the author.
  945. X
  946. This program may not be distributed in modified form without prior
  947. written permission from the author.  In other words, patches may be
  948. distributed, but modified source may not be distributed.
  949. X
  950. If there are any questions, comments or suggestions, the author may be
  951. contacted at:
  952. X
  953. X    jeff@rd1.interlan.com
  954. X
  955. X    or
  956. X
  957. X    Jeffrey Bailey
  958. X    Racal-Datacom, Inc.
  959. X    Mail Stop E-110
  960. X    1601 N. Harrison Parkway
  961. X    Sunrise, FL  33323-2899
  962. */
  963. X
  964. #include "pan.h"
  965. X
  966. extern char *malloc();
  967. extern char *getenv();
  968. X
  969. extern int errno;
  970. extern char *sys_errlist[];
  971. X
  972. /*
  973. X    Routine called when the destroy button on a note is selected.  Destroys the
  974. X    selected note.
  975. */
  976. removenote(item, event)
  977. X    Panel_item item;
  978. X    Event *event;
  979. X    {
  980. X    struct Note *np;
  981. X    int  mod;
  982. X    char fname[MAXBUFLEN];
  983. X
  984. X    np = (struct Note *) xv_get(item, PANEL_CLIENT_DATA);
  985. X    if(confirmdestroy)
  986. X        {
  987. X        if(notice_prompt(np->frame, NULL,
  988. X                     NOTICE_MESSAGE_STRINGS, "Really destroy this note?", NULL,
  989. X                     NOTICE_BUTTON_YES, "Yes",
  990. X                     NOTICE_BUTTON_NO, "No",
  991. X                     NOTICE_NO_BEEPING, noticenobeep,
  992. X                     NULL) == NOTICE_NO)
  993. X            {
  994. X            return;
  995. X            }
  996. X        }
  997. X    mod = xv_get(np->textsw, TEXTSW_MODIFIED);
  998. X    if(mod)
  999. X        {
  1000. X        textsw_reset(np->textsw, 0, 0);
  1001. X        }
  1002. X    makename(fname, np);
  1003. X    (void) unlink(fname);
  1004. X    strcat(fname, "%"); /* Attempt to remove the textsw files */
  1005. X    (void) unlink(fname);
  1006. X    makeinfoname(fname, np);
  1007. X    (void) unlink(fname);
  1008. X    put_win(np);
  1009. X    LLM_delete(&np->sp->note_rt, np);
  1010. X    refresh_popups();
  1011. X    }
  1012. SHAR_EOF
  1013. chmod 0644 rmnote.c ||
  1014. echo 'restore of rmnote.c failed'
  1015. Wc_c="`wc -c < 'rmnote.c'`"
  1016. test 2035 -eq "$Wc_c" ||
  1017.     echo 'rmnote.c: original size 2035, current size' "$Wc_c"
  1018. fi
  1019. true || echo 'restore of search.c failed'
  1020. echo End of part 5, continue with part 6
  1021. exit 0
  1022. -- 
  1023. --
  1024. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  1025. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  1026. Sunnyvale, California 94086            at&t: 408/522-9236
  1027.