home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmmac2.zip / SAMPACTN.E < prev    next >
Text File  |  1996-04-10  |  19KB  |  427 lines

  1. ; This is a Toolbar Actions file.  You add a line to your ACTIONS.LST:
  2. ;    sampactn
  3. ; to indicate that this should be invoked to build the list of defined
  4. ; actions when the user asks for a list (by selecting Create or Edit
  5. ; from the toolbar pop-up menu and clicking on the drop-down arrow
  6. ; on the Actions page).  EPM loads this .ex file and executes the
  7. ; command SAMPACTN_ACTIONLIST (it appends "_ACTIONLIST" to the name of the
  8. ; .ex file).  This command must be defined by the actions file to add
  9. ; a line to a file for each toolbar-definable action defined in the .ex
  10. ; file.
  11.  
  12. ; The line consists of the command to be executed, a description of the
  13. ; action, and the name of the .ex file, each separated by a delimiter
  14. ; (which is the first character on the line, and can be any character
  15. ; otherwise unused on that line; below, an ASCII 1 is used throughout).
  16. ; The description is used in the action page description field when
  17. ; you edit or create an item of the toolbar. It should explain both what
  18. ; the action does, and which parameters it expects.
  19. ; No space is wasted because the descriptions below
  20. ; are constants which are also used as button selection prompts.
  21.  
  22. ; The action commands (below, "a_messages", etc.) may be called with a
  23. ; parameter of "I" to indicate that the menu has been initialized (the user
  24. ; pressed MB1 down over this toolbar item, or pressed MB1 down over another
  25. ; toolbar item and dragged the mouse over this item, or pressed F10 to go to
  26. ; the action bar and scrolled to this toolbar item), "E" for a menu-end message,
  27. ; "H" for Help (user pressed F1), or "S" to indicate that the toolbar item
  28. ; has been selected.  The parameter might be followed by command parameters
  29. ; if the user entered any in the Parameters field of the Actions page.
  30.  
  31. ; Now, the executable portions of the file.  First, include some files to
  32. ; define constants that will be needed in this file (yours might not need them):
  33.  
  34. const
  35.    WANT_DYNAMIC_PROMPTS = 1  -- Force definition of menu prompts in ENGLISH.E.
  36. include 'stdconst.e'
  37. include 'english.e'
  38. include 'menuhelp.h'
  39.  
  40. ; Next, define some additional text constants (defined as separate constants
  41. ; instead of using the strings where needed in order to allow for easier NLS
  42. ; translation).
  43.  
  44. const
  45. ;  a_Messages_PROMPT = MESSAGES_MENUP__MSG  -- Defined in ENGLISH.E.  Starts with ASCII 1
  46.    a_Add_New__MSG = 'Add New'
  47.    a_Add_New_PROMPT = 'Add a new, .Untitled file to the ring'
  48.    a_Open_empty_PROMPT = \1'Open a new edit window containing .Untitled'
  49.    a_NewWindow_PROMPT = \1'Move current file to new edit window (saving changes, if any)'
  50. ;  a_Settings_PROMPT = CONFIG_MENUP__MSG
  51.    a_Time_PROMPT = \1'Display or type the time'
  52.    a_Time_PROMPT2= '.  Parameter = "?" to display, or "I" to insert into file.'
  53.    a_Date_PROMPT = \1'Display or type the date'
  54.    a_Date_PROMPT2= '.  Parameter = "?" to display, or "USA", "European", "Ordered" or "Normal" to insert into file.'
  55.    a_MonoFont_PROMPT = 'Change to a monospaced font, or back to the default font'
  56. ;  a_Shell_PROMPT = CREATE_SHELL_MENUP__MSG
  57.    a_Shell_PROMPT2 = '.  Optional parameter is command to be written to new shell window.'
  58. ;  a_List_Ring_PROMPT = LIST_FILES_MENUP__MSG
  59.    a_Toggle_Hilight__MSG = 'Keyword highlighting'
  60.    a_Toggle_Hilight_PROMPT = 'Toggle keyword highlighting on or off'
  61.    a_Print__MSG = 'Print'
  62.    a_Match_Brackets_PROMPT = 'Move cursor to matching bracket, #if / #endif, :ol / :eol, /* */, or SGML tag.'
  63.    a_Match_Brackets_PROMPT2 = '(bracket is one of ()[]{}<> )'
  64.    Generic_toolbar_help_title = 'Help for Toolbar selection'
  65.    EXECUTES_COMMAND = 'Executes command:'
  66.    NO_HILIGHT_KNOWN__MSG = "Don't know what keyword highlighting file to use."
  67.    a_Timestamp_PROMPT = \1'Type a timestamp into the file'
  68.  
  69. EA_comment 'This is a toolbar "actions" file which defines a number of simple commands.'
  70.  
  71. ----------------------- End of MRI for translation ---------------------------------
  72.  
  73. ; Here is the <file_name>_ACTIONLIST command that adds the action commands
  74. ; to the list.
  75.  
  76. defc sampactn_actionlist
  77.    universal ActionsList_FileID  -- This is the fileid that gets the line(s)
  78.  
  79.    insertline "a_Messages"MESSAGES_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  80.    insertline "a_Add_New"a_Add_New_PROMPT"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  81.    insertline "a_Add_File"ADD_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  82.    insertline "a_Open_empty"a_Open_empty_PROMPT"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  83.    insertline "a_NewWindow"a_NewWindow_PROMPT"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  84.    insertline "a_Settings"CONFIG_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  85.    insertline "a_Time"a_Time_PROMPT||a_Time_PROMPT2"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  86.    insertline "a_Date"a_Date_PROMPT||a_Date_PROMPT2"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  87.    insertline "a_TimeStamp"a_Timestamp_PROMPT"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  88.    insertline "a_MonoFont"a_MonoFont_PROMPT"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  89.    insertline "a_Shell"CREATE_SHELL_MENUP__MSG || a_Shell_PROMPT2"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  90.    insertline "a_List_Ring"LIST_FILES_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  91.    insertline "a_Compiler_Help"DESCRIBE_COMPILER_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  92.    insertline "a_Compiler_Next"NEXT_COMPILER_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  93.    insertline "a_Compiler_Prev"PREV_COMPILER_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  94.    insertline "a_Proof"PROOF_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  95.    insertline "a_Synonym"SYNONYM_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  96.    insertline "a_Togl_Hilit"a_Toggle_Hilight_PROMPT"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  97.    insertline "a_Print"ENHPRT_FILE_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  98.    insertline "a_Save"SAVE_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  99.    insertline "a_SearchDlg"SEARCH_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  100.    insertline "a_UndoDlg"UNDO_REDO_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  101.    insertline "a_Quit"QUIT_MENUP__MSG"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  102.    insertline "a_match_brackets"a_MATCH_BRACKETS_PROMPT a_MATCH_BRACKETS_PROMPT2"sampactn", ActionsList_FileID.last+1, ActionsList_FileID
  103.  
  104. ; These are the command that will be called for the above actions.  Since all
  105. ; actions defined herein resolve to standard commands, the Help doesn't need
  106. ; to load an additional help file; it can refer to panels in the standard
  107. ; EPM.HLP.
  108.  
  109. defc a_Messages
  110.    a_common_action(arg(1), 'messagebox', MESSAGES_MENUP__MSG, HP_OPTIONS_MESSAGES)
  111.  
  112. defc a_Add_New
  113.    parse arg action_letter parms
  114.    if action_letter = 'I' then       -- button Initialized
  115.       display -8
  116.       sayerror a_Add_New_PROMPT
  117.       display 8
  118.    elseif action_letter = 'S' then   -- button Selected
  119.       sayerror 0                        -- Clear prompt
  120.       'xcom e /n'                       -- execute action
  121.    elseif action_letter = 'H' then   -- button Help
  122. ;;    'helpmenu' ???                     -- No help panel for this; use a messagebox
  123.       call winmessagebox(a_Add_New__MSG, a_Add_New_PROMPT, MB_OK + MB_INFORMATION + MB_MOVEABLE)
  124.    elseif action_letter = 'E' then   -- button End
  125. ;;    sayerror 0                        -- (We don't do anything for this one; get lots of them.)
  126.    endif
  127.  
  128. defc a_Add_File
  129.    a_common_action(arg(1), 'opendlg EDIT', ADD_MENUP__MSG, HP_FILE_EDIT)
  130.  
  131. defc a_Open_empty
  132.    a_common_action(arg(1), 'open', a_Open_empty_PROMPT, HP_FILE_OPEN_NEW)
  133.  
  134. defc a_NewWindow
  135.    a_common_action(arg(1), 'newwindow', a_NewWindow_PROMPT, 1990)
  136.  
  137. defc a_Settings
  138.    a_common_action(arg(1), 'configdlg', CONFIG_MENUP__MSG, HP_OPTIONS_CONFIG)
  139.  
  140. defc a_Time
  141. ;compile if WANT_DBCS_SUPPORT
  142.    universal countryinfo
  143. ;compile endif
  144. ;;  a_common_action(arg(1), 'qt', a_Time_PROMPT, 2250)
  145.    parse arg action_letter parms
  146.    if action_letter = 'I' then       -- button Initialized
  147.       display -8
  148.       sayerror a_Time_PROMPT
  149.       display 8
  150.    elseif action_letter = 'S' then   -- button Selected -  execute action
  151.       sayerror 0                        -- Clear prompt
  152.       if abbrev('?', parms, 0) then
  153.          'qt'
  154.       else
  155. ;compile if WANT_DBCS_SUPPORT  -- We're not including MYCNF.E...
  156.         if countryinfo then    -- Instead, see if countryinfo has been set.
  157.  compile if EPM32
  158.          time_sep = substr(countryinfo,24,1)
  159.  compile else
  160.          time_sep = substr(countryinfo,18,1)
  161.  compile endif
  162.         else
  163.          time_sep = ':'
  164.         endif
  165.          parse value gettime(0) with ':' mm ':' ss . ';' h24 ':'
  166.          keyin h24 || time_sep || mm || time_sep || ss' '
  167. ;compile else
  168. ;         parse value gettime(0) with ':' mmss . ';' h24 ':'
  169. ;         keyin h24':'mmss
  170. ;compile endif
  171.       endif
  172.    elseif action_letter = 'H' then   -- button Help
  173.       'helpmenu 2250'
  174. ;  elseif action_letter = 'E' then   -- button End
  175. ;;    sayerror 0                        -- (We don't do anything for this one; get lots of them.)
  176.    endif
  177.  
  178. defc a_Date
  179. ;  a_common_action(arg(1), 'qd', a_Date_PROMPT, 2240)
  180.    parse arg action_letter parms
  181.    if action_letter = 'I' then       -- button Initialized
  182.       display -8
  183.       sayerror a_Date_PROMPT
  184.       display 8
  185.    elseif action_letter = 'S' then   -- button Selected -  execute action
  186.       sayerror 0                        -- Clear prompt
  187.       if abbrev('?', parms, 0) then
  188.          'qd'
  189.       else
  190.          parse value getdate(0) with WeekDay Month Day ', ' Year';'MonthNum
  191.          parms = upcase(parms)
  192.          if abbrev('USA', parms, 1) then
  193.             keyin monthnum'/'rightstr(day, 2, 0)'/'rightstr(year, 2)' '
  194.          elseif abbrev('EUROPEAN', parms, 1) then
  195.             keyin day'/'rightstr(monthnum, 2, 0)'/'rightstr(year, 2)' '
  196.          elseif abbrev('ORDERED', parms, 1) then
  197.             keyin rightstr(year, 2)'/'rightstr(monthnum, 2, 0)'/'rightstr(day, 2, 0)' '
  198.          else
  199.             keyin day leftstr(month, 3) year' '   -- 7 March 1995
  200.          endif
  201.       endif
  202.    elseif action_letter = 'H' then   -- button Help
  203.       'helpmenu 2240'
  204. ;  elseif action_letter = 'E' then   -- button End
  205. ;;    sayerror 0                        -- (We don't do anything for this one; get lots of them.)
  206.    endif
  207.  
  208. defc a_TimeStamp
  209.    a_common_action(arg(1), 'TimeStamp', a_TimeStamp_PROMPT, 0)
  210.  
  211. defc a_Quit
  212.    a_common_action(arg(1), 'quit', QUIT_MENUP__MSG, HP_FILE_QUIT)
  213.  
  214. defc a_MonoFont
  215.    universal default_font
  216.    parse arg action_letter parms
  217.    if action_letter = 'I' then       -- button Initialized
  218.       display -8
  219.       sayerror a_MonoFont_PROMPT
  220.       display 8
  221.    elseif action_letter = 'S' then   -- button Selected -  execute action
  222.       sayerror 0                        -- Clear prompt
  223.       parse value queryfont(.font) with fontname '.'
  224.       if fontname='System Monospaced' then
  225.          .font = default_font
  226.       else
  227.          'monofont'
  228.       endif
  229.    elseif action_letter = 'H' then   -- button Help
  230.       'helpmenu 1991'
  231.    elseif action_letter = 'E' then   -- button End
  232. ;;    sayerror 0                        -- (We don't do anything for this one; get lots of them.)
  233.    endif
  234.  
  235. defc a_Shell
  236.    parse arg action_letter parms
  237.    if action_letter = 'I' then       -- button Initialized
  238.       display -8
  239.       sayerror substr(CREATE_SHELL_MENUP__MSG, 2)
  240.       display 8
  241.    elseif action_letter = 'S' then   -- button Selected
  242.       if isadefc('shell') then
  243.          sayerror 0                        -- Clear prompt
  244.          'shell' parms                     -- execute action
  245.       else
  246.          sayerror 'EPM was compiled without WANT_EPM_SHELL = 1; SHELL command not available.'
  247.       endif
  248.    elseif action_letter = 'H' then   -- button Help
  249.       'helpmenu' HP_COMMAND_SHELL
  250.    elseif action_letter = 'E' then   -- button End
  251. ;;    sayerror 0                        -- (We don't do anything for this one; get lots of them.)
  252.    endif
  253.  
  254. defc a_List_Ring
  255.    a_common_action(arg(1), 'ring_more', LIST_FILES_MENUP__MSG, HP_OPTIONS_LIST)
  256.  
  257. defc a_Compiler_Help
  258.    parse arg action_letter parms
  259.    if action_letter = 'I' then       -- button Initialized
  260.       display -8
  261.       sayerror substr(DESCRIBE_COMPILER_MENUP__MSG, 2)
  262.       display 8
  263.    elseif action_letter = 'S' then   -- button Selected
  264.       sayerror 0                        -- Clear prompt
  265.       'compiler_help'                   -- execute action
  266.    elseif action_letter = 'H' then   -- button Help
  267. ;;    'helpmenu' ???                     -- No help panel for this; use a messagebox
  268.       call winmessagebox(DESCRIBE_COMPILER_MENU__MSG, DESCRIBE_COMPILER_MENUP__MSG, MB_OK + MB_INFORMATION + MB_MOVEABLE)
  269.    elseif action_letter = 'E' then   -- button End
  270. ;;    sayerror 0                        -- (We don't do anything for this one; get lots of them.)
  271.    endif
  272.  
  273. defc a_Compiler_Next
  274.    parse arg action_letter parms
  275.    if action_letter = 'I' then       -- button Initialized
  276.       display -8
  277.       sayerror substr(NEXT_COMPILER_MENUP__MSG, 2)
  278.       display 8
  279.    elseif action_letter = 'S' then   -- button Selected
  280.       sayerror 0                        -- Clear prompt
  281.       'nextbookmark N 16'               -- execute action
  282.    elseif action_letter = 'H' then   -- button Help
  283. ;;    'helpmenu' ???                     -- No help panel for this; use a messagebox
  284.       call winmessagebox(NEXT_COMPILER_MENU__MSG, NEXT_COMPILER_MENUP__MSG, MB_OK + MB_INFORMATION + MB_MOVEABLE)
  285.    elseif action_letter = 'E' then   -- button End
  286. ;;    sayerror 0                        -- (We don't do anything for this one; get lots of them.)
  287.    endif
  288.  
  289. defc a_Compiler_Prev
  290.    parse arg action_letter parms
  291.    if action_letter = 'I' then       -- button Initialized
  292.       display -8
  293.       sayerror substr(PREV_COMPILER_MENUP__MSG, 2)
  294.       display 8
  295.    elseif action_letter = 'S' then   -- button Selected
  296.       sayerror 0                        -- Clear prompt
  297.       'nextbookmark P 16'               -- execute action
  298.    elseif action_letter = 'H' then   -- button Help
  299. ;;    'helpmenu' ???                     -- No help panel for this; use a messagebox
  300.       call winmessagebox(PREV_COMPILER_MENU__MSG, PREV_COMPILER_MENUP__MSG, MB_OK + MB_INFORMATION + MB_MOVEABLE)
  301.    elseif action_letter = 'E' then   -- button End
  302. ;;    sayerror 0                        -- (We don't do anything for this one; get lots of them.)
  303.    endif
  304.  
  305. defc a_Proof
  306.    a_common_action(arg(1), 'proof', PROOF_MENUP__MSG, HP_OPTIONS_PROOF)
  307.  
  308. defc a_Synonym
  309.    a_common_action(arg(1), 'syn', SYNONYM_MENUP__MSG, HP_OPTIONS_SYN)
  310.  
  311. defc a_togl_hilit
  312.    if arg(1) = 'S' then       -- button Selected
  313.       sayerror 0
  314.       color_file=''
  315.       ext=filetype()
  316.       if wordpos(ext, 'C H SQC CPP HPP CXX HXX JAVA') then
  317.          color_file= 'EPMKWDS.C'
  318.       elseif wordpos(ext, 'CMD BAT EXC EXEC XEDIT ERX REX REXX VRX') then
  319.          if .last then
  320.             line = upcase(textline(1))
  321.          else
  322.             line = ''
  323.          endif
  324.          if word(line,1)='EXTPROC' & pos('PERL', line) then
  325.             color_file='EPMKWDS.PL'
  326.          else
  327.             color_file='EPMKWDS.CMD'
  328.          endif
  329.       elseif ext='E' then
  330.          color_file= 'EPMKWDS.E'
  331.       elseif wordpos(ext, 'HTM HTML') then
  332.          color_file= 'EPMKWDS.HTM'
  333.       elseif wordpos(ext, 'FOR FORTRAN F90') then
  334.          color_file= 'EPMKWDS.F90'
  335.       elseif ext='IPF' then
  336.          color_file= 'EPMKWDS.IPF'
  337.       elseif ext='JAVA' then
  338.          color_file= 'EPMKWDS.JAV'
  339.       elseif (upcase(rightstr(.filename,8))='MAKEFILE' | ext='MAK') then
  340.          color_file='EPMKWDS.MAK'
  341.       elseif wordpos(ext, 'PL PRL PERL') then
  342.          color_file='EPMKWDS.PL'
  343.       elseif ext='RC' then
  344.          color_file= 'EPMKWDS.RC'
  345.       elseif ext='RXP' then
  346.          color_file= 'EPMKWDS.RXP'
  347.  compile if defined(my_SCRIPT_FILE_TYPE)
  348.       elseif wordpos(ext, 'SCR SCT SCRIPT' my_SCRIPT_FILE_TYPE) then
  349.  compile else
  350.       elseif wordpos(ext, 'SCR SCT SCRIPT') then
  351.  compile endif
  352.          color_file='EPMKWDS.SCR'
  353.  compile if defined(TEX_FILETYPES)
  354.       elseif wordpos(ext, TEX_FILETYPES) then
  355.  compile else
  356.       elseif wordpos(ext, 'TEX LATEX') then
  357.  compile endif
  358.          color_file= 'EPMKWDS.TEX'
  359.       else
  360.          findfile color_file, 'EPMKWDS.'ext, '', 'D'
  361.          if rc then
  362.             sayerror NO_HILIGHT_KNOWN__MSG
  363.             return
  364.          endif
  365.       endif
  366.       current_toggle = windowmessage(1,  getpminfo(EPMINFO_EDITFRAME),
  367.                                      5505,          -- EPM_EDIT_KW_QUERYPARSE
  368.                                      0,
  369.                                      0)
  370.       'toggle_parse' (not current_toggle) color_file
  371.    elseif arg(1) = 'I' then   -- button Initialized
  372.       display -8
  373.       sayerror a_Toggle_Hilight_PROMPT
  374.       display 8
  375.    elseif arg(1) = 'H' then   -- button Help
  376.       call winmessagebox(a_Toggle_Hilight__MSG, a_Toggle_Hilight_PROMPT, MB_OK + MB_INFORMATION + MB_MOVEABLE)
  377.    elseif arg(1) = 'E' then   -- button End
  378. ;;    sayerror 0
  379.    endif
  380.  
  381. defc a_print
  382.    a_common_action(arg(1), 'printdlg', ENHPRT_FILE_MENUP__MSG, HP_FILE_ENHPRINT)
  383.  
  384. defc a_save
  385.    a_common_action(arg(1), 'save', SAVE_MENUP__MSG, HP_FILE_SAVE)
  386.  
  387. defc a_searchdlg
  388.    a_common_action(arg(1), 'searchdlg', SEARCH_MENUP__MSG, HP_SEARCH_SEARCH)
  389.  
  390. defc a_undodlg
  391.    a_common_action(arg(1), 'undodlg', UNDO_REDO_MENUP__MSG, HP_EDIT_UNDOREDO)
  392.  
  393. defc a_match_brackets
  394.    parse value arg(1) with action_letter parms
  395.    if action_letter = 'I' then       -- button Initialized
  396.       display -8
  397.       sayerror a_Match_Brackets_PROMPT
  398.       display 8
  399.    elseif action_letter = 'S' then   -- button Selected
  400.       sayerror 0
  401.       call passist()
  402.    elseif action_letter = 'H' then   -- button Help
  403.       call winmessagebox(Generic_toolbar_help_title, a_Match_Brackets_PROMPT a_Match_Brackets_PROMPT2, MB_OK + MB_INFORMATION + MB_MOVEABLE)
  404. ;; elseif action_letter = 'E' then   -- button End
  405. ;;    sayerror 0
  406.    endif
  407.  
  408. defproc a_common_action(arg1, command, prompt, panel)
  409.    parse value arg1 with action_letter parms
  410.    if action_letter = 'I' then       -- button Initialized
  411.       display -8
  412.       sayerror substr(prompt, 2)  -- All the prompts in ENGLISH.E start with an ASCII 1.
  413.       display 8
  414.    elseif action_letter = 'S' then   -- button Selected
  415.       sayerror 0
  416.       command parms
  417.    elseif action_letter = 'H' then   -- button Help
  418.       if panel then
  419.          'helpmenu' panel
  420.       else
  421.          call winmessagebox(Generic_toolbar_help_title, substr(prompt, 2)\n\n || EXECUTES_COMMAND\ncommand, MB_OK + MB_INFORMATION + MB_MOVEABLE)
  422.       endif
  423. ;; elseif action_letter = 'E' then   -- button End
  424. ;;    sayerror 0
  425.    endif
  426.  
  427.