|
Post by bigbass on Aug 1, 2012 5:38:17 GMT 1
When I started with BaCon I really wanted to use Bacon GUI but couldn't because gtksourceview wouldnt compile on my box so I had to compile every example until after much time I discovered the command line shell I wanted to make it a GUI but didn't know how to do it until now so now here is a simple version with a GUI *The official bacon GUI is the best you should try that no GTK code just BaCon and HUG This is just a very light easy version you could include easily in your projects RAD comes to mind UPDATED to run when clicked on no sourcing neededJoe *fixed code in last post*
|
|
|
Post by bigbass on Aug 2, 2012 17:33:32 GMT 1
|
|
|
Post by bigbass on Nov 29, 2018 18:21:06 GMT 1
fixed the broken above code now it works again did this in fltk too Joe '--guishell.bac '---This is the HUG GUI frontend version of a bacon shell '---all the HUG GUI code by bigbass
'================================================================= ' original shell code http://basic-converter.org/shell.bac ' Simple Command Line Shell emulation to directly execute some BaCon commands. ' October 2010, PvE - GPL. '=================================================================
' Include the files for making a GUI. INCLUDE "hug.bac" INIT
TRAP LOCAL '--------------- SUB TEXT_OUT '---------------
' clear second box TEXT(EDIT_BOX2,"" )
PRINT GRAB$(EDIT_BOX)
command$ = CONCAT$(GRAB$(EDIT_BOX))
' Get the arguments SPLIT ARGUMENT$ BY " " TO arg$ SIZE amount
' Name of temporary directory to store generated C files tmp_dir$ = CONCAT$("/tmp/", arg$[0], "/")
' Name of tmp file for direct mode tmp_file$ = CONCAT$(arg$[0], ".tmp.bac")
' compiler binary wouldn't launch from desktop now fixed bacon$ = "bacon"
' Default prompt prompt$ = "-> "
PRINT NL$, "---= Entering BaCon Shell v0.1 using BaCon version ", VERSION$, " with 65535 bytes free ;-) =---", NL$
' Create the temporary directory MAKEDIR tmp_dir$
' EXIT command? IF EQUAL(CHOP$(UCASE$(command$)), "EXIT") THEN END
' No, assume BaCon code ELIF LEN(command$) > 0 THEN
' Cleanup temporary directory IF FILEEXISTS(CONCAT$(tmp_dir$, tmp_file$)) THEN DELETE FILE CONCAT$(tmp_dir$, tmp_file$) IF FILEEXISTS(CONCAT$(tmp_dir$, tmp_file$, ".c")) THEN DELETE FILE CONCAT$(tmp_dir$, tmp_file$, ".c") IF FILEEXISTS(CONCAT$(tmp_dir$, tmp_file$, ".h")) THEN DELETE FILE CONCAT$(tmp_dir$, tmp_file$, ".h")
' Write command to temporary file OPEN CONCAT$(tmp_dir$, tmp_file$) FOR WRITING AS tmp_file WRITELN command$ TO tmp_file CLOSE FILE tmp_file
' Convert and compile result$ = EXEC$(CONCAT$(bacon$, " -d ", tmp_dir$, " ", CONCAT$(tmp_dir$, tmp_file$)))
' Check result IF NOT(INSTR(result$, "ready")) THEN PRINT "? ERROR" ELSE result3$ = EXEC$(CONCAT$(tmp_dir$, LEFT$(tmp_file$, LEN(tmp_file$) - 4)))
END IF
END IF
PRINT "result-->",result$ PRINT "result3-->",result3$ TEXT(EDIT_BOX2, result3$ ) ENDSUB
' 1.) Create your main working window, 350 pixels wide x 200 pixels high Mainwin = WINDOW( "BaCon Test code snippets ", 350, 500 )
My_label = MARK( "Type or paste some code in the box ", 300, 30 ) ATTACH( Mainwin, My_label, 20, 10) FONT(My_label, "sans 12")
' formatting changes if you use another label name My_label = MARK( "Press Run when done ", 300, 30 ) ATTACH( Mainwin, My_label, -20 ,30) FONT(My_label, "sans 12")
EDIT_BOX = EDIT(310, 200) ATTACH( Mainwin, EDIT_BOX, 20, 60 )
My_label = MARK( "Result of Run ", 300, 30 ) ATTACH( Mainwin, My_label, -70 ,270) FONT(My_label, "sans 12")
EDIT_BOX2 = EDIT(310, 150) ATTACH( Mainwin, EDIT_BOX2, 20, 300 )
My_btn = BUTTON("Run", 80, 25) ATTACH( Mainwin, My_btn, 140, 465 ) CALLBACK( My_btn, TEXT_OUT)
' Create a button. My_chk = STOCK("gtk-quit", 80, 25) ATTACH( Mainwin, My_chk, 255, 465 )
' Make button do something CALLBACK( My_chk, QUIT)
DISPLAY
|
|