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

  1. # $Header:   P:\source\wmacros\startup.pev   1.87   20 Mar 1995 17:28:42   NOBLE  $
  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:   startup.pel  $: System startup processing
  21.  
  22. global temp_create_new_bufwin = FALSE;
  23.  
  24. ###
  25. # The startup() function controls the overall initialization and 
  26. # customization of the Sage Professional Editor.  For certain special 
  27. # applications it may be desirable to modify or replace startup() in order to 
  28. # override normal startup behavior.  However, caution is advised.
  29. #
  30. # The recommended location for routine customizations is (a) in the 
  31. # local_setup() function in LOCAL.PEL, (b) in the PVCSEDIT.CFG config file, 
  32. # or (c) in both locations.  Local_setup() provides the fastest 
  33. # initialization, and is the preferred location for customizations that 
  34. # change infrequently.  Items in the configuration file execute a little more 
  35. # slowly, but are easily changed.  Presently, all the customizations provided 
  36. # by setup are placed in the config file, and override local_setup().  This 
  37. # permits multiple users or projects to share a base configuration of the 
  38. # editor, yet easily allows local customizations.
  39. #
  40. global function startup()
  41. {
  42.    process_background( DISABLE_FOREGROUND, function_id("do_startup") )
  43. }
  44.  
  45. global function do_startup()
  46. {
  47.    local menu
  48.    local tbhand
  49.    local is_visible
  50.  
  51.    ###
  52.    # The items contained within this function are customizable, though
  53.    # few will want to change them here:
  54.    
  55.    local  save_flags;
  56.    
  57.    pause_on_error = 1            # DO prompt after each error
  58.    
  59.    attach_event_handler( EVENT.EDITOR_RUNNING, "setup_global_keycodes" )
  60.    
  61.    # this dll contains all of the default resources used by the editor.
  62.    use_resource_file(resource_dll)
  63.       
  64.    optional_function( "default_status_bar" )
  65.    
  66.    ###
  67.    # Load the config buffer so it is available to read sections from
  68.    # without having to be repeatedly loaded and unloaded.
  69.    #
  70.    get_config_buffer()
  71.  
  72.    ###
  73.    # Setup GUI objects.
  74.    #
  75.    optional_function( "create_default_toolbar" )      # set up default toolbar
  76.    optional_function( "gui_menu" )                    # set up default menu
  77.    optional_function( "cpe_popup_create" )            # set up default popupmenu
  78.    
  79.    # the attach help call without the window handle 
  80.    # causes the help file to be attached with the editor window
  81.    #
  82.    attach_help(editor_helpfile) 
  83.  
  84.    attach_event_handler(EVENT.HELP_INVOKED,        "display_help HelpTOC")
  85.    attach_event_handler(EVENT.EXIT_EDITOR,         "exit_editor")
  86.                                                    
  87.    attach_event_handler(EVENT.MOUSE_RIGHT_DOWN,    "mouse_right_down")
  88.    attach_event_handler(EVENT.MOUSE_RIGHT_UP,      "mouse_right_up")
  89.    attach_event_handler(EVENT.RMOUSE_DRAG,         "mouse_right_drag")
  90.                                                    
  91.    attach_event_handler(EVENT.LMOUSE_DRAG,         "lmouse_drag")
  92.    attach_event_handler(EVENT.MOUSE_LEFT_DOWN,     "mouse_left_down")
  93.    attach_event_handler(EVENT.MOUSE_LEFT_UP,       "mouse_left_up")
  94.                                                    
  95.    attach_event_handler(EVENT.RESIZE_EDITWIN,      "resize_editwin")
  96.    attach_event_handler(EVENT.EDITOR_RUNNING,      "editor_start")
  97.                                                    
  98.    attach_event_handler(EVENT.FILE_DROPPED,        "file_dropped")
  99.  
  100.    attach_event_handler(EVENT.NEW_EDIT_FILE,       "new_edit_file" ) 
  101.    attach_event_handler(EVENT.NEW_CURNT_BUFFER,    "syntax_new_buffer" ) 
  102.                                                    
  103.    attach_event_handler(EVENT.EMULATION_CHANGED,   "delete_mapped_menu" ) 
  104.    attach_event_handler(EVENT.UNABLE_TO_OPEN_FILE, "catch_file_open_error" ) 
  105.  
  106.    attach_event_handler( EVENT.FIRST_MOD,          "file_access_first_mod_handler" )
  107.    attach_event_handler( EVENT.UNMOD,              "file_access_unmod_handler" )
  108.    attach_event_handler( EVENT.NEW_EDIT_FILE,      "file_access_file_open_handler" )
  109.  
  110.    attach_event_handler( EVENT.WINDOW_CREATED,     "new_window" )
  111.    attach_event_handler( EVENT.TRACKING_DONE,      "create_track_window" )
  112.  
  113.    ###
  114.    # initialize language structure
  115.    #
  116.    optional_function("load_user_extensions");
  117.    optional_function("load_user_compilers");
  118.    optional_function("load_user_syntax_colors"); #  Colors need to be loaded before styles
  119.  
  120.    optional_function("load_user_styles"); #  Styles need to be loaded before types so the default categories will get the right colors.
  121.    syntax_loaded["__styles"] = TRUE;
  122.  
  123.    optional_function("load_user_types"); #  Types need to be loaded after styles so the default categories will have the right colors.
  124.    optional_function("load_factory_default_templates");
  125.  
  126.    ###
  127.    #  Set default_word_delimiter to what we think they want
  128.    #
  129.    default_word_delimiter = "~!@#$%^&*()+{}|:\"<>?`-=[]\\;',./";
  130.    word_delimiter  = default_word_delimiter;
  131.                             
  132.    ###
  133.    # implement hard-wired user customization:
  134.    #
  135.    optional_function( "local_setup" )
  136.    
  137.    ###
  138.    # decide now whether to show the toolbar or not.  Before, there where 
  139.    # problems where id's and things set from an emulation weren't set because
  140.    # the toolbar didn't exist yet.
  141.    #
  142.    optional_function( "toggle_toolbar", 1 )
  143.  
  144.    ###
  145.    # Read soft-wired configuration and state information from the config file
  146.    #
  147.    optional_function( "read_config_file" )
  148.  
  149.    ###
  150.    # Implement hard-wired user settings customization:
  151.    #
  152.    optional_function( "local_settings" )
  153.  
  154.    ###
  155.    # Kill the config buffer we loaded earlier
  156.    #
  157.    delete_config_buffer()
  158.       
  159.    ###
  160.    # Initialize the Xpediter+ event handlers
  161.    #
  162.    optional_function( "xpp_init" )
  163.       
  164.    ###
  165.    # Process command line options and create buffers for all files 
  166.    # named on the command line
  167.    #
  168.    process_command_line()
  169.  
  170.    ###
  171.    # If no emulation mode has been defined by setup or config then
  172.    #       use "cua".  This may override some of the settings
  173.    #       defined in local_setup or in the config file, (notably
  174.    #       default_window_flags, search_flags, and calls to the
  175.    #       assign_key function).
  176.    #
  177.    if ( emulation_mode == "" )
  178.    {
  179.       optional_function( "cua" )
  180. #      toggle_linenumbers( 2 )
  181.    }
  182.    
  183.    ###
  184.    # The Last thing we need to do is place the copyright notice on the
  185.    # status line
  186.    #
  187.    optional_function( "default_status_bar", 1 )
  188.    notify( version" - (c) 1994,1995 Compuware Corp. All Rights Reserved." );
  189.    optional_function( "restore_status_bar" )
  190.  
  191.    # Due to an apparent problem between CommonView and Windows, we need to
  192.    # force an update of the MDI menu after the windows have been created
  193.    # Also need to make sure status bar and toolbar menu items are properly
  194.    # checked
  195.  
  196.    optional_function( "modify_mdi_menu", mdi_mode )
  197.    optional_function( "toggle_status_bar", 1, status_bar_flags)
  198.  
  199.    ###
  200.    # When startup() exits, the editor will create a full-screen window,
  201.    # Next it will ensure that current_window is a non-system window
  202.    # and current_buffer is attached.  (These steps are omitted if they
  203.    # have already been performed by the config file or local_setup().)
  204.    #
  205.    # Then the editor will begin processing keyboard input.
  206.    #
  207.  
  208.    display_redraw()
  209. }
  210.