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

  1. compile if not defined(SMALL)  -- If SMALL not defined, then being separately compiled
  2.  define INCLUDING_FILE = 'SGMLTAGS.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 SGML 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.    SGMLTAGS_BAR__MSG =      TILDE_CHAR'SGML '
  36.      PARAGRAPH_MENU__MSG = '~Paragraph'
  37.      LIST_ITEM_MENU__MSG = '~List item'
  38.      QUOTE_MENU__MSG =     '~Quote'
  39.      OLIST_MENU__MSG =     '~Ordered list'
  40.      ULIST_MENU__MSG =     '~Unordered list'
  41.      SLIST_MENU__MSG =     '~Simple list'
  42.      DLIST_MENU__MSG =     '~Definition list'
  43.      FIGURE_MENU__MSG =    '~Figure'
  44.      HEADS_MENU__MSG =     '~Heading levels'
  45.        HEAD0_MENU__MSG =   'Heading ~0'
  46.        HEAD1_MENU__MSG =   'Heading ~1'
  47.        HEAD2_MENU__MSG =   'Heading ~2'
  48.        HEAD3_MENU__MSG =   'Heading ~3'
  49.        HEAD4_MENU__MSG =   'Heading ~4'
  50.        HEAD5_MENU__MSG =   'Heading ~5'
  51.      EM_MENU__MSG =        '~Emphasize phrase'
  52.      EM2_MENU__MSG =       'He~avy emphasis'
  53.      TYPES_MENU__MSG =     '~Typestyles'
  54.        TYPE_R_MENU__MSG =  '~Roman'
  55.        TYPE_I_MENU__MSG =  '~Italic'
  56.        TYPE_B_MENU__MSG =  '~Bold'
  57.        TYPE_M_MENU__MSG =  '~Monospace'
  58.        TYPE_SC_MENU__MSG = '~Small caps'
  59.        TYPE_SUB_MENU__MSG= 'S~ubscript'
  60.        TYPE_SUP_MENU__MSG= 'Su~perscript'
  61.      DOC_MENU__MSG =       'Docu~ments'
  62.        SIMDOC_MENU__MSG =      '~SIMDOC'
  63.        HTMLDOC_MENU__MSG =      '~HTML'
  64.  
  65. compile if WANT_DYNAMIC_PROMPTS
  66.    SGMLTAGS_BARP__MSG =     \1'Create SGML tags'
  67.      PARAGRAPH_MENUP__MSG = \1'Insert paragraph tag after current line'
  68.      LIST_ITEM_MENUP__MSG = \1'Insert list item tag after current line'
  69.      QUOTE_MENUP__MSG =     \1'Insert quote tags around block or char. mark, or current word'
  70.      OLIST_MENUP__MSG =     \1'Create ordered list'
  71.      ULIST_MENUP__MSG =     \1'Create unordered list'
  72.      SLIST_MENUP__MSG =     \1'Create simple list'
  73.      DLIST_MENUP__MSG =     \1'Create definition list'
  74.      FIGURE_MENUP__MSG =    \1'Create a figure'
  75.      HEADS_MENUP__MSG =     \1'Insert heading levels at beginning of current line'
  76.        HEAD0_MENUP__MSG =     \1'[New page / 5 spaces after][Capitalize][Underscore][Bold][TOC]'
  77.        HEAD1_MENUP__MSG =     \1'[New page / 3 spaces after][Capitalize][Underscore][Bold][TOC]'
  78.        HEAD2_MENUP__MSG =     \1'[3 spaces before / 2 spaces after][Capitalize][Underscore][Bold][TOC]'
  79.        HEAD3_MENUP__MSG =     \1'[3 spaces before / 2 spaces after][Underscore][Bold][TOC]'
  80.        HEAD4_MENUP__MSG =     \1'[3 spaces before / 2 spaces after][Bold][TOC]'
  81.        HEAD5_MENUP__MSG =     \1'[1 space before / Text follows on same line][Bold][no TOC]'
  82.      EM_MENUP__MSG =        \1'Emphasize a phrase - block or char. mark, or current word'
  83.      EM2_MENUP__MSG =       \1'Heavily emphasize a phrase - block or char. mark, or current word'
  84.      TYPES_MENUP__MSG =     \1'Change the typestyle of a phrase - block or char. mark, or current word'
  85.        TYPE_x_MENUP__MSG =  \1'Change block or char. mark, or current word, to indicated typestyle'
  86.      DOC_MENUP__MSG =       \1'Create a document'
  87.        SIMDOC_MENUP__MSG =      \1'Create a SIMDOC'
  88.        HTMLDOC_MENUP__MSG =     \1'Create an HTML document'
  89. compile else
  90.    SGMLTAGS_BARP__MSG =     ''
  91.      PARAGRAPH_MENUP__MSG = ''
  92.      LIST_ITEM_MENUP__MSG = ''
  93.      QUOTE_MENUP__MSG =     ''
  94.      OLIST_MENUP__MSG =     ''
  95.      ULIST_MENUP__MSG =     ''
  96.      SLIST_MENUP__MSG =     ''
  97.      DLIST_MENUP__MSG =     ''
  98.      FIGURE_MENUP__MSG =    ''
  99.      HEADS_MENUP__MSG =     ''
  100.        HEAD0_MENUP__MSG =   ''
  101.        HEAD1_MENUP__MSG =   ''
  102.        HEAD2_MENUP__MSG =   ''
  103.        HEAD3_MENUP__MSG =   ''
  104.        HEAD4_MENUP__MSG =   ''
  105.        HEAD5_MENUP__MSG =   ''
  106.      EM_MENUP__MSG =        ''
  107.      EM2_MENUP__MSG =       ''
  108.      TYPES_MENUP__MSG =     ''
  109.        TYPE_x_MENUP__MSG =  ''
  110.      DOC_MENUP__MSG =        ''
  111.        SIMDOC_MENUP__MSG =     ''
  112.        HTMLDOC_MENUP__MSG =    ''
  113. compile endif  -- WANT_DYNAMIC_PROMPTS
  114.  
  115.    CANCEL__MSG =      'Cancel'  -- This is also in ENGLISH.E
  116.  
  117.    SECURITY_TITLE__MSG =  'Document security'
  118.    SECURITY_PROMPT__MSG = 'Select the desired security level'
  119.    SECURITY_LEVELS__MSG = '/Unclassified/'COMPANY_NAME'Internal Use Only/'COMPANY_NAME'Confidential/'COMPANY_NAME'Confidential-Restricted/Registered 'COMPANY_NAME'Confidential'
  120.    SELECT__MSG =          '~Select'
  121.    NONE__MSG =            '~None'
  122.  
  123. definit
  124.    universal defaultmenu, activemenu
  125.    universal activeaccel
  126.    universal SGML_tags_menu_flag
  127.    deletemenu defaultmenu, 6, 0, 0  -- delete the existing Help menu (we want it to stay at the right)
  128.  
  129.    buildsubmenu defaultmenu, 40, SGMLTAGS_BAR__MSG, SGMLTAGS_BARP__MSG, 0, 0
  130.      buildmenuitem defaultmenu,   40, 4000, PARAGRAPH_MENU__MSG,     'SGML_IL <p>'PARAGRAPH_MENUP__MSG, 0, 0
  131.      buildmenuitem defaultmenu,   40, 4001, \0,                      '',      4, 0
  132.      buildmenuitem defaultmenu,   40, 4002, LIST_ITEM_MENU__MSG,     'SGML_IL <li>'LIST_ITEM_MENUP__MSG, 0, 0
  133.      buildmenuitem defaultmenu,   40, 4003, QUOTE_MENU__MSG,         'SGML_em q'QUOTE_MENUP__MSG, 0, 0
  134.      buildmenuitem defaultmenu,   40, 4006, \0,                      '',      4, 0
  135.      buildmenuitem defaultmenu,   40, 4010, OLIST_MENU__MSG,         'SGML_IML |<list form=disp seq=ord>|<li>|<li>|</list>'OLIST_MENUP__MSG, 0, 0
  136.      buildmenuitem defaultmenu,   40, 4011, ULIST_MENU__MSG,         'SGML_IML |<list form=disp seq=unord>|<li>|<li>|</list>'ULIST_MENUP__MSG, 0, 0
  137.      buildmenuitem defaultmenu,   40, 4012, SLIST_MENU__MSG,         'SGML_IML |<list form=bare seq=unord>|<li>|<li>|</list>'SLIST_MENUP__MSG, 0, 0
  138.      buildmenuitem defaultmenu,   40, 4013, DLIST_MENU__MSG,         'SGML_IML |<list form=def seq=unord>|<lt>|<li>|</list>'DLIST_MENUP__MSG, 0, 0
  139.      buildmenuitem defaultmenu,   40, 4015, \0,                      '',      4, 0
  140.      buildmenuitem defaultmenu,   40, 4016, FIGURE_MENU__MSG,        'SGML_IML |<fig>||<cap>|</fig>'FIGURE_MENUP__MSG, 0, 0
  141.      buildmenuitem defaultmenu,   40, 4019, \0,                      '',      4, 0
  142.      buildmenuitem defaultmenu,   40, 4020, HEADS_MENU__MSG,         HEADS_MENUP__MSG, 17, 0
  143.        buildmenuitem defaultmenu, 40, 4021, HEAD0_MENU__MSG,         'SGML_pref <h0>'HEAD0_MENUP__MSG, 0, 0
  144.        buildmenuitem defaultmenu, 40, 4022, HEAD1_MENU__MSG,         'SGML_pref <h1>'HEAD1_MENUP__MSG, 0, 0
  145.        buildmenuitem defaultmenu, 40, 4023, HEAD2_MENU__MSG,         'SGML_pref <h2>'HEAD2_MENUP__MSG, 0, 0
  146.        buildmenuitem defaultmenu, 40, 4024, HEAD3_MENU__MSG,         'SGML_pref <h3>'HEAD3_MENUP__MSG, 0, 0
  147.        buildmenuitem defaultmenu, 40, 4025, HEAD4_MENU__MSG,         'SGML_pref <h4>'HEAD4_MENUP__MSG, 0, 0
  148.        buildmenuitem defaultmenu, 40, 4026, HEAD5_MENU__MSG,         'SGML_pref <h5>'HEAD5_MENUP__MSG, 32769, 0
  149.      buildmenuitem defaultmenu,   40, 4030, EM_MENU__MSG,            'SGML_EM e'EM_MENUP__MSG, 0, 0
  150.      buildmenuitem defaultmenu,   40, 4031, EM2_MENU__MSG,           'SGML_EM h'EM_MENUP__MSG, 0, 0
  151.      buildmenuitem defaultmenu,   40, 4032, TYPES_MENU__MSG,         TYPES_MENUP__MSG, 17, 0
  152.        buildmenuitem defaultmenu, 40, 4033, TYPE_R_MENU__MSG,          'SGML_EM r'TYPE_x_MENUP__MSG, 0, 0
  153.        buildmenuitem defaultmenu, 40, 4034, TYPE_I_MENU__MSG,          'SGML_EM r'TYPE_x_MENUP__MSG, 0, 0
  154.        buildmenuitem defaultmenu, 40, 4035, TYPE_B_MENU__MSG,          'SGML_EM b'TYPE_x_MENUP__MSG, 0, 0
  155.        buildmenuitem defaultmenu, 40, 4036, TYPE_M_MENU__MSG,          'SGML_EM m'TYPE_x_MENUP__MSG, 0, 0
  156.        buildmenuitem defaultmenu, 40, 4037, TYPE_SC_MENU__MSG,         'SGML_EM sc'TYPE_x_MENUP__MSG, 0, 0
  157.        buildmenuitem defaultmenu, 40, 4038, TYPE_SUB_MENU__MSG,        'SGML_EM sub'TYPE_x_MENUP__MSG, 0, 0
  158.        buildmenuitem defaultmenu, 40, 4039, TYPE_SUP_MENU__MSG,        'SGML_EM sup'TYPE_x_MENUP__MSG, 32769, 0
  159.      buildmenuitem defaultmenu,   40, 4050, DOC_MENU__MSG,           DOC_MENUP__MSG, 17, 0
  160.        buildmenuitem defaultmenu, 40, 4051, SIMDOC_MENU__MSG,          'SGML_SIMDOC'SIMDOC_MENUP__MSG, 0, 0
  161.        buildmenuitem defaultmenu, 40, 4052, HTMLDOC_MENU__MSG,         'SGML_IML |<html>|<head>|<TITLE>|</TITLE>|</head>|<body>||</body>|</html>'HTMLDOC_MENUP__MSG, 0, 0
  162.  
  163.    call readd_help_menu()
  164.    SGML_tags_menu_flag = 1
  165.    -- Following not necessary; this duplicates the 'Search' accelerator in the English version.
  166. ;; buildacceltable activeaccel, 'dokey a+S', AF_CHAR+AF_ALT,    83, 4098  -- a+S
  167. ;; buildacceltable activeaccel, 'dokey a+S', AF_CHAR+AF_ALT,   115, 4099  -- a+s
  168. ;; activateacceltable  activeaccel
  169.  
  170. defc SGML_IL = -- InsertLine
  171.    insertline arg(1), .line+1
  172.    '+1'
  173.    end_line
  174.  
  175. defc SGML_pref = -- Prefix line with arg
  176.    replaceline arg(1) || textline(.line), .line
  177.    .col = length(arg(1))+1
  178.  
  179. defc SGML_IML = -- Insert Many Lines
  180.    parse value strip(arg(1),'L') with delim 2 rest
  181.    nextline = .line+1
  182.    do while rest <> ''
  183.       parse value rest with line (delim) rest
  184.       insertline line, nextline
  185.       nextline = nextline + 1
  186.    enddo
  187.    '+2'
  188.    end_line
  189.  
  190. defc SGML_em
  191.    level = arg(1)
  192.    call SGML_insert_tags('<'level'>', '</'level'>')
  193.  
  194. defproc SGML_insert_tags(start_tag, end_tag)
  195.    mt = marktype()
  196.    if pos(leftstr(mt,1), 'BC') then  -- Block or Character mark
  197.       getfileid fid
  198.       getmark firstline,lastline,firstcol,lastcol,fileid
  199.       if fid<>fileid then
  200.          sayerror 'Wrong file - check mark'
  201.          return
  202.       endif
  203.    else
  204.       firstline = .line; lastline = .line;
  205.       call pend_word(); lastcol = .col
  206.       call pbegin_word(); firstcol = .col
  207.    endif
  208.    .col=lastcol+1
  209.    lastline
  210.    i_s = insert_state()
  211.    if not i_s then insert_toggle; endif
  212.    keyin end_tag
  213.    firstline
  214.    .col=firstcol
  215.    keyin start_tag
  216.    if pos(leftstr(mt,1), 'BC') then  -- Block or Character mark
  217.       l = length(start_tag)
  218.       call pset_mark(firstline, lastline, firstcol+l, lastcol+(l*(lastline=firstline)), mt, fileid)
  219.    endif
  220.    if not i_s then insert_toggle; endif
  221.  
  222. defc SGML_SIMDOC
  223.    if not SGML_security(security) then
  224.       return
  225.    endif
  226.    if security<>'' then
  227.       security = " sec='"security"'"
  228.    endif
  229.    start_line = .line
  230.    start_size = .last
  231.    'SGML_IML |<simdoc'security'>|<title>|<titlem>|<date>|<abstract>|</abstract>|<author>|<address>|<line>|</address>|</titlep>' 
  232.    start_line + .last - start_size
  233.    'SGML_IML |<frontm>|<h1>Preface>|<h1>Table of Contents|<collect h>|<h1>Figure List|<collect fig>|<body>|<backm>|<app>|<h1>Index|<collect ie>|</simdoc>'
  234.    start_line+4; end_line
  235.  
  236. defproc SGML_security(var security)
  237.    parse value listbox(SECURITY_TITLE__MSG, SECURITY_LEVELS__MSG,
  238.                        '/'SELECT__MSG'/'NONE__MSG'/'Cancel__MSG,1,5,5,0,
  239. compile if EVERSION >= 5.60
  240.                        atol(0) || atoi(1) || atoi(1) || atoi(0) || SECURITY_PROMPT__MSG) with button 2 security \0
  241. compile else
  242.                        atoi(1) || atoi(1) || atoi(0) || atol(0) || SECURITY_PROMPT__MSG) with button 2 security \0
  243. compile endif
  244.    if button=\2 then  -- None
  245.       security = ''
  246.    elseif button<>\1 then  -- Other than Select or None means Cancel or Close
  247.       return 0
  248.    endif
  249.    return 1
  250.