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.