gtkdialog2html add color to code (code parser too)

For discussions about programming and projects not necessarily associated with Porteus.
Post Reply
User avatar
bigbass
Contributor
Contributor
Posts: 151
Joined: 13 Jan 2012, 14:35
Distribution: slackware 14

gtkdialog2html add color to code (code parser too)

Post#1 by bigbass » 15 Apr 2012, 15:32

these are official examples converted to have colored tags and tested


click on the link to see the html page
examples with images and color highlighted code all in one place
also fixing or replacing any non working examples to work on Porteus
http://puppy2.org/slaxer/Porteus/Gtkdia ... color.html

so now it is possible to have
syntax highlighting for gtkdialog!!! I may add a GUI later that calls this backend tool
I find it a must to have some sort of syntax highlighting while writing code

but the cool part is you can select text and paste it into your text editor
and the color is removed so you can use the code this acts like a syntax
checking tool if you had a typo the tag the color wouldn't be shown

I wrote a program in BaCon that automatically converts the gtkdialog tags to html
and adds color and retains the original indentation :)
*I love BaCon basic reminds me of the good old days *
bash scripting is fun but compiling very fast cli binaries with BaCon is cool
source Bacon compiles to a binary C app
it is very fast at converting the code

so the end result is a command line binary that can be called simply
to do all the conversion from gtkdialog to html automatically



version one this does all tags prior to thunors updates
I will be doing thunors one at a time too but will be taking a little break
it took 14 days to get this far :shock:

Code: Select all


'--- ***************************************************** '
'--- PROGRAM:	gtkdialog2html.bac '
'--- PURPOSE:	gtkdialog code with forced syntax color and indentation '
'--- AUTHOR:	big_bass Joe Arose   '
'--- DEPENDS:	gcc, bacon,  '
'--- PLATFORM:	linux '
'--- DATE:		April 14-28 ,2012'
'--- NOTES:	    syntax tag highlighting for gtkdialog 
'--- LICENSE:	GPL version 3 or later '
'--- *****************************************************'


'--- convert syntax from gtkdialog  to html format ---'
'--- this is also for modifing of code with justified indentation
'--- USUAGE: ./gtkdialog2html /path-and-filename" ---'
'--- note the file will get a .gtkdialog-fixed.html added to the filename ---'
'--- on error print usage ---'
'--- this part was added to for variables to be passed at command line ---'

CONST Single_quote$ = CHR$(39)
CONST Double_quote$ = CHR$(34)
CONST Dollar_sign$ = CHR$(36)

TRAP LOCAL
SPLIT ARGUMENT$ BY " " TO arg$ SIZE dim
IF LEN(arg$[1]) EQ 0 THEN
     PRINT "USUAGE:  ./gtkdialog2html /path-and-filename"
     END
END IF

Tab$ = CHR$(9)
FIVE_BLANKS$ = SPC$(5)



'--- copy_this$ is the first argument passed from the command line ---'
'--- path-and-filename is arg$[1] this is a valid bacon argument ---'
'--- give it a string name for clarity  ---'
copy_this$ = arg$[1]


'--- another code snippet from GatorDog thanks ---'
IF ISFALSE(FILEEXISTS(copy_this$)) THEN
     PRINT NL$, "=>> ", copy_this$, " <<== not found."
     PRINT "Please check your directory for assistance ;>)", NL$
END FALSE
END IF



'still need to add these a reminder 



'<window></window>
'<i>Italic</i>  '<u>underlined</u>  '<s>strikethrough</s> 
'<small>Small</small> '<big>Large</big>'<tt>Monospace</tt> 
'<sup>Supercript</sup> '<sub>Subscript</sub> '<span></span> 
'<span color="blue">this is in color</span> 



'--- catch any stray greater than less than symbols in comments ---'
Greater_than$ = CONCAT$("&","gt",";")
Less_than$ = CONCAT$("&","lt",";")


'--- add color to tags ---'
'--- there are quirky things that happen with html code when you want to view ---'
'--- code from XML as readable text you have to convert special characters ---'
'--- and you have to allow for line indentation html cuts  off leading spaces by default ---'


'--- grouped by color  action,combobox ,entry,item---'
'--- blue ---'


Combobox_color$ = CONCAT$("<span style=","\"background-color:DodgerBlue;" ,"\">" , "<combobox>" ,"</", "span>")
Combobox_color_close$ = CONCAT$("<span style=","\"background-color:DodgerBlue" ,"\">" , "</combobox>" ,"</", "span>")

Combobox_case_sensitive_color$ = CONCAT$("<span style=","\"background-color:DodgerBlue;" ,"\">" , "<combobox case-sensitive=" ,"</", "span>")
Combobox_allow_empty_color$ = CONCAT$("<span style=","\"background-color:DodgerBlue;" ,"\">" , "<combobox allow-empty=" ,"</", "span>")



Action_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<action>" ,"</", "span>")
Action_color_close$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "</action>" ,"</", "span>")



'---action type    special formatting needed---'
Action_type_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<action type=" ,"</", "span>")
Action_signal_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<action signal=" ,"</", "span>")



Entry_activates_default_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<entry activates_default=" ,"</", "span>")
Entry_editable_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<entry editable=" ,"</", "span>")
Entry_has_frame_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<entry has_frame=" ,"</", "span>")
Entry_max_length_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<entry max_length=" ,"</", "span>")
Entry_invisible_char_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<entry width_chars=" ,"</", "span>")
Entry_width_chars_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<entry invisible_char=" ,"</", "span>")

Entry_color$ = CONCAT$("<span style=","\"background-color:Bisque;" ,"\">" , "<entry>" ,"</", "span>")
Entry_color_close$ = CONCAT$("<span style=","\"background-color:Bisque;" ,"\">" , "</entry>" ,"</", "span>")
Entry_accept_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<entry accept=" ,"</", "span>")
Entry_activates_default_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<entry activates-default=" ,"</", "span>")

'---Chartreuse
While_condition_color$ = CONCAT$("<span style=","\"background-color:HotPink;" ,"\">" , "<while condition=" ,"</", "span>")
While_color_close$ = CONCAT$("<span style=","\"background-color:HotPink;" ,"\">" , "</while>" ,"</", "span>")


'--- special formatting needed---'

Item_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<item>" ,"</", "span>")
Item_color_close$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "</item>" ,"</", "span>")

Item_stock_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<item stock=" ,"</", "span>")
Item_stock_id_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<item stock_id=" ,"</", "span>")
Item_icon_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<item icon=" ,"</", "span>")
Item_icon_name_color$ = CONCAT$("<span style=","\"color:blue;" ,"\">" , "<item icon_name=" ,"</", "span>")

'--- grouped by color ---'
'--- LimeGreen ---'

Button_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<button>" ,"</", "span>")
Button_color_close$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "</button>" ,"</", "span>")

Button_no_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<button no>" ,"</", "span>")
Button_yes_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<button yes>" ,"</", "span>")
Button_cancel_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<button cancel>" ,"</", "span>")
Button_ok_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<button ok>" ,"</", "span>")
Button_help_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<button help>" ,"</", "span>")
Button_can_default_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<button can-default=" ,"</", "span>")


'---   special formatting needed---'
Button_sensitive_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<button sensitive=" ,"</", "span>")

Radiobutton_active_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<radiobutton active=" ,"</", "span>")
Radiobutton_draw_indicator_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<radiobutton draw_indicator=" ,"</", "span>")
Radiobutton_inconsistent_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<radiobutton inconsistent=" ,"</", "span>")

Radiobutton_color$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "<radiobutton>" ,"</", "span>")
Radiobutton_color_close$ = CONCAT$("<span style=","\"background-color:LimeGreen;" ,"\">" , "</radiobutton>" ,"</", "span>")



'--- grouped by color ---'
'--- MediumPurple  Bisque---'

Checkbox_color$ = CONCAT$("<span style=","\"background-color:MediumPurple;" ,"\">" , "<checkbox>" ,"</", "span>")
Checkbox_color_close$ = CONCAT$("<span style=","\"background-color:MediumPurple" ,"\">" , "</checkbox>" ,"</", "span>")



'---action type    special formatting needed---'
Checkbox_active_color$ = CONCAT$("<span style=","\"background-color:MediumPurple;" ,"\">" , "<checkbox active=" ,"</", "span>")
Checkbox_draw_indicator_color$ = CONCAT$("<span style=","\"background-color:MediumPurple;" ,"\">" , "<checkbox draw_indicator=" ,"</", "span>")
Checkbox_inconsistent_color$ = CONCAT$("<span style=","\"background-color:MediumPurple;" ,"\">" , "<checkbox inconsistent=" ,"</", "span>")
 


'--- grouped by color ---'
'--- cyan ---'

Label_color$ = CONCAT$("<span style=","\"background-color:cyan;" ,"\">" , "<label>" ,"</", "span>")
Label_color_close$ = CONCAT$("<span style=","\"background-color:cyan;" ,"\">" , "</label>" ,"</", "span>")

Text_color$ = CONCAT$("<span style=","\"background-color:cyan;" ,"\">" , "<text>" ,"</", "span>")
Text_color_close$ = CONCAT$("<span style=","\"background-color:cyan;" ,"\">" , "</text>" ,"</", "span>")

Text_use_markup_color$ = CONCAT$("<span style=","\"background-color:cyan;" ,"\">" , "<text use-markup=" ,"</", "span>")
Text_wrap_color$ = CONCAT$("<span style=","\"background-color:cyan;" ,"\">" , "<text wrap=" ,"</", "span>")
Text_selectable_color$ = CONCAT$("<span style=","\"background-color:cyan;" ,"\">" , "<text selectable=" ,"</", "span>")


'--- grouped by color ---'
'--- yellow ---'

Hbox_color$ = CONCAT$("<span style=","\"background-color:yellow;" ,"\">" , "<hbox>" ,"</", "span>")
Hbox_color_close$ = CONCAT$("<span style=","\"background-color:yellow;" ,"\">" , "</hbox>" ,"</", "span>")
Hbox_spacing_color$ = CONCAT$("<span style=","\"background-color:yellow;" ,"\">" , "<hbox spacing=" ,"</", "span>")
Hbox_homogeneous_color$ = CONCAT$("<span style=","\"background-color:yellow;" ,"\">" , "<hbox homogeneous=" ,"</", "span>")
Hbox_fill_color$ = CONCAT$("<span style=","\"background-color:yellow;" ,"\">" , "<hbox fill=" ,"</", "span>")



'----frame is a special opened on the left side no close
Frame_color$ = CONCAT$("<span style=","\"background-color:BurlyWood;" ,"\">" , "<frame " ,"</", "span>")
Frame_color_close$ = CONCAT$("<span style=","\"background-color:BurlyWood;" ,"\">" , "</frame>" ,"</", "span>")



'--- grouped by color ---'
'--- orange ---'

Vbox_color$ = CONCAT$("<span style=","\"background-color:orange;" ,"\">" , "<vbox>" ,"</", "span>")
Vbox_color_close$ = CONCAT$("<span style=","\"background-color:orange;" ,"\">" , "</vbox>" ,"</", "span>")


'--- grouped by color ---'
'--- red ---'
Input_file_color$ = CONCAT$("<span style=","\"color:Red;" ,"\">" , "<input file>" ,"</", "span>")
Input_file_color_close$ = CONCAT$("<span style=","\"color:Red;" ,"\">" , "</input>" ,"</", "span>")

Input_color$ = CONCAT$("<span style=","\"color:Red;" ,"\">" , "<input>" ,"</", "span>")
Input_color_close$ = CONCAT$("<span style=","\"color:Red;" ,"\">" , "</input>" ,"</", "span>")

Input_file_stock_color$ = CONCAT$("<span style=","\"color:Red;" ,"\">" , "<input file stock=" ,"</", "span>")
Input_icon_column_color$ = CONCAT$("<span style=","\"color:Red;" ,"\">" , "<input icon_column=" ,"</", "span>")  
Input_file_icon_color$ = CONCAT$("<span style=","\"color:Red;" ,"\">" , "<input file icon=" ,"</", "span>")  
 

 

   
Pixmap_icon_size_color$ = CONCAT$("<span style=","\"background-color:OrangeRed;" ,"\">" , "<pixmap icon_size=" ,"</", "span>")

Pixmap_color$ = CONCAT$("<span style=","\"background-color:OrangeRed;" ,"\">" , "<pixmap>" ,"</", "span>")
Pixmap_color_close$ = CONCAT$("<span style=","\"background-color:OrangeRed;" ,"\">" , "</pixmap>" ,"</", "span>")
 


'--- grouped by color ---'
'--- others ---'


Menubar_color$ = CONCAT$("<span style=","\"background-color:Khaki;" ,"\">" , "<menubar>" ,"</", "span>")
Menubar_color_close$ = CONCAT$("<span style=","\"background-color:Khaki;" ,"\">" , "</menubar>" ,"</", "span>")


Menu_color$ = CONCAT$("<span style=","\"background-color:Thistle;" ,"\">" , "<menu>" ,"</", "span>")
Menu_color_close$ = CONCAT$("<span style=","\"background-color:Thistle;" ,"\">" , "</menu>" ,"</", "span>")

Menuitem_stock_color$ = CONCAT$("<span style=","\"color:Violet;" ,"\">" , "<menuitem stock=" ,"</", "span>")

Menuitem_color$ = CONCAT$("<span style=","\"color:Violet;" ,"\">" , "<menuitem>" ,"</", "span>")
Menuitem_color_close$ = CONCAT$("<span style=","\"color:Violet;" ,"\">" , "</menuitem>" ,"</", "span>")

Menuitem_icon_color$ = CONCAT$("<span style=","\"color:Violet;" ,"\">" , "<menuitem icon=" ,"</", "span>")

Separator_color$ = CONCAT$("<span style=","\"color:Navy;" ,"\">" , "<separator>" ,"</", "span>")
Separator_color_close$ = CONCAT$("<span style=","\"color:Navy;" ,"\">" , "</separator>" ,"</", "span>")



Window_color$ = CONCAT$("<span style=","\"background-color:PeachPuff;" ,"\">" , "<window>" ,"</", "span>")
Window_color_close$ = CONCAT$("<span style=","\"background-color:PeachPuff;" ,"\">" , "</window>" ,"</", "span>")
Window_title_color$ = CONCAT$("<span style=","\"background-color:PeachPuff;" ,"\">" , "<window title=" ,"</", "span>")





Chooser_color$ = CONCAT$("<span style=","\"background-color:LightPink;" ,"\">" , "<chooser>" ,"</", "span>")
Chooser_color_close$ = CONCAT$("<span style=","\"background-color:LightPink;" ,"\">" , "</chooser>" ,"</", "span>")

  
Variable_color$ = CONCAT$("<span style=","\"color:DarkGoldenRod;" ,"\">" , "<variable>" ,"</", "span>")
Variable_color_close$ = CONCAT$("<span style=","\"color:DarkGoldenRod;" ,"\">" , "</variable>" ,"</", "span>")

Progressbar_color$ = CONCAT$("<span style=","\"background-color:gold;" ,"\">" , "<progressbar>" ,"</", "span>")
Progressbar_color_close$ = CONCAT$("<span style=","\"background-color:gold;" ,"\">" , "</progressbar>" ,"</", "span>")


Default_color$ = CONCAT$("<span style=","\"color:SlateGray;" ,"\">" , "<default>" ,"</", "span>")
Default_color_close$ = CONCAT$("<span style=","\"color:SlateGray" ,"\">" , "</default>" ,"</", "span>")


Visible_color$ = CONCAT$("<span style=","\"color:SlateGray;" ,"\">" , "<visible>" ,"</", "span>")
Visible_color_close$ = CONCAT$("<span style=","\"color:SlateGray" ,"\">" , "</visible>" ,"</", "span>")


Table_color$ = CONCAT$("<span style=","\"background-color:MediumTurquoise;" ,"\">" , "<table>" ,"</", "span>")
Table_color_close$ = CONCAT$("<span style=","\"background-color:MediumTurquoise" ,"\">" , "</table>" ,"</", "span>")

 
Width_color$ = CONCAT$("<span style=","\"color:Tan;" ,"\">" , "<width>" ,"</", "span>")
Width_color_close$ = CONCAT$("<span style=","\"color:Tan;" ,"\">" , "</width>" ,"</", "span>")

Height_color$ = CONCAT$("<span style=","\"color:Tan;" ,"\">" , "<height>" ,"</", "span>")
Height_color_close$ = CONCAT$("<span style=","\"color:Tan;" ,"\">" , "</height>" ,"</", "span>")


'--- grouped by color ---'
'--- PaleVioletRed ---'


Edit_color$ = CONCAT$("<span style=","\"background-color:PaleVioletRed;" ,"\">" , "<edit>" ,"</", "span>")
Edit_color_close$ = CONCAT$("<span style=","\"background-color:PaleVioletRed;" ,"\">" , "</edit>" ,"</", "span>")


Edit_editable_color$ = CONCAT$("<span style=","\"color:PaleVioletRed;" ,"\">" , "<edit editable=" ,"</", "span>")
Edit_accepts_tab_color$ = CONCAT$("<span style=","\"color:PaleVioletRed;" ,"\">" , "<edit accepts-tab=" ,"</", "span>")
Edit_indent_color$ = CONCAT$("<span style=","\"color:PaleVioletRed;" ,"\">" , "<edit indent=" ,"</", "span>")
Edit_left_margin_color$ = CONCAT$("<span style=","\"color:PaleVioletRed;" ,"\">" , "<edit left-margin=" ,"</", "span>")
Edit_cursor_visible_color$ = CONCAT$("<span style=","\"color:PaleVioletRed;" ,"\">" , "<edit cursor-visible=" ,"</", "span>")
 

Tree_stock_color$ = CONCAT$("<span style=","\"background-color:Lime;" ,"\">" , "<tree stock=" ,"</", "span>")
Tree_color$ = CONCAT$("<span style=","\"background-color:Lime;" ,"\">" , "<tree>" ,"</", "span>")
Tree_color_close$ = CONCAT$("<span style=","\"background-color:Lime;" ,"\">" , "</tree>" ,"</", "span>")
Tree_rules_hint_color$ = CONCAT$("<span style=","\"background-color:Lime;" ,"\">" , "<tree rules_hint=" ,"</", "span>")
Tree_hover_expand_color$ = CONCAT$("<span style=","\"background-color:Lime;" ,"\">" , "<tree hover_expand=" ,"</", "span>")
Tree_icon_name_color$ = CONCAT$("<span style=","\"background-color:Lime;" ,"\">" , "<tree icon_name=" ,"</", "span>")
 

List_color$ = CONCAT$("<span style=","\"background-color:DimGray;" ,"\">" , "<list>" ,"</", "span>")
List_color_close$ = CONCAT$("<span style=","\"background-color:DimGray;" ,"\">" , "</list>" ,"</", "span>")
List_selection_mode_color$ = CONCAT$("<span style=","\"background-color:DimGray;" ,"\">" , "<list selection-mode=" ,"</", "span>")
 

Notebook_labels_color$ = CONCAT$("<span style=","\"background-color:Plum;" ,"\">" , "<notebook labels=" ,"</", "span>")
Notebook_color_close$ = CONCAT$("<span style=","\"background-color:Plum;" ,"\">" , "</notebook>" ,"</", "span>")


'---markup ---'
Bold_markup_color$ = CONCAT$("<span style=","\"color:SlateGray;" ,"\">" , "<b>" ,"</", "span>")
Bold_markup_color_close$ = CONCAT$("<span style=","\"color:SlateGray;" ,"\">" , "</b>" ,"</", "span>")

    
    
 

COPY copy_this$ TO CONCAT$(copy_this$,".gtkdialog-fixed.html")

'--- set the default line indents ---'
FIVE_SPACES$ = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"

'--- respect the leading white space per line  
'--- this function will get called to replace white space tabs and spaces
'--- It is used together with another routine that calculates and
'--- stores the number indented  spaces in  start_space_count.
 
'--- Rpt "was" a fixed  number of the times you  would repeat
'--- a character it gets replaced with  start_space_count 
'--- which is a  number that changes  per line depending on the
'--- indentation used


' ------------------
FUNCTION REPEAT_STR$(int Rpt, STRING Rpt_str$)
' ------------------
    LOCAL Cnt TYPE int
    LOCAL LocStr$ TYPE STRING
    IF Rpt < 1 THEN RETURN ""

    FOR Cnt = 1 TO Rpt
        LocStr$ = CONCAT$(LocStr$, Rpt_str$)
    NEXT Cnt

    RETURN LocStr$
END FUNCTION
' ------------------


'--- main code starts here this is a loop the above function is called 
'--- if white space indentation is found.  Rename working file to TMP ext.
RENAME CONCAT$(copy_this$,".gtkdialog-fixed.html") TO CONCAT$(copy_this$,".gtkdialog-fixed.htmlTMP")
OPEN CONCAT$(copy_this$,".gtkdialog-fixed.html") FOR WRITING AS my_outfile
OPEN CONCAT$(copy_this$,".gtkdialog-fixed.htmlTMP") FOR READING AS my_infile
WHILE NOT(ENDFILE(my_infile))
     READLN txt$ FROM my_infile

     '--- check if line of text starts with spaces or tabs or tags ---'
     IF REGEX(txt$, "^ ") OR REGEX(txt$, "^FIVE_BLANKS$")  OR REGEX(txt$, "^<") THEN
          
          full_count = LEN(txt$)
          '--- calculate leading spaces per line read  from READLN
          '--- a chop left is used here to remove only left spaces ---'
          chopped_count = LEN(CHOP$(txt$," ",1))
          start_space_count = full_count - chopped_count

          '--- call above FUNCTION REPEAT_STR$(int Rpt, STRING Rpt_str$)
          '--- and exchange Rpt with start_space_count
          '--- Tmp$ will be prefixed to txt$
          Tmp$ = REPEAT_STR$(start_space_count, "&nbsp;")         


          '--- pre step replace tabs with five spaces ---'
          txt$ = REPLACE$(txt$, Tab$, FIVE_BLANKS$)
     
          '--- convert tab syntax ---'
          txt$ = REPLACE$(txt$, "<action>", Action_color$)
          txt$ = REPLACE$(txt$, "</action>", Action_color_close$) 
      
          txt$ = REPLACE$(txt$, "<button>", Button_color$)
          txt$ = REPLACE$(txt$, "</button>", Button_color_close$) 
      
          txt$ = REPLACE$(txt$, "<button no>", Button_no_color$)
          txt$ = REPLACE$(txt$, "<button yes>", Button_yes_color$)
          txt$ = REPLACE$(txt$, "<button cancel>", Button_cancel_color$)
          txt$ = REPLACE$(txt$, "<button ok>", Button_ok_color$)
          txt$ = REPLACE$(txt$, "<button help>", Button_help_color$)
      
          txt$ = REPLACE$(txt$, "<hbox>", Hbox_color$)
          txt$ = REPLACE$(txt$, "</hbox>", Hbox_color_close$) 
          
          txt$ = REPLACE$(txt$, "<hbox spacing=", Hbox_spacing_color$) 
          txt$ = REPLACE$(txt$, "<hbox homogeneous=", Hbox_homogeneous_color$) 
          txt$ = REPLACE$(txt$, "<hbox fill=", Hbox_fill_color$) 
     
          txt$ = REPLACE$(txt$, "<vbox>", Vbox_color$)
          txt$ = REPLACE$(txt$, "</vbox>", Vbox_color_close$)       
                                                
          txt$ = REPLACE$(txt$, "<label>", Label_color$)
          txt$ = REPLACE$(txt$, "</label>", Label_color_close$) 
          
          txt$ = REPLACE$(txt$, "<text>", Text_color$)
          txt$ = REPLACE$(txt$, "</text>", Text_color_close$) 
          txt$ = REPLACE$(txt$, "<text use-markup=", Text_use_markup_color$)           
          txt$ = REPLACE$(txt$, "<text wrap=", Text_wrap_color$) 
          txt$ = REPLACE$(txt$, "<text selectable=", Text_selectable_color$)       


        
          txt$ = REPLACE$(txt$, "<frame ", Frame_color$) 
          txt$ = REPLACE$(txt$, "</frame>", Frame_color_close$) 
        
          txt$ = REPLACE$(txt$, "<input>", Input_color$)
          txt$ = REPLACE$(txt$, "</input>", Input_color_close$) 
          txt$ = REPLACE$(txt$, "<input file>", Input_file_color$)          
        
          txt$ = REPLACE$(txt$, "<variable>", Variable_color$)
          txt$ = REPLACE$(txt$, "</variable>", Variable_color_close$) 
         
          txt$ = REPLACE$(txt$, "<checkbox>", Checkbox_color$)
          txt$ = REPLACE$(txt$, "</checkbox>", Checkbox_color_close$)          
                   
          txt$ = REPLACE$(txt$, "<entry>", Entry_color$)
          txt$ = REPLACE$(txt$, "</entry>", Entry_color_close$) 
          
          txt$ = REPLACE$(txt$, "<default>", Default_color$)
          txt$ = REPLACE$(txt$, "</default>", Default_color_close$)   
          
          txt$ = REPLACE$(txt$, "<visible>", Visible_color$)
          txt$ = REPLACE$(txt$, "</visible>", Visible_color_close$)   
          
          txt$ = REPLACE$(txt$, "<combobox>", Combobox_color$)
          txt$ = REPLACE$(txt$, "</combobox>", Combobox_color_close$)        
                              
          txt$ = REPLACE$(txt$, "<action type=", Action_type_color$)
          txt$ = REPLACE$(txt$, "<action signal=", Action_signal_color$)
          txt$ = REPLACE$(txt$, "<button sensitive=", Button_sensitive_color$)
          txt$ = REPLACE$(txt$, "<button can-default=", Button_can_default_color$)
          

          
          txt$ = REPLACE$(txt$, "<entry activates_default=", Entry_activates_default_color$)
          txt$ = REPLACE$(txt$, "<entry editable=", Entry_editable_color$)
          txt$ = REPLACE$(txt$, "<entry has_frame=", Entry_has_frame_color$)
          txt$ = REPLACE$(txt$, "<entry max_length=", Entry_max_length_color$)
          txt$ = REPLACE$(txt$, "<entry width_chars=", Entry_width_chars_color$)
          txt$ = REPLACE$(txt$, "<entry invisible_char=", Entry_invisible_char_color$)
          txt$ = REPLACE$(txt$, "<entry accept=", Entry_accept_color$)
          txt$ = REPLACE$(txt$, "<entry activates-default=", Entry_activates_default_color$)
       

          
          txt$ = REPLACE$(txt$, "<checkbox active=", Checkbox_active_color$)
          txt$ = REPLACE$(txt$, "<checkbox draw_indicator=", Checkbox_draw_indicator_color$)
          txt$ = REPLACE$(txt$, "<checkbox inconsistent=", Checkbox_inconsistent_color$)
          
          txt$ = REPLACE$(txt$, "<radiobutton active=", Radiobutton_active_color$)
          txt$ = REPLACE$(txt$, "<radiobutton draw_indicator=", Radiobutton_draw_indicator_color$)
          txt$ = REPLACE$(txt$, "<radiobutton inconsistent=", Radiobutton_inconsistent_color$)
          txt$ = REPLACE$(txt$, "</radiobutton>", Radiobutton_color_close$)
          txt$ = REPLACE$(txt$, "<radiobutton>", Radiobutton_color$)    
          
          txt$ = REPLACE$(txt$, "<combobox case-sensitive=", Combobox_case_sensitive_color$)
          txt$ = REPLACE$(txt$, "<combobox allow-empty=", Combobox_allow_empty_color$)
          
          txt$ = REPLACE$(txt$, "<item>", Item_color$)
          txt$ = REPLACE$(txt$, "</item>", Item_color_close$)  
          txt$ = REPLACE$(txt$, "<item stock=", Item_stock_color$)          
          txt$ = REPLACE$(txt$, "<item stock_id=", Item_stock_id_color$)
          txt$ = REPLACE$(txt$, "<item icon=", Item_icon_color$)
          txt$ = REPLACE$(txt$, "<item icon_name=", Item_icon_name_color$)        
         
          
          txt$ = REPLACE$(txt$, "<progressbar>", Progressbar_color$ )
          txt$ = REPLACE$(txt$, "</progressbar>", Progressbar_color_close$)
 
          txt$ = REPLACE$(txt$, "<width>", Width_color$)
          txt$ = REPLACE$(txt$, "</width>", Width_color_close$)          
    
          txt$ = REPLACE$(txt$, "<height>", Height_color$)
          txt$ = REPLACE$(txt$, "</height>", Height_color_close$)
          
          txt$ = REPLACE$(txt$, "<edit>", Edit_color$)
          txt$ = REPLACE$(txt$, "</edit>", Edit_color_close$)
          
          
          txt$ = REPLACE$(txt$, "<list>", List_color$)
          txt$ = REPLACE$(txt$, "</list>", List_color_close$)
          txt$ = REPLACE$(txt$, "<list selection-mode=", List_selection_mode_color$)
          
          
          txt$ = REPLACE$(txt$, "<table>", Table_color$)
          txt$ = REPLACE$(txt$, "</table>", Table_color_close$)
          
          txt$ = REPLACE$(txt$, "<edit editable=", Edit_editable_color$)
          txt$ = REPLACE$(txt$, "<edit accepts-tab=", Edit_accepts_tab_color$)
          txt$ = REPLACE$(txt$, "<edit indent=", Edit_indent_color$)           
          txt$ = REPLACE$(txt$, "<edit left-margin=", Edit_left_margin_color$)           
          txt$ = REPLACE$(txt$, "<edit cursor-visible=", Edit_cursor_visible_color$)           
    
          txt$ = REPLACE$(txt$, "<input file stock=", Input_file_stock_color$)
          txt$ = REPLACE$(txt$, "<input icon_column=", Input_icon_column_color$)
          txt$ = REPLACE$(txt$, "<input file icon=",  Input_file_icon_color$) 
          
          txt$ = REPLACE$(txt$, "<pixmap icon_size=", Pixmap_icon_size_color$)
          txt$ = REPLACE$(txt$, "<pixmap>", Pixmap_color$) 
          txt$ = REPLACE$(txt$, "</pixmap>", Pixmap_color_close$)    
    
          txt$ = REPLACE$(txt$, "<tree>", Tree_color$) 
          txt$ = REPLACE$(txt$, "</tree>", Tree_color_close$)          
          txt$ = REPLACE$(txt$, "<tree stock=", Tree_stock_color$)
          txt$ = REPLACE$(txt$, "<tree rules_hint=", Tree_rules_hint_color$)          
          txt$ = REPLACE$(txt$, "<tree hover_expand=", Tree_hover_expand_color$)
          txt$ = REPLACE$(txt$, "<tree icon_name=", Tree_icon_name_color$)
         
          txt$ = REPLACE$(txt$, "<notebook labels=", Notebook_labels_color$)  
          txt$ = REPLACE$(txt$, "</notebook>", Notebook_color_close$)            
         
          txt$ = REPLACE$(txt$, "<chooser>", Chooser_color$)  
          txt$ = REPLACE$(txt$, "</chooser>", Chooser_color_close$)    
         
          txt$ = REPLACE$(txt$, "<menubar>", Menubar_color$)  
          txt$ = REPLACE$(txt$, "</menubar>", Menubar_color_close$)    
         
          txt$ = REPLACE$(txt$, "<menu>", Menu_color$)  
          txt$ = REPLACE$(txt$, "</menu>", Menu_color_close$)    
          
          txt$ = REPLACE$(txt$, "<menuitem>", Menuitem_color$)  
          txt$ = REPLACE$(txt$, "</menuitem>", Menuitem_color_close$)    
         
          txt$ = REPLACE$(txt$, "<separator>", Separator_color$)  
          txt$ = REPLACE$(txt$, "</separator>", Separator_color_close$)    
         
          txt$ = REPLACE$(txt$, "<menuitem stock=", Menuitem_stock_color$)  
          txt$ = REPLACE$(txt$, "<menuitem icon=", Menuitem_icon_color$) 
          
          
          txt$ = REPLACE$(txt$, "<window>", Window_color$)  
          txt$ = REPLACE$(txt$, "</window>", Window_color_close$)            
          txt$ = REPLACE$(txt$, "<window title=", Window_title_color$)  
          
          
          txt$ = REPLACE$(txt$, "<while condition=", While_condition_color$)  
          txt$ = REPLACE$(txt$, "</while>", While_color_close$) 
  


          '--- html special characters ---'             
          txt$ = REPLACE$(txt$, Dollar_sign$,"&#36;" )  
                                                         
          '---markup ---'          
          txt$ = REPLACE$(txt$, "<b>", Bold_markup_color$)
          txt$ = REPLACE$(txt$, "</b>", Bold_markup_color_close$)           
                 
         
          PRINT txt$
          '--- Tmp$ are the spaces or tabs converted to &nbsp;
          '--- txt$ is the orginal line of text converted to color
          '--- we need a html line break added here for formatting 
          WRITELN  Tmp$, txt$ ,"<br />" TO my_outfile
          
          ELSE         
          '--- catch any stray greater than less than symbols in comments ---'   
          
          txt$ = REPLACE$(txt$,"<" , Less_than$)
          txt$ = REPLACE$(txt$,">", Greater_than$)
          PRINT txt$
          WRITELN  txt$ ,"<br />" TO my_outfile
        
     WEND
END IF
CLOSE FILE my_infile
CLOSE FILE my_outfile
DELETE FILE CONCAT$(copy_this$,".gtkdialog-fixed.htmlTMP")

COLOR FG TO BLUE
PRINT
PRINT
PRINT "The html conversion is done!"
PRINT copy_this$,".gtkdialog-fixed.html", "  <--- is the modified file "
COLOR RESET




Last edited by bigbass on 29 Apr 2012, 05:07, edited 18 times in total.

User avatar
brokenman
Site Admin
Site Admin
Posts: 5652
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: gtkdialog2html add color to code (code parser too)

Post#2 by brokenman » 22 Apr 2012, 01:44

Sizzling. I love bacon.

Great job with the highlighting. Makes things easier on the eye. (or eyes if you are fortunate enough to have two).
How do i become super user?
Wear your underpants on the outside and put on a cape.

User avatar
bigbass
Contributor
Contributor
Posts: 151
Joined: 13 Jan 2012, 14:35
Distribution: slackware 14

Re: gtkdialog2html add color to code (code parser too)

Post#3 by bigbass » 23 Apr 2012, 16:45

finally a version one and all examples converted to have color

Joe

Post Reply