Silverfrost Forums

Welcome to our forums

Is here something wrong

19 May 2010 11:14 #6390

or what i am trying to do (dynamically coloring output text in %cw) is just impossible?

   include <windows.ins> 
   iun = 33
   kolRed=rgb@(255,0,0)
   kolGrn=rgb@(0,255,0)
   kol   =rgb@(0,0,255)

   i=winio@('%ac[esc]&','exit')
   i=winio@('%tc%55.15cw[vscroll,local_font]&',kol,iun)
   i=winio@('%lc&',ihw)
   i=winio@('%lw',ilw)    
   do i=1,15
     kol=kolGrn
     call SET_CONTROL_TEXT_COLOUR@(ihw,kol)
     write(iun,*) 'Green'
           call temporary_yield@
           call sleep1@(0.5)
     kol=kolRed
     call SET_CONTROL_TEXT_COLOUR@(ihw,kol)
     write(iun,*) 'Red'
   enddo

   end
24 May 2010 7:29 #6406

You cannot change the colour in a %cw control on a line by line basis. It can be done with a %eb control but not in the direct way implied by your code. The next release of the library makes it easier for the programmer when using %eb but it is still tricky. If you are really keen I could try to explain how it works.

24 May 2010 9:03 #6411

Sure. I love your enhancements. cwplus.enh file is the place i look first 😃

25 May 2010 6:50 #6413

You will find some information in ftn95.chm under Win32 Platform->ClearWin+->Edit box (%eb)->%N.Meb[options].

You use the option [user_colours] together with the Edit info values 15 and 16 in the %eb callback function. The 'callback reason' is 'COLOURING'.

When your text display needs to be refreshed (e.g. because something that covered it has been moved) then ClearWin+ sends information to your callback function about the text and the number of characters that are about to be redisplayed. Your callback function then uses other edit info values to specify the text and background colouring that you want for this text.

This is the kind of approach that you would take if you wanted to apply syntax colouring to (say) the display of a Fortran program. i.e. your callback would provide an algorithm to detect and colour the keywords etc.

I have added some new functions for the next release of the library and these can be used in the calback function in order to set the colours in a relatively simple way. You can do it at the moment but only by using addresses provided in the edit info structure (i.e. you have to do some tricky programming with CCORE1 etc).

26 May 2010 9:05 #6429

I've just remembered another trick of coloring text with %eb i've used years ago but completely forgot it. To color the entire line with needed color the %st can be used. The output looks like this

http://img39.imageshack.us/img39/4827/ebcoloring.png

This is used to color the line in the initial data file where error occured

If you have no plans to add coloring to %cw then i might change to %eb... Was %eb implemented similarly to %cw in terms of internal buffer sizes restrictions? My code prints into %cw windows whole day probably many megabytes of text and i do not worry because nothing ever happened, no crashes or weird behavior. It is probably more reliable then usual DOS window. But with %eb 10 or more years ago as i remember there were some issues with text size. May be not anymore

27 May 2010 11:28 #6435

As I recall %eb and %st are independent controls.

%cw has a maximum buffer size that you can set using set_max_lines@ or set_all_max_lines@.

With %eb you can provide your own text buffer which you can make as large as you like. Otherwise the buffer size will grow on demand.

I have no plans to extend %cw so that it can be used with multiple colours.

Please login to reply.