1. Re: writing in a box in text mode.

--=====================_853300182==_

At 09:17 14-01-97 +0100, you wrote:
>---------------------- Information from the mail header -----------------------
>Sender:       Euphoria Programming for MS-DOS <EUPHORIA at
>MIAMIU.ACS.MUOHIO.EDU>
>Poster:       Raul Benavides Cordoba <f62becor at UCO.ES>
>-------------------------------------------------------------------------------
>
>Hi to All,
>
>          I have one problem and is that I want to draw a box in text mode
>but I don't Know how to write a good routine for it. The problem is that I
>can't fill the box. Can somebody help me?
>
>------------------------------
>
>               Thank you.
>

I send you this test code I wrote some times ago.
It draw a box (single line or double) and display a file list inside it.


--=====================_853300182==_

-- test code : drawing a box and writing in bound.

without warning

include file.e
include image.e

with trace
--trace(1)
constant attr = 7*16+15
constant padding = repeat(32,14)
object list

  list = dir("c:\\win95") -- my windows directory
  if atom(list) then
    puts(1,"Directory not found.\n")
    abort(1)
  end if

sequence   text

sequence window
  window = {{4,10},{20,60}}
integer x,y,width,height
width = window[2][2]-window[1][2]
height = window[2][1]-window[1][1]

function build_buffer(integer attr, sequence text)
sequence buffer
    buffer = {}
    for i = 1 to length(text) do
        buffer = buffer & text[i] & attr
    end for
    return buffer
end function -- build_buffer

constant cBOX = {{
                 {218,196,191}, -- single line box
                 {179,32,179},
                 {192,196,217}
                },
                {
                 {201,205,187}, -- double line box
                 {186,32,186},
                 {200,205,188}
                }
               }

constant cFRAME_SINGLE = 1, cFRAME_DOUBLE = 2

procedure DrawBox(integer style, integer color, sequence area)
-- draw a box
-- inputs:  style -> 0 single line, 1 double line
--          color -> text color attribute
--          area  -> box coordinates as {{y1,x1},{y2,x2}}
integer height, width
sequence box
    height = area[2][1] - area[1][1]
    width  = area[2][2] - area[1][2]
    if height < 1 or width < 1 then
        return
    end if
    box = cBOX[style]
    -- extend box to width
    box[1] = box[1][1]&repeat(box[1][2],width-1)&box[1][3]
    box[2] = box[2][1]&repeat(box[2][2],width-1)&box[2][3]
    box[3] = box[3][1]&repeat(box[3][2],width-1)&box[3][3]
    -- extend box to height
    box = {box[1]} & repeat(box[2],height-1) & {box[3]}
    for i = 1 to length(box) do
        box[i] = build_buffer(color,box[i])
    end for
    display_text_image(area[1],box)
end procedure -- DrawBox()

procedure ScrollUp()
sequence r
    r = repeat(0,10)
    r[REG_AX] = #0601
    r[REG_BX] = attr*256
    r[REG_CX] = (window[1][1]-1)*256+window[1][2]-1
    r[REG_DX] = (window[2][1]-1)*256+window[2][2]-1
    r = dos_interrupt(#10,r)
end procedure

DrawBox(cFRAME_SINGLE,16+15,
        {{window[1][1]-1,window[1][2]-1},{window[2][1]+1,window[2][2]+1}})

--atom start
--start =  time()
-- display   a list of file in a box.
x = 0  y = 0
for i = 1  to length(list) do
    text = list[i][D_NAME] & padding
    text = text[1..14]
    display_text_image({window[1][1]+y,window[1][2]+x},
                       {build_buffer(attr, text)})
    x = x + 14
    if x > width - 14 then
        x = 0
        y = y + 1
    end if
    if y > height then
        ScrollUp()
        y = height
    end if
end for
--clear_screen()
--? time() - start


--=====================_853300182==_

Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com

--=====================_853300182==_--

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu