You can look into all my yab apps and games. The source always in the program folder under/boot/system/apps/nameofprogram
Hi,
Yes I doing this. This is helpfull Thanks.
But I donât find the Application Message for the resize button?
I want to place something in case of it.
https://besly.de/index.php/en/development/yab/yab-and-the-layout-command
All changes are majeable with the layout command, but i does not know if this is possible with buttons
I have try with the layout command before but there where some bug (a View stay in the same position when I resize the window) I had put a layout âallâ and layout âbottom,right,leftâ) but and that make a grey square in my main text edit box when I resized the window.
For now I finaly found a âsolutionâ by make a split in the app but that can be helpfull if I encounter same bug again in other app.
Can you send me a cut of your source or screenshot, so i can check for a solution.
The layout option need to set for all things on the window.
Itâs upgraded nowâŠThe solution is done by an other way but here is all the code(for now it can compile one file) but I advice the compilator put a file in /boot/home/buil for now:
window open 50, 50 to 710,530, "View", "TextEditor"
layout "top,bottom,right,left", "View"
window set "View", "minimumto",640,480
menu "File","Open","O","View"
menu "File","New","N","View"
menu "File","Save","S","View"
menu "File","Save As...","Z","View"
menu "File","Quit","Q","View"
menu "Run","Compile","C","View"
menu "Run","Run","R","View"
menu "Options","Linking","L","View"
menu"Help","About","A","View"
h = window get "View", "height"
w = window get "View", "width"
LinkLib$=""
current_path$="/boot/home"
current_file$=""
//Splitview crée 2 vues ajustables dans View ici
splitview 0,25 to 660,465, "Split", false, false, "View"
tooltip "Split", "SPLITVIEW"
textedit 0,0 to 660,h-150, TextEd$, 3, "Split1"
LISTBOX 0,0 to w,100, Log$,3, "Split2"
inloop = true
while(inloop)
h = window get "View", "height"
w = window get "View", "width"
Option$="countlines"
LineCount=TEXTEDIT GET TextEd$,Option$
Option$ = "currentline"
LineNumber = TEXTEDIT GET TextEd$, Option$
Update()
msg$=message$
switch msg$
case "View:_QuitRequested|"
inloop = false
break
case "View:File:Quit|"
inloop = false
break
case "View:File:Open|"
filename$ = ""
filename$ = filepanel "load-file", "Open File", current_path$,""
if(not(filename$=""))then
//Clear the text Edit box
TEXTEDIT CLEAR TextEd$
FileDir()
//Open the file
open filename$ for reading as #1
while(!eof(1))
//Read a line and stock it in newline
line input #1 newline$
//Add the new line + \n in Text box
textedit add TextEd$, newline$ + "\n"
wend
//close file
close #1
//Place the cursor to line 1 when finished loading the file
textedit set TextEd$, "gotoline", 1
endif
break
case "View:File:Save|"
SaveFile()
break
case "View:File:Save As...|"
SaveFileAs()
break
case "View:Run:Compile|"
LISTBOX CLEAR Log$
SaveFile()
print ("gcc "+filename$+" -o /boot/home/build "+LinkLib$)
if(LinkLib$="")then
if(system("gcc "+filename$+" -o /boot/home/build 2> /boot/home/log.txt")=0)then
alert "Compilation successfull","Ok","Message"
endif
elseif(system("gcc "+filename$+" -o /boot/home/build "+LinkLib$+" 2> /boot/home/log.txt")=0)then
alert "Compilation successfull with lib","Ok","Message"
endif
open "/boot/home/log.txt" for reading as #1
while(!eof(1))
line input #1newline$
LISTBOX ADD Log$, newline$
wend
close #1
break
case "View:File:New|"
NewFile()
break
case "View:Run:Run|"
system("Terminal /boot/home/build")
break
case "View:Options:Linking|"
Linking()
break
case "View:Help:About|"
alert "Developed by Kitsune.", "Ok", "About"
break
end switch
wend
window close "View"
Exit
sub Update()
draw flush "View"
draw text 10,h-3,"Line: "+str$(LineNumber)+"/"+str$(LineCount), "View"
return
end sub
sub SaveFile()
if(current_file$="")then
SaveFileAs()
elseif(current_path$="")then
SaveFileAs()
else
file2save$=textedit get$ TextEd$
filename$=current_path$+current_file$
open filename$ for writing as #1
print #1 file2save$
close #1
print ("Saved File at "+filename$)
endif
end sub
sub SaveFileAs()
file2save$=""
filename$=""
file2save$ = textedit get$ TextEd$
if file2save$ <> "" then
filename$ = filepanel "save-file", "Save File As ...", current_path$,current_file$
if filename$= "" return
FileDir()
open filename$ for writing as #1
print #1 file2save$
close #1
endif
end sub
sub FileDir()
//RĂ©cupĂšre le nom du fichier courant
current_file$=system$("basename "+filename$)
//Supprimer le caractĂšre espace ou "\n" en fin de ligne"
current_file$=rtrim$(current_file$)
FileLenght=len(current_file$)
cpt=0
spacetxt$=""
while(cpt<FileLenght)
spacetxt$=spacetxt$+" "
cpt=cpt+1
wend
print current_path$
current_path$=filename$
right$(current_path$,FileLenght)=spacetxt$
current_path$=rtrim$(current_path$)
print current_path$
print current_file$
print str$(FileLenght)
end sub
sub NewFile()
selected = alert "Would you like to continue to create a new file? This will erase the current content.", "Yes", "No","Save the current File before","info"
if(selected=1)then
TEXTEDIT CLEAR TextEd$
LISTBOX CLEAR Log$
current_file$=""
elseif(selected=3)then
SaveFile()
TEXTEDIT CLEAR TextEd$
LISTBOX CLEAR Log$
current_file$=""
endif
end sub
//Option menu
sub Linking()
window open 150, 150 to 640,230, "Linking", "Link library"
option set "Linking", "Focus", true
TEXTCONTROL 10,10 TO 480,20, "InputLib", "", LinkLib$, "Linking"
BUTTON 10,40 TO 80,70, "LinkButOk", "Ok", "Linking"
quitting=0
while(not quitting)
m$ =message$
if(m$ = "LinkButOk|")then
LinkLib$ = TEXTCONTROL GET$ "InputLib"
quitting =true
endif
if(instr(m$, "_QuitRequested")) quitting = true
wend
print LinkLib$
window close "Linking"
end sub
Here something to play around, i does not get two buttons under each over to change in the same direction.
WINDOW OPEN 200,200 TO 600,600, "MyWindow", "Test"
DRAW SET "BGColor", 10,10,100, "MyWindow"
//First 2 Buttons
LAYOUT "Left, Top, Right", "MyWindow"
BUTTON 10,10 TO 200,40, "BT:1", "Button 1", "MyWindow"
LAYOUT "Left, Top, Right", "MyWindow"
BUTTON 10,50 TO 200,80, "BT:2", "Button 2", "MyWindow"
//Second 2 Buttons
LAYOUT "Left, Bottom, Right", "MyWindow"
BUTTON 10,100 TO 200,130, "BT:3", "Button 3", "MyWindow"
LAYOUT "Left, Bottom, Right", "MyWindow"
BUTTON 10,140 TO 200,170, "BT:4", "Button 4", "MyWindow"
//Third 2 Buttons
LAYOUT "Left, Botto, Top, Right", "MyWindow"
VIEW 10,200 TO 210,240, "View1", "MyWindow"
DRAW SET "BGColor", 10,10,100, "View1"
//LAYOUT "Left, Top, Bottom, Right", "View1"
BUTTON 0,0 TO 200,30, "BT:5", "Button 5", "View1"
LAYOUT "Left, Bottom, Right", "MyWindow"
VIEW 10,250 TO 210,290, "View2", "MyWindow"
DRAW SET "BGColor", 200,10,200, "View1"
//LAYOUT "Left, Top, Bottom, Right", "View2"
BUTTON 0,0 TO 200,30, "BT:6", "Button 6", "View2"
//Main Loop
dim part$(1)
inloop = true
while(inloop)
//General Messages
msg$ = message$
if (split(msg$, part$(), ":|") > 2) then
PartOne$=part$(1)
PartTwo$ = part$(2)
PartThree$ = part$(3)
fi
if (split(msg$, part$(), ":|") > 3) then
PartFour$ = part$(4)
fi
if (split(msg$, part$(), ":|") > 4) then
PartFife$ = part$(5)
fi
if (msg$ <> "") print msg$
switch (msg$)
case "MyWindow:_QuitRequested|"
WINDOW CLOSE "MyWindow"
break
default:
break
end switch
wait 0.05
if(window count<1) inloop = false
sleep 0.05
wend
I have this error at first line but donât know why: 0xff
that was the " "
try again, i have pasted the source as quote, so he change the " sign to a not current on
Hi,
I try to dynamically make some Stackview for View new open file. The idee is like the YabIDE file list that open document in a TextEdit but I donât find the method for make it.
YabIDE have a source code somewhere?
Ok I find it here:
Yab IDE Source
Thanks
Ok apparently YabIDE can open maximum 20 files by default and a comment of dynamically implement Stackview is in the code source. So this is the way.
It is not so complicated. But if you want to load all projects at startup like yabIDE, this slow down the program start.
If you want load all at startup:
Example
-view on the left with a listbox
-stackview on the right with the max stacks count of open documents. Place on all a textedit.
-readout the projects folder and list them on the listbox.
-selecting a project in the listbox and change to the coresponding stack.
Hello,
I have a few bugs in my application regarding saving and closing files at the moment. This since I use several files.
I think it was the delete column command that was complicating things with me. That must change the kind of âIDâ of a row in the column box.
Also, I canât find any way to modify a row of a columnBox.
Example: With the Save As button, I will change the name of the file in the ColumnBox
The only way I have found is to delete the row and add a new one. Is this the right way?
I will post my source but itâs long now. Dont use important file for testing it and the New command donât work at all for now.
window open 50, 50 to 950,700, "View", "CCompiler"
layout "all", "View"
window set "View", "minimumto",640,480
menu "File","New","N","View"
menu "File","Open","O","View"
menu "File","Save","S","View"
menu "File","Save As...","Z","View"
menu "File","Close","X","View"
menu "File","Quit","Q","View"
menu "Run","Compile","K","View"
menu "Run","Run","R","View"
menu "Run","Terminal","T","View"
menu "Run","--","","View"
menu "Run","Make Löve","","View"
menu "Options","Build Directory","B","View"
menu "Options","Linking","L","View"
menu"Help","About","A","View"
h = window get "View", "height"
w = window get "View", "width"
LinkLib$=""
current_path$="/boot/home"
current_file$=""
BuildDirName$=""
FilePosition=1
//Splitview crée 3 vues ajustables
splitview 0,22 to 900,637, "FileSplit", true, false, "View"
splitview 0,0 to 660,614, "TxtSplit", false, false, "FileSplit2"
SPLITVIEW SET "FileSplit", "Divider", 150
SPLITVIEW SET "TxtSplit", "Divider", 500
COLUMNBOX 0,0 TO 145,612, "FileBox", true, "resizable no-sorting", "FileSplit1"
columnbox column "FileBox", "File Name",1, 140, 60, 80, "align-left"
columnbox column "FileBox", "File Path",2, 250, 60, 180, "align-left"
//Initialisation de pages.
MAXFILE=3
stackview 0,0 to 743,h-150, "Stack", MAXFILE, "TxtSplit1"
FileNumber=1
for FileNumber=1 to MAXFILE
print ("alo")
textedit 0,0 to 743,h-150, "TextEd"+str$(FileNumber),3,"Stack"+str$(FileNumber)
textedit color "TextEd"+str$(FileNumber),"bgcolor",255,255,255
next FileNumber
FileNumber=1
//textedit 0,0 to 743,h-150, TextEd$, 3, "Stack1"
//textedit 0,0 to 743,h-150, TextEd1$,3,"Stack2"
LISTBOX 0,0 to 743,107, Log$,3, "TxtSplit2"
inloop = true
while(inloop)
if(FileNumber>0)then
Option$="countlines"
LineCount=TEXTEDIT GET "TextEd"+str$(FileNumber),Option$
Option$ = "currentline"
LineNumber = TEXTEDIT GET "TextEd"+str$(FileNumber), Option$
endif
msg$=message$
switch msg$
case "View:_QuitRequested|"
inloop = false
break
case "View:File:Quit|"
inloop = false
break
case "View:File:Open|"
filename$ = ""
filename$ = filepanel "load-file", "Open File", current_path$,""
//Open the file
OpenFile()
//BuildDirName$=""
break
case "View:Options:Build Directory|"
ChangDir=1
BuildDir()
break
case "View:File:Save|"
SaveFile()
break
case "View:File:Save As...|"
SaveFileAs()
break
case "View:Run:Compile|"
LISTBOX CLEAR Log$
SaveFile()
BuildDir()
print ("gcc "+filename$+" -o "+BuildDirName$+"/build "+LinkLib$)
if(LinkLib$="")then
if(system("gcc "+filename$+" -o "+BuildDirName$+"/build 2> /boot/home/log.txt")=0)then
alert "Compilation successfull","Ok","Message"
endif
elseif(system("gcc "+filename$+" -o "+BuildDirName$+"/build "+LinkLib$+" 2> /boot/home/log.txt")=0)then
alert "Compilation successfull with lib","Ok","Message"
endif
open "/boot/home/log.txt" for reading as #1
while(!eof(1))
line input #1newline$
LISTBOX ADD Log$, newline$
wend
close #1
break
case "View:File:New|"
NewFile()
break
case "View:File:Close|"
CloseFile()
break
case "View:Run:Run|"
system("Terminal "+BuildDirName$+"/build")
break
case "View:Run:Terminal|"
system("Terminal")
break
case "View:Options:Linking|"
Linking()
break
case "View:Help:About|"
alert "Developed by Kitsune.", "Ok", "About"
break
end switch
//Si on sélectionne un fichier dans la FileBox
if(instr(msg$, "_Select")) then
currentRow = columnbox get "FileBox"
currentItem$ = columnbox get$ "FileBox", 2, currentRow
print "Row: "+str$(currentRow)
print columnbox get$ "FileBox", 1, currentRow
filename$=currentItem$
WINDOW SET "View", "Title", "CCompiler "+filename$
STACKVIEW SET "Stack", currentRow
FilePosition=currentRow
endif
//Si on double-click
if(instr(msg$, "_Invoke")) then
currentRow = columnbox get "FileBox"
currentItem$ = columnbox get$ "FileBox", 2, currentRow
print columnbox get$ "FileBox", 1, currentRow
filename$=currentItem$
WINDOW SET "View", "Title", "CCompiler "+filename$
STACKVIEW SET "Stack", currentRow
FilePosition=currentRow
endif
if(instr(msg$, "Quit"))then
inloop = false
endif
Update()
wend
window close "View"
Exit
//-------------------------------------------------Functions---------------------------------------------
sub Update()
draw flush "View"
draw text 10,h-3,"Line: "+str$(LineNumber)+"/"+str$(LineCount), "View"
return
end sub
sub CloseFile()
if(COLUMNBOX COUNT "FileBox">0)then
currentRow = columnbox get "FileBox"
FilePosition=currentRow
textedit clear "TextEd"+str$(FilePosition)
COLUMNBOX REMOVE "FileBox", FilePosition
if(COLUMNBOX COUNT "FileBox">0)
COLUMNBOX SELECT "FileBox", 1
endif
end Sub
sub SaveFile()
FileDir()
if(current_file$="")then
SaveFileAs()
elseif(current_path$="")then
SaveFileAs()
else
file2save$=textedit get$ "TextEd"+str$(FilePosition)
filename$=current_path$+current_file$
open filename$ for writing as #1
print #1 file2save$
close #1
print ("Saved File at "+filename$)
endif
end sub
sub SaveFileAs()
file2save$=""
filename$=""
print("Filetosave"+filename$)
currentRow = columnbox get "FileBox"
FilePosition=currentRow
print("Position:"+str$(FilePosition))
file2save$ = textedit get$ "TextEd"+str$(FilePosition)
filename$ = filepanel "save-file", "Save File As ...", current_path$,current_file$
if filename$= "" return
COLUMNBOX REMOVE "FileBox", currentRow
FileDir()
columnbox add "FileBox", 1, FileNumber, 18, current_file$
columnbox add "FileBox", 2, FileNumber, 18, filename$
WINDOW SET "View", "Title", "CCompiler "+filename$
open filename$ for writing as #1
print #1 file2save$
close #1
end sub
sub FileDir()
//RĂ©cupĂšre le nom du fichier courant
current_file$=system$("basename "+filename$)
//Supprimer le caractĂšre espace ou "\n" en fin de ligne"
current_file$=rtrim$(current_file$)
FileLenght=len(current_file$)
cpt=0
spacetxt$=""
while(cpt<FileLenght)
spacetxt$=spacetxt$+" "
cpt=cpt+1
wend
print current_path$
current_path$=filename$
right$(current_path$,FileLenght)=spacetxt$
current_path$=rtrim$(current_path$)
print current_path$
print current_file$
print str$(FileLenght)
end sub
sub NewFile()
selected = alert "Would you like to continue to create a new file? This will erase the current content.", "Yes", "No","Save the current File before","info"
if(selected=1)then
TEXTEDIT CLEAR TextEd$
LISTBOX CLEAR Log$
filename$="/boot/home/main.c"
current_file$="main.c"
elseif(selected=3)then
SaveFile()
TEXTEDIT CLEAR TextEd$
LISTBOX CLEAR Log$
current_file$=""
BuildDirName$=""
endif
end sub
//Option menu
sub Linking()
window open 150, 150 to 640,230, "Linking", "Link library"
option set "Linking", "Focus", true
TEXTCONTROL 10,10 TO 480,20, "InputLib", "", LinkLib$, "Linking"
BUTTON 10,40 TO 80,70, "LinkButOk", "Ok", "Linking"
quitting=0
while(not quitting)
m$ =message$
if(m$ = "LinkButOk|")then
LinkLib$ = TEXTCONTROL GET$ "InputLib"
quitting =true
endif
if(instr(m$, "_QuitRequested")) quitting = true
wend
print LinkLib$
window close "Linking"
end sub
sub BuildDir()
if(BuildDirName$="" or ChangDir=1)then
BuildDirName$ = FILEPANEL "Load-Directory", "Select the Build Directory", BuildDirName$,""
ChangDir=0
endif
end sub
//Test if a file is open
sub Opened()
test=1
NumberOfRows = COLUMNBOX COUNT "FileBox"
if(NumberOfRows>0)then
for cpt=1 to NumberOfRows
Item$ = COLUMNBOX GET$ "FileBox", 2, cpt
if(filename$=Item$)then
test=0
cpt = NumberOfRows
else
test=1
endif
next cpt
endif
end sub
sub OpenFile()
Opened()
if(test=0)then
alert "The file "+filename$+" is already open", "Ok","Stop"
elseif(COLUMNBOX COUNT "FileBox"<MAXFILE)then
//Si un fichier est sélectionné
if(not(filename$=""))then
FileDir()
//Gestion de la nouvelle vue
NumberOfRows = COLUMNBOX COUNT "FileBox"
if(NumberOfRows<MAXFILE)then
FileNumber=NumberOfRows+1
endif
columnbox add "FileBox", 1, FileNumber, 18, current_file$
columnbox add "FileBox", 2, FileNumber, 18, filename$
COLUMNBOX SELECT "FileBox", FileNumber
open filename$ for reading as #1
WINDOW SET "View", "Title", "CCompiler "+filename$
while(!eof(1))
//Read a line and stock it in newline
line input #1 newline$
//Add the new line + \n in Text box
textedit add "TextEd"+str$(FileNumber), newline$ + "\n"
wend
//close file
close #1
//Place the cursor to line 1 when finished loading the file
textedit set "TextEd"+str$(FileNumber), "gotoline", 1
stackview set "Stack", FileNumber
endif
else
alert "You have open the maximum of files!", "Ok", "Stop"
endif
end sub
Thank you.
The columnbox is realy simple and have no edit options. Thats why i use more a listbox.
You need to remove the old one and add a new one. If you want the entrys in the alphabetical order you need to clean the complete columnbox and set the entries new into it.
I have change my code without remove the row in the column box but adding a new row in the same place. And that still work for now. But donât sure it will give me some bugs in the futurâŠ
Thatâs seem to work for this SaveAs example.
In Yab IDE the file panel seem to be also a column box.
Hi Kitsune,
i the Yab-IDE the file-panel is a columnbox without sorting function. You can deactivate the sorting function. I think, you doesnât get errors in the future.
Regards lorglas
You need to know that columnbox entry is for the right textedit if you use more then one textedit.
Yes thatâs the case here.
I put my work as example here, I solved some trouble I thinkâŠThis is certainly not perfect but itâs progressing step by step:
window open 50, 50 to 950,700, "View", "CCompiler"
layout "all", "View"
window set "View", "minimumto",640,480
menu "File","New","N","View"
menu "File","Open","O","View"
menu "File","Save","S","View"
menu "File","Save As...","Z","View"
menu "File","Close","X","View"
menu "File","Quit","Q","View"
menu "Run","Compile","K","View"
menu "Run","Run","R","View"
menu "Run","Terminal","T","View"
menu "Run","--","","View"
menu "Run","Make Löve","V","View"
menu "Options","Build Directory","B","View"
menu "Options","Linking","L","View"
menu"Help","About","B","View"
h = window get "View", "height"
//w = window get "View", "width"
LinkLib$=""
current_path$="/boot/home"
current_file$=""
BuildDirName$=""
//Splitview crée 3 vues ajustables
splitview 0,22 to 900,637, "FileSplit", true, false, "View"
splitview 0,0 to 660,614, "TxtSplit", false, false, "FileSplit2"
SPLITVIEW SET "FileSplit", "Divider", 150
SPLITVIEW SET "TxtSplit", "Divider", 500
COLUMNBOX 0,0 TO 145,612, "FileBox", true, "resizable no-sorting", "FileSplit1"
columnbox column "FileBox", "File Name",1, 140, 60, 80, "align-left"
columnbox column "FileBox", "File Path",2, 250, 60, 180, "align-left"
//Initialisation de pages.
MAXFILE=5
stackview 0,0 to 743,h-150, "Stack", MAXFILE+1, "TxtSplit1"
FileNumber=1
for FileNumber=1 to MAXFILE
print ("Generating text editor:"+str$(FileNumber))
textedit 0,0 to 743,h-150, "TextEd"+str$(FileNumber),3,"Stack"+str$(FileNumber)
next FileNumber
FileNumber=1
STACKVIEW SET "Stack", FileNumber
columnbox add "FileBox", 1, 1, 18, "New"+str$(FileNumber)
columnbox add "FileBox", 2, 1, 18, ""
COLUMNBOX SELECT "FileBox", 1
currentRow=1
LISTBOX 0,0 to 743,107, Log$,3, "TxtSplit2"
inloop = true
while(inloop)
//Get the counter of lines
currentRow = columnbox get "FileBox"
if(currentRow>0)then
Option$="countlines"
LineCount=TEXTEDIT GET "TextEd"+str$(currentRow),Option$
Option$ = "currentline"
LineNumber = TEXTEDIT GET "TextEd"+str$(currentRow), Option$
else
LineNumber=0
LineCount=0
endif
Update()
msg$=message$
switch msg$
case "View:_QuitRequested|"
inloop = false
break
case "View:File:Quit|"
inloop = false
break
case "View:File:Open|"
filename$ = ""
filename$ = filepanel "load-file", "Open File", current_path$,""
//Open the file
OpenFile()
break
case "View:Options:Build Directory|"
ChangDir=1
BuildDir()
break
case "View:File:Save|"
SaveFile()
break
case "View:File:Save As...|"
SaveFileAs()
break
case "View:Run:Compile|"
LISTBOX CLEAR Log$
SaveFile()
BuildDir()
GCC_LINE$="gcc "+filename$+" -o "+BuildDirName$+"/build "+LinkLib$
LISTBOX ADD Log$, GCC_LINE$
if(LinkLib$="")then
if(system("gcc "+filename$+" -o "+BuildDirName$+"/build 2> /boot/home/log.txt")=0)then
LISTBOX ADD Log$, "Compilation of "+filename$+" Successfull!"
endif
elseif(system("gcc "+filename$+" -o "+BuildDirName$+"/build "+LinkLib$+" 2> /boot/home/log.txt")=0)then
LISTBOX ADD Log$, "Compilation of "+filename$+" Successfull!"
endif
open "/boot/home/log.txt" for reading as #1
while(!eof(1))
line input #1newline$
LISTBOX ADD Log$, newline$
wend
close #1
break
case "View:File:New|"
NewFile()
break
case "View:File:Close|"
CloseFile()
break
case "View:Run:Run|"
system("Terminal "+BuildDirName$+"/build")
break
case "View:Run:Terminal|"
system("Terminal")
break
case "View:Run:Make Löve|"
MakeLove()
break
case "View:Options:Linking|"
Linking()
break
case "View:Help:About|"
alert "Developed by Kitsune.", "Ok", "About"
break
end switch
//Si on sélectionne un fichier dans la FileBox
if(instr(msg$, "_Select")) then
currentRow = columnbox get "FileBox"
currentItem$ = columnbox get$ "FileBox", 2, currentRow
print "Row: "+str$(currentRow)
print columnbox get$ "FileBox", 1, currentRow
filename$=currentItem$
WINDOW SET "View", "Title", "CCompiler "+filename$
STACKVIEW SET "Stack", currentRow
FileType(filename$,currentRow)
endif
//Si on double-click
if(instr(msg$, "_Invoke")) then
currentRow = columnbox get "FileBox"
currentItem$ = columnbox get$ "FileBox", 2, currentRow
print columnbox get$ "FileBox", 1, currentRow
filename$=currentItem$
WINDOW SET "View", "Title", "CCompiler "+filename$
STACKVIEW SET "Stack", currentRow
FileType(filename$,currentRow)
endif
if(instr(msg$, "Quit"))then
inloop = false
endif
wend
window close "View"
Exit
//-------------------------------------------------Functions---------------------------------------------
sub Update()
h = window get "View", "height"
draw flush "View"
draw text 10,h-3,"Line: "+str$(LineNumber)+"/"+str$(LineCount), "View"
return
end sub
sub CloseFile()
//If more than 0 Row in the column Box then launch the close command
NumberOfRows=COLUMNBOX COUNT "FileBox"
if(NumberOfRows>0)then
Selected=alert "Would you like to save your work before closing the file?", "Yes", "No", "Cancel", "info"
if(Selected=2)then
ClosingFile()
elseif(Selected=1)
SaveFile()
ClosingFile()
endif
// if(COLUMNBOX COUNT "FileBox">0)
// COLUMNBOX SELECT "FileBox", 1
endif
end Sub
sub ClosingFile()
NumberOfRows=COLUMNBOX COUNT "FileBox"
currentRow = columnbox get "FileBox"
textedit clear "TextEd"+str$(currentRow)
COLUMNBOX REMOVE "FileBox", currentRow
for cpt=currentRow to NumberOfRows
if(not(cpt+1>NumberOfRows))then
TxtBuffer$ = textedit get$ "TextEd"+str$(cpt+1)
TEXTEDIT ADD "TextEd"+str$(cpt),TxtBuffer$
textedit clear "TextEd"+str$(cpt+1)
endif
next cpt
if(COLUMNBOX COUNT "FileBox">0)then
COLUMNBOX SELECT "FileBox",1
else
STACKVIEW SET "Stack", MAXFILE+1
endif
end sub
sub SaveFile()
if(COLUMNBOX COUNT "FileBox">0)then
currentRow = columnbox get "FileBox"
filename$ = COLUMNBOX GET$ "FileBox", 2, currentRow
PathFind(filename$)
if(current_file$="")then
SaveFileAs()
elseif(current_path$="")then
SaveFileAs()
else
currentRow = columnbox get "FileBox"
file2save$=textedit get$ "TextEd"+str$(currentRow)
filename$=current_path$+current_file$
open filename$ for writing as #1
print #1 file2save$
close #1
print ("Saved File at "+filename$)
endif
else
alert "No file to save!","Ok","Stop"
endif
end sub
sub SaveFileAs()
if(COLUMNBOX COUNT "FileBox">0)then
file2save$=""
filename$=""
currentRow = columnbox get "FileBox"
filename$ = COLUMNBOX GET$ "FileBox", 2, currentRow
PathFind(filename$)
print("Position:"+str$(currentRow))
file2save$ = textedit get$ "TextEd"+str$(currentRow)
filename$ = filepanel "save-file", "Save File As ...", current_path$,current_file$
if filename$= "" return
print("Filetosave"+filename$)
// COLUMNBOX REMOVE "FileBox", currentRow
//Get the current choosed file name
PathFind(filename$)
FileType(filename$,currentRow)
columnbox add "FileBox", 1, currentRow, 18, current_file$
columnbox add "FileBox", 2, currentRow, 18, filename$
WINDOW SET "View", "Title", "CCompiler "+filename$
open filename$ for writing as #1
print #1 file2save$
close #1
else
alert "No file to save!","Ok","Stop"
endif
end sub
sub NewFile()
FileNumber=FileNumber+1
NumberOfRows=COLUMNBOX COUNT "FileBox"
if(NumberOfRows>=MAXFILE)then
alert "You have reach the maximum of files","Ok","Stop"
else
columnbox add "FileBox", 1, NumberOfRows+1, 18, "New"+str$(FileNumber)
columnbox add "FileBox", 2, NumberOfRows+1, 18, ""
COLUMNBOX SELECT "FileBox", NumberOfRows+1
STACKVIEW SET "Stack", NumberOfRows+1
LISTBOX CLEAR Log$
endif
end sub
//Option menu
sub Linking()
window open 150, 150 to 640,230, "Linking", "Link library"
option set "Linking", "Focus", true
TEXTCONTROL 10,10 TO 480,20, "InputLib", "", LinkLib$, "Linking"
BUTTON 10,40 TO 80,70, "LinkButOk", "Ok", "Linking"
quitting=0
while(not quitting)
m$ =message$
if(m$ = "LinkButOk|")then
LinkLib$ = TEXTCONTROL GET$ "InputLib"
quitting =true
endif
if(instr(m$, "_QuitRequested")) quitting = true
wend
print LinkLib$
window close "Linking"
end sub
sub BuildDir()
if(BuildDirName$="" or ChangDir=1)then
BuildDirName$ = FILEPANEL "Load-Directory", "Select the Build Directory", BuildDirName$,""
ChangDir=0
endif
end sub
//Test if a file is open
sub Opened()
NumberOfRows = COLUMNBOX COUNT "FileBox"
if(NumberOfRows>0)then
for cpt=1 to NumberOfRows
Item$ = COLUMNBOX GET$ "FileBox", 2, cpt
if(not(filename$="") and filename$=Item$)then
cpt = NumberOfRows
return true
endif
next cpt
return false
endif
end sub
sub OpenFile()
if(Opened())then
alert "The file "+filename$+" is already open", "Ok","Stop"
elseif(COLUMNBOX COUNT "FileBox"<MAXFILE)then
//Si un fichier est sélectionné
if(not(filename$=""))then
WINDOW OPEN 200,200 TO 500,250, "Loading", "Loading File"
WINDOW SET "Loading", "Look", "Modal"
DRAW TEXT 30,30, "Loading the file: "+filename$, "Loading"
PathFind(filename$)
//Gestion de la nouvelle vue
NumberOfRows = COLUMNBOX COUNT "FileBox"
if(NumberOfRows<MAXFILE)then
FileNumber=NumberOfRows+1
endif
columnbox add "FileBox", 1, FileNumber, 18, current_file$
columnbox add "FileBox", 2, FileNumber, 18, filename$
COLUMNBOX SELECT "FileBox", FileNumber
open filename$ for reading as #1
FileType(filename$,FileNumber)
WINDOW SET "View", "Title", "CCompiler "+filename$
while(!eof(1))
//Read a line and stock it in newline
line input #1 newline$
//Add the new line + \n in Text box
textedit add "TextEd"+str$(FileNumber), newline$ + "\n"
wend
//close file
close #1
//Place the cursor to line 1 when finished loading the file
textedit set "TextEd"+str$(FileNumber), "gotoline", 1
stackview set "Stack", FileNumber
window close "Loading"
endif
else
alert "You have open the maximum of files!", "Ok", "Stop"
endif
end sub
sub MakeLove()
selected = alert "Select your main.lua file or your Love project directory where is it.", "Single file", "Love Project Directory", "Cancel", "info"
if(selected=1)then
cpt=1
while(cpt)
LoveFile$=""
LoveFile$ = filepanel "load-file", "Open your main.lua file", current_path$,""
filename$=LoveFile$
PathFind(filename$)
LoveFile$=system$("basename "+LoveFile$)
LoveFile$=rtrim$(LoveFile$)
if(LoveFile$="main.lua")then
print "super!"
cpt=0
elseif(LoveFile$="")
cpt=0
elseif(not (LoveFile$="main.lua"))then
alert "Please choose a main.lua file!", "Ok","warning"
endif
wend
if(LoveFile$="main.lua")then
WINDOW OPEN 200,200 TO 500,250, "LoveMaking", "Making LOVE"
WINDOW SET "LoveMaking", "Look", "Modal"
DRAW TEXT 30,30, "Making Love File...Please Wait", "LoveMaking"
system("cd "+current_path$+" && rm -f main.love && zip -J -9 -r -T main.love main.lua")
window close "LoveMaking"
system("cd /bin/x86/ && love "+current_path$+"main.love")
LoveFile$=current_path$+"main.love"
endif
elseif(selected=2)then
cpt=1
while(cpt)
LoveFile$=""
LoveFile$ = filepanel "Load-Directory", "Love Project Directory", current_path$,""
if(LoveFile$="/boot/home")then
selected=alert ("It seem that your choose the /boot/home directory as a Love project folder. This is dangerous!"),"Continue","Choose an other directory", "Cancel", "Stop"
//Continue
if(selected=1)then
cpt=0
//Cancel
elseif(selected=3)then
LoveFile$=""
cpt=0
//Other directory
elseif(selected=2)
cpt=1
selected=0
else
cpt=0
endif
endif
//Searching for the main.lua file
Item$=system$("cd "+LoveFile$+" && dir main.lua")
Item$=rtrim$(Item$)
if(Item$="main.lua")then
cpt=0
elseif(not(LoveFile$=""))
alert "The file main.lua not found in this directory. Please select an other one.", "Ok", "Info"
cpt=1
elseif(LoveFile$="")
cpt=0
endif
wend
if(not(LoveFile$=""))then
WINDOW OPEN 200,200 TO 500,250, "LoveMaking", "Making LOVE"
WINDOW SET "LoveMaking", "Look", "Modal"
DRAW TEXT 30,30, "Making Love File...Please Wait", "LoveMaking"
system("cd "+LoveFile$+" && rm -f main.love && zip -J -9 -r -T main.love *")
window close "LoveMaking"
system("cd /bin/x86/ && love "+LoveFile$+"/main.love")
LoveFile$=LoveFile$+"/main.love"
endif
else
LoveFile$=""
endif
print ("Your Love File is in: "+LoveFile$)
if(not(LoveFile$=""))then
selected = alert "Would you like to build the love file for making it executable?", "Build it!","No", "Recreate a Love File", "Info"
if(selected=1)then
LoveBuild$=""
LoveBuild$ = filepanel "save-file", "Save Executable", "/boot/home", "LoveBuild"
if(not(LoveBuild$=""))then
WINDOW OPEN 200,200 TO 500,250, "BuildLove", "Build LOVE"
WINDOW SET "BuildLove", "Look", "Modal"
DRAW TEXT 30,30, "Making Love Executable...Please Wait", "BuildLove"
system("cat /boot/system/bin/x86/love "+LoveFile$+" > "+LoveBuild$+" && chmod 777 "+LoveBuild$)
window close "BuildLove"
PathFind(LoveBuild$)
system("open "+current_path$)
endif
elseif(selected=3)
MakeLove()
endif
endif
end sub
sub PathFind(path$)
//RĂ©cupĂšre le nom du fichier courant
current_file$=system$("basename "+path$)
//Supprimer le caractĂšre espace ou "\n" en fin de ligne"
current_file$=rtrim$(current_file$)
FileLenght=len(current_file$)
cpt=0
spacetxt$=""
while(cpt<FileLenght)
spacetxt$=spacetxt$+" "
cpt=cpt+1
wend
print current_path$
current_path$=path$
right$(current_path$,FileLenght)=spacetxt$
current_path$=rtrim$(current_path$)
print current_path$
print current_file$
print str$(FileLenght)
end sub
sub FileType(type$,Row)
textedit color "TextEd"+str$(Row),"bgcolor",255,255,255
textedit color "TextEd"+str$(Row),"textcolor",0,0,0
if(right$(type$,2)=".c")then
print "This is a C file"
textedit color "TextEd"+str$(Row),"color2",255,0,0
textedit color "TextEd"+str$(Row),"color1",0,0,255
textedit color "TextEd"+str$(Row),"color3",0,120,0
textedit color "TextEd"+str$(Row),"color3","printf"
textedit color "TextEd"+str$(Row),"color1","int"
textedit color "TextEd"+str$(Row),"color1","char"
textedit color "TextEd"+str$(Row),"color1","double"
textedit color "TextEd"+str$(Row),"color1","float"
textedit color "TextEd"+str$(Row),"color3","main"
textedit color "TextEd"+str$(Row),"color3","include"
textedit color "TextEd"+str$(Row),"color2","return"
textedit color "TextEd"+str$(Row),"color2","if"
textedit color "TextEd"+str$(Row),"color2","else"
elseif(right$(type$,4)=".lua")then
print "This is a LUA file"
elseif(right$(type$,4)=".txt")then
print "This is a Text File"
textedit color "TextEd"+str$(Row),"color1",0,0,0
textedit color "TextEd"+str$(Row),"color2",0,0,0
textedit color "TextEd"+str$(Row),"color3",0,0,0
textedit color "TextEd"+str$(Row),"color4",0,0,0
else
textedit color "TextEd"+str$(Row),"color1",0,0,0
textedit color "TextEd"+str$(Row),"color2",0,0,0
textedit color "TextEd"+str$(Row),"color3",0,0,0
textedit color "TextEd"+str$(Row),"color4",0,0,0
print "This is a unrecognized file type"
endif
end sub
If you encounter some troubles, please put the step of the way you encounter it.
Thanks.
Yes I had do it cause thatâs making trouble about Files management. Thanks
Your app looks good. Is good, that you make a editor for löve2D. I say, that i will do that, but at the moment i have no time.
Yes I have put a Make love button in it, I work on it for âcompilingâ but I donât work on the syntax for now.
I have updated the code , the button making love work now. That create a Love file named main.love in the same directory of the main.lua fileâŠAnd launch Love after it making. You can build the love file to an executable. For now that always overwrite a /boot/home/MyLoveBuild file (for the executable).
You must have Love Installed. Zip too (command line) and GCC for compile in C. Here love is in the /bin/86 folder of Haiku (32bits version).
I donât know if that work on 64bit haiku system. Cause the love directory itâs not the same I think. Also donât know if YabIDE work on 64Bits.