Subversion Repositories Kolibri OS

Rev

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