Re: Lucius PUT.E

new topic     » goto parent     » topic index » view thread      » older message » newer message

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
_________________________

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu