home *** CD-ROM | disk | FTP | other *** search
/ Internet File Formats / InternetFileFormatsCD.bin / text / latex / mac / alpha60.hqx / Tcl / SystemCode / menus.tcl < prev    next >
Encoding:
Text File  |  1995-07-14  |  7.2 KB  |  410 lines

  1. # My menus.        
  2.  
  3. menu -n File -p fileMenuProc {
  4.     "/Nnew"
  5.     "/Oopen╔"
  6.     {menu -n recent {}}
  7.     "<S/Wclose"
  8.     "<S<I<O/WcloseAll"
  9.     "(-"
  10.     "<S/Ssave"
  11.     "<S<I<O/SsaveAll"
  12.     "<SsaveACopyAs╔"
  13.     "<SsaveAs╔"
  14.     "revert"
  15.     "(-"
  16.     "/Yshell"
  17.     "(-"
  18.     "pageSetup╔"
  19.     {menu -n print {}}
  20.     "(-"
  21.     "/Qquit"
  22. }
  23.  
  24.  
  25. proc fileMenuProc {menu item} {
  26.     if {$item == "open"} {
  27.         findFile
  28.     } elseif {$item == "close"} {
  29.         killWindow
  30.     } else {
  31.         $item
  32.     }
  33. }
  34.  
  35.  
  36. menu -n Edit {
  37.     "/Zundo"
  38.     "/Z<I<Oredo"
  39.     "/Lload"
  40.     "(-"
  41.     "/X<Scut"
  42.     "/X<S<I<Ocut&Append"
  43.     "/C<Scopy"
  44.     "/C<S<I<Ocopy&Append"
  45.     "/V<Spaste"
  46.     "/V<S<I<OpastePop"
  47.     "(-"
  48.     "/`<Stwiddle"
  49.     "/`<S<I<OtwiddleWords"
  50.     "yank"
  51.     "/A<SselectAll"
  52.     "/A<S<I<OselectParagraph"
  53.     "clear"
  54.     "(-"
  55.     {/[<SshiftLeft}
  56.     {/[<S<I<OshiftLeftSpace}
  57.     {/]<SshiftRight}
  58.     {/]<S<I<OshiftRightSpace}
  59.     "/Bbalance"
  60.     "(-"
  61.     "viewSavedSetting╔"
  62.     "removeSavedSetting╔"
  63.     "editPrefs.tcl"
  64. }
  65.  
  66. menu -n Search {
  67.     "/F<Sfind╔"
  68.     "/F<S<I<OsearchStart"
  69.     "/G<SfindAgain"
  70.     "/G<S<I<OfindAgainBackward"
  71.     "/H<I<OfindInNextFile"
  72.     "(-"
  73.     "/E<SenterSearchString"
  74.     "/E<S<I<OenterReplaceString"
  75.     "(-"
  76.     "/Rreplace"
  77.     "/Hreplace&FindAgain"
  78.     "<S/R<O<IreplaceAll"
  79.     "<S/R<O<I<BreplaceInFileset"
  80.     "(-"
  81.     "/=markHilite"
  82.     "(-"
  83.     {menu -n namedMarks -p namedMarkProc {
  84.         "/K<O<Sset╔"
  85.         "/K<O<B<SmarkFile"
  86.         "/K<I<Ogoto╔"
  87.         "remove╔"
  88.         "(-"
  89.         "sort"
  90.         "sortByPosition"}}
  91.     {menu -n unnamedMark -p unnamedMarkproc {
  92.         "set╔"
  93.         "exchangePointAndMark"}}
  94.     {menu -n markStack -p markMenuProc { "/,<Bpush" "/.<Bpop"}}
  95.     {menu -n registers { pointToRegister jumpToRegister }}
  96. }
  97.  
  98. proc namedMarkProc {menu item} {
  99.     switch $item {
  100.         "markFile"            {markFile; message "File marked."}
  101.         "set"                 {setNamedMark}
  102.         "goto"                {gotoFileMark}
  103.         "remove"            {removeNamedMark}
  104.         "sort"                {sortMarksFile}
  105.         "sortByPosition"    {orderMarks}
  106.     }
  107. }
  108.  
  109. proc unnamedMarkproc {menu item} {
  110.     switch $item {
  111.         "set"                     {setMark}
  112.         "exchangePointAndMark"    {exchangePointAndMark}
  113.         "hilite"                {markHilite}
  114.     }
  115. }
  116.     
  117. proc markMenuProc {menu item} {
  118.     switch $item {
  119.         "push"     {pushMark}
  120.         "pop"    {popMark}
  121.     }
  122. }
  123.         
  124. proc installProc {menu item} {
  125.     switch $item {
  126.         "Electric Alias"     {loadElectricAlias}
  127.         "LaTeX 2.09"        {loadLaTeX}
  128.         "LaTeX2e"            {loadLaTeX}
  129.         "MacPerl"            {loadMacPerl}
  130.     }
  131. }
  132.  
  133.  
  134. menu -n "Utils" {
  135.         {menu -n fileUtils {
  136.             "insertPathName╔"
  137.             "insertFile╔"
  138.             "fileRemove╔"
  139.             "fileInfo╔"
  140.             "wordCount"}}
  141.         {menu -m -n compare -p compareProc {
  142.             "Windows"
  143.             "Files╔"
  144.             "Directories╔"}}
  145.         {menu -n asciiEtc {
  146.             "quoteChar"
  147.             "(-"
  148.             "keyCode"
  149.             "keyAscii"
  150.             "getAscii"
  151.             "insertAscii"}}
  152.         "(-"
  153.         "evaluate╔"
  154.         {menu -n KbdMacros {
  155.             "/qstartKeyboardMacro"
  156.             "/rendKeyboardMacro"
  157.             "/sexecuteKeyboardMacro"
  158.             "dumpMacro"}}
  159.         "(-"
  160.         "sortLines"
  161.         "/L<I<OspellcheckWindow"
  162.         "sendUrl"
  163.         "(-"
  164.         "/M<I<OmatchingLines"
  165.         "gotoMatch"
  166.         "/inextMatch"
  167.         "(-"
  168.         {menu -n NamedClipboards -p namedClipMenuProc {"copy╔" "cut╔" "paste╔"}}
  169.         {menu -m -n install -p installProc {
  170.             "Electric Alias"
  171.             "MacPerl"
  172.             "(-"
  173.             "LaTeX2e"
  174.             "LaTeX 2.09"
  175.         }}
  176.         listFunctions
  177. }
  178.  
  179.  
  180. proc compareProc {menu item} {
  181.     catch {compare$item} msg
  182.     message $msg
  183. }
  184.  
  185. proc namedClipMenuProc {menu item} {
  186.     switch $item {
  187.         "copy"         "copyNamedClipboard"
  188.         "cut"         "cutNamedClipboard"
  189.         "paste"     "pasteNamedClipboard"
  190.     }
  191. }
  192.  
  193.         
  194. menu    -n Mode {
  195.         {menu -s -n flags -p editFlag {}}
  196.         {menu -s -n vars -p editVar {}}
  197.         "(-"
  198.         "/jcmdDoubleClick"
  199.         "/kdescribeBinding"
  200.         "listBindings"
  201.         {menu -n emacs {}}
  202.         {menu -n appPaths {}}
  203.         "(-"
  204.         "/lsetFontsTabs╔"
  205.         "(-"
  206.         {menu -m -n switchTo -p switchProc {}}
  207.         "toolserverShell"
  208. }
  209.  
  210. # ==== NOTE:  rectMarkHilite, onespace, centerRedraw, doTab
  211. menu    -n Convert {
  212.         "/I<SfillParagraph"
  213.         "/I<S<O<IwrapParagraph"
  214.         "/I<S<O<BsentenceParagraph"
  215.         "/U<S<OfillRegion"
  216.         "/U<S<I<OwrapRegion"
  217.         "<E<SparagraphToLine"
  218.         "<SlineToParagraph"
  219.         "(-"
  220.         "zapInvisibles"
  221.         "<SspacesToTabs"
  222.         "<StabsToSpaces"
  223.         "(-"
  224.         {menu -n Strings {
  225.             "<SremovePrefix"
  226.             "<SinsertPrefix"
  227.             "<S<EremoveSuffix"
  228.             "<SinsertSuffix"
  229.             "setPrefix"
  230.             "setSuffix"
  231.             }}
  232.         "/D<ScommentLine"
  233.         "/D<S<I<OuncommentLine"
  234.         "<SuncommentBox"
  235.         "<ScommentBox"
  236.         "<S<EindentRegion"
  237.         "<SindentLine"
  238.         "(-"
  239.         "<SupcaseRegion"
  240.         "<SdowncaseRegion"
  241. }
  242.  
  243. # Real Kludge
  244. proc helpMenuProc {menu item} {
  245.     global HOME helpMenu
  246.     
  247.     if {$menu == $helpMenu} {
  248.         edit -r $HOME:Help:$item
  249.     } else {
  250.         edit -r $HOME:Help:$menu:$item
  251.     }
  252. #     if {$item == "Manual"} {
  253. #         global winModes
  254. #         
  255. #         set nm [lindex [winNames -f] 0]
  256. #         set winModes($nm) Help
  257. #         changeMode Help
  258. #     }
  259. }
  260.  
  261. proc strip {arg} {
  262.     if {[regsub -all {\\([][\{\}])} $arg {\1} v]} {return $v}
  263.     return $arg
  264. }
  265.  
  266. set men { "Manual" "Alpha Commands" "Tcl Commands" "(-" "Readme" "Changes" "ToDo" "(-" }
  267.  
  268. foreach f [lsort -ignore [glob "$HOME:Help:*"]] {
  269.     set f [file tail $f]
  270.     if {($f != "Manual") && ($f != "Readme") && ($f != "Changes") && ($f != "ToDo") && ($f != "Alpha Commands") && ($f != "Tcl Commands")} {
  271.         lappend men $f
  272.     }
  273. }
  274. menu -n $helpMenu -s -m -p helpMenuProc $men
  275. unset men
  276.  
  277.  
  278. proc escapeSpaces {str} {
  279.     regsub -all { } $str {\ } str2
  280.     return $str2
  281. }
  282.  
  283.  
  284. proc buildSwitches {} {
  285.     global switchApps
  286.     
  287.     menu -m -n switchTo -p switchProc {"<O<I/NNow╔" "Add╔" "Remove╔" "(-"}
  288.  
  289.     if {[info exists switchApps]} {
  290.         foreach app $switchApps {
  291.             lappend names [file tail $app]
  292.         }
  293.         foreach name [lsort -ignore $names] {
  294.             addMenuItem -m -l "blah" switchTo $name
  295.         }
  296.     }
  297. }
  298.  
  299.  
  300. proc switchProc {menu name} {
  301.     global switchTo switchApps
  302.  
  303.     if {$name == "Add"} {
  304.         set fname [getfile "Pick an app:"]
  305.         lappend switchApps $fname
  306.         addDef switchApps $switchApps
  307.         buildSwitches
  308.     } elseif {$name == "Remove"} {
  309.         foreach app $switchApps {
  310.             lappend apps [file tail $app]
  311.         }
  312.         set name [listpick -p "Remove which app?" $apps]
  313.         if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
  314.             set switchApps [lreplace $switchApps $ind $ind]
  315.             addDef switchApps $switchApps
  316.             buildSwitches
  317.         }
  318.     } elseif {$name == "Now"} {
  319.         switchApp
  320.     } else {
  321.         if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
  322.             if {[catch {switchTo $name}]} {
  323.                 launch -f [lindex $switchApps $ind]
  324.             }
  325.         }
  326.     }
  327. }
  328.         
  329.  
  330. proc winTileProc {menu item} {
  331.     win$item
  332. }
  333.  
  334. menu -n $winMenu -p menuWin {
  335.         {menu -n arrange -p winTileProc {
  336.             "/Jvertically^1"
  337.             "/J<O<Ihorizontally^2"
  338.             "tiled^3"
  339.             "overlay^4"
  340.             "(-"
  341.             {menu -n other {
  342.                 {bufferOtherWindow}
  343.                 {chooseAWindow}
  344.                 {chooseWindowStatus}
  345.                 {iconify}
  346.                 {killWindowStatus}
  347.                 {nextWin}
  348.                 {nextWindow}
  349.                 {otherThing}
  350.                 {prevWindow}
  351.                 {shrinkFull}
  352.                 {shrinkHigh}
  353.                 {shrinkLeft}
  354.                 {shrinkLow}
  355.                 {shrinkRight}
  356.                 {singlePage}
  357.                 {swapWithNext}
  358.                 {threeQuarters}
  359.                 {winhorizontally}
  360.                 {winoverlay}
  361.                 {wintiled}
  362.                 {winvertically}
  363.                 {zoom}
  364.             }}}}
  365.         "(-"
  366.         "//<Szoom"
  367.         "//<S<I<OsinglePage"
  368.         "/Y<O<Iiconify"
  369.         "splitWindow"
  370.         "/otoggleScrollbar"
  371.         "(-"
  372.         "<SprevWindow"
  373.         "<SnextWindow"
  374.         "swapWithNext"
  375.         "<S/;chooseAWindow"
  376.         "(-"
  377. }
  378.  
  379. # We may be reloading, so add whatever windows we have
  380. if {[info exists winNameToNum]} {
  381.     set nms [array names winNameToNum]
  382.     foreach name $nms {
  383.         regexp {[^:]*$} $name item
  384.         set num $winNameToNum($name)
  385.         if {$num < 10}     {
  386.             addMenuItem -m $winMenu /$num$item
  387.         } else {
  388.             addMenuItem -m $winMenu $item
  389.         }
  390.     }
  391. }
  392.  
  393. insertMenu "File"
  394. insertMenu "Edit"
  395. insertMenu "Search"
  396. insertMenu "Utils"
  397. insertMenu "Mode"
  398. enableMenuItem NamedClipboards paste off
  399. insertMenu "Convert"
  400. menu -n $fsetMenuName {}; 
  401. insertMenu $winMenu
  402.  
  403. catch {insertMenu $helpMenu}
  404.  
  405.  
  406. menu -n $terrMenu {}
  407.  
  408. menu -n $toolserverMenu {}
  409.  
  410.