Subversion Repositories Kolibri OS

Rev

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