home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume21 / pan / part05 < prev    next >
Encoding:
Text File  |  1993-11-08  |  40.5 KB  |  1,350 lines

  1. Newsgroups: comp.sources.x
  2. From: jeff@tasslehoff.interlan.com (Jeff Bailey)
  3. Subject: v21i041:  pan - A post a note program, Part05/06
  4. Message-ID: <1993Nov9.000730.10980@sparky.sterling.com>
  5. X-Md4-Signature: 5c82d394f16ea73400a8de8aeed77d1a
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Tue, 9 Nov 1993 00:07:30 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: jeff@tasslehoff.interlan.com (Jeff Bailey)
  12. Posting-number: Volume 21, Issue 41
  13. Archive-name: pan/part05
  14. Environment: X11, OpenLook, XView
  15. Supersedes: pan: Volume 16, Issue 137-142
  16.  
  17. ---- Cut Here and feed the following to sh ----
  18. #!/bin/sh
  19. # This is part 05 of a multipart archive
  20. # ============= pan3.0/pan.c ==============
  21. if test ! -d 'pan3.0'; then
  22.     echo 'x - creating directory pan3.0'
  23.     mkdir 'pan3.0'
  24. fi
  25. if test -f 'pan3.0/pan.c' -a X"$1" != X"-c"; then
  26.     echo 'x - skipping pan3.0/pan.c (File already exists)'
  27. else
  28. echo 'x - extracting pan3.0/pan.c (Text)'
  29. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/pan.c' &&
  30. X/*
  31. XPost A Note V3.0
  32. XCopyright (c) 1993, Jeffrey W. Bailey
  33. XAll rights reserved.
  34. X
  35. XPermission is granted to distribute this program in exact, complete
  36. Xsource form, which includes this copyright notice, as long as no fee
  37. Xother than media and distribution cost is charged.
  38. X
  39. XThis program may not be used in whole, or in part, in any other manner
  40. Xwithout prior written permission from the author.
  41. X
  42. XThis program may not be distributed in modified form without prior
  43. Xwritten permission from the author.  In other words, patches may be
  44. Xdistributed, but modified source may not be distributed.
  45. X
  46. XIf there are any questions, comments or suggestions, the author may be
  47. Xcontacted at:
  48. X
  49. X    jeff@rd1.interlan.com
  50. X
  51. X    or
  52. X
  53. X    Jeffrey Bailey
  54. X    Racal-Datacom, Inc.
  55. X    Mail Stop E-110
  56. X    1601 N. Harrison Parkway
  57. X    Sunrise, FL  33323-2899
  58. X*/
  59. X
  60. X#define public
  61. X
  62. X#include "pan.h"
  63. X#include "patchlevel.h"
  64. X#include <signal.h>
  65. X
  66. X#include <X11/X.h>
  67. X#include <X11/Xutil.h>
  68. X#include <X11/Xos.h>
  69. X
  70. Xextern int errno;
  71. Xextern char *sys_errlist[];
  72. X
  73. Xint  xverror(), xerror();
  74. X
  75. Xextern char *optarg;
  76. X
  77. Xstatic char init_search_val[MAXSEARCHLEN];
  78. X
  79. XNotify_value aborted();
  80. X
  81. Xmain(argc, argv)
  82. X    int  argc;
  83. X    char *argv[];
  84. X    {
  85. X    Xv_Server server;
  86. X    FILE *fp;
  87. X    char *cp;
  88. X    int  opt;
  89. X
  90. X    debug_on = 0;
  91. X    move_up = 0;
  92. X    destroy_up = 0;
  93. X    search_up = 0;
  94. X    notecount = 0;
  95. X    *init_search_val = 0;
  96. X
  97. X    LLM_init(&subdir_rt, sizeof(struct SubDir));
  98. X    LLM_init(&freewin_rt, sizeof(struct FreeWin));
  99. X
  100. X    strcpy(myname, argv[0]);
  101. X    cp = getenv("HOME");
  102. X    if(cp == NULL)
  103. X        {
  104. X        fprintf(stderr, "%s:  Can't determine value of HOME\n", myname);
  105. X        exit(1);
  106. X        }
  107. X
  108. X    /* If first time run, set up default dirs */
  109. X    sprintf(note_dir, "%s/%s", cp, NOTEDIR);
  110. X    (void) mkdir(note_dir, 0700);
  111. X    sprintf(note_dir, "%s/%s/Miscellaneous", cp, NOTEDIR);
  112. X    (void) mkdir(note_dir, 0700);
  113. X
  114. X    sprintf(note_dir, "%s/%s", cp, NOTEDIR);
  115. X
  116. X    server = xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv,
  117. X        XV_ERROR_PROC, xverror,
  118. X        XV_X_ERROR_PROC, xerror,
  119. X        NULL);
  120. X
  121. X    /* Process the X resources database for what we need */
  122. X    defaults_load_db(NULL);
  123. X
  124. X    cp = defaults_get_string(resources[RES_IDIR].a, resources[RES_IDIR].b,
  125. X         note_dir);
  126. X    if(cp != note_dir)
  127. X        {
  128. X        strcpy(note_dir, cp);
  129. X        }
  130. X
  131. X    while((opt = getopt(argc, argv, "d:x")) != -1)
  132. X        {
  133. X        switch(opt)
  134. X            {
  135. X            case 'd' : /* Initial directory */
  136. X                strcpy(note_dir, optarg);
  137. X                break;
  138. X            case 'x' : /* Turn on debugs.  Undocumented flag */
  139. X                debug_on = 1;
  140. X                break;
  141. X            }
  142. X        }
  143. X
  144. X    if(chdir(note_dir) < 0)
  145. X        {
  146. X        fprintf(stderr, "%s:  Couldn't chdir to %s\n", myname, note_dir);
  147. X        exit(1);
  148. X        }
  149. X
  150. X    fp = fopen(PIDNAM, "w");
  151. X    if(fp != NULL)
  152. X        {
  153. X        fprintf(fp, "%d\n", getpid());
  154. X        (void) fclose(fp);
  155. X        }
  156. X
  157. X    confirmdestroy = (defaults_get_boolean(resources[RES_CDESTROY].a,
  158. X        resources[RES_CDESTROY].b, RESDEF_CDESTROY) == TRUE);
  159. X
  160. X    /* Reverse boolean */
  161. X    noticenobeep = (defaults_get_boolean(resources[RES_NBEEP].a,
  162. X        resources[RES_NBEEP].b, RESDEF_NBEEP) == FALSE);
  163. X
  164. X    icontransparent = (defaults_get_boolean(resources[RES_ITRANSPARENT].a,
  165. X        resources[RES_ITRANSPARENT].b, RESDEF_ITRANSPARENT) == TRUE);
  166. X
  167. X    cp = defaults_get_string(resources[RES_FORDER].a, resources[RES_FORDER].b,
  168. X         RESDEF_FORDER);
  169. X    strcpy(folderorder, cp);
  170. X
  171. X    cp = defaults_get_string(resources[RES_DSEARCH].a, resources[RES_DSEARCH].b,
  172. X         RESDEF_DSEARCH);
  173. X    strcpy(init_search_val, cp);
  174. X
  175. X    fintitle = (defaults_get_boolean(resources[RES_FINTITLE].a,
  176. X        resources[RES_FINTITLE].b, RESDEF_FINTITLE) == TRUE);
  177. X
  178. X    cp = defaults_get_string(resources[RES_TEXTFONT].a,
  179. X         resources[RES_TEXTFONT].b, RESDEF_TEXTFONT);
  180. X    if(cp != NULL)
  181. X        strcpy(textfont, cp);
  182. X    else
  183. X        *textfont = 0;
  184. X
  185. X    windowmax = defaults_get_integer(resources[RES_WINDOWMAX].a,
  186. X        resources[RES_WINDOWMAX].b, RESDEF_WINDOWMAX);
  187. X
  188. X    cp = defaults_get_string(resources[RES_ACTIONDEF].a,
  189. X         resources[RES_ACTIONDEF].b, RESDEF_ACTIONDEF);
  190. X    strcpy(actiondef, cp);
  191. X
  192. X    menutextlen = defaults_get_integer(resources[RES_MENUTEXTLEN].a,
  193. X        resources[RES_MENUTEXTLEN].b, RESDEF_MENUTEXTLEN);
  194. X    if(menutextlen < 5) menutextlen = 5;
  195. X    if(menutextlen > MAXTITLELEN) menutextlen = MAXTITLELEN;
  196. X
  197. X    setwidth = defaults_get_integer(resources[RES_SETWIDTH].a,
  198. X        resources[RES_SETWIDTH].b, RESDEF_SETWIDTH);
  199. X    if(setwidth < 0 || setwidth > 200) setwidth = RESDEF_SETWIDTH;
  200. X    sprintf(widthtext, "Width %d", setwidth);
  201. X
  202. X    logging = (defaults_get_boolean(resources[RES_LOGGING].a,
  203. X        resources[RES_LOGGING].b, RESDEF_LOGGING) == TRUE);
  204. X
  205. X    topmargin = defaults_get_integer(resources[RES_TOPMARGIN].a,
  206. X        resources[RES_TOPMARGIN].b, RESDEF_TOPMARGIN);
  207. X    if(topmargin < 0) topmargin = 0;
  208. X
  209. X    bottommargin = defaults_get_integer(resources[RES_BOTTOMMARGIN].a,
  210. X        resources[RES_BOTTOMMARGIN].b, RESDEF_BOTTOMMARGIN);
  211. X    if(bottommargin < 0) bottommargin = 0;
  212. X
  213. X    leftmargin = defaults_get_integer(resources[RES_LEFTMARGIN].a,
  214. X        resources[RES_LEFTMARGIN].b, RESDEF_LEFTMARGIN);
  215. X    if(leftmargin < 0) leftmargin = 0;
  216. X
  217. X    rightmargin = defaults_get_integer(resources[RES_RIGHTMARGIN].a,
  218. X        resources[RES_RIGHTMARGIN].b, RESDEF_RIGHTMARGIN);
  219. X    if(rightmargin < 0) rightmargin = 0;
  220. X
  221. X    checkinterval = defaults_get_integer(resources[RES_CHECKINTERVAL].a,
  222. X        resources[RES_CHECKINTERVAL].b, RESDEF_CHECKINTERVAL);
  223. X    if(checkinterval < 5) checkinterval = 5;
  224. X
  225. X    cp = defaults_get_string(resources[RES_SEARCHMENU].a,
  226. X         resources[RES_SEARCHMENU].b, RESDEF_SEARCHMENU);
  227. X    strcpy(searchmenu, cp);
  228. X    trim(searchmenu);
  229. X    if(*searchmenu == 0) strcpy(searchmenu, RESDEF_SEARCHMENU);
  230. X
  231. X    notewidth = defaults_get_integer(resources[RES_NOTEWIDTH].a,
  232. X        resources[RES_NOTEWIDTH].b, RESDEF_NOTEWIDTH);
  233. X    noteheight = defaults_get_integer(resources[RES_NOTEHEIGHT].a,
  234. X        resources[RES_NOTEHEIGHT].b, RESDEF_NOTEHEIGHT);
  235. X
  236. X    setup_display();
  237. X#ifdef PAN_DND
  238. X    drag_init(server);
  239. X#endif
  240. X    restorenotes();
  241. X    xv_main_loop(main_frame);
  242. X    (void) unlink(PIDNAM);
  243. X    exit(0);
  244. X    /* NOTREACHED */
  245. X    }
  246. X
  247. X/*
  248. X    Routine to set up main frame and buttons.
  249. X*/
  250. Xsetup_display()
  251. X    {
  252. X    char *cp;
  253. X    struct ps_component *lp, *np;
  254. X    Menu menu;
  255. X    Menu_item mitem;
  256. X    Server_image image, image2;
  257. X    Icon icon;
  258. X    static XClassHint chint;
  259. X    struct itimerval itv;
  260. X    Rect *rect;
  261. X    Panel_item item;
  262. X    int  x, num, mnum;
  263. X
  264. X    main_frame = xv_create(NULL, FRAME,
  265. X                           XV_LABEL, PAN_VERSION,
  266. X                           FRAME_NO_CONFIRM, TRUE,
  267. X                           NULL);
  268. X    if(main_frame == NULL)
  269. X        {
  270. X        fprintf(stderr, "%s:  Couldn't create base frame.\n", myname);
  271. X        exit(1);
  272. X        }
  273. X
  274. X    /* Set up the X class since xview doesn't */
  275. X    chint.res_name = "panmain";
  276. X    chint.res_class = "PanMain";
  277. X    XSetClassHint((Display *)xv_get(main_frame, XV_DISPLAY),
  278. X        xv_get(main_frame, XV_XID), &chint);
  279. X
  280. X    notify_interpose_destroy_func(main_frame, aborted);
  281. X
  282. X    main_panel = (Panel) xv_create(main_frame, PANEL, 
  283. X                     WIN_RETAINED, FALSE, 
  284. X                     NULL);
  285. X
  286. X    main_newnote = xv_create(NULL, MENU,
  287. X                     MENU_NOTIFY_PROC, newnote,
  288. X                     NULL);
  289. X    item = (Panel_item) xv_create(main_panel, PANEL_BUTTON,
  290. X                     PANEL_LABEL_STRING, "New Note", 
  291. X                     PANEL_ITEM_MENU, main_newnote,
  292. X                     XV_X, xv_col(main_panel, 0),
  293. X                     XV_Y, xv_row(main_panel, 0),
  294. X                     NULL);
  295. X    rect = (Rect *) xv_get(item, PANEL_ITEM_RECT);
  296. X    x = rect->r_width + DEFPANELSPACING;
  297. X    
  298. X    item = (Panel_item) xv_create(main_panel, PANEL_BUTTON,
  299. X                     PANEL_LABEL_STRING, "Hide Notes",
  300. X                     PANEL_NOTIFY_PROC, hideall,
  301. X                     XV_X, x,
  302. X                     XV_Y, xv_row(main_panel, 0),
  303. X                     NULL);
  304. X    main_expose = xv_create(NULL, MENU,
  305. X                     MENU_NOTIFY_PROC, exposemenu,
  306. X                     MENU_STRINGS, CHOICE_ALL, NULL,
  307. X                     NULL);
  308. X    item = (Panel_item) xv_create(main_panel, PANEL_BUTTON,
  309. X                     PANEL_LABEL_STRING, "Expose Notes", 
  310. X                     PANEL_ITEM_MENU, main_expose,
  311. X                     XV_X, xv_col(main_panel, 0),
  312. X                     XV_Y, xv_row(main_panel, 1),
  313. X                     NULL);
  314. X    rect = (Rect *) xv_get(item, PANEL_ITEM_RECT);
  315. X    x = rect->r_width + DEFPANELSPACING;
  316. X
  317. X    main_print = xv_create(NULL, MENU,
  318. X                     MENU_NOTIFY_PROC, actionmenu,
  319. X                     NULL);
  320. X    menu = xv_create(NULL, MENU,
  321. X                     MENU_NOTIFY_PROC, actionmenu,
  322. X                     MENU_ITEM,
  323. X                         MENU_STRING, CHOICE_FOLDER,
  324. X                         MENU_NOTIFY_PROC, createfolder,
  325. X                         NULL,
  326. X                     MENU_ITEM,
  327. X                         MENU_STRING, CHOICE_MOVE,
  328. X                         MENU_NOTIFY_PROC, movenote,
  329. X                         NULL,
  330. X                     MENU_ITEM,
  331. X                         MENU_STRING, CHOICE_PRINT,
  332. X                         MENU_PULLRIGHT, main_print,
  333. X                         NULL,
  334. X                     MENU_ITEM,
  335. X                         MENU_STRING, CHOICE_DESTROY,
  336. X                         MENU_NOTIFY_PROC, destroyfolder,
  337. X                         NULL,
  338. X                     MENU_ITEM,
  339. X                         MENU_STRING, CHOICE_QUIT,
  340. X                         NULL,
  341. X                     NULL);
  342. X    mitem = (Menu_item) xv_find(menu, MENUITEM,
  343. X                                MENU_STRING, actiondef,
  344. X                                XV_AUTO_CREATE, FALSE,
  345. X                                NULL);
  346. X    if(mitem)
  347. X        {
  348. X        mnum = xv_get(menu, MENU_NITEMS);
  349. X        num = 0;
  350. X        while(!num && mnum)
  351. X            {
  352. X            if(mitem == (Menu_item) xv_get(menu, MENU_NTH_ITEM, mnum))
  353. X                num = mnum;
  354. X            mnum--;
  355. X            }
  356. X        xv_set(menu, MENU_DEFAULT, num, NULL);
  357. X        }
  358. X
  359. X    item = (Panel_item) xv_create(main_panel, PANEL_BUTTON,
  360. X                     PANEL_LABEL_STRING, "Action",
  361. X                     PANEL_ITEM_MENU, menu,
  362. X                     XV_X, x,
  363. X                     XV_Y, xv_row(main_panel, 1),
  364. X                     NULL);
  365. X
  366. X    search_item = xv_create(main_panel, PANEL_TEXT,
  367. X                     PANEL_LABEL_STRING, "Search:",
  368. X                     PANEL_VALUE, init_search_val,
  369. X                     PANEL_VALUE_DISPLAY_LENGTH, MAXSEARCHDISLEN + 1,
  370. X                     PANEL_VALUE_STORED_LENGTH, MAXSEARCHLEN,
  371. X                     PANEL_NOTIFY_PROC, notesearch,
  372. X                     XV_X, xv_col(main_panel, 0),
  373. X                     XV_Y, xv_row(main_panel, 2),
  374. X                     NULL);
  375. X
  376. X    rect = (Rect *) xv_get(search_item, PANEL_ITEM_RECT);
  377. X    x = rect->r_width + DEFPANELSPACING;
  378. X
  379. X    menu = xv_create(NULL, MENU,
  380. X                     MENU_NOTIFY_PROC, search_menu_proc,
  381. X                     NULL);
  382. X    lp = parse_string(searchmenu, ", \t\n", 1, 1, 1);
  383. X    np = lp;
  384. X    while(np != NULL)
  385. X        {
  386. X        cp = malloc(strlen(np->ps_text) + 1);
  387. X        if(cp == NULL)
  388. X            {
  389. X            fprintf(stderr, "%s:  Couldn't allocate memory.\n", myname);
  390. X            exit(1);
  391. X            }
  392. X        strcpy(cp, np->ps_text);
  393. X        mitem = xv_create(NULL, MENUITEM,
  394. X            MENU_STRING, cp,
  395. X            MENU_RELEASE,
  396. X            MENU_RELEASE_IMAGE,
  397. X            NULL);
  398. X        xv_set(menu, MENU_APPEND_ITEM, mitem, NULL);
  399. X        np = np->ps_next;
  400. X        }
  401. X    free_ps_list(lp);
  402. X    search_button = (Panel_item) xv_create(main_panel, PANEL_ABBREV_MENU_BUTTON,
  403. X                     PANEL_ITEM_MENU, menu,
  404. X                     XV_X, x,
  405. X                     XV_Y, xv_row(main_panel, 2),
  406. X                     NULL);
  407. X
  408. X    image = xv_create(NULL, SERVER_IMAGE, XV_WIDTH, 64, XV_HEIGHT, 64,
  409. X                      SERVER_IMAGE_BITS, mainicon, NULL);
  410. X    image2 = xv_create(NULL, SERVER_IMAGE, XV_WIDTH, 64, XV_HEIGHT, 64,
  411. X                      SERVER_IMAGE_BITS, mainiconmask, NULL);
  412. X    icon = xv_create(main_frame, ICON,
  413. X                     ICON_IMAGE, image,
  414. X                     ICON_MASK_IMAGE, image2,
  415. X                     ICON_LABEL, "Notes",
  416. X                     ICON_TRANSPARENT, icontransparent,
  417. X                     NULL);
  418. X    xv_set(main_frame, FRAME_ICON, icon, NULL);
  419. X    window_fit(main_panel);
  420. X    window_fit(main_frame);
  421. X
  422. X    itv.it_interval.tv_sec = checkinterval;
  423. X    itv.it_interval.tv_usec = 0;
  424. X    itv.it_value.tv_sec = checkinterval;
  425. X    itv.it_value.tv_usec = 0;
  426. X    notify_set_itimer_func(main_frame, check_ctl_file, ITIMER_REAL, &itv, NULL);
  427. X
  428. X    notify_set_signal_func(main_frame, check_ctl_file, SIGUSR1, NOTIFY_SYNC);
  429. X
  430. X    init_menu_string_normalize();
  431. X    }
  432. X
  433. XNotify_value aborted(client, status)
  434. X    Notify_client client;
  435. X    Destroy_status status;
  436. X    {
  437. X    struct SubDir *sp;
  438. X    struct Note *np;
  439. X    if(status == DESTROY_CHECKING) return(NOTIFY_DONE);
  440. X
  441. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  442. X    while(sp != NULL)
  443. X        {
  444. X        np = (struct Note *) LLM_first(&sp->note_rt);
  445. X        while(np != NULL)
  446. X            {
  447. X            update(np);
  448. X            np = (struct Note *) LLM_next(&sp->note_rt);
  449. X            }
  450. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  451. X        }
  452. X
  453. X    if(status == DESTROY_CLEANUP)
  454. X        return(notify_next_destroy_func(client, status));
  455. X
  456. X    return(NOTIFY_DONE);
  457. X    }
  458. X
  459. X/*
  460. X    Routine called to safely cleanup and exit pan.  Called by Action Quit menu
  461. X    item.
  462. X*/
  463. Xcleanup(errnum)
  464. X    int  errnum;
  465. X    {
  466. X    struct SubDir *sp;
  467. X    struct Note *np;
  468. X
  469. X    sp = (struct SubDir *) LLM_first(&subdir_rt);
  470. X    while(sp != NULL)
  471. X        {
  472. X        np = (struct Note *) LLM_first(&sp->note_rt);
  473. X        while(np != NULL)
  474. X            {
  475. X            update(np);
  476. X            updateinfo(np, NOFORCE);
  477. X            np = (struct Note *) LLM_next(&sp->note_rt);
  478. X            }
  479. X        sp = (struct SubDir *) LLM_next(&subdir_rt);
  480. X        }
  481. X    xv_destroy_safe(main_frame);
  482. X    (void) unlink(PIDNAM);
  483. X    exit(errnum);
  484. X    }
  485. X
  486. X/*
  487. X    Scan the notes directory and locate all notes.  Create frames of the
  488. X    appropriate attributes for any notes found.  Called on startup or
  489. X    folder change.
  490. X*/
  491. Xrestorenotes()
  492. X    {
  493. X    int  found;
  494. X    char *cp;
  495. X    DIR *dp;
  496. X    struct dirent *ent;
  497. X    struct stat st;
  498. X    struct Note *np;
  499. X    struct SubDir *sp;
  500. X    struct ps_component *list, *tok;
  501. X    Menu_item mi;
  502. X    char buf[MAXBUFLEN];
  503. X
  504. X    /* parse requested order */
  505. X    list = parse_string(folderorder, ", \t", 0, 0, 0);
  506. X    if(list != NULL)
  507. X        {
  508. X        tok = list;
  509. X        while(tok != NULL)
  510. X            {
  511. X            if(stat(tok->ps_text, &st) == 0 && (S_IFMT & st.st_mode) == S_IFDIR)
  512. X                {
  513. X                sp = (struct SubDir *)LLM_add(&subdir_rt);
  514. X                if(sp == NULL)
  515. X                    {
  516. X                    notice_prompt(main_frame, NULL,
  517. X                        NOTICE_MESSAGE_STRINGS,
  518. X                            "Insufficient memory - Exiting",
  519. X                            sys_errlist[errno],
  520. X                            NULL,
  521. X                        NOTICE_BUTTON_YES, "Acknowledge",
  522. X                        NOTICE_NO_BEEPING, noticenobeep,
  523. X                        NULL);
  524. X                    cleanup(1);
  525. X                    }
  526. X                strcpy(sp->subdir, tok->ps_text);
  527. X                LLM_init(&sp->note_rt, sizeof(struct Note));
  528. X                mi = xv_create(NULL, MENUITEM,
  529. X                    MENU_STRING, sp->subdir,
  530. X                    MENU_NOTIFY_PROC, newnote,
  531. X                    NULL);
  532. X                xv_set(main_newnote, MENU_APPEND_ITEM, mi, NULL);
  533. X                mi = xv_create(NULL, MENUITEM,
  534. X                    MENU_STRING, sp->subdir,
  535. X                    MENU_GEN_PULLRIGHT, gen_exposemenu,
  536. X                    NULL);
  537. X                xv_set(main_expose, MENU_APPEND_ITEM, mi, NULL);
  538. X                mi = xv_create(NULL, MENUITEM,
  539. X                    MENU_STRING, sp->subdir,
  540. X                    MENU_GEN_PULLRIGHT, gen_prtmenu,
  541. X                    NULL);
  542. X                xv_set(main_print, MENU_APPEND_ITEM, mi, NULL);
  543. X                }
  544. X            tok = tok->ps_next;
  545. X            }
  546. X        free_ps_list(list);
  547. X        }
  548. X
  549. X    dp = opendir(note_dir);
  550. X    if(dp == NULL)
  551. X        {
  552. X        notice_prompt(main_frame, NULL,
  553. X            NOTICE_MESSAGE_STRINGS,
  554. X                "Couldn't read directory",
  555. X                note_dir,
  556. X                sys_errlist[errno],
  557. X                NULL,
  558. X            NOTICE_BUTTON_YES, "Acknowledge",
  559. X            NOTICE_NO_BEEPING, noticenobeep,
  560. X            NULL);
  561. X        return;
  562. X        }
  563. X    (void) re_comp("Note_[0-9][0-9]*.*\\.info$");
  564. X    while((ent = readdir(dp)) != NULL)
  565. X        {
  566. X        if(*ent->d_name != '.' && stat(ent->d_name, &st) == 0 &&
  567. X           (S_IFMT & st.st_mode) == S_IFDIR)
  568. X            {
  569. X            found = 0;
  570. X            sp = (struct SubDir *)LLM_first(&subdir_rt);
  571. X            while(sp != NULL)
  572. X                {
  573. X                if(strcmp(ent->d_name, sp->subdir) == 0)/* already processed */
  574. X                    {
  575. X                    found = 1;
  576. X                    break;
  577. X                    }
  578. X                sp = (struct SubDir *)LLM_next(&subdir_rt);
  579. X                }
  580. X            if(found) continue;
  581. X            sp = (struct SubDir *)LLM_add(&subdir_rt);
  582. X            if(sp == NULL)
  583. X                {
  584. X                notice_prompt(main_frame, NULL,
  585. X                    NOTICE_MESSAGE_STRINGS,
  586. X                        "Insufficient memory - Exiting",
  587. X                        sys_errlist[errno],
  588. X                        NULL,
  589. X                    NOTICE_BUTTON_YES, "Acknowledge",
  590. X                    NOTICE_NO_BEEPING, noticenobeep,
  591. X                    NULL);
  592. X                cleanup(1);
  593. X                }
  594. X            strcpy(sp->subdir, ent->d_name);
  595. X            LLM_init(&sp->note_rt, sizeof(struct Note));
  596. X            mi = xv_create(NULL, MENUITEM,
  597. X                MENU_STRING, sp->subdir,
  598. X                MENU_NOTIFY_PROC, newnote,
  599. X                NULL);
  600. X            xv_set(main_newnote, MENU_APPEND_ITEM, mi, NULL);
  601. X            mi = xv_create(NULL, MENUITEM,
  602. X                MENU_STRING, sp->subdir,
  603. X                MENU_GEN_PULLRIGHT, gen_exposemenu,
  604. X                NULL);
  605. X            xv_set(main_expose, MENU_APPEND_ITEM, mi, NULL);
  606. X            mi = xv_create(NULL, MENUITEM,
  607. X                MENU_STRING, sp->subdir,
  608. X                MENU_GEN_PULLRIGHT, gen_prtmenu,
  609. X                NULL);
  610. X            xv_set(main_print, MENU_APPEND_ITEM, mi, NULL);
  611. X            }
  612. X        }
  613. X    closedir(dp);
  614. X    sp = (struct SubDir *)LLM_first(&subdir_rt);
  615. X    while(sp != NULL)
  616. X        {
  617. X        sprintf(buf, "%s/%s", note_dir, sp->subdir);
  618. X        dp = opendir(buf);
  619. X        if(dp == NULL)
  620. X            {
  621. X            notice_prompt(main_frame, NULL,
  622. X                NOTICE_MESSAGE_STRINGS,
  623. X                    "Couldn't read directory",
  624. X                    note_dir,
  625. X                    sys_errlist[errno],
  626. X                    NULL,
  627. X                NOTICE_BUTTON_YES, "Acknowledge",
  628. X                NOTICE_NO_BEEPING, noticenobeep,
  629. X                NULL);
  630. X            }
  631. X        else
  632. X            {
  633. X            while((ent = readdir(dp)) != NULL)
  634. X                {
  635. X                if(re_exec(ent->d_name) == 1)
  636. X                    {
  637. X                    np = (struct Note *)LLM_add(&sp->note_rt);
  638. X                    if(np == NULL)
  639. X                        {
  640. X                        notice_prompt(main_frame, NULL,
  641. X                            NOTICE_MESSAGE_STRINGS,
  642. X                                "Insufficient memory - Exiting",
  643. X                                note_dir,
  644. X                                sys_errlist[errno],
  645. X                                NULL,
  646. X                            NOTICE_BUTTON_YES, "Acknowledge",
  647. X                            NOTICE_NO_BEEPING, noticenobeep,
  648. X                            NULL);
  649. X                        cleanup(1);
  650. X                        }
  651. X                    memset((char *)np, 0, sizeof(struct Note));
  652. X                    np->sp = sp;
  653. X                    strcpy(np->basename, ent->d_name);
  654. X                    cp = np->basename;
  655. X                    while(*cp)
  656. X                        {
  657. X                        if(*cp == '.') *cp = 0;
  658. X                        cp++;
  659. X                        }
  660. X                    setnote(np);
  661. X                    adjust_sorted(np);
  662. X                    }
  663. X                }
  664. X            closedir(dp);
  665. X            }
  666. X        sp = (struct SubDir *)LLM_next(&subdir_rt);
  667. X        }
  668. X    }
  669. X
  670. X/*
  671. X   Trims trailing blanks, tabs, newlines, and carriage returns from a string 
  672. X*/
  673. X
  674. Xtrim(start)
  675. X    register char *start;
  676. X    {
  677. X    register int  slen;
  678. X    register char *end;
  679. X
  680. X    slen = strlen(start);
  681. X    if(slen == 0) return;
  682. X    end = start + slen - 1;
  683. X    while( (*end == ' ' || *end == '\t' || *end == '\n' || *end == '\r')
  684. X           && end >= start) end--;
  685. X    end++;
  686. X    *end = '\0';
  687. X    }
  688. X
  689. X/* Searches for first occurrence of spattern in string */
  690. X
  691. Xchar *instr(string, spattern)
  692. X    char *string;
  693. X    char *spattern;
  694. X    {
  695. X    register char *pos1, *pos2;
  696. X
  697. X    while(*string != '\0')
  698. X        {
  699. X        pos1 = string;
  700. X        pos2 = spattern;
  701. X        while(*pos1 == *pos2)
  702. X            {
  703. X            pos1++;
  704. X            pos2++;
  705. X            if(*pos2 == '\0') return(string);
  706. X            }
  707. X        string++;
  708. X        }
  709. X    return(NULL);
  710. X    }
  711. X
  712. Xxverror(obj, list)
  713. X    Xv_object obj;
  714. X    Attr_avlist list;
  715. X    {
  716. X    fprintf(stderr, "XView error:  %s\n", xv_error_format(obj, list));
  717. X    kill(getpid(), SIGBUS);
  718. X    }
  719. X
  720. Xxerror()
  721. X    {
  722. X    if(fork() == 0)
  723. X        kill(getpid(), SIGBUS);
  724. X    return(XV_ERROR);
  725. X    }
  726. SHAR_EOF
  727. chmod 0644 pan3.0/pan.c ||
  728. echo 'restore of pan3.0/pan.c failed'
  729. Wc_c="`wc -c < 'pan3.0/pan.c'`"
  730. test 21826 -eq "$Wc_c" ||
  731.     echo 'pan3.0/pan.c: original size 21826, current size' "$Wc_c"
  732. fi
  733. # ============= pan3.0/update.c ==============
  734. if test -f 'pan3.0/update.c' -a X"$1" != X"-c"; then
  735.     echo 'x - skipping pan3.0/update.c (File already exists)'
  736. else
  737. echo 'x - extracting pan3.0/update.c (Text)'
  738. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/update.c' &&
  739. X/*
  740. XPost A Note V3.0
  741. XCopyright (c) 1993, Jeffrey W. Bailey
  742. XAll rights reserved.
  743. X
  744. XPermission is granted to distribute this program in exact, complete
  745. Xsource form, which includes this copyright notice, as long as no fee
  746. Xother than media and distribution cost is charged.
  747. X
  748. XThis program may not be used in whole, or in part, in any other manner
  749. Xwithout prior written permission from the author.
  750. X
  751. XThis program may not be distributed in modified form without prior
  752. Xwritten permission from the author.  In other words, patches may be
  753. Xdistributed, but modified source may not be distributed.
  754. X
  755. XIf there are any questions, comments or suggestions, the author may be
  756. Xcontacted at:
  757. X
  758. X    jeff@rd1.interlan.com
  759. X
  760. X    or
  761. X
  762. X    Jeffrey Bailey
  763. X    Racal-Datacom, Inc.
  764. X    Mail Stop E-110
  765. X    1601 N. Harrison Parkway
  766. X    Sunrise, FL  33323-2899
  767. X*/
  768. X
  769. X#include "pan.h"
  770. X
  771. Xextern int errno;
  772. Xextern char *sys_errlist[];
  773. X
  774. X/*
  775. X    Routine called when an update of the notes size and position and title
  776. X    is desired.  Only write to a file if changes have been made or the
  777. X    force flag is set.
  778. X*/
  779. Xupdateinfo(np, force)
  780. X    struct Note *np;
  781. X    int  force;
  782. X    {
  783. X    int  closed;
  784. X    FILE *fp;
  785. X    Rect rect;
  786. X    char fname[MAXBUFLEN];
  787. X
  788. X    if(!np->mapped) return;
  789. X    closed = xv_get(np->frame, FRAME_CLOSED);
  790. X    if(!closed)
  791. X        {
  792. X        frame_get_rect(np->frame, &rect);
  793. X        if(force != FORCE)
  794. X            {
  795. X            if(np->rect.r_left == rect.r_left &&
  796. X               np->rect.r_top == rect.r_top &&
  797. X               np->rect.r_width == rect.r_width &&
  798. X               np->rect.r_height == rect.r_height)
  799. X                {
  800. X                return;
  801. X                }
  802. X            }
  803. X        memcpy((char *)&np->rect, (char *)&rect, sizeof(rect));
  804. X        }
  805. X    makeinfoname(fname, np);
  806. X    fp = fopen(fname, "w");
  807. X    if(fp != NULL)
  808. X        {
  809. X        if(np->state == Hidden)
  810. X            fprintf(fp, "%d\t%d\t%d\t%d\tHIDDEN\n", np->rect.r_left,
  811. X                np->rect.r_top, np->rect.r_width, np->rect.r_height);
  812. X        else
  813. X            fprintf(fp, "%d\t%d\t%d\t%d\tVISIBLE\n", np->rect.r_left,
  814. X                np->rect.r_top, np->rect.r_width, np->rect.r_height);
  815. X        fprintf(fp, "%s\n", np->ntitle);
  816. X        fprintf(fp, "%d\n", np->crttime);
  817. X        fclose(fp);
  818. X        }
  819. X    else
  820. X        {
  821. X        notice_prompt(main_frame, NULL,
  822. X            NOTICE_MESSAGE_STRINGS,
  823. X                "Couldn't open note geometry file",
  824. X                fname,
  825. X                sys_errlist[errno],
  826. X                NULL,
  827. X            NOTICE_BUTTON_YES, "Acknowledge",
  828. X            NOTICE_NO_BEEPING, noticenobeep,
  829. X            NULL);
  830. X        }
  831. X    }
  832. X
  833. X/*
  834. X    Called when a save of the note text is desired.  Only writes to the file
  835. X    if modifications have been made.
  836. X*/
  837. Xupdate(np)
  838. X    struct Note *np;
  839. X    {
  840. X    int  mod;
  841. X    char fname[MAXBUFLEN];
  842. X
  843. X    if(!np->mapped) return(0);
  844. X    mod = xv_get(np->textsw, TEXTSW_MODIFIED);
  845. X    if(mod)
  846. X        {
  847. X        xv_set(np->textsw, TEXTSW_CONFIRM_OVERWRITE, FALSE, NULL);
  848. X        makename(fname, np);
  849. X        textsw_store_file(np->textsw, fname, 0, 0);
  850. X        }
  851. X    return(mod);
  852. X    }
  853. X
  854. X/*
  855. X    Make a note file name.
  856. X*/
  857. Xmakename(fname, np)
  858. X    char *fname;
  859. X    struct Note *np;
  860. X    {
  861. X    struct SubDir *sp;
  862. X
  863. X    sp = np->sp;
  864. X    sprintf(fname, "%s/%s/%s", note_dir, sp->subdir, np->basename);
  865. X    }
  866. X
  867. X/*
  868. X    Make a note information file name.
  869. X*/
  870. Xmakeinfoname(fname, np)
  871. X    char *fname;
  872. X    struct Note *np;
  873. X    {
  874. X    struct SubDir *sp;
  875. X
  876. X    sp = np->sp;
  877. X    sprintf(fname, "%s/%s/%s.info", note_dir, sp->subdir, np->basename);
  878. X    }
  879. SHAR_EOF
  880. chmod 0644 pan3.0/update.c ||
  881. echo 'restore of pan3.0/update.c failed'
  882. Wc_c="`wc -c < 'pan3.0/update.c'`"
  883. test 3543 -eq "$Wc_c" ||
  884.     echo 'pan3.0/update.c: original size 3543, current size' "$Wc_c"
  885. fi
  886. # ============= pan3.0/search.c ==============
  887. if test -f 'pan3.0/search.c' -a X"$1" != X"-c"; then
  888.     echo 'x - skipping pan3.0/search.c (File already exists)'
  889. else
  890. echo 'x - extracting pan3.0/search.c (Text)'
  891. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/search.c' &&
  892. X/*
  893. XPost A Note V3.0
  894. XCopyright (c) 1993, Jeffrey W. Bailey
  895. XAll rights reserved.
  896. X
  897. XPermission is granted to distribute this program in exact, complete
  898. Xsource form, which includes this copyright notice, as long as no fee
  899. Xother than media and distribution cost is charged.
  900. X
  901. XThis program may not be used in whole, or in part, in any other manner
  902. Xwithout prior written permission from the author.
  903. X
  904. XThis program may not be distributed in modified form without prior
  905. Xwritten permission from the author.  In other words, patches may be
  906. Xdistributed, but modified source may not be distributed.
  907. X
  908. XIf there are any questions, comments or suggestions, the author may be
  909. Xcontacted at:
  910. X
  911. X    jeff@rd1.interlan.com
  912. X
  913. X    or
  914. X
  915. X    Jeffrey Bailey
  916. X    Racal-Datacom, Inc.
  917. X    Mail Stop E-110
  918. X    1601 N. Harrison Parkway
  919. X    Sunrise, FL  33323-2899
  920. X*/
  921. X
  922. X#include "pan.h"
  923. X#include <X11/X.h>
  924. X#include <X11/Xutil.h>
  925. X
  926. Xextern int errno;
  927. Xextern char *sys_errlist[];
  928. X
  929. Xint applysearch(), searchdone(), search_resize_proc();
  930. XPanel_item srchlist, srchapply;
  931. X
  932. Xstatic char re [MAXSEARCHLEN + 1];
  933. X
  934. Xnotesearch(item, event) /* don't use event without mods to search_menu_proc */
  935. X    Panel_item item;
  936. X    Event *event;
  937. X    {
  938. X    struct LLM_root root;
  939. X    struct Note *np;
  940. X    struct Note **npp;
  941. X    int  count;
  942. X    char buf [MAXSEARCHLEN + 1];
  943. X
  944. X    count = 0;
  945. X
  946. X    strcpy(buf, (char *) xv_get(item, PANEL_VALUE));
  947. X    trim(buf);
  948. X    if(strlen(buf) == 0)
  949. X        {
  950. X        notice_prompt(main_frame, NULL,
  951. X            NOTICE_MESSAGE_STRINGS,
  952. X                "No search string entered",
  953. X                NULL,
  954. X            NOTICE_BUTTON_YES, "Acknowledge",
  955. X            NOTICE_NO_BEEPING, noticenobeep,
  956. X            NULL);
  957. X        return;
  958. X        }
  959. X    strcpy(re, buf);
  960. X    count = w_matchingnotes(&root, re, 1);
  961. X    if(count == -1)
  962. X        {
  963. X        notice_prompt(main_frame, NULL,
  964. X            NOTICE_MESSAGE_STRINGS,
  965. X                "Invalid regular expression entered",
  966. X                NULL,
  967. X            NOTICE_BUTTON_YES, "Acknowledge",
  968. X            NOTICE_NO_BEEPING, noticenobeep,
  969. X            NULL);
  970. X        return;
  971. X        }
  972. X    if(count == -2)
  973. X        {
  974. X        notice_prompt(main_frame, NULL,
  975. X            NOTICE_MESSAGE_STRINGS,
  976. X                "Memory allocation failure",
  977. X                sys_errlist[errno],
  978. X                NULL,
  979. X            NOTICE_BUTTON_YES, "Acknowledge",
  980. X            NOTICE_NO_BEEPING, noticenobeep,
  981. X            NULL);
  982. X        LLM_free(&root);
  983. X        return;
  984. X        }
  985. X    if(count == 0)
  986. X        {
  987. X        notice_prompt(main_frame, NULL,
  988. X            NOTICE_MESSAGE_STRINGS,
  989. X                "No hidden notes matching search string found",
  990. X                NULL,
  991. X            NOTICE_BUTTON_YES, "Acknowledge",
  992. X            NOTICE_NO_BEEPING, noticenobeep,
  993. X            NULL);
  994. X        return;
  995. X        }
  996. X    if(count == 1)
  997. X        {
  998. X        npp = (struct Note **) LLM_first(&root);
  999. X        np = *npp;
  1000. X        w_exposenote(np, ERRONDISPLAY);
  1001. X        }
  1002. X    else
  1003. X        {
  1004. X        postsearch(&root);
  1005. X        }
  1006. X    LLM_free(&root);
  1007. X    }
  1008. X
  1009. Xpostsearch(root)
  1010. X    struct LLM_root *root;
  1011. X    {
  1012. X    struct Note **npp;
  1013. X    int  x, y;
  1014. X    int  row;
  1015. X    Panel search_panel;
  1016. X    static XClassHint chint;
  1017. X
  1018. X    w_popupxy(&x, &y, SEARCHWIDTH, SEARCHHEIGHT, SEARCHSPACING);
  1019. X    search_frame = xv_create(main_frame, FRAME_CMD,
  1020. X                           XV_LABEL, "Matching Notes",
  1021. X                           XV_X, x,
  1022. X                           XV_Y, y,
  1023. X                           XV_WIDTH, SEARCHWIDTH,
  1024. X                           XV_HEIGHT, SEARCHHEIGHT,
  1025. X                           FRAME_NO_CONFIRM, TRUE,
  1026. X                           FRAME_DONE_PROC, searchdone,
  1027. X                           FRAME_SHOW_RESIZE_CORNER, TRUE,
  1028. X                           WIN_EVENT_PROC, search_resize_proc,
  1029. X                           WIN_CONSUME_EVENTS,
  1030. X                               WIN_RESIZE,
  1031. X                               NULL,
  1032. X                           NULL);
  1033. X    if(search_frame == NULL)
  1034. X        {
  1035. X        notice_prompt(main_frame, NULL,
  1036. X            NOTICE_MESSAGE_STRINGS,
  1037. X                "Unable to create sub-frame (internal error)",
  1038. X                NULL,
  1039. X            NOTICE_BUTTON_YES, "Acknowledge",
  1040. X            NOTICE_NO_BEEPING, noticenobeep,
  1041. X            NULL);
  1042. X        return;
  1043. X        }
  1044. X
  1045. X    /* Set up the X class since xview doesn't */
  1046. X    chint.res_name = "pan";
  1047. X    chint.res_class = "Pan";
  1048. X    XSetClassHint((Display *)xv_get(search_frame, XV_DISPLAY),
  1049. X        xv_get(search_frame, XV_XID), &chint);
  1050. X
  1051. X    xv_set(search_frame, XV_SHOW, TRUE, NULL);
  1052. X
  1053. X    search_panel = (Panel) xv_get(search_frame, FRAME_CMD_PANEL);
  1054. X    xv_set(search_panel, WIN_RETAINED, FALSE, NULL);
  1055. X
  1056. X    (void) xv_create(search_panel, PANEL_MESSAGE,
  1057. X        XV_X, xv_col(search_panel, 0),
  1058. X        XV_Y, xv_row(search_panel, 0),
  1059. X        PANEL_LABEL_STRING, "Matching Notes",
  1060. X        NULL);
  1061. X    srchlist = xv_create(search_panel, PANEL_LIST,
  1062. X        XV_X, xv_col(search_panel, 0),
  1063. X        XV_Y, xv_row(search_panel, 1),
  1064. X        PANEL_LIST_DISPLAY_ROWS, 7,
  1065. X        PANEL_LIST_WIDTH, xv_col(search_panel, 25),
  1066. X        PANEL_CHOOSE_ONE, FALSE,
  1067. X        PANEL_READ_ONLY, TRUE,
  1068. X        NULL);
  1069. X    row = 0;
  1070. X    npp = (struct Note **) LLM_first(root);
  1071. X    while(npp != NULL)
  1072. X        {
  1073. X        xv_set(srchlist,
  1074. X            PANEL_LIST_INSERT, row,
  1075. X            PANEL_LIST_STRING, row, (*npp)->ntitle, 
  1076. X            PANEL_LIST_CLIENT_DATA, row, *npp, 
  1077. X            NULL);
  1078. X        npp = (struct Note **) LLM_next(root);
  1079. X        row++;
  1080. X        }
  1081. X
  1082. X
  1083. X    srchapply = xv_create(search_panel, PANEL_BUTTON,
  1084. X                 XV_X, SEARCHWIDTH / 2 - 30,
  1085. X                 XV_Y, SEARCHHEIGHT - 30,
  1086. X                 PANEL_LABEL_STRING, "Apply",
  1087. X                 PANEL_NOTIFY_PROC, applysearch,
  1088. X                 NULL);
  1089. X
  1090. X    (void) xv_set(search_item, PANEL_INACTIVE, TRUE, NULL);
  1091. X    (void) xv_set(search_button, PANEL_INACTIVE, TRUE, NULL);
  1092. X    search_up = 1;
  1093. X    }
  1094. X
  1095. Xsearchdone()
  1096. X    {
  1097. X    xv_destroy_safe(search_frame);
  1098. X    (void) xv_set(search_item, PANEL_INACTIVE, FALSE, NULL);
  1099. X    (void) xv_set(search_button, PANEL_INACTIVE, FALSE, NULL);
  1100. X    (void) xv_set(main_panel, PANEL_CARET_ITEM, search_item, NULL);
  1101. X    search_up = 0;
  1102. X    }
  1103. X
  1104. Xapplysearch(item, event)
  1105. X    Panel_item item;
  1106. X    Event *event;
  1107. X    {
  1108. X    struct Note *np;
  1109. X    int  i, row;
  1110. X
  1111. X    row = xv_get(srchlist, PANEL_LIST_NROWS);
  1112. X    for(i = 0; i < row; i++)
  1113. X        {
  1114. X        if(xv_get(srchlist, PANEL_LIST_SELECTED, i))
  1115. X            {
  1116. X            np = (struct Note *) xv_get(srchlist, PANEL_LIST_CLIENT_DATA, i);
  1117. X            if(np != NULL) w_exposenote(np, ERRONDISPLAY);
  1118. X            }
  1119. X        }
  1120. X    if(xv_get(search_frame, FRAME_CMD_PUSHPIN_IN) == FALSE)
  1121. X        {
  1122. X        xv_destroy_safe(search_frame);
  1123. X        (void) xv_set(search_item, PANEL_INACTIVE, FALSE, NULL);
  1124. X        (void) xv_set(search_button, PANEL_INACTIVE, FALSE, NULL);
  1125. X        (void) xv_set(main_panel, PANEL_CARET_ITEM, search_item, NULL);
  1126. X        search_up = 0;
  1127. X        }
  1128. X    refresh_popups();
  1129. X    }
  1130. X
  1131. Xrefresh_search()
  1132. X    {
  1133. X    struct LLM_root root;
  1134. X    struct Note **npp;
  1135. X    int  i;
  1136. X    int  row;
  1137. X
  1138. X    if(!search_up) return;
  1139. X
  1140. X    xv_set(srchlist, XV_SHOW, FALSE, NULL);
  1141. X
  1142. X    row = xv_get(srchlist, PANEL_LIST_NROWS);
  1143. X    for(i = row - 1; i >= 0; i--)
  1144. X        {
  1145. X        xv_set(srchlist, PANEL_LIST_DELETE, i, NULL);
  1146. X        }
  1147. X
  1148. X    w_matchingnotes(&root, re, 1);
  1149. X    row = 0;
  1150. X    npp = (struct Note **) LLM_first(&root);
  1151. X    while(npp != NULL)
  1152. X        {
  1153. X        xv_set(srchlist,
  1154. X            PANEL_LIST_INSERT, row,
  1155. X            PANEL_LIST_STRING, row, (*npp)->ntitle,
  1156. X            PANEL_LIST_CLIENT_DATA, row, *npp,
  1157. X            NULL);
  1158. X        npp = (struct Note **) LLM_next(&root);
  1159. X        row++;
  1160. X        }
  1161. X    LLM_free(&root);
  1162. X
  1163. X    xv_set(srchlist, XV_SHOW, TRUE, NULL);
  1164. X    }
  1165. X
  1166. Xsearch_resize_proc(frame, event, arg)
  1167. X    Frame frame;
  1168. X    Event *event;
  1169. X    Notify_arg arg;
  1170. X    {
  1171. X    Rect rect, brect, lrect;
  1172. X    Rect *prect;
  1173. X    int  rh, h;
  1174. X
  1175. X    if(event_id(event) != WIN_RESIZE) return;
  1176. X    frame_get_rect(frame, &rect);
  1177. X    rect.r_height -= (topmargin + bottommargin); /* correct for wm borders */
  1178. X    rect.r_width -= (leftmargin + rightmargin);
  1179. X
  1180. X    prect = (Rect *) xv_get(srchapply, PANEL_ITEM_RECT);
  1181. X    brect = *prect;
  1182. X    xv_set(srchapply,
  1183. X        XV_X, (rect.r_width / 2) - (brect.r_width / 2),
  1184. X        XV_Y, rect.r_height - brect.r_height - DEFPANELSPACING,
  1185. X        NULL);
  1186. X
  1187. X    prect = (Rect *) xv_get(srchlist, PANEL_ITEM_RECT);
  1188. X    lrect = *prect;
  1189. X    prect = (Rect *) xv_get(srchapply, PANEL_ITEM_RECT);
  1190. X    brect = *prect;
  1191. X    rh = xv_get(srchlist, PANEL_LIST_ROW_HEIGHT);
  1192. X    h = brect.r_top - lrect.r_top - (2 * rh);
  1193. X    h = h / rh;
  1194. X    if(h <= 0) h = 1;
  1195. X    xv_set(srchlist,
  1196. X        PANEL_LIST_WIDTH, rect.r_width - SCROLLWIDTH,
  1197. X        PANEL_LIST_DISPLAY_ROWS, h,
  1198. X        NULL);
  1199. X    }
  1200. X
  1201. Xsearch_menu_proc(menu, mitem)
  1202. X    Menu menu;
  1203. X    Menu_item mitem;
  1204. X    {
  1205. X    char buf1[MAXSEARCHLEN + 1];
  1206. X    char buf2[MAXSEARCHLEN + 1];
  1207. X
  1208. X    strcpy(buf1, (char *) xv_get(search_item, PANEL_VALUE));
  1209. X    strcpy(buf2, (char *) xv_get(mitem, MENU_STRING));
  1210. X    xv_set(search_item, PANEL_VALUE, buf2, NULL);
  1211. X    notesearch(search_item, NULL); /* event isn't used, so NULL is ok */
  1212. X    xv_set(search_item, PANEL_VALUE, buf1, NULL);
  1213. X    }
  1214. SHAR_EOF
  1215. chmod 0644 pan3.0/search.c ||
  1216. echo 'restore of pan3.0/search.c failed'
  1217. Wc_c="`wc -c < 'pan3.0/search.c'`"
  1218. test 9168 -eq "$Wc_c" ||
  1219.     echo 'pan3.0/search.c: original size 9168, current size' "$Wc_c"
  1220. fi
  1221. # ============= pan3.0/win.c ==============
  1222. if test -f 'pan3.0/win.c' -a X"$1" != X"-c"; then
  1223.     echo 'x - skipping pan3.0/win.c (File already exists)'
  1224. else
  1225. echo 'x - extracting pan3.0/win.c (Text)'
  1226. sed 's/^X//' << 'SHAR_EOF' > 'pan3.0/win.c' &&
  1227. X/*
  1228. XPost A Note V3.0
  1229. XCopyright (c) 1993, Jeffrey W. Bailey
  1230. XAll rights reserved.
  1231. X
  1232. XPermission is granted to distribute this program in exact, complete
  1233. Xsource form, which includes this copyright notice, as long as no fee
  1234. Xother than media and distribution cost is charged.
  1235. X
  1236. XThis program may not be used in whole, or in part, in any other manner
  1237. Xwithout prior written permission from the author.
  1238. X
  1239. XThis program may not be distributed in modified form without prior
  1240. Xwritten permission from the author.  In other words, patches may be
  1241. Xdistributed, but modified source may not be distributed.
  1242. X
  1243. XIf there are any questions, comments or suggestions, the author may be
  1244. Xcontacted at:
  1245. X
  1246. X    jeff@rd1.interlan.com
  1247. X
  1248. X    or
  1249. X
  1250. X    Jeffrey Bailey
  1251. X    Racal-Datacom, Inc.
  1252. X    Mail Stop E-110
  1253. X    1601 N. Harrison Parkway
  1254. X    Sunrise, FL  33323-2899
  1255. X*/
  1256. X
  1257. X#include "pan.h"
  1258. X
  1259. Xextern int errno;
  1260. Xextern char *sys_errlist[];
  1261. X
  1262. Xget_win(np)
  1263. X    struct Note *np;
  1264. X    {
  1265. X    struct FreeWin *fp;
  1266. X
  1267. X    fp = (struct FreeWin *)LLM_first(&freewin_rt);
  1268. X    if(fp == NULL) return(0);
  1269. X    np->frame = fp->frame;
  1270. X    np->panel = fp->panel;
  1271. X    np->textsw = fp->textsw;
  1272. X    np->title = fp->title;
  1273. X    np->hide = fp->hide;
  1274. X    np->action = fp->action;
  1275. X    np->actionmenu = fp->actionmenu;
  1276. X    np->cdate = fp->cdate;
  1277. X    np->ctime = fp->ctime;
  1278. X    np->icon = fp->icon;
  1279. X#ifdef PAN_DND
  1280. X    np->drag_obj = fp->drag_obj;
  1281. X    np->drag_tgt = fp->drag_tgt;
  1282. X    np->got_itms = fp->got_itms;
  1283. X    np->sel_itm1 = fp->sel_itm1;
  1284. X    np->sel_itm2 = fp->sel_itm2;
  1285. X    np->sel_itm3 = fp->sel_itm3;
  1286. X#endif
  1287. X    LLM_delete(&freewin_rt, fp);
  1288. X    return(1);
  1289. X    }
  1290. X
  1291. Xput_win(np)
  1292. X    struct Note *np;
  1293. X    {
  1294. X    struct FreeWin *fp;
  1295. X
  1296. X    fp = (struct FreeWin *)LLM_add(&freewin_rt);
  1297. X    if(fp == NULL)
  1298. X        {
  1299. X        fprintf(stderr, "Internal memory allocation error\n");
  1300. X        exit(1);
  1301. X        }
  1302. X    fp->frame = np->frame;
  1303. X    fp->panel = np->panel;
  1304. X    fp->textsw = np->textsw;
  1305. X    fp->title = np->title;
  1306. X    fp->hide = np->hide;
  1307. X    fp->action = np->action;
  1308. X    fp->actionmenu = np->actionmenu;
  1309. X    fp->cdate = np->cdate;
  1310. X    fp->ctime = np->ctime;
  1311. X    fp->icon = np->icon;
  1312. X#ifdef PAN_DND
  1313. X    fp->drag_obj = np->drag_obj;
  1314. X    fp->drag_tgt = np->drag_tgt;
  1315. X    fp->got_itms = np->got_itms;
  1316. X    fp->sel_itm1 = np->sel_itm1;
  1317. X    fp->sel_itm2 = np->sel_itm2;
  1318. X    fp->sel_itm3 = np->sel_itm3;
  1319. X#endif
  1320. X    xv_set(fp->frame, XV_SHOW, FALSE, NULL);
  1321. X    if(xv_get(fp->frame, FRAME_CLOSED))
  1322. X        xv_set(fp->frame, FRAME_CLOSED, FALSE, NULL);
  1323. X    xv_set(fp->title, PANEL_VALUE, "", NULL);
  1324. X    }
  1325. SHAR_EOF
  1326. chmod 0644 pan3.0/win.c ||
  1327. echo 'restore of pan3.0/win.c failed'
  1328. Wc_c="`wc -c < 'pan3.0/win.c'`"
  1329. test 2517 -eq "$Wc_c" ||
  1330.     echo 'pan3.0/win.c: original size 2517, current size' "$Wc_c"
  1331. fi
  1332. true || echo 'restore of pan3.0/work.c failed'
  1333. echo End of part 5, continue with part 6
  1334. exit 0
  1335.  
  1336. --
  1337. Jeffrey Bailey
  1338. Racal-Datacom, Inc.
  1339. Mail Stop E-110
  1340. 1601 N. Harrison Parkway                  INET : jeff@rd1.interlan.com
  1341. Sunrise, FL 33323-2899                    UUCP : ...uflorida!novavax!rd1!jeff
  1342.  
  1343. exit 0 # Just in case...
  1344. -- 
  1345.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1346. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  1347.  "It's intuitively obvious to the |
  1348.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1349.