Subversion Repositories Kolibri OS

Rev

Rev 2804 | Rev 2813 | 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.         ;Leency[
  171.         cmp eax,1
  172.         jne .getkeyi
  173.         mov ah,dh
  174.         jmp .next
  175.  
  176. .getkeyi:
  177.         mov dh,ah
  178.         jmp key
  179.  
  180. .next:  ;]Leency
  181.     cmp  ah,104         ; HELP
  182.     jne  .nohelp
  183.   .help:
  184.     mov  [is_scroll_bar_needed],    0
  185.     xor  [mode],RTF_HELP
  186.     test [mode],RTF_HELP
  187.     jz   load_file
  188.     mov  dword[HDoc],200                        ; it makes the help page not scroll
  189.     mov  ecx,help_end-help_file
  190.     mov  [block_end],ecx
  191.     add  [block_end],I_END
  192.     mov  [tail],ecx
  193.     add  [tail],I_END
  194.     mov  esi,help_file
  195.     mov  edi,I_END
  196.     rep  movsb
  197. ;    or   [mode],RTF_HELP
  198.     xor  eax,eax
  199.     mov  [max_block],eax
  200.     jmp  top_red
  201.   .nohelp:
  202. ;    test [mode],RTF_HELP
  203. ;    jz   .nohelp2
  204. ;    and  [mode],not RTF_HELP
  205. ;    cmp  dword[fileinfo.name],N_A
  206. ;    je   still
  207. ;    jmp  prep_load
  208.   .nohelp2:
  209.     cmp  ah,114         ; R - redraw
  210.     je   red
  211.     cmp  ah,99          ; C - color
  212.     jne  .nocolor
  213.   .color:
  214.     xor  [mode],RTF_COLORLESS
  215.     jmp  red
  216.   .nocolor:
  217.     cmp  ah,97          ; A - alignment
  218.     jne  .noalign
  219.   .alignment:
  220.     xor  [mode],RTF_ALIGNLESS
  221.     jmp  red
  222.   .noalign:
  223.     cmp  ah,44          ; < - pitch dec
  224.     jne  .nopd
  225.   .decp:
  226.     dec  [pitch]
  227.     jmp  red
  228.   .nopd:
  229.     cmp  ah,46          ; < - pitch inc
  230.     jne  .nopi
  231.   .incp:
  232.     inc  [pitch]
  233.     jmp  red
  234.   .nopi:
  235.     cmp  ah,180         ; Home
  236.     je   top_red
  237.    
  238.     cmp  dword[is_scroll_bar_needed], 0
  239.      je  still
  240.    
  241.     mov  ebx,dword[prcinfo+46]
  242.     sub  ebx,TOP+15
  243.     cmp  ah,183 ;PgDn
  244.     jne  .nopgdn
  245. ;    sub  [top],bx
  246.  
  247.     cmp  dword[is_scroll_bar_needed], 0
  248.      je  still
  249.    
  250.     mov  eax, [scroll_bar_data_vertical.position]
  251.     add  eax, AR_OFFSET*7
  252.     mov  ebx, [scroll_bar_data_vertical.max_area]
  253.     sub  ebx, [scroll_bar_data_vertical.cur_area]
  254.     cmp  eax, ebx
  255.     mov  dword[scroll_bar_data_vertical.position], eax
  256.     jl  @f
  257.     mov  dword[scroll_bar_data_vertical.position], ebx
  258.   @@:
  259.     call Set_position
  260.     jmp  red
  261.   .nopgdn:
  262.     cmp  ah,177 ;arrDn
  263.     jne  .noardn
  264. ;    sub  [top],CHARH
  265.  
  266.     cmp  dword[is_scroll_bar_needed], 0
  267.      je  still
  268.    
  269.     mov  eax, [scroll_bar_data_vertical.position]
  270.     add  eax, AR_OFFSET
  271.     mov  ebx, [scroll_bar_data_vertical.max_area]
  272.     sub  ebx, [scroll_bar_data_vertical.cur_area]
  273.     cmp  eax, ebx
  274.     mov  dword[scroll_bar_data_vertical.position], eax
  275.     jl  @f
  276.     mov  dword[scroll_bar_data_vertical.position], ebx
  277.   @@:
  278.     call Set_position
  279.  
  280.     jmp  red
  281.   .noardn:
  282.     mov  cx,[top]
  283.     cmp  ah,184 ;PgUp
  284.     jne  .nopgup
  285. ;    add  [top],bx
  286. ;    cmp  [top],TOP
  287. ;    jl   red
  288. ;    mov  [top],TOP
  289. ;    cmp  cx,[top]
  290. ;    je   still
  291.  
  292.     cmp  dword[is_scroll_bar_needed], 0
  293.      je  still
  294.    
  295.     cmp  dword[scroll_bar_data_vertical.position], AR_OFFSET*7
  296.     sub  dword[scroll_bar_data_vertical.position], AR_OFFSET*7
  297.     jg  @f
  298.     mov  dword[scroll_bar_data_vertical.position], 0
  299.   @@:
  300.     call Set_position
  301.     jmp  red
  302.   .nopgup:
  303.     cmp  ah,178 ;arrUp
  304.     jne  .noarup
  305. ;    add  [top],CHARH
  306.  
  307.     cmp  dword[is_scroll_bar_needed], 0
  308.      je  still
  309.    
  310.     cmp  dword[scroll_bar_data_vertical.position], AR_OFFSET
  311.     sub  dword[scroll_bar_data_vertical.position], AR_OFFSET
  312.     jg  @f
  313.     mov  dword[scroll_bar_data_vertical.position], 0
  314.   @@:
  315.     call Set_position
  316.  
  317. ;    cmp  [top],TOP
  318. ;    jl   red
  319. ;    mov  [top],TOP
  320. ;    cmp  cx,[top]
  321. ;    je   still
  322.     jmp  red
  323.   .noarup:
  324.   if  RENDER eq FREE
  325.     cmp  ah,56 ;zoom+
  326.     jne  .noplus
  327.   .zplus:
  328.     fld  [FreeFontscale]
  329.     fmul [Zoomscale]
  330.   .zoom:
  331.     fstp [FreeFontscale]
  332.     jmp  red
  333.   .noplus:
  334.     cmp  ah,54 ;zoom-
  335.     jne  .nominus
  336.   .zminus:
  337.     fld  [FreeFontscale]
  338.     fdiv [Zoomscale]
  339.     jmp  .zoom
  340.   .nominus:
  341.   end if
  342.     cmp  ah,0xB5        ; end
  343.     jne  .pre_file_open
  344.   .end:
  345.  
  346.     cmp  dword[is_scroll_bar_needed], 0
  347.      je  still
  348.    
  349.     mov  eax, [scroll_bar_data_vertical.max_area]
  350.     sub  eax, [scroll_bar_data_vertical.cur_area]
  351.     mov  dword[scroll_bar_data_vertical.position], eax
  352.     call Set_position
  353.     jmp  red
  354.   .pre_file_open:
  355.     cmp  ah,108         ; L - load
  356.     jne  still
  357.   .file_open:
  358. ;---------------------------------------------------------------------
  359. ;OpenDialog_start:
  360. ;       copy_path       open_dialog_name,path,library_path,0
  361.        
  362.         push    dword OpenDialog_data
  363.         call    [OpenDialog_Start]
  364.  
  365. ;       cmp     [OpenDialog_data.status],2 ; OpenDialog does not start
  366. ;       je      .sysxtree  ;    some kind of alternative, instead OpenDialog
  367.         cmp     [OpenDialog_data.status],1
  368.         je      prep_load
  369.         jmp     still
  370. ;---------------------------------------------------------------------  
  371. ;.sysxtree:
  372. ;    or   [mode],RTF_OPENING
  373. ;    opendialog draw_window, prep_load, st_1, fname_buf
  374. ;  st_1:
  375. ;    and  [mode],not RTF_OPENING
  376. ;    jmp  still;red
  377. ;  stilld:
  378. ;    jmp  still
  379. ;---------------------------------------------------------------------
  380.  
  381.   button:
  382.     mcall 17            ; 17 - ¯®«ãç¨âì ¨¤¥­â¨ä¨ª â®à ­ ¦ â®© ª­®¯ª¨
  383.  
  384.     cmp   ah, 1         ; ¥á«¨ ­ ¦ â  ª­®¯ª  á ­®¬¥à®¬ 1,
  385.     je    .exit
  386.     jmp still
  387.    
  388.   .exit:
  389.     mcall -1            ; ¨­ ç¥ ª®­¥æ ¯à®£à ¬¬ë
  390.    
  391.  
  392. ;---------------------------------------------------------------------
  393. ;---  MOUSE EVENT PROCESSING  ----------------------------------------
  394. ;---------------------------------------------------------------------    
  395. mouse:
  396.         mcall   37,7
  397.         test    eax,    eax
  398.         je      .menu_bar_1;.mouse
  399.         jmp     still
  400.  
  401.  
  402. .menu_bar_1:
  403.         call    .set_mouse_flag
  404. @@:
  405.         push    dword menu_data_1       ;mouse event for Menu 1
  406.         call    [menu_bar_mouse]
  407.         cmp     [menu_data_1.click],dword 1
  408.         jne     .menu_bar_2
  409.         cmp     [menu_data_1.cursor_out],dword 0
  410.         jne     .analyse_out_menu_1
  411.         jmp     .menu_bar_1
  412. .menu_bar_2:
  413.         push    dword menu_data_2
  414.         call    [menu_bar_mouse]
  415.         cmp     [menu_data_2.click],dword 1
  416.         jne     .menu_bar_3
  417.         cmp     [menu_data_2.cursor_out],dword 0
  418.         jne     .analyse_out_menu_2
  419.         jmp     .menu_bar_1
  420. .menu_bar_3:
  421.         push    dword menu_data_3
  422.         call    [menu_bar_mouse]
  423.         cmp     [menu_data_3.click],dword 1
  424.         jne     .scroll_bar
  425.         cmp     [menu_data_3.cursor_out],dword 0
  426.         jne     .analyse_out_menu_3
  427.         jmp     .menu_bar_1
  428.  
  429. .set_mouse_flag:
  430.         xor     eax,eax
  431.         inc     eax
  432.         mov     [menu_data_1.get_mouse_flag],eax
  433.         mov     [menu_data_2.get_mouse_flag],eax
  434.         mov     [menu_data_3.get_mouse_flag],eax
  435.         ret
  436.  
  437. .analyse_out_menu_1:
  438.         cmp     [menu_data_1.cursor_out],dword 1
  439.         je      key.file_open
  440.         cmp     [menu_data_1.cursor_out],dword 2
  441.         je      button.exit
  442.         jmp     red
  443.  
  444. .analyse_out_menu_2:
  445.         cmp     [menu_data_2.cursor_out],dword 1
  446.         je      key.zplus
  447.         cmp     [menu_data_2.cursor_out],dword 2
  448.         je      key.zminus
  449.         cmp     [menu_data_2.cursor_out],dword 3
  450.         je      key.incp
  451.         cmp     [menu_data_2.cursor_out],dword 4
  452.         je      key.decp
  453.         cmp     [menu_data_2.cursor_out],dword 5
  454.         je      key.alignment
  455.         cmp     [menu_data_2.cursor_out],dword 6
  456.         je      key.color
  457.         jmp     red
  458.  
  459. .analyse_out_menu_3:
  460.         cmp     [menu_data_3.cursor_out],dword 1
  461.         je      key.help
  462.         jmp     red
  463.  
  464. .scroll_bar:
  465.         cmp     dword[is_scroll_bar_needed], 0
  466.         je      still
  467. .vertical:
  468.         mov     eax,[scroll_bar_data_vertical.max_area]
  469.         cmp     eax,[scroll_bar_data_vertical.cur_area]
  470.         jbe     still
  471. ; mouse event for Vertical ScrollBar
  472.  
  473.         push    dword scroll_bar_data_vertical
  474.         call    [scrollbar_ver_mouse]
  475.  
  476.         call    Set_position
  477.        
  478.         mov     eax,scroll_bar_data_vertical.redraw
  479.         xor     ebx,ebx
  480.         cmp     [eax],ebx
  481.         je      @f
  482.         mov     [eax],ebx
  483.         jmp     red
  484. @@:
  485.         cmp     [scroll_bar_data_vertical.delta2],0
  486.         jne     still
  487. .other:
  488.         jmp     still
  489. ;---------------------------------------------------------------------
  490. ;---  Ž…„…‹…ˆ… ˆ Ž’ˆ‘Ž‚Š€ ŽŠ€  ----------------------------------
  491. ;---------------------------------------------------------------------
  492.  
  493. draw_window:
  494.  
  495.     mcall 9, procinfo2, -1
  496.     test [procinfo2.wnd_state], 0x04
  497.     jz   @f
  498.     mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x80000000, window_title
  499.     ret
  500.   @@:
  501.     mov  edx, -1
  502.     mov  esi, -1
  503.    
  504.     mov  eax, [procinfo2.box.width]
  505.     cmp  eax, [window_width]
  506.      je  @f
  507.     mov  [is_scroll_bar_needed],    0
  508.     cmp  eax, 140
  509.      jnl @f
  510.     mov  eax, 140
  511.   @@:
  512.     mov  edx, eax
  513.     mov  [window_width],    eax
  514.  
  515.     mov  eax, [procinfo2.box.height]
  516.     cmp  eax, [window_height]
  517.      je  @f
  518.     mov  [is_scroll_bar_needed],    0
  519.     cmp  eax, 80
  520.      jnl @f
  521.     mov  eax, 80
  522.   @@:
  523.     mov  esi, eax
  524.     mov  [window_height],   eax
  525.  
  526.     mcall 67, -1, -1
  527.  
  528.     mcall 12, 1
  529. ;    mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x805080D0, 0x005080D0
  530. ;    mcall 4, <8,8>, 0x10DDEEFF, title, titlesize-title
  531.     mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x80000000, window_title
  532. ;---------------------------------------------
  533.     cmp  [is_scroll_bar_needed],    0
  534.      je  @f
  535.     call Set_scroll_position
  536.         xor     eax,eax
  537.         inc     eax
  538.         mov     [scroll_bar_data_vertical.all_redraw],eax
  539. ; draw for Vertical ScrollBar
  540.         push    dword scroll_bar_data_vertical
  541.         call    [scrollbar_ver_draw]
  542. ; reset all_redraw flag
  543.         xor     eax,eax
  544.         mov     [scroll_bar_data_vertical.all_redraw],eax
  545.   @@:
  546. ;---------------------------------------------
  547.     mcall 47,0x30000,isymImplemented,<114,8>, 0x10DDEEFF
  548.     add  edx,36 shl 16
  549.     mcall ,,isymMax
  550.     add  edx,40 shl 16
  551.     mov  esi,0x104e00e7;0x10f27840
  552.     cmp  dword[fileinfo.name],N_A
  553.     jne  .noNA
  554.     mov  esi,0x10ff0000
  555.   .noNA:
  556. ;    mcall 4,edx,esi,fileinfo.name,[fname_size]
  557.     mov  edi,prcinfo
  558.     mcall 9,edi,-1
  559.     and  [mode],not RTF_TOEOF
  560.     mov  ebx,[edi+42]
  561.     cmp  ebx,[wSave]
  562.     je   .nochg
  563.   .chg:
  564.     mov  [wSave],ebx
  565.     or   [mode],RTF_TOEOF
  566.     and  [HDoc],0
  567.     and  [line_count],0
  568. ;    mov  [HClick],-100
  569.   .nochg:
  570.  
  571. ;---------------------------------------------
  572.     call  Set_scroll_position
  573.  
  574.     mov ebx, dword[prcinfo+0x3E]
  575.     mcall     38, , 65536*18+18, 0x8b8b89
  576.     inc ebx
  577.     mcall     13, , 65536*0+18, 0xe9e9e2
  578. ;---------------------------------------------
  579. ; draw for Menu 1
  580.         push    dword menu_data_1
  581.         call    [menu_bar_draw]
  582. ; draw for Menu 2
  583.         push    dword menu_data_2
  584.         call    [menu_bar_draw]
  585. ; draw for Menu 3
  586.         push    dword menu_data_3
  587.         call    [menu_bar_draw]        
  588. ;---------------------------------------------
  589.  
  590.     sub  dword[prcinfo+42],2*LMARGIN+scroll_width_size
  591.     sub  dword[prcinfo+46],CHARH+25
  592.    
  593.  if GUTTER eq 1
  594.     mov  ebx,LMARGIN shl 16+20
  595.     mov  ecx,20
  596.     mov  eax,4
  597.     mov  edx,arrow
  598.     mov  esi,1
  599.   .loop1:
  600.     push ecx
  601.     mcall ,,0xff0000
  602.     pop  ecx
  603.     add  ebx,50 shl 16
  604.     loop .loop1
  605.  end if
  606.  if MODE eq RTF
  607.     test [mode],RTF_OPENING
  608.     jne  .ex
  609.     and  [mode],not (RTF_BOTTOM);+RTF_TOEOF)
  610.     mov  [colorptr],colortbl
  611.     mov  eax,DEFCOLOR
  612.     mov  edi,colortbl
  613.     mov  ecx,16
  614.     rep  stosd
  615.     xor  eax,eax
  616.     mov  [cGroup],eax
  617.     mov  edi,Chp
  618.     mov  ecx,SIZE_save
  619.     rep  stosb
  620.     mov  ax,[top]
  621.     mov  word[Free+6],10
  622.     mov  word[Free+4],ax
  623.     mov  esi,I_END
  624.     call RtfParse
  625. ;    dpd  eax
  626. ;    dps  'Lines='
  627.     mov  eax,[line_count]
  628. ;    dpd  eax
  629. ;    newline
  630. ;    movzx  eax,word[Free+4]
  631. ;    dpd  eax
  632.     mov  eax,dword[prcinfo+42]
  633.     mov  edx,WIN_COLOR
  634.     call draw_progress
  635. if BENCH eq 1
  636.     mcall 26,9
  637.     sub  eax,[bench]
  638. ;    dps  <13,10,'Bench='>
  639. ;    dpd  eax
  640. end if
  641.  else
  642.     mov  [char],0
  643.     mov  ebx,10 shl 16+TOP
  644.     mov  ecx,16
  645.   .l0:
  646.     push ecx
  647.     mov  ecx,16
  648.   .l1:
  649.     push ecx
  650.   if RENDER eq BGI
  651.     mov  edx,char
  652.     mov  ecx,0x48000000
  653.     mov  esi,1
  654.     BGIfont_Outtext
  655.   else
  656.     mcall 4,,0x10000000,char,1
  657.   end if
  658.     pop  ecx
  659.     inc  [char]
  660.     add  ebx,(CHARW+3) shl 16
  661.     loop .l1
  662.     pop  ecx
  663.     add  ebx,CHARH+2
  664.     and  ebx,0x0000ffff
  665.     add  ebx,10 shl 16
  666.     loop .l0
  667.  end if
  668.  .ex:
  669. call Set_position
  670. ;---------------------------------------------
  671.     cmp  dword[is_scroll_bar_needed], 0
  672.      je  @f
  673.         xor     eax,eax
  674.         inc     eax
  675.         mov     [scroll_bar_data_vertical.all_redraw],eax
  676. ; draw for Vertical ScrollBar
  677.         push    dword scroll_bar_data_vertical
  678.         call    [scrollbar_ver_draw]
  679. ; reset all_redraw flag
  680.         xor     eax,eax
  681.         mov     [scroll_bar_data_vertical.all_redraw],eax
  682.   @@:
  683. ;---------------------------------------------
  684.     mcall 12, 2
  685.     ret
  686.  
  687. ;---------------------------------------------------------------------
  688. Set_position:
  689.     mov  eax, dword[prcinfo+46]
  690.     cmp  eax, [HDoc]
  691.     mov  dword[is_scroll_bar_needed], 0
  692.      jnl .quit
  693.     mov  dword[is_scroll_bar_needed], 1
  694.  
  695.     mov  eax, [scroll_bar_data_vertical.max_area]
  696.     mul  dword[prcinfo+46]
  697.     div  dword[HDoc]
  698.     cmp  eax, [scroll_bar_data_vertical.max_area]
  699.     mov  dword[scroll_bar_data_vertical.cur_area],eax
  700.      jng @f
  701.     mov  eax, [scroll_bar_data_vertical.max_area]
  702.     mov  dword[scroll_bar_data_vertical.cur_area], eax
  703.   @@:
  704.     mov eax, [HDoc]
  705.     cmp eax, dword[prcinfo+46]
  706.     sub eax, dword[prcinfo+46]
  707.     add eax, 20                    ; height of clear area under text when you are at the end of document
  708.      jg @f
  709.     mov eax, 0
  710.   @@:
  711.     mul [scroll_bar_data_vertical.position]
  712.     mov ebx, [scroll_bar_data_vertical.max_area]
  713.     sub ebx, [scroll_bar_data_vertical.cur_area]
  714.     div ebx
  715.    
  716.     mov dword[top], TOP
  717.     sub dword[top], eax
  718.    
  719.   .quit:
  720.     ret
  721. ;---------------------------------------------------------------------
  722. Set_scroll_position:
  723.     mcall 9, procinfo2, -1
  724.     mov eax, dword[procinfo2+0x3E]
  725.     sub eax, scroll_width_size
  726.     mov word[scroll_bar_data_vertical.start_x], ax
  727.  
  728.     mov eax, dword[procinfo2+0x42]
  729.     sub eax, 17
  730.     mov word[scroll_bar_data_vertical.size_y], ax
  731.    
  732.     ret
  733. ;---------------------------------------------------------------------
  734.  
  735. if GUTTER eq 1
  736.    arrow db 0x19
  737. end if
  738. ;---------------------------------------------------------------------
  739. ;---  „€›… Žƒ€ŒŒ›  ----------------------------------------------
  740. ;---------------------------------------------------------------------
  741.  
  742. ; ¨­â¥àä¥©á ¯à®£à ¬¬ë ¬­®£®ï§ëç­ë©
  743. ;  ‚ë ¬®¦¥â¥ § ¤ âì ï§ëª ¢ MACROS.INC (lang fix ï§ëª)
  744.  
  745. window_title:           db      'RtfRead v1.034',0
  746. is_scroll_bar_needed    dd      0x0
  747. window_width            dd      0x0
  748. window_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. ;  db '/HD/1/RTF/texts/index_ru.RTF',0
  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 1    ;+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. if RENDER eq PIX
  1050. ;  rd 2
  1051.   Free rd 9
  1052. else
  1053. if RENDER eq BGI
  1054.   FreeFontscale dd 0.07
  1055. else
  1056.   Zoomscale dd 1.15
  1057.   FreeFontscale dd 0.04
  1058. end if
  1059.   Free BGIfree FONT_NAME,0,0,1.0,1.0,char,1,0x44000000,0
  1060. end if
  1061. I_END0:
  1062. fname_buf:
  1063.         rb      1024+16
  1064. fileattr rd 40/4
  1065. if BENCH eq 1
  1066.   bench dd ?
  1067. end if
  1068. tail dd ?
  1069. cGroup dd ?
  1070. Chp:
  1071.   CHP
  1072. Pap:
  1073.   PAP
  1074. Sep:
  1075.   SEP
  1076. Dop:
  1077.   DOP
  1078. rds db ?
  1079. ris db ?
  1080. cbBin dd ?
  1081. lParam dd ?
  1082. fSkipDestIfUnk db ?
  1083. mode dd ?
  1084. curheight dw ?
  1085. maxheight dw ?
  1086. RetroBlock dd ?
  1087. RetroSave:
  1088.   SAVE
  1089. prcinfo rb 1024
  1090. RetroPtr dd ?
  1091. colorptr dd ?
  1092. colortbl rd 16
  1093. ct_end:
  1094. fname_size dd ?
  1095. max_block dd ?
  1096. cur_block dd ?
  1097. HDoc dd ?
  1098. ;HClick dd ?
  1099. top dw ?
  1100. line_count dd ?
  1101. par_count  dd ?
  1102. char db ?
  1103. pitch db ?
  1104. wSave dd ?
  1105. RetroXY dd ?
  1106. RetroGroup dd ?
  1107.  
  1108. save_stack:
  1109. rb RTFSTACKSIZE
  1110. save_limit:
  1111. rb BGIFONTSIZE
  1112.  
  1113. listptr dd ?
  1114. szKeyword rb 31
  1115. szParameter rb 21
  1116. block_end dd ?
  1117.  
  1118. ;---------------------------------------------------------------------
  1119. I_END:                             ; ¬¥âª  ª®­æ  ¯à®£à ¬¬ë
  1120.  
  1121. procinfo process_information
  1122. rb RTFSIZE
  1123. esp1:
  1124. rb ESPSIZE
  1125. procinfo2 process_information
  1126. ;---------------------------------------------------------------------
  1127. temp_dir_pach:
  1128.         rb 4096
  1129. cur_dir_path:
  1130.         rb 4096
  1131. library_path:
  1132.         rb 4096
  1133. ;---------------------------------------------------------------------
  1134.     rb ESPSIZE                      ;stack
  1135. esp_end:
  1136. sys_mem:
  1137.