1. Lucius PUT.E
- Posted by C & K L <candk at TICNET.COM> Nov 25, 1998
- 409 views
Lucius, How do I set the color of the text? I assume I have to poke the color into a relative location. Also, how would I include the '\n'. Right now it prints a weird character. Should I adjust your put.e to accept the '\n' or would that slow it down too much? I tried using write.e, but got the color issue as well. Thanks in advance! ck
2. Re: Lucius PUT.E
- Posted by Lucius Hilley III <lhilley at CDC.NET> Nov 25, 1998
- 389 views
On Wed, 25 Nov 1998 15:32:50 -0600, C & K L <candk at TICNET.COM> wrote: >Lucius, > >How do I set the color of the text? I assume I have to poke the color >into a relative location. > >Also, how would I include the '\n'. Right now it prints a weird >character. Should I adjust your put.e to accept the '\n' or would that >slow it down too much? > >I tried using write.e, but got the color issue as well. > >Thanks in advance! >ck You may adjust the code in any way you like. The character that is displayed is the actual LineFeed character. You would get the same effect if you try to print character 13. It will display a single quarter-note just as 14 displays a double quarter-note. It has been quite some time since I wrote that code so I will dig it up now. ------------------------------------------------------------- --fast_puts-- This procedure is safe. It uses no color unless you exceed --boundary, if you exceed boundary then it automaticaly reverts to puts --instead of poking. This keeps the output SAFE. ------------------------------------------------------------- Hmm. That tells me that the color isn't set when using fast_puts(). Whatever color is at that point will remain there. Another thing with fast_puts() is that I don't believe it changes the current cursor position... Yes. I was right. I doesn't change the cursor position. ------------------------------------------------------------- --f_puts(integer, sequence) --WARNING. this is a FAST, NOT SAFE, procedure. -- . if sequence goes out of bounds it -- . may cause serious damage. -- USE AT OWN RISK. <SNIP> ------------------------------------------------------------- Essentially f_puts is much faster because it lacks border checking and color setting. I just created color_fast_puts below on. ------------------------------------------------------------- --color_fast_puts-- This procedure is safe. This uses color. --If you exceed boundary then it automaticaly reverts --to puts instead of poking. This keeps the output SAFE. --Must pass color because I have no way for testing for the --current text_color() setting. As you see this only works --for the foreground colors. Both foreground and background --can be supported but require even more Bloating of the --procedure. ------------------------------------------------------------- global procedure color_fast_puts(sequence s, integer color) atom p integer l, width sequence w, vc machine_proc(9, color)--sets text_color() Euphoria style machine_proc(10, 0)--sets back_color() Euphoria style vc = machine_func(13, 0) w = machine_func(25, 0) - 1 width = vc[4] + vc[4] p = w[1] * width + w[2] + w[2] l = length(s) if vc[2] < 4 and vc[3] * width > l + l + p then p = #B8000 + p for A = 1 to l do poke(p, s[A]) p = p + 1 poke(p, color) end for else puts(1, s) w = w + 1 position(w[1], w[2]) end if end procedure ---------------------------- I surely hope this helps. PS: Not tested as of yet. _________________________ Lucius L. Hilley III lhilley at cdc.net http://www.cdc.net/~lhilley http://www.americanantiques.com http://www.dragonvet.com _________________________
3. Re: Lucius PUT.E
- Posted by C & K L <candk at TICNET.COM> Nov 25, 1998
- 397 views
Thanks, Lucius! I appreciate it. I'm going to bloat the code a little bit more to get background color, cuz it's important to my proggie... Lucius Hilley III wrote: > > On Wed, 25 Nov 1998 15:32:50 -0600, C & K L <candk at TICNET.COM> wrote: > > >Lucius, > > > >How do I set the color of the text? I assume I have to poke the color > >into a relative location. > > > >Also, how would I include the '\n'. Right now it prints a weird > >character. Should I adjust your put.e to accept the '\n' or would that > >slow it down too much? > > > >I tried using write.e, but got the color issue as well. > > > >Thanks in advance! > >ck > > You may adjust the code in any way you like. The character > that is displayed is the actual LineFeed character. You would > get the same effect if you try to print character 13. It will > display a single quarter-note just as 14 displays a double > quarter-note. > > It has been quite some time since I wrote that code so I > will dig it up now. > ------------------------------------------------------------- > --fast_puts-- This procedure is safe. It uses no color unless you exceed > --boundary, if you exceed boundary then it automaticaly reverts to puts > --instead of poking. This keeps the output SAFE. > ------------------------------------------------------------- > Hmm. That tells me that the color isn't set when using fast_puts(). > Whatever color is at that point will remain there. Another > thing with fast_puts() is that I don't believe it changes the current > cursor position... Yes. I was right. I doesn't change the > cursor position. > > ------------------------------------------------------------- > --f_puts(integer, sequence) > --WARNING. this is a FAST, NOT SAFE, procedure. > -- . if sequence goes out of bounds it > -- . may cause serious damage. > -- USE AT OWN RISK. > <SNIP> > ------------------------------------------------------------- > > Essentially f_puts is much faster because it lacks border > checking and color setting. > > I just created color_fast_puts below on. > ------------------------------------------------------------- > --color_fast_puts-- This procedure is safe. This uses color. > --If you exceed boundary then it automaticaly reverts > --to puts instead of poking. This keeps the output SAFE. > --Must pass color because I have no way for testing for the > --current text_color() setting. As you see this only works > --for the foreground colors. Both foreground and background > --can be supported but require even more Bloating of the > --procedure. > ------------------------------------------------------------- > global procedure color_fast_puts(sequence s, integer color) > atom p > integer l, width > sequence w, vc > > machine_proc(9, color)--sets text_color() Euphoria style > machine_proc(10, 0)--sets back_color() Euphoria style > vc = machine_func(13, 0) > w = machine_func(25, 0) - 1 > width = vc[4] + vc[4] > p = w[1] * width + w[2] + w[2] > l = length(s) > if vc[2] < 4 and vc[3] * width > l + l + p then > p = #B8000 + p > for A = 1 to l do > poke(p, s[A]) > p = p + 1 > poke(p, color) > end for > else > puts(1, s) > w = w + 1 > position(w[1], w[2]) > end if > end procedure > > ---------------------------- > I surely hope this helps. > PS: Not tested as of yet. > _________________________ > > Lucius L. Hilley III lhilley at cdc.net > http://www.cdc.net/~lhilley > http://www.americanantiques.com > http://www.dragonvet.com > _________________________
4. Re: Lucius PUT.E
- Posted by Lucius Hilley III <lhilley at CDC.NET> Nov 26, 1998
- 387 views
Here you go. Full color support. \n is still not handled. I still haven't decided just how bad the bloating might be to be able to handle \n. As long as you aren't attempting to display beyond the screens boundary it will use poke. There is a definate speed increase over puts() but just how much of a speed may depend on the version of Euphoria and your machine. It has been tested under Euphoria 2.0 global procedure color_fast_puts(sequence s, integer tcolor, integer bcolor) atom p integer l, width sequence w, vc machine_proc(9, tcolor)--sets text_color() Euphoria style machine_proc(10, bcolor)--sets back_color() Euphoria style tcolor = and_bits(tcolor, 31) bcolor = and_bits(bcolor, 7) if tcolor > 15 then bcolor = bcolor + 8 tcolor = tcolor - 16 end if tcolor = tcolor + (bcolor * 16) vc = machine_func(13, 0) w = machine_func(25, 0) - 1 width = vc[4] + vc[4] p = w[1] * width + w[2] + w[2] l = length(s) if vc[2] < 4 and vc[3] * width > l + l + p then p = #B8000 + p for A = 1 to l do poke(p, s[A]) p = p + 1 poke(p, tcolor) p = p + 1 end for else puts(1, s) w = w + 1 position(w[1], w[2]) end if end procedure _________________________ Lucius L. Hilley III lhilley at cdc.net http://www.cdc.net/~lhilley http://www.americanantiques.com http://www.dragonvet.com _________________________