fb:porticula NoPaste
CGUI, Console (not Working properly)
Uploader: | ZaPPa |
Datum/Zeit: | 07.08.2007 00:12:20 |
#include once "allegro.bi"
#include once "cgui.bi"
DECLARE SUB make_a_console ()
TYPE Console
cInput AS STRING
cDump AS STRING
cWelcome AS STRING
cTemp AS STRING
IDE AS INTEGER
IDT AS INTEGER
UC as SUB cdecl(BYVAL userdata as Console)
END TYPE
SUB update_console CDECL (BYVAL userdata AS Console )
DIM AS INTEGER scan,ascii,offset, x
GetEditData(@scan, @ascii, @offset)
SELECT CASE ascii
CASE 13
userdata.cTemp+="_>"
Print userdata.cTemp
userdata.cWelcome+=userdata.cTemp
UpdateTextBoxText(userdata.IDT, userdata.cWelcome )
Refresh(userdata.IDT)
SELECT CASE TRIM(UCASE(userdata.cTemp))
CASE "EXIT_>"
End 0
Case "NEW_>"
print "opening window"
userdata.cTemp=""
SetEditData(scan,0,offset)
userdata.cInput=""
click(userdata.IDE)
make_a_console()
Case else
userdata.cTemp=""
SetEditData(scan,0,offset)
userdata.cInput=""
click(userdata.IDE)
end select
'refresh(IDE)
'click(IDE)
'print "#" & trim(ucase(cTemp)) & "#"
CASE 32 TO 255
userdata.cTemp+=CHR(ascii)
CASE ELSE
'print ascii
END SELECT
END SUB
SUB stop_program CDECL (BYVAL userdata AS ANY PTR)
END 0
END SUB
SUB close_window CDECL (BYVAL userdata AS ANY PTR)
'' This terminates the top level of event proscessing
StopProcessEvents()
CloseWin(NULL)
END SUB
SUB make_a_console( )
Dim c as Console
c.UC = @update_console
c.cWelcome= "Welcome! _ Enter your commands... _ Type 'exit' to quit!_>"
MkDialogue(CGUI_ADAPTIVE, "Console", 0)
c.IDT=AddTextBox(10,5, c.cWelcome, 500, 20, CGUI_TB_FRAMESINK OR CGUI_TB_LINEFEED_)
c.IDE=AddEditBox(10,275, 430, "Input:", CGUI_FPTRSTR, 200, @c.cInput )
AddHandler(c.IDE, c.UC, @c)
click(c.IDE)
AddButton(CGUI_RIGHT, "Close", @close_window, NULL)
DisplayWin()
print "window opened"
'' Check for events - like mouse clicks and key-presses
ProcessEvents()
END SUB
:::MAIN
InitCgui(1152, 864, 16)
make_a_console()
END_OF_MAIN()