Subversion Repositories Kolibri OS

Rev

Rev 2194 | Rev 2804 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;   RTF READER FOR KOLIBRI >= 0.7.7.0
  2. ;   Written in pure assembler by Ivushkin Andrey aka Willow
  3. ;   Menu_bar and scroll_bar from box_lib provided by dunkaist
  4. ;---------------------------------------------------------------------
  5. M64 equ 64*1024
  6. N_A equ 0x412f4e
  7. RTFSIZE equ M64
  8. RTFSTACKSIZE equ M64
  9. BGIFONTSIZE equ 120*1024
  10. ESPSIZE equ M64
  11. LMARGIN equ 15
  12. CHARW equ 6
  13. CHARH equ 11
  14. WINW  equ 600
  15. WINH  equ 450
  16. WIN_COLOR equ 0x33f0f0f0;0x3f0f0f0
  17. DEFCOLOR equ 0x303030
  18. ;RENDER equ PIX
  19. ;RENDER equ BGI
  20. RENDER equ FREE
  21.  
  22. BGIFONT_PATH equ '/sys/fonts/'
  23. FONT_NAME equ 'LITT'
  24. TOP = 45
  25. MODE equ RTF
  26. INVALHEX equ 0
  27. RTF_COLORLESS equ 1
  28. RTF_ALIGNLESS equ 2
  29. RTF_NO1STLINE equ 4
  30. RTF_OPENING   equ 8
  31. RTF_HELP      equ 16
  32. RTF_VALID     equ 32
  33. RTF_BLIND     equ 64
  34. RTF_TOEOF     equ 128
  35. RTF_BOTTOM    equ 256
  36. STEPBYSTEP equ 10
  37. DEBUG_BLOCK equ 10
  38. SHOWALIGN equ 10
  39. GUTTER equ 10
  40. BENCH  equ 0;1
  41. syms equ 12
  42.  
  43. ;-------------------------------
  44.  
  45. scroll_width_size       equ     15
  46. AR_OFFSET               equ     10
  47.  
  48. ;-------------------------------
  49.  
  50.   use32              ; ¢ª«îç¨âì 32-¡¨â­ë© ०¨¬  áᥬ¡«¥à 
  51.   org    0x0         ;  ¤à¥á æ¨ï á ­ã«ï
  52.  
  53.   db     'MENUET01'  ; 8-¡ ©â­ë© ¨¤¥­â¨ä¨ª â®à MenuetOS
  54.   dd     0x01        ; ¢¥àá¨ï § £®«®¢ª  (¢á¥£¤  1)
  55.   dd     START       ;  ¤à¥á ¯¥à¢®© ª®¬ ­¤ë
  56.   dd     I_END0      ; à §¬¥à ¯à®£à ¬¬ë
  57.   dd     esp_end     ; ª®«¨ç¥á⢮ ¯ ¬ïâ¨
  58.   dd     sys_mem     ;  ¤à¥á ¢¥à設ë áâíª 
  59.   dd     fname_buf   ;  ¤à¥á ¡ãä¥à  ¤«ï ¯ à ¬¥â஢ (­¥ ¨á¯®«ì§ã¥âáï)
  60.   dd     cur_dir_path         ; § à¥§¥à¢¨à®¢ ­®
  61.  
  62. include '../../../config.inc'           ;for nightbuild
  63. include '../../../macros.inc' ; ¬ ªà®áë ®¡«¥£ç îâ ¦¨§­ì  áᥬ¡«¥à騪®¢!
  64. include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
  65. include '../../../develop/libraries/box_lib/load_lib.mac'
  66.  
  67. ;include 'MACROS.INC'
  68. ;include 'load_lib.mac'
  69.  
  70. @use_library
  71.  
  72. ;include '../../debug.inc'
  73.  
  74. if ~ RENDER eq PIX
  75.   TOP=TOP+4
  76.   include 'bgifont.inc'
  77. end if
  78. include 'rtf_lite.inc'
  79. ;include 'ascl.inc'
  80. ;---------------------------------------------------------------------
  81. ;---  €—€‹Ž Žƒ€ŒŒ›  ----------------------------------------------
  82. ;---------------------------------------------------------------------
  83. help_file:
  84.     file  'reader.rtf'
  85. help_end:
  86.  
  87. START:
  88.         mcall 68, 11
  89.         mcall 40, 0x27
  90.  
  91. load_libraries l_libs_start,end_l_libs
  92.  
  93. ;OpenDialog     initialisation
  94.         push    dword OpenDialog_data
  95.         call    [OpenDialog_Init]
  96.  
  97.     mov  [pitch],2
  98.   if ~ RENDER eq PIX
  99.     mov  edx,FONT_NAME
  100.     mov  edi,save_limit
  101.     BGIfont_Prepare
  102.   end if
  103.  start2:
  104.     cmp  byte[fname_buf],0
  105.     je   load_file;top_red
  106.     jmp  noactivate
  107.  prep_load:
  108.     mov  [is_scroll_bar_needed],    0
  109. ;    mcall 18,3,dword[prcinfo+30]
  110.  noactivate:
  111. ;    and  ebp,not RTF_OPENING
  112. ;    and  ebp,not RTF_HELP
  113.  
  114. ;    and  [mode],not RTF_OPENING
  115.     and  [mode],not (RTF_HELP+RTF_OPENING)
  116.     mov  ecx,16
  117.     mov  edi,fileinfo.name
  118.     mov  esi,fname_buf
  119.     rep  movsd
  120.  load_file:
  121.         mov     eax, 70
  122.         and     [fileattr+32], 0
  123.         mov     ebx, attrinfo
  124.         mcall
  125.         mov     ebx, [fileattr+32]
  126.         test    eax, eax
  127.         jz      .sizok
  128.         mov     dword [fileinfo.name], N_A
  129. .sizok:
  130.     and  [wSave],0
  131. ;    mov  [HClick],-100
  132.     mov  eax,ebx
  133.     and  eax,RTFSIZE-1
  134.     add  eax,I_END
  135.     mov  [tail],eax
  136.     shr  ebx,16
  137. ;    dpd ebx
  138.     mov  [max_block],ebx
  139.     xor  eax,eax
  140.     mov  ecx,256
  141.     mov  edi,fileinfo.name
  142.     repne scasb
  143.     sub  edi,fileinfo.name+1
  144.     mov  [fname_size],edi
  145. top_red:
  146.     mov  [top],TOP
  147.     mov  [scroll_bar_data_vertical.position],0
  148. red:                    ; ¯¥à¥à¨á®¢ âì ®ª­®
  149.     call draw_window    ; ¢ë§ë¢ ¥¬ ¯à®æ¥¤ãàã ®âà¨á®¢ª¨ ®ª­ 
  150.  
  151. ;---------------------------------------------------------------------
  152. ;---  –ˆŠ‹ Ž€Ž’Šˆ ‘Ž›’ˆ‰  ----------------------------------------
  153. ;---------------------------------------------------------------------
  154.  
  155. still:
  156.     mcall 10            ; äã­ªæ¨ï 10 - ¦¤ âì ᮡëâ¨ï
  157.  
  158.     cmp  eax,1          ; ¯¥à¥à¨á®¢ âì ®ª­® ?
  159.     je   red            ; ¥á«¨ ¤  - ­  ¬¥âªã red
  160.     cmp  eax,3          ; ­ ¦ â  ª­®¯ª  ?
  161.     je   button         ; ¥á«¨ ¤  - ­  button
  162.     cmp  eax,6
  163.     je   mouse
  164.  
  165. ;---------------------------------------------------------------------
  166.  
  167.  
  168. key:                  ; ­ ¦ â  ª« ¢¨è  ­  ª« ¢¨ âãà¥
  169.     mcall 2           ; äã­ªæ¨ï 2 - áç¨â âì ª®¤ ᨬ¢®«  (¢ ah)
  170.         ;Leency[
  171.         cmp eax,1
  172.         jne .getkeyi
  173.         mov ah,dh
  174.         jmp .next
  175.  
  176. .getkeyi:
  177.         mov dh,ah
  178.         jmp key
  179.  
  180. .next:  ;]Leency
  181.     cmp  ah,104         ; HELP
  182.     jne  .nohelp
  183.   .help:
  184.     mov  [is_scroll_bar_needed],    0
  185.     xor  [mode],RTF_HELP
  186.     test [mode],RTF_HELP
  187.     jz   load_file
  188.     mov  dword[HDoc],200                        ; it makes the help page not scroll
  189.     mov  ecx,help_end-help_file
  190.     mov  [block_end],ecx
  191.     add  [block_end],I_END
  192.     mov  [tail],ecx
  193.     add  [tail],I_END
  194.     mov  esi,help_file
  195.     mov  edi,I_END
  196.     rep  movsb
  197. ;    or   [mode],RTF_HELP
  198.     xor  eax,eax
  199.     mov  [max_block],eax
  200.     jmp  top_red
  201.   .nohelp:
  202. ;    test [mode],RTF_HELP
  203. ;    jz   .nohelp2
  204. ;    and  [mode],not RTF_HELP
  205. ;    cmp  dword[fileinfo.name],N_A
  206. ;    je   still
  207. ;    jmp  prep_load
  208.   .nohelp2:
  209.     cmp  ah,114         ; R - redraw
  210.     je   red
  211.     cmp  ah,99          ; C - color
  212.     jne  .nocolor
  213.   .color:
  214.     xor  [mode],RTF_COLORLESS
  215.     jmp  red
  216.   .nocolor:
  217.     cmp  ah,97          ; A - alignment
  218.     jne  .noalign
  219.   .alignment:
  220.     xor  [mode],RTF_ALIGNLESS
  221.     jmp  red
  222.   .noalign:
  223.     cmp  ah,44          ; < - pitch dec
  224.     jne  .nopd
  225.   .decp:
  226.     dec  [pitch]
  227.     jmp  red
  228.   .nopd:
  229.     cmp  ah,46          ; < - pitch inc
  230.     jne  .nopi
  231.   .incp:
  232.     inc  [pitch]
  233.     jmp  red
  234.   .nopi:
  235.     cmp  ah,180         ; Home
  236.     je   top_red
  237.    
  238.     cmp  dword[is_scroll_bar_needed], 0
  239.      je  still
  240.    
  241.     mov  ebx,dword[prcinfo+46]
  242.     sub  ebx,TOP+15
  243.     cmp  ah,183 ;PgDn
  244.     jne  .nopgdn
  245. ;    sub  [top],bx
  246.  
  247.     cmp  dword[is_scroll_bar_needed], 0
  248.      je  still
  249.    
  250.     mov  eax, [scroll_bar_data_vertical.position]
  251.     add  eax, AR_OFFSET*7
  252.     mov  ebx, [scroll_bar_data_vertical.max_area]
  253.     sub  ebx, [scroll_bar_data_vertical.cur_area]
  254.     cmp  eax, ebx
  255.     mov  dword[scroll_bar_data_vertical.position], eax
  256.     jl  @f
  257.     mov  dword[scroll_bar_data_vertical.position], ebx
  258.   @@:
  259.     call Set_position
  260.     jmp  red
  261.   .nopgdn:
  262.     cmp  ah,177 ;arrDn
  263.     jne  .noardn
  264. ;    sub  [top],CHARH
  265.  
  266.     cmp  dword[is_scroll_bar_needed], 0
  267.      je  still
  268.    
  269.     mov  eax, [scroll_bar_data_vertical.position]
  270.     add  eax, AR_OFFSET
  271.     mov  ebx, [scroll_bar_data_vertical.max_area]
  272.     sub  ebx, [scroll_bar_data_vertical.cur_area]
  273.     cmp  eax, ebx
  274.     mov  dword[scroll_bar_data_vertical.position], eax
  275.     jl  @f
  276.     mov  dword[scroll_bar_data_vertical.position], ebx
  277.   @@:
  278.     call Set_position
  279.  
  280.     jmp  red
  281.   .noardn:
  282.     mov  cx,[top]
  283.     cmp  ah,184 ;PgUp
  284.     jne  .nopgup
  285. ;    add  [top],bx
  286. ;    cmp  [top],TOP
  287. ;    jl   red
  288. ;    mov  [top],TOP
  289. ;    cmp  cx,[top]
  290. ;    je   still
  291.  
  292.     cmp  dword[is_scroll_bar_needed], 0
  293.      je  still
  294.    
  295.     cmp  dword[scroll_bar_data_vertical.position], AR_OFFSET*7
  296.     sub  dword[scroll_bar_data_vertical.position], AR_OFFSET*7
  297.     jg  @f
  298.     mov  dword[scroll_bar_data_vertical.position], 0
  299.   @@:
  300.     call Set_position
  301.     jmp  red
  302.   .nopgup:
  303.     cmp  ah,178 ;arrUp
  304.     jne  .noarup
  305. ;    add  [top],CHARH
  306.  
  307.     cmp  dword[is_scroll_bar_needed], 0
  308.      je  still
  309.    
  310.     cmp  dword[scroll_bar_data_vertical.position], AR_OFFSET
  311.     sub  dword[scroll_bar_data_vertical.position], AR_OFFSET
  312.     jg  @f
  313.     mov  dword[scroll_bar_data_vertical.position], 0
  314.   @@:
  315.     call Set_position
  316.  
  317. ;    cmp  [top],TOP
  318. ;    jl   red
  319. ;    mov  [top],TOP
  320. ;    cmp  cx,[top]
  321. ;    je   still
  322.     jmp  red
  323.   .noarup:
  324.   if  RENDER eq FREE
  325.     cmp  ah,56 ;zoom+
  326.     jne  .noplus
  327.   .zplus:
  328.     fld  [FreeFontscale]
  329.     fmul [Zoomscale]
  330.   .zoom:
  331.     fstp [FreeFontscale]
  332.     jmp  red
  333.   .noplus:
  334.     cmp  ah,54 ;zoom-
  335.     jne  .nominus
  336.   .zminus:
  337.     fld  [FreeFontscale]
  338.     fdiv [Zoomscale]
  339.     jmp  .zoom
  340.   .nominus:
  341.   end if
  342.     cmp  ah,0xB5        ; end
  343.     jne  .pre_file_open
  344.   .end:
  345.  
  346.     cmp  dword[is_scroll_bar_needed], 0
  347.      je  still
  348.    
  349.     mov  eax, [scroll_bar_data_vertical.max_area]
  350.     sub  eax, [scroll_bar_data_vertical.cur_area]
  351.     mov  dword[scroll_bar_data_vertical.position], eax
  352.     call Set_position
  353.     jmp  red
  354.   .pre_file_open:
  355.     cmp  ah,108         ; L - load
  356.     jne  still
  357.   .file_open:
  358. ;---------------------------------------------------------------------
  359. ;OpenDialog_start:
  360. ;       copy_path       open_dialog_name,path,library_path,0
  361.        
  362.         push    dword OpenDialog_data
  363.         call    [OpenDialog_Start]
  364.  
  365. ;       cmp     [OpenDialog_data.status],2 ; OpenDialog does not start
  366. ;       je      .sysxtree  ;    some kind of alternative, instead OpenDialog
  367.         cmp     [OpenDialog_data.status],1
  368.         je      prep_load
  369.         jmp     still
  370. ;---------------------------------------------------------------------  
  371. ;.sysxtree:
  372. ;    or   [mode],RTF_OPENING
  373. ;    opendialog draw_window, prep_load, st_1, fname_buf
  374. ;  st_1:
  375. ;    and  [mode],not RTF_OPENING
  376. ;    jmp  still;red
  377. ;  stilld:
  378. ;    jmp  still
  379. ;---------------------------------------------------------------------
  380.  
  381.   button:
  382.     mcall 17            ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
  383.  
  384.     cmp   ah, 1         ; ¥á«¨ ­ ¦ â  ª­®¯ª  á ­®¬¥à®¬ 1,
  385.     je    .exit
  386.     jmp still
  387.    
  388.   .exit:
  389.     mcall -1            ; ¨­ ç¥ ª®­¥æ ¯à®£à ¬¬ë
  390.    
  391.  
  392. ;---------------------------------------------------------------------
  393. ;---  MOUSE EVENT PROCESSING  ----------------------------------------
  394. ;---------------------------------------------------------------------    
  395. mouse:
  396.         mcall   37,7
  397.         test    eax,    eax
  398.         je      .menu_bar_1;.mouse
  399.         jmp     still
  400.  
  401.  
  402. .menu_bar_1:
  403.         call    .set_mouse_flag
  404. @@:
  405.         push    dword menu_data_1       ;mouse event for Menu 1
  406.         call    [menu_bar_mouse]
  407.         cmp     [menu_data_1.click],dword 1
  408.         jne     .menu_bar_2
  409.         cmp     [menu_data_1.cursor_out],dword 0
  410.         jne     .analyse_out_menu_1
  411.         jmp     .menu_bar_1
  412. .menu_bar_2:
  413.         push    dword menu_data_2
  414.         call    [menu_bar_mouse]
  415.         cmp     [menu_data_2.click],dword 1
  416.         jne     .menu_bar_3
  417.         cmp     [menu_data_2.cursor_out],dword 0
  418.         jne     .analyse_out_menu_2
  419.         jmp     .menu_bar_1
  420. .menu_bar_3:
  421.         push    dword menu_data_3
  422.         call    [menu_bar_mouse]
  423.         cmp     [menu_data_3.click],dword 1
  424.         jne     .scroll_bar
  425.         cmp     [menu_data_3.cursor_out],dword 0
  426.         jne     .analyse_out_menu_3
  427.         jmp     .menu_bar_1
  428.  
  429. .set_mouse_flag:
  430.         xor     eax,eax
  431.         inc     eax
  432.         mov     [menu_data_1.get_mouse_flag],eax
  433.         mov     [menu_data_2.get_mouse_flag],eax
  434.         mov     [menu_data_3.get_mouse_flag],eax
  435.         ret
  436.  
  437. .analyse_out_menu_1:
  438.         cmp     [menu_data_1.cursor_out],dword 1
  439.         je      key.file_open
  440.         cmp     [menu_data_1.cursor_out],dword 2
  441.         je      button.exit
  442.         jmp     red
  443.  
  444. .analyse_out_menu_2:
  445.         cmp     [menu_data_2.cursor_out],dword 1
  446.         je      key.zplus
  447.         cmp     [menu_data_2.cursor_out],dword 2
  448.         je      key.zminus
  449.         cmp     [menu_data_2.cursor_out],dword 3
  450.         je      key.incp
  451.         cmp     [menu_data_2.cursor_out],dword 4
  452.         je      key.decp
  453.         cmp     [menu_data_2.cursor_out],dword 5
  454.         je      key.alignment
  455.         cmp     [menu_data_2.cursor_out],dword 6
  456.         je      key.color
  457.         jmp     red
  458.  
  459. .analyse_out_menu_3:
  460.         cmp     [menu_data_3.cursor_out],dword 1
  461.         je      key.help
  462.         jmp     red
  463.  
  464. .scroll_bar:
  465.         cmp     dword[is_scroll_bar_needed], 0
  466.         je      still
  467. .vertical:
  468.         mov     eax,[scroll_bar_data_vertical.max_area]
  469.         cmp     eax,[scroll_bar_data_vertical.cur_area]
  470.         jbe     still
  471. ; mouse event for Vertical ScrollBar
  472.  
  473.         push    dword scroll_bar_data_vertical
  474.         call    [scrollbar_ver_mouse]
  475.  
  476.         call    Set_position
  477.        
  478.         mov     eax,scroll_bar_data_vertical.redraw
  479.         xor     ebx,ebx
  480.         cmp     [eax],ebx
  481.         je      @f
  482.         mov     [eax],ebx
  483.         jmp     red
  484. @@:
  485.         cmp     [scroll_bar_data_vertical.delta2],0
  486.         jne     still
  487. .other:
  488.         jmp     still
  489. ;---------------------------------------------------------------------
  490. ;---  Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€  ----------------------------------
  491. ;---------------------------------------------------------------------
  492.  
  493. draw_window:
  494.  
  495.     mcall 9, procinfo2, -1
  496.     test [procinfo2.wnd_state], 0x04
  497.     jz   @f
  498.     mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x80000000, window_title
  499.     ret
  500.   @@:
  501.     mov  edx, -1
  502.     mov  esi, -1
  503.    
  504.     mov  eax, [procinfo2.box.width]
  505.     cmp  eax, [window_width]
  506.      je  @f
  507.     mov  [is_scroll_bar_needed],    0
  508.     cmp  eax, 140
  509.      jnl @f
  510.     mov  eax, 140
  511.   @@:
  512.     mov  edx, eax
  513.     mov  [window_width],    eax
  514.  
  515.     mov  eax, [procinfo2.box.height]
  516.     cmp  eax, [window_height]
  517.      je  @f
  518.     mov  [is_scroll_bar_needed],    0
  519.     cmp  eax, 80
  520.      jnl @f
  521.     mov  eax, 80
  522.   @@:
  523.     mov  esi, eax
  524.     mov  [window_height],   eax
  525.  
  526.     mcall 67, -1, -1
  527.  
  528.     mcall 12, 1
  529. ;    mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x805080D0, 0x005080D0
  530. ;    mcall 4, <8,8>, 0x10DDEEFF, title, titlesize-title
  531.     mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x80000000, window_title
  532. ;---------------------------------------------
  533.     cmp  [is_scroll_bar_needed],    0
  534.      je  @f
  535.     call Set_scroll_position
  536.         xor     eax,eax
  537.         inc     eax
  538.         mov     [scroll_bar_data_vertical.all_redraw],eax
  539. ; draw for Vertical ScrollBar
  540.         push    dword scroll_bar_data_vertical
  541.         call    [scrollbar_ver_draw]
  542. ; reset all_redraw flag
  543.         xor     eax,eax
  544.         mov     [scroll_bar_data_vertical.all_redraw],eax
  545.   @@:
  546. ;---------------------------------------------
  547.     mov  esi,ecx
  548.     mcall 47,0x30000,isymImplemented,<114,8>
  549.     add  edx,36 shl 16
  550.     mcall ,,isymMax
  551.     add  edx,40 shl 16
  552.     mov  esi,0x104e00e7;0x10f27840
  553.     cmp  dword[fileinfo.name],N_A
  554.     jne  .noNA
  555.     mov  esi,0x10ff0000
  556.   .noNA:
  557. ;    mcall 4,edx,esi,fileinfo.name,[fname_size]
  558.     mov  edi,prcinfo
  559.     mcall 9,edi,-1
  560.     and  [mode],not RTF_TOEOF
  561.     mov  ebx,[edi+42]
  562.     cmp  ebx,[wSave]
  563.     je   .nochg
  564.   .chg:
  565.     mov  [wSave],ebx
  566.     or   [mode],RTF_TOEOF
  567.     and  [HDoc],0
  568.     and  [line_count],0
  569. ;    mov  [HClick],-100
  570.   .nochg:
  571.  
  572. ;---------------------------------------------
  573.     call  Set_scroll_position
  574.  
  575.     mov ebx, dword[prcinfo+0x3E]
  576.     mcall     38, , 65536*18+18, 0x8b8b89
  577.     inc ebx
  578.     mcall     13, , 65536*0+18, 0xe9e9e2
  579. ;---------------------------------------------
  580. ; draw for Menu 1
  581.         push    dword menu_data_1
  582.         call    [menu_bar_draw]
  583. ; draw for Menu 2
  584.         push    dword menu_data_2
  585.         call    [menu_bar_draw]
  586. ; draw for Menu 3
  587.         push    dword menu_data_3
  588.         call    [menu_bar_draw]        
  589. ;---------------------------------------------
  590.  
  591.     sub  dword[prcinfo+42],2*LMARGIN+scroll_width_size
  592.     sub  dword[prcinfo+46],CHARH+25
  593.    
  594.  if GUTTER eq 1
  595.     mov  ebx,LMARGIN shl 16+20
  596.     mov  ecx,20
  597.     mov  eax,4
  598.     mov  edx,arrow
  599.     mov  esi,1
  600.   .loop1:
  601.     push ecx
  602.     mcall ,,0xff0000
  603.     pop  ecx
  604.     add  ebx,50 shl 16
  605.     loop .loop1
  606.  end if
  607.  if MODE eq RTF
  608.     test [mode],RTF_OPENING
  609.     jne  .ex
  610.     and  [mode],not (RTF_BOTTOM);+RTF_TOEOF)
  611.     mov  [colorptr],colortbl
  612.     mov  eax,DEFCOLOR
  613.     mov  edi,colortbl
  614.     mov  ecx,16
  615.     rep  stosd
  616.     xor  eax,eax
  617.     mov  [cGroup],eax
  618.     mov  edi,Chp
  619.     mov  ecx,SIZE_save
  620.     rep  stosb
  621.     mov  ax,[top]
  622.     mov  word[Free+6],10
  623.     mov  word[Free+4],ax
  624.     mov  esi,I_END
  625.     call RtfParse
  626. ;    dpd  eax
  627. ;    dps  'Lines='
  628.     mov  eax,[line_count]
  629. ;    dpd  eax
  630. ;    newline
  631. ;    movzx  eax,word[Free+4]
  632. ;    dpd  eax
  633.     mov  eax,dword[prcinfo+42]
  634.     mov  edx,WIN_COLOR
  635.     call draw_progress
  636. if BENCH eq 1
  637.     mcall 26,9
  638.     sub  eax,[bench]
  639. ;    dps  <13,10,'Bench='>
  640. ;    dpd  eax
  641. end if
  642.  else
  643.     mov  [char],0
  644.     mov  ebx,10 shl 16+TOP
  645.     mov  ecx,16
  646.   .l0:
  647.     push ecx
  648.     mov  ecx,16
  649.   .l1:
  650.     push ecx
  651.   if RENDER eq BGI
  652.     mov  edx,char
  653.     mov  ecx,0x48000000
  654.     mov  esi,1
  655.     BGIfont_Outtext
  656.   else
  657.     mcall 4,,0x10000000,char,1
  658.   end if
  659.     pop  ecx
  660.     inc  [char]
  661.     add  ebx,(CHARW+3) shl 16
  662.     loop .l1
  663.     pop  ecx
  664.     add  ebx,CHARH+2
  665.     and  ebx,0x0000ffff
  666.     add  ebx,10 shl 16
  667.     loop .l0
  668.  end if
  669.  .ex:
  670. call Set_position
  671. ;---------------------------------------------
  672.     cmp  dword[is_scroll_bar_needed], 0
  673.      je  @f
  674.         xor     eax,eax
  675.         inc     eax
  676.         mov     [scroll_bar_data_vertical.all_redraw],eax
  677. ; draw for Vertical ScrollBar
  678.         push    dword scroll_bar_data_vertical
  679.         call    [scrollbar_ver_draw]
  680. ; reset all_redraw flag
  681.         xor     eax,eax
  682.         mov     [scroll_bar_data_vertical.all_redraw],eax
  683.   @@:
  684. ;---------------------------------------------
  685.     mcall 12, 2
  686.     ret
  687.  
  688. ;---------------------------------------------------------------------
  689. Set_position:
  690.     mov  eax, dword[prcinfo+46]
  691.     cmp  eax, [HDoc]
  692.     mov  dword[is_scroll_bar_needed], 0
  693.      jnl .quit
  694.     mov  dword[is_scroll_bar_needed], 1
  695.  
  696.     mov  eax, [scroll_bar_data_vertical.max_area]
  697.     mul  dword[prcinfo+46]
  698.     div  dword[HDoc]
  699.     cmp  eax, [scroll_bar_data_vertical.max_area]
  700.     mov  dword[scroll_bar_data_vertical.cur_area],eax
  701.      jng @f
  702.     mov  eax, [scroll_bar_data_vertical.max_area]
  703.     mov  dword[scroll_bar_data_vertical.cur_area], eax
  704.   @@:
  705.     mov eax, [HDoc]
  706.     cmp eax, dword[prcinfo+46]
  707.     sub eax, dword[prcinfo+46]
  708.     add eax, 20                    ; height of clear area under text when you are at the end of document
  709.      jg @f
  710.     mov eax, 0
  711.   @@:
  712.     mul [scroll_bar_data_vertical.position]
  713.     mov ebx, [scroll_bar_data_vertical.max_area]
  714.     sub ebx, [scroll_bar_data_vertical.cur_area]
  715.     div ebx
  716.    
  717.     mov dword[top], TOP
  718.     sub dword[top], eax
  719.    
  720.   .quit:
  721.     ret
  722. ;---------------------------------------------------------------------
  723. Set_scroll_position:
  724.     mcall 9, procinfo2, -1
  725.     mov eax, dword[procinfo2+0x3E]
  726.     sub eax, scroll_width_size
  727.     mov word[scroll_bar_data_vertical.start_x], ax
  728.  
  729.     mov eax, dword[procinfo2+0x42]
  730.     sub eax, 17
  731.     mov word[scroll_bar_data_vertical.size_y], ax
  732.    
  733.     ret
  734. ;---------------------------------------------------------------------
  735.  
  736. if GUTTER eq 1
  737.    arrow db 0x19
  738. end if
  739. ;---------------------------------------------------------------------
  740. ;---  „€›… Žƒ€ŒŒ›  ----------------------------------------------
  741. ;---------------------------------------------------------------------
  742.  
  743. ; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë©
  744. ;  ‚ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª)
  745.  
  746. window_title:           db      'RtfRead v1.034',0
  747. is_scroll_bar_needed    dd      0x0
  748. window_width            dd      0x0
  749. window_height           dd      0x0
  750. ;---------------------------------------------------------------------
  751. l_libs_start:
  752.  
  753. library01  l_libs system_dir_ProcLib+9, cur_dir_path, library_path, system_dir_ProcLib, \
  754. err_message_found_lib2, head_f_l, ProcLib_import, err_message_import2, head_f_i
  755.  
  756. library02  l_libs system_dir_Boxlib+9, cur_dir_path, library_path, system_dir_Boxlib, \
  757. err_message_found_lib1, head_f_l, Box_lib_import, err_message_import1, head_f_i
  758.  
  759. end_l_libs:
  760. ;---------------------------------------------------------------------
  761. system_dir_ProcLib      db '/sys/lib/proc_lib.obj',0
  762. system_dir_Boxlib       db '/sys/lib/box_lib.obj',0
  763.  
  764. head_f_i:
  765. head_f_l                db 'error',0
  766.  
  767. err_message_found_lib1  db 'box_lib.obj - Not found!',0
  768. err_message_found_lib2  db 'proc_lib.obj - Not found!',0
  769.  
  770. err_message_import1     db 'box_lib.obj - Wrong import!',0
  771. err_message_import2     db 'proc_lib.obj - Wrong import!',0
  772.  
  773. ;---------------------------------------------------------------------
  774. align 4
  775. ProcLib_import:
  776. OpenDialog_Init         dd aOpenDialog_Init
  777. OpenDialog_Start        dd aOpenDialog_Start
  778. ;OpenDialog__Version    dd aOpenDialog_Version
  779.         dd      0
  780.         dd      0
  781. aOpenDialog_Init        db 'OpenDialog_init',0
  782. aOpenDialog_Start       db 'OpenDialog_start',0
  783. ;aOpenDialog_Version    db 'Version_OpenDialog',0
  784. ;---------------------------------------------------------------------
  785. OpenDialog_data:
  786. .type                   dd 0
  787. .procinfo               dd procinfo ;+4
  788. .com_area_name          dd communication_area_name ;+8
  789. .com_area               dd 0 ;+12
  790. .opendir_pach           dd temp_dir_pach ;+16
  791. .dir_default_pach       dd communication_area_default_pach ;+20
  792. .start_path             dd open_dialog_path ;+24
  793. .draw_window            dd draw_window ;+28
  794. .status                 dd 0 ;+32
  795. .openfile_pach          dd fname_buf ;+36
  796. .filename_area          dd 0    ;+40
  797. .filter_area            dd Filter
  798. .x:
  799. .x_size                 dw 420 ;+48 ; Window X size
  800. .x_start                dw 10 ;+50 ; Window X position
  801. .y:
  802. .y_size                 dw 320 ;+52 ; Window y size
  803. .y_start                dw 10 ;+54 ; Window Y position
  804.  
  805. communication_area_name:
  806.         db 'FFFFFFFF_open_dialog',0
  807. open_dialog_path:
  808. if __nightbuild eq yes
  809.     db '/sys/MANAGERS/opendial',0
  810. else
  811.     db '/sys/File Managers/opendial',0
  812. end if
  813. communication_area_default_pach:
  814.         db '/rd/1',0
  815.  
  816. Filter:
  817. dd Filter.end - Filter
  818. .1:
  819. db 'RTF',0
  820. .end:
  821. db 0
  822. ;---------------------------------------------------------------------
  823. attrinfo:
  824.         dd      5
  825.         dd      0
  826.         dd      0
  827.         dd      0
  828.         dd      fileattr
  829.         db      0
  830.         dd      fileinfo.name
  831.  
  832. fileinfo:
  833.   dd 0
  834. .block:
  835.   dd 0
  836.   dd 0
  837. .size  dd 1
  838.   dd I_END
  839. .name:
  840.  
  841. ;  db '/HD/1/RTF/texts/index_ru.RTF',0
  842.  
  843.    rb  256-($-.name)
  844. ;---------------------------------------------------------------------
  845. ;blind db ?
  846. if RENDER eq PIX
  847. ;  rd 2
  848.   Free rd 9
  849. else
  850. if RENDER eq BGI
  851.   FreeFontscale dd 0.07
  852. else
  853.   Zoomscale dd 1.15
  854.   FreeFontscale dd 0.04
  855. end if
  856.   Free BGIfree FONT_NAME,0,0,1.0,1.0,char,1,0x44000000,0
  857. end if
  858. ;I_END0:
  859. fname_buf:
  860.         rb      1024+16
  861. fileattr rd 40/4
  862. if BENCH eq 1
  863.   bench dd ?
  864. end if
  865. tail dd ?
  866. cGroup dd ?
  867. Chp:
  868.   CHP
  869. Pap:
  870.   PAP
  871. Sep:
  872.   SEP
  873. Dop:
  874.   DOP
  875. rds db ?
  876. ris db ?
  877. cbBin dd ?
  878. lParam dd ?
  879. fSkipDestIfUnk db ?
  880. mode dd ?
  881. curheight dw ?
  882. maxheight dw ?
  883. RetroBlock dd ?
  884. RetroSave:
  885.   SAVE
  886. prcinfo rb 1024
  887. RetroPtr dd ?
  888. colorptr dd ?
  889. colortbl rd 16
  890. ct_end:
  891. fname_size dd ?
  892. max_block dd ?
  893. cur_block dd ?
  894. HDoc dd ?
  895. ;HClick dd ?
  896. top dw ?
  897. line_count dd ?
  898. par_count  dd ?
  899. char db ?
  900. pitch db ?
  901. wSave dd ?
  902. RetroXY dd ?
  903. RetroGroup dd ?
  904.  
  905. save_stack:
  906. rb RTFSTACKSIZE
  907. save_limit:
  908. rb BGIFONTSIZE
  909.  
  910. listptr dd ?
  911. szKeyword rb 31
  912. szParameter rb 21
  913. block_end dd ?
  914.  
  915. ;---------------------------------------------------------------------
  916. align   4
  917. Box_lib_import:
  918.  
  919. menu_bar_draw           dd aMenu_bar_draw
  920. menu_bar_mouse          dd aMenu_bar_mouse
  921.  
  922. scrollbar_ver_draw      dd aScrollbar_ver_draw
  923. scrollbar_ver_mouse     dd aScrollbar_ver_mouse
  924.  
  925.         dd 0
  926.         dd 0
  927.  
  928. aMenu_bar_draw          db 'menu_bar_draw',0
  929. aMenu_bar_mouse         db 'menu_bar_mouse',0
  930. ;aVersion_menu_bar       db 'version_menu_bar',0
  931.  
  932. aScrollbar_ver_draw     db 'scrollbar_v_draw',0
  933. aScrollbar_ver_mouse    db 'scrollbar_v_mouse',0
  934. ;---------------------------------------------------------------------
  935. align   4
  936. menu_data_1:
  937. .type:          dd 0    ;+0
  938. .x:
  939. .size_x         dw 40   ;+4
  940. .start_x        dw 2    ;+6
  941. .y:
  942. .size_y         dw 15   ;+8
  943. .start_y        dw 2    ;+10
  944. .text_pointer:  dd menu_text_area       ;0      ;+12
  945. .pos_pointer:   dd menu_text_area.1     ;0      ;+16
  946. .text_end       dd menu_text_area.end   ;0      ;+20
  947. .mouse_pos      dd 0    ;+24
  948. .mouse_keys     dd 0    ;+28
  949. .x1:
  950. .size_x1        dw 40   ;+32
  951. .start_x1       dw 2    ;+34
  952. .y1:
  953. .size_y1        dw 100  ;+36
  954. .start_y1       dw 18   ;+38
  955. .bckg_col       dd 0xeeeeee     ;+40
  956. .frnt_col       dd 0xff ;+44
  957. .menu_col       dd 0xffffff     ;+48
  958. .select         dd 0    ;+52
  959. .out_select     dd 0    ;+56
  960. .buf_adress     dd 0    ;+60
  961. .procinfo       dd 0    ;+64
  962. .click          dd 0    ;+68
  963. .cursor         dd 0    ;+72
  964. .cursor_old     dd 0    ;+76
  965. .interval       dd 16   ;+80
  966. .cursor_max     dd 0    ;+84
  967. .extended_key   dd 0    ;+88
  968. .menu_sel_col   dd 0x00cc00     ;+92
  969. .bckg_text_col  dd 0    ;+96
  970. .frnt_text_col  dd 0xffffff     ;+100
  971. .mouse_keys_old dd 0    ;+104
  972. .font_height    dd 8    ;+108
  973. .cursor_out     dd 0    ;+112
  974. .get_mouse_flag dd 0    ;+116
  975.  
  976. menu_text_area:
  977.         db 'File',0
  978. .1:
  979.         db 'Open',0
  980.         db 'Exit',0
  981. .end:
  982.         db 0
  983. ;---------------------------------------------------------------------
  984. align   4
  985. menu_data_2:
  986. .type:          dd 0    ;+0
  987. .x:
  988. .size_x         dw 40   ;+4
  989. .start_x        dw 43   ;+6
  990. .y:
  991. .size_y         dw 15   ;+8
  992. .start_y        dw 2    ;+10
  993. .text_pointer:  dd menu_text_area_2     ;0      ;+12
  994. .pos_pointer:   dd menu_text_area_2.1   ;0      ;+16
  995. .text_end       dd menu_text_area_2.end ;0      ;+20
  996. .mouse_pos      dd 0    ;+24
  997. .mouse_keys     dd 0    ;+28
  998. .x1:
  999. .size_x1        dw 50   ;+32
  1000. .start_x1       dw 43   ;+34
  1001. .y1:
  1002. .size_y1        dw 100  ;+36
  1003. .start_y1       dw 18   ;+38
  1004. .bckg_col       dd 0xeeeeee     ;+40
  1005. .frnt_col       dd 0xff ;+44
  1006. .menu_col       dd 0xffffff     ;+48
  1007. .select         dd 0    ;+52
  1008. .out_select     dd 0    ;+56
  1009. .buf_adress     dd 0    ;+60
  1010. .procinfo       dd 0    ;+64
  1011. .click          dd 0    ;+68
  1012. .cursor         dd 0    ;+72
  1013. .cursor_old     dd 0    ;+76
  1014. .interval       dd 16   ;+80
  1015. .cursor_max     dd 0    ;+84
  1016. .extended_key   dd 0    ;+88
  1017. .menu_sel_col   dd 0x00cc00     ;+92
  1018. .bckg_text_col  dd 0    ;       +96
  1019. .frnt_text_col  dd 0xffffff     ;+100
  1020. .mouse_keys_old dd 0    ;+104
  1021. .font_height    dd 8    ;+108
  1022. .cursor_out     dd 0    ;+112
  1023. .get_mouse_flag dd 0    ;+116
  1024.  
  1025. menu_text_area_2:
  1026.         db 'View',0
  1027. .1:
  1028.         db 'Zoom +',0
  1029.         db 'Zoom -',0
  1030.         db ' > >',0
  1031.         db ' << ',0
  1032.         db 'Align',0
  1033.         db 'Color',0
  1034. .end:
  1035.         db 0
  1036. ;---------------------------------------------------------------------
  1037. align   4
  1038. menu_data_3:
  1039. .type:          dd 0    ;+0
  1040. .x:
  1041. .size_x         dw 40   ;+4
  1042. .start_x        dw 84   ;+6
  1043. .y:
  1044. .size_y         dw 15   ;+8
  1045. .start_y        dw 2    ;+10
  1046. .text_pointer:  dd menu_text_area_3     ;0      ;+12
  1047. .pos_pointer:   dd menu_text_area_3.1   ;0      ;+16
  1048. .text_end       dd menu_text_area_3.end ;0      ;+20
  1049. .mouse_pos      dd 0    ;+24
  1050. .mouse_keys     dd 0    ;+28
  1051. .x1:
  1052. .size_x1        dw 40   ;+32
  1053. .start_x1       dw 84   ;+34
  1054. .y1:
  1055. .size_y1        dw 100  ;+36
  1056. .start_y1       dw 18   ;+38
  1057. .bckg_col       dd 0xeeeeee     ;+40
  1058. .frnt_col       dd 0xff ;+44
  1059. .menu_col       dd 0xffffff     ;+48
  1060. .select         dd 0    ;+52
  1061. .out_select     dd 0    ;+56
  1062. .buf_adress     dd 0    ;+60
  1063. .procinfo       dd 0    ;+64
  1064. .click          dd 0    ;+68
  1065. .cursor         dd 0    ;+72
  1066. .cursor_old     dd 0    ;+76
  1067. .interval       dd 16   ;+80
  1068. .cursor_max     dd 0    ;+84
  1069. .extended_key   dd 0    ;+88
  1070. .menu_sel_col   dd 0x00cc00     ;+92
  1071. .bckg_text_col  dd 0    ;       +96
  1072. .frnt_text_col  dd 0xffffff     ;+100
  1073. .mouse_keys_old dd 0    ;+104
  1074. .font_height    dd 8    ;+108
  1075. .cursor_out     dd 0    ;+112
  1076. .get_mouse_flag dd 0    ;+116
  1077.  
  1078. menu_text_area_3:
  1079.         db 'Help',0
  1080. .1:
  1081.         db 'Home',0
  1082. .end:
  1083.         db 0
  1084. ;---------------------------------------------------------------------
  1085. align   4
  1086. scroll_bar_data_vertical:
  1087. .x:
  1088. .size_x         dw scroll_width_size;+0
  1089. .start_x        dw WINW-25  ;+2
  1090. .y:
  1091. .size_y         dw WINH-45  ;+4
  1092. .start_y        dw 19   ;+6
  1093. .btn_high       dd scroll_width_size    ;+8
  1094. .type           dd 1    ;+12
  1095. .max_area       dd 300       ;+16
  1096. .cur_area       dd 50   ;+20
  1097. .position       dd 0    ;+24
  1098. .bckg_col       dd 0xAAAAAA     ;+28
  1099. .frnt_col       dd 0xCCCCCC     ;+32
  1100. .line_col       dd 0    ;+36
  1101. .redraw         dd 0    ;+40
  1102. .delta          dw 0    ;+44
  1103. .delta2         dw 0    ;+46
  1104. .run_x:
  1105. .r_size_x       dw 0    ;+48
  1106. .r_start_x      dw 0    ;+50
  1107. .run_y:
  1108. .r_size_y       dw 0    ;+52
  1109. .r_start_y      dw 0    ;+54
  1110. .m_pos          dd 0    ;+56
  1111. .m_pos_2        dd 0    ;+60
  1112. .m_keys         dd 0    ;+64
  1113. .run_size       dd 0    ;+68
  1114. .position2      dd 0    ;+72
  1115. .work_size      dd 0    ;+76
  1116. .all_redraw     dd 0    ;+80
  1117. .ar_offset      dd AR_OFFSET   ;+84
  1118. ;---------------------------------------------------------------------
  1119. I_END0:
  1120. I_END:                             ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë
  1121.  
  1122. procinfo process_information
  1123. rb RTFSIZE
  1124. esp1:
  1125. rb ESPSIZE
  1126. procinfo2 process_information
  1127. ;---------------------------------------------------------------------
  1128. temp_dir_pach:
  1129.         rb 4096
  1130. cur_dir_path:
  1131.         rb 4096
  1132. library_path:
  1133.         rb 4096
  1134. ;---------------------------------------------------------------------
  1135.     rb ESPSIZE                      ;stack
  1136. esp_end:
  1137. sys_mem:
  1138.