home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / sun / volume1 / contool2.2 / part01 / clipboard.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-26  |  2.3 KB  |  72 lines

  1. /************************************************************************/
  2. /*    Copyright 1988, 1989 by Chuck Musciano and Harris Corporation    */
  3. /*                                    */
  4. /*    Permission to use, copy, modify, and distribute this software    */
  5. /*    and its documentation for any purpose and without fee is    */
  6. /*    hereby granted, provided that the above copyright notice    */
  7. /*    appear in all copies and that both that copyright notice and    */
  8. /*    this permission notice appear in supporting documentation, and    */
  9. /*    that the name of Chuck Musciano and Harris Corporation not be    */
  10. /*    used in advertising or publicity pertaining to distribution    */
  11. /*    of the software without specific, written prior permission.    */
  12. /*    Chuck Musciano and Harris Corporation make no representations    */
  13. /*    about the suitability of this software for any purpose.  It is    */
  14. /*    provided "as is" without express or implied warranty.  This     */
  15. /*    software may not be sold without the prior explicit permission    */
  16. /*    of Harris Corporation.                        */
  17. /************************************************************************/
  18.  
  19. #include    <stdio.h>
  20.  
  21. #include    <suntool/sunview.h>
  22. #include    <suntool/panel.h>
  23.  
  24. #include    "contool.h"
  25. #include    "entry.h"
  26.  
  27. EXPORT    f_ptr    clipboard;
  28. EXPORT    int    cb_size = 0;
  29.  
  30. /************************************************************************/
  31. EXPORT    clear_clipboard()
  32.  
  33. {    int    i;
  34.     f_ptr    f;
  35.  
  36.     if (cb_size > 0) {
  37.        for (i = 0, f = clipboard; i < cb_size; i++, f++) {
  38.           free(f->start);
  39.           if (f->end)
  40.              free(f->end);
  41.           }
  42.        free(clipboard);
  43.        cb_size = 0;
  44.        }
  45. }
  46.  
  47. /************************************************************************/
  48. EXPORT    add_to_clipboard(e)
  49.  
  50. register    e_ptr    e;
  51.  
  52. {    register    f_ptr    f;
  53.  
  54.     if (cb_size == 0)
  55.        f = clipboard = (f_ptr) malloc(sizeof(f_rec));
  56.     else {
  57.        clipboard = (f_ptr) realloc(clipboard, sizeof(f_rec) * (cb_size + 1));
  58.        f = clipboard + cb_size;
  59.        }
  60.     f->beep  = (int) panel_get(e->beep,  PANEL_VALUE);
  61.     f->flash = (int) panel_get(e->flash, PANEL_VALUE);
  62.     f->open  = (int) panel_get(e->open,  PANEL_VALUE);
  63.     f->save  = (int) panel_get(e->save,  PANEL_VALUE);
  64.     f->stamp = (int) panel_get(e->stamp, PANEL_VALUE);
  65.     f->start = strsave(panel_get(e->start, PANEL_VALUE));
  66.     if (panel_get(e->lines, PANEL_VALUE))
  67.        f->end = strsave(panel_get(e->end, PANEL_VALUE));
  68.     else
  69.        f->end = NULL;
  70.     cb_size++;
  71. }
  72.