home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 1 / Macwelt DVD 1.toast / Web-Publishing / HTML-Editoren / Alpha ƒ / Tcl / Modes / HTML and CSS Modes / htmlMenu.tcl < prev    next >
Encoding:
Text File  |  2001-01-14  |  22.0 KB  |  736 lines

  1. ## -*-Tcl-*-
  2.  # ###################################################################
  3.  #  HTML mode - tools for editing HTML documents
  4.  # 
  5.  #  FILE: "htmlMenu.tcl"
  6.  #                                    created: 96-04-29 21.31.40 
  7.  #                                last update: 01-01-14 19.33.38 
  8.  #  Author: Johan Linde
  9.  #  E-mail: <alpha_www_tools@go.to>
  10.  #     www: <http://go.to/alpha_www_tools>
  11.  #  
  12.  # Version: 3.0
  13.  # 
  14.  # Copyright 1996-2001 by Johan Linde
  15.  #  
  16.  # This program is free software; you can redistribute it and/or modify
  17.  # it under the terms of the GNU General Public License as published by
  18.  # the Free Software Foundation; either version 2 of the License, or
  19.  # (at your option) any later version.
  20.  # 
  21.  # This program is distributed in the hope that it will be useful,
  22.  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23.  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24.  # GNU General Public License for more details.
  25.  # 
  26.  # You should have received a copy of the GNU General Public License
  27.  # along with this program; if not, write to the Free Software
  28.  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29.  # 
  30.  # ###################################################################
  31.  ##
  32.  
  33. #===============================================================================
  34. # This file contains the main procs for building and handling the two HTML menus.
  35. #===============================================================================
  36.  
  37. proc html::Hide {} {
  38.     html::DisableSome on
  39.     html::SetDis
  40.     html::DisableSome off
  41. }
  42.  
  43. # Disable some HTML elements    
  44. proc html::DisableSome {onoff} {
  45.     global html::DisabledItems htmlMenu
  46.     # if called from CSS mode.
  47.     if {![info exists html::DisabledItems]} {return}
  48.     foreach i ${html::DisabledItems} {
  49.         set it [split $i /]
  50.         set m [lindex $it 0]
  51.         if {[string index $m 0] == "$"} {eval set m $m}
  52.         enableMenuItem $m [lindex $it 1] $onoff
  53.     }
  54. }
  55.  
  56. proc html::DisableMenuItems {me deprecated extensions {strict ""} {trans ""}} {
  57.     global HTMLmodeVars html::HideDeprecated html::HideExtensions html::HideFrames
  58.     set disabled ""
  59.     if {${html::HideDeprecated} || $HTMLmodeVars(hideDeprecated)} {
  60.         set disabled [concat $extensions $deprecated]
  61.     } elseif {${html::HideExtensions} || $HTMLmodeVars(hideExtensions)} {
  62.         set disabled $extensions
  63.     }
  64.     if {${html::HideDeprecated}} {
  65.         eval lappend disabled $strict
  66.     } elseif {${html::HideFrames}} {
  67.         eval lappend disabled $trans
  68.     }
  69.     foreach i $disabled {
  70.         enableMenuItem $me $i off
  71.     }
  72. }
  73.  
  74. proc html::UseBigBrother {} {
  75.     global HTMLmodeVars
  76.     set HTMLmodeVars(useBigBrother) [expr {!$HTMLmodeVars(useBigBrother)}]
  77.     if {[catch {nameFromAppl Bbth}]} {
  78.         set HTMLmodeVars(useBigBrother) 0
  79.         enableMenuItem {Check Links} {Use Big Brother} off
  80.     }
  81.     markMenuItem -m {Check Links} {Use Big Brother} $HTMLmodeVars(useBigBrother)
  82.     prefs::modifiedModeVar useBigBrother HTML
  83.     message "[lindex {"Don't use" Use} [set HTMLmodeVars(useBigBrother)]] Big Brother."
  84. }
  85.  
  86. # Called from HTML menu to change browser.
  87. proc html::ToggleBrowser {brws} {
  88.     global html::Browsers browserSig
  89.     foreach b ${html::Browsers} {
  90.         if {$brws == [lindex $b 1]} {set browserSig [lindex $b 0]}
  91.     }
  92.     prefs::modifiedVar browserSig
  93.     if {![key::optionPressed]} {
  94.         if {[key::shiftPressed]} {
  95.             htmlSendWindow "" 1
  96.         } else {
  97.             htmlSendWindow
  98.         }
  99.     }
  100. }
  101.  
  102. # Called whenever browserSig is changed.
  103. proc html::ToggleBrowser2 {args} {
  104.     global browserSig html::Browsers HTMLmodeVars
  105.     if {![lcontains HTMLmodeVars(browsers) $browserSig]} {html::AddBrowser $browserSig}
  106.     foreach b ${html::Browsers} {
  107.         if {$browserSig == [lindex $b 0]} {
  108.             markMenuItem -m Browsers [lindex $b 1] on
  109.         } else {
  110.             markMenuItem -m Browsers [lindex $b 1] off
  111.         }
  112.     }
  113. }
  114.  
  115. # Add a browser to Browser menu.
  116. proc html::AddBrowser {{sig ""}} {
  117.     global html::Browsers HTMLmodeVars browserSig
  118.     if {$sig == ""} {
  119.         set fil [getfile "Locate a web browser."]
  120.         set sig [getFileSig $fil]
  121.     }
  122.     if {[catch {nameFromAppl $sig} fil]} {
  123.         alertnote "Couldn't get the name of the browser. If nothing else helps try rebuilding the desktop."
  124.         return
  125.     }
  126.     if {[lcontains HTMLmodeVars(browsers) $sig]} {return}
  127.     lappend HTMLmodeVars(browsers) $sig
  128.     prefs::modifiedModeVar browsers HTML
  129.     lappend html::Browsers [list $sig [set app [file tail $fil]]]
  130.     html::AddBrowserItem $app $sig
  131.     message "$app added to Browsers menu."
  132. }
  133.  
  134. # Remove a browser from Browser menu.
  135. proc html::RemoveBrowser {} {
  136.     global html::Browsers HTMLmodeVars browserSig
  137.     foreach b ${html::Browsers} {
  138.         lappend tmp [lindex $b 1]
  139.     }
  140.     if {[catch {listpick -p "Select browser to remove" $tmp} brws] || $brws == ""} {return}
  141.     for {set i 0} {$i < [llength ${html::Browsers}]} {incr i} {
  142.         if {$brws == [lindex [lindex ${html::Browsers} $i] 1]} {
  143.             html::AddBrowserItem $brws [lindex [lindex ${html::Browsers} $i] 0] removeFrom
  144.             if {[lindex $HTMLmodeVars(browsers) $i] == $browserSig} {
  145.                 set j 0
  146.                 if {$i == 0} {incr j}
  147.                 if {$j < [llength $HTMLmodeVars(browsers)]} {set browserSig [lindex $HTMLmodeVars(browsers) $j]}
  148.                 prefs::modifiedVar browserSig
  149.             }
  150.             set html::Browsers [lreplace ${html::Browsers} $i $i]
  151.             set HTMLmodeVars(browsers) [lreplace $HTMLmodeVars(browsers) $i $i] 
  152.         }
  153.     }
  154.     prefs::modifiedModeVar browsers HTML
  155.     message "$brws removed from Browsers menu."
  156. }
  157.  
  158. proc html::AddBrowserItem {app sig {proc insert}} {
  159.     switch $sig {
  160.         MOSS {
  161.             if {[string match "*Navigator*" $app]} {
  162.                 set ic 85
  163.             } else {
  164.                 set ic 86
  165.             }
  166.         }
  167.         MSIE {set ic 87}
  168.         OlG1 {set ic 88}
  169.         dogz {set ic 73}
  170.         iCAB {set ic 89}
  171.         default {set ic 78}
  172.     }
  173.     menu::$proc Browsers items end [menu::itemWithIcon $app $ic]
  174. }
  175.  
  176.  
  177. proc html::EnableURLs {onoff} {
  178.     enableMenuItem URLs "Clean Up…" $onoff
  179.     enableMenuItem URLs "Clear" $onoff
  180.     enableMenuItem URLs "Export…" $onoff
  181. }
  182.  
  183. proc html::Enablewindows {onoff} {
  184.     global htmlUtilsMenu
  185.     enableMenuItem $htmlUtilsMenu Windows $onoff
  186. }
  187.  
  188. proc html::EnableExtend {} {
  189.     enableMenuItem Extend "Remove Additions…" [html::AdditionsExists]
  190. }
  191.  
  192. proc html::ActivateHook {args} {
  193.     global html::HideDeprecated html::HideExtensions html::HideFrames
  194.     set html::HideExtensions 0
  195.     set html::HideDeprecated 0
  196.     set html::HideFrames 0
  197.     set doc [html::FindDoctype]
  198.     if {$doc == "transitional" || $doc == "frameset"} {
  199.         set html::HideExtensions 1
  200.         if {$doc == "transitional"} {set html::HideFrames 1}
  201.     } elseif {$doc == "strict"} {
  202.         set html::HideDeprecated 1
  203.     }
  204.     html::Hide
  205. }
  206.  
  207. proc html::FindDoctype {} {
  208.     if {![catch {search -s -f 1 -r 1 -i 1 -m 0 {<!doctype[^<>]+html[ \t\r\n]+4.01?[ \t\r\n]+transitional[^<>]+>} [minPos]}]} {
  209.         return transitional
  210.     } elseif {![catch {search -s -f 1 -r 1 -i 1 -m 0 {<!doctype[^<>]+html[ \t\r\n]+4.01?[ \t\r\n]+frameset[^<>]+>} [minPos]}]} {
  211.         return frameset
  212.     } elseif {![catch {search -s -f 1 -r 1 -i 1 -m 0 {<!doctype[^<>]+html[ \t\r\n]+4.01?[ \t\r\n]*//[^<>]+>} [minPos]}]} {
  213.         return strict
  214.     }
  215.     return ""
  216. }
  217.  
  218. #===============================================================================
  219. # Menu Processing
  220. #===============================================================================
  221.  
  222. proc html::MenuItem {menu item} {
  223.     global html::DisabledItems html::ElemAttrOptional
  224.     global screenWidth defWidth
  225.     global mode::features global::features mode
  226.  
  227.     if {[info exists mode::features($mode)] && ![lcontains mode::features($mode) htmlMenu] && \
  228.       [info exists global::features] && ![lcontains global::features htmlMenu]} {return}
  229.     
  230.     foreach it ${html::DisabledItems} {
  231.         if {[lindex [split $it /] 1] == $menu || "${menu}/$item" == $it} {beep; return}
  232.     }
  233.     
  234.     switch -glob $menu {
  235.         "•*" -
  236.         "Html*" {eval html::[join $item ""]} 
  237.         "Browsers" {
  238.             switch $item {
  239.                 "Send File to Browser"    {htmlSendWindow}
  240.                 "Send URL to Browser"    {htmlSendWindow "" 1}
  241.                 "Add"    {html::AddBrowser}
  242.                 "Remove" {html::RemoveBrowser}
  243.                 default {html::ToggleBrowser $item}
  244.             }
  245.         }
  246.         "Preferences" {
  247.             switch $item {
  248.                 "Attributes Globally" {html::GlobalAttrsPrefs}
  249.                 "Use Attributes" {html::UseAttributes}
  250.                 "Indentation" {html::IndentationPrefs}
  251.                 "Element Layout" {html::ElementLayout}
  252.                 "Optional Closing Tags" {html::OptionalClosingTags}
  253.                 "Content Types" {html::TypesPrefs contenttypes "Content Types"}
  254.                 "Media Descriptors" {html::TypesPrefs mediatypes "Media Descriptors"}
  255.                 "Link Types" {html::TypesPrefs linktypes "Link Types"}
  256.                 "Home Pages" {html::HomePages}
  257.                 "Key Bindings" {html::KeyBindings}
  258.                 "Electrics" {dialog::modifyModeFlags "HTML mode Electric Preferences"}
  259.                 default {html::modifyFlags [lindex $item 0]}
  260.             }
  261.         }
  262.         "Palettes" {float -m "$item" -t 50 -l [expr {$screenWidth - $defWidth > 110 ? $defWidth : $screenWidth - 110}] -z HTML} 
  263.         "Style Sheets" {
  264.             switch $item {
  265.                 Style {html::Tag STYLE}
  266.                 Span {html::Tag SPAN}
  267.                 default {eval html::[join $item ""]}
  268.             }
  269.         }
  270.         "Headers" {
  271.             switch $item {
  272.                 "Header1"    {html::Tag H1}
  273.                 "H1 no attr" {html::Tag H1 NOATTR}
  274.                 "Header2"    {html::Tag H2}
  275.                 "H2 no attr" {html::Tag H2 NOATTR}
  276.                 "Header3"    {html::Tag H3}
  277.                 "H3 no attr" {html::Tag H3 NOATTR}
  278.                 "Header4"    {html::Tag H4}
  279.                 "H4 no attr" {html::Tag H4 NOATTR}
  280.                 "Header5"    {html::Tag H5}
  281.                 "H5 no attr" {html::Tag H5 NOATTR}
  282.                 "Header6"    {html::Tag H6}
  283.                 "H6 no attr" {html::Tag H6 NOATTR}
  284.                 default {eval html::[join $item ""]}
  285.             }
  286.         }
  287.         "Blocks and Dividers" {
  288.             switch $item {
  289.                 "Paragraph"    {html::Tag P}
  290.                 "P no attr" {html::Tag P NOATTR}
  291.                 "Division"        {html::Tag DIV}
  292.                 "Block Quote"    {html::Tag BLOCKQUOTE}
  293.                 "Address"        {html::Tag ADDRESS}
  294.                 "Center"        {html::Tag CENTER}
  295.                 "Preformatted"    {html::Tag PRE}
  296.                 "Multi Column"    {html::Tag MULTICOL}
  297.                 "Spacing"        {html::Tag SPACER}
  298.                 "Direction Override" {html::Tag BDO}
  299.                 "Inserted Text"    {html::Tag INS}
  300.                 "Deleted Text"    {html::Tag DEL}
  301.                 "Line Break"        {html::Tag BR}
  302.                 "BR no attr"        {html::Tag BR NOATTR}
  303.                 "Horizontal Rule"    {html::Tag HR}
  304.                 "HR no attr"    {html::Tag HR NOATTR}
  305.                 "No Line Break"    {html::Tag NOBR}
  306.                 "Word Break"    {html::Tag WBR}
  307.                 default {eval html::[join $item ""]}
  308.             }
  309.         }
  310.         "Styles"    {
  311.             switch $item {
  312.                 "Font"            {html::Tag FONT}
  313.                 "Basefont"        {html::Tag BASEFONT}
  314.                 "Marquee"        {html::Tag MARQUEE}
  315.                 "Bold"            {html::Tag B}
  316.                 "Italic"        {html::Tag I}
  317.                 "Strike out"    {html::Tag STRIKE}
  318.                 "Underlined"    {html::Tag U}
  319.                 "Subscript"        {html::Tag SUB}
  320.                 "Superscript"    {html::Tag SUP}
  321.                 "Bigger"        {html::Tag BIG}
  322.                 "Smaller"        {html::Tag SMALL}
  323.                 "Emphasis"        {html::Tag EM}
  324.                 "Strong"        {html::Tag STRONG}
  325.                 "Definition"    {html::Tag DFN}
  326.                 "Code"            {html::Tag CODE}
  327.                 "Variable"        {html::Tag VAR}
  328.                 "Citation"        {html::Tag CITE}
  329.                 "Keyboard"        {html::Tag KBD}
  330.                 "Typewriter"    {html::Tag TT}
  331.                 "Sample"        {html::Tag SAMP}
  332.                 "Blinking"        {html::Tag BLINK}
  333.                 "Quotation"        {html::Tag Q}
  334.                 "Abbreviation"    {html::Tag ABBR}
  335.                 "Acronym"        {html::Tag ACRONYM}
  336.                 default {eval html::[join $item ""]}
  337.             }
  338.         }
  339.         "Links"    {
  340.             switch $item {
  341.                 "Link or Anchor" {html::Tag A}
  342.                 "Image"    {html::Tag IMG}
  343.                 Object {html::Tag OBJECT}
  344.                 Sound {html::Tag BGSOUND}
  345.                 default {eval html::[join $item ""]}
  346.             }
  347.         }
  348.         "Plug-ins" {
  349.             switch $item {
  350.                 "General" {html::Tag EMBED}
  351.                 "No Embed" {html::Tag NOEMBED}
  352.                 default {eval html::[join $item ""]}
  353.             }
  354.         }
  355.         "Lists"    {
  356.             switch $item {
  357.                 "Unordered List"    {html::BuildList UL "LI IN UL" UL}
  358.                 "UL no attr"    {html::BuildList UL NOATTR NOATTR}
  359.                 "Ordered List"    {html::BuildList OL "LI IN OL" OL}
  360.                 "OL no attr"    {html::BuildList OL NOATTR NOATTR}
  361.                 "Directory"    {html::BuildList DIR LI}
  362.                 "Menu"        {html::BuildList MENU LI}
  363.                 default {eval html::[join $item ""]}
  364.             }
  365.         }
  366.         "Forms" {
  367.             switch $item {
  368.                 "Form"        {html::Tag FORM}
  369.                 "Field Set" {html::Tag FIELDSET}
  370.                 "Legend"    {html::Tag LEGEND}
  371.                 "Label"        {html::Tag LABEL}
  372.                 "Text"        {html::Tag "INPUT TYPE=TEXT"}
  373.                 "Checkbox"    {html::Tag "INPUT TYPE=CHECKBOX"}
  374.                 "Input Button"    {html::Tag "INPUT TYPE=BUTTON"}
  375.                 "Radio"        {html::Tag "INPUT TYPE=RADIO"}
  376.                 "Submit"        {html::Tag "INPUT TYPE=SUBMIT"}
  377.                 "Reset"        {html::Tag "INPUT TYPE=RESET"}
  378.                 "Password"    {html::Tag "INPUT TYPE=PASSWORD"}
  379.                 "Hidden"        {html::Tag "INPUT TYPE=HIDDEN"}
  380.                 "Image"        {html::Tag "INPUT TYPE=IMAGE"}
  381.                 "File Upload" {html::Tag "INPUT TYPE=FILE"}
  382.                 "Button"    {html::Tag BUTTON}
  383.                 "Select"        {html::Tag SELECT}
  384.                 "Option Group" {html::Tag OPTGROUP}
  385.                 "Option"        {html::Tag OPTION}
  386.                 "Textarea"    {html::Tag TEXTAREA}
  387.                 "Key Generator" {html::Tag KEYGEN}
  388.                 default {eval html::[join $item ""]}
  389.             }
  390.         }
  391.         "Tables" {
  392.             switch $item {
  393.                 Table    {html::Tag TABLE}
  394.                 Row        {html::Tag TR}
  395.                 "TR no attr"        {html::Tag TR NOATTR}
  396.                 Header        {html::Tag TH}
  397.                 "TH no attr"        {html::Tag TH NOATTR}
  398.                 Cell        {html::Tag TD}
  399.                 "TD no attr"        {html::Tag TD NOATTR}
  400.                 Caption    {html::Tag CAPTION}
  401.                 Head {html::Tag THEAD}
  402.                 Body {html::Tag TBODY}
  403.                 Foot {html::Tag TFOOT}
  404.                 "Column Group" {html::Tag COLGROUP}
  405.                 Column {html::Tag COL}
  406.                 default {eval html::[join $item ""]}
  407.             }
  408.         }
  409.         "Frames" {
  410.             switch $item {
  411.                 Frameset        {html::Tag FRAMESET}
  412.                 Frame        {html::Tag FRAME}
  413.                 "Inline Frame" {html::Tag IFRAME}
  414.                 "No Frames"    {html::Tag NOFRAMES}
  415.                 default {eval html::[join $item ""]}
  416.             }
  417.         }
  418.         "Image Maps" {
  419.             switch $item {
  420.                 Map        {html::Tag MAP}
  421.                 Area    {html::Tag AREA}
  422.                 default {eval html::[join $item ""]}
  423.             }
  424.         }
  425.         "Java and JavaScript"    {
  426.             switch $item {
  427.                 Applet    {html::Tag APPLET}
  428.                 Parameter {html::Tag PARAM}
  429.                 Script    {html::Tag SCRIPT}
  430.                 "No Script" {html::Tag NOSCRIPT}
  431.                 Server {html::Tag SERVER}
  432.                 default {eval html::[join $item ""]}
  433.             }
  434.         }
  435.         "Layers" {
  436.             switch $item {
  437.                 Layer {html::Tag LAYER}
  438.                 "Inline Layer" {html::Tag ILAYER}
  439.                 "No Layer" {html::Tag NOLAYER}
  440.                 default {eval html::[join $item ""]}
  441.             }
  442.         }
  443.         "Other"    {
  444.             switch $item {
  445.                 "Base"    {html::Tag BASE}
  446.                 "Isindex" {html::Tag ISINDEX}
  447.                 "Link"    {html::Tag LINK}
  448.                 "Meta"    {html::Tag META}
  449.                 default {eval html::[join $item ""]}
  450.             }
  451.         }
  452.         "Character Entities"    {
  453.             switch $item {
  454.                 "Add"    {html::AddCommonChars}
  455.                 "Remove" {html::RemoveCommonChars}
  456.                 default        {html::InsertCharacter $item}
  457.             }
  458.         }
  459.         "*Chars*" {
  460.             html::InsertCharacter $item
  461.         }
  462.         "Custom"    {
  463.             set elem [string toupper $item]
  464.             if {[info exists html::ElemAttrOptional($elem)]} {
  465.                 html::Tag $elem
  466.             } elseif {[html::AdditionsExists]} {
  467.                 html::Tag "INPUT TYPE=$elem"
  468.             }
  469.         }
  470.     }
  471. }
  472.  
  473. proc html::UtilsMenuItem {menu item} {
  474.     global mode::features global::features mode
  475.     if {$menu == "Colors"} {
  476.         if {[info exists mode::features($mode)] && ![lcontains mode::features($mode) cssMenu] && \
  477.           ![lcontains mode::features($mode) htmlUtilsMenu] && \
  478.           [info exists global::features] && ![lcontains global::features cssMenu] && \
  479.           ![lcontains global::features htmlUtilsMenu]} {return}
  480.     } elseif {[info exists mode::features($mode)] && ![lcontains mode::features($mode) htmlUtilsMenu] && \
  481.       [info exists global::features] && ![lcontains global::features htmlUtilsMenu]} {return}
  482.  
  483.     switch -glob $menu {
  484.         "•*" -
  485.         "Html*" - 
  486.         "Check Links" -
  487.         "Includes" -
  488.         "FTP" -
  489.         "Formatting" -
  490.         "Extend" -
  491.         "Editing" -
  492.         "Validate" {eval html::[join $item ""]}
  493.         "Character Translation"    {
  494.             switch $item {
  495.                 "åäö -> HTML"        {html::Characterstohtml 0}
  496.                 "HTML -> åäö"    {html::htmltoCharacters 0}
  497.                 "<>& -> HTML"    {html::Characterstohtml 1}
  498.                 "HTML -> <>&"    {html::htmltoCharacters 1}
  499.                 default {eval html::[join $item ""]}
  500.             }
  501.         }
  502.         "Colors" {
  503.             switch -glob -- $item {
  504.                 "New Color Set" {html::NewColorSet}
  505.                 "Delete Color Set" {html::DeleteColorSet}
  506.                 "Edit Color Set" {html::EditColorSet}
  507.                 "Edit*" {html::EditAColorSet [lrange $item 1 end]}
  508.                 default {html::ActivateColorSet $item}
  509.             }
  510.         }
  511.         "URLs"    {
  512.             switch $item {
  513.                 "Clean Up"        {html::CleanUpCache URLs}
  514.                 "Clear"            {html::ClearCache URLs}
  515.                 default {eval html::[join $item ""]}
  516.             }
  517.         }
  518.         "Windows"    {
  519.             switch $item {
  520.                 "Clean Up"    {html::CleanUpCache windows}
  521.                 "Clear"        {html::ClearCache windows}
  522.                 default {eval html::[join $item ""]}
  523.             }
  524.         }
  525.         "Home Page Windows" {
  526.             switch $item {
  527.                 "Open" {html::OpenHPwin}
  528.                 default {eval html::[join $item ""]}
  529.             }
  530.         }
  531.     }
  532. }
  533.  
  534.  
  535. #
  536. # The menu.
  537. #
  538. # <B = control <I = option <U = shift <O = command <S = dynamic
  539.  
  540. proc html::BuildSubMenuProc {me proc} {
  541.     global html::buildingWholeMenu
  542.     if {![info exists html::buildingWholeMenu]} {html::ReadMenuKeys}
  543.     return [list build [html::BuildOneMenu $me] "$proc -m -M HTML" "" $me]
  544. }
  545.  
  546. proc html::BuildSubCharsMenu {me name flg} {
  547.     global html::OtherChars2Menu html::OtherChars1Menu html::CapitalCharsMenu html::SmallCharsMenu
  548.     return [list build [set $me] "html::MenuItem $flg -m -M HTML" "" $name]
  549. }
  550.  
  551. proc html::BuildCharsMenu {} {
  552.     global HTMLmodeVars
  553.     set me $HTMLmodeVars(commonChars)
  554.     if {[llength $me]} {lappend me "(-"}
  555.     return [list build [concat $me Add… Remove… \
  556.       [list [list Menu -p html::MenuItem -m -M HTML -n "Small Chars" {}]] \
  557.       [list [list Menu -p html::MenuItem -m -M HTML -c -n "Capital Chars" {}]] \
  558.       [list [list Menu -p html::MenuItem -m -M HTML -n "Other Chars 1" {}]] \
  559.       [list [list Menu -p html::MenuItem -m -M HTML -n "Other Chars 2" {}]]] \
  560.       "html::MenuItem -m -M HTML" [list "Small Chars" "Capital Chars" "Other Chars 1" "Other Chars 2"] "Character Entities"]
  561. }
  562.  
  563. proc html::BuildCustomMenu {} {
  564.     global html::buildingWholeMenu
  565.     if {![info exists html::buildingWholeMenu]} {html::ReadMenuKeys}
  566.     html::CreateCustomSub
  567.     return [list build [html::BuildOneMenu Custom] "html::MenuItem -m -M HTML" "" Custom]    
  568. }
  569.  
  570. proc html::BuildMenuProc {} {
  571.     global htmlMenu htmlSubMenus
  572.     return [list build [html::BuildMenu0] "html::MenuItem -m -M HTML" \
  573.       [concat [lrange $htmlSubMenus 1 end] [list "Character Entities"]] $htmlMenu]
  574.     
  575. }
  576.  
  577. proc html::BuildUtilsMenuProc {} {
  578.     global htmlUtilsMenu htmlUtilSubMenus
  579.     return [list build [html::BuildUtilsMenu0] "html::MenuItem -m -M HTML" \
  580.       [lrange $htmlUtilSubMenus 1 end] $htmlUtilsMenu]
  581.     
  582. }
  583.  
  584. proc html::BuildMenu0 {} {
  585.     global htmlStartElements html::PrefsFolder htmlCustomSub
  586.     global htmlSubMenus customHTMLpalettes
  587.     
  588.     # Build submenus
  589.     html::ReadMenuKeys    
  590.     message "Building HTML menu…"
  591.     set HTMLMenu [html::BuildOneMenu HTML]
  592.     
  593.     lappend htmlMenuList [list Menu -p html::MenuItem -m -M HTML -n Browsers {}]
  594.     append htmlMenuList " " [lindex $HTMLMenu 0]
  595.     lappend htmlMenuList [list Menu -p html::MenuItem -m -M HTML -n Preferences {}]
  596.     # add custom pallettes if any
  597.     if {[info exists customHTMLpalettes]} {
  598.         lappend htmlMenuList [list Menu -p html::MenuItem -m -M HTML -n Palettes $customHTMLpalettes]
  599.     }
  600.     lappend htmlMenuList "(-" [lindex $HTMLMenu 1] [lindex $HTMLMenu 2]
  601.     for {set i $htmlStartElements} {$i < [llength $htmlSubMenus]} {incr i} {
  602.         lappend htmlMenuList [list Menu -p html::MenuItem -m -M HTML -n [lindex $htmlSubMenus $i] {}]
  603.     }
  604.     
  605.     # Allow user to insert custom menu items
  606.     if {[html::NewElementsExists]} {
  607.         lappend htmlMenuList [list Menu -p html::MenuItem -m -M HTML -n "Custom" {}]
  608.     }
  609.     lappend htmlMenuList [list Menu -p html::MenuItem -m -M HTML -n "Character Entities" {}]
  610.         
  611.     return $htmlMenuList
  612. }
  613.  
  614. proc html::BuildMenuExtra {} {
  615.     global htmlMenuKey htmlMenu
  616.     if {[html::NewElementsExists]} {
  617.         menu::buildSome Custom
  618.     }
  619.     catch {unset htmlMenuKey}
  620.     html::DisableMenuItems $htmlMenu {} {Plug-ins Layers}
  621. }
  622.  
  623. proc html::BlocksDisable {} {
  624.     html::DisableMenuItems "Blocks and Dividers" Center {"Multi Column" Spacing "No Line Break" "Word Break"}
  625. }
  626.  
  627. proc html::StylesDisable {} {
  628.     html::DisableMenuItems Styles {Font Basefont "Strike out" Underlined} {Marquee Blinking}
  629. }
  630.  
  631. proc html::LinksDisable {} {
  632.     html::DisableMenuItems Links {} Sound
  633. }
  634.  
  635. proc html::ListsDisable {} {
  636.     html::DisableMenuItems Lists {Directory Menu} {}
  637. }
  638.  
  639. proc html::FormsDisable {} {
  640.     html::DisableMenuItems Forms {} {"Key Generator"}
  641. }
  642.  
  643. proc html::FramesDisable {} {
  644.     html::DisableMenuItems Frames {} {} {Frameset Frame "Inline Frame" "No Frames"} {Frameset Frame}
  645. }
  646.  
  647. proc html::JavaDisable {} {
  648.     html::DisableMenuItems "Java and JavaScript" Applet Server
  649. }
  650.  
  651. proc html::OtherDisable {} {
  652.     html::DisableMenuItems Other Isindex {}
  653. }
  654.  
  655. proc html::MarkBrowsersMenu {} {
  656.     global HTMLmodeVars browserSig html::Browsers
  657.     foreach brws ${html::Browsers} {
  658.         if {[lindex $brws 0] == $browserSig} {markMenuItem -m "Browsers" [lindex $brws 1] on}
  659.     }
  660. }
  661.  
  662. proc html::BuildUtilsMenu0 {} {
  663.     global htmlUtilSubMenus HTMLmodeVars htmlUtilsMenu
  664.     # Build submenus
  665.     html::ReadMenuKeys
  666.     message "Building HTML Utilities menu…"
  667.     set UtilitiesMenu [html::BuildOneMenu Utilities]
  668.  
  669.     foreach me [lrange $htmlUtilSubMenus 1 end] {
  670.         lappend utilSubs [list Menu -p html::MenuItem -m -M HTML -n $me {}]
  671.     }
  672.     
  673.     return [concat $utilSubs "(-" $UtilitiesMenu]
  674. }
  675.  
  676. proc html::BuildUtilsMenuExtra {} {
  677.     global htmlMenuKey
  678.     catch {unset htmlMenuKey}
  679. }
  680.  
  681. # Add some things to translation menu.
  682. proc html::CharacterMenuExtra {} {
  683.     addMenuItem -m -l "" "Character Translation" "<>& -> HTML"
  684.     addMenuItem -m -l "" "Character Translation" "HTML -> <>&"
  685. }
  686.  
  687. # Check if Big Brother exists and if it should be used.
  688. proc html::CheckMenuExtra {} {
  689.     global HTMLmodeVars
  690.     if {[catch {nameFromAppl Bbth}]} {
  691.         enableMenuItem "Check Links" "Use Big Brother" off
  692.         enableMenuItem "Check Links" "Check Remote Links" off
  693.         if {$HTMLmodeVars(useBigBrother)} {
  694.             set HTMLmodeVars(useBigBrother) 0
  695.             prefs::modifiedModeVar useBigBrother HTML
  696.         }
  697.     } elseif {$HTMLmodeVars(useBigBrother)} {
  698.         markMenuItem -m {Check Links} {Use Big Brother} 1
  699.     }
  700. }
  701.  
  702. # Disable URLs menu if cache is empty.
  703. proc html::URLsMenuExtra {} {
  704.     global HTMLmodeVars
  705.     if {![llength $HTMLmodeVars(URLs)]} {html::EnableURLs off}
  706. }
  707.  
  708. # Disable Windows menu if cache is empty.
  709. proc html::WindowsMenuExtra {} {
  710.     global HTMLmodeVars
  711.     if {![llength $HTMLmodeVars(windows)]} {html::Enablewindows off}
  712. }
  713.  
  714. proc html::FtpMenuExtra {} {
  715.     if {[catch {nameFromAppl Woof}]} {
  716.         enableMenuItem FTP "NetFinder Mirror Files…" off
  717.     }
  718. }
  719.  
  720. proc html::SetDis {} {
  721.     global HTMLmodeVars html::DisabledItems html::DisabledExtensions html::DisabledDeprecated
  722.     global html::HideDeprecated html::HideExtensions html::HideFrames
  723.     set html::DisabledItems ""
  724.     if {${html::HideDeprecated} || $HTMLmodeVars(hideDeprecated)} {
  725.         set html::DisabledItems ${html::DisabledDeprecated}
  726.     } elseif {${html::HideExtensions} || $HTMLmodeVars(hideExtensions)} {
  727.         set html::DisabledItems ${html::DisabledExtensions}
  728.     }
  729.     if {${html::HideDeprecated}} {
  730.         lappend html::DisabledItems "Frames/Frameset" "Frames/Frame" "Frames/Inline Frame" "Frames/No Frames"
  731.     } elseif {${html::HideFrames}} {
  732.         lappend html::DisabledItems "Frames/Frameset" "Frames/Frame"
  733.     }
  734. }
  735.  
  736.