PWB Extensions Help (ext.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
GetColor and PutColor
                                             Up Contents Index Back
─────PWB Extensions─────────────────────────────────────────────────────────
 
  Syntax:  flagType GetColor( LINE line, la *colorlist, PFILE pfFile );
           void     PutColor( LINE line, la *colorlist, PFILE pfFile );
 
  Returns: GetColor returns true if there is color attached to the line,
           otherwise false.
 
  See:     SetColor, SetHiLite, AddAColor, Colors in Extensions
 
     GetColor gets the color array associated with a line in a file.
     PutColor attaches a color array to the specified line.
 
     Argument       Description
 
     <line>         Zero-based line number.
     <colorlist>    A variable-length array of color/length pairs.
     <pfFile>       File handle.
 
     The <colorlist> array is a variable-length list of color index and
     length pairs. Each pair has the lineAttr type, which is defined
     in EXT.H as:
 
          typedef struct lineAttr {     // Line color attribute info
              unsigned char attr;       // Attribute of piece
              unsigned char len;        // Bytes in colored piece
              } la, *pla;
 
     The format of a color list array is shown below:
 
          ┌────┬────┬────┬────┬────┬────┬─────────┬────┬────┐
          │attr│len │attr│len │attr│len │  . . .  │ -1 │ -1 │
          └────┴────┴────┴────┴────┴────┴─────────┴────┴────┘
 
     The <attr> element is the color index of a color in the PWB color
     table. This is a color constant from EXT.H or an index returned by
     AddAColor. The <len> element is the number of characters that have
     the associated color. The list must be terminated with an entry in
     which both elements are -1.
     See: Color Constants
 
     GetColor and PutColor can be used to copy colored lines. For each
     line to be copied, copy the text using GetLine and PutLine. Copy
     the color by getting the color array of the source and putting it
     on the corresponding line of the destination. In some cases it may
     be easier to use CopyBox, CopyLine, or CopyStream, which copy
     color attributes along with the text.
 
     You can also color text by building color arrays and putting them
     on uncolored lines, or by using SetColor.
                                    -♦-