#!/boot/home/config/bin/yab
//localize

##### Allgemeines ##### 

Programmname$="HtmlEditor"
Version$="1.0"
Versionsdatum$="11.10.2006"
Entwickler$="Christian Albrecht"
Nickname$="Lelldorin"
Url_Label$="BeSly Projects"
Url_Text$="http://www.besly.de"

##### Fensternamen #####
Hpt_Fenster$=Programmname$
Lade_Fenster$=""

##### Bildschirmgröße #####
B_Breite = peek("desktopwidth")
B_Hoehe = peek("desktopheight")

##### Fenstergröße #####

F_Hoehe1=((B_Hoehe/2)-300)
F_Hoehe2=((B_Hoehe/2)+300)

F_Breite1=((B_Breite/2)-300)
F_Breite2=((B_Breite/2)+300)

F_minBreite=800
F_maxBreite=800
F_minHoehe=600
F_maxHoehe=600

##### Editor View Groesse #####

Editor_Breite1=240
Editor_Breite2= 790
Editor_Hoehe1=120
Editor_Hoehe2=590

##### Texteditor Groesse #####

TE_Breite1=5
TE_Breite2=535
TE_Hoehe1=30
TE_Hoehe2=420

##### Tab Optionen #####

Opt_Breite1=240
Opt_Breite2=790
Opt_Hoehe1=30
Opt_Hoehe2=110

##### Tab Auswahl #####

Sel_Breite1=10
Sel_Breite2=230
Sel_Hoehe1=120
Sel_Hoehe2=590

##### Listbox Programmiersprache Auswahl #####

LB_HTML_Breite1=10
LB_HTML_Breite2=200
LB_HTML_Hoehe1=40
LB_HTML_Hoehe2=420

##### Programmverzeichnis ######

Prg_Ordner$=""
Gfx_Ordner$=""
Hlp_Ordner$=""
Sfx_Ordner$=""

##### Programmstart #####

Prg_Fenster()

################################	
	
	
	
	
dim part$(1)

inloop = true
while(inloop)

	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 (msg$ <> "") print msg$

	switch msg$
	
	case Hpt_Fenster$+":_QuitRequested|"
		window close Hpt_Fenster$
		window close "View_Ueber"
		window close "View_Hilfe"
	break
	
	case translate$(Hpt_Fenster$+":Program:Quit")+"|"
		window close Hpt_Fenster$
		window close "View_Ueber"
		window close "View_Hilfe"
	break
	
	case "Beenden_View_Ueber|"
		window close "View_Ueber"
	break
	
	case "Beenden_View_Hilfe|"
		window close "View_Hilfe"
	break

	
	
	//Funktionen
	
	case "DB_Drives:"+PartTwo$+"|"
		Drive_Selection$=PartTwo$
		read_folders()
	break
	
	case Programmname$+":View:Fullscreen|"
		F_Hoehe1=0
		F_Hoehe2=B_Hoehe

		F_Breite1=0
		F_Breite2=B_Breite

		F_minBreite=800
		F_maxBreite=B_Breite
		F_minHoehe=600
		F_maxHoehe=B_Hoehe
		
		Editor_Breite2=F_Breite2-20
		Editor_Hoehe2=F_Hoehe2-20
		
		TE_Breite2=Editor_Breite2-255
		TE_Hoehe2=Editor_Hoehe2-190
		
		Opt_Breite2=Editor_Breite2
		
		Sel_Hoehe2=Editor_Hoehe2
		
		LB_HTML_Hoehe2=TE_Hoehe2
		
		window close Hpt_Fenster$
		Prg_Fenster()
	break
	
	case Programmname$+":View:Default|"
		F_Hoehe1=((B_Hoehe/2)-300)
		F_Hoehe2=((B_Hoehe/2)+300)

		F_Breite1=((B_Breite/2)-300)
		F_Breite2=((B_Breite/2)+300)

		F_minBreite=800
		F_maxBreite=800
		F_minHoehe=600
		F_maxHoehe=600
		
		Editor_Breite2=790
		Editor_Hoehe2=590
		
		TE_Breite2=535
		TE_Hoehe2=420
		
		Opt_Breite2=790
		
		Sel_Hoehe2=590
		
		LB_HTML_Hoehe2=420
		
		window close Hpt_Fenster$
		Prg_Fenster()
	break
	
	case "CB_Files:_Invoke:"+PartThree$+"|"
		dateiauswahl$=COLUMNBOX GET$ "CB_Files", 2, val(PartThree$)
		print dateiauswahl$
		DateiLaden()
	break
	
	case "CB_Folders:_Invoke:"+PartThree$+"|"
		foldername$=COLUMNBOX GET$ "CB_Folders", 2, val(PartThree$)
		if(foldername$="..")then
			VerzeichnisZurueck()
		else
			Drive_Selection$=Drive_Selection$+"/"+foldername$
			read_folders()
		endif
	break
	
	default:

	end switch

	if(window count<1) inloop = false
	sleep 0.1
wend

sub Prg_Fenster()
	window open F_Breite1,F_Hoehe1 to F_Breite2,F_Hoehe2, Hpt_Fenster$, "BeSly Software "+Programmname$
		window set Hpt_Fenster$, "MinimumTo", F_minBreite,F_minHoehe
		window set Hpt_Fenster$, "MaximumTo", F_maxBreite,F_maxHoehe
		WINDOW SET Hpt_Fenster$, "Flags", "not-zoomable"
		
	menu "Program", translate$("About"), "", Hpt_Fenster$
	menu "Program", translate$("Help"), "", Hpt_Fenster$
	menu "Program", translate$("Documentation"), "", Hpt_Fenster$
	menu "Program", translate$("Options"), "", Hpt_Fenster$
	menu "Program", translate$("Quit"), "", Hpt_Fenster$
	menu "View", translate$("Fullscreen"), "", Hpt_Fenster$
	menu "View", translate$("Default"), "", Hpt_Fenster$
	
	TABVIEW Sel_Breite1,Sel_Hoehe1 TO Sel_Breite2,Sel_Hoehe2, "Tab_Selection", "bottom", Hpt_Fenster$
		TABVIEW ADD "Tab_Selection", "File"
			DROPBOX 4,10 TO 125,20, "DB_Drives", "", "Tab_Selection1"
				DROPBOX ADD "DB_Drives", "Select Drive"
				DROPBOX ADD "DB_Drives", "--"
			COLUMNBOX 10,40 TO 200,200, "CB_Folders",true, "movable", "Tab_Selection1"
				COLUMNBOX COLUMN "CB_Folders", "__Icon__", 1, 60, 20, 20, "align-left"
				COLUMNBOX COLUMN "CB_Folders", "Name", 2, 60, 200, 20, "align-left"			
			COLUMNBOX 10,220 TO 200,420, "CB_Files",true, "movable", "Tab_Selection1"
				COLUMNBOX COLUMN "CB_Files", "__Icon__", 1, 60, 20, 20, "align-left"
				COLUMNBOX COLUMN "CB_Files", "Name", 2, 60, 200, 20, "align-left"
		TABVIEW ADD "Tab_Selection", "Code"
			DROPBOX 4,10 TO 125,20, "DB_Language", "", "Tab_Selection2"
				DROPBOX ADD "DB_Language", "Select Language"
				DROPBOX ADD "DB_Language", "--"
				DROPBOX ADD "DB_Language", "HTML"
				DROPBOX ADD "DB_Language", "PHP"
				DROPBOX ADD "DB_Language", "XML"
				DROPBOX ADD "DB_Language", "JavaScript"
				DROPBOX ADD "DB_Language", "CGI"
				DROPBOX ADD "DB_Language", "Perl"
				DROPBOX ADD "DB_Language", "CSS"
			COLUMNBOX LB_HTML_Breite1,LB_HTML_Hoehe1 TO LB_HTML_Breite2,LB_HTML_Hoehe2, "CB_HTML", true, "movable", "Tab_Selection2"
				columnbox column "CB_HTML", "__Icon__", 1, 60, 20, 20, "align-left"
				columnbox column "CB_HTML", "Name", 2, 60, 200, 20, "align-left"

	TABVIEW Opt_Breite1,Opt_Hoehe1 TO Opt_Breite2,Opt_Hoehe2, "Tab_Options", "top", Hpt_Fenster$
		TABVIEW ADD "Tab_Options", "Frames" 
		TABVIEW ADD "Tab_Options", "Tables" 
		TABVIEW ADD "Tab_Options", "Fonts"
		TABVIEW ADD "Tab_Options", "Images"  
	
	TABVIEW Editor_Breite1, Editor_Hoehe1 TO Editor_Breite2,Editor_Hoehe2, "Tab_Editor", "bottom", Hpt_Fenster$
		TABVIEW ADD "Tab_Editor", "Default" 		
		TEXTEDIT TE_Breite1,TE_Hoehe1 TO TE_Breite2,TE_Hoehe2, "editor", 3, "Tab_Editor1"
			TEXTEDIT COLOR "editor", "char-color", "<"
			TEXTEDIT COLOR "editor", "char-color", ">"
			TEXTEDIT COLOR "editor", "char-color", "="
			TEXTEDIT COLOR "editor", "char-color", "/"
			TEXTEDIT COLOR "editor", "char-color", "#"
			TEXTEDIT COLOR "editor", "char-color", "<?"
			TEXTEDIT COLOR "editor", "char-color", "?>"
	read_drives()
	
	
	
end sub



sub ueber()
	REM ###### Fenstergröße #######
	
	F_Hoehe_Ueber1=((B_Hoehe/2)-100)
	F_Hoehe_Ueber2=((B_Hoehe/2)+100)
	
	F_Breite_Ueber1=((B_Breite/2)-100)
	F_Breite_Ueber2=((B_Breite/2)+100)
	
	window open F_Breite_Ueber1,F_Hoehe_Ueber1 to F_Breite_Ueber2,F_Hoehe_Ueber2, "View_Ueber", "About"
		window set "View_Ueber", "MinimumTo", 260,200
		window set "View_Ueber", "MaximumTo", 260,200
		window set "View_Ueber", "look", "modal"
		
	draw text 10, 20, Programmname$, "View_Ueber"
	draw text 10, 60, translate$("Version/Date: ")+Version$+" / "+Versionsdatum$, "View_Ueber"
	draw text 10, 80, translate$("Developer: ")+Entwickler$, "View_Ueber"
	draw text 10, 100, translate$("Nickname: ")+Nickname$, "View_Ueber"
	draw text 10, 120, translate$("Webside: "), "View_Ueber"
	texturl 90,112, "", Url_Label$, Url_Text$, "View_Ueber"
	BUTTON 80,160 TO 180,180, "Beenden_View_Ueber", translate$("Schließen"), "View_Ueber"
end sub

sub hilfe()
	REM ###### Fenstergröße #######
	
	F_Hoehe_Hilfe1=((B_Hoehe/2)-150)
	F_Hoehe_Hilfe2=((B_Hoehe/2)+150)
	
	F_Breite_Hilfe1=((B_Breite/2)-150)
	F_Breite_Hilfe2=((B_Breite/2)+150)
	
	window open F_Breite_Hilfe1,F_Hoehe_Hilfe1 to F_Breite_Hilfe2,F_Hoehe_Hilfe2, "View_Hilfe", "Help"
		window set "View_Hilfe", "MinimumTo", 300,300
		window set "View_Hilfe", "MaximumTo", 300,300
		window set "View_Hilfe", "look", "modal"		
		
	BUTTON 100,260 TO 200,280, "Beenden_View_Hilfe", translate$("Close"), "View_Hilfe"
end sub

sub read_drives()
	rDrives$=system$("ls -G -1 /")	
	dim SplitDrives$(1)
	rda=0
	rdb=0
	rda = split(rDrives$, SplitDrives$(), "\n")            
	for rdb = 1 to rda-1
		dropbox add "DB_Drives", SplitDrives$(rdb)
	next rdb
end sub

sub read_folders()
	COLUMNBOX CLEAR "CB_Files"
	COLUMNBOX CLEAR "CB_Folders"
	COLUMNBOX ADD "CB_Folders", 2, 1, 15, ".."
	x=1
	dim SplitFolderEntrys$(1)
	CheckFolderEntrys$=system$("ls -1 /"+"\""+Drive_Selection$+"\"")
	entrys=split(CheckFolderEntrys$, SplitFolderEntrys$(), "\n")
	
	dim SplitEntrys$(1)
	for look = 2 to entrys
		x=x+1
		Folder$="/"+Drive_Selection$+"/"+SplitFolderEntrys$(x)
		CheckFolder$=system$("ls -allAd "+"\""+Folder$+"\"")
		g = split(CheckFolder$, SplitEntrys$(), " ")
		if(mid$(SplitEntrys$(1),1,1)="-")then
			COLUMNBOX ADD "CB_Files", 2, x, 15, SplitFolderEntrys$(x)
		elseif(mid$(SplitEntrys$(1),1,1)="d")then
			COLUMNBOX ADD "CB_Folders", 2, x, 15, SplitFolderEntrys$(x)
		elseif(mid$(SplitEntrys$(1),1,1)="l")then
		endif
	next look
end sub

sub DateiLaden()
	auslesen=open("/"+Drive_Selection$+"/"+dateiauswahl$, "r")
	x=0
	while (not EOF(auslesen))
   		x=x+1
		dim FileLoad$(x)
   	 	line input #auslesen b$
		FileLoad$(x)=b$
		FullSizeFile=x
	wend
	close(auslesen)
	ladebalken()
end sub

sub ladebalken()
	F_Hoehe_Ueber1=((B_Hoehe/2)-100)
	F_Hoehe_Ueber2=((B_Hoehe/2)+100)
	
	F_Breite_Ueber1=((B_Breite/2)-200)
	F_Breite_Ueber2=((B_Breite/2)+200)
	
	window open F_Breite_Ueber1,F_Hoehe_Ueber1 to F_Breite_Ueber2,F_Hoehe_Ueber2, "View_Ladebalken", "xxx"
		window set "View_Ladebalken", "MinimumTo", 400,200
		window set "View_Ladebalken", "MaximumTo", 400,200
		window set "View_Ladebalken", "look", "modal"
	
	view 20,60 to 380,80, "DrawView", "View_Ladebalken"
		draw set "BgColor", 255,255,255, "DrawView"
 		draw set "HighColor", 108,166,205,"DrawView"
		draw set 0, "HighSolidFill"
		BalkenPosition=0
		TextLadebalken$="loading document"
		TextLadebalken=len(TextLadebalken$) 
		draw text (160-(TextLadebalken/2)), 15, TextLadebalken$, "DrawView"
		
	x=0
	for size=1 to FullSizeFile
		ProzentSize=(size*100)/320
		BalkenPosition=(320*ProzentSize)/100
		draw rect 0,0 to BalkenPosition,20, "DrawView"
		TEXTEDIT ADD "editor", FileLoad$(size)
		TEXTEDIT ADD "editor", "\n"
	next size
	
	DRAW FLUSH "DrawView"
	TextLadebalken$="ready!"
	TextLadebalken=len(TextLadebalken$)
	//WINDOW CLOSE "View_Ladebalken"
	end sub

sub VerzeichnisZurueck()
	SizeFolderString=0
	BackFolder=0
	SizeFoldername=0
	dim FolderBack$(1)
	SizeFolderString=len(Drive_Selection$)
	BackFolder=split(Drive_Selection$, FolderBack$(), "/")
	SizeFoldername=len(FolderBack$(BackFolder))
	BackDriveName$=left$(Drive_Selection$, (SizeFolderString-(SizeFoldername+1)))
	if(BackDriveName$="")then
		read_folders()
	else
		Drive_Selection$=BackDriveName$
		read_folders()
	endif
end sub