Html_Editor/HTML_Edit_291206.yab
be90e3c2
 #!/boot/home/config/bin/yab
 //localize
 
 ##### Allgemeines ##### 
 
 Programmname$="HtmlEditor"
 Version$="1.0"
 Versionsdatum$="11.10.2006"
 Entwickler$="Christian Albrecht, Lorenz Glaser"
 Nickname$="Lelldorin, Lorglas"
 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$=""
 ProgrammierSprachenVerzeichnis$="/boot/home/Projekte/yab/Html_Editor/ProgrammierSprachen"
 ##### Programmstart #####
 
 Prg_Fenster()
 
 ################################	
 	
 	ProgrammierSprachen(ProgrammierSprachenVerzeichnis$)
 	
 	
 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
 	
 	case "DB_Language:"+PartTwo$+"|"
 		Auswahl$=PartTwo$
 		COLUMNBOX CLEAR "CB_HTML" //ColumnBox$
 		ProgrammierSprachenInhalt(Auswahl$)		
 	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", "--"	
 			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", 1, x, 15, "__Path__="+SplitFolderEntrys$(x)
 			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
 	StatusLeisteAufbau()
 	while (not EOF(auslesen))
    		x=x+1
 		dim FileLoad$(x)
    	 	line input #auslesen b$
 		FileLoad$(x)=b$		
 		statusleiste(x)
 	wend
 	close(auslesen)
 	Dateigroesse=x
 	print "Dateigroesse "+str$(Dateigroesse)
 	//ladebalken()
 	WINDOW CLOSE "View_Ladebalken"
 end sub
 sub StatusLeisteAufbau() 
 	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,180, "DrawView", "View_Ladebalken"
 		draw set "BgColor", 255,255,255, "DrawView"
  		draw set "HighColor", 108,166,205,"DrawView"
 		draw set 0, "HighSolidFill"
 		
 	//STATUSBAR 10, 40 to 360, 80, "ID$", "Label1$", "Label2$", "DrawView"
 	
 end sub
 sub statusleiste(x)
 	draw set "highcolor", 0,0,0, "DrawView"	
 	draw set 1, "HighSolidFill"
 	draw circle 50,50, 41, "DrawView"
 	draw set "highcolor", 0,0,245, "DrawView"
 
 	radius=radius+0.125	
 	draw line 50,50 to 50+cos(radius)*40,50+sin(radius)*40, "DrawView"
 	//print radius
 	if (radius=360) then
 		radius=0
 	endif	
 	TEXTEDIT ADD "editor", FileLoad$(x)
 		TEXTEDIT ADD "editor", "\n"
 	//STATUSBAR SET "ID$", "Label1$", "Label2$", x
 	wait 0.01
 	DRAW FLUSH "DrawView"
 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,180, "DrawView", "View_Ladebalken"
 		draw set "BgColor", 255,255,255, "DrawView"
  		draw set "HighColor", 108,166,205,"DrawView"
 		draw set 0, "HighSolidFill"
 		
 	STATUSBAR 10, 40 to 360, 80, "ID$", "Label1$", "Label2$", "DrawView"
 	STATUSBAR SET "ID$", "Label1$", "Label2$", x
 		//BalkenPosition=0
 	//	TextLadebalken$="loading document"
 	//	TextLadebalken=len(TextLadebalken$) 
 	//	draw text (160-(TextLadebalken/2)), 15, TextLadebalken$, "DrawView"		
 	//	Prozent=Dateigroesse/100
 	//	print Prozent
 	//	BalkenPosition=(Prozent*360)/100
 	//	print BalkenPosition
 		//TeilBalken=BalkenPosition/3.6
 	//  schleife=360/BalkenPosition
 	//	print schleife
 	//	z=1
 	//for Balken=1 to schleife		
 	//	TeilBalken=BalkenPosition*Balken
 	//	draw rect 0,0 to TeilBalken,20, "DrawView"
 	//	//wait 0.1
 	//	z=z+1
 	//	print z	
 	//	print TeilBalken	
 	//next Balken
 	for size=1 to Dateigroesse			
 		//ProzentSize=(size*100)/320
 		//BalkenPosition=(320*ProzentSize)/100
 		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
 
 sub ProgrammierSprachen(ProgrammierSprachenVerzeichnis$)				
 				verzeichnisinhalt$=system$("ls -QA "+"\""+ProgrammierSprachenVerzeichnis$+"\"")
 				print verzeichnisinhalt$
 				dim splitdir_li$(1)
 				n = split(verzeichnisinhalt$, splitdir_li$(), "\n")
 					i=0
 				b_li$="\""
 				       
 				//dateiname anzeigen     
 				for i = 1 to n-1					
 				 	posname_li=instr(splitdir_li$(i),b_li$,1)		 
 		 			dateiname_li$=mid$(splitdir_li$(i),posname_li+1)
 		 			posname_ende_li=len(dateiname_li$)
 			 	    dateiname_ohne_li$=left$(dateiname_li$,posname_ende_li-1)
 			 	   // print dateiname_ohne_li$			
 				DROPBOX ADD "DB_Language", dateiname_ohne_li$			
 				next i
 end sub
 sub ProgrammierSprachenInhalt(Auswahl$)
 	ir=0
 	xt=0
 	az=0	
 	DateiAuswahl$=ProgrammierSprachenVerzeichnis$+"/"+Auswahl$
 	auslesen=open(DateiAuswahl$, "r")
 
 	while (not EOF(auslesen))
 		line input #auslesen b$
 		dim elements$(1)
 		numElements = split(b$, elements$(),";")
 		for ir = 1 to numElements
 			xt=xt+1
 			dim d$(xt)
 			d$(xt) = elements$(ir)
 			print d$(xt)
 		next ir
 	wend
 	close(auslesen)
 		anzahlspalten=numElements
 		
 	if (anzahlspalten<1) then
 		anzahlzeilen=0
 	else
 		anzahlzeilen=xt/anzahlspalten
 	endif
 	print anzahlzeilen
 	if (anzahlzeilen>0) then
 		for az = 1 to anzahlzeilen			
 			//COLUMNBOX ADD ColumnBox$, Column, Row, Height, Item$
 			columnbox ADD "CB_HTML", 2, az, 20, d$(az) 			
 		next az	
 	else
 			columnbox ADD "CB_HTML", 2, 1, 20, "Keine Inhalte vorhanden"
 	endif
 end sub