home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-03-06 | 31.3 KB | 1,027 lines |
- Newsgroups: comp.sources.x
- Path: uunet!think.com!mips!msi!dcmartin
- From: jeff@rd1.interlan.com (Jeff Bailey)
- Subject: v16i141: pan - Post A Note (for Open Windows), Part05/06
- Message-ID: <1992Mar6.200408.8349@msi.com>
- Originator: dcmartin@fascet
- Sender: dcmartin@msi.com (David C. Martin - Moderator)
- Organization: Molecular Simulations, Inc.
- References: <csx-16i137-pan@uunet.UU.NET>
- Date: Fri, 6 Mar 1992 20:04:08 GMT
- Approved: dcmartin@msi.com
-
- Submitted-by: jeff@rd1.interlan.com (Jeff Bailey)
- Posting-number: Volume 16, Issue 141
- Archive-name: pan/part05
-
-
- ---- Cut Here and feed the following to sh ----
- #!/bin/sh
- # This is part 05 of a multipart archive
- # ============= pan.man ==============
- if test -f 'pan.man' -a X"$1" != X"-c"; then
- echo 'x - skipping pan.man (File already exists)'
- else
- echo 'x - extracting pan.man (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'pan.man' &&
- .TH pan l "January 17, 1991"
- .SH NAME
- pan \- Post A Note Open Look program
- .SH SYNTAX
- \fBpan\fP [args...]
- .SH DESCRIPTION
- The \fBpan\fP program keeps track of multiple text notes. Each note
- has its own window and associated attributes. The position, size, and
- visibility of each note is maintained across invocations along with the
- note text.
- .LP
- A note may be in one of three states: Visible, Hidden, or Veiled.
- A visible note has a window mapped to the display. A hidden note is not
- mapped to the display. A veiled note is a note which has been dismissed
- via the window manager's window menu. It is not mapped, but the permanent
- state is still "Visible". This feature allows a note to be unmapped, but
- made visible automatically upon the next invocation of \fBpan\fP. A veiled
- note may be exposed just like a hidden note.
- .LP
- The \fBpan\fP program accepts all standard Open Look command line arguments.
- .LP
- In addition, \fBpan\fP accepts the following command line arguments:
- .LP
- \fB-d<directory>\fP
- .RS
- Set the initial pan directory. This overrides the X resource
- \fBinitialDirectory\fP.
- .RE
- .LP
- All notes are automatically saved to disk when the pointer moves outside
- of the note window, or upon loss of the keyboard focus. Note that saving
- to disk is only done if changes have been made.
- .LP
- The \fBpan\fP program has one base window from which many functions may be
- accessed. Each note consists of a separate window which may or may not be
- mapped to the display. The base window has the following buttons:
- .LP
- \fBNew Note\fP
- .RS
- Clicking on this button with mouse button 1 causes a new blank note to
- be created and made visible. This new note is created in the default folder.
- .LP
- Clicking on this button and holding with mouse button 3 will bring up a menu
- of folders in which a new note may be created.
- .RE
- .LP
- \fBHide Notes\fP
- .RS
- Clicking on this button causes all visible notes to be unmapped from the
- display.
- .RE
- .LP
- \fBExpose Notes\fP
- .RS
- This button has a menu attached to it. Clicking with mouse button 1
- selects the default action. Pressing mouse button 3 brings up
- a menu. The menu items are:
- .LP
- \fBAll\fP
- .RS
- Expose (make visible) all notes. This is the default action.
- .RE
- .LP
- \fB<Folders>\fP
- .RS
- An additional entry for each folder is displayed. By moving the pointer right,
- a menu of all hidden notes in that folder is displayed. The first entry is
- the item "All". Selecting this will expose all notes in the folder. The
- remaining items are individual notes within the folder.
- .RE
- .RE
- .LP
- \fBAction\fP
- .RS
- This button has a menu attached to it. Clicking with mouse button 1
- selects the default action. Pressing mouse button 3 brings up
- a menu. The menu items are:
- .LP
- \fBQuit\fB
- .RS
- Cause \fBpan\fP to exit. This is the default action.
- .RE
- .LP
- \fBCreate Folder\fP
- .RS
- Selecting this menu item brings up another window that allows a folder
- name to be entered. When this is done, \fBpan\fP will create a new
- folder.
- .RE
- .LP
- \fBMove Note\fP
- .RS
- This menu item will bring up a window with 3 lists. The first list is the
- folder \fBfrom\fP which to move notes. The second list is the folder
- \fBto\fP which notes will be moved. The third list is the list of notes
- in the source folder. Select the appropriate source and destination folders,
- then select the note or notes to be moved and click on the "Apply" button. The
- selected notes will be moved to the destination folder.
- .RE
- .LP
- \fBPrint Note\fP
- .RS
- This menu item will bring up a menu of all folders, similar to the \fBExpose\fP
- menu.
- Sliding the pointer to the right while holding
- mouse button 3 down reveals a list of all notes in the selected folder.
- Highlight the one
- to be printed and release the mouse button to cause the note to be printed.
- .RE
- .LP
- \fBDestroy Folder\fP
- .RS
- This menu item will pop up a window with a list of all available folders.
- Selecting a folder and then clicking the "Apply" button will cause all
- notes in that folder to be destroyed. The folder itself will then be
- destroyed. \fIThis is an extremely destructive function and should be
- used with great care.\fP
- .RE
- .RE
- .LP
- \fBSearch:\fP
- .RS
- This is a text entry field. It can be used to enter a regular expression.
- Upon pressing the \fIreturn\fP key, \fBpan\fP will search for a note with
- a title matching the RE and expose it if there is a single match. If more
- than one note matches, a list window will be displayed allowing multiple
- selections of notes to expose.
- .RE
- .SH NOTE WINDOWS
- Each note window contains the following items:
- .LP
- \fBTitle\fP
- .RS
- This is a scrolling text entry item. A note title may be entered here. \fBThe
- title does not become active until the return key is pressed.\fP
- .RE
- .LP
- \fBHide\fP
- .RS
- Clicking on this button will cause this note to be hidden.
- .RE
- .LP
- \fBDestroy\fP
- .RS
- Clicking on this button will cause this note to be destroyed. There is
- no way to recover a note after this action is taken.
- .RE
- .SH RESOURCES
- The \fBpan\fP program will query the X server for resource information.
- The following items of information are examined by \fBpan\fP:
- .LP
- \fBpan.initialDirectory\fP
- .RS
- This resource may be defined with a directory name. \fBPan\fP will read
- this directory for notes upon startup instead of reading the default directory.
- Note that the \fB-d\fP command line argument can override this.
- .LP
- The current default directory is "$HOME/.pan". It will be created
- automatically by \fBpan\fP if necessary. Note that a directory other than the
- default will \fBnot\fP be automatically created.
- .RE
- .LP
- \fBpan.printCommand\fP
- .RS
- This resource may be defined to be a command that will cause a note to
- be printed.
- .LP
- The current default command is "/usr/ucb/lpr $FILE". Another command, including
- flags may be substituted. Two special variables are available: $FILE, and
- $NOTETITLE. The first will contain the full path and file name of the note
- selected to be printed. The second will contain the full title of the note
- selected to be printed. If a postscript printer is available, a nicely
- formatted printout may be obtained by using 'mp -o -s "$NOTETITLE" $FILE | lpr'.
- .RE
- .LP
- \fBpan.confirmDestroy\fP
- .RS
- This resource controls whether \fBpan\fP will display a confirmation notice
- when the destroy button on a note is selected. This is a boolean resource.
- .LP
- The default value is False.
- .RE
- .LP
- \fBpan.noticeBeep\fP
- .RS
- This resource controls whether notices displayed by \fBpan\fP will be
- accompanied by an audible beep. It is a boolean resource.
- .LP
- The current default is True.
- .RE
- .LP
- \fBpan.iconTransparent\fP
- .RS
- This resource controls whether or not the icons used by \fBpan\fP have
- a transparent background. This is a boolean resource.
- .LP
- The default value is False.
- .RE
- .LP
- \fBpan.folderOrder\fP
- .RS
- This is a string resource. It consists of a comma separated list of folder
- names. This resource allows the order in which folders appear in the menus
- to be specified. Any folders not explicitly mentioned are added to the
- end of the list in the order in which they are encountered when reading
- the directory.
- .LP
- The default value is "Miscellaneous".
- .RE
- .LP
- \fBpan.defaultSearch\fP
- .RS
- This resource allows the specification of a default search string to appear
- in the "Search:" field in the base window.
- .LP
- The default value is "".
- .RE
- .SH NOTES
- The \fBpan\fP program will accept drag and drop files from the Open Look
- file manager. The full path name of the file or directory will be inserted
- into the note (the file's contents will \fBnot\fP be loaded). For
- this feature to work, the file icon must be dropped directly into the text
- subwindow of the note. Dropping the icon anywhere else will not have
- any effect. This feature is provided to allow a path name to be easily
- generated from the file manager. It may then be highlighted, copied, and
- pasted into any application window that supports Open Look style selection
- operations.
- .LP
- If the note file directories are examined, occasionally files with names
- ending in a "%" character will be seen. These files are created automatically
- by the Open Look text subwindow package, and are simply old versions of the
- note files being edited.
- .SH WINDOW CLASS
- \fBPan\fP supports three different window classes for use with window manager
- properties such as minimal decor. The first is "PanMain". This is the class
- for the main window. The second is "PanNote". This is the class for all
- notes. The third is "Pan" (assuming the executable name is not changed).
- This is used for all pop up windows, such as the create folder window.
- Note that the third class, "Pan", is only set under Open Windows V3.0.
- .SH FILES
- Default note directory:
- .RS
- $HOME/.pan
- .RE
- .LP
- Note files:
- .RS
- Note_%d_%d
- .br
- Note_%d_%d.info
- .LP
- where the "%d" instances are replaced by unique id numbers.
- .RE
- .SH FILE FORMAT
- The "Note_%d_%d" file is a plain ASCII file containing the note text. Lines
- are delimited by the newline character.
- .LP
- The "Note_%d_%d.info" file is a plain ASCII file currently containing 3 lines.
- .LP
- The first line contains 4 whitespace separated numbers followed by a
- text word. The 4 numbers describe the note window's start x, start y,
- width, and height. The text word is either "VISIBLE" or "HIDDEN" describing
- whether the note is mapped to the display by default or not.
- .LP
- The second line of the file contains the note title.
- .LP
- The third line is an ASCII representation of the decimal number returned
- by time(3) describing the note's creation date and time.
- .LP
- An example might be:
- .nf
- X
- 4 424 349 206 HIDDEN
- Note title
- 664129826
- X
- .fi
- .SH BUGS
- When \fBpan\fP is compiled and run under Open Windows V3.0, the drag and
- drop feature \fBloads\fP the file into the note.
- .LP
- Occasionally, when a new note is created, the focus is initially in the text
- sub-window instead of in the title panel item.
- .LP
- The text sub-window package in xview creates files ending with a "%" character
- and doesn't delete them. Periodically it is a good idea to remove them by
- hand to recover disk space.
- .SH AUTHOR
- Jeffrey Bailey
- SHAR_EOF
- chmod 0644 pan.man ||
- echo 'restore of pan.man failed'
- Wc_c="`wc -c < 'pan.man'`"
- test 10032 -eq "$Wc_c" ||
- echo 'pan.man: original size 10032, current size' "$Wc_c"
- fi
- # ============= parser.c ==============
- if test -f 'parser.c' -a X"$1" != X"-c"; then
- echo 'x - skipping parser.c (File already exists)'
- else
- echo 'x - extracting parser.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'parser.c' &&
- /*
- Post A Note V2.4
- Copyright (c) 1992, Jeffrey W. Bailey
- All rights reserved.
- X
- Permission is granted to distribute this program in exact, complete
- source form, which includes this copyright notice, as long as no fee
- other than media and distribution cost is charged.
- X
- This program may not be used in whole, or in part, in any other manner
- without prior written permission from the author.
- X
- This program may not be distributed in modified form without prior
- written permission from the author. In other words, patches may be
- distributed, but modified source may not be distributed.
- X
- If there are any questions, comments or suggestions, the author may be
- contacted at:
- X
- X jeff@rd1.interlan.com
- X
- X or
- X
- X Jeffrey Bailey
- X Racal-Datacom, Inc.
- X Mail Stop E-110
- X 1601 N. Harrison Parkway
- X Sunrise, FL 33323-2899
- */
- X
- #include <stdio.h>
- #include <ctype.h>
- X
- extern char *malloc();
- static char *instr();
- X
- /*
- X Component structure for each token on the linked list.
- */
- struct ps_component
- X {
- X struct ps_component *ps_prev; /* Pointer to previous node */
- X struct ps_component *ps_next; /* Pointer to next node */
- X char *ps_text; /* Pointer to token text */
- X char ps_start_delim; /* Character delimiter for start of token */
- X char ps_end_delim; /* Character delimiter for end of token */
- X };
- X
- /*
- X
- X Name: parse_string()
- X
- X Calling sequence is:
- X
- X string - pointer to string to be parsed
- X delim - pointer to string of delimiters
- X d_quote - 1 or 0 allowing/disallowing double quoting
- X s_quote - 1 or 0 allowing/disallowing single quoting
- X esc - 1 or 0 allowing/disallowing escaping
- X
- X Returns: A pointer to the first node in the linked list; NULL on failure
- X *OR* if the string contains no tokens.
- X
- X Note that this routine is implemented as a somewhat complex state machine.
- */
- X
- struct ps_component *parse_string(string, delim, d_quote, s_quote, esc)
- X char *string, *delim;
- X int d_quote, s_quote, esc;
- X {
- X struct ps_component *start, *ps_add_node();
- X char *point1, *point2, *t_string, *t_component;
- X int beg_escape = 0;
- X int in_escape = 0;
- X int in_d_quote = 0;
- X int in_s_quote = 0;
- X int in_component = 0;
- X int is_delim = 0;
- X int is_quote = 0;
- X int beg_component = 1;
- X char temp [2];
- X char t_start_delim;
- X
- X t_start_delim = NULL;
- X temp [1] = 0;
- X start = NULL;
- X
- X /* Skip leading delimiters */
- X point1 = string;
- X temp [0] = *point1;
- X while(*point1 != NULL && instr(delim, temp) != NULL)
- X {
- X t_start_delim = *point1;
- X temp [0] = *++point1;
- X }
- X
- X /* quick check for null string */
- X if(!strlen(point1)) return(NULL);
- X
- X /* allocate temp storage */
- X t_string = malloc(strlen(point1) + 1);
- X if(t_string == NULL) return(NULL);
- X strcpy(t_string, point1);
- X t_component = malloc(strlen(t_string) + 1);
- X if(t_component == NULL)
- X {
- X free(t_string);
- X return(NULL);
- X }
- X *t_component = 0;
- X point1 = t_string;
- X point2 = t_component;
- X
- X /* parse the string */
- X while(*point1 != NULL)
- X {
- X /* handle the escape character logic */
- X in_escape = 0;
- X if(beg_escape) in_escape = 1;
- X beg_escape = 0;
- X is_quote = 0;
- X
- X /* is the next char a delimiter? */
- X temp [0] = *point1;
- X if(instr(delim, temp) != NULL) is_delim = 1;
- X else is_delim = 0;
- X
- X /* if an escape char and not already escaped */
- X if(*point1 == '\\' && !in_escape && esc) beg_escape = 1;
- X
- X /* if a double quote, not in single quote, and not escaped */
- X if(*point1 == '"' && !in_s_quote && !in_escape)
- X {
- X /* if not escaped, in double quote, and it is a double quote */
- X if(d_quote && in_d_quote && !beg_escape)
- X {
- X is_quote = 1;
- X in_d_quote = 0;
- X *point2 = 0;
- X start = ps_add_node(start, t_component,
- X '"', *point1);
- X point2 = t_component;
- X }
- X else
- X if(d_quote && !in_d_quote) /* beginning double quote */
- X {
- X is_quote = 1;
- X in_d_quote = 1;
- X beg_component = 1;
- X }
- X }
- X /* if a single quote, not in double quote, and not escaped */
- X if(*point1 == '\'' && !in_d_quote && !in_escape)
- X {
- X /* if not escaped, in single quote, and it is a single quote */
- X if(s_quote && in_s_quote && !beg_escape)
- X {
- X is_quote = 1;
- X in_s_quote = 0;
- X *point2 = 0;
- X start = ps_add_node(start, t_component,
- X '\'', *point1);
- X point2 = t_component;
- X }
- X else
- X if(s_quote && !in_s_quote) /* beginning single quote */
- X {
- X is_quote = 1;
- X in_s_quote = 1;
- X beg_component = 1;
- X }
- X }
- X /* if delimiter, not in quotes and not escaped, or is a quote */
- X if( (is_delim && !in_d_quote && !in_s_quote && !in_escape) || is_quote)
- X {
- X /* at the beginning of a component */
- X beg_component = 1;
- X in_component = 0;
- X *point2 = 0;
- X if(strlen(t_component)) start = ps_add_node(start, t_component,
- X t_start_delim, *point1);
- X /* store the start delimiter */
- X t_start_delim = *point1;
- X point2 = t_component;
- X }
- X else
- X {
- X if(beg_component) /* if start of component, mark as in comp. */
- X {
- X in_component = 1;
- X beg_component = 0;
- X }
- X /* copy while in component */
- X if(in_component && !beg_escape)
- X {
- X *point2 = *point1;
- X point2++;
- X }
- X }
- X point1++;
- X }
- X /* if still in component, terminate and add it to the list */
- X if(in_component)
- X {
- X *point2 = 0;
- X if(strlen(t_component)) start = ps_add_node(start, t_component,
- X t_start_delim, *point1);
- X }
- X /* free temp storage */
- X free(t_string);
- X free(t_component);
- X return(start);
- X }
- X
- /*
- X Name: ps_add_node()
- X
- X Description: private routine called to build list
- */
- X
- static struct ps_component *ps_add_node(start, text, start_delim, end_delim)
- X struct ps_component *start;
- X char *text;
- X char start_delim, end_delim;
- X {
- X struct ps_component *hold, *current, *prev;
- X
- X hold = (struct ps_component *) malloc(sizeof(struct ps_component));
- X if(hold == NULL) return(NULL);
- X hold->ps_text = malloc(strlen(text) + 1);
- X if(hold->ps_text == NULL) return(NULL);
- X strcpy(hold->ps_text, text);
- X hold->ps_start_delim = start_delim;
- X hold->ps_end_delim = end_delim;
- X current = start;
- X prev = current;
- X while(current != NULL)
- X {
- X prev = current;
- X current = current->ps_next;
- X }
- X if(prev == NULL)
- X {
- X start = hold;
- X hold->ps_prev = NULL;
- X hold->ps_next = NULL;
- X }
- X else
- X {
- X prev->ps_next = hold;
- X hold->ps_prev = prev;
- X hold->ps_next = NULL;
- X }
- X return(start);
- X }
- X
- /*
- X Name: free_ps_list()
- X
- X Description: Routine to free a list built by parse_string. Pass the
- X address of the first node in the list.
- */
- X
- free_ps_list(start)
- X struct ps_component *start;
- X {
- X struct ps_component *current, *hold;
- X
- X current = start;
- X while(current != NULL)
- X {
- X hold = current->ps_next;
- X if(current->ps_text != NULL) free(current->ps_text);
- X free(current);
- X current = hold;
- X }
- X return(1);
- X }
- SHAR_EOF
- chmod 0644 parser.c ||
- echo 'restore of parser.c failed'
- Wc_c="`wc -c < 'parser.c'`"
- test 8055 -eq "$Wc_c" ||
- echo 'parser.c: original size 8055, current size' "$Wc_c"
- fi
- # ============= rmfolder.c ==============
- if test -f 'rmfolder.c' -a X"$1" != X"-c"; then
- echo 'x - skipping rmfolder.c (File already exists)'
- else
- echo 'x - extracting rmfolder.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'rmfolder.c' &&
- /*
- Post A Note V2.4
- Copyright (c) 1992, Jeffrey W. Bailey
- All rights reserved.
- X
- Permission is granted to distribute this program in exact, complete
- source form, which includes this copyright notice, as long as no fee
- other than media and distribution cost is charged.
- X
- This program may not be used in whole, or in part, in any other manner
- without prior written permission from the author.
- X
- This program may not be distributed in modified form without prior
- written permission from the author. In other words, patches may be
- distributed, but modified source may not be distributed.
- X
- If there are any questions, comments or suggestions, the author may be
- contacted at:
- X
- X jeff@rd1.interlan.com
- X
- X or
- X
- X Jeffrey Bailey
- X Racal-Datacom, Inc.
- X Mail Stop E-110
- X 1601 N. Harrison Parkway
- X Sunrise, FL 33323-2899
- */
- X
- #include "pan.h"
- X
- extern char *malloc();
- extern char *getenv();
- X
- extern int errno;
- extern char *sys_errlist[];
- X
- int applydestroy(), destroydone();
- Panel_item fldrlist;
- X
- destroyfolder(menu, mitem)
- X Menu menu;
- X Menu_item mitem;
- X {
- X struct SubDir *sp;
- X Display *dpy;
- X Xv_Screen screen;
- X int screen_num;
- X int screen_height;
- X int screen_width;
- X int row;
- X Rect rect;
- X Panel destroy_panel;
- X
- X destroy_mitem = mitem;
- X dpy = (Display *) xv_get(main_frame, XV_DISPLAY);
- X screen = (Xv_Screen) xv_get(main_frame, XV_SCREEN);
- X screen_num = xv_get(screen, SCREEN_NUMBER);
- X screen_height = DisplayHeight(dpy, screen_num);
- X screen_width = DisplayWidth(dpy, screen_num);
- X frame_get_rect(main_frame, &rect);
- X rect.r_left += DESTROYSPACING;
- X if((rect.r_left + DESTROYWIDTH) > (screen_width - DESTROYSPACING))
- X rect.r_left = screen_width - DESTROYWIDTH - DESTROYSPACING;
- X if((rect.r_top + rect.r_height + 2 * DESTROYSPACING + DESTROYHEIGHT) <
- X screen_height)
- X rect.r_top += (rect.r_height + DESTROYSPACING);
- X else
- X rect.r_top -= (DESTROYHEIGHT + 2 * DESTROYSPACING);
- X destroy_frame = xv_create(main_frame, FRAME_CMD,
- X XV_LABEL, "Destroy Folder",
- X XV_X, rect.r_left,
- X XV_Y, rect.r_top,
- X XV_WIDTH, DESTROYWIDTH,
- X XV_HEIGHT, DESTROYHEIGHT,
- X FRAME_NO_CONFIRM, TRUE,
- X FRAME_DONE_PROC, destroydone,
- X NULL);
- X if(destroy_frame == NULL)
- X {
- X notice_prompt(main_frame, NULL,
- X NOTICE_MESSAGE_STRINGS,
- X "Unable to create sub-frame (internal error)",
- X NULL,
- X NOTICE_BUTTON_YES, "Acknowledge",
- X NOTICE_NO_BEEPING, noticenobeep,
- X NULL);
- X return;
- X }
- X xv_set(destroy_frame, XV_SHOW, TRUE, NULL);
- X
- X destroy_panel = (Panel) xv_get(destroy_frame, FRAME_CMD_PANEL);
- X xv_set(destroy_panel, WIN_RETAINED, FALSE, NULL);
- X
- X (void) xv_create(destroy_panel, PANEL_MESSAGE,
- X XV_X, xv_col(destroy_panel, 0),
- X XV_Y, xv_row(destroy_panel, 0),
- X PANEL_LABEL_STRING, "Destroy Folder",
- X NULL);
- X fldrlist = xv_create(destroy_panel, PANEL_LIST,
- X XV_X, xv_col(destroy_panel, 0),
- X XV_Y, xv_row(destroy_panel, 1),
- X PANEL_LIST_DISPLAY_ROWS, 7,
- X PANEL_LIST_WIDTH, xv_col(destroy_panel, 15),
- X PANEL_CHOOSE_ONE, TRUE,
- X NULL);
- X row = 0;
- X sp = (struct SubDir *) LLM_first(&subdir_rt);
- X while(sp != NULL)
- X {
- X xv_set(fldrlist,
- X PANEL_LIST_INSERT, row,
- X PANEL_LIST_STRING, row, sp->subdir,
- X PANEL_LIST_CLIENT_DATA, row, sp,
- X NULL);
- X sp = (struct SubDir *) LLM_next(&subdir_rt);
- X row++;
- X }
- X
- X
- X destroy_item = xv_create(destroy_panel, PANEL_BUTTON,
- X XV_X, DESTROYWIDTH / 2 - 30,
- X XV_Y, DESTROYHEIGHT - 30,
- X PANEL_LABEL_STRING, "Apply",
- X PANEL_NOTIFY_PROC, applydestroy,
- X NULL);
- X
- X window_fit_height(destroy_panel);
- X
- X (void) xv_set(mitem, MENU_INACTIVE, TRUE, NULL);
- X destroy_up = 1;
- X }
- X
- destroydone()
- X {
- X xv_destroy_safe(destroy_frame);
- X (void) xv_set(destroy_mitem, MENU_INACTIVE, FALSE, NULL);
- X destroy_up = 0;
- X }
- X
- applydestroy(item, event)
- X Panel_item item;
- X Event *event;
- X {
- X Menu_item mitem;
- X struct SubDir *sp;
- X struct Note *np;
- X int i, row;
- X DIR *dp;
- X struct dirent *ent;
- X char buf[MAXBUFLEN];
- X
- X row = xv_get(fldrlist, PANEL_LIST_NROWS);
- X for(i = 0; i < row; i++)
- X {
- X if(xv_get(fldrlist, PANEL_LIST_SELECTED, i))
- X {
- X sp = (struct SubDir *) xv_get(fldrlist, PANEL_LIST_CLIENT_DATA, i);
- X }
- X }
- X
- #ifdef CONFIDENT
- X if(confirmdestroy)
- X {
- #endif
- X if(notice_prompt(destroy_frame, NULL,
- X NOTICE_MESSAGE_STRINGS, "Really destroy this folder?",
- X sp->subdir,
- X "(This action will destroy all notes in the folder)",
- X NULL,
- X NOTICE_BUTTON_YES, "Yes",
- X NOTICE_BUTTON_NO, "No",
- X NOTICE_NO_BEEPING, noticenobeep,
- X NULL) == NOTICE_NO)
- X {
- X if(xv_get(destroy_frame, FRAME_CMD_PUSHPIN_IN) == FALSE)
- X {
- X xv_destroy_safe(destroy_frame);
- X (void) xv_set(destroy_mitem, MENU_INACTIVE, FALSE, NULL);
- X destroy_up = 0;
- X }
- X return;
- X }
- #ifdef CONFIDENT
- X }
- #endif
- X
- X np = (struct Note *) LLM_first(&sp->note_rt);
- X while(np != NULL)
- X {
- X if(np->mapped)
- X {
- X textsw_reset(np->textsw, 0, 0);
- X put_win(np);
- X np->mapped = 0;
- X }
- X np = (struct Note *) LLM_next(&sp->note_rt);
- X }
- X
- X dp = opendir(sp->subdir);
- X if(dp == NULL)
- X {
- X notice_prompt(main_frame, NULL,
- X NOTICE_MESSAGE_STRINGS,
- X "Couldn't read directory",
- X sp->subdir,
- X sys_errlist[errno],
- X NULL,
- X NOTICE_BUTTON_YES, "Acknowledge",
- X NOTICE_NO_BEEPING, noticenobeep,
- X NULL);
- X if(xv_get(destroy_frame, FRAME_CMD_PUSHPIN_IN) == FALSE)
- X {
- X xv_destroy_safe(destroy_frame);
- X (void) xv_set(destroy_mitem, MENU_INACTIVE, FALSE, NULL);
- X destroy_up = 0;
- X }
- X return;
- X }
- X while((ent = readdir(dp)) != NULL)
- X {
- X if(strcmp(ent->d_name, ".") != 0 && strcmp(ent->d_name, "..") != 0)
- X {
- X sprintf(buf, "%s/%s", sp->subdir, ent->d_name);
- X unlink(buf);
- X }
- X }
- X closedir(dp);
- X if(rmdir(sp->subdir) < 0)
- X {
- X notice_prompt(main_frame, NULL,
- X NOTICE_MESSAGE_STRINGS,
- X "Couldn't remove directory",
- X sp->subdir,
- X sys_errlist[errno],
- X NULL,
- X NOTICE_BUTTON_YES, "Acknowledge",
- X NOTICE_NO_BEEPING, noticenobeep,
- X NULL);
- X }
- X
- X mitem = xv_find(main_newnote, MENUITEM, MENU_STRING, sp->subdir, NULL);
- X if(mitem != NULL)
- X {
- X (void) xv_set(main_newnote, MENU_REMOVE_ITEM, mitem, NULL);
- X xv_destroy_safe(mitem);
- X }
- X mitem = xv_find(main_expose, MENUITEM, MENU_STRING, sp->subdir, NULL);
- X if(mitem != NULL)
- X {
- X (void) xv_set(main_expose, MENU_REMOVE_ITEM, mitem, NULL);
- X xv_destroy_safe(mitem);
- X }
- X mitem = xv_find(main_print, MENUITEM, MENU_STRING, sp->subdir, NULL);
- X if(mitem != NULL)
- X {
- X (void) xv_set(main_print, MENU_REMOVE_ITEM, mitem, NULL);
- X xv_destroy_safe(mitem);
- X }
- X
- X LLM_free(&sp->note_rt);
- X LLM_delete(&subdir_rt, sp);
- X
- X refresh_popups();
- X if(xv_get(destroy_frame, FRAME_CMD_PUSHPIN_IN) == FALSE)
- X {
- X xv_destroy_safe(destroy_frame);
- X (void) xv_set(destroy_mitem, MENU_INACTIVE, FALSE, NULL);
- X destroy_up = 0;
- X }
- X }
- X
- refresh_destroy()
- X {
- X int row, i;
- X struct SubDir *sp;
- X
- X if(!destroy_up) return;
- X
- X xv_set(fldrlist, XV_SHOW, FALSE, NULL);
- X
- X row = xv_get(fldrlist, PANEL_LIST_NROWS);
- X for(i = row - 1; i >= 0; i--)
- X xv_set(fldrlist, PANEL_LIST_DELETE, i, NULL);
- X
- X row = 0;
- X sp = (struct SubDir *) LLM_first(&subdir_rt);
- X while(sp != NULL)
- X {
- X xv_set(fldrlist,
- X PANEL_LIST_INSERT, row,
- X PANEL_LIST_STRING, row, sp->subdir,
- X PANEL_LIST_CLIENT_DATA, row, sp,
- X NULL);
- X sp = (struct SubDir *) LLM_next(&subdir_rt);
- X row++;
- X }
- X
- X xv_set(fldrlist, XV_SHOW, TRUE, NULL);
- X }
- SHAR_EOF
- chmod 0644 rmfolder.c ||
- echo 'restore of rmfolder.c failed'
- Wc_c="`wc -c < 'rmfolder.c'`"
- test 8786 -eq "$Wc_c" ||
- echo 'rmfolder.c: original size 8786, current size' "$Wc_c"
- fi
- # ============= rmnote.c ==============
- if test -f 'rmnote.c' -a X"$1" != X"-c"; then
- echo 'x - skipping rmnote.c (File already exists)'
- else
- echo 'x - extracting rmnote.c (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'rmnote.c' &&
- /*
- Post A Note V2.4
- Copyright (c) 1992, Jeffrey W. Bailey
- All rights reserved.
- X
- Permission is granted to distribute this program in exact, complete
- source form, which includes this copyright notice, as long as no fee
- other than media and distribution cost is charged.
- X
- This program may not be used in whole, or in part, in any other manner
- without prior written permission from the author.
- X
- This program may not be distributed in modified form without prior
- written permission from the author. In other words, patches may be
- distributed, but modified source may not be distributed.
- X
- If there are any questions, comments or suggestions, the author may be
- contacted at:
- X
- X jeff@rd1.interlan.com
- X
- X or
- X
- X Jeffrey Bailey
- X Racal-Datacom, Inc.
- X Mail Stop E-110
- X 1601 N. Harrison Parkway
- X Sunrise, FL 33323-2899
- */
- X
- #include "pan.h"
- X
- extern char *malloc();
- extern char *getenv();
- X
- extern int errno;
- extern char *sys_errlist[];
- X
- /*
- X Routine called when the destroy button on a note is selected. Destroys the
- X selected note.
- */
- removenote(item, event)
- X Panel_item item;
- X Event *event;
- X {
- X struct Note *np;
- X int mod;
- X char fname[MAXBUFLEN];
- X
- X np = (struct Note *) xv_get(item, PANEL_CLIENT_DATA);
- X if(confirmdestroy)
- X {
- X if(notice_prompt(np->frame, NULL,
- X NOTICE_MESSAGE_STRINGS, "Really destroy this note?", NULL,
- X NOTICE_BUTTON_YES, "Yes",
- X NOTICE_BUTTON_NO, "No",
- X NOTICE_NO_BEEPING, noticenobeep,
- X NULL) == NOTICE_NO)
- X {
- X return;
- X }
- X }
- X mod = xv_get(np->textsw, TEXTSW_MODIFIED);
- X if(mod)
- X {
- X textsw_reset(np->textsw, 0, 0);
- X }
- X makename(fname, np);
- X (void) unlink(fname);
- X strcat(fname, "%"); /* Attempt to remove the textsw files */
- X (void) unlink(fname);
- X makeinfoname(fname, np);
- X (void) unlink(fname);
- X put_win(np);
- X LLM_delete(&np->sp->note_rt, np);
- X refresh_popups();
- X }
- SHAR_EOF
- chmod 0644 rmnote.c ||
- echo 'restore of rmnote.c failed'
- Wc_c="`wc -c < 'rmnote.c'`"
- test 2035 -eq "$Wc_c" ||
- echo 'rmnote.c: original size 2035, current size' "$Wc_c"
- fi
- true || echo 'restore of search.c failed'
- echo End of part 5, continue with part 6
- exit 0
- --
- --
- Molecular Simulations, Inc. mail: dcmartin@msi.com
- 796 N. Pastoria Avenue uucp: uunet!dcmartin
- Sunnyvale, California 94086 at&t: 408/522-9236
-