Subversion Repositories Kolibri OS

Rev

Rev 1524 | Rev 1582 | 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, [window_width]
  489.      je  @f
  490.     mov  [is_scroll_bar_needed],    0
  491.     cmp  eax, 140
  492.      jnl @f
  493.     mov  eax, 140
  494.   @@:
  495.     mov  edx, eax
  496.     mov  [window_width],    eax
  497.  
  498.     mov  eax, [procinfo2.box.height]
  499.     cmp  eax, [window_height]
  500.      je  @f
  501.     mov  [is_scroll_bar_needed],    0
  502.     cmp  eax, 80
  503.      jnl @f
  504.     mov  eax, 80
  505.   @@:
  506.     mov  esi, eax
  507.     mov  [window_height],   eax
  508.  
  509.     mcall 67, -1, -1
  510.  
  511.     mcall 12, 1
  512. ;    mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x805080D0, 0x005080D0
  513. ;    mcall 4, <8,8>, 0x10DDEEFF, title, titlesize-title
  514.     mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x80000000, window_title
  515. ;---------------------------------------------
  516.     cmp  [is_scroll_bar_needed],    0
  517.      je  @f
  518.     call Set_scroll_position
  519.         xor     eax,eax
  520.         inc     eax
  521.         mov     [scroll_bar_data_vertical.all_redraw],eax
  522. ; draw for Vertical ScrollBar
  523.         push    dword scroll_bar_data_vertical
  524.         call    [scrollbar_ver_draw]
  525. ; reset all_redraw flag
  526.         xor     eax,eax
  527.         mov     [scroll_bar_data_vertical.all_redraw],eax
  528.   @@:
  529. ;---------------------------------------------
  530.     mov  esi,ecx
  531.     mcall 47,0x30000,isymImplemented,<114,8>
  532.     add  edx,36 shl 16
  533.     mcall ,,isymMax
  534.     add  edx,40 shl 16
  535.     mov  esi,0x104e00e7;0x10f27840
  536.     cmp  dword[fileinfo.name],N_A
  537.     jne  .noNA
  538.     mov  esi,0x10ff0000
  539.   .noNA:
  540. ;    mcall 4,edx,esi,fileinfo.name,[fname_size]
  541.     mov  edi,prcinfo
  542.     mcall 9,edi,-1
  543.     and  [mode],not RTF_TOEOF
  544.     mov  ebx,[edi+42]
  545.     cmp  ebx,[wSave]
  546.     je   .nochg
  547.   .chg:
  548.     mov  [wSave],ebx
  549.     or   [mode],RTF_TOEOF
  550.     and  [HDoc],0
  551.     and  [line_count],0
  552. ;    mov  [HClick],-100
  553.   .nochg:
  554.  
  555. ;---------------------------------------------
  556.     call  Set_scroll_position
  557.  
  558.     mov ebx, dword[prcinfo+0x3E]
  559.     mcall     38, , 65536*18+18, 0x8b8b89
  560.     inc ebx
  561.     mcall     13, , 65536*0+18, 0xe9e9e2
  562. ;---------------------------------------------
  563. ; draw for Menu 1
  564.         push    dword menu_data_1
  565.         call    [menu_bar_draw]
  566. ; draw for Menu 2
  567.         push    dword menu_data_2
  568.         call    [menu_bar_draw]
  569. ; draw for Menu 3
  570.         push    dword menu_data_3
  571.         call    [menu_bar_draw]        
  572. ;---------------------------------------------
  573.  
  574.     sub  dword[prcinfo+42],2*LMARGIN+scroll_width_size
  575.     sub  dword[prcinfo+46],CHARH+25
  576.    
  577.  if GUTTER eq 1
  578.     mov  ebx,LMARGIN shl 16+20
  579.     mov  ecx,20
  580.     mov  eax,4
  581.     mov  edx,arrow
  582.     mov  esi,1
  583.   .loop1:
  584.     push ecx
  585.     mcall ,,0xff0000
  586.     pop  ecx
  587.     add  ebx,50 shl 16
  588.     loop .loop1
  589.  end if
  590.  if MODE eq RTF
  591.     test [mode],RTF_OPENING
  592.     jne  .ex
  593.     and  [mode],not (RTF_BOTTOM);+RTF_TOEOF)
  594.     mov  [colorptr],colortbl
  595.     mov  eax,DEFCOLOR
  596.     mov  edi,colortbl
  597.     mov  ecx,16
  598.     rep  stosd
  599.     xor  eax,eax
  600.     mov  [cGroup],eax
  601.     mov  edi,Chp
  602.     mov  ecx,SIZE_save
  603.     rep  stosb
  604.     mov  ax,[top]
  605.     mov  word[Free+6],10
  606.     mov  word[Free+4],ax
  607.     mov  esi,I_END
  608.     call RtfParse
  609. ;    dpd  eax
  610. ;    dps  'Lines='
  611.     mov  eax,[line_count]
  612. ;    dpd  eax
  613. ;    newline
  614. ;    movzx  eax,word[Free+4]
  615. ;    dpd  eax
  616.     mov  eax,dword[prcinfo+42]
  617.     mov  edx,WIN_COLOR
  618.     call draw_progress
  619. if BENCH eq 1
  620.     mcall 26,9
  621.     sub  eax,[bench]
  622. ;    dps  <13,10,'Bench='>
  623. ;    dpd  eax
  624. end if
  625.  else
  626.     mov  [char],0
  627.     mov  ebx,10 shl 16+TOP
  628.     mov  ecx,16
  629.   .l0:
  630.     push ecx
  631.     mov  ecx,16
  632.   .l1:
  633.     push ecx
  634.   if RENDER eq BGI
  635.     mov  edx,char
  636.     mov  ecx,0x48000000
  637.     mov  esi,1
  638.     BGIfont_Outtext
  639.   else
  640.     mcall 4,,0x10000000,char,1
  641.   end if
  642.     pop  ecx
  643.     inc  [char]
  644.     add  ebx,(CHARW+3) shl 16
  645.     loop .l1
  646.     pop  ecx
  647.     add  ebx,CHARH+2
  648.     and  ebx,0x0000ffff
  649.     add  ebx,10 shl 16
  650.     loop .l0
  651.  end if
  652.  .ex:
  653. call Set_position
  654. ;---------------------------------------------
  655.     cmp  dword[is_scroll_bar_needed], 0
  656.      je  @f
  657.         xor     eax,eax
  658.         inc     eax
  659.         mov     [scroll_bar_data_vertical.all_redraw],eax
  660. ; draw for Vertical ScrollBar
  661.         push    dword scroll_bar_data_vertical
  662.         call    [scrollbar_ver_draw]
  663. ; reset all_redraw flag
  664.         xor     eax,eax
  665.         mov     [scroll_bar_data_vertical.all_redraw],eax
  666.   @@:
  667. ;---------------------------------------------
  668.     mcall 12, 2
  669.     ret
  670.  
  671. ;---------------------------------------------------------------------
  672. Set_position:
  673.     mov  eax, dword[prcinfo+46]
  674.     cmp  eax, [HDoc]
  675.     mov  dword[is_scroll_bar_needed], 0
  676.      jnl .quit
  677.     mov  dword[is_scroll_bar_needed], 1
  678.  
  679.     mov  eax, [scroll_bar_data_vertical.max_area]
  680.     mul  dword[prcinfo+46]
  681.     div  dword[HDoc]
  682.     cmp  eax, [scroll_bar_data_vertical.max_area]
  683.     mov  dword[scroll_bar_data_vertical.cur_area],eax
  684.      jng @f
  685.     mov  eax, [scroll_bar_data_vertical.max_area]
  686.     mov  dword[scroll_bar_data_vertical.cur_area], eax
  687.   @@:
  688.     mov eax, [HDoc]
  689.     cmp eax, dword[prcinfo+46]
  690.     sub eax, dword[prcinfo+46]
  691.     add eax, 20                    ; height of clear area under text when you are at the end of document
  692.      jg @f
  693.     mov eax, 0
  694.   @@:
  695.     mul [scroll_bar_data_vertical.position]
  696.     mov ebx, [scroll_bar_data_vertical.max_area]
  697.     sub ebx, [scroll_bar_data_vertical.cur_area]
  698.     div ebx
  699.    
  700.     mov dword[top], TOP
  701.     sub dword[top], eax
  702.    
  703.   .quit:
  704.     ret
  705. ;---------------------------------------------------------------------
  706. Set_scroll_position:
  707.     mcall 9, procinfo2, -1
  708.     mov eax, dword[procinfo2+0x3E]
  709.     sub eax, scroll_width_size
  710.     mov word[scroll_bar_data_vertical.start_x], ax
  711.  
  712.     mov eax, dword[procinfo2+0x42]
  713.     sub eax, 17
  714.     mov word[scroll_bar_data_vertical.size_y], ax
  715.    
  716.     ret
  717. ;---------------------------------------------------------------------
  718.  
  719. if GUTTER eq 1
  720.    arrow db 0x19
  721. end if
  722. ;---------------------------------------------------------------------
  723. ;---  „€›… Žƒ€ŒŒ›  ----------------------------------------------
  724. ;---------------------------------------------------------------------
  725.  
  726. ; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë©
  727. ;  ‚ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª)
  728.  
  729. window_title:           db      'RtfRead v1.034',0
  730. is_scroll_bar_needed    dd      0x0
  731. window_width            dd      0x0
  732. window_height           dd      0x0
  733. ;---------------------------------------------------------------------
  734. l_libs_start:
  735.  
  736. library01  l_libs system_dir_ProcLib+9, cur_dir_path, library_path, system_dir_ProcLib, \
  737. err_message_found_lib2, head_f_l, ProcLib_import, err_message_import2, head_f_i
  738.  
  739. library02  l_libs system_dir_Boxlib+9, cur_dir_path, library_path, system_dir_Boxlib, \
  740. err_message_found_lib1, head_f_l, Box_lib_import, err_message_import1, head_f_i
  741.  
  742. end_l_libs:
  743. ;---------------------------------------------------------------------
  744. system_dir_ProcLib      db '/sys/lib/proc_lib.obj',0
  745. system_dir_Boxlib       db '/sys/lib/box_lib.obj',0
  746.  
  747. head_f_i:
  748. head_f_l                db 'error',0
  749.  
  750. err_message_found_lib1  db 'box_lib.obj - Not found!',0
  751. err_message_found_lib2  db 'proc_lib.obj - Not found!',0
  752.  
  753. err_message_import1     db 'box_lib.obj - Wrong import!',0
  754. err_message_import2     db 'proc_lib.obj - Wrong import!',0
  755.  
  756. ;---------------------------------------------------------------------
  757. align 4
  758. ProcLib_import:
  759. OpenDialog_Init         dd aOpenDialog_Init
  760. OpenDialog_Start        dd aOpenDialog_Start
  761. ;OpenDialog__Version    dd aOpenDialog_Version
  762.         dd      0
  763.         dd      0
  764. aOpenDialog_Init        db 'OpenDialog_init',0
  765. aOpenDialog_Start       db 'OpenDialog_start',0
  766. ;aOpenDialog_Version    db 'Version_OpenDialog',0
  767. ;---------------------------------------------------------------------
  768. OpenDialog_data:
  769. .type                   dd 0
  770. .procinfo               dd procinfo ;+4
  771. .com_area_name          dd communication_area_name ;+8
  772. .com_area               dd 0 ;+12
  773. .opendir_pach           dd temp_dir_pach ;+16
  774. .dir_default_pach       dd communication_area_default_pach ;+20
  775. .start_path             dd open_dialog_path ;+24
  776. .draw_window            dd draw_window ;+28
  777. .status                 dd 0 ;+32
  778. .openfile_pach          dd fname_buf ;+36
  779. .filename_area          dd 0    ;+40
  780. .filter_area            dd Filter
  781.  
  782. communication_area_name:
  783.         db 'FFFFFFFF_open_dialog',0
  784. open_dialog_path:
  785.         db '/sys/File Managers/opendial',0
  786. communication_area_default_pach:
  787.         db '/rd/1',0
  788.  
  789. Filter:
  790. dd Filter.end - Filter
  791. .1:
  792. db 'RTF',0
  793. .end:
  794. db 0
  795. ;---------------------------------------------------------------------
  796. attrinfo:
  797.         dd      5
  798.         dd      0
  799.         dd      0
  800.         dd      0
  801.         dd      fileattr
  802.         db      0
  803.         dd      fileinfo.name
  804.  
  805. fileinfo:
  806.   dd 0
  807. .block:
  808.   dd 0
  809.   dd 0
  810. .size  dd 1
  811.   dd I_END
  812. .name:
  813.  
  814. ;  db '/HD/1/RTF/texts/index_ru.RTF',0
  815.  
  816.    rb  256-($-.name)
  817. ;---------------------------------------------------------------------
  818. ;blind db ?
  819. if RENDER eq PIX
  820. ;  rd 2
  821.   Free rd 9
  822. else
  823. if RENDER eq BGI
  824.   FreeFontscale dd 0.07
  825. else
  826.   Zoomscale dd 1.15
  827.   FreeFontscale dd 0.04
  828. end if
  829.   Free BGIfree FONT_NAME,0,0,1.0,1.0,char,1,0x44000000,0
  830. end if
  831. ;I_END0:
  832. fname_buf:
  833.         rb      1024+16
  834. fileattr rd 40/4
  835. if BENCH eq 1
  836.   bench dd ?
  837. end if
  838. tail dd ?
  839. cGroup dd ?
  840. Chp:
  841.   CHP
  842. Pap:
  843.   PAP
  844. Sep:
  845.   SEP
  846. Dop:
  847.   DOP
  848. rds db ?
  849. ris db ?
  850. cbBin dd ?
  851. lParam dd ?
  852. fSkipDestIfUnk db ?
  853. mode dd ?
  854. curheight dw ?
  855. maxheight dw ?
  856. RetroBlock dd ?
  857. RetroSave:
  858.   SAVE
  859. prcinfo rb 1024
  860. RetroPtr dd ?
  861. colorptr dd ?
  862. colortbl rd 16
  863. ct_end:
  864. fname_size dd ?
  865. max_block dd ?
  866. cur_block dd ?
  867. HDoc dd ?
  868. ;HClick dd ?
  869. top dw ?
  870. line_count dd ?
  871. par_count  dd ?
  872. char db ?
  873. pitch db ?
  874. wSave dd ?
  875. RetroXY dd ?
  876. RetroGroup dd ?
  877.  
  878. save_stack:
  879. rb RTFSTACKSIZE
  880. save_limit:
  881. rb BGIFONTSIZE
  882.  
  883. listptr dd ?
  884. szKeyword rb 31
  885. szParameter rb 21
  886. block_end dd ?
  887.  
  888. ;---------------------------------------------------------------------
  889. align   4
  890. Box_lib_import:
  891.  
  892. menu_bar_draw           dd aMenu_bar_draw
  893. menu_bar_mouse          dd aMenu_bar_mouse
  894.  
  895. scrollbar_ver_draw      dd aScrollbar_ver_draw
  896. scrollbar_ver_mouse     dd aScrollbar_ver_mouse
  897.  
  898.         dd 0
  899.         dd 0
  900.  
  901. aMenu_bar_draw          db 'menu_bar_draw',0
  902. aMenu_bar_mouse         db 'menu_bar_mouse',0
  903. ;aVersion_menu_bar       db 'version_menu_bar',0
  904.  
  905. aScrollbar_ver_draw     db 'scrollbar_v_draw',0
  906. aScrollbar_ver_mouse    db 'scrollbar_v_mouse',0
  907. ;---------------------------------------------------------------------
  908. align   4
  909. menu_data_1:
  910. .type:          dd 0    ;+0
  911. .x:
  912. .size_x         dw 40   ;+4
  913. .start_x        dw 2    ;+6
  914. .y:
  915. .size_y         dw 15   ;+8
  916. .start_y        dw 2    ;+10
  917. .text_pointer:  dd menu_text_area       ;0      ;+12
  918. .pos_pointer:   dd menu_text_area.1     ;0      ;+16
  919. .text_end       dd menu_text_area.end   ;0      ;+20
  920. .mouse_pos      dd 0    ;+24
  921. .mouse_keys     dd 0    ;+28
  922. .x1:
  923. .size_x1        dw 40   ;+32
  924. .start_x1       dw 2    ;+34
  925. .y1:
  926. .size_y1        dw 100  ;+36
  927. .start_y1       dw 18   ;+38
  928. .bckg_col       dd 0xeeeeee     ;+40
  929. .frnt_col       dd 0xff ;+44
  930. .menu_col       dd 0xffffff     ;+48
  931. .select         dd 0    ;+52
  932. .out_select     dd 0    ;+56
  933. .buf_adress     dd 0    ;+60
  934. .procinfo       dd 0    ;+64
  935. .click          dd 0    ;+68
  936. .cursor         dd 0    ;+72
  937. .cursor_old     dd 0    ;+76
  938. .interval       dd 16   ;+80
  939. .cursor_max     dd 0    ;+84
  940. .extended_key   dd 0    ;+88
  941. .menu_sel_col   dd 0x00cc00     ;+92
  942. .bckg_text_col  dd 0    ;+96
  943. .frnt_text_col  dd 0xffffff     ;+100
  944. .mouse_keys_old dd 0    ;+104
  945. .font_height    dd 8    ;+108
  946. .cursor_out     dd 0    ;+112
  947. .get_mouse_flag dd 0    ;+116
  948.  
  949. menu_text_area:
  950.         db 'File',0
  951. .1:
  952.         db 'Open',0
  953.         db 'Exit',0
  954. .end:
  955.         db 0
  956. ;---------------------------------------------------------------------
  957. align   4
  958. menu_data_2:
  959. .type:          dd 0    ;+0
  960. .x:
  961. .size_x         dw 40   ;+4
  962. .start_x        dw 43   ;+6
  963. .y:
  964. .size_y         dw 15   ;+8
  965. .start_y        dw 2    ;+10
  966. .text_pointer:  dd menu_text_area_2     ;0      ;+12
  967. .pos_pointer:   dd menu_text_area_2.1   ;0      ;+16
  968. .text_end       dd menu_text_area_2.end ;0      ;+20
  969. .mouse_pos      dd 0    ;+24
  970. .mouse_keys     dd 0    ;+28
  971. .x1:
  972. .size_x1        dw 50   ;+32
  973. .start_x1       dw 43   ;+34
  974. .y1:
  975. .size_y1        dw 100  ;+36
  976. .start_y1       dw 18   ;+38
  977. .bckg_col       dd 0xeeeeee     ;+40
  978. .frnt_col       dd 0xff ;+44
  979. .menu_col       dd 0xffffff     ;+48
  980. .select         dd 0    ;+52
  981. .out_select     dd 0    ;+56
  982. .buf_adress     dd 0    ;+60
  983. .procinfo       dd 0    ;+64
  984. .click          dd 0    ;+68
  985. .cursor         dd 0    ;+72
  986. .cursor_old     dd 0    ;+76
  987. .interval       dd 16   ;+80
  988. .cursor_max     dd 0    ;+84
  989. .extended_key   dd 0    ;+88
  990. .menu_sel_col   dd 0x00cc00     ;+92
  991. .bckg_text_col  dd 0    ;       +96
  992. .frnt_text_col  dd 0xffffff     ;+100
  993. .mouse_keys_old dd 0    ;+104
  994. .font_height    dd 8    ;+108
  995. .cursor_out     dd 0    ;+112
  996. .get_mouse_flag dd 0    ;+116
  997.  
  998. menu_text_area_2:
  999.         db 'View',0
  1000. .1:
  1001.         db 'Zoom +',0
  1002.         db 'Zoom -',0
  1003.         db ' > >',0
  1004.         db ' << ',0
  1005.         db 'Align',0
  1006.         db 'Color',0
  1007. .end:
  1008.         db 0
  1009. ;---------------------------------------------------------------------
  1010. align   4
  1011. menu_data_3:
  1012. .type:          dd 0    ;+0
  1013. .x:
  1014. .size_x         dw 40   ;+4
  1015. .start_x        dw 84   ;+6
  1016. .y:
  1017. .size_y         dw 15   ;+8
  1018. .start_y        dw 2    ;+10
  1019. .text_pointer:  dd menu_text_area_3     ;0      ;+12
  1020. .pos_pointer:   dd menu_text_area_3.1   ;0      ;+16
  1021. .text_end       dd menu_text_area_3.end ;0      ;+20
  1022. .mouse_pos      dd 0    ;+24
  1023. .mouse_keys     dd 0    ;+28
  1024. .x1:
  1025. .size_x1        dw 40   ;+32
  1026. .start_x1       dw 84   ;+34
  1027. .y1:
  1028. .size_y1        dw 100  ;+36
  1029. .start_y1       dw 18   ;+38
  1030. .bckg_col       dd 0xeeeeee     ;+40
  1031. .frnt_col       dd 0xff ;+44
  1032. .menu_col       dd 0xffffff     ;+48
  1033. .select         dd 0    ;+52
  1034. .out_select     dd 0    ;+56
  1035. .buf_adress     dd 0    ;+60
  1036. .procinfo       dd 0    ;+64
  1037. .click          dd 0    ;+68
  1038. .cursor         dd 0    ;+72
  1039. .cursor_old     dd 0    ;+76
  1040. .interval       dd 16   ;+80
  1041. .cursor_max     dd 0    ;+84
  1042. .extended_key   dd 0    ;+88
  1043. .menu_sel_col   dd 0x00cc00     ;+92
  1044. .bckg_text_col  dd 0    ;       +96
  1045. .frnt_text_col  dd 0xffffff     ;+100
  1046. .mouse_keys_old dd 0    ;+104
  1047. .font_height    dd 8    ;+108
  1048. .cursor_out     dd 0    ;+112
  1049. .get_mouse_flag dd 0    ;+116
  1050.  
  1051. menu_text_area_3:
  1052.         db 'Help',0
  1053. .1:
  1054.         db 'Home',0
  1055. .end:
  1056.         db 0
  1057. ;---------------------------------------------------------------------
  1058. align   4
  1059. scroll_bar_data_vertical:
  1060. .x:
  1061. .size_x         dw scroll_width_size;+0
  1062. .start_x        dw WINW-25  ;+2
  1063. .y:
  1064. .size_y         dw WINH-45  ;+4
  1065. .start_y        dw 19   ;+6
  1066. .btn_high       dd scroll_width_size    ;+8
  1067. .type           dd 1    ;+12
  1068. .max_area       dd 300       ;+16
  1069. .cur_area       dd 50   ;+20
  1070. .position       dd 0    ;+24
  1071. .bckg_col       dd 0xAAAAAA     ;+28
  1072. .frnt_col       dd 0xCCCCCC     ;+32
  1073. .line_col       dd 0    ;+36
  1074. .redraw         dd 0    ;+40
  1075. .delta          dw 0    ;+44
  1076. .delta2         dw 0    ;+46
  1077. .run_x:
  1078. .r_size_x       dw 0    ;+48
  1079. .r_start_x      dw 0    ;+50
  1080. .run_y:
  1081. .r_size_y       dw 0    ;+52
  1082. .r_start_y      dw 0    ;+54
  1083. .m_pos          dd 0    ;+56
  1084. .m_pos_2        dd 0    ;+60
  1085. .m_keys         dd 0    ;+64
  1086. .run_size       dd 0    ;+68
  1087. .position2      dd 0    ;+72
  1088. .work_size      dd 0    ;+76
  1089. .all_redraw     dd 0    ;+80
  1090. .ar_offset      dd AR_OFFSET   ;+84
  1091. ;---------------------------------------------------------------------
  1092. I_END0:
  1093. I_END:                             ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë
  1094.  
  1095. procinfo process_information
  1096. rb RTFSIZE
  1097. esp1:
  1098. rb ESPSIZE
  1099. procinfo2 process_information
  1100. ;---------------------------------------------------------------------
  1101. temp_dir_pach:
  1102.         rb 4096
  1103. cur_dir_path:
  1104.         rb 4096
  1105. library_path:
  1106.         rb 4096
  1107. ;---------------------------------------------------------------------
  1108.     rb ESPSIZE                      ;stack
  1109. esp_end:
  1110. sys_mem:
  1111.