home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / editor / epmtools / cstepm / custepm.e < prev    next >
Encoding:
Text File  |  1993-03-30  |  15.8 KB  |  327 lines

  1. ; This is included as a site version of MYEXTRA.E (and so part of EXTRA.EX)
  2. ; if EXTRA.EX = 1, or as a site version of MYSTUFF.E (and so part of EPM.EX)
  3. ; if EXTRA.EX = 0.
  4. ; Or, as of March 29, 1993, this can be compiled as a stand-alone module which
  5. ; is linked from one of the above.
  6.  
  7. compile if not defined(SMALL)  -- If SMALL not defined, then being separately compiled
  8.  define INCLUDING_FILE = 'CUSTEPM.E'
  9. const
  10.    tryinclude 'MYCNF.E'        -- the user's configuration customizations.
  11.  
  12.  compile if not defined(SITE_CONFIG)
  13.     const SITE_CONFIG = 'SITECNF.E'
  14.  compile endif
  15.  compile if SITE_CONFIG
  16.     tryinclude SITE_CONFIG
  17.  compile endif
  18.  
  19. const
  20.  compile if not defined(WANT_BRACKET_MATCHING)
  21.    WANT_BRACKET_MATCHING = 0
  22.  compile endif
  23.  compile if not defined(NLS_LANGUAGE)
  24.    NLS_LANGUAGE = 'ENGLISH'
  25.  compile endif
  26. include NLS_LANGUAGE'.e'
  27.  
  28. define                     -- We're being compiled standalone, so we know we must want the rest.
  29.    SKIP_REST_OF_FILE = 0
  30. compile else   -- not defined(SMALL)   else being included from MYSTUFF or MYEXTRA
  31. define                 -- so if we should link separately, then only define the stub here.
  32.    SKIP_REST_OF_FILE = LINK_CUSTEPM_SEPARATELY
  33.  
  34.  compile if LINK_CUSTEPM_SEPARATELY
  35. definit
  36.    'linkverify custepm'
  37.  compile endif
  38. compile endif  -- not defined(SMALL)
  39.  
  40. compile if not SKIP_REST_OF_FILE
  41. const  -- Text defined separately, for easier NLS translation
  42.    ACTIONS_BAR__MSG =      TILDE_CHAR'Actions '  -- See also ACTIONS_ACCEL__L in CUSTEPM.CFG
  43.      BOX_MENU__MSG =         '~Box'
  44.        BOX_1_MENU__MSG =       'Box ~1 - │'
  45.        BOX_2_MENU__MSG =       'Box ~2 - ║'
  46.        BOX_3_MENU__MSG =       'Box ~3 - |'
  47.        BOX_4_MENU__MSG =       'Box ~4 - █'
  48.        BOX_5_MENU__MSG =       'Box ~5 - ╤'
  49.        BOX_6_MENU__MSG =       'Box ~6 - ╥'
  50.        BOX_A_MENU__MSG =       'Box ~Asm'
  51.        BOX_B_MENU__MSG =       'Box ~Blanks'
  52.        BOX_C_MENU__MSG =       'Box ~C'
  53.        BOX_E_MENU__MSG =       'Box ~E'
  54.        BOX_P_MENU__MSG =       'Box ~Pascal'
  55.        BOX_R_MENU__MSG =       'Box ~Remove'
  56.        BOX_S_MENU__MSG =       'Box ~Script'
  57.      DRAW_MENU__MSG =        '~Draw'
  58.        DRAW_1_MENU__MSG =      'Draw ~1 - │'
  59.        DRAW_2_MENU__MSG =      'Draw ~2 - ║'
  60.        DRAW_3_MENU__MSG =      'Draw ~3 - |'
  61.        DRAW_4_MENU__MSG =      'Draw ~4 - █'
  62.        DRAW_5_MENU__MSG =      'Draw ~5 - ╤'
  63.        DRAW_6_MENU__MSG =      'Draw ~6 - ╥'
  64.        DRAW_B_MENU__MSG =      'Draw ~Blanks'
  65.      HOST_SCREEN_MENU__MSG = '~Host screen'
  66.        SCREEN_A_MENU__MSG =    'Screen ~A'
  67.        SCREEN_B_MENU__MSG =    'Screen ~B'
  68.        SCREEN_C_MENU__MSG =    'Screen ~C'
  69.        SCREEN_D_MENU__MSG =    'Screen ~D'
  70.        SCREEN_E_MENU__MSG =    'Screen ~E'
  71.        SCREEN_F_MENU__MSG =    'Screen ~F'
  72.        SCREEN_G_MENU__MSG =    'Screen ~G'
  73.        SCREEN_H_MENU__MSG =    'Screen ~H'
  74.        SCREEN_I_MENU__MSG =    'Screen ~I'
  75.        SCREEN_J_MENU__MSG =    'Screen ~J'
  76.      SCAN_TEXT_MENU__MSG =   'Scan for ~text...'
  77.      GREP_TEXT_MENU__MSG =   'G~REP for text...'
  78.      SORT_LINES_MENU__MSG =  '~Sort lines'
  79.        SORT_ASCENDING__MSG =   'Sort ~ascending'
  80.        SORT_DESCENDING__MSG =  'Sort ~descending'
  81. compile if EVERSION >= 5.50  -- GPI version required for code folding
  82.      FOLD_CODE_MENU__MSG =   '~Fold code'
  83.      EXPAND_CODE_MENU__MSG = '~Expand code'
  84. compile endif
  85. compile if WANT_BRACKET_MATCHING
  86.      MATCH_BRACKET_MENU__MSG='~Match bracket'
  87. compile endif
  88.      GML_TAGS_MENU__MSG =    '~GML tags'
  89.      SGML_TAGS_MENU__MSG =   'SGM~L tags'
  90.      LATEX_CMDS_MENU__MSG =  '~LaTeX commands'
  91.      PRINTER_CODES_MENU__MSG='~Printer codes'
  92.  
  93. compile if WANT_DYNAMIC_PROMPTS
  94.    ACTIONS_BARP__MSG =      \1'Additional actions that can be taken with text regions'
  95.      BOX_MENUP__MSG =         \1'Draw box around marked block'
  96.        BOX_x_MENUP__MSG =       \1'Draw a box using line style shown'
  97.        BOX_A_MENUP__MSG =       \1'Draw a box using Assembler comments'
  98.        BOX_B_MENUP__MSG =       \1'Draw a box using blanks'
  99.        BOX_C_MENUP__MSG =       \1'Draw a box using C comments'
  100.        BOX_E_MENUP__MSG =       \1'Draw a box using E comments'
  101.        BOX_P_MENUP__MSG =       \1'Draw a box using Pascal comments'
  102.        BOX_R_MENUP__MSG =       \1'Reflow the text in the block'
  103.        BOX_S_MENUP__MSG =       \1'Draw a box using Script comments'
  104.      DRAW_MENUP__MSG =        \1'Draw lines; press Esc to stop'
  105.        DRAW_x_MENUP__MSG =      \1'Draw lines using line style shown'
  106.        DRAW_B_MENUP__MSG =      \1'Draw lines using blanks'
  107.      HOST_SCREEN_MENUP__MSG = \1'Capture the host screen'
  108.        SCREEN_A_MENUP__MSG =    \1'Capture host screen - session A'
  109.        SCREEN_B_MENUP__MSG =    \1'Capture host screen - session B'
  110.        SCREEN_C_MENUP__MSG =    \1'Capture host screen - session C'
  111.        SCREEN_D_MENUP__MSG =    \1'Capture host screen - session D'
  112.        SCREEN_E_MENUP__MSG =    \1'Capture host screen - session E'
  113.        SCREEN_F_MENUP__MSG =    \1'Capture host screen - session F'
  114.        SCREEN_G_MENUP__MSG =    \1'Capture host screen - session G'
  115.        SCREEN_H_MENUP__MSG =    \1'Capture host screen - session H'
  116.        SCREEN_I_MENUP__MSG =    \1'Capture host screen - session I'
  117.        SCREEN_J_MENUP__MSG =    \1'Capture host screen - session J'
  118.      SCAN_TEXT_MENUP__MSG =   \1'Search for text in external files'
  119.      GREP_TEXT_MENUP__MSG =   \1'Search for text in external files using GREP algorithm'
  120.      SORT_LINES_MENUP__MSG =  \1'Sort lines in ascending or descending order'
  121.        SORT_ASCENDINGP__MSG =   \1'Sort lines in ascending order'
  122.        SORT_DESCENDINGP__MSG =  \1'Sort lines in descending order'
  123.  compile if EVERSION >= 5.50  -- GPI version required for code folding
  124.      FOLD_CODE_MENUP__MSG =   \1'Place cursor on bracket & select to fold bracketed code'
  125.      EXPAND_CODE_MENUP__MSG = \1'Place cursor inside folded code & select to expand code'
  126.  compile endif
  127.  compile if WANT_BRACKET_MATCHING
  128.      MATCH_BRACKET_MENUP__MSG=\1'Place cursor on bracket & select to find match'
  129.  compile endif
  130.      GML_TAGS_MENUP__MSG =    \1'Add/remove GML Tag menu to/from the action bar'
  131.      SGML_TAGS_MENUP__MSG =   \1'Add/remove SGML Tag menu to/from the action bar'
  132.      LATEX_CMDS_MENUP__MSG =  \1'Add/remove LaTeX menu to/from the action bar'
  133.      PRINTER_CODES_MENUP__MSG=\1'Add/remove Printer Codes menu to/from the action bar'
  134. compile else
  135.    ACTIONS_BARP__MSG =      ''
  136.      BOX_MENUP__MSG =         ''
  137.        BOX_x_MENUP__MSG =       ''
  138.        BOX_A_MENUP__MSG =       ''
  139.        BOX_B_MENUP__MSG =       ''
  140.        BOX_C_MENUP__MSG =       ''
  141.        BOX_E_MENUP__MSG =       ''
  142.        BOX_P_MENUP__MSG =       ''
  143.        BOX_R_MENUP__MSG =       ''
  144.        BOX_S_MENUP__MSG =       ''
  145.      DRAW_MENUP__MSG =        ''
  146.        DRAW_x_MENUP__MSG =      ''
  147.        DRAW_B_MENUP__MSG =      ''
  148.      HOST_SCREEN_MENUP__MSG = ''
  149.        SCREEN_A_MENUP__MSG =    ''
  150.        SCREEN_B_MENUP__MSG =    ''
  151.        SCREEN_C_MENUP__MSG =    ''
  152.        SCREEN_D_MENUP__MSG =    ''
  153.        SCREEN_E_MENUP__MSG =    ''
  154.        SCREEN_F_MENUP__MSG =    ''
  155.        SCREEN_G_MENUP__MSG =    ''
  156.        SCREEN_H_MENUP__MSG =    ''
  157.        SCREEN_I_MENUP__MSG =    ''
  158.        SCREEN_J_MENUP__MSG =    ''
  159.      SCAN_TEXT_MENUP__MSG =   ''
  160.      GREP_TEXT_MENUP__MSG =   ''
  161.      SORT_LINES_MENUP__MSG =  ''
  162.        SORT_ASCENDINGP__MSG =   ''
  163.        SORT_DESCENDINGP__MSG =  ''
  164.  compile if EVERSION >= 5.50  -- GPI version required for code folding
  165.      FOLD_CODE_MENUP__MSG =   ''
  166.      EXPAND_CODE_MENUP__MSG = ''
  167.  compile endif
  168.  compile if WANT_BRACKET_MATCHING
  169.      MATCH_BRACKET_MENUP__MSG=''
  170.  compile endif
  171.      GML_TAGS_MENUP__MSG =    ''
  172.      SGML_TAGS_MENUP__MSG =   ''
  173.      LATEX_CMDS_MENUP__MSG =  ''
  174.      PRINTER_CODES_MENUP__MSG=''
  175. compile endif  -- WANT_DYNAMIC_PROMPTS
  176.  
  177.    SCAN_TITLE__MSG =  'Scan for text in files'
  178.    SCAN_PROMPT__MSG = 'Enter string (in quotes if it contains spaces) and file spec.'
  179.    OK__MSG =          '~OK'
  180.  
  181. definit
  182.    'postme add_actions_menu'  -- Make this happen *after* menus are built.
  183.  
  184. defc add_actions_menu
  185.    universal defaultmenu, activemenu
  186.    universal GML_tags_menu_flag, SGML_tags_menu_flag, printer_codes_menu_flag
  187.    deletemenu defaultmenu, 6, 0, 0  -- delete the existing Help menu (we want it to stay at the right)
  188.  
  189.    buildsubmenu defaultmenu, 37, ACTIONS_BAR__MSG, ACTIONS_BARP__MSG, 0, 0
  190.      buildmenuitem defaultmenu,   37, 3760, BOX_MENU__MSG,           BOX_MENUP__MSG, 17, 0
  191.        buildmenuitem defaultmenu, 37, 3761, BOX_1_MENU__MSG,         'box 1'BOX_x_MENUP__MSG, 0, 0
  192.        buildmenuitem defaultmenu, 37, 3762, BOX_2_MENU__MSG,         'box 2'BOX_x_MENUP__MSG, 0, 0
  193.        buildmenuitem defaultmenu, 37, 3763, BOX_3_MENU__MSG,         'box 3'BOX_x_MENUP__MSG, 0, 0
  194.        buildmenuitem defaultmenu, 37, 3764, BOX_4_MENU__MSG,         'box 4'BOX_x_MENUP__MSG, 0, 0
  195.        buildmenuitem defaultmenu, 37, 3765, BOX_5_MENU__MSG,         'box 5'BOX_x_MENUP__MSG, 0, 0
  196.        buildmenuitem defaultmenu, 37, 3766, BOX_6_MENU__MSG,         'box 6'BOX_x_MENUP__MSG, 0, 0
  197.        buildmenuitem defaultmenu, 37, 3767, BOX_A_MENU__MSG,         'box A'BOX_A_MENUP__MSG, 0, 0
  198.        buildmenuitem defaultmenu, 37, 3768, BOX_B_MENU__MSG,         'box B'BOX_B_MENUP__MSG, 0, 0
  199.        buildmenuitem defaultmenu, 37, 3769, BOX_C_MENU__MSG,         'box C'BOX_C_MENUP__MSG, 0, 0
  200.        buildmenuitem defaultmenu, 37, 3770, BOX_E_MENU__MSG,         'box E'BOX_E_MENUP__MSG, 0, 0
  201.        buildmenuitem defaultmenu, 37, 3771, BOX_P_MENU__MSG,         'box P'BOX_P_MENUP__MSG, 0, 0
  202.        buildmenuitem defaultmenu, 37, 3772, BOX_R_MENU__MSG,         'box R'BOX_R_MENUP__MSG, 0, 0
  203.        buildmenuitem defaultmenu, 37, 3773, BOX_S_MENU__MSG,         'box S'BOX_S_MENUP__MSG, 32769, 0
  204.      buildmenuitem defaultmenu,   37, 3780, DRAW_MENU__MSG,          DRAW_MENUP__MSG, 17, 0
  205.        buildmenuitem defaultmenu, 37, 3781, DRAW_1_MENU__MSG,        'draw 1'DRAW_x_MENUP__MSG, 0, 0
  206.        buildmenuitem defaultmenu, 37, 3782, DRAW_2_MENU__MSG,        'draw 2'DRAW_x_MENUP__MSG, 0, 0
  207.        buildmenuitem defaultmenu, 37, 3783, DRAW_3_MENU__MSG,        'draw 3'DRAW_x_MENUP__MSG, 0, 0
  208.        buildmenuitem defaultmenu, 37, 3784, DRAW_4_MENU__MSG,        'draw 4'DRAW_x_MENUP__MSG, 0, 0
  209.        buildmenuitem defaultmenu, 37, 3785, DRAW_5_MENU__MSG,        'draw 5'DRAW_x_MENUP__MSG, 0, 0
  210.        buildmenuitem defaultmenu, 37, 3786, DRAW_6_MENU__MSG,        'draw 6'DRAW_x_MENUP__MSG, 0, 0
  211.        buildmenuitem defaultmenu, 37, 3787, DRAW_B_MENU__MSG,        'draw B'DRAW_B_MENUP__MSG, 32769, 0
  212.      buildmenuitem defaultmenu,   37, 3788, \0,                      '',      4, 0
  213.      buildmenuitem defaultmenu,   37, 3700, HOST_SCREEN_MENU__MSG,   HOST_SCREEN_MENUP__MSG, 17, 0
  214.        buildmenuitem defaultmenu, 37, 3701, SCREEN_A_MENU__MSG,      'gethost A'SCREEN_A_MENUP__MSG, 0, 0
  215.        buildmenuitem defaultmenu, 37, 3702, SCREEN_B_MENU__MSG,      'gethost B'SCREEN_B_MENUP__MSG, 0, 0
  216.        buildmenuitem defaultmenu, 37, 3703, SCREEN_C_MENU__MSG,      'gethost C'SCREEN_C_MENUP__MSG, 0, 0
  217.        buildmenuitem defaultmenu, 37, 3704, SCREEN_D_MENU__MSG,      'gethost D'SCREEN_D_MENUP__MSG, 0, 0
  218.        buildmenuitem defaultmenu, 37, 3705, SCREEN_E_MENU__MSG,      'gethost E'SCREEN_E_MENUP__MSG, 0, 0
  219.        buildmenuitem defaultmenu, 37, 3706, SCREEN_F_MENU__MSG,      'gethost F'SCREEN_F_MENUP__MSG, 0, 0
  220.        buildmenuitem defaultmenu, 37, 3707, SCREEN_G_MENU__MSG,      'gethost G'SCREEN_G_MENUP__MSG, 0, 0
  221.        buildmenuitem defaultmenu, 37, 3708, SCREEN_H_MENU__MSG,      'gethost H'SCREEN_H_MENUP__MSG, 0, 0
  222.        buildmenuitem defaultmenu, 37, 3709, SCREEN_I_MENU__MSG,      'gethost I'SCREEN_I_MENUP__MSG, 0, 0
  223.        buildmenuitem defaultmenu, 37, 3710, SCREEN_J_MENU__MSG,      'gethost J'SCREEN_J_MENUP__MSG, 32769, 0
  224.      buildmenuitem defaultmenu,   37, 3711, \0,                      '',      4, 0
  225.      buildmenuitem defaultmenu,   37, 3720, SCAN_TEXT_MENU__MSG,     'Scan'SCAN_TEXT_MENUP__MSG, 0, 0
  226.      buildmenuitem defaultmenu,   37, 3721, GREP_TEXT_MENU__MSG,     'GREP'GREP_TEXT_MENUP__MSG, 0, 0
  227.      buildmenuitem defaultmenu,   37, 3730, SORT_LINES_MENU__MSG,    SORT_LINES_MENUP__MSG, 17, 0
  228.        buildmenuitem defaultmenu, 37, 3731, SORT_ASCENDING__MSG,     'sort'SORT_ASCENDINGP__MSG, 0, 0
  229.        buildmenuitem defaultmenu, 37, 3732, SORT_DESCENDING__MSG,    'sort R'SORT_DESCENDINGP__MSG, 32769, 0
  230.      buildmenuitem defaultmenu,   37, 3733, \0,                      '',      4, 0
  231. compile if EVERSION >= 5.50  -- GPI version required for code folding
  232.      buildmenuitem defaultmenu,   37, 3735, FOLD_CODE_MENU__MSG,     'fold'FOLD_CODE_MENUP__MSG, 0, 0
  233.      buildmenuitem defaultmenu,   37, 3736, EXPAND_CODE_MENU__MSG,   'fold 0'EXPAND_CODE_MENUP__MSG, 0, 0
  234. compile endif
  235. compile if WANT_BRACKET_MATCHING
  236.      buildmenuitem defaultmenu,   37, 3737, MATCH_BRACKET_MENU__MSG, 'match_bracket'MATCH_BRACKET_MENUP__MSG, 0, 0
  237. compile endif
  238. compile if EVERSION >= 5.50  or WANT_BRACKET_MATCHING
  239.      buildmenuitem defaultmenu,   37, 3738, \0,                      '',      4, 0
  240. compile endif
  241.      buildmenuitem defaultmenu,   37, 3740, GML_TAGS_MENU__MSG,      'link_gmltags'GML_TAGS_MENUP__MSG, 0, 0
  242.      buildmenuitem defaultmenu,   37, 3742, SGML_TAGS_MENU__MSG,     'link_sgmltags'SGML_TAGS_MENUP__MSG, 0, 0
  243.      buildmenuitem defaultmenu,   37, 3745, LATEX_CMDS_MENU__MSG,    'link_LaTeX'LATEX_CMDS_MENUP__MSG, 0, 0
  244.      buildmenuitem defaultmenu,   37, 3750, PRINTER_CODES_MENU__MSG, 'epmprt'PRINTER_CODES_MENUP__MSG, 0, 0
  245.  
  246.    call readd_help_menu()
  247.    if printer_codes_menu_flag='' then printer_codes_menu_flag=0; endif
  248.  
  249. defc menuinit_37
  250.    universal GML_tags_menu_flag, SGML_tags_menu_flag, printer_codes_menu_flag, LaTeX_cmds_menu_flag
  251.    SetMenuAttribute( 3740, 8192, not GML_tags_menu_flag)
  252.    SetMenuAttribute( 3742, 8192, not SGML_tags_menu_flag)
  253.    SetMenuAttribute( 3745, 8192, not LaTeX_cmds_menu_flag)
  254.    SetMenuAttribute( 3750, 8192, not printer_codes_menu_flag)
  255.  
  256. compile if WANT_BRACKET_MATCHING
  257. defc match_bracket = call passist()
  258. compile endif
  259.  
  260. defc link_gmltags
  261.    universal GML_tags_menu_flag
  262.    universal defaultmenu, activemenu
  263.    if GML_tags_menu_flag then
  264.       deletemenu defaultmenu, 38, 0, 0
  265.       call maybe_show_menu()
  266.       GML_tags_menu_flag = 0
  267.       unlink 'gmltags'
  268.       return
  269.    endif
  270.    'linkverify gmltags'
  271.  
  272. defc link_sgmltags
  273.    universal SGML_tags_menu_flag
  274.    universal defaultmenu, activemenu
  275.    if SGML_tags_menu_flag then
  276.       deletemenu defaultmenu, 40, 0, 0
  277.       call maybe_show_menu()
  278.       SGML_tags_menu_flag = 0
  279.       unlink 'sgmltags'
  280.       return
  281.    endif
  282.    'linkverify sgmltags'
  283.  
  284. defc link_LaTeX
  285.    universal LaTeX_cmds_menu_flag
  286.    universal defaultmenu, activemenu
  287.    if LaTeX_cmds_menu_flag then
  288.       deletemenu defaultmenu, 39, 0, 0
  289.       call maybe_show_menu()
  290.       LaTeX_cmds_menu_flag = 0
  291.       unlink 'latexmnu'
  292.       return
  293.    endif
  294.    'linkverify latexmnu'
  295.  
  296. defc scan
  297.    call grep_common(arg(1), '/a')
  298.  
  299. defc grep =
  300.    call grep_common(arg(1))
  301.  
  302. defproc grep_common(search_arg)
  303.    if search_arg='' then
  304.       parse value entrybox(SCAN_TITLE__MSG,'/'OK__MSG'/'Cancel__MSG'/',\0,'',200,
  305.              atoi(1) || atoi(0) || gethwndc(APP_HANDLE) ||
  306.              SCAN_PROMPT__MSG) with button 2 search_arg \0
  307.       if button<>\1 then return; endif
  308.    endif
  309.    sayerror 'Scanning files...'
  310.    call redirect('grep', arg(2) '/y /q /l' search_arg)
  311.    if not .last | (.last=1 & leftstr(textline(.last), 7) = 'SEARCH:') then
  312.       'q'
  313.       sayerror 'No hits.'
  314.    endif
  315.  
  316. defproc redirect(cmd)
  317.    universal vTEMP_PATH
  318.    outfile=vTEMP_PATH || substr(cmd'_______',1,8) || '.out'
  319.    quietshell cmd arg(2) '>'outfile '2>&1'
  320.    if RC = sayerror('Insufficient memory') or
  321.       RC = sayerror('File Not found')      then stop; endif
  322.    'e /u /d' outfile
  323.    .filename='.Output from' cmd arg(2)
  324.    call erasetemp(outfile)
  325.  
  326. compile endif -- not SKIP_REST_OF_FILE
  327.