home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / cstepm.zip / gmltags.e < prev    next >
Text File  |  1994-07-18  |  16KB  |  336 lines

  1. compile if not defined(SMALL)  -- If SMALL not defined, then being separately compiled
  2.  define INCLUDING_FILE = 'GMLTAGS.E'
  3. const
  4.    tryinclude 'MYCNF.E'        -- the user's configuration customizations.
  5.  
  6.  compile if not defined(SITE_CONFIG)
  7.     const SITE_CONFIG = 'SITECNF.E'
  8.  compile endif
  9.  compile if SITE_CONFIG
  10.     tryinclude SITE_CONFIG
  11.  compile endif
  12.  
  13.  compile if EVERSION >= 6
  14.    EA_comment "CUSTEPM's GML tags menu & support code."
  15.  compile endif
  16. compile endif
  17.  
  18. const
  19. compile if not defined(COMPANY_NAME)
  20. ;  COMPANY_NAME = 'IBM '    -- Include a trailing blank if a company name is given.
  21.    COMPANY_NAME = ''    
  22. compile endif
  23. compile if not defined(WANT_DYNAMIC_PROMPTS)
  24.    WANT_DYNAMIC_PROMPTS = 1
  25. compile endif
  26. compile if EVERSION < '5.21'
  27.    TILDE_CHAR = ''
  28. compile else
  29.    TILDE_CHAR = '~'
  30. compile endif
  31.    AF_CHAR        =   1   -- key style constants (from STDCONST.E)
  32.    AF_ALT         =  32
  33.  
  34. const  -- Text defined separately, for easier NLS translation
  35.    GMLTAGS_BAR__MSG =      TILDE_CHAR'GML '
  36.      PARAGRAPH_MENU__MSG = '~Paragraph'
  37.      LIST_ITEM_MENU__MSG = '~List item'
  38.      QUOTE_MENU__MSG =     '~Quote'
  39.      CENTER_MENU__MSG =    '~Center'
  40.      UNDERLINE_MENU__MSG = 'U~nderline'
  41.      OLIST_MENU__MSG =     '~Ordered list'
  42.      ULIST_MENU__MSG =     '~Unordered list'
  43.      SLIST_MENU__MSG =     '~Simple list'
  44.      DLIST_MENU__MSG =     '~Definition list'
  45.      PLIST_MENU__MSG =     'P~arameter list'
  46.      FIGURE_MENU__MSG =    '~Figure'
  47.      TABLE_MENU__MSG =     '~Table'
  48.      HEADS_MENU__MSG =     '~Heading levels'
  49.        HEAD0_MENU__MSG =   'Heading ~0'
  50.        HEAD1_MENU__MSG =   'Heading ~1'
  51.        HEAD2_MENU__MSG =   'Heading ~2'
  52.        HEAD3_MENU__MSG =   'Heading ~3'
  53.        HEAD4_MENU__MSG =   'Heading ~4'
  54.        HEAD5_MENU__MSG =   'Heading ~5'
  55.        HEAD6_MENU__MSG =   'Heading ~6'
  56.      HP_MENU__MSG =        'H~ighlighted phrase'
  57.        HP0_MENU__MSG =     '~0 (Normal)'
  58.        HP1_MENU__MSG =     '~1 (Italic or Underscore)'
  59.        HP2_MENU__MSG =     '~2 (Bold)'
  60.        HP3_MENU__MSG =     '~3 (Bold Italic)'
  61.      LINKS_MENU__MSG =     'Lin~ks'
  62.        LINKHD_MENU__MSG =    '~Heading link...'
  63.        LINKFN_MENU__MSG =    '~Footnote reference...'
  64.      DOC_MENU__MSG =       'Docu~ments'
  65.        GDOC_MENU__MSG =      '~GDOC'
  66.        BUSERDOC_MENU__MSG =   'Bookmaster ~UserDOC'
  67.        IUSERDOC_MENU__MSG =   '~IPF UserDOC'
  68.  
  69. compile if WANT_DYNAMIC_PROMPTS
  70.    GMLTAGS_BARP__MSG =      \1'Create GML tags'
  71.      PARAGRAPH_MENUP__MSG = \1'Insert paragraph tag after current line'
  72.      LIST_ITEM_MENUP__MSG = \1'Insert list item tag after current line'
  73.      QUOTE_MENUP__MSG =     \1'Insert quote tags around block or char. mark, or current word'
  74.      CENTER_MENUP__MSG =    \1'Insert center tag at beginning of line'
  75.      UNDERLINE_MENUP__MSG = \1'Insert underline tag at beginning of line'
  76.      OLIST_MENUP__MSG =     \1'Create ordered list'
  77.      ULIST_MENUP__MSG =     \1'Create unordered list'
  78.      SLIST_MENUP__MSG =     \1'Create simple list'
  79.      DLIST_MENUP__MSG =     \1'Create definition list'
  80.      PLIST_MENUP__MSG =     \1'Create parameter list'
  81.      FIGURE_MENUP__MSG =    \1'Create a figure'
  82.      TABLE_MENUP__MSG =     \1'Create a table'
  83.      HEADS_MENUP__MSG =     \1'Insert heading levels at beginning of line'
  84.        HEAD0_MENUP__MSG =     \1'[New page / 5 spaces after][Capitalize][Underscore][Bold][TOC]'
  85.        HEAD1_MENUP__MSG =     \1'[New page / 3 spaces after][Capitalize][Underscore][Bold][TOC]'
  86.        HEAD2_MENUP__MSG =     \1'[3 spaces before / 2 spaces after][Capitalize][Underscore][Bold][TOC]'
  87.        HEAD3_MENUP__MSG =     \1'[3 spaces before / 2 spaces after][Underscore][Bold][TOC]'
  88.        HEAD4_MENUP__MSG =     \1'[3 spaces before / 2 spaces after][Bold][TOC]'
  89.        HEAD5_MENUP__MSG =     \1'[1 space before / Text follows on same line][Bold][no TOC]'
  90.        HEAD6_MENUP__MSG =     \1'[1 space before / Text follows on same line][Underscore][no TOC]'
  91.      HP_MENUP__MSG =        \1'Highlight phrase - block or char. mark, or current word'
  92.        HP0_MENUP__MSG =       \1'Highlight phrase 0 - Normal text'
  93.        HP1_MENUP__MSG =       \1'Highlight phrase 1 - Underscore text'
  94.        HP2_MENUP__MSG =       \1'Highlight phrase 2 - Boldface text'
  95.        HP3_MENUP__MSG =       \1'Highlight phrase 3 - Underscore and boldface text'
  96.      LINKS_MENUP__MSG =     \1'Add a link around block or char. mark, or current word'
  97.        LINKHD_MENUP__MSG =    \1'Add a link to a heading'
  98.        LINKFN_MENUP__MSG =    \1'Add a link to a footnote'
  99.      DOC_MENUP__MSG =       \1'Create a document'
  100.        GDOC_MENUP__MSG =      \1'Create a GDOC (General Document)'
  101.        BUSERDOC_MENUP__MSG =  \1'Create a Bookmaster User Document'
  102.        IUSERDOC_MENUP__MSG =  \1'Create an IPF User Document'
  103. compile else
  104.    GMLTAGS_BARP__MSG =      ''
  105.      PARAGRAPH_MENUP__MSG = ''
  106.      LIST_ITEM_MENUP__MSG = ''
  107.      QUOTE_MENUP__MSG =     ''
  108.      CENTER_MENUP__MSG =    ''
  109.      UNDERLINE_MENUP__MSG = ''
  110.      OLIST_MENUP__MSG =     ''
  111.      ULIST_MENUP__MSG =     ''
  112.      SLIST_MENUP__MSG =     ''
  113.      DLIST_MENUP__MSG =     ''
  114.      PLIST_MENUP__MSG =     ''
  115.      FIGURE_MENUP__MSG =    ''
  116.      TABLE_MENUP__MSG =     ''
  117.      HEADS_MENUP__MSG =     ''
  118.        HEAD0_MENUP__MSG =   ''
  119.        HEAD1_MENUP__MSG =   ''
  120.        HEAD2_MENUP__MSG =   ''
  121.        HEAD3_MENUP__MSG =   ''
  122.        HEAD4_MENUP__MSG =   ''
  123.        HEAD5_MENUP__MSG =   ''
  124.        HEAD6_MENUP__MSG =   ''
  125.      HP_MENUP__MSG =        ''
  126.        HP0_MENUP__MSG =     ''
  127.        HP1_MENUP__MSG =     ''
  128.        HP2_MENUP__MSG =     ''
  129.        HP3_MENUP__MSG =     ''
  130.      LINKS_MENUP__MSG =     ''
  131.        LINKHD_MENUP__MSG =  ''
  132.        LINKFN_MENUP__MSG =  ''
  133.      DOC_MENUP__MSG =        ''
  134.        GDOC_MENUP__MSG =     ''
  135.        BUSERDOC_MENUP__MSG = ''
  136.        IUSERDOC_MENUP__MSG = ''
  137. compile endif  -- WANT_DYNAMIC_PROMPTS
  138.  
  139.    LINK_TITLE__MSG =  ':Link. arguments'
  140.    LINK_PROMPT__MSG = 'Enter the heading reference id or the resource id'
  141.    OK__MSG =          '~OK'
  142.    CANCEL__MSG =      'Cancel'  -- This is also in ENGLISH.E
  143.  
  144.    SECURITY_TITLE__MSG =  'Document security'
  145.    SECURITY_PROMPT__MSG = 'Select the desired security level'
  146.    SECURITY_LEVELS__MSG = '/Unclassified/'COMPANY_NAME'Internal Use Only/'COMPANY_NAME'Confidential/'COMPANY_NAME'Confidential-Restricted/Registered 'COMPANY_NAME'Confidential'
  147.    SELECT__MSG =          '~Select'
  148.    NONE__MSG =            '~None'
  149.  
  150. definit
  151.    universal defaultmenu, activemenu
  152.    universal activeaccel
  153.    universal GML_tags_menu_flag
  154.    deletemenu defaultmenu, 6, 0, 0  -- delete the existing Help menu (we want it to stay at the right)
  155.  
  156.    buildsubmenu defaultmenu, 38, GMLTAGS_BAR__MSG, GMLTAGS_BARP__MSG, 0, 0
  157.      buildmenuitem defaultmenu,   38, 3800, PARAGRAPH_MENU__MSG,     'GML_IL :p.'PARAGRAPH_MENUP__MSG, 0, 0
  158.      buildmenuitem defaultmenu,   38, 3801, \0,                      '',      4, 0
  159.      buildmenuitem defaultmenu,   38, 3802, LIST_ITEM_MENU__MSG,     'GML_IL :li.'LIST_ITEM_MENUP__MSG, 0, 0
  160.      buildmenuitem defaultmenu,   38, 3803, QUOTE_MENU__MSG,         'GML_quote'QUOTE_MENUP__MSG, 0, 0
  161.      buildmenuitem defaultmenu,   38, 3804, CENTER_MENU__MSG,        'GML_pref .ce 'CENTER_MENUP__MSG, 0, 0
  162.      buildmenuitem defaultmenu,   38, 3805, UNDERLINE_MENU__MSG,     'GML_pref .us 'UNDERLINE_MENUP__MSG, 0, 0
  163.      buildmenuitem defaultmenu,   38, 3806, \0,                      '',      4, 0
  164.      buildmenuitem defaultmenu,   38, 3810, OLIST_MENU__MSG,         'GML_IML /:ol./:li./:li./:eol.'OLIST_MENUP__MSG, 0, 0
  165.      buildmenuitem defaultmenu,   38, 3811, ULIST_MENU__MSG,         'GML_IML /:ul./:li./:li./:eul.'ULIST_MENUP__MSG, 0, 0
  166.      buildmenuitem defaultmenu,   38, 3812, SLIST_MENU__MSG,         'GML_IML /:sl./:li./:li./:esl.'SLIST_MENUP__MSG, 0, 0
  167.      buildmenuitem defaultmenu,   38, 3813, DLIST_MENU__MSG,         'GML_IML /:dl./:dt./:dd./:edl.'DLIST_MENUP__MSG, 0, 0
  168.      buildmenuitem defaultmenu,   38, 3814, PLIST_MENU__MSG,         'GML_IML /:parml./:pt./:pd./:eparml.'PLIST_MENUP__MSG, 0, 0
  169.      buildmenuitem defaultmenu,   38, 3815, \0,                      '',      4, 0
  170.      buildmenuitem defaultmenu,   38, 3816, FIGURE_MENU__MSG,        'GML_IML /:fig./:figcap./:figdesc.//:efig.'FIGURE_MENUP__MSG, 0, 0
  171.      buildmenuitem defaultmenu,   38, 3817, TABLE_MENU__MSG,         'GML_IML /:table./:tcap./:tdesc./:etdesc./:etable.'TABLE_MENUP__MSG, 0, 0
  172.      buildmenuitem defaultmenu,   38, 3819, \0,                      '',      4, 0
  173.      buildmenuitem defaultmenu,   38, 3820, HEADS_MENU__MSG,         HEADS_MENUP__MSG, 17, 0
  174.        buildmenuitem defaultmenu, 38, 3821, HEAD0_MENU__MSG,         'GML_pref :h0.'HEAD0_MENUP__MSG, 0, 0
  175.        buildmenuitem defaultmenu, 38, 3822, HEAD1_MENU__MSG,         'GML_pref :h1.'HEAD1_MENUP__MSG, 0, 0
  176.        buildmenuitem defaultmenu, 38, 3823, HEAD2_MENU__MSG,         'GML_pref :h2.'HEAD2_MENUP__MSG, 0, 0
  177.        buildmenuitem defaultmenu, 38, 3824, HEAD3_MENU__MSG,         'GML_pref :h3.'HEAD3_MENUP__MSG, 0, 0
  178.        buildmenuitem defaultmenu, 38, 3825, HEAD4_MENU__MSG,         'GML_pref :h4.'HEAD4_MENUP__MSG, 0, 0
  179.        buildmenuitem defaultmenu, 38, 3826, HEAD5_MENU__MSG,         'GML_pref :h5.'HEAD5_MENUP__MSG, 0, 0
  180.        buildmenuitem defaultmenu, 38, 3827, HEAD6_MENU__MSG,         'GML_pref :h6.'HEAD6_MENUP__MSG, 32769, 0
  181.      buildmenuitem defaultmenu,   38, 3830, HP_MENU__MSG,            HP_MENUP__MSG, 17, 0
  182.        buildmenuitem defaultmenu, 38, 3831, HP0_MENU__MSG,           'GML_hp 0'HP0_MENUP__MSG, 0, 0
  183.        buildmenuitem defaultmenu, 38, 3832, HP1_MENU__MSG,           'GML_hp 1'HP1_MENUP__MSG, 0, 0
  184.        buildmenuitem defaultmenu, 38, 3833, HP2_MENU__MSG,           'GML_hp 2'HP2_MENUP__MSG, 0, 0
  185.        buildmenuitem defaultmenu, 38, 3834, HP3_MENU__MSG,           'GML_hp 3'HP3_MENUP__MSG, 32769, 0
  186.      buildmenuitem defaultmenu,   38, 3840, LINKS_MENU__MSG,         LINKS_MENUP__MSG, 17, 0
  187.        buildmenuitem defaultmenu, 38, 3841, LINKHD_MENU__MSG,         'GML_link hd'LINKHD_MENUP__MSG, 0, 0
  188.        buildmenuitem defaultmenu, 38, 3842, LINKFN_MENU__MSG,         'GML_link fn'LINKFN_MENUP__MSG, 32769, 0
  189.      buildmenuitem defaultmenu,   38, 3850, DOC_MENU__MSG,           DOC_MENUP__MSG, 17, 0
  190.        buildmenuitem defaultmenu, 38, 3851, GDOC_MENU__MSG,          'GML_GDOC'GDOC_MENUP__MSG, 0, 0
  191.        buildmenuitem defaultmenu, 38, 3852, BUSERDOC_MENU__MSG,      'GML_USERDOC'BUSERDOC_MENUP__MSG, 0, 0
  192.        buildmenuitem defaultmenu, 38, 3853, IUSERDOC_MENU__MSG,      'GML_IML /:userdoc./:docprof toc=123./:h1./:euserdoc.'IUSERDOC_MENUP__MSG, 32769, 0
  193.  
  194.    call readd_help_menu()
  195.    GML_tags_menu_flag = 1
  196.  
  197.    buildacceltable activeaccel, 'dokey a+G', AF_CHAR+AF_ALT,    71, 3898  -- a+G
  198.    buildacceltable activeaccel, 'dokey a+G', AF_CHAR+AF_ALT,   103, 3899  -- a+g
  199.    activateacceltable  activeaccel
  200.  
  201. defc GML_IL = -- InsertLine
  202.    insertline arg(1), .line+1
  203.    '+1'
  204.    end_line
  205.  
  206. defc GML_pref = -- Prefix line with arg
  207.    replaceline arg(1) || textline(.line), .line
  208.    .col = length(arg(1))+1
  209.  
  210. defc GML_IML = -- Insert Many Lines
  211.    parse value strip(arg(1),'L') with delim 2 rest
  212.    nextline = .line+1
  213.    do while rest <> ''
  214.       parse value rest with line (delim) rest
  215.       insertline line, nextline
  216.       nextline = nextline + 1
  217.    enddo
  218.    '+2'
  219.    end_line
  220.  
  221. defc GML_quote
  222.    call GML_insert_tags(':q.', ':eq.')
  223.  
  224. defc GML_hp
  225.    level = arg(1)
  226.    call GML_insert_tags(':hp'level'.', ':ehp'level'.')
  227.  
  228. defc hdlink =
  229.    parse arg refid reftype .
  230.    if refid='' then sayerror 'Missing refid.'; return; endif
  231.    if isnum(refid) then
  232.       refres = 'res'
  233.    else
  234.       refres = 'refid'
  235.    endif
  236.    if reftype='' then reftype='hd'; endif
  237.    call GML_insert_tags(':link' refres'='refid 'reftype='reftype'.', ':elink.')
  238.  
  239. defc GML_link =
  240.    parse arg reftype .
  241.    parse value entrybox(LINK_TITLE__MSG,'/'OK__MSG'/'Cancel__MSG'/',\0,'',200,
  242.           atoi(1) || atoi(0) || gethwndc(APP_HANDLE) ||
  243.           LINK_PROMPT__MSG) with button 2 refid \0
  244.    if button<>\1 then return; endif
  245.    if isnum(refid) then
  246.       refres = 'res'
  247.    else
  248.       refres = 'refid'
  249.    endif
  250.    if reftype='' then reftype='hd'; endif
  251.    call GML_insert_tags(':link' refres'='refid 'reftype='reftype'.', ':elink.')
  252.  
  253. defproc GML_insert_tags(start_tag, end_tag)
  254.    call psave_pos(savepos)
  255.    mt = marktype()
  256.    if pos(leftstr(mt,1), 'BC') then  -- Block or Character mark
  257.       getfileid fid
  258.       getmark firstline,lastline,firstcol,lastcol,fileid
  259.       if fid<>fileid then
  260.          sayerror 'Wrong file - check mark'
  261.          return
  262.       endif
  263.    else
  264.       firstline = .line; lastline = .line;
  265.       call pend_word(); lastcol = .col
  266.       call pbegin_word(); firstcol = .col
  267.    endif
  268.    .col=lastcol+1
  269.    lastline
  270.    i_s = insert_state()
  271.    if not i_s then insert_toggle; endif
  272.    keyin end_tag
  273.    firstline
  274.    .col=firstcol
  275.    keyin start_tag
  276.    if pos(leftstr(mt,1), 'BC') then  -- Block or Character mark
  277.       l = length(start_tag)
  278.       call pset_mark(firstline, lastline, firstcol+l, lastcol+(l*(lastline=firstline)), mt, fileid)
  279.    endif
  280.    if not i_s then insert_toggle; endif
  281.    call prestore_pos(savepos)
  282. ;  if word(savepos, 1) = firstline & word(savepos, 2) >= firstcol then
  283. ;     .col = .col + length(start_tag)
  284. ;  endif
  285.  
  286. defc GML_GDOC
  287.    if not GML_security(security) then
  288.       return
  289.    endif
  290.    if security<>'' then
  291.       security = " sec='"security"'"
  292.    endif
  293.    start_line = .line
  294.    'GML_IML /:gdoc'security'./:frontm./:titlep./:title./:docnum./:date./:author./:address./:aline./:eaddress./:etitlep.' ||
  295.            '/:abstract./:preface./:toc./:figlist./:tlist./:body./:appendix./:backm./:index./:egdoc.'
  296.    start_line+4; end_line
  297.  
  298. defc GML_USERDOC
  299.    if not GML_security(security) then
  300.       return
  301.    endif
  302.    if security<>'' then
  303.       security = " sec='"security"'"
  304.    endif
  305.    start_line = .line
  306.    start_size = .last
  307.    "GML_IML /:userdoc"security"./:prolog./:docprof style=./:title stitle='[short title]'./:library./[First line of library part of title]/[Next line of library part of title]/:topic./[First line of topic part of title]/[Next line of topic part of title]"
  308.    start_line + .last - start_size
  309.    "GML_IML /:release.[Release identification]/:etitle./:pgmnum.[Program number]/:author.[Writer's name]/:address./[First line of address]/[And as many more as you need]/:address.&rbl./:address.Filename: &$fnam/:eaddress./:date.[Specific date or blank]"
  310.    start_line + .last - start_size
  311.    "GML_IML /:docnum.[Document number]/:filenum.[File number]/:bindnum.[Binder number]/:vendor.Company name/:prtloc.Printing location (other than USA)/:eprolog."
  312.    start_line + .last - start_size
  313.    "GML_IML /:frontm./:tipage./:snotice.//:esnotice./:synopsis.//:esynopsis./:notices./:nitem subject='[subject of notice]'./:enotices./:vnotice./:vnhd.[Edition notice heading]//:evnotice."
  314.    start_line + .last - start_size
  315.    "GML_IML /:preface./:toc./:figlist./:tlist./:body./:appendix./:backm./:glossary./:index./:euserdoc."
  316.    start_line+3; end_line
  317.  
  318. defproc GML_security(var security)
  319.    parse value listbox(SECURITY_TITLE__MSG, SECURITY_LEVELS__MSG,
  320.                        '/'SELECT__MSG'/'NONE__MSG'/'Cancel__MSG,1,5,5,0,
  321. compile if EVERSION >= 5.60
  322.                        atol(0) || atoi(1) || atoi(1) || atoi(0) || SECURITY_PROMPT__MSG) with button 2 security \0
  323. compile else
  324.                        atoi(1) || atoi(1) || atoi(0) || atol(0) || SECURITY_PROMPT__MSG) with button 2 security \0
  325. compile endif
  326.    if button=\2 then  -- None
  327.       security = ''
  328.    elseif button<>\1 then  -- Other than Select or None means Cancel or Close
  329.       return 0
  330.    endif
  331.    return 1
  332.  
  333. compile if EVERSION >= 6
  334.    EA_comment "CUSTEPM's GML tags menu & support code."
  335. compile endif
  336.