Subversion Repositories Kolibri OS

Rev

Rev 259 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;-----------------------------------------------------------------------------
  2. func save_file ;//////////////////////////////////////////////////////////////
  3. ;-----------------------------------------------------------------------------
  4.         ret     ; DISALLOW FOR NOW
  5.  
  6.         mov     esi,tb_opensave.text
  7.         mov     edi,f_info.path
  8.         movzx   ecx,[tb_opensave.length]
  9.         mov     [f_info.length],ecx
  10.         cld
  11.         rep     movsb
  12.         mov     byte[edi],0
  13.  
  14.         mov     esi,[cur_editor.Lines] ;! AREA_EDIT     ; 0x70000 = 448 Kbytes (maximum)
  15.         mov     edi,0 ;!!! AREA_TEMP
  16.  
  17.   .new_string:
  18.         call    save_string
  19.         cmp     dword[esi],0
  20.         jne     .new_string
  21.         sub     edi,0 ;!!! AREA_TEMP+2   ; minus last CRLF
  22. ;!      mov     [filelen],edi
  23.         cmp     byte[f_info.path],'/'
  24.         je      .systree_save
  25.         mcall   33,f_info.path,0,edi,0 ;!!! AREA_TEMP,edi,0;[filelen],0
  26.         or      eax,eax
  27.         jz      .exit
  28. ;       call    file_not_found
  29.         jmp     .exit.2
  30.  
  31.   .systree_save:
  32.         mov     [f_info70+0],2
  33.         mov     [f_info70+12],edi
  34.         mov     [f_info70+16],0 ;!!! AREA_TEMP
  35.         mov     byte[f_info70+20],0
  36.         mov     [f_info70+21],f_info.path
  37.         mcall   70,f_info70
  38.  
  39.         call    set_status_fs_error
  40.  
  41.         or      eax,eax
  42.         jnz     .exit.2
  43.  
  44.   .exit:
  45.         mov     [cur_editor.Modified],0 ;! [modified],0
  46.         clc
  47.         ret
  48.  
  49.   .exit.2:
  50.         stc
  51.         ret
  52. endf
  53.  
  54. ;-----------------------------------------------------------------------------
  55. func save_string ;////////////////////////////////////////////////////////////
  56. ;-----------------------------------------------------------------------------
  57.         movzx   ecx,word[esi]
  58.         test    dword[esi],0x00010000
  59.         jz      @f
  60.         or      dword[esi],0x00020000
  61.     @@: add     esi,4
  62. ;       mov     ecx,eax
  63.  
  64.     @@: cmp     byte[esi+ecx-1],' '
  65.         jne     @f
  66.         loop    @b
  67.     @@: jecxz   .endcopy
  68.         xor     edx,edx
  69.         mov     ebx,edx
  70.         mov     ah,dl
  71.  
  72.   .next_char:
  73.         mov     al,[esi+ebx]
  74.         inc     ebx
  75. ;        cmp     [asm_mode],0
  76. ;        je      .put
  77.         test    [options],OPTS_OPTIMSAVE
  78.         jz      .put
  79.         test    ah,00000001b
  80.         jnz     .char
  81.         cmp     al,'"'
  82.         jne     @f
  83.         xor     ah,00000100b
  84.         jmp     .char
  85.     @@: cmp     al,"'"
  86.         jne     @f
  87.         xor     ah,00000010b
  88.         jmp     .char
  89.     @@: test    ah,00000110b
  90.         jnz     .char
  91.         cmp     al,';'
  92.         jne     @f
  93.         test    ah,00000001b
  94.         jnz     .char
  95.         xor     ah,00000001b
  96.         jmp     .char
  97.     @@: cmp     al,' '
  98.         jne     .char
  99.         inc     edx
  100.         test    ebx,ATABW-1
  101.         jnz     @f
  102.         dec     edx
  103.         jle     .put
  104.         mov     al,9
  105.         xor     edx,edx
  106.         jmp     .put
  107.   .char:
  108.         or      edx,edx
  109.         jz      .put
  110.         push    ecx eax
  111.         mov     ecx,edx
  112.         mov     al,' '
  113.         rep     stosb
  114.         pop     eax ecx
  115.         xor     edx,edx
  116.   .put:
  117.         stosb
  118.     @@: loop    .next_char
  119.  
  120.   .endcopy:
  121.         mov     eax,0x0A0D
  122.         stosw
  123.         movzx   eax,word[esi-4]
  124.         add     esi,eax;[esi-4]
  125.         ret
  126. endf
  127.  
  128. func set_status_fs_error
  129.         push    eax
  130.         mov     esi,s_fs_error
  131.     @@: dec     eax
  132.         js      @f
  133.         movzx   ecx,byte[esi]
  134.         lea     esi,[esi+ecx+1]
  135.         jmp     @b
  136.     @@: inc     esi
  137.         mov     [s_status],esi
  138.         pop     eax
  139.         call    draw_statusbar
  140.         ret
  141. endf
  142.  
  143. ;-----------------------------------------------------------------------------
  144. func load_file ;//////////////////////////////////////////////////////////////
  145. ;-----------------------------------------------------------------------------
  146.         mov     esi,tb_opensave.text
  147.         mov     edi,f_info.path
  148.         movzx   ecx,[tb_opensave.length]
  149.         mov     [f_info.length],ecx
  150.         cld
  151.         rep     movsb
  152.         mov     byte[edi],0
  153.  
  154.         xor     eax,eax
  155.         mov     [f_info70+0],5
  156.         mov     [f_info70+4],eax
  157.         mov     [f_info70+8],eax
  158.         mov     [f_info70+12],eax
  159.         mov     [f_info70+16],file_info
  160.         mov     byte[f_info70+20],al
  161.         mov     [f_info70+21],f_info.path
  162.         mcall   70,f_info70
  163.         mov     [f_info70+0],0
  164.         mov     eax,dword[file_info.Size]
  165.         mov     [f_info70+12],eax
  166.         call    mem.Alloc
  167.         mov     [f_info70+16],eax
  168.         mcall   70,f_info70
  169.  
  170.         call    set_status_fs_error
  171.  
  172.         mov     esi,[f_info70+16]
  173.  
  174.         xchg    eax,ebx
  175.         test    ebx,ebx
  176.         je      .file_found
  177.         cmp     ebx,6            ;// ATV driver fix (6 instead of 5)
  178.         je      .file_found
  179.  
  180.         mov     eax,[f_info70+16]
  181.         call    mem.Free
  182.         stc
  183.         ret
  184.  
  185.   .file_found:
  186.         mov     ecx,eax
  187.         call    create_tab
  188.         push    ecx esi edi
  189.         mov     esi,tb_opensave.text
  190.         lea     edi,[ebp+TABITEM.Editor.FilePath]
  191.         movzx   ecx,[tb_opensave.length]
  192.         rep     movsb
  193.         mov     byte[edi],0
  194.         lea     edi,[ebp+TABITEM.Editor.FilePath]
  195.         movzx   ecx,[tb_opensave.length]
  196.     @@: cmp     byte[edi+ecx-1],'/'
  197.         je      @f
  198.         dec     ecx
  199.         jmp     @b
  200.     @@: mov     [ebp+TABITEM.Editor.FileName],ecx
  201.         call    flush_cur_tab
  202.         pop     edi esi ecx
  203.         call    load_from_memory
  204.         mov     eax,[f_info70+16]
  205.         call    mem.Free
  206.         clc
  207.         ret
  208. endf
  209.  
  210. ;-----------------------------------------------------------------------------
  211. func load_from_memory ;///////////////////////////////////////////////////////
  212. ;-----------------------------------------------------------------------------
  213. ; ECX = data length
  214. ; ESI = data pointer
  215. ; EBP = EDITOR*
  216. ;-----------------------------------------------------------------------------
  217.         call    get_lines_in_file
  218.         inc     eax
  219.         mov     [ebp+EDITOR.Lines.Count],eax
  220.         imul    ebx,eax,14
  221.         add     ebx,ecx
  222.         mov     eax,[ebp+EDITOR.Lines]
  223.         call    mem.ReAlloc
  224.         mov     [ebp+EDITOR.Lines],eax
  225.  
  226.         mov     [ebp+EDITOR.Columns.Count],0
  227.         mov     edi,eax
  228.         mov     edx,ecx
  229.  
  230.   .next_line:
  231.         mov     ebx,edi
  232.         add     edi,4
  233.   .next_char:
  234.         or      edx,edx
  235.         jle     .exit
  236.         lodsb
  237.         dec     edx
  238.         cmp     al,13
  239.         je      .CR
  240.         cmp     al,10
  241.         je      .LF
  242.         cmp     al,9
  243.         je      .TB
  244.         cmp     al,0
  245.         je      .exit
  246.         stosb
  247.         jmp     .next_char
  248.  
  249.   .exit:
  250.         mov     ecx,10
  251.         mov     al,' '
  252.         rep     stosb
  253.         lea     eax,[edi-4]
  254.         sub     eax,ebx
  255.         mov     [ebx],eax
  256.         mov     dword[ebx+eax+4],0
  257.         sub     eax,10
  258.         jnz     @f
  259.         inc     eax
  260.     @@: cmp     eax,[ebp+EDITOR.Columns.Count] ;! eax,[columns]
  261.         jbe     @f
  262.         mov     [ebp+EDITOR.Columns.Count],eax ;! [columns],eax
  263.     @@: mov     [ebp+EDITOR.Modified],0 ;! [modified],0
  264.         ret
  265.  
  266.   .CR:  cmp     byte[esi],10
  267.         jne     .LF
  268.         lodsb
  269.         dec     edx
  270.   .LF:  mov     ecx,10
  271.         mov     al,' '
  272.         rep     stosb
  273.         lea     eax,[edi-4]
  274.         sub     eax,ebx
  275.         mov     [ebx],eax
  276. ;       inc     [cur_editor.Lines] ;! [lines]
  277.         add     eax,-10
  278.         cmp     eax,[ebp+EDITOR.Columns.Count] ;! eax,[columns]
  279.         jbe     .next_line
  280.         mov     [ebp+EDITOR.Columns.Count],eax ;! [columns],eax
  281.         jmp     .next_line
  282.  
  283.   .TB:  lea     eax,[edi-4]
  284.         sub     eax,ebx
  285.         mov     ecx,eax
  286.         add     ecx,ATABW
  287.         and     ecx,not(ATABW-1)
  288.         sub     ecx,eax
  289.         mov     al,' '
  290.         rep     stosb
  291.         jmp     .next_char
  292. endf
  293.