home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / VIDEO.HPP < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  54 lines

  1. // +++Date last modified: 05-Jul-1997
  2.  
  3. // Simple text video control class for DOS & OS/2
  4. // public domain
  5. // by David L. Nugent <davidn@unique.blaze.net.au>
  6. // 3:632/348@fidonet
  7.  
  8. #if !defined(_video_h)
  9. #define _video_h
  10.  
  11. typedef unsigned short cell_t;
  12.  
  13. class video
  14. {
  15.   public:
  16.     video();
  17.     ~video();
  18.  
  19.     void cls();
  20.     void scroll(cell_t left, cell_t top, cell_t right, cell_t bottom, cell_t lines, char dir =1);
  21.     void gotoxy(cell_t x, cell_t y);
  22.     void put(int ch);
  23.     void put(char const * s);
  24.     void repchr(int ch, int n);
  25.  
  26.     void maxxy(cell_t & cols, cell_t & rows);
  27.     void wherexy(cell_t & x, cell_t & y);
  28.  
  29.     void setattr(cell_t c)    { attr = c; }
  30.     void setfill(cell_t c)    { fill = c; }
  31.     void setfg(cell_t c)      { attr = cell_t((attr & 0xf0)|(c & 0xf)); }
  32.     void setbg(cell_t c)      { attr = cell_t((attr & 0x0f)|((c & 0xf) << 4)); }
  33.  
  34.     cell_t getattr() const    { return attr; }
  35.     cell_t getfg() const      { return cell_t(attr & 0xf); }
  36.     cell_t getbg() const      { return cell_t((attr & 0xf0) >> 4); }
  37.  
  38.     unsigned short getkey();
  39.  
  40.   private:
  41.     void adjustcursor(cell_t cols, cell_t lines =0);
  42.     void putcursor();
  43.  
  44.     cell_t maxx,
  45.            maxy;
  46.     cell_t curx,
  47.            cury;
  48.     cell_t attr,
  49.            fill;
  50. };
  51.  
  52. #endif
  53.  
  54.