Subversion Repositories Kolibri OS

Rev

Rev 474 | Rev 517 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. virtual at 0
  2. viewer_data:
  3.         .buf_start      dq      ?
  4.         .cur_pos        dq      ?
  5.         .filesize       dq      ?
  6.         .buf_pos        dd      ?
  7.         .buf_size       dd      ?
  8.         .col            dq      ?
  9.         .encoding       db      ?
  10.         .bEofReached    db      ?
  11.         .flags          db      ?       ; & 1: hex mode
  12.                                         ; & 2: unwrap
  13.                                         ; & 4: big-endian unicode
  14.                         rb      1
  15.         .filename       rb      1024
  16.         .buf            rb      16384
  17.         .size = $
  18. end virtual
  19.  
  20. view_file:
  21.         mov     eax, [ebp + panel1_files - panel1_data]
  22.         mov     ecx, [eax+ecx*4]
  23.         test    byte [ecx], 10h
  24.         jz      .file
  25.         ret
  26. .file:
  27.         lea     esi, [ebp + panel1_dir - panel1_data]
  28.         push    ecx
  29.         mov     ecx, viewer_data.size
  30.         mov     edx, viewer_vtable
  31.         call    new_screen
  32.         pop     ecx
  33.         test    eax, eax
  34.         jnz     @f
  35.         ret
  36. @@:
  37.         mov     [ebp+viewer_data.encoding], encodings.cp866
  38.         mov     [ebp+viewer_data.flags], 0
  39.         and     dword [ebp+viewer_data.col], 0
  40.         and     dword [ebp+viewer_data.col+4], 0
  41.         lea     edi, [ebp+viewer_data.filename]
  42.         push    edi
  43. @@:
  44.         lodsb
  45.         test    al, al
  46.         jz      @f
  47.         stosb
  48.         jmp     @b
  49. @@:
  50.         lea     esi, [ecx+40]
  51.         mov     al, '/'
  52.         stosb
  53. @@:
  54.         lodsb
  55.         stosb
  56.         test    al, al
  57.         jnz     @b
  58.         pop     eax
  59.         push    eax
  60.         mov     ebx, attrinfo
  61.         mov     [ebx+21], eax
  62. .attr_retry:
  63.         push    70
  64.         pop     eax
  65.         mcall
  66.         test    eax, eax
  67.         jz      @f
  68.         lea     ebx, [ebp+viewer_data.filename]
  69.         push    ebx
  70.         push    aCannotReadFile
  71.         call    get_error_msg
  72.         push    eax
  73.         mov     eax, esp
  74.         push    RetryOrCancelBtn
  75.         push    2
  76.         push    eax
  77.         push    3
  78.         push    -1
  79.         push    -1
  80.         push    aError
  81.         call    SayErr
  82.         add     esp, 3*4
  83.         mov     ebx, attrinfo
  84.         test    eax, eax
  85.         jz      .attr_retry
  86.         jmp     delete_active_screen
  87. @@:
  88.         mov     eax, dword [attrinfo.attr+32]
  89.         mov     dword [ebp+viewer_data.filesize], eax
  90.         mov     eax, dword [attrinfo.attr+36]
  91.         mov     dword [ebp+viewer_data.filesize+4], eax
  92.         mov     ebx, readinfo
  93.         xor     eax, eax
  94.         mov     dword [ebx+readinfo.first-readinfo], eax
  95.         mov     dword [ebx+readinfo.first+4-readinfo], eax
  96.         mov     dword [ebp+viewer_data.buf_start], eax
  97.         mov     dword [ebp+viewer_data.buf_start+4], eax
  98.         mov     dword [ebp+viewer_data.cur_pos], eax
  99.         mov     dword [ebp+viewer_data.cur_pos+4], eax
  100.         mov     [ebx+readinfo.size-readinfo], 16384
  101.         lea     eax, [ebp+viewer_data.buf]
  102.         mov     [readinfo.data], eax
  103.         mov     [ebp+viewer_data.buf_pos], eax
  104.         pop     dword [readinfo.name]
  105. .retry:
  106.         push    70
  107.         pop     eax
  108.         mcall
  109.         mov     [ebp+viewer_data.buf_size], ebx
  110.         test    eax, eax
  111.         jz      .readok
  112.         cmp     eax, 6
  113.         jz      .readok
  114.         lea     ebx, [ebp+viewer_data.filename]
  115.         push    ebx
  116.         push    aCannotReadFile
  117.         call    get_error_msg
  118.         push    eax
  119.         mov     eax, esp
  120.         push    RetryOrCancelBtn
  121.         push    2
  122.         push    eax
  123.         push    3
  124.         push    -1
  125.         push    -1
  126.         push    aError
  127.         call    SayErr
  128.         add     esp, 3*4
  129.         mov     ebx, readinfo
  130.         test    eax, eax
  131.         jz      .attr_retry
  132.         jmp     delete_active_screen
  133. .readok:
  134.         cmp     ebx, 2
  135.         jb      .nounicode
  136.         cmp     word [ebp+viewer_data.buf], 0xFEFF
  137.         jz      @f
  138.         cmp     word [ebp+viewer_data.buf], 0xFFFE
  139.         jnz     .nounicode
  140.         or      byte [ebp+viewer_data.flags], 4
  141. @@:
  142.         mov     [ebp+viewer_data.encoding], encodings.unicode
  143. .nounicode:
  144.         call    viewer_set_keybar
  145.         call    viewer_draw_text
  146.         ret
  147.  
  148. viewer_get_next_char:
  149.         pusha
  150.         cmp     [ebp+viewer_data.encoding], encodings.unicode
  151.         jnz     @f
  152.         cmp     [bForHex], 0
  153.         jnz     @f
  154.         cmp     dword [ebp+viewer_data.buf_start], 0
  155.         jnz     @f
  156.         cmp     dword [ebp+viewer_data.buf_start+4], 0
  157.         jnz     @f
  158.         lea     eax, [ebp+viewer_data.buf]
  159.         cmp     eax, [ebp+viewer_data.buf_pos]
  160.         jnz     @f
  161.         cmp     word [eax], 0xFFFE
  162.         jz      .skip
  163.         cmp     word [eax], 0xFEFF
  164.         jnz     @f
  165. .skip:
  166.         add     [ebp+viewer_data.buf_pos], 2
  167. @@:
  168.         mov     eax, [ebp+viewer_data.buf_pos]
  169.         lea     ecx, [ebp+viewer_data.buf]
  170.         add     ecx, [ebp+viewer_data.buf_size]
  171.         cmp     eax, ecx
  172.         jb      .buffered
  173.         mov     al, ' '
  174.         sub     ecx, ebp
  175.         cmp     ecx, viewer_data.buf + 16384
  176.         jb      .err
  177.         mov     eax, dword [ebp+viewer_data.buf_start]
  178.         add     eax, 8192
  179.         mov     dword [ebp+viewer_data.buf_start], eax
  180.         mov     edx, dword [ebp+viewer_data.buf_start+4]
  181.         adc     edx, 0
  182.         mov     dword [ebp+viewer_data.buf_start+4], edx
  183.         add     eax, 16384-8192
  184.         adc     edx, 0
  185.         mov     dword [readinfo.first], eax
  186.         mov     dword [readinfo.first+4], edx
  187.         mov     dword [readinfo.size], 8192
  188.         lea     edi, [ebp+viewer_data.buf]
  189.         lea     esi, [edi+8192]
  190.         mov     ecx, (16384-8192)/4
  191.         rep     movsd
  192.         mov     [readinfo.data], edi
  193.         lea     eax, [ebp+viewer_data.filename]
  194.         mov     [readinfo.name], eax
  195. .readretry:
  196.         mov     ebx, readinfo
  197.         push    70
  198.         pop     eax
  199.         mcall
  200.         test    eax, eax
  201.         jz      .readok
  202.         cmp     eax, 6
  203.         jz      .readok
  204.         call    ask_retry_ignore
  205.         jz      .readretry
  206. .readok:
  207.         sub     [ebp+viewer_data.buf_pos], 8192
  208.         add     ebx, 16384-8192
  209.         mov     [ebp+viewer_data.buf_size], ebx
  210.         mov     eax, [ebp+viewer_data.buf_pos]
  211.         cmp     ecx, 16384-8192
  212.         jnz     .buffered
  213. .err:
  214.         stc
  215.         popa
  216.         ret
  217. .buffered:
  218.         cmp     [ebp+viewer_data.encoding], encodings.unicode
  219.         jz      .unicode
  220.         mov     al, [eax]
  221. .done:
  222.         mov     [esp+28], al
  223.         inc     [ebp+viewer_data.buf_pos]
  224.         clc
  225.         popa
  226.         ret
  227.  
  228. .unicode:
  229.         inc     [ebp+viewer_data.buf_pos]
  230.         cmp     [bForHex], 0
  231.         jnz     @f
  232.         call    read_unicode_char
  233.         jmp     .done
  234. @@:
  235.         mov     ax, [eax]
  236.         mov     [esp+29], ah
  237.         jmp     .done
  238.  
  239. viewer_get_prev_char:
  240.         pusha
  241.         lea     ecx, [ebp+viewer_data.buf]
  242.         cmp     [ebp+viewer_data.buf_pos], ecx
  243.         ja      .buffered
  244.         mov     eax, dword [ebp+viewer_data.buf_start]
  245.         mov     edx, dword [ebp+viewer_data.buf_start+4]
  246.         test    eax, eax
  247.         jnz     @f
  248.         test    edx, edx
  249.         jnz     @f
  250.         stc
  251.         jmp     .ret
  252. @@:
  253.         sub     eax, 8192
  254.         sbb     edx, 0
  255.         jnc     @f
  256.         xor     eax, eax
  257.         xor     edx, edx
  258. @@:
  259.         call    viewer_seek
  260.         add     [ebp+viewer_data.buf_pos], 8192
  261. .buffered:
  262.         mov     eax, [ebp+viewer_data.buf_pos]
  263.         dec     eax
  264.         cmp     [ebp+viewer_data.encoding], encodings.unicode
  265.         jz      .unicode
  266.         mov     [ebp+viewer_data.buf_pos], eax
  267.         mov     al, [eax]
  268.         mov     [esp+28], al
  269. .done:
  270.         clc
  271. .ret:
  272.         popa
  273.         ret
  274.  
  275. .unicode:
  276.         dec     eax
  277.         mov     [ebp+viewer_data.buf_pos], eax
  278.         call    read_unicode_char
  279.         jmp     .done
  280.  
  281. read_unicode_char:
  282.         mov     ax, [eax]
  283. uni2ansi_char:
  284.         test    [ebp+viewer_data.flags], 4
  285.         jz      @f
  286.         xchg    al, ah
  287. @@:
  288.         cmp     ax, 0x80
  289.         jb      .ret
  290.         cmp     ax, 0x401
  291.         jz      .yo1
  292.         cmp     ax, 0x451
  293.         jz      .yo2
  294.         cmp     ax, 0x410
  295.         jb      .unk
  296.         cmp     ax, 0x440
  297.         jb      .rus1
  298.         cmp     ax, 0x450
  299.         jb      .rus2
  300. .unk:
  301.         mov     al, ' '
  302. .ret:
  303.         ret
  304. .yo1:
  305.         mov     al, 'ð'
  306.         ret
  307. .yo2:
  308.         mov     al, 'ñ'
  309.         ret
  310. .rus1:
  311. ; 0x410-0x43F -> 0x80-0xAF
  312.         add     al, 0x70
  313.         ret
  314. .rus2:
  315. ; 0x440-0x44F -> 0xE0-0xEF
  316.         add     al, 0xA0
  317.         ret
  318.  
  319. fld_uint64:
  320.         fild    qword [eax]
  321.         test    byte [eax+7], 80h
  322.         jz      .ret
  323.         fadd    [@f]
  324. .ret:
  325.         ret
  326. @@      dq      18446744073709551616.0 ;0x10000000000000000
  327.  
  328. viewer_draw_text:
  329.         call    viewer_seek_to_current
  330.         xor     eax, eax
  331.         xor     edx, edx
  332.         call    get_console_ptr
  333.         mov     ah, [view_status_color]
  334.         lea     esi, [ebp+viewer_data.filename]
  335.         mov     dl, 3
  336.         mov     ecx, [cur_width]
  337.         sub     ecx, 44
  338.         cmp     ecx, 20
  339.         jae     .5
  340.         mov     cl, 20
  341. .5:
  342.         lodsb
  343.         cmp     al, '/'
  344.         jnz     @f
  345.         dec     edx
  346.         jz      .6
  347. @@:
  348.         stosw
  349.         loop    .5
  350. .6:
  351.         dec     ecx
  352.         stosw
  353.         push    esi
  354. @@:
  355.         inc     esi
  356.         cmp     byte [esi-1], 0
  357.         jnz     @b
  358.         sub     esi, [esp]
  359.         dec     esi
  360.         cmp     ecx, esi
  361.         jae     .7
  362.         mov     al, '.'
  363.         stosw
  364.         stosw
  365.         stosw
  366.         sub     ecx, 3
  367.         sub     esi, ecx
  368.         add     [esp], esi
  369. .7:
  370.         pop     esi
  371. @@:
  372.         lodsb
  373.         test    al, al
  374.         jz      @f
  375.         dec     ecx
  376.         stosw
  377.         jmp     @b
  378. @@:
  379.         mov     al, ' '
  380.         add     ecx, 8
  381.         rep     stosw
  382.         movzx   esi, [ebp+viewer_data.encoding]
  383.         lea     esi, [encodings.names+esi*8]
  384.         mov     cl, 8
  385. @@:
  386.         lodsb
  387.         stosw
  388.         loop    @b
  389.         mov     al, ' '
  390.         mov     cl, 8
  391.         rep     stosw
  392.         std
  393.         push    edi
  394.         mov     edx, dword [ebp+viewer_data.filesize+4]
  395.         mov     eax, dword [ebp+viewer_data.filesize]
  396.         mov     cl, 10
  397. @@:
  398.         push    eax
  399.         mov     eax, edx
  400.         xor     edx, edx
  401.         div     ecx
  402.         xchg    eax, [esp]
  403.         div     ecx
  404.         xchg    eax, edx
  405.         add     al, '0'
  406.         mov     ah, [view_status_color]
  407.         stosw
  408.         xchg    eax, edx
  409.         pop     edx
  410.         test    eax, eax
  411.         jnz     @b
  412.         test    edx, edx
  413.         jnz     @b
  414.         mov     al, ' '
  415.         mov     ah, [view_status_color]
  416.         stosw
  417.         cld
  418.         pop     edi
  419.         inc     edi
  420.         inc     edi
  421.         mov     al, ' '
  422.         mov     cl, 5
  423.         rep     stosw
  424. if lang eq ru
  425.         mov     al, 'Š'
  426.         stosw
  427.         mov     al, '®'
  428.         stosw
  429.         mov     al, '«'
  430.         stosw
  431. else
  432.         mov     al, 'C'
  433.         stosw
  434.         mov     al, 'o'
  435.         stosw
  436.         mov     al, 'l'
  437.         stosw
  438. end if
  439.         mov     al, ' '
  440.         stosw
  441.         push    edi
  442.         mov     eax, dword [ebp+viewer_data.col]
  443.         mov     edx, dword [ebp+viewer_data.col+4]
  444.         test    edx, edx
  445.         jnz     .col_big
  446.         cmp     eax, 100000
  447.         jae     .col_big
  448.         mov     cl, 10
  449.         push    -'0'
  450. @@:
  451.         div     ecx
  452.         push    edx
  453.         xor     edx, edx
  454.         test    eax, eax
  455.         jnz     @b
  456. @@:
  457.         pop     eax
  458.         add     eax, '0'
  459.         jz      .col_done
  460.         mov     ah, [view_status_color]
  461.         stosw
  462.         jmp     @b
  463. .col_big:
  464.         push    eax
  465.         mov     al, '.'
  466.         mov     ah, [view_status_color]
  467.         stosw
  468.         stosw
  469.         stosw
  470.         xor     eax, eax
  471.         xchg    eax, edx
  472.         mov     cl, 100
  473.         div     ecx
  474.         pop     eax
  475.         div     ecx
  476.         mov     cl, 10
  477.         xor     eax, eax
  478.         xchg    eax, edx
  479.         div     ecx
  480.         add     al, '0'
  481.         mov     ah, [view_status_color]
  482.         stosw
  483.         mov     al, dl
  484.         add     al, '0'
  485.         stosw
  486. .col_done:
  487.         pop     ecx
  488.         add     ecx, 10*2
  489.         sub     ecx, edi
  490.         shr     ecx, 1
  491.         mov     al, ' '
  492.         mov     ah, [view_status_color]
  493.         rep     stosw
  494.         finit
  495.         fldcw   [fpu_cw]
  496.         mov     [tmp], 100
  497.         lea     eax, [ebp+viewer_data.filesize]
  498.         cmp     dword [eax], 0
  499.         jnz     @f
  500.         cmp     dword [eax+4], 0
  501.         jz      .size_zero
  502. @@:
  503.         call    fld_uint64
  504.         lea     eax, [ebp+viewer_data.cur_pos]
  505.         call    fld_uint64
  506.         fdivrp
  507.         fimul   [_100d]
  508.         fistp   [tmp]
  509. .size_zero:
  510.         mov     byte [edi-2], '%'
  511.         sub     edi, 4
  512.         mov     eax, [tmp]
  513.         mov     cl, 10
  514. @@:
  515.         xor     edx, edx
  516.         div     ecx
  517.         xchg    eax, edx
  518.         add     al, '0'
  519.         mov     [edi], al
  520.         sub     edi, 2
  521.         xchg    eax, edx
  522.         test    eax, eax
  523.         jnz     @b
  524.         xor     eax, eax
  525.         push    1
  526.         pop     edx
  527.         call    get_console_ptr
  528.         test    [ebp+viewer_data.flags], 1
  529.         jnz     .DrawHex
  530.         push    2
  531.         pop     edx
  532.         xor     ecx, ecx
  533.         mov     dword [scrpos], ecx
  534.         mov     dword [scrpos+4], ecx
  535.         mov     dword [viewer_right_side], ecx
  536.         mov     dword [viewer_right_side+4], ecx
  537. .1:
  538.         call    viewer_get_next_char
  539.         jc      .done
  540. .2:
  541.         cmp     al, 0xD
  542.         jz      .newline
  543.         cmp     al, 0xA
  544.         jz      .newline
  545.         cmp     ecx, [cur_width]
  546.         jb      .no_newline
  547.         test    [ebp+viewer_data.flags], 2
  548.         jnz     .no_newline
  549. .newline:
  550.         push    eax
  551.         mov     ecx, dword [scrpos]
  552.         mov     eax, dword [scrpos+4]
  553.         sub     ecx, dword [ebp+viewer_data.col]
  554.         sbb     eax, dword [ebp+viewer_data.col+4]
  555.         ja      .line_filled
  556.         jb      .line_full
  557.         cmp     ecx, [cur_width]
  558.         ja      .line_filled
  559.         jmp     @f
  560. .line_full:
  561.         xor     ecx, ecx
  562. @@:
  563.         test    ecx, ecx
  564.         jnz     @f
  565.         mov     eax, dword [scrpos]
  566.         or      eax, dword [scrpos+4]
  567.         jz      @f
  568.         inc     ecx
  569. @@:
  570.         sub     ecx, [cur_width]
  571.         neg     ecx
  572.         mov     al, ' '
  573.         mov     ah, [view_normal_color]
  574.         rep     stosw
  575. .line_filled:
  576.         mov     eax, dword [scrpos]
  577.         sub     eax, dword [viewer_right_side]
  578.         mov     eax, dword [scrpos+4]
  579.         sbb     eax, dword [viewer_right_side+4]
  580.         jb      @f
  581.         mov     eax, dword [scrpos]
  582.         mov     dword [viewer_right_side], eax
  583.         mov     eax, dword [scrpos+4]
  584.         mov     dword [viewer_right_side+4], eax
  585. @@:
  586.         xor     ecx, ecx
  587.         mov     dword [scrpos], ecx
  588.         mov     dword [scrpos+4], ecx
  589.         inc     edx
  590.         pop     eax
  591.         cmp     edx, [cur_height]
  592.         jae     .done
  593. .no_newline:
  594.         cmp     al, 0xD
  595.         jz      .3
  596.         cmp     al, 0xA
  597.         jz      .3
  598. .4:
  599.         test    al, al
  600.         jns     @f
  601.         movzx   esi, [ebp+viewer_data.encoding]
  602.         cmp     esi, encodings.unicode
  603.         jz      @f
  604.         shl     esi, 7
  605.         movzx   eax, al
  606.         mov     al, [encodings.tables-80h+esi+eax]
  607. @@:
  608.         cmp     al, 9
  609.         jz      .tab
  610.         call    .write_char
  611.         inc     ecx
  612.         jns     .1
  613.         push    edx
  614.         mov     eax, ecx
  615.         xor     edx, edx
  616.         div     [tabsize]
  617.         mov     ecx, edx
  618.         pop     edx
  619.         jmp     .1
  620. .3:
  621.         mov     bl, al
  622.         call    viewer_get_next_char
  623.         jc      .done
  624.         xor     bl, al
  625.         cmp     bl, 0xA xor 0xD
  626.         jz      .1
  627.         jmp     .2
  628. .tab:
  629.         push    edx
  630.         push    ecx
  631.         mov     eax, ecx
  632.         mov     ecx, [tabsize]
  633.         xor     edx, edx
  634.         div     ecx
  635.         pop     eax
  636.         sub     ecx, edx
  637.         add     eax, ecx
  638.         test    [ebp+viewer_data.flags], 2
  639.         jnz     @f
  640.         cmp     eax, [cur_width]
  641.         jbe     @f
  642.         sub     eax, [cur_width]
  643.         sub     ecx, eax
  644.         mov     eax, [cur_width]
  645. @@:
  646.         push    eax
  647.         mov     al, ' '
  648. @@:
  649.         call    .write_char
  650.         loop    @b
  651.         pop     ecx
  652.         pop     edx
  653.         jmp     .1
  654. .done:
  655.         setc    [ebp+viewer_data.bEofReached]
  656. .done2:
  657.         inc     edx
  658.         cmp     edx, [cur_height]
  659.         jnc     @f
  660.         mov     eax, dword [ebp+viewer_data.cur_pos]
  661.         or      eax, dword [ebp+viewer_data.cur_pos+4]
  662.         jz      @f
  663.         call    viewer_seek_to_current
  664.         call    viewer_prev_newline
  665.         jmp     viewer_draw_text
  666. @@:
  667.         push    edi
  668.         xor     eax, eax
  669.         mov     edx, [cur_height]
  670.         dec     edx
  671.         call    get_console_ptr
  672.         mov     ecx, edi
  673.         pop     edi
  674.         sub     ecx, edi
  675.         shr     ecx, 1
  676.         mov     al, ' '
  677.         mov     ah, [view_normal_color]
  678.         rep     stosw
  679.         cmp     [ebp+viewer_data.bEofReached], 0
  680.         jz      @f
  681.         xor     edx, edx
  682.         mov     eax, [cur_width]
  683.         sub     eax, 4
  684.         call    get_console_ptr
  685.         mov     ah, [view_status_color]
  686.         mov     al, '1'
  687.         stosw
  688.         mov     al, '0'
  689.         stosw
  690.         stosw
  691. @@:
  692.         call    draw_image
  693.         ret
  694. .DrawHex:
  695.         xor     esi, esi
  696.         mov     [ebp+viewer_data.bEofReached], 0
  697. .line:
  698.         mov     al, ' '
  699.         mov     ah, [view_normal_color]
  700.         push    edi
  701.         mov     ecx, [cur_width]
  702.         rep     stosw
  703.         mov     ebx, edi
  704.         pop     edi
  705.         mov     [bForHex], 1
  706.         call    viewer_get_next_char
  707.         mov     [bForHex], 0
  708.         jc      .hexdone
  709.         push    eax
  710.         push    edi
  711.         add     edi, 36*2
  712.         mov     al, 0xB3
  713.         mov     ah, [view_normal_color]
  714.         call    .safechar
  715.         pop     edi
  716.         mov     eax, dword [ebp+viewer_data.cur_pos]
  717.         mov     edx, dword [ebp+viewer_data.cur_pos+4]
  718.         push    esi
  719.         shl     esi, 4
  720.         add     eax, esi
  721.         adc     edx, 0
  722.         pop     esi
  723.         push    eax
  724.         mov     al, dl
  725.         shr     eax, 4
  726.         and     al, 0xF
  727.         call    .hex_digit
  728.         mov     al, dl
  729.         and     al, 0xF
  730.         call    .hex_digit
  731.         pop     eax
  732.         push    8
  733.         pop     ecx
  734.         add     edi, 7*2
  735.         std
  736. @@:
  737.         push    eax
  738.         and     al, 0xF
  739.         call    .hex_digit
  740.         pop     eax
  741.         shr     eax, 4
  742.         loop    @b
  743.         cld
  744.         add     edi, 9*2
  745.         mov     al, ':'
  746.         mov     ah, [view_normal_color]
  747.         stosw
  748.         mov     al, ' '
  749.         stosw
  750.         xor     ecx, ecx
  751.         pop     eax
  752.         jmp     @f
  753. .hexchar:
  754.         mov     [bForHex], 1
  755.         call    viewer_get_next_char
  756.         mov     [bForHex], 0
  757.         jc      .hexdone
  758. @@:
  759.         cmp     [ebp+viewer_data.encoding], encodings.unicode
  760.         jz      .hexchar_unicode
  761.         push    eax
  762.         shr     al, 4
  763.         call    .hex_digit
  764.         pop     eax
  765.         push    eax
  766.         and     al, 0xF
  767.         call    .hex_digit
  768.         mov     al, ' '
  769.         call    .safechar
  770.         pop     eax
  771.         push    edi
  772.         add     edi, 48*2
  773.         push    ecx
  774.         shl     ecx, 2
  775.         sub     edi, ecx
  776.         pop     ecx
  777.         cmp     ecx, 8
  778.         jb      @f
  779.         sub     edi, 4
  780. @@:
  781.         test    al, al
  782.         jns     @f
  783.         movzx   edx, [ebp+viewer_data.encoding]
  784.         shl     edx, 7
  785.         movzx   eax, al
  786.         mov     al, [encodings.tables+eax+edx-80h]
  787.         mov     ah, [view_normal_color]
  788. @@:
  789.         call    .safechar
  790.         pop     edi
  791.         inc     ecx
  792.         cmp     ecx, 8
  793.         jnz     @f
  794.         mov     al, 0xB3
  795.         call    .safechar
  796.         mov     al, ' '
  797.         call    .safechar
  798. @@:
  799.         cmp     ecx, 16
  800.         jnz     .hexchar
  801.         jmp     .hexchar_nextline
  802. .hexchar_unicode:
  803.         push    eax
  804.         shr     eax, 12
  805.         call    .hex_digit
  806.         pop     eax
  807.         push    eax
  808.         shr     eax, 8
  809.         and     al, 0xF
  810.         call    .hex_digit
  811.         pop     eax
  812.         push    eax
  813.         shr     al, 4
  814.         call    .hex_digit
  815.         pop     eax
  816.         push    eax
  817.         and     al, 0xF
  818.         call    .hex_digit
  819.         mov     al, ' '
  820.         mov     ah, [view_normal_color]
  821.         call    .safechar
  822.         pop     eax
  823.         push    edi
  824.         add     edi, 38*2
  825.         push    ecx
  826.         shl     ecx, 3
  827.         sub     edi, ecx
  828.         pop     ecx
  829.         cmp     ecx, 4
  830.         jb      @f
  831.         sub     edi, 4
  832. @@:
  833.         call    uni2ansi_char
  834.         mov     ah, [view_normal_color]
  835.         call    .safechar
  836.         pop     edi
  837.         inc     ecx
  838.         cmp     ecx, 4
  839.         jnz     @f
  840.         mov     al, 0xB3
  841.         call    .safechar
  842.         mov     al, ' '
  843.         call    .safechar
  844. @@:
  845.         cmp     ecx, 8
  846.         jnz     .hexchar
  847. .hexchar_nextline:
  848.         mov     edi, ebx
  849.         add     esi, 3
  850.         mov     edx, esi
  851.         cmp     esi, [cur_height]
  852.         jae     .done2
  853.         dec     esi
  854.         dec     esi
  855.         jmp     .line
  856. .hexdone:
  857.         mov     [ebp+viewer_data.bEofReached], 1
  858.         mov     edi, ebx
  859.         lea     edx, [esi+2]
  860.         jmp     .done2
  861.  
  862. .hex_digit:
  863.         push    eax
  864.         cmp     al, 10
  865.         sbb     al, 69h
  866.         das
  867.         mov     ah, [view_normal_color]
  868.         call    .safechar
  869.         pop     eax
  870.         ret
  871. .safechar:
  872.         cmp     edi, ebx
  873.         jae     @f
  874.         stosw
  875. @@:
  876.         ret
  877. .write_char:
  878.         push    ecx eax
  879.         mov     ecx, dword [scrpos]
  880.         mov     eax, dword [scrpos+4]
  881.         sub     ecx, dword [ebp+viewer_data.col]
  882.         sbb     eax, dword [ebp+viewer_data.col+4]
  883.         jb      .left
  884.         ja      .skip
  885.         test    ecx, ecx
  886.         jnz     @f
  887.         mov     eax, dword [scrpos]
  888.         or      eax, dword [scrpos+4]
  889.         jnz     .skip
  890. @@:
  891.         cmp     ecx, [cur_width]
  892.         ja      .skip
  893.         jb      .do
  894.         mov     al, '>'
  895.         mov     [edi-2], al
  896.         mov     al, [view_arrows_color]
  897.         mov     [edi-1], al
  898.         jmp     .skip
  899. .left:
  900.         mov     eax, dword [scrpos]
  901.         or      eax, dword [scrpos+4]
  902.         jnz     .skip
  903.         mov     al, '<'
  904.         mov     ah, [view_arrows_color]
  905.         stosw
  906.         jmp     .skip
  907. .do:
  908.         mov     al, [esp]
  909.         mov     ah, [view_normal_color]
  910.         stosw
  911. .skip:
  912.         pop     eax ecx
  913.         add     dword [scrpos], 1
  914.         adc     dword [scrpos+4], 0
  915.         ret
  916.  
  917. viewer_seek_to_current:
  918.         mov     eax, dword [ebp+viewer_data.cur_pos]
  919.         mov     edx, dword [ebp+viewer_data.cur_pos+4]
  920. viewer_seek:
  921.         push    eax edx
  922.         sub     eax, dword [ebp+viewer_data.buf_start]
  923.         sbb     edx, dword [ebp+viewer_data.buf_start+4]
  924.         jb      .prev
  925.         ja      .next
  926.         cmp     eax, 16384
  927.         jae     .next
  928.         lea     eax, [ebp+viewer_data.buf+eax]
  929.         mov     [ebp+viewer_data.buf_pos], eax
  930.         pop     edx eax
  931.         ret
  932. .prev:
  933.         inc     edx
  934.         jnz     .read_full
  935.         and     eax, not 511
  936.         cmp     eax, -16384
  937.         jbe     .read_full
  938.         lea     edi, [ebp+viewer_data.buf+16384-4]
  939.         lea     esi, [edi+eax]
  940.         lea     ecx, [eax+16384]
  941.         push    ecx
  942.         shr     ecx, 2
  943.         std
  944.         rep     movsd
  945.         cld
  946.         pop     ecx
  947.         add     dword [ebp+viewer_data.buf_start], eax
  948.         adc     dword [ebp+viewer_data.buf_start+4], -1
  949.         neg     eax
  950.         cmp     dword [ebp+viewer_data.buf_size], ecx
  951.         jb      .doread
  952.         mov     dword [ebp+viewer_data.buf_size], ecx
  953.         jmp     .doread
  954. .read_full:
  955.         pop     edx eax
  956.         push    eax edx
  957.         and     eax, not 511
  958.         sub     eax, 8192-512
  959.         sbb     edx, 0
  960.         jnc     @f
  961.         xor     eax, eax
  962.         xor     edx, edx
  963. @@:
  964.         mov     dword [ebp+viewer_data.buf_start], eax
  965.         mov     dword [ebp+viewer_data.buf_start+4], edx
  966.         and     dword [ebp+viewer_data.buf_size], 0
  967.         mov     eax, 16384
  968. .doread:
  969.         mov     ebx, readinfo
  970.         push    dword [ebp+viewer_data.buf_start]
  971.         pop     dword [ebx+4]
  972.         push    dword [ebp+viewer_data.buf_start+4]
  973.         pop     dword [ebx+8]
  974.         mov     [ebx+12], eax
  975.         lea     eax, [ebp+viewer_data.buf]
  976.         mov     [ebx+16], eax
  977.         lea     eax, [ebp+viewer_data.filename]
  978.         mov     [ebx+21], eax
  979.         push    70
  980.         pop     eax
  981.         mcall
  982.         test    eax, eax
  983.         jz      .readok
  984.         cmp     eax, 6
  985.         jz      .readok
  986.         call    ask_retry_ignore
  987.         jz      .doread
  988. .readok:
  989.         cmp     ebx, [readinfo.size]
  990.         jnz     @f
  991.         add     ebx, [ebp+viewer_data.buf_size]
  992. @@:
  993. .ret:
  994.         mov     [ebp+viewer_data.buf_size], ebx
  995.         pop     edx eax
  996.         sub     eax, dword [ebp+viewer_data.buf_start]
  997.         lea     eax, [ebp+eax+viewer_data.buf]
  998.         mov     [ebp+viewer_data.buf_pos], eax
  999.         ret
  1000. .next:
  1001.         or      eax, 511
  1002.         sub     eax, 16384-1
  1003.         sbb     edx, 0
  1004.         jnz     .read_full
  1005.         cmp     eax, 16384
  1006.         jae     .read_full
  1007.         cmp     [ebp+viewer_data.buf_size], 16384
  1008.         jb      .read_full
  1009.         lea     edi, [ebp+viewer_data.buf]
  1010.         lea     esi, [edi+eax]
  1011.         mov     ecx, 16384
  1012.         sub     ecx, eax
  1013.         shr     ecx, 2
  1014.         rep     movsd
  1015.         add     dword [ebp+viewer_data.buf_start], eax
  1016.         adc     dword [ebp+viewer_data.buf_start+4], 0
  1017.         mov     ebx, readinfo
  1018.         mov     [ebx+16], edi
  1019.         sub     edi, ebp
  1020.         sub     edi, viewer_data.buf
  1021.         mov     edx, dword [ebp+viewer_data.buf_start]
  1022.         add     edx, edi
  1023.         mov     [ebx+4], edx
  1024.         mov     edx, dword [ebp+viewer_data.buf_start+4]
  1025.         adc     edx, 0
  1026.         mov     [ebx+8], edx
  1027.         mov     [ebx+12], eax
  1028.         lea     eax, [ebp+viewer_data.filename]
  1029.         mov     [ebx+21], eax
  1030. @@:
  1031.         push    70
  1032.         pop     eax
  1033.         mcall
  1034.         test    eax, eax
  1035.         jz      @f
  1036.         cmp     eax, 6
  1037.         jz      @f
  1038.         call    ask_retry_ignore
  1039.         jnz     @f
  1040.         mov     ebx, readinfo
  1041.         jmp     @b
  1042. @@:
  1043.         sub     ebx, [readinfo.size]
  1044.         add     ebx, 16384
  1045.         jmp     .ret
  1046.  
  1047. ask_retry_ignore:
  1048.         push    esi
  1049.         lea     esi, [ebp+viewer_data.filename]
  1050.         push    esi
  1051.         push    aCannotReadFile
  1052.         call    get_error_msg
  1053.         push    eax
  1054.         mov     eax, esp
  1055.         push    RetryOrIgnoreBtn
  1056.         push    2
  1057.         push    eax
  1058.         push    3
  1059.         push    -1
  1060.         push    -1
  1061.         push    aError
  1062.         call    SayErr
  1063.         add     esp, 3*4
  1064.         pop     esi
  1065.         test    eax, eax
  1066.         ret
  1067.  
  1068. viewer_set_curpos:
  1069.         mov     eax, [ebp+viewer_data.buf_pos]
  1070.         sub     eax, ebp
  1071.         sub     eax, viewer_data.buf
  1072.         xor     edx, edx
  1073.         add     eax, dword [ebp+viewer_data.buf_start]
  1074.         adc     edx, dword [ebp+viewer_data.buf_start+4]
  1075.         mov     dword [ebp+viewer_data.cur_pos], eax
  1076.         mov     dword [ebp+viewer_data.cur_pos+4], edx
  1077.         ret
  1078.  
  1079. viewer_next_newline:
  1080.         test    [ebp+viewer_data.flags], 1
  1081.         jz      .nohex
  1082.         push    8
  1083.         pop     ecx
  1084.         cmp     [ebp+viewer_data.encoding], encodings.unicode
  1085.         jz      @f
  1086.         add     ecx, ecx
  1087. @@:
  1088.         call    viewer_get_next_char
  1089.         jc      @f
  1090.         loop    @b
  1091.         call    viewer_set_curpos
  1092.         clc
  1093. @@:     ret
  1094. .nohex:
  1095.         xor     ecx, ecx
  1096. @@:
  1097.         call    viewer_get_next_char
  1098.         jc      .ret
  1099.         cmp     al, 0xD
  1100.         jz      .1
  1101.         cmp     al, 0xA
  1102.         jz      .1
  1103.         cmp     al, 9
  1104.         jz      .tab
  1105.         inc     ecx
  1106. .next:
  1107.         test    [ebp+viewer_data.flags], 2
  1108.         jnz     @b
  1109.         cmp     ecx, [cur_width]
  1110.         jbe     @b
  1111.         call    viewer_get_prev_char
  1112.         jmp     .2
  1113. .tab:
  1114.         push    ecx
  1115.         mov     eax, ecx
  1116.         mov     ecx, [tabsize]
  1117.         xor     edx, edx
  1118.         div     ecx
  1119.         sub     ecx, edx
  1120.         add     [esp], ecx
  1121.         pop     ecx
  1122.         jmp     .next
  1123. .1:
  1124.         mov     cl, al
  1125.         call    viewer_get_next_char
  1126.         jc      .ret
  1127.         xor     cl, al
  1128.         cmp     cl, 0xD xor 0xA
  1129.         jz      .2
  1130.         dec     [ebp+viewer_data.buf_pos]
  1131.         cmp     [ebp+viewer_data.encoding], encodings.unicode
  1132.         jnz     .2
  1133.         dec     [ebp+viewer_data.buf_pos]
  1134. .2:
  1135. .ret:
  1136.         call    viewer_set_curpos
  1137.         ret
  1138.  
  1139. viewer_prev_newline:
  1140.         test    [ebp+viewer_data.flags], 1
  1141.         jz      .nohex
  1142.         push    8
  1143.         pop     ecx
  1144.         cmp     [ebp+viewer_data.encoding], encodings.unicode
  1145.         jz      @f
  1146.         add     ecx, ecx
  1147. @@:
  1148.         call    viewer_get_prev_char
  1149.         jc      @f
  1150.         loop    @b
  1151. @@:     call    viewer_set_curpos
  1152.         ret
  1153. .nohex:
  1154.         mov     eax, 8192
  1155.         push    eax
  1156.         cdq
  1157.         div     [cur_width]
  1158.         pop     eax
  1159.         sub     eax, edx
  1160.         mov     edx, eax
  1161.         call    viewer_get_prev_char
  1162.         jc      .0
  1163.         dec     edx
  1164.         cmp     al, 0xD
  1165.         jz      .2
  1166.         cmp     al, 0xA
  1167.         jnz     .3
  1168. .2:
  1169.         mov     cl, al
  1170.         call    viewer_get_prev_char
  1171.         jc      .0
  1172.         dec     edx
  1173.         xor     cl, al
  1174.         cmp     cl, 0xD xor 0xA
  1175.         jnz     .3
  1176. @@:
  1177.         call    viewer_get_prev_char
  1178.         jc      .0
  1179.         dec     edx
  1180.         jz      .0
  1181. .3:
  1182.         cmp     al, 0xD
  1183.         jz      .1
  1184.         cmp     al, 0xA
  1185.         jnz     @b
  1186. .1:
  1187.         call    viewer_get_next_char
  1188. .0:
  1189.         push    dword [ebp+viewer_data.cur_pos+4]
  1190.         push    dword [ebp+viewer_data.cur_pos]
  1191.         call    viewer_set_curpos
  1192. @@:
  1193.         push    dword [ebp+viewer_data.cur_pos+4]
  1194.         push    dword [ebp+viewer_data.cur_pos]
  1195.         call    viewer_next_newline
  1196.         jc      .ret3
  1197.         mov     eax, dword [ebp+viewer_data.cur_pos]
  1198.         mov     edx, dword [ebp+viewer_data.cur_pos+4]
  1199.         sub     eax, [esp+8]
  1200.         sbb     edx, [esp+12]
  1201.         jae     .ret3
  1202.         pop     eax
  1203.         pop     eax
  1204.         jmp     @b
  1205. .ret3:
  1206.         pop     dword [ebp+viewer_data.cur_pos]
  1207.         pop     dword [ebp+viewer_data.cur_pos+4]
  1208. .ret:
  1209.         pop     eax
  1210.         pop     eax
  1211.         jmp     viewer_seek_to_current
  1212.  
  1213. viewer_set_keybar:
  1214.         mov     eax, keybar_viewer
  1215. if lang eq ru
  1216.         test    [ebp+viewer_data.flags], 1
  1217.         jnz     .hex
  1218.         mov     dword [eax+(4-1)*6], 'Š®¤ '
  1219.         mov     word [eax+(4-1)*6+4], '  '
  1220.         jmp     @f
  1221. .hex:
  1222.         mov     dword [eax+(4-1)*6], '’¥ªá'
  1223.         mov     word [eax+(4-1)*6+4], 'â '
  1224. @@:
  1225.         test    [ebp+viewer_data.flags], 2
  1226.         jnz     .unwrap
  1227.         mov     dword [eax+6], ' §¢'
  1228.         mov     word [eax+6+4], '¥à'
  1229.         jmp     @f
  1230. .unwrap:
  1231.         mov     dword [eax+6], '‘¢¥à'
  1232.         mov     word [eax+6+4], '­ '
  1233. @@:
  1234. else
  1235.         test    [ebp+viewer_data.flags], 1
  1236.         jnz     .hex
  1237.         mov     dword [eax+(4-1)*6], 'Hex '
  1238. ;        mov     word [eax+(4-1)*6+4], '  '
  1239.         jmp     @f
  1240. .hex:
  1241.         mov     dword [eax+(4-1)*6], 'Text'
  1242. ;        mov     word [eax+(4-1)*6+4], '  '
  1243. @@:
  1244.         test    [ebp+viewer_data.flags], 2
  1245.         jnz     .unwrap
  1246.         mov     dword [eax+6], 'Unwr'
  1247.         mov     word [eax+6+4], 'ap'
  1248.         jmp     @f
  1249. .unwrap:
  1250.         mov     dword [eax+6], 'Wrap'
  1251.         mov     word [eax+6+4], '  '
  1252. @@:
  1253. end if
  1254.         movzx   esi, [ebp+viewer_data.encoding]
  1255.         dec     esi
  1256.         jz      @f
  1257.         push    1
  1258.         pop     esi
  1259. @@:
  1260.         lea     esi, [encodings.names+esi*8]
  1261.         lea     edi, [eax+keybar_cp-keybar_viewer]
  1262.         movsd
  1263.         movsw
  1264.         jmp     draw_keybar
  1265.  
  1266. viewer_OnRedraw:
  1267.         call    viewer_set_keybar
  1268.         call    viewer_draw_text
  1269.         ret
  1270.  
  1271. viewer_OnKey:
  1272.         mov     esi, viewer_ctrlkeys
  1273.         jmp     process_ctrl_keys
  1274. .exit:
  1275.         call    delete_active_screen
  1276.         ret
  1277. .down:
  1278.         cmp     [ebp+viewer_data.bEofReached], 0
  1279.         jnz     .ret
  1280.         call    viewer_seek_to_current
  1281.         call    viewer_next_newline
  1282.         jc      .ret
  1283.         call    viewer_draw_text
  1284.         ret
  1285. .pgdn:
  1286.         cmp     [ebp+viewer_data.bEofReached], 0
  1287.         jnz     .ret
  1288.         call    viewer_seek_to_current
  1289.         mov     ebx, [cur_height]
  1290.         sub     ebx, 3
  1291. @@:
  1292.         call    viewer_next_newline
  1293.         jc      .ret
  1294.         dec     ebx
  1295.         jnz     @b
  1296.         call    viewer_draw_text
  1297.         ret
  1298. .up:
  1299.         call    viewer_seek_to_current
  1300.         call    viewer_prev_newline
  1301.         call    viewer_draw_text
  1302.         ret
  1303. .pgup:
  1304.         call    viewer_seek_to_current
  1305.         mov     ebx, [cur_height]
  1306.         sub     ebx, 3
  1307. @@:
  1308.         call    viewer_prev_newline
  1309.         dec     ebx
  1310.         jnz     @b
  1311. .done_redraw:
  1312.         call    viewer_draw_text
  1313. .ret:
  1314.         ret
  1315. .f8:
  1316.         movzx   esi, [ebp+viewer_data.encoding]
  1317.         dec     [ebp+viewer_data.encoding]
  1318.         jz      .done_redraw_keybar
  1319.         mov     [ebp+viewer_data.encoding], 1
  1320.         jmp     .done_redraw_keybar
  1321. .f2:
  1322.         xor     [ebp+viewer_data.flags], 2
  1323. .done_redraw_keybar:
  1324.         call    viewer_set_keybar
  1325.         jmp     .done_redraw
  1326. .f4:
  1327.         xor     [ebp+viewer_data.flags], 1
  1328.         pushf
  1329.         call    viewer_set_keybar
  1330.         popf
  1331.         jnz     .tohex
  1332.         push    1
  1333.         pop     eax
  1334.         cmp     [ebp+viewer_data.encoding], encodings.unicode
  1335.         jnz     @f
  1336.         add     eax, eax
  1337. @@:
  1338.         add     dword [ebp+viewer_data.cur_pos], eax
  1339.         adc     dword [ebp+viewer_data.cur_pos+4], 0
  1340.         call    viewer_seek_to_current
  1341.         call    viewer_prev_newline
  1342.         jmp     .done_redraw
  1343. .tohex:
  1344.         and     byte [ebp+viewer_data.cur_pos], 0xF0
  1345.         jmp     .done_redraw
  1346. .home:
  1347.         xor     eax, eax
  1348.         mov     dword [ebp+viewer_data.cur_pos], eax
  1349.         mov     dword [ebp+viewer_data.cur_pos+4], eax
  1350.         mov     dword [ebp+viewer_data.col], eax
  1351.         mov     dword [ebp+viewer_data.col+4], eax
  1352.         jmp     .done_redraw
  1353. .end:
  1354.         mov     eax, dword [ebp+viewer_data.filesize]
  1355.         mov     edx, dword [ebp+viewer_data.filesize+4]
  1356.         and     al, 0xF0
  1357.         mov     dword [ebp+viewer_data.cur_pos], eax
  1358.         mov     dword [ebp+viewer_data.cur_pos+4], edx
  1359.         and     dword [ebp+viewer_data.col], 0
  1360.         and     dword [ebp+viewer_data.col+4], 0
  1361.         jmp     .done_redraw
  1362. .right:
  1363.         add     dword [ebp+viewer_data.col], 1
  1364.         adc     dword [ebp+viewer_data.col+4], 0
  1365.         jnc     .done_redraw
  1366.         sub     dword [ebp+viewer_data.col], 1
  1367.         sbb     dword [ebp+viewer_data.col+4], 0
  1368.         ret
  1369. .left:
  1370.         sub     dword [ebp+viewer_data.col], 1
  1371.         sbb     dword [ebp+viewer_data.col+4], 0
  1372.         jnc     .done_redraw
  1373.         add     dword [ebp+viewer_data.col], 1
  1374.         adc     dword [ebp+viewer_data.col+4], 0
  1375.         ret
  1376. .ctrl_left:
  1377.         test    [ebp+viewer_data.flags], 1
  1378.         jnz     .ctrl_left_hex
  1379.         sub     dword [ebp+viewer_data.col], 20
  1380.         sbb     dword [ebp+viewer_data.col+4], 0
  1381.         jnc     .done_redraw
  1382. .ctrl_shift_left:
  1383.         and     dword [ebp+viewer_data.col], 0
  1384.         and     dword [ebp+viewer_data.col+4], 0
  1385.         jmp     .done_redraw
  1386. .ctrl_left_hex:
  1387.         call    viewer_seek_to_current
  1388.         call    viewer_get_prev_char
  1389.         jc      @f
  1390.         call    viewer_set_curpos
  1391.         jmp     .done_redraw
  1392. .ctrl_right:
  1393.         test    [ebp+viewer_data.flags], 1
  1394.         jnz     .ctrl_right_hex
  1395.         add     dword [ebp+viewer_data.col], 20
  1396.         adc     dword [ebp+viewer_data.col+4], 0
  1397.         jnc     .done_redraw
  1398.         sub     dword [ebp+viewer_data.col], 20
  1399.         sbb     dword [ebp+viewer_data.col+4], 0
  1400. @@:     ret
  1401. .ctrl_right_hex:
  1402.         call    viewer_seek_to_current
  1403.         call    viewer_get_next_char
  1404.         call    viewer_set_curpos
  1405.         jmp     .done_redraw
  1406. .ctrl_shift_right:
  1407.         test    [ebp+viewer_data.flags], 1
  1408.         jnz     @b
  1409.         mov     eax, dword [viewer_right_side]
  1410.         mov     edx, dword [viewer_right_side+4]
  1411.         sub     eax, [cur_width]
  1412.         sbb     edx, 0
  1413.         jnc     @f
  1414.         xor     eax, eax
  1415.         xor     edx, edx
  1416. @@:
  1417.         mov     dword [ebp+viewer_data.col], eax
  1418.         mov     dword [ebp+viewer_data.col+4], edx
  1419.         jmp     .done_redraw
  1420. .shift_f8:
  1421.         mov     ecx, encodings.menu.1
  1422.         mov     al, [ebp+viewer_data.encoding]
  1423. @@:
  1424.         cmp     byte [ecx-1], al
  1425.         jz      @f
  1426.         mov     ecx, [ecx]
  1427.         jmp     @b
  1428. @@:
  1429.         push    1
  1430.         push    aTables
  1431.         push    ecx
  1432.         call    menu
  1433.         cmp     eax, -1
  1434.         jz      .ret
  1435.         mov     al, [eax-1]
  1436.         mov     [ebp+viewer_data.encoding], al
  1437.         cmp     al, encodings.unicode
  1438.         jnz     .done_redraw_keybar
  1439.         add     dword [ebp+viewer_data.cur_pos], 1
  1440.         adc     dword [ebp+viewer_data.cur_pos+4], 0
  1441.         and     dword [ebp+viewer_data.cur_pos], not 1
  1442.         jmp     .done_redraw_keybar
  1443.  
  1444. viewer_getname:
  1445. if lang eq ru
  1446.         mov     eax, 'à®á'
  1447.         stosd
  1448.         mov     eax, '¬®âà'
  1449.         stosd
  1450.         mov     eax, '    '
  1451.         stosd
  1452.         stosb
  1453. else
  1454.         mov     eax, 'View'
  1455.         stosd
  1456.         mov     eax, '    '
  1457.         stosd
  1458.         stosd
  1459.         stosb
  1460. end if
  1461.         sub     ecx, 13
  1462.         lea     esi, [ebp+viewer_data.filename]
  1463.         push    3
  1464.         pop     edx
  1465. @@:
  1466.         lodsb
  1467.         stosb
  1468.         dec     ecx
  1469.         cmp     al, '/'
  1470.         jnz     @b
  1471.         dec     edx
  1472.         jnz     @b
  1473.         push    esi
  1474. @@:
  1475.         lodsb
  1476.         test    al, al
  1477.         jnz     @b
  1478.         sub     esi, [esp]
  1479.         dec     esi
  1480.         cmp     esi, ecx
  1481.         jbe     @f
  1482.         mov     al, '.'
  1483.         stosb
  1484.         stosb
  1485.         stosb
  1486.         sub     ecx, 3
  1487.         sub     esi, ecx
  1488.         add     [esp], esi
  1489. @@:
  1490.         pop     esi
  1491. @@:
  1492.         lodsb
  1493.         stosb
  1494.         test    al, al
  1495.         jnz     @b
  1496.         ret
  1497.