home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pmos2002.zip / DEF / LISTEDIT.DEF < prev    next >
Text File  |  1991-05-16  |  4KB  |  88 lines

  1. DEFINITION MODULE ListEditor;
  2.  
  3.     (********************************************************)
  4.     (*                            *)
  5.     (*        "Generic" list editor            *)
  6.     (*                            *)
  7.     (*  Programmer:        P. Moylan            *)
  8.     (*  Last edited:    13 February 1991        *)
  9.     (*  Status:        OK                *)
  10.     (*                            *)
  11.     (********************************************************)
  12.  
  13. FROM SYSTEM IMPORT
  14.     (* type *)    ADDRESS;
  15.  
  16. FROM Windows IMPORT
  17.     (* type *)    Window;
  18.  
  19. FROM FieldEditor IMPORT
  20.     (* type *)    FieldType, WriteProc, EditProc;
  21.  
  22. (************************************************************************)
  23. (*                                    *)
  24. (*  The editor in this module is "generic" in a limited sense.  It    *)
  25. (*  performs screen editing of a linear list, but obviously it has to    *)
  26. (*  make some assumptions about the linkage method by which the list    *)
  27. (*  is implemented.  The list must have the general form        *)
  28. (*                                    *)
  29. (*     TYPE List = POINTER TO    RECORD                    *)
  30. (*                    next: List;                *)
  31. (*                    component: some pointer type;    *)
  32. (*                END (*RECORD*)                *)
  33. (*                                    *)
  34. (*  Notice however that this definition module actually defines lists    *)
  35. (*  and components in terms of type ADDRESS, so that there is no    *)
  36. (*  requirement that the caller's types and field names match the    *)
  37. (*  above definition.                            *)
  38. (*                                    *)
  39. (*  The caller is required to supply, via FieldEditor.DefineFieldType,    *)
  40. (*  procedures which write and edit list components.            *)
  41. (*                                    *)
  42. (*  The procedures in this module obey the rules set by module        *)
  43. (*  FieldEditor.  In the case where a list of lists is being edited,    *)
  44. (*  the component editor can simply call EditList to do its job for it.    *)
  45. (*                                    *)
  46. (************************************************************************)
  47.  
  48. TYPE
  49.     ListFormat;        (* is private *)
  50.     List = ADDRESS;
  51.  
  52. (************************************************************************)
  53.  
  54. PROCEDURE DefineListFormat (header, separator, trailer: ARRAY OF CHAR;
  55.                 ComponentType: FieldType): ListFormat;
  56.  
  57.     (* Sets up the output format for a class of lists.  The header is    *)
  58.     (* what is written before the first component; the separator is    *)
  59.     (* what is written between the components; and the trailer is what    *)
  60.     (* is written after the last component.  For an empty list, only    *)
  61.     (* the header and trailer will be written.  ComponentType        *)
  62.     (* implicitly specifies the procedures which will be used to write    *)
  63.     (* and edit the components of the list.                *)
  64.  
  65. PROCEDURE DiscardFormat (format: ListFormat);
  66.  
  67.     (* A notification from the user that this format will not be used    *)
  68.     (* again (unless it is redefined by another call to procedure    *)
  69.     (* DefineListFormat).  Use of this procedure is optional, but is    *)
  70.     (* recommended for the sake of "clean" memory management.        *)
  71.  
  72. PROCEDURE WriteList (w: Window;  L: List;  format: ListFormat);
  73.  
  74.     (* Writes L on the screen, including its delimiters.  This        *)
  75.     (* procedure is not actually used in this module, but is provided    *)
  76.     (* as something that a client module may find useful.        *)
  77.  
  78. PROCEDURE EditList (w: Window;  VAR (*INOUT*) L: List;  format: ListFormat);
  79.  
  80.     (* Edits a list at the current cursor position in window w.  We    *)
  81.     (* leave this procedure on seeing a keyboard character which does    *)
  82.     (* not belong to us.  The cursor is left just beyond the "trailer"    *)
  83.     (* string which terminates the displayed form of the list.  The    *)
  84.     (* terminating keystroke is returned to the keyboard driver so that    *)
  85.     (* it can still be read by the caller.                *)
  86.  
  87. END ListEditor.
  88.