home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / BBS / NSDEDIT2.ZIP / EDTKT06B.ZIP / QUOTE.CPP < prev    next >
C/C++ Source or Header  |  1994-09-06  |  4KB  |  138 lines

  1. /***********************************************************************
  2. *                                                                      *
  3. *  Definition file for QUOTE.CPP                                       *
  4. *                                                                      *
  5. *  Purpose : Implementation of different colors for quote lines        *
  6. *                                                                      *
  7. *  Author  : Peter Bloemendaal                                         *
  8. *            Brainbox systems +31-70-3523661                           *
  9. *  eMail   : internet -> bloemendaal@rullf2.LeidenUniv.nl              *
  10. *            fidonet  -> 2:281/908                                     *
  11. *                                                                      *
  12. *----------------------------------------------------------------------*
  13. *                                                                      *
  14. *                                                                      *
  15. * $Log: quote.cpv $
  16. // Revision 1.1  1994/08/27  11:21:57  BRAINBOX
  17. // Initial revision
  18. //
  19. //                                                                *
  20. *                                                                      *
  21. ************************************************************************
  22. */
  23.  
  24. #ifndef _QUOTE_CPP
  25. #define _QUOTE_CPP
  26.  
  27.  
  28. #include "ABBREV.CPP"
  29. #include "QUOTE.HPP"
  30.  
  31. #define QUOTE_POS   10
  32.  
  33. void QuoteEdit::setQuoteColor(unsigned char col)
  34. {
  35.    quoteColor = col ;
  36. }
  37.  
  38.  
  39. unsigned char QuoteEdit::getQuoteColor(void)
  40. {
  41.    return quoteColor ;
  42. }
  43.  
  44. void QuoteEdit::display(void)
  45. {
  46.    register int  i, j, k;
  47.    char *st ;
  48.    bool l_fQuote ;
  49.    unsigned long quotePos ;
  50.  
  51.    l_fQuote = FALSE ;
  52.  
  53.    st = (char*) malloc(width+1) ;
  54.  
  55.    this->formatText() ;
  56.  
  57.  
  58.    this->Output::outTextattr(color) ;
  59.  
  60.    for (i = 0 ; i < height ; i++)
  61.       if (strcmp(curScreen[i],oldScreen[i]) != 0)
  62.       {
  63.          for (j = 0 ; j < width ; j++)
  64.             if (curScreen[i][j] != oldScreen[i][j])
  65.                break ;
  66.          for (k = width ; k > 0 ; k--)
  67.             if (curScreen[i][k] != oldScreen[i][k])
  68.                break ;
  69.          strncpy(st,curScreen[i]+j,k-j+1) ;
  70.          st[k - j + 1] = '\0' ;
  71.  
  72.          this->Output::outGotoxy(x1 + j, y1 + i) ;
  73.          // look if the line contains a quote
  74.          quotePos = strchr(curScreen[i],'>') - curScreen[i] ;
  75.          if (quotePos <= QUOTE_POS )
  76.          {
  77.             if (!l_fQuote)
  78.                this->outTextattr(quoteColor) ;
  79.             l_fQuote = TRUE ;
  80.          }
  81.          else
  82.          {
  83.             if (l_fQuote)
  84.                this->outTextattr(color) ;
  85.             l_fQuote = FALSE ;
  86.          }
  87.  
  88.          this->Output::outPrintf(st) ;
  89.       }
  90.    // Place cursor
  91.    this->redrawCursor() ;
  92.  
  93.    this->copyScreen() ;
  94.  
  95.    free(st) ;
  96. }
  97.  
  98. void QuoteEdit::redraw(void)
  99. {
  100.    register int i ;
  101.    bool l_fQuote ;
  102.    unsigned long quotePos ;
  103.  
  104.    l_fQuote = FALSE ;
  105.  
  106.    this->drawborder() ;
  107.    this->formatText() ;
  108.    this->Output::outTextattr(color) ;
  109.  
  110.    for (i = 0 ; i < height ; i++)
  111.    {
  112.       this->Output::outGotoxy(x1,y1+i) ;
  113.  
  114.       // look if the line contains a quote
  115.       quotePos = strchr(curScreen[i],'>') - curScreen[i] ;
  116.       if (quotePos <= QUOTE_POS )
  117.       {
  118.          if (!l_fQuote)
  119.             this->outTextattr(quoteColor) ;
  120.          l_fQuote = TRUE ;
  121.       }
  122.       else
  123.       {
  124.          if (l_fQuote)
  125.             this->outTextattr(color) ;
  126.          l_fQuote = FALSE ;
  127.       }
  128.  
  129.       this->Output::outPrintf(curScreen[i]) ;
  130.    }
  131.    // Place cursor
  132.    this->redrawCursor() ;
  133.  
  134.    this->copyScreen() ;
  135. }
  136.  
  137. #endif
  138.