Subversion Repositories Kolibri OS

Rev

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