Subversion Repositories Kolibri OS

Rev

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