home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / source / menustuf.sit / PromoteMenu.p < prev    next >
Text File  |  1990-04-16  |  1KB  |  66 lines

  1. Program PromoteMenu;
  2. {
  3.     This program is an MPW tool which removes a menu from the hierarchical
  4.     portion of the menu list and adds it onto the end of the menu bar.
  5.     Call it from the MPW Shell as follows:
  6.  
  7.         PromoteMenu [menuName]
  8.  
  9.     where menuName is the name of the menu to be promoted. If the argument
  10.     is omitted, a list of all the current top-level menus is written to
  11.     the standard output, as a sequence of PromoteMenu commands.
  12.  
  13.     First working version by LDO 1989 January 4.
  14.     Modified 1989 January 6 to add listing function.
  15.     Modified 1989 January 9 to use nicer quoting function.
  16. }
  17.  
  18.     Uses
  19.         MemTypes,
  20.         QuickDraw,
  21.         OSIntf,
  22.         ToolIntf,
  23.         IntEnv,
  24.         MenuStuffCommon;
  25.  
  26.     Var
  27.         TheMenu : MenuHandle;
  28.         ItemNo : LongInt;
  29.  
  30.     Procedure ListTopLevel
  31.       (
  32.         ThisMenu : MenuHandle;
  33.         var KeepGoing : Boolean;
  34.         Ignored : univ LongInt
  35.       );
  36.       { handler which generates the list of promoted menus. }
  37.  
  38.         Var
  39.             ThisMenuName : Str255;
  40.  
  41.       Begin
  42.         ThisMenuName := ThisMenu^^.MenuData;
  43.         Writeln(Output, ArgV^[0]^, ' ', Quote(ThisMenuName))
  44.       End {ListTopLevel};
  45.  
  46.   Begin {PromoteMenu}
  47.     InitGraf(@ThePort);
  48.     If ArgC > 1 then
  49.       Begin
  50.         TheMenu := FindSubMenu(ArgV^[1]^);
  51.         If TheMenu <> Nil then
  52.           Begin
  53.             DeleteMenu(TheMenu^^.MenuID);
  54.             InsertMenu(TheMenu, 0);
  55.             DrawMenuBar
  56.           End
  57.         else
  58.           Begin
  59.             Writeln(Diagnostic, '### ', ArgV^[0]^, ' - submenu "', ArgV^[1]^, '" not found');
  60.             IEExit(2)
  61.           End
  62.       End
  63.     else
  64.         TraverseMenus(@ListTopLevel, Nil)
  65.   End {PromoteMenu}.
  66.