menu.red 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. % simple demo of tools for menus and break windows
  2. % MLG and WFG
  3. Symbolic Procedure MakeMenu();
  4. % Setup the Menu Window
  5. begin scalar oldbuffer;
  6. % Create the MENU buffer
  7. MenuBuffer:=CreateBuffer('MENU, eval DefaultMode);
  8. % Create (but don't "select") the window to look into the buffer.
  9. MenuWindow :=
  10. FramedWindowDescriptor('MENU,
  11. % Starts at column 50, Row 13
  12. Coords(50,13),
  13. Coords(25,7));
  14. % Set up the buffer text.
  15. oldbuffer := CurrentBufferName;
  16. SelectBuffer 'MENU;
  17. append_line("ERASE(); % the screen");
  18. append_line("ExitMenu();");
  19. append_line("KillMenu();");
  20. !$CRLF();
  21. % "Pop" back to original buffer.
  22. SelectBuffer oldbuffer;
  23. % Define a new key binding (for text mode) for popping up the menu.
  24. SetTextKey(Char Cntrl H, 'Menu);
  25. end;
  26. Procedure KillMenu(); % Exit and Wipe MENU
  27. <<!*KillMenu:=T; Throw('!$MENU!$,0)>>;
  28. Procedure ExitMenu(); % Exit and LEAVE Menu
  29. <<!*KillMenu:=NIL; Throw('!$MENU!$,0)>>;
  30. Fluid '(!*KillMenu);
  31. procedure MenuReader();
  32. TopLoop('ReformXread,'NoPrint,'EVAL,"Menu","");
  33. Procedure NoPrint x;
  34. X;
  35. procedure Menu;
  36. Begin Scalar W;
  37. % Need to select EMODE channels, since MENU is typically invoked while
  38. % "old" channels are selected.
  39. SelectEMODEChannels();
  40. W:=CurrentWindowdescriptor;
  41. SelectWindow MenuWindow$
  42. !$BeginningOfBuffer(); % Place point at start of buffer.
  43. % Transfer control to the menu reader.
  44. Catch('!$MENU!$, MenuReader() );
  45. % When finished, "pop" our screen off of the physical screen.
  46. If !*KillMenu then DeselectScreen CurrentVirtualScreen;
  47. SelectWindow W; % Back to the window we originally had.
  48. end;