home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / mlepm.zip / htmlmode.e < prev    next >
Text File  |  1995-09-19  |  8KB  |  200 lines

  1. /* htmlmode.e - this is the E part of the HTML mode package  950915 */
  2.  
  3. compile if not defined(BLACK)
  4. const
  5.    my_html_keys_is_external = 1
  6.    INCLUDING_FILE = 'HTMLMODE.E'
  7.    EXTRA_EX = 0
  8.    include 'stdconst.e'
  9. compile else
  10.    const my_html_keys_is_external = 0
  11. compile endif
  12.  
  13.    include 'english.e'
  14.  
  15. compile if my_html_keys_is_external = 1
  16.    HTML_TABS = 3
  17.    HTML_MARGINS = 1 MAXMARGIN 1
  18.    WANT_CUA_MARKING = 'SWITCH'
  19.    ASSIST_TRIGGER = 'ENTER'
  20.    ENHANCED_ENTER_KEYS = 1
  21.    ENTER_ACTION   = 'ADDATEND'
  22.    c_ENTER_ACTION = 'ADDLINE'
  23.    SYNTAX_INDENT = 3
  24. compile endif
  25.  
  26. compile if EVERSION < 5.60
  27. definit
  28.    -- popupmenu kludge
  29.    buildacceltable 'defaccel', 'html_tabify', AF_VIRTUALKEY+AF_ALT,0,9240
  30.    buildacceltable 'defaccel', 'HTML_TABIFY', AF_VIRTUALKEY+AF_ALT,0,9241
  31.    buildacceltable 'defaccel', 'html_style', AF_VIRTUALKEY+AF_ALT,0,9242
  32.    buildacceltable 'defaccel', 'html_style EM', AF_VIRTUALKEY+AF_ALT,0,9243
  33.    buildacceltable 'defaccel', 'html_style CITE', AF_VIRTUALKEY+AF_ALT,0,9244
  34.    buildacceltable 'defaccel', 'html_style STRONG', AF_VIRTUALKEY+AF_ALT,0,9245
  35.    buildacceltable 'defaccel', 'html_style CODE', AF_VIRTUALKEY+AF_ALT,0,9246
  36.    buildacceltable 'defaccel', 'html_style SAMP', AF_VIRTUALKEY+AF_ALT,0,9247
  37.    buildacceltable 'defaccel', 'html_style KBD', AF_VIRTUALKEY+AF_ALT,0,9248
  38.    buildacceltable 'defaccel', 'html_style VAR', AF_VIRTUALKEY+AF_ALT,0,9249
  39.    buildacceltable 'defaccel', 'html_style DFN', AF_VIRTUALKEY+AF_ALT,0,9250
  40.    buildacceltable 'defaccel', 'html_style Q', AF_VIRTUALKEY+AF_ALT,0,9251
  41.    buildacceltable 'defaccel', 'html_style LANG', AF_VIRTUALKEY+AF_ALT,0,9252
  42.    buildacceltable 'defaccel', 'html_style AU', AF_VIRTUALKEY+AF_ALT, 0,9253
  43.    buildacceltable 'defaccel', 'html_style PERSON', AF_VIRTUALKEY+AF_ALT,0,9254
  44.    buildacceltable 'defaccel', 'html_style ACRONYM', AF_VIRTUALKEY+AF_ALT,0,9255
  45.    buildacceltable 'defaccel', 'html_style ABBREV', AF_VIRTUALKEY+AF_ALT,0,9256
  46.    buildacceltable 'defaccel', 'html_style INS', AF_VIRTUALKEY+AF_ALT,0,9257
  47.    buildacceltable 'defaccel', 'html_style DEL', AF_VIRTUALKEY+AF_ALT,0,9258
  48.    buildacceltable 'defaccel', 'html_style B', AF_VIRTUALKEY+AF_ALT,0,9260
  49.    buildacceltable 'defaccel', 'html_style I', AF_VIRTUALKEY+AF_ALT,0,9261
  50.    buildacceltable 'defaccel', 'html_style U', AF_VIRTUALKEY+AF_ALT,0,9262
  51.    buildacceltable 'defaccel', 'html_style S', AF_VIRTUALKEY+AF_ALT,0,9263
  52.    buildacceltable 'defaccel', 'html_style TT', AF_VIRTUALKEY+AF_ALT,0,9264
  53.    buildacceltable 'defaccel', 'html_style BIG', AF_VIRTUALKEY+AF_ALT,0,9266
  54.    buildacceltable 'defaccel', 'html_style SMALL', AF_VIRTUALKEY+AF_ALT,0,9267
  55.    buildacceltable 'defaccel', 'html_style SUB', AF_VIRTUALKEY+AF_ALT,0,9268
  56.    buildacceltable 'defaccel', 'html_style SUP', AF_VIRTUALKEY+AF_ALT,0,9269
  57.  
  58. compile endif
  59.  
  60. defc html_load_hook
  61.    universal load_ext
  62.    universal load_var
  63.  
  64.    if load_ext='HTM' | load_ext='HTML' then
  65. compile if HTML_TABS <> 0
  66.       if not (load_var // 2) then  -- 1 would be on if tabs set from EA EPM.TABS
  67.          'tabs' HTML_TABS
  68.       endif
  69. compile endif
  70. compile if HTML_MARGINS <> 0
  71.       if not (load_var%2 - 2*(load_var%4)) then  -- 2 would be on if tabs set from EA EPM.MARGINS
  72.          'ma'   HTML_MARGINS
  73.       endif
  74. compile endif
  75.       'HTML_mode'
  76.    endif
  77.  
  78. defc HTML_mode
  79.    'msetfilemode HTML mode'
  80.    'msetfilelanguage HTML'
  81.  
  82. defc mpopup_HTML_menu
  83. compile if EVERSION < 5.60
  84.    mt = leftstr(marktype(),1)
  85.    if mt = 'L' then
  86.       call mpopup(102)
  87.    elseif mt = ' ' then
  88.       call mpopup(100)
  89.    elseif mt = 'C' then
  90.       call mpopup(101)
  91.    endif
  92. compile else
  93.    universal activemenu, previouslyactivemenu
  94.  compile if CHECK_FOR_LEXAM
  95.    universal LEXAM_is_available
  96.  compile endif
  97.    if previouslyactivemenu = '' then
  98.       previouslyactivemenu = activemenu
  99.    endif
  100.    menuname = 'popup1'
  101.    activemenu = menuname
  102.  
  103.    deletemenu menuname, 0, 0, 0
  104.    buildsubmenu  menuname, 80, '', '', 0 , 0
  105.    mt = leftstr(marktype(),1)
  106.    'MH_gotoposition'
  107.    ch = substr(textline(.line), .col, 1)
  108.    gray_if_space = 16384*(ch=' ')
  109.    if mt = 'L' then
  110.       buildmenuitem menuname, 80, 9240, 'Create ~table', 'HTML_TABIFY', 0, 0
  111.    elseif mt = ' ' then
  112.       buildmenuitem menuname, 80, 9241, 'Create ~table...', 'HTML_TABIFY', 0, 0
  113.       buildmenuitem menuname, 80, 9270, \0, '', 4, 0
  114.    endif
  115.    if mt = 'C' | mt = ' ' then
  116.       buildmenuitem menuname, 80, 9242, 'Styl~e',        'html_style', 17, 0
  117.       buildmenuitem menuname, 80, 9243, '~EM',           'html_style EM', 1, 0
  118.       buildmenuitem menuname, 80, 9244, '~CITE',         'html_style CITE', 1, 0
  119.       buildmenuitem menuname, 80, 9245, '~STRONG',       'html_style STRONG', 1, 0
  120.       buildmenuitem menuname, 80, 9246, 'C~ODE',         'html_style CODE', 1, 0
  121.       buildmenuitem menuname, 80, 9247, 'SA~MP',         'html_style SAMP', 1, 0
  122.       buildmenuitem menuname, 80, 9248, '~KBD',          'html_style KBD', 1, 0
  123.       buildmenuitem menuname, 80, 9249, '~VAR',          'html_style VAR', 1, 0
  124.       buildmenuitem menuname, 80, 9250, '~DFN',          'html_style DFN', 1, 0
  125.       buildmenuitem menuname, 80, 9251, '~Q',            'html_style Q', 2049, 0
  126.       buildmenuitem menuname, 80, 9252, '~LANG',         'html_style LANG', 1, 0
  127.       buildmenuitem menuname, 80, 9253, '~AU',           'html_style AU', 1, 0
  128.       buildmenuitem menuname, 80, 9254, '~PERSON',       'html_style PERSON', 1, 0
  129.       buildmenuitem menuname, 80, 9255, 'AC~RONYM',      'html_style ACRONYM', 1, 0
  130.       buildmenuitem menuname, 80, 9256, 'A~BBREV',       'html_style ABBREV', 1, 0
  131.       buildmenuitem menuname, 80, 9257, '~INS',          'html_style INS', 1, 0
  132.       buildmenuitem menuname, 80, 9258, '~DEL',          'html_style DEL', 32769, 0
  133.       buildmenuitem menuname, 80, 9259, \0,             '', 4, 0
  134.       buildmenuitem menuname, 80, 9260, '~Bold',         'html_style B', 0, 0
  135.       buildmenuitem menuname, 80, 9261, '~Italic',       'html_style I', 0, 0
  136.       buildmenuitem menuname, 80, 9262, '~Underline',    'html_style U', 0, 0
  137.       buildmenuitem menuname, 80, 9263, '~Strik through','html_style S', 0, 0
  138.       buildmenuitem menuname, 80, 9264, '~TeleType',     'html_style TT', 0, 0
  139.       buildmenuitem menuname, 80, 9265, \0,             '', 4, 0
  140.       buildmenuitem menuname, 80, 9266, 'B~ig print',    'html_style BIG', 0, 0
  141.       buildmenuitem menuname, 80, 9267, 'S~mall print',  'html_style SMALL', 0, 0
  142.       buildmenuitem menuname, 80, 9268, 'S~ubscript',    'html_style SUB', 0, 0
  143.       buildmenuitem menuname, 80, 9269, 'Su~perscript',  'html_style SUP', 0, 0
  144.    endif
  145.    showmenu menuname,1
  146. compile endif
  147.  
  148. defc html_style
  149.    parse arg cmd
  150.    if cmd='' then
  151.    else
  152.       mt = leftstr(marktype(),1)
  153.       if mt = ' ' then
  154.          keyin '<'cmd'></'cmd'>'
  155.          .col=.col-3-length(cmd)
  156.       elseif mt = 'C' then
  157.          call psave_pos(opos)
  158.          call pend_mark()
  159.          right
  160.          keyin '</'cmd'>'
  161.          call pbegin_mark()
  162.          keyin '<'cmd'>'
  163.          call prestore_pos(opos)
  164.       endif
  165.    endif
  166.  
  167. defc html_tabify
  168.    parse arg row col
  169.    if row = '' then
  170.       row = ';'
  171.    endif
  172.    if col = '' then
  173.       col = ','
  174.    endif
  175.    mt = leftstr(marktype(),1)
  176.    if mt = ' ' then
  177.       result =  entrybox('HTML - Create table','/~Create/Cancel/Help','3, 4',0,25,
  178. compile if EVERSION >= 5.60
  179.                          gethwnd(APP_HANDLE) || atoi(1) || atoi(9300) ||
  180. compile else
  181.                          atoi(1) || atoi(9300) || gethwnd(APP_HANDLE) ||
  182. compile endif
  183.                          'Rows count, columns count'\0)
  184.       if result<>'' then
  185.          parse value substr(result,2) ' z' with row ',' col .
  186.          row=strip(row); col=strip(col)
  187.          insertline '<table border>', .line
  188.          insertline '</table>', .line+1
  189.          for i = 1 to row
  190.             insertline '<tr> 'copies('<td></td> ',col)'</tr>', .line+1
  191.          endfor
  192.       endif
  193.    elseif mt = 'L' then
  194.       getmark firstl, lastl
  195.       insertline '<table border><tr><td>', firstl
  196.       insertline '</td></tr></table>', lastl+2
  197.       firstl; 'change _'row'_</td></tr><tr><td>_*M'
  198.       firstl; 'change _'col'_</td><td>_*M'
  199.    endif
  200.