TIP: Click on subject to list as thread! ANSI
echo: qedit
to: ALL
from: JACKSON
date: 1997-05-19 23:51:00
subject: multi-coloured List()

From: Jackson 
I reached my purpose of using colors in lList() in a very
different way from my original idea. 
Here is a raw example to show how it works (It's slow, but it's very 
parametic)
I'm using TSE 2.50d.
With the buffer to be "lListed" we must have another buffer with a
"map" of the coloured zone.
I will call these buffers with their id: ii and ip
Ii must have no tab char. Ip must have a line for each line of the ii buffer.
For every zone to be coloured in ii's line ther must be, in the 
corresponding line of ip, an 8 char string:
  2 hex: colour          '0A          ( Bright Green )
  3 hex: starting column    00B       ( Column 11    )
  3 hex: length                005'   ( 5 char       )
I'm not very familiar with the Hook functions, so I'd like very
much comments and suggestions.
Many thanks to Chris Antos and George De Bruin for their support.
Ciao. Jackson
//-------------------------------------------------------------------
integer ii              //  id buffer to lList
integer ip              //  id map of the colored zones
integer do_it = True
integer cRow = -1
integer cLin = -1
integer xOff = -1
forward proc H_NeI()
forward proc H_ANeC()
forward proc FillBuff()
//-------------------------------------------------------------------
proc main()
   integer ris, oMTA, oMBA
   Set(Break, ON)             //  Debug
   cRow = -1
   cLin = -1
   xOff = -1
   oMTA = Set( MenuTextAttr,   Color(White on Black) )
   oMBA = Set( MenuBorderAttr, Color(Bright White on Black) )
   ip = CreateTempBuffer()
   ii = CreateTempBuffer()
   FillBuff()
   Hook(_NONEDIT_IDLE_, H_NeI)
   Hook(_AFTER_NONEDIT_COMMAND_, H_ANeC)
   ris = lList( 'Test', Query(ScreenCols)-2,
                        Query(ScreenRows)-2,
                        _ENABLE_SEARCH_ |
                        _FIXED_HEIGHT_  |
                        _ENABLE_HSCROLL_     )
   UnHook(H_NeI)
   UnHook(H_ANeC)
   if not ris
      warn( 'Abort..')        //  or whatever...
   endif
   abandonfile( ii )
   abandonfile( ip )
   Set( MenuTextAttr, oMTA )
   Set( MenuBorderAttr,  oMBA )
end
//-------------------------------------------------------------------
proc Colori()
   integer wY1 = Query( WindowY1 )
   integer wX1 = Query( WindowX1 )
   integer wRo = Query( WindowRows )
   integer wCo = Query( WindowCols )
   integer cRo   = CurrRow()
   integer delta = CurrLine() - CRo
   integer xOffs = CurrXoffset()
   integer xx
   integer xCol, xPos, xLen, dd
   string sk[255]
   for xx = wY1 to wRo
      if xx  cRo
         GotoBufferId(ip)
         GotoLine( xx + delta )
         if CurrLineLen()
            sk = GetText(1,255)
            while length(sk) >= 8
               xPos = Val( sk[3:3], 16 )
               xLen = Val( sk[6:3], 16 )
               if ( xPos + xLen - 1 >= xOffs + wX1 ) and
                  ( xPos            <= xOffs + wCo )
                  xCol = Val( sk[1:2], 16 )
                  dd = xPos - Xoffs
                  if dd < wY1
                     VGotoXY( wX1,  xx )
                     putattr( xCol, xLen - wX1 + dd )
                  elseif dd + xLen > wCo
                     VGotoXY( dd,  xx )
                     putattr( xCol, wCo - dd + 1 )
                  else
                     VGotoXY( dd,  xx )
                     putattr( xCol, xLen )
                  endif
               endif
               sk = delstr(sk, 1, 8)
            endwhile
         endif
      endif
   endfor
   GotoBufferId(ii)
 end
//-------------------------------------------------------------------
proc H_NeI()
   If do_it
      colori()
      cRow = CurrRow()
      cLin = CurrLine()
      xOff = CurrXoffset()
      do_it = False
   endif
end
//-------------------------------------------------------------------
proc H_ANeC()
   do_it = cRow  CurrRow() or
           cLin  CurrLine() or
           xOff  CurrXoffset()
end
//-------------------------------------------------------------------
proc FillBuff()      //  for example
   integer kk
   string s[255] = 'Red  Blue  Green'
   for kk = 1 to 90
      AddLine( s, ii )
      AddLine( '0C' + Format(kk:3:'0':16)    + '003' +
               '09' + Format(kk+5:3:'0':16)  + '004' +
               '0A' + Format(kk+11:3:'0':16) + '005', ip)
      s = ' ' + s
   endfor
   GotoLine(1)
end
//-------------------------------------------------------------------
----------------------------
Andrea "Jackson" Casamurata
Italy
E-mail: jackson@akros.it
----------------------------
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.