home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / p2demo21.exe / PEL / MENU.PEL < prev    next >
Text File  |  1995-03-22  |  9KB  |  278 lines

  1. # $Header:   P:\source\wmacros\menu.pev   1.84   22 Mar 1995 17:11:30   WALKER  $
  2. ## $Tabs:4 7$
  3.  
  4. ##############################################################################
  5. #
  6. #       Compuware Corporation
  7. #         31440 Northwestern Highway
  8. #           Farmington Hills, Michigan 48334-2564
  9. #
  10. #   This source code listing contains information that is
  11. #   proprietary to Compuware Corporation and may not be copied
  12. #   duplicated, translated, transmitted, stored, retrieved
  13. #   or in any manner or by any method conveyed or disclosed
  14. #   to a third party or parties without express written
  15. #   permission from Compuware Corporation.
  16. #
  17. #
  18. ##############################################################################
  19.  
  20. #### $Workfile:   menu.pel  $
  21.  
  22. global main_menu     = 0
  23.  
  24. global menu_function_list[]
  25.  
  26. global function gui_menu()                                      #PUBLIC #VOID
  27. {
  28.    local menu_temp
  29.  
  30.    #
  31.    ## top level menu
  32.    #
  33.    main_menu = create_menu(IDM_MAIN, resource_dll)
  34.    # use the Windows menu option as the menu to display all open windows
  35.    # in MDI mode
  36.    set_auto_update(main_menu, 6)
  37.  
  38.    change_menu( main_menu )
  39.  
  40.     # can't delay creating the menu_list because emulation modes depend
  41.     # on menu_list being set.
  42. #   if (!editor_running)
  43. #      attach_event_handler( EVENT.EDITOR_RUNNING, "menu_setup")
  44. #   else
  45.       menu_setup()
  46. }
  47.  
  48. global function menu_setup()
  49. {
  50.    #
  51.    ## File menu
  52.    #
  53. #   message("Begin menu_setup")
  54.    delete_event( EVENT.EDITOR_RUNNING, "menu_setup")
  55.    menu_function_list[IDM_NEW]          = "gui_new"
  56.    menu_function_list[IDM_ADDFILE]      = "gui_open"
  57.    menu_function_list[IDM_INSERTFILE]   = "gui_insert_file"
  58.    menu_function_list[IDM_ERRORFILE]    = "display_error_file_key"
  59.    menu_function_list[IDM_UNDER_CURSOR] = "open_file_under_cursor"
  60.    menu_function_list[IDM_SAVE]         = "gui_save"
  61.    menu_function_list[IDM_SAVEAS]       = "gui_saveas"
  62.    menu_function_list[IDM_SAVEALL]      = "gui_saveall"
  63.    menu_function_list[IDM_PRINT]        = "gui_print"
  64.    menu_function_list[IDM_PRINTSEL]     = "gui_print_select"
  65.    menu_function_list[IDM_EXIT]         = "done"
  66.  
  67.    #
  68.    ## Edit menu
  69.    #
  70.    menu_function_list[IDM_UNDO]      = "undo" 
  71.    menu_function_list[IDM_REDO]      = "redo" 
  72.    menu_function_list[IDM_CUT]       = "delete_to_scrap" 
  73.    menu_function_list[IDM_COPY]      = "copy_to_scrap_key" 
  74.    menu_function_list[IDM_APPEND]    = "append_to_scrap" 
  75.    menu_function_list[IDM_PASTE]     = "insert_scrap" 
  76.    menu_function_list[IDM_DELETE]    = "delete_chars" 
  77.    menu_function_list[IDM_UPPER]     = "upper" 
  78.    menu_function_list[IDM_LOWER]     = "lower" 
  79.    menu_function_list[IDM_INDENT]    = "indent_tab_maybe" 
  80.    menu_function_list[IDM_OUTDENT]   = "outdent_tab_maybe" 
  81.  
  82.    #
  83.    ## Search menu
  84.    #
  85.    menu_function_list[IDM_FIND]             = "gui_find" 
  86.    menu_function_list[IDM_FINDAGAIN]        = "gui_search_again" 
  87.    menu_function_list[IDM_ISEARCH]          = "search_i" 
  88.    menu_function_list[IDM_CHANGE]           = "gui_change" 
  89.    menu_function_list[IDM_FINDMATCHING]     = "goto_matching" 
  90.    menu_function_list[IDM_MARKMATCHING]     = "mark_matching" 
  91.    menu_function_list[IDM_MARKNEXTMATCHING] = "mark_matching_next" 
  92.    menu_function_list[IDM_ROUTINE]          = "routines"
  93.    menu_function_list[IDM_GOTOLINE]         = "goto_line_key" 
  94.    menu_function_list[IDM_BOOKMARKLIST]     = "bookmark_list" 
  95.  
  96.    #
  97.    ## Buffers menu
  98.    #
  99.    menu_function_list[IDM_NEXT]         = "next_buffer_mask" 
  100.    menu_function_list[IDM_PREV]         = "prev_buffer_mask" 
  101.    menu_function_list[IDM_CLOSE]        = "gui_delete_buffer" 
  102.    menu_function_list[IDM_BUFFERLIST]   = "buffer_list" 
  103.  
  104.    #
  105.    ## Tools menu
  106.    #
  107.    menu_function_list[IDM_COMMAND]      = "gui_command" 
  108.    menu_function_list[IDM_DOSBOX]       = "dos_box" 
  109.    menu_function_list[IDM_DOSSHELL]     = "system" 
  110.    menu_function_list[IDM_COMPILE]      = "compile_buffer" 
  111.    menu_function_list[IDM_PEL_DEBUGGER] = "debug" 
  112.    menu_function_list[IDM_DIALOG_LIST]  = "dialog_list" 
  113.    menu_function_list[IDM_NEXTERR]      = "goto_next_error" 
  114.    menu_function_list[IDM_PREVERR]      = "goto_prev_error" 
  115.    menu_function_list[IDM_CTAGS_LOCATE] = "tags" 
  116.    menu_function_list[IDM_CTAGS_MAKE]   = "ctags_make_dialog" 
  117.    menu_function_list[IDM_PELTAGS_MAKE] = "peltags_make" 
  118.  
  119.    #
  120.    ## PVCS submenu
  121.    #
  122.    menu_function_list[IDM_GET]   = "pvcs_get_existing_buffer 1"
  123.    menu_function_list[IDM_PUT]   = "pvcs_put_buffer 1"
  124.    menu_function_list[IDM_VDIFF] = "pvcs_vdiff"
  125.    
  126.    #
  127.    ## Options menu
  128.    #
  129.    menu_function_list[IDM_QUICK_SETTINGS]  = "quick_settings" 
  130.    menu_function_list[IDM_EDITOR_SETTINGS] = "settings_notebook" 
  131.    menu_function_list[IDM_SAVE_SETTINGS]   = "save_settings_data 1"
  132.    menu_function_list[IDM_SAVE_STATE]      = "save_state_data 1"
  133.  
  134.    menu_function_list[IDM_COLOR]           = "color_dialog_key" 
  135.    menu_function_list[IDM_FONT]            = "font_dialog"
  136.    menu_function_list[IDM_KEY_BINDINGS]    = "keys_dialog" 
  137.    menu_function_list[IDM_TOOLBAR]         = "toggle_toolbar" 
  138.    menu_function_list[IDM_STATUSBAR]       = "toggle_status_bar" 
  139.  
  140.    #
  141.    ## Create the Window menu.
  142.    #
  143.    menu_function_list[IDM_HEX_MODE]        = "toggle_dump_mode" 
  144.  
  145.    # Located in mdi.pel
  146.    optional_function( "mdi_menu" )
  147.  
  148.    #
  149.    ## Help menu
  150.    #
  151.    menu_function_list[IDM_INDEX]        = "gui_help_index" 
  152.    menu_function_list[IDM_GENERAL]      = "gui_general_help" 
  153.    menu_function_list[IDM_USING]        = "gui_using" 
  154.    menu_function_list[IDM_KEYWORDHELP]  = "display_help_item" 
  155.    menu_function_list[IDM_ABOUT]        = "about_dialog" 
  156.  
  157.    menu_functions = menu_function_list
  158.  
  159.    optional_function( "xpp_tools_menu", main_menu )
  160.    optional_function( "xpp_options_menu", main_menu )
  161.  
  162.    optional_function( "user_menu" )    # add user menus, if any
  163.  
  164.    # use the Windows menu option as the menu to display all open windows
  165.    # in MDI mode
  166.    set_auto_update(main_menu, 6)
  167.  
  168.    change_menu( main_menu )
  169.  
  170.    optional_function( "modify_mdi_menu", mdi_mode ) # fix windows menu
  171.  
  172.    optional_function( "add_editfile_to_menu" )
  173. #   message("End menu_setup")
  174. }
  175.  
  176.  
  177. global function attach_menu_to_win( win )
  178. {
  179.    local menu
  180.  
  181.    if ( !win )
  182.       win = current_window
  183.  
  184.    menu = create_menu(IDM_MAIN, resource_dll)
  185.  
  186.    change_menu( menu, win );
  187.  
  188.    modify_mdi_menu(mdi_mode, menu)
  189. }
  190.  
  191. global function cpe_popup_create()
  192. {
  193.    popupmenu = create_menu(IDM_POPUP, resource_dll)
  194.  
  195.    menu_function_list[POP_CUT]              = "gui_delete_to_scrap" 
  196.    menu_function_list[POP_COPY]             = "copy_to_scrap_key" 
  197.    menu_function_list[POP_PASTE]            = "insert_scrap" 
  198.    menu_function_list[POP_DELETE]           = "delete_chars" 
  199.    menu_function_list[POP_UPPER]            = "upper" 
  200.    menu_function_list[POP_LOWER]            = "lower" 
  201.    menu_function_list[POP_INDENT]           = "indent_tab_maybe" 
  202.    menu_function_list[POP_OUTDENT]          = "outdent_tab_maybe" 
  203.    menu_function_list[POP_FIND]             = "gui_context_find" 
  204.    menu_function_list[POP_FINDMATCHING]     = "goto_matching" 
  205.    menu_function_list[POP_MARKMATCHING]     = "mark_matching" 
  206.    menu_function_list[POP_MARKNEXTMATCHING] = "mark_matching_next" 
  207.    menu_function_list[POP_INSERTFILE]       = "gui_insert_file" 
  208.    menu_function_list[POP_WRITEBLOCK]       = "gui_write_block" 
  209.    menu_function_list[POP_KEYWORDHELP]      = "display_help_item" 
  210.  
  211.    menu_functions = menu_function_list
  212.    optional_function( "xpp_popup_menu", popupmenu )
  213. }                                                                                                 
  214.  
  215. global function gui_show_popup()
  216. {
  217.    optional_function( "xpp_filter_popup_menu")
  218.    show_popup(popupmenu)
  219. }
  220.  
  221. global function reset_menu_text()
  222. {
  223.    local menu = menu_info( 0, 0 )
  224.  
  225.    modify_menuitem( menu, 0, MI_RESET_KEYSTEXT )
  226. }
  227.  
  228. global function fix_menu_text( id, mapped, prefix, keymap )
  229. {
  230.    local temp_array[]
  231.    local count = argcount()
  232.  
  233.    if ( count < 2 )
  234.       return
  235.  
  236.    temp_array[ id ].mapped = mapped
  237.  
  238.    if ( count >= 3 )
  239.       temp_array[ id ].prefix = prefix
  240.  
  241.    if ( count >= 4 )
  242.       temp_array[ id ].keymap = keymap
  243.  
  244.    mapped_menu_functions = temp_array
  245. }
  246.  
  247. global function set_menu_mappings( mapped, prefix, keymap )
  248. {
  249.    local temp_array[]
  250.    local count = argcount()
  251.  
  252.    if ( count >= 1 )
  253.    {
  254.       temp_array.mapped = mapped
  255.  
  256.       if ( count >= 2 )
  257.       {
  258.          temp_array.prefix = prefix
  259.  
  260.          if ( count >= 3 )
  261.             temp_array.keymap = keymap
  262.       }
  263.    }
  264.  
  265.    return temp_array
  266. }
  267.  
  268. global function set_default_keymap( keymap )
  269. {
  270.    mapped_menu_functions[ "0" ].keymap = keymap
  271. }
  272.  
  273. global function delete_mapped_menu()
  274. {
  275.    if ( mapped_menu_functions )
  276.       delete mapped_menu_functions
  277. }
  278.