home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / INTERNET / WWW / LYNX / SOURCE / SRC0_8A.ZIP / DOSLYNX / SRC / TURLVI12.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-24  |  3.2 KB  |  103 lines

  1. //    Copyright (c) 1993, University of Kansas, All Rights Reserved
  2. //
  3. //    Class:        TURLView
  4. //    Include File:    turlview.h
  5. //    Purpose:    Provide the view of a URL
  6. //    Remarks/Portability/Dependencies/Restrictions:
  7. //    Revision History:
  8. //        12-27-93    created
  9. //        02-02-94    Began a major revision to fully handle a
  10. //                multiple document interface with WWW, take
  11. //                over the formatting and drawing of the
  12. //                old gridtext functions of HText, and optimize
  13. //                memory usage, selecting anchors, the usage of
  14. //                HText's new image file.  See gridtext.
  15. //        02-09-94    Split all members into seperate files.
  16. #include"turlview.h"
  17.  
  18. unsigned short int TURLView::HTMLColor(signed long int sli_chars, unsigned
  19.     short int usi_colorindex)    {
  20. //    Purpose:    Take an offset into an HText stream and return
  21. //            an appropriate color with regards to fonts, anchors,
  22. //            and the video display mode.
  23. //    Arguments:    sli_chars    The offset into the HText stream.
  24. //            usi_colorindex    The offset into the palette entries
  25. //                    for the color for the video mode.
  26. //    Return Value:    unsigned short int    The color.
  27. //    Remarks/Portability/Dependencies/Restrictions:
  28. //        Bypassing TVision's color palettes for ease of configuation.
  29. //    Revision History:
  30. //        01-29-94    created
  31. //        04-04-94    Added a search color.
  32. //        04-20-94    Increased performance by not searching through
  33. //                all anchors all the time for a match.
  34.  
  35.     //    Go through the anchors, intelligently deciding if sli_chars
  36.     //    is within an anchor.
  37.     auto TextAttribute *TAp_check = NULL;
  38.  
  39.     //    First, check if there is search text to highlight.
  40.     if(TAp_search != NULL)    {
  41.         if(TAp_search->inRange(sli_chars) == 1)    {
  42.             //    Check to make sure that this is also not
  43.             //    the selected anchor.
  44.             if(TAp_selected != NULL)    {
  45.                 if(TAp_selected->inRange(sli_chars) == 1)
  46.                 {
  47.                     return(SearchSelectedColor);
  48.                 }
  49.             }
  50.             return(SearchColor);
  51.         }
  52.     }
  53.  
  54.     //    Start from the beginning index of the first anchor on possibly
  55.     //    on the screen already indexed by the draw function for us. If
  56.     //    our offset ever passes that of sli_chars, then consider that
  57.     //    it is not inside an anchor, check the one after it too for
  58.     //    nested anchors, but save this index until the next time draw
  59.     //    is called.
  60.     auto Boolean B_check2 = False;
  61.  
  62.     while(ssi_fasterpussycat < TNSCp_anchors->getCount())    {
  63.         //    Obtain the anchor.
  64.         TAp_check = (TextAttribute *)(TNSCp_anchors->at(
  65.             ssi_fasterpussycat));
  66.  
  67.         //    If already past what we are checking, break.
  68.         if(sli_chars < TAp_check->getBegin())    {
  69.             break;
  70.         }
  71.  
  72.         //    Next, determine if in the range of the anchor.
  73.         if(TAp_check->inRange(sli_chars) == 1)    {
  74.             //    Is this the selected anchor?
  75.             if(TAp_selected == TAp_check)    {
  76.                 return(SelectedColor);
  77.             }
  78.  
  79.             //    Okay, isn't the selected anchor, but is the
  80.             //    next anchor nested into this one, and if so,
  81.             //    is it the selected anchor?
  82.             if(B_check2 != True)    {
  83.                 B_check2 = True;
  84.                 ssi_fasterpussycat++;
  85.                 continue;
  86.             }
  87.  
  88.             return(AnchorColor);
  89.         }
  90.  
  91.         //    Check the next one.
  92.         ssi_fasterpussycat++;
  93.     }
  94.  
  95.     //    not in any range, just display normally.
  96.     //    Could have been checked last time....
  97.     if(B_check2 == True)    {
  98.         ssi_fasterpussycat--;
  99.         return(AnchorColor);
  100.     }
  101.     return(TextColor);
  102. }
  103.