From 06a1a8f6a3b48c816ae52e6dda39626e302fa75b Mon Sep 17 00:00:00 2001 From: "Evgeny Grechnikov (Diamond)" Date: Wed, 2 May 2007 12:19:54 +0000 Subject: [PATCH] * KFar 0.32. * smtps modified to use function 70 and standard header in function 0. git-svn-id: svn://kolibrios.org@474 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/fs/kfar/trunk/dialogs.inc | 220 +- programs/fs/kfar/trunk/filetool.inc | 226 +++ programs/fs/kfar/trunk/font.inc | 112 +- programs/fs/kfar/trunk/kfar.asm | 2555 +++++++++++++++++------- programs/fs/kfar/trunk/memalloc.inc | 517 ----- programs/fs/kfar/trunk/tools.inc | 218 +- programs/fs/kfar/trunk/viewer.inc | 207 +- programs/network/smtps/trunk/smtps.asm | 60 +- 8 files changed, 2765 insertions(+), 1350 deletions(-) create mode 100644 programs/fs/kfar/trunk/filetool.inc delete mode 100644 programs/fs/kfar/trunk/memalloc.inc diff --git a/programs/fs/kfar/trunk/dialogs.inc b/programs/fs/kfar/trunk/dialogs.inc index f1f30ed0c2..553bce0b8e 100644 --- a/programs/fs/kfar/trunk/dialogs.inc +++ b/programs/fs/kfar/trunk/dialogs.inc @@ -27,6 +27,8 @@ GenericBox: pushad mov ebx, [esp+20h+4] ; center window if required + push [ebx+dlgtemplate.x] + push [ebx+dlgtemplate.y] cmp [ebx+dlgtemplate.x], -1 jnz @f mov eax, [cur_width] @@ -59,6 +61,8 @@ GenericBox: cmp [ebx+dlgtemplate.border_size_y], 1 jge .sizeok .sizeerr: + pop [ebx+dlgtemplate.y] + pop [ebx+dlgtemplate.x] popad or eax, -1 ret 8 @@ -73,11 +77,11 @@ GenericBox: jz @f mov edi, warning_colors .setcolor: - mov al, [dialog_main_color-dialog_colors+edi] + mov al, [edi + dialog_main_color-dialog_colors] mov [ebx+dlgtemplate.main_color], al - mov al, [dialog_border_color-dialog_colors+edi] + mov al, [edi + dialog_border_color-dialog_colors] mov [ebx+dlgtemplate.border_color], al - mov al, [dialog_header_color-dialog_colors+edi] + mov al, [edi + dialog_header_color-dialog_colors] mov [ebx+dlgtemplate.header_color], al @@: ; allocate memory for data under dialog @@ -95,10 +99,12 @@ GenericBox: add edx, [ebx+dlgtemplate.border_size_y] inc edx mul edx - add eax, eax - call mf_alloc + lea ecx, [eax*2] + call xpgalloc test eax, eax jnz @f + pop [ebx+dlgtemplate.y] + pop [ebx+dlgtemplate.x] popad or eax, -1 ret 8 @@ -296,7 +302,7 @@ GenericBox: dec edx jnz @b ; send redraw message - mov eax, [esp+20h+8] + mov eax, [esp+28h+8] push ebx ebp push 0 push 0 @@ -347,7 +353,7 @@ GenericBox: jz .alt_down cmp al, 0xB8 jz .alt_up - mov ecx, [esp+20h+8] + mov ecx, [esp+28h+8] push ebx ebp push 0 push eax @@ -357,7 +363,7 @@ GenericBox: pop ebp ebx test eax, eax jz .event - mov [esp+28], eax + mov [esp+8+28], eax jmp .exit .ctrl_down: test ah, ah @@ -430,9 +436,11 @@ GenericBox: call draw_keybar cmp ebx, nomem_dlgdata jz @f - mov eax, ebp - call mf_free + mov ecx, ebp + call pgfree @@: + pop [ebx+dlgtemplate.y] + pop [ebx+dlgtemplate.x] or [cursor_x], -1 or [cursor_y], -1 call draw_image @@ -548,14 +556,14 @@ menu: ; void* variants, const char* title, unsigned flags); menu_centered_in: pushad - mov eax, 56 + mov ecx, 56 ; 36 bytes for dlgtemplate + additional: ; +36: dd cur_variant ; +40: dd num_variants ; +44: dd begin_variant ; +48: dd end_variant ; +52: dd cur_variant_idx - call xmalloc + call xpgalloc test eax, eax jnz @f .ret_bad: @@ -700,8 +708,8 @@ menu_centered_in: push ebx call GenericBox mov [esp+28], eax - mov eax, ebx - call mf_free + mov ecx, ebx + call pgfree popad ret 28 @@ -715,6 +723,33 @@ MenuDlgProc: .draw: call .dodraw ret 16 +.prev: + mov eax, [ebx+36] + cmp dword [eax+4], 0 + jz .end + call .line_prev +.posret: + mov [ebx+36], eax +.redraw: + call .dodraw + call draw_image + xor eax, eax + ret 16 +.next: + mov eax, [ebx+36] + cmp dword [eax], 0 + jz .home + call .line_next + jmp .posret +.pgdn: + mov eax, [ebx+36] + mov ecx, [ebx+dlgtemplate.height] +.pgdnl: + cmp dword [eax], 0 + jz .posret + call .line_next + loop .pgdnl + jmp .posret .key: mov al, [esp+12] cmp al, 0x48 @@ -773,33 +808,6 @@ MenuDlgProc: call .line_prev loop .pgupl jmp .posret -.prev: - mov eax, [ebx+36] - cmp dword [eax+4], 0 - jz .end - call .line_prev -.posret: - mov [ebx+36], eax -.redraw: - call .dodraw - call draw_image - xor eax, eax - ret 16 -.next: - mov eax, [ebx+36] - cmp dword [eax], 0 - jz .home - call .line_next - jmp .posret -.pgdn: - mov eax, [ebx+36] - mov ecx, [ebx+dlgtemplate.height] -.pgdnl: - cmp dword [eax], 0 - jz .posret - call .line_next - loop .pgdnl - jmp .posret .home: mov eax, [ebx+36] @@: @@ -1083,6 +1091,7 @@ ManagerDlgProc: ret 16 @@: lea ebx, [ebp+dlgtemplate.size+12] + mov ecx, [ebx-4] .enter_find: cmp [ebx+dlgitemtemplate.type], 2 jnz @f @@ -1090,7 +1099,8 @@ ManagerDlgProc: jnz .enter_found @@: add ebx, dlgitemtemplate.size - jmp .enter_find + loop .enter_find + jmp .enter_found .tab: test [ctrlstate], 3 jnz .shift_tab @@ -1159,46 +1169,14 @@ ManagerDlgProc: cmp al, 0x0E jz .editor_backspace cmp al, 0x53 - jz .editor_del - test [ctrlstate], 0x3C - jnz .ret_draw -; query keyboard layout - pushad - push 26 - pop eax - push 2 - pop ebx - xor ecx, ecx - cmp [ctrlstate], 1 - sbb ecx, -2 - mov edx, layout - int 0x40 - popad -; translate scancode to ASCII - movzx eax, al - movzx eax, byte [layout+eax] - push eax -; insert entered symbol - xor eax, eax - lea edi, [edx+12] - or ecx, -1 - repnz scasb - not ecx - pop eax - cmp ecx, [edx] - ja .ret_test ; buffer capacity exceeded - lea edi, [edx+ecx+12-1] - mov esi, [edx+4] - lea esi, [edx+esi+12] -@@: - mov cl, [edi] - mov [edi+1], cl - dec edi - cmp edi, esi - jae @b - mov [esi], al - inc dword [edx+4] -@@: jmp .ret_test + jnz .editor_char +.editor_del: + mov ecx, [edx+4] + lea edi, [ecx+edx+12] + lea esi, [edi+1] + cmp byte [edi], 0 + jz .ret_test + jmp .copy_and_ret_test .editor_left: mov ecx, [edx+4] jecxz @f @@ -1248,13 +1226,46 @@ ManagerDlgProc: test al, al jnz @b jmp .ret_test -.editor_del: - mov ecx, [edx+4] - lea edi, [ecx+edx+12] - lea esi, [edi+1] - cmp byte [edi], 0 - jz .ret_test - jmp .copy_and_ret_test +.editor_char: + test [ctrlstate], 0x3C + jnz .ret_draw +; query keyboard layout + pushad + push 26 + pop eax + push 2 + pop ebx + xor ecx, ecx + cmp [ctrlstate], 1 + sbb ecx, -2 + mov edx, layout + int 0x40 + popad +; translate scancode to ASCII + movzx eax, al + movzx eax, byte [layout+eax] + push eax +; insert entered symbol + xor eax, eax + lea edi, [edx+12] + or ecx, -1 + repnz scasb + not ecx + pop eax + cmp ecx, [edx] + ja .ret_test ; buffer capacity exceeded + lea edi, [edx+ecx+12-1] + mov esi, [edx+4] + lea esi, [edx+esi+12] +@@: + mov cl, [edi] + mov [edi+1], cl + dec edi + cmp edi, esi + jae @b + mov [esi], al + inc dword [edx+4] +@@: jmp .ret_test .dodraw: or [cursor_x], -1 @@ -1434,6 +1445,16 @@ SayNoMem: ; int num_strings, const char* strings[], ; int num_buttons, const char* buttons[]); ; may be x=-1 and/or y=-1 +SayErr: + push 2 + jmp @f + +; int __stdcall Message(const char* title, int x, int y, +; int num_strings, const char* strings[], +; int num_buttons, const char* buttons[]); +Message: + push 1 +@@: ; [esp+4] = title ; [esp+8] = x ; [esp+12] = y @@ -1441,21 +1462,22 @@ SayNoMem: ; [esp+20] = strings ; [esp+24] = num_buttons ; [esp+28] = buttons -SayErr: - mov eax, [esp+16] - add eax, [esp+24] - imul eax, dlgitemtemplate.size - add eax, dlgtemplate.size+12 - call xmalloc + pop eax + pushad + mov ecx, [esp+4+16] + add ecx, [esp+4+24] + imul ecx, dlgitemtemplate.size + add ecx, dlgtemplate.size+12 + call xpgalloc test eax, eax jnz @f + popad or eax, -1 ret 28 @@: - pushad mov ebx, eax mov edi, eax - mov eax, 2 + mov eax, [esp+28] stosd ; dlgtemplate.flags mov eax, [esp+32+8] stosd ; dlgtemplate.x @@ -1592,7 +1614,7 @@ SayErr: sub eax, [esp+32+16] @@: mov [esp+28], eax - mov eax, ebx - call mf_free + mov ecx, ebx + call pgfree popad ret 28 diff --git a/programs/fs/kfar/trunk/filetool.inc b/programs/fs/kfar/trunk/filetool.inc new file mode 100644 index 0000000000..48a51c53fa --- /dev/null +++ b/programs/fs/kfar/trunk/filetool.inc @@ -0,0 +1,226 @@ +delete_file_worker: +; in: ecx=flags: 1=deleting directory +; out: eax=0 - OK, eax=1 - retry, eax=2 - skip, eax=-1 - cancel, +; PF, ZF, CF and SF set accordingly to 'cmp eax,2' (or 'cmp al,2') + push ebx + push 70 + pop eax + mov ebx, delinfo + int 0x40 + pop ebx + test eax, eax + jz .ret + cmp [del_bSkipAll], 0 + jz @f + push 2 + pop eax + jmp .ret +@@: + push execdata + push aCannotDeleteFolder + test cl, 1 + jnz @f + mov dword [esp], aCannotDeleteFile +@@: + call get_error_msg + push eax + mov eax, esp + push DeleteErrorBtn + push 4 + push eax + push 3 + push -1 + push -1 + push aError + call SayErr + add esp, 3*4 + cmp al, -1 + jz @f + inc eax + cmp al, 4 ; "cancel" button + jnz @f + or eax, -1 +@@: + cmp al, 3 ; "skip all" button + jnz .ret + mov [del_bSkipAll], 1 + dec eax +.ret: + cmp al, 2 + ret + +delete_file: +; in: eax->BDFE block +; out: CF and ZF not set <=> cancel job ("ja cancel_label") + pushad + mov [del_dir_stack_ptr], del_dir_stack + lea esi, [ebp + panel1_dir - panel1_data] + mov edi, execdata +@@: + lodsb + test al, al + jz @f + stosb + jmp @b +@@: + mov esi, [esp+28] + mov ecx, esi + add esi, 40 + mov al, '/' + stosb +.l1: + lodsb + cmp edi, execdataend + jb @f + call panels_OnKey.bigfilename + popad + ret +@@: + stosb + test al, al + jnz .l1 + mov ecx, [esp+28] + test byte [ecx], 10h + jnz .delete_dir +.retrydel: + xor ecx, ecx + call delete_file_worker + jae @f + jp .retrydel +@@: + popad + ret + +.delete_dir: +; recursive delete of directory + xor ebp, ebp ; ebp will contain number of undeletable items +.return_from_recursion: + mov ebx, dirinfo + mov [ebx+dirinfo.first-dirinfo], ebp + mov [ebx+dirinfo.size-dirinfo], del_dir_query_size + mov [ebx+dirinfo.dirdata-dirinfo], del_dir_query_area + mov [ebx+dirinfo.name-dirinfo], execdata + push 70 + pop eax + int 0x40 +; if we get read error, the best available action is try to delete directory itself + test eax, eax + jz @f + cmp eax, 6 + jnz .do_delete_dir +@@: +; loop through a directory and delete items + mov edx, del_dir_query_area+32 + imul ebx, 304 + add ebx, edx +.delete_dir_entry_loop: + cmp edx, ebx + jae .delete_dir_entry_done +; ignore special entries "." and ".." + inc ebp + cmp word [edx+40], '.' + jz .delete_dir_entry_continue + cmp word [edx+40], '..' + jnz @f + cmp byte [edx+42], 0 + jz .delete_dir_entry_continue +@@: + dec ebp + mov esi, execdata +@@: + lodsb + test al, al + jnz @b + mov byte [esi-1], '/' + mov edi, esi + lea esi, [edx+40] +@@: + cmp edi, execdataend + jae .fullname_big + lodsb + stosb + test al, al + jnz @b + test byte [edx], 10h + jnz .entry_is_folder +.retry2: + xor ecx, ecx + call delete_file_worker + ja .cancel + jz .skip + jp .retry2 + jmp .restore_name +.entry_is_folder: +; allocate new item in directory stack + mov eax, [del_dir_stack_ptr] + mov [eax], ebp + add eax, 4 + mov [del_dir_stack_ptr], eax +; do recursive deleting + jmp .delete_dir +.fullname_big: +; we will just ignore such files and continue - in real life this situation can not happen + inc ebp + mov esi, execdataend-1 + jmp .do_restore_name +.skip: + inc ebp +.restore_name: + mov esi, execdata +@@: + lodsb + test al, al + jnz @b + dec esi + dec esi +.do_restore_name: + std +@@: + lodsb + cmp al, '/' + jnz @b + cld + mov byte [esi+1], 0 +.delete_dir_entry_continue: + add edx, 304 + jmp .delete_dir_entry_loop +.delete_dir_entry_done: +.do_delete_dir: + mov cl, 1 + call delete_file_worker + ja .cancel + jz @f + jp .delete_dir +@@: +; al=0 - OK, al=2 - skip this directory +; return to previous directory +; pop item from directory stack + mov ecx, [del_dir_stack_ptr] + cmp ecx, del_dir_stack + jbe .done + sub ecx, 4 + mov [del_dir_stack_ptr], ecx + mov ebp, [ecx] + cmp al, 2 + sbb ebp, -1 +; restore prev directory name + mov esi, execdata +@@: + lodsb + test al, al + jnz @b + dec esi + dec esi + std +@@: + lodsb + cmp al, '/' + jnz @b + cld + mov byte [esi+1], 0 + jmp .return_from_recursion +.done: +.cancel: + mov [dirinfo.first], 0 ; do not destroys flags + popad + ret diff --git a/programs/fs/kfar/trunk/font.inc b/programs/fs/kfar/trunk/font.inc index 4484fffde6..bb861dc014 100644 --- a/programs/fs/kfar/trunk/font.inc +++ b/programs/fs/kfar/trunk/font.inc @@ -22,27 +22,111 @@ end if end virtual font: +macro set_name_test a,b +{ +if %=a +font_data_#a = b +end if +} +macro set_name b +{ +set_name_test 1,b +set_name_test 2,b +set_name_test 3,b +set_name_test 4,b +set_name_test 5,b +set_name_test 6,b +set_name_test 7,b +set_name_test 8,b +set_name_test 9,b +set_name_test 10,b +set_name_test 11,b +set_name_test 12,b +set_name_test 13,b +set_name_test 14,b +set_name_test 15,b +set_name_test 16,b +} +macro db_name_test a +{ +if %=a +db font_data_#a +end if +} +macro db_name +{ +db_name_test 1 +db_name_test 2 +db_name_test 3 +db_name_test 4 +db_name_test 5 +db_name_test 6 +db_name_test 7 +db_name_test 8 +db_name_test 9 +db_name_test 10 +db_name_test 11 +db_name_test 12 +db_name_test 13 +db_name_test 14 +db_name_test 15 +db_name_test 16 +} +macro dw_name_test a +{ +if %=a +dw font_data_#a +end if +} +macro dw_name +{ +dw_name_test 1 +dw_name_test 2 +dw_name_test 3 +dw_name_test 4 +dw_name_test 5 +dw_name_test 6 +dw_name_test 7 +dw_name_test 8 +dw_name_test 9 +dw_name_test 10 +dw_name_test 11 +dw_name_test 12 +dw_name_test 13 +dw_name_test 14 +dw_name_test 15 +dw_name_test 16 +} repeat font_height cur_scan = % - repeat 256 + repeat 16 virtual at 0 - a2 = (font_width+14) shr 3 - if cur_scan=1 & %=0x10 - a2 = (font_width+7) shr 3 - end if - file fontname:3Eh + font_bmp_scanline*(font_height*(16-((%-1) shr 4))-cur_scan) + ((((%-1) and 0xF)*font_width) shr 3), a2 + file fontname:3Eh + font_bmp_scanline*(font_height*(17-%)-cur_scan), font_width*2 dd 0 - load a1 dword from 0 - a1 = ((a1 and 0x55555555) shl 1) or ((a1 and 0xAAAAAAAA) shr 1) - a1 = ((a1 and 0x33333333) shl 2) or ((a1 and 0xCCCCCCCC) shr 2) - a1 = ((a1 and 0x0F0F0F0F) shl 4) or ((a1 and 0xF0F0F0F0) shr 4) + repeat 16 + load a1 dword from ((%-1)*font_width) shr 3 + a1 = ((a1 and 0x55555555) shl 1) or ((a1 and 0xAAAAAAAA) shr 1) + a1 = ((a1 and 0x33333333) shl 2) or ((a1 and 0xCCCCCCCC) shr 2) + a1 = ((a1 and 0x0F0F0F0F) shl 4) or ((a1 and 0xF0F0F0F0) shr 4) + a1 = (a1 shr (((%-1)*font_width) and 7)) and ((1 shl font_width) - 1) + a1 = a1 xor ((1 shl font_width) - 1) + set_name a1 + end repeat end virtual - a1 = (a1 shr (((%-1)*font_width) and 7)) and ((1 shl font_width) - 1) - a1 = a1 xor ((1 shl font_width) - 1) if font_width > 8 - dw a1 + repeat 16 + dw_name + end repeat else - db a1 + repeat 16 + db_name + end repeat end if end repeat end repeat +purge set_name_test +purge db_name_test +purge dw_name_test +purge set_name +purge db_name +purge dw_name diff --git a/programs/fs/kfar/trunk/kfar.asm b/programs/fs/kfar/trunk/kfar.asm index 6abd03907f..71a85f022f 100644 --- a/programs/fs/kfar/trunk/kfar.asm +++ b/programs/fs/kfar/trunk/kfar.asm @@ -5,20 +5,62 @@ use32 dd i_end memsize dd mem dd stacktop - dd 0, 0 + dd 0, app_path include 'lang.inc' include 'font.inc' include 'sort.inc' include 'kglobals.inc' -include 'memalloc.inc' include 'dialogs.inc' include 'viewer.inc' include 'tools.inc' +include 'filetool.inc' start: - mov eax, mem - call mf_init + mov edi, tolower_table + push 'A' + pop ecx + xor eax, eax +@@: + stosb + inc eax + loop @b + add al, 0x20 + mov cl, 'Z'-'A'+1 +@@: + stosb + inc eax + loop @b + sub al, 0x20 + mov cl, 'А'-'Z'-1 +@@: + stosb + inc eax + loop @b + add al, 0x20 + mov cl, 'Р'-'А' +@@: + stosb + inc eax + loop @b + add al, 0x30 + mov cl, 'Я'-'Р'+1 +@@: + stosb + inc eax + loop @b + sub al, 0x50 + mov cl, 256-'Я'-1 +@@: + stosb + inc eax + loop @b + mov byte [edi-256+'Ё'], 'ё' + push 68 + pop eax + push 11 + pop ebx + int 0x40 call init_console call draw_window push 66 @@ -27,6 +69,157 @@ start: pop ebx mov ecx, ebx int 40h ; set keyboard mode to scancodes + mov eax, 200 + mov [panel1_nfa], eax + mov [panel2_nfa], eax + mov ecx, 200*4 + 32 + 200*304 + call pgalloc + mov [panel1_files], eax + call pgalloc + mov [panel2_files], eax + test eax, eax + jz exit + cmp [panel1_files], eax + jz exit + mov [panel1_sortmode], 0 ; sort by name + mov [panel2_sortmode], 0 + push 2 ; "средний" формат + pop eax + mov [panel1_colmode], eax + mov [panel2_colmode], eax + mov [num_screens], 1 + mov ecx, 0x1000 + call pgalloc + mov [screens], eax + test eax, eax + jz exit + mov ecx, panels_vtable + mov [eax], ecx + mov [active_screen_vtable], ecx +; load libini.obj and kfar.ini + mov eax, libini_name + mov esi, ini_import + push 2 + pop ebp ; we use version 2 of libini + call load_dll_and_import + test eax, eax + jnz .noini + mov edi, app_path + or ecx, -1 + repnz scasb + mov dword [edi-1], '.ini' + mov byte [edi+3], 0 + push 1 + push dword aConfirmDelete + push dword aConfirmations + push dword app_path + call [ini.get_int] + mov [bConfirmDelete], al + push 0 + push dword aConfirmDeleteIncomplete + push dword aConfirmations + push dword app_path + call [ini.get_int] + mov [bConfirmDeleteIncomplete], al + mov ecx, 0x1000 + call xpgalloc + test eax, eax + jz .skip_assoc +@@: + mov edx, eax + push edx ecx + push ecx + push edx + push dword aAssociations + push dword app_path + call [ini.query_sec] + pop ecx edx + cmp eax, ecx + jbe @f + add ecx, ecx + call xpgrealloc + test eax, eax + jz .skip_assoc + jmp @b +@@: + cmp ecx, 0x1000 + jbe @f + mov ecx, eax + call xpgrealloc ; must succeed, because we decrease size + mov edx, eax +@@: + mov [associations], edx + xor ebp, ebp + xor esi, esi +.skip_assoc: + mov edi, saved_file_name + push dword nullstr + push 512 + push edi + push dword aShortcut + push dword aFolderShortcuts + push dword app_path + call [ini.get_str] + cmp byte [edi], 0 + jz .shortcut_cont + or ecx, -1 + xor eax, eax + repnz scasb + not ecx + cmp ecx, 2 + jz @f + cmp byte [edi-2], '/' + jnz @f + mov byte [edi-2], 0 + dec ecx +@@: + mov al, [aShortcut.d] + push esi + inc esi + mov [FolderShortcuts+(eax-'0')*4], esi + lea esi, [esi+ecx-1] + push esi + and esi, 0xFFF + cmp esi, ecx + pop esi + ja .norealloc + mov edx, ebp + mov ecx, esi + call xpgrealloc + test eax, eax + jnz @f + mov edi, FolderShortcuts + mov ecx, 10 + rep stosd + jmp .skip_shortcuts +@@: + mov ebp, eax +.norealloc: + pop edi + add edi, ebp + mov ecx, saved_file_name +@@: + mov al, [ecx] + inc ecx + stosb + test al, al + jnz @b +.shortcut_cont: + inc [aShortcut.d] + cmp [aShortcut.d], '9' + jbe .skip_assoc + mov esi, FolderShortcuts + mov ecx, 10 + dec ebp +.l3: + lodsd + test eax, eax + jz @f + add [esi-4], ebp +@@: + loop .l3 +.skip_shortcuts: +.noini: mov esi, def_left_dir mov edi, panel1_dir @@: @@ -41,39 +234,16 @@ start: stosb test al, al jnz @b - mov eax, 200 - mov [panel1_nfa], eax - mov [panel2_nfa], eax - mov eax, 200*4 + 32 + 200*304 - push eax - call mf_alloc - mov [panel1_files], eax - pop eax - call mf_alloc - mov [panel2_files], eax - test eax, eax - jz exit - cmp [panel1_files], eax - jz exit - mov [panel1_sortmode], 0 ; sort by name - mov [panel2_sortmode], 0 - mov [num_screens], 1 - mov eax, 8 - call mf_alloc - mov [screens], eax - test eax, eax - jz exit - mov ecx, panels_vtable - mov [eax], ecx - mov [active_screen_vtable], ecx call draw_keybar call draw_cmdbar mov [prev_dir], 0 mov ebp, panel1_data + call calc_colwidths call read_folder call draw_panel mov [bSilentFolderMode], 1 mov ebp, panel2_data + call calc_colwidths call read_folder call draw_panel event: @@ -196,6 +366,9 @@ redraw: add esi, 5-1 int 40h .resize_draw: + mov ecx, [MemForImage] + call pgfree + and [MemForImage], 0 call init_console ; call draw_window call draw_keybar @@ -414,28 +587,37 @@ ctrlkey_test4: ret new_screen: - call xmalloc +; in: ecx=sizeof(screen data), edx->vtable +; out: ebp=pointer or NULL, eax!=0 if successful +; destroys ebx,ecx + call xpgalloc test eax, eax jnz @f ret @@: mov ebp, eax - mov ebx, [num_screens] - inc ebx - shl ebx, 3 mov eax, [screens] - call xrealloc + mov ecx, [num_screens] + inc ecx + shl ecx, 3 + test ecx, 0xFFF + jnz .norealloc + push edx + mov edx, eax + call xpgrealloc + pop edx test eax, eax jnz @f - mov eax, ebp - call mf_free + mov ecx, ebp + call pgfree xor eax, eax ret @@: mov [screens], eax +.norealloc: inc [num_screens] - mov [eax+ebx-8], edx - mov [eax+ebx-4], ebp + mov [eax+ecx-8], edx + mov [eax+ecx-4], ebp mov eax, [num_screens] dec eax mov [active_screen], eax @@ -465,12 +647,16 @@ delete_active_screen: add ecx, ecx rep movsd dec [num_screens] - mov ebx, [num_screens] - shl ebx, 3 - mov eax, [screens] - call mf_realloc ; must succeed, because we decrease size - pop eax - call mf_free + mov ecx, [num_screens] + shl ecx, 3 + test ecx, 0xFFF + jnz .norealloc + mov edx, [screens] + call pgrealloc ; must succeed, because we decrease size + mov [screens], eax +.norealloc: + pop ecx + call pgfree and [active_screen], 0 change_screen: @@ -491,7 +677,8 @@ F12: add eax, 8 mov esi, eax mul [num_screens] - call xmalloc + mov ecx, eax + call xpgalloc test eax, eax jnz @f ret @@ -553,7 +740,7 @@ F12: mul esi add eax, ebx push 1 - push aScreens + push dword aScreens push eax call menu cmp eax, -1 @@ -562,8 +749,8 @@ F12: div esi mov [active_screen], eax @@: - mov eax, ebx - call mf_free + mov ecx, ebx + call pgfree jmp change_screen panels_OnKey: @@ -587,10 +774,38 @@ panels_OnKey: ; call draw_panel ; ret jmp draw_panel +.insert: + lea eax, [ecx*4] + add eax, [ebp + panel1_files - panel1_data] + mov eax, [eax] + cmp word [eax+40], '..' + jnz @f + cmp byte [eax+42], 0 + jz .insert.down +@@: + xor byte [eax+303], 1 + mov edx, [eax+32] + test byte [eax+303], 1 + mov eax, [eax+36] + jnz .insert.increase + sub dword [ebp + panel1_selected_size - panel1_data], edx + sbb dword [ebp + panel1_selected_size+4 - panel1_data], eax + dec [ebp + panel1_selected_num - panel1_data] + jmp .insert.down +.insert.increase: + add dword [ebp + panel1_selected_size - panel1_data], edx + adc dword [ebp + panel1_selected_size+4 - panel1_data], eax + inc [ebp + panel1_selected_num - panel1_data] +.insert.down: + inc ecx + cmp ecx, [ebp + panel1_numfiles - panel1_data] + jae .done_redraw + jmp @f .down: inc ecx cmp ecx, [ebp + panel1_numfiles - panel1_data] jae .ret +@@: mov [ebp + panel1_index - panel1_data], ecx cmp ecx, ebx jb .done_redraw @@ -599,31 +814,55 @@ panels_OnKey: mov [ebp + panel1_start - panel1_data], ecx jmp .done_redraw .left: - jecxz .ret - sub ecx, [ebp + panel1_colsz - panel1_data] + test ecx, ecx + jnz @f + ret +@@: + mov eax, [ebp + panel1_colsz - panel1_data] + sub ecx, eax jae @f xor ecx, ecx @@: mov [ebp + panel1_index - panel1_data], ecx +.finalize_left: cmp ecx, edx jae .done_redraw - sub edx, [ebp + panel1_colsz - panel1_data] + sub edx, eax jae @f xor edx, edx @@: mov [ebp + panel1_start - panel1_data], edx jmp .done_redraw +.pgup: + mov eax, [ebp + panel1_colst - panel1_data] + dec eax + jnz @f + inc eax +@@: + test ecx, ecx + jnz @f + ret +@@: + sub ecx, eax + jae @f + xor ecx, ecx +@@: + mov [ebp + panel1_index - panel1_data], ecx + dec ecx + jmp .finalize_left .right: - add ecx, [ebp + panel1_colsz - panel1_data] + mov eax, [ebp + panel1_colsz - panel1_data] + add ecx, eax cmp ecx, [ebp + panel1_numfiles - panel1_data] jb @f mov ecx, [ebp + panel1_numfiles - panel1_data] dec ecx @@: mov [ebp + panel1_index - panel1_data], ecx +.finalize_right: cmp ecx, ebx jb .done_redraw - add ebx, [ebp + panel1_colsz - panel1_data] + add ebx, eax cmp ebx, [ebp + panel1_numfiles - panel1_data] jbe @f mov ebx, [ebp + panel1_numfiles - panel1_data] @@ -634,6 +873,21 @@ panels_OnKey: @@: mov [ebp + panel1_start - panel1_data], ebx jmp .done_redraw +.pgdn: + mov eax, [ebp + panel1_colst - panel1_data] + dec eax + jnz @f + inc eax +@@: + add ecx, eax + cmp ecx, [ebp + panel1_numfiles - panel1_data] + jb @f + mov ecx, [ebp + panel1_numfiles - panel1_data] + dec ecx +@@: + mov [ebp + panel1_index - panel1_data], ecx + inc ecx + jmp .finalize_right .tab: xor [active_panel], panel1_data xor panel2_data call draw_cmdbar @@ -661,12 +915,28 @@ panels_OnKey: jnz .enter_folder call find_extension jc .run_app - jnz .run_app .run_association: - mov eax, [edi+4] + cmp byte [edi], 0 + jz .l1 + cmp byte [edi], ';' + jnz @f +.l1: + ret +@@: + mov esi, edi +@@: + lodsb + test al, al + jz @f + cmp al, ';' + jnz @b + dec esi + mov byte [esi], 0 + mov [restore_semicolon], esi +@@: .run_association2: mov [execparams], execdata - mov [execptr], eax + mov [execptr], edi jmp .dorun .run_app: mov [execptr], execdata @@ -699,7 +969,14 @@ panels_OnKey: xor edx, edx cmp [execparams], edx jz .nofasm - cmp [execptr], fasm + mov esi, [execptr] +@@: + lodsb + test al, al + jnz @b + mov eax, [esi-5] + or eax, 0x20202020 + cmp eax, 'fasm' jnz .nofasm cmp edi, execdata+(execdataend-execdata)/2 ja .bigfilename @@ -749,13 +1026,19 @@ panels_OnKey: push 70 pop eax int 40h + xor esi, esi + xchg esi, [restore_semicolon] + test esi, esi + jz @f + mov byte [esi], ';' +@@: neg eax js @f - push aContinue + push dword aContinue mov esi, esp call get_error_msg push eax - push aRunError + push dword aRunError mov eax, esp push esi push 1 @@ -763,7 +1046,7 @@ panels_OnKey: push 2 push -1 push -1 - push aError + push dword aError call SayErr add esp, 3*4 ret @@ -784,8 +1067,14 @@ panels_OnKey: pop esi .bigfilename: mov eax, aFileNameTooBig +.l2: + xor esi, esi + xchg esi, [restore_semicolon] + test esi, esi + jz @f + mov byte [esi], ';' @@: - push aContinue + push dword aContinue mov esi, esp push eax mov eax, esp @@ -795,21 +1084,21 @@ panels_OnKey: push 1 push -1 push -1 - push aError + push dword aError call SayErr add esp, 2*4 ret .bigcmdline: mov eax, aCmdLineTooBig - jmp @b + jmp .l2 .bigfoldername2: mov byte [ecx], 0 .bigfoldername: mov eax, aFolderNameTooBig - jmp @b + jmp .l2 .copytoself: mov eax, aCannotCopyToSelf - jmp @b + jmp .l2 .enter_folder: lea esi, [ecx+40] cmp word [esi], '..' @@ -940,6 +1229,7 @@ panels_OnKey: mov [ebx+dirinfo.dirdata-dirinfo], driveinfo mov [ebx+dirinfo.name-dirinfo], tmpname mov byte [tmpname], '/' + xor edx, edx xor ecx, ecx .drive_loop_e: mov byte [tmpname+1], 0 @@ -965,17 +1255,20 @@ panels_OnKey: mov ebx, dirinfo test eax, eax jnz .drive_loop_i_done - mov eax, 32+8 - call xmalloc + add ecx, 32+8 + push ecx + and ecx, 0xFFF + cmp ecx, 32+8 + pop ecx + ja @f + call xpgrealloc + mov edx, eax test eax, eax - jz .drive_loop_i_done - jecxz @f - mov [ecx], eax + jnz @f + pop eax + ret @@: - and dword [eax], 0 - mov [eax+4], ecx - mov ecx, eax - lea edi, [eax+8] + lea edi, [edx+ecx-32] mov esi, tmpname @@: lodsb @@ -1000,6 +1293,20 @@ panels_OnKey: jmp .drive_loop_e .drive_loop_e_done: and [ebx+dirinfo.first-dirinfo], 0 + mov edi, edx + xor esi, esi + add ecx, edx +@@: + and dword [edi], 0 + mov dword [edi+4], esi + mov esi, edi + add edi, 32+8 + cmp edi, ecx + jae @f + mov [esi], edi + jmp @b +@@: + mov ecx, edx lea edi, [ebp + panel1_dir - panel1_data] .find_cur_drive_loop: push edi @@ -1013,12 +1320,13 @@ panels_OnKey: inc edi jmp @b @@: - cmp dword [ecx+4], 0 + cmp dword [ecx], 0 jz @f pop edi - mov ecx, [ecx+4] + mov ecx, [ecx] jmp .find_cur_drive_loop @@: + mov ecx, edx .cur_drive_found: pop edi push 1 @@ -1049,17 +1357,8 @@ panels_OnKey: stosb test al, al jnz @b -@@: - cmp dword [ecx+4], 0 - jz @f - mov ecx, [ecx+4] - jmp @b -@@: - mov eax, ecx - mov ecx, [ecx] - call mf_free - test ecx, ecx - jnz @b + mov ecx, edx + call pgfree call read_folder jmp .done_redraw .shift_f5: @@ -1317,17 +1616,17 @@ panels_OnKey: cmp eax, 6 jz .copyreadok push esi - push aCannotReadFile + push dword aCannotReadFile call get_error_msg push eax mov eax, esp - push RetryOrCancelBtn + push dword RetryOrCancelBtn push 2 push eax push 3 push -1 push -1 - push aError + push dword aError call SayErr add esp, 3*4 test eax, eax @@ -1347,17 +1646,17 @@ panels_OnKey: test eax, eax jz .copywriteok push edi - push aCannotWriteFile + push dword aCannotWriteFile call get_error_msg push eax mov eax, esp - push RetryOrCancelBtn + push dword RetryOrCancelBtn push 2 push eax push 3 push -1 push -1 - push aError + push dword aError call SayErr add esp, 3*4 test eax, eax @@ -1381,15 +1680,15 @@ panels_OnKey: jz @f cmp [writeinfo.code], 2 jz .copydone - push aIncompleteFile + push dword aIncompleteFile mov eax, esp - push DeleteOrKeepBtn + push dword DeleteOrKeepBtn push 2 push eax push 1 push -1 push -1 - push aCopyCaption + push dword aCopyCaption call SayErr add esp, 4 test eax, eax @@ -1409,13 +1708,83 @@ panels_OnKey: call view_file .ret2: ret +.f8_has_selected: + mov edi, saved_file_name+511 + mov byte [edi], 0 + mov eax, [ebp + panel1_selected_num - panel1_data] +if lang eq ru + cmp eax, 1 + jz @f + dec edi + mov byte [edi], 'а' + cmp eax, 4 + jbe @f + dec edi + mov word [edi], 'ов' +@@: + mov dword [edi-4], 'мент' + mov dword [edi-8], ' эле' + sub edi, 8 +else + cmp eax, 1 + jz @f + dec edi + mov byte [edi], 's' +@@: + mov dword [edi-4], 'item' + mov byte [edi-5], ' ' + sub edi, 5 +end if + xor edx, edx + push 10 + pop ecx +@@: + div ecx + add dl, '0' + dec edi + mov [edi], dl + xor edx, edx + test eax, eax + jnz @b + push edi + push aConfirmDeleteText + mov eax, esp + push DeleteOrCancelBtn + push 2 + push eax + push 2 + push -1 + push -1 + push aDeleteCaption + call Message + add esp, 8 + test eax, eax + jnz .ret2 + mov [del_bSkipAll], 0 + mov ecx, [ebp + panel1_numfiles - panel1_data] + jecxz .ret2 + mov esi, [ebp + panel1_files - panel1_data] +.f8_loop: + lodsd + test byte [eax+303], 1 + jz @f + call delete_file + ja .f8_multiple_cancel +@@: + loop .f8_loop +.f8_multiple_cancel: + jmp .ctrl_r .f8: + cmp [ebp + panel1_selected_num - panel1_data], 0 + jnz .f8_has_selected call get_curfile_folder_entry cmp [bConfirmDelete], 0 jz .f8_allowed - mov ebx, f8_confirm_dlgdata + lea eax, [ecx+40] + push eax mov esi, aConfirmDeleteText mov edi, aConfirmDeleteTextBuf + push edi @@: lodsb stosb @@ -1431,93 +1800,23 @@ panels_OnKey: stosb test al, al jnz @b - lea esi, [ecx+40] - mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.name], esi - or eax, -1 -@@: - inc eax - cmp byte [eax+esi], 0 - jnz @b - sub edi, aConfirmDeleteTextBuf+1 - cmp eax, edi - jae @f - mov eax, edi -@@: - inc eax - inc eax - mov edx, [cur_width] - sub edx, 8 - cmp eax, edx - jbe @f - mov eax, edx -@@: - mov [ebx + dlgtemplate.width], eax - dec eax - dec eax - mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.width2], eax - mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.width3], eax - shr eax, 1 - mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.del_x2], eax - sub eax, aDeleteLength-1 - mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.del_x1], eax - add eax, aDeleteLength - mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.cnl_x1], eax - add eax, aCancelLength - 1 - mov [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.cnl_x2], eax - or byte [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.flags1], 4 - and byte [ebx - f8_confirm_dlgdata + f8_confirm_dlgdata.flags2], not 4 - push ebx - call DialogBox - cmp eax, f8_confirm_dlgdata.del_btn - jnz .ret2 -.f8_allowed: - lea esi, [ebp + panel1_dir - panel1_data] - mov edi, execdata -@@: - lodsb - test al, al - jz @f - stosb - jmp @b -@@: - lea esi, [ecx+40] - mov al, '/' - stosb -@@: - lodsb - cmp edi, execdataend - jae .bigfilename - stosb - test al, al - jnz @b -.retrydel: - push 70 - pop eax - mov ebx, delinfo - int 0x40 - test eax, eax - jz .ctrl_r - push execdata - push aCannotDeleteFolder - call get_curfile_folder_entry - test byte [ecx], 10h - jnz @f - mov dword [esp], aCannotDeleteFile -@@: - call get_error_msg - push eax mov eax, esp - push RetryOrCancelBtn + push DeleteOrCancelBtn push 2 push eax - push 3 + push 2 push -1 push -1 - push aError - call SayErr - add esp, 3*4 + push aDeleteCaption + call Message + add esp, 8 test eax, eax - jz .retrydel + jz .f8_allowed + ret +.f8_allowed: + mov [del_bSkipAll], 0 + mov eax, ecx + call delete_file .ctrl_r: ; Rescan panel ; call read_folder @@ -1589,10 +1888,24 @@ panels_OnKey: @@: call find_extension jc .menuret - jnz .menuret ; known extension - mov ebx, [edi+8] - test ebx, ebx +@@: + cmp byte [edi], 0 + jz .menuret + cmp byte [edi], ';' + jz @f + inc edi + jmp @b +@@: + inc edi +@@: + inc edi + cmp byte [edi-1], ' ' + jz @b + cmp byte [edi-1], 9 + jz @b + dec edi + cmp byte [edi], 0 jz .menuret mov ecx, esi @@: @@ -1605,41 +1918,99 @@ panels_OnKey: mov cl, 15 @@: xor edx, edx + xor ebp, ebp + push edx .menucreateloop: - mov eax, [ebx] - test eax, eax - jz .menucreated + mov eax, edi + xor ebx, ebx @@: + cmp byte [edi], ',' + jz @f + cmp byte [edi], bl + jz @f + inc edi + jmp @b +@@: + xchg bl, [edi] + pushad + push nullstr + push 1024 + push saved_file_name + push eax + push aMenu + push app_path + call [ini.get_str] + popad + mov [edi], bl + mov eax, saved_file_name +@@: + cmp byte [eax], 0 + jz .menucreatecont + cmp byte [eax], ',' + jz @f inc eax - cmp byte [eax-1], 0 - jnz @b - sub eax, [ebx] + jmp @b +@@: + mov byte [eax], 0 + push eax + sub eax, saved_file_name-1 cmp eax, ecx ja @f mov eax, ecx @@: - add eax, 12 - call xmalloc + xchg eax, [esp] + inc eax + push eax +@@: + inc eax + cmp byte [eax-1], 0 + jnz @b + sub eax, [esp] + add [esp+4], eax + pop eax eax + add eax, 8 + add ebp, eax + push ebp + and ebp, 0xFFF + cmp ebp, eax + pop ebp + ja @f + push eax + xchg edx, [esp+4] + push ecx + mov ecx, ebp + call xpgrealloc + pop ecx + pop edx + xchg edx, [esp] test eax, eax + xchg eax, [esp] jz .menucreated - add eax, 4 +@@: + neg eax + add eax, ebp + add eax, [esp] + and dword [eax], 0 + and dword [eax+4], 0 test edx, edx jz @f + sub eax, [esp] mov [edx], eax -@@: + add eax, [esp] + sub edx, [esp] mov [eax+4], edx +@@: mov edx, eax - push esi - mov esi, [ebx+4] - mov [eax-4], esi - mov esi, [ebx] + push esi edi + mov esi, saved_file_name lea edi, [eax+8] @@: lodsb stosb test al, al jnz @b - sub esi, [ebx] + push esi + sub esi, saved_file_name sub esi, ecx jae .menunoadd neg esi @@ -1650,36 +2021,50 @@ panels_OnKey: jnz @b .menunoadd: pop esi - add ebx, 8 - jmp .menucreateloop +@@: + lodsb + stosb + test al, al + jnz @b + pop edi esi +.menucreatecont: + inc edi + cmp byte [edi-1], ',' + jz .menucreateloop .menucreated: test edx, edx - jz .menuret + jz .menuret_free and dword [edx], 0 + pop edx + mov ecx, edx + add [ecx], edx @@: - cmp dword [edx+4], 0 + mov ecx, [ecx] + cmp dword [ecx], 0 jz @f - mov edx, [edx+4] + add [ecx], edx + add [ecx+4], edx jmp @b @@: + add [ecx+4], edx + push edx push 1 push esi push edx call menu cmp eax, -1 - jz .menuret - push dword [eax-4] + jz .menuret_free + lea edi, [eax+8] @@: - test edx, edx - jz @f - lea eax, [edx-4] - mov edx, [edx] - call mf_free - jmp @b -@@: - pop eax + inc edi + cmp byte [edi-1], 0 + jnz @b + mov ebp, [active_panel] call get_curfile_folder_entry - jmp .run_association2 + call .run_association2 +.menuret_free: + pop ecx + jmp pgfree .f7: mov dword [CopyDestEditBuf], CopyDestEditBuf.length and dword [CopyDestEditBuf+4], 0 @@ -1758,42 +2143,161 @@ panels_OnKey: int 0x40 test eax, eax jz @f - push CopyDestEditBuf+12 - push aCannotMakeFolder + push dword CopyDestEditBuf+12 + push dword aCannotMakeFolder call get_error_msg push eax mov eax, esp - push RetryOrCancelBtn + push dword RetryOrCancelBtn push 2 push eax push 3 push -1 push -1 - push aError + push dword aError call SayErr add esp, 3*4 test eax, eax jz .mkdir_retry @@: jmp .copydone +.change_mode: + dec eax + mov [ebp + panel1_colmode - panel1_data], eax + call calc_colwidths + jmp draw_panel +.quick_jump: + dec eax + cmp al, 10 + jnz @f + xor eax, eax +@@: + mov eax, [FolderShortcuts+eax*4] + test eax, eax + jnz @f + ret +@@: + lea esi, [ebp + panel1_dir - panel1_data] + push eax esi + mov edi, prev_dir +@@: + lodsb + stosb + test al, al + jnz @b + pop edi esi +@@: + lodsb + stosb + test al, al + jnz @b + jmp .reread +.greyplus: + push 0 + mov ecx, aSelect + jmp @f +.greyminus: + push 1 + mov ecx, aDeselect +@@: + mov eax, mark_dlgdata + mov [eax+mark_dlgdata.title-mark_dlgdata], ecx + mov [eax+mark_dlgdata.flags-mark_dlgdata], 0xC + mov edi, enter_string_buf+12 + mov dword [edi-12], 512 + mov dword [edi-8], 1 + and dword [edi-4], 0 + mov word [edi], '*' + push eax + call DialogBox + inc eax + jnz @f +.noselect: + pop eax + ret +@@: + xor eax, eax + mov esi, edi +@@: + lodsb + mov al, [tolower_table+eax] + mov [esi-1], al + test al, al + jnz @b +@@: + mov ecx, [ebp + panel1_numfiles - panel1_data] + mov ebx, [ebp + panel1_files - panel1_data] + jecxz .noselect + mov eax, [ebx] + cmp word [eax+40], '..' + jnz .selectloop + cmp byte [eax+42], 0 + jnz .selectloop + dec ecx + jz .noselect + add ebx, 4 +.selectloop: + xor eax, eax + mov esi, [ebx] + add esi, 40 + mov edx, lower_file_name-1 +@@: + lodsb + inc edx + mov al, [tolower_table+eax] + mov [edx], al + test al, al + jnz @b + mov esi, lower_file_name + call match_mask_rev_lowercase + jc @f + mov esi, [ebx] + mov eax, [esi+32] + cmp byte [esp], 0 + jz .doselect + test byte [esi+303], 1 + jz @f + and byte [esi+303], not 1 + sub dword [ebp + panel1_selected_size - panel1_data], eax + mov eax, [esi+36] + sbb dword [ebp + panel1_selected_size+4 - panel1_data], eax + dec dword [ebp + panel1_selected_num - panel1_data] + jmp @f +.doselect: + test byte [esi+303], 1 + jnz @f + or byte [esi+303], 1 + add dword [ebp + panel1_selected_size - panel1_data], eax + mov eax, [esi+36] + adc dword [ebp + panel1_selected_size+4 - panel1_data], eax + inc dword [ebp + panel1_selected_num - panel1_data] +@@: + add ebx, 4 + dec ecx + jnz .selectloop + pop eax + jmp .done_redraw panels_OnRedraw: call draw_cmdbar mov ebp, panel1_data + call calc_colwidths call draw_panel mov ebp, panel2_data + call calc_colwidths call draw_panel ret init_console: - mov eax, [console_data_ptr] - call mf_free + mov ecx, [console_data_ptr] + call pgfree mov eax, [cur_width] mul [cur_height] mov ecx, eax - add eax, eax - add eax, eax - call mf_alloc + push ecx + shl ecx, 2 + call pgalloc + pop ecx test eax, eax jz exit mov [console_data_ptr], eax @@ -1963,7 +2467,6 @@ draw_window: @@: cmp [fill_height], 0 jz @f - mov al, 13 xor edx, edx mov ebx, 50000h mov bx, word [wnd_width] @@ -1977,15 +2480,21 @@ draw_window: @@: ; xor ecx, ecx ; call draw_image - and [min_x], 0 - and [min_y], 0 - mov eax, [cur_width] - dec eax - mov [max_x], eax - mov eax, [cur_height] - dec eax - mov [max_y], eax - call draw_image.force + mov al, 65 + mov ebx, [MemForImage] + test ebx, ebx + jz @f + mov ecx, [cur_width] + imul ecx, font_width*10000h + mov cx, word [cur_height] + imul cx, font_height + mov edx, [skinh] + add edx, 5*10000h + mov esi, 8 + mov edi, console_colors + xor ebp, ebp + int 0x40 +@@: mov al, 12 push 2 pop ebx @@ -2012,187 +2521,145 @@ draw_image.nomem: ret draw_image: -; determine draw rectangle - and [max_x], 0 - or [min_x], -1 - or [min_y], -1 - mov esi, [console_data_ptr] - xor eax, eax - xor edx, edx + mov [bMemForImageValidData], byte 1 + cmp [MemForImage], 0 + jnz .allocated +; allocate memory for image mov ecx, [cur_width] imul ecx, [cur_height] -.m1: - mov bx, [esi] - cmp bx, [esi+ecx*2] - jz .m2 - cmp eax, [min_x] - ja @f - mov [min_x], eax -@@: - cmp eax, [max_x] - jb @f - mov [max_x], eax -@@: - cmp edx, [min_y] - jae @f - mov [min_y], edx -@@: - mov [max_y], edx -.m2: - add esi, 2 - inc eax - cmp eax, [cur_width] - jb .m1 - xor eax, eax - inc edx - cmp edx, [cur_height] - jb .m1 - mov eax, [cursor_x] - cmp eax, -1 - jz .m3 - cmp eax, [min_x] - ja @f - mov [min_x], eax -@@: - cmp eax, [max_x] - jb @f - mov [max_x], eax -@@: - mov edx, [cursor_y] - cmp edx, [min_y] - ja @f - mov [min_y], edx -@@: - cmp edx, [max_y] - jb @f - mov [max_y], edx -@@: -.m3: - xchg eax, [old_cursor_x] - xchg edx, [old_cursor_y] - cmp eax, -1 - jz .m4 - cmp eax, [min_x] - ja @f - mov [min_x], eax -@@: - cmp eax, [max_x] - jb @f - mov [max_x], eax -@@: - cmp edx, [min_y] - ja @f - mov [min_y], edx -@@: - cmp edx, [max_y] - jb @f - mov [max_y], edx -@@: -.m4: - cmp [min_y], -1 - jz .nodraw -.force: -; allocate memory for image - mov ecx, [max_x] - sub ecx, [min_x] - inc ecx - mov [used_width], ecx - mov edx, [max_y] - sub edx, [min_y] - inc edx - mov [used_height], edx - imul ecx, edx imul ecx, font_width*font_height - add ecx, [heapend] - push 64 - pop eax - push 1 - pop ebx - int 0x40 + call pgalloc test eax, eax - jnz draw_image.nomem - mov edi, [heapend] + jz draw_image.nomem + mov [MemForImage], eax + mov [bMemForImageValidData], byte 0 +.allocated: + and [max_x], 0 + or [min_x], -1 + and [max_y], 0 + or [min_y], -1 + mov eax, [cursor_y] + mul [cur_width] + add eax, [cursor_x] + add eax, eax + add eax, [console_data_ptr] + xchg [cur_cursor_pos], eax + mov [old_cursor_pos], eax + mov edi, [MemForImage] mov esi, [console_data_ptr] - mov eax, [min_y] - imul eax, [cur_width] - add eax, [min_x] - lea esi, [esi+eax*2] - mov ecx, [used_height] + mov ecx, [cur_height] .lh: - push ecx esi - mov ecx, [used_width] + push ecx + mov ecx, [cur_width] .lw: push ecx - mov ebx, [esi] mov eax, [cur_width] imul eax, [cur_height] + mov ebx, [esi] + cmp [bMemForImageValidData], 0 + jz @f + cmp esi, [cur_cursor_pos] + jz @f + cmp esi, [old_cursor_pos] + jz @f + cmp bx, [eax*2+esi] + jnz @f + inc esi + inc esi + jmp .skip_symbol +@@: mov [eax*2+esi], bx - movzx eax, bl + cmp ecx, [min_x] + ja @f + mov [min_x], ecx +@@: + cmp ecx, [max_x] + jb @f + mov [max_x], ecx +@@: + mov eax, [esp+4] + mov [min_y], eax + cmp eax, [max_y] + jb @f + mov [max_y], eax +@@: push edi - movzx ebx, bh - mov ebp, ebx - shr ebp, 4 - and ebx, 0xF + xor eax, eax + mov al, [esi+1] + and al, 0xF + mov ebx, eax + mov al, [esi+1] + shr al, 4 + mov ebp, eax sub ebx, ebp - add esi, 2 + lodsb + inc esi if font_width > 8 lea edx, [eax+eax+font] else lea edx, [eax+font] end if - mov ecx, font_height .sh: - push ecx edx edi - xor ecx, ecx - mov edx, [edx] -.sw: - shr edx, 1 + mov ecx, [edx] +repeat font_width + shr ecx, 1 sbb eax, eax and eax, ebx add eax, ebp - mov [edi], al - add ecx, 1 - add edi, 1 - cmp ecx, font_width - jb .sw - pop edi edx ecx - mov eax, [used_width] - imul eax, font_width + mov [edi+%-1], al +end repeat + mov eax, [cur_width] +; imul eax, font_width +; add edi, eax +if font_width = 6 + lea eax, [eax*2+eax] + lea edi, [edi+eax*2] +else if font_width = 7 + lea edi, [edi+eax*8] + sub edi, eax +else if font_width = 8 + lea edi, [edi+eax*8] +else if font_width = 9 + lea edi, [edi+eax*8] add edi, eax +else if font_width = 10 + lea eax, [eax*4+eax] + lea edi, [edi+eax*2] +else +Unknown font_width value! +end if if font_width > 8 add edx, 256*2 + cmp edx, font+256*2*font_height else add edx, 256 + cmp edx, font+256*font_height end if - loop .sh + jb .sh pop edi .skip_symbol: pop ecx add edi, font_width dec ecx jnz .lw - mov eax, [used_width] + mov eax, [cur_width] imul eax, (font_height-1)*font_width add edi, eax - pop esi ecx - add esi, [cur_width] - add esi, [cur_width] + pop ecx dec ecx jnz .lh ; cursor mov eax, [cursor_y] inc eax jz .nocursor - sub eax, [min_y] - mul [used_width] + mul [cur_width] imul eax, font_height*font_width mov edx, [cursor_x] - sub edx, [min_x] inc edx imul edx, font_width add eax, edx - add eax, [heapend] - mov edx, [used_width] + add eax, [MemForImage] + mov edx, [cur_width] imul edx, font_width neg edx mov ecx, (font_height*15+50)/100 @@ -2210,31 +2677,44 @@ end if pop ecx loop .cursor_loop .nocursor: - mov ecx, [used_width] - imul ecx, font_width*65536 - mov cx, word [used_height] - imul cx, font_height - mov edx, [min_x] + cmp [min_y], -1 + jz .nodraw + mov ecx, [cur_width] + mov ebx, [cur_height] + mov eax, ebx + sub ebx, [max_y] + sub eax, [min_y] + sub eax, ebx + inc eax + imul ebp, eax, font_height + mov edx, ecx + sub edx, [max_x] imul edx, font_width - add edx, 5 + mov eax, edx shl edx, 16 - mov dx, word [min_y] - imul dx, font_height + imul dx, bx, font_height + imul ebx, [cur_width] + mov ecx, [max_x] + sub ecx, [min_x] + inc ecx + imul ecx, font_width*10000h + add ecx, ebp + imul ebx, font_width*font_height + add ebx, [MemForImage] + add ebx, eax add edx, [skinh] + add edx, 5*10000h + imul esi, [cur_width], font_width + mov ebp, ecx + shr ebp, 16 + sub esi, ebp + mov ebp, esi push 65 pop eax - mov ebx, [heapend] + mov edi, console_colors push 8 pop esi - mov edi, console_colors - xor ebp, ebp - int 0x40 - push 64 - pop eax - push 1 - pop ebx - mov ecx, [heapend] - int 0x40 + int 40h .nodraw: ret @@ -2419,6 +2899,60 @@ draw_border: stosw ret +calc_colwidths: +; in: ebp->panel data + imul esi, [ebp + panel1_colmode - panel1_data], PanelMode.size + add esi, colmodes + lodsd + mov ecx, eax + lea edx, [ecx-1] + xor ebx, ebx + add esi, PanelMode.ColumnWidths-4 + push ecx esi + xor eax, eax +.loop: + lodsb + add edx, eax + cmp al, 1 + adc ebx, 0 + loop .loop + pop esi ecx + lea edi, [ebp + panel1_colwidths - panel1_data] + test ebx, ebx + jz .loop2 + mov eax, [ebp + panel1_width - panel1_data] + dec eax + dec eax + sub eax, edx + jae @f + xor eax, eax +@@: + xor edx, edx + div ebx + test eax, eax + jnz @f + xor edx, edx + inc eax +@@: + push eax +.loop2: + movzx eax, byte [esi] + inc esi + test eax, eax + jnz @f + pop eax + push eax + dec ebx + cmp ebx, edx + jae @f + inc eax +@@: + stosd + loop .loop2 + pop eax + and dword [edi], 0 + ret + draw_panel: mov eax, [ebp + panel1_left - panel1_data] mov edx, [ebp + panel1_top - panel1_data] @@ -2442,27 +2976,43 @@ draw_panel: rep stosw mov al, 0xB6 stosw - mov eax, [ebp + panel1_width - panel1_data] - sub eax, 3 - shr eax, 1 - mov [column_width], eax + + imul esi, [ebp + panel1_colmode - panel1_data], PanelMode.size + add esi, colmodes + lodsd + mov ecx, eax ; number of columns + lea ebx, [ebp + panel1_colwidths - panel1_data] mov eax, [ebp + panel1_left - panel1_data] inc eax mov [column_left], eax - add eax, [column_width] + mov eax, [ebp + panel1_top - panel1_data] + inc eax + mov [column_top], eax + mov eax, [ebp + panel1_height - panel1_data] + sub eax, 4 + mov [column_height], eax + dec eax + mov [ebp + panel1_colsz - panel1_data], eax + and [ebp + panel1_colst - panel1_data], 0 + mov eax, [ebp + panel1_start - panel1_data] + mov [column_index], eax + mov [last_column_index], eax +.columns_loop: + push ecx + mov eax, [ebx] + add ebx, 4 + mov [column_width], eax + cmp ecx, 1 + jz .skip_right_border + add eax, [column_left] mov edx, [ebp + panel1_top - panel1_data] - inc edx - mov [column_top], edx - dec edx call get_console_ptr - mov ah, [panel_border_color] + mov ah, [panel_header_color] mov al, 0xD1 mov [edi], ax add edi, [cur_width] add edi, [cur_width] - mov ecx, [ebp + panel1_height - panel1_data] - sub ecx, 4 - mov [column_height], ecx + mov ecx, [column_height] mov al, 0xB3 @@: mov [edi], ax @@ -2471,22 +3021,60 @@ draw_panel: loop @b mov al, 0xC1 stosw - mov eax, [column_height] - dec eax - mov [ebp + panel1_colsz - panel1_data], eax - add eax, eax - mov [ebp + panel1_colst - panel1_data], eax - mov eax, [ebp + panel1_start - panel1_data] - mov [column_index], eax - call draw_column - mov eax, [ebp + panel1_width - panel1_data] - sub eax, 3 +.skip_right_border: + mov eax, [column_left] + mov edx, [column_top] + call get_console_ptr +; заголовок столбца + push edi + mov edx, [esi] + and edx, 0xF + mov edx, [column_headers+edx*4] + movzx ecx, byte [edx] + inc edx + cmp ecx, [column_width] + jb @f mov ecx, [column_width] - sub eax, ecx - mov [column_width], eax +@@: + push ecx + sub ecx, [column_width] + neg ecx + shr ecx, 1 + mov al, ' ' + mov ah, [column_header_color] + rep stosw + pop ecx + jecxz .skipcopyhdr + push ecx +@@: + mov al, [edx] + inc edx + stosw + loop @b + pop ecx +.skipcopyhdr: + sub ecx, [column_width] + neg ecx inc ecx - add [column_left], ecx - call draw_column + shr ecx, 1 + mov al, ' ' + rep stosw + pop edi + add edi, [cur_width] + add edi, [cur_width] +; сам столбец + mov eax, [esi] + and eax, 0xF + push ebx esi + call dword [draw_column_proc+eax*4] + pop esi ebx + inc esi + mov eax, [column_width] + inc eax + add [column_left], eax + pop ecx + dec ecx + jnz .columns_loop ; Заголовок панели (текущая папка) lea esi, [ebp + panel1_dir - panel1_data] mov edi, cur_header @@ -2555,9 +3143,68 @@ draw_panel: movzx eax, [ebp + panel1_sortmode - panel1_data] mov al, [compare_names+eax] stosb + mov eax, [ebp + panel1_selected_num - panel1_data] + test eax, eax + jz .skip_selected_info +; Информация о выделенных файлах + push dword [ebp + panel1_selected_size+4 - panel1_data] + push dword [ebp + panel1_selected_size - panel1_data] + call fill_total_info + mov eax, [ebp + panel1_width - panel1_data] + sub eax, 2 + cmp ecx, eax + jbe @f + mov ecx, eax + mov edi, saved_file_name+512 + sub edi, eax + mov byte [edi], '.' + mov word [edi+1], '..' +@@: + mov esi, edi + sub eax, ecx + shr eax, 1 + inc eax + add eax, [ebp + panel1_left - panel1_data] + mov edx, [ebp + panel1_top - panel1_data] + add edx, [ebp + panel1_height - panel1_data] + sub edx, 3 + call get_console_ptr + mov ah, [panel_numselected_color] +@@: + lodsb + stosw + loop @b +.skip_selected_info: +; Информация об общем числе и размере файлов панели + mov eax, [ebp + panel1_total_num - panel1_data] + push dword [ebp + panel1_total_size+4 - panel1_data] + push dword [ebp + panel1_total_size - panel1_data] + call fill_total_info + mov eax, [ebp + panel1_width - panel1_data] + sub eax, 2 + cmp ecx, eax + jbe @f + mov ecx, eax + mov byte [edi+ecx-3], '.' + mov word [edi+ecx-2], '..' +@@: + sub eax, ecx + shr eax, 1 + inc eax + add eax, [ebp + panel1_left - panel1_data] + add edx, [ebp + panel1_top - panel1_data] + add edx, [ebp + panel1_height - panel1_data] + dec edx + mov esi, edi + call get_console_ptr + mov ah, [panel_number_color] +@@: + lodsb + stosw + loop @b cmp [ebp + panel1_numfiles - panel1_data], 0 jz .skip_curinfo -; Информация о выбранном файле +; Информация о текущем файле mov ebx, [ebp + panel1_index - panel1_data] mov eax, [ebp + panel1_files - panel1_data] mov ebx, [eax+ebx*4] @@ -2572,6 +3219,8 @@ draw_panel: mov ecx, [ebp + panel1_width - panel1_data] dec ecx dec ecx + cmp [ebp + panel1_colmode - panel1_data], 3 + jz .show_curname ; Время модификации sub edi, 5*2 sub ecx, 6 @@ -2702,6 +3351,7 @@ draw_panel: jnz .size_num .size_done: cld +.show_curname: ; Имя sub edi, ecx sub edi, ecx @@ -2735,52 +3385,115 @@ draw_panel: call draw_image ret -draw_column: - mov eax, [column_left] - mov edx, [column_top] - call get_console_ptr -; заголовок столбца - push edi - mov ah, [column_header_color] - mov al, ' ' - mov ecx, [column_width] +fill_total_info: + mov edi, saved_file_name+511 + mov byte [edi], ' ' if lang eq ru - sub ecx, 3 + mov byte [edi-1], 'е' + dec edi + cmp eax, 1 + jz @f + mov word [edi-1], 'ах' + dec edi +@@: + mov dword [edi-4], 'файл' + mov byte [edi-5], ' ' + sub edi, 5 else - sub ecx, 4 + cmp eax, 1 + jz @f + dec edi + mov byte [edi], 's' +@@: + mov dword [edi-4], 'file' + mov byte [edi-5], ' ' + sub edi, 5 end if - shr ecx, 1 - rep stosw + xor edx, edx + push 10 + pop ecx +@@: + div ecx + dec edi + add dl, '0' + mov [edi], dl + xor edx, edx + test eax, eax + jnz @b if lang eq ru - mov al, 'И' - stosw - mov al, 'м' - stosw - mov al, 'я' - stosw + mov dword [edi-4], 'т в ' + mov dword [edi-8], ' бай' + sub edi, 8 else - mov al, 'N' - stosw - mov al, 'a' - stosw - mov al, 'm' - stosw - mov al, 'e' - stosw + mov dword [edi-4], ' in ' + mov dword [edi-8], 'ytes' + mov word [edi-10], ' b' + sub edi, 10 end if - mov al, ' ' - mov ecx, [column_width] -if lang eq ru - sub ecx, 2 -else - sub ecx, 3 -end if - shr ecx, 1 - rep stosw - pop edi - add edi, [cur_width] - add edi, [cur_width] -; файлы + lea esi, [edi-3] + mov edx, [esp+8] + mov eax, [esp+4] +.selsizel: + push edx + mov ebx, edx + xor edx, edx + add ebx, ebx + adc edx, edx + push ebx + push edx + add ebx, ebx + adc edx, edx + add ebx, [esp+4] + adc edx, [esp] + add esp, 8 + add eax, ebx + adc edx, 0 + div ecx + dec edi + cmp edi, esi + jae @f + mov byte [edi], ',' + dec edi + sub esi, 4 +@@: + pop ebx + add dl, '0' + mov byte [edi], dl + xchg eax, ebx + mul [muldiv10] + add eax, ebx + adc edx, 0 + mov ebx, eax + or ebx, edx + jnz .selsizel + dec edi + mov byte [edi], ' ' + mov ecx, saved_file_name+512 + sub ecx, edi + ret 8 + +get_file_color: + mov ah, [esi + 6] + cmp ebp, [active_panel] + jnz @f + cmp ecx, [ebp + panel1_index - panel1_data] + jnz @f + mov ah, [esi + 7] +@@: + test byte [esi + 303], 1 + jnz @f + mov ah, [esi + 4] + cmp ebp, [active_panel] + jnz @f + cmp ecx, [ebp + panel1_index - panel1_data] + jnz @f + mov ah, [esi + 5] +@@: + ret + +draw_name_column: + mov eax, [column_index] + mov [last_column_index], eax mov edx, [ebp + panel1_numfiles - panel1_data] mov ecx, [column_height] dec ecx @@ -2788,18 +3501,12 @@ end if cmp [column_index], edx jae .ret push ecx - mov esi, [column_index] - mov ecx, [ebp + panel1_files - panel1_data] - mov esi, [ecx+esi*4] - add esi, 40 - mov ah, [esi - 40 + 5] - cmp ebp, [active_panel] - jnz @f mov ecx, [column_index] - cmp ecx, [ebp + panel1_index - panel1_data] - jnz @f - mov ah, [esi - 40 + 6] -@@: + mov esi, [ebp + panel1_files - panel1_data] + mov esi, [esi+ecx*4] + mov ebx, [esi] + call get_file_color + add esi, 40 mov ecx, [column_width] push edi @@: @@ -2808,12 +3515,68 @@ end if jz @f stosw loop @b - cmp byte [esi], 0 + lodsb + test al, al jz @f mov byte [edi], '}' + jmp .continue +@@: + test bl, 10h + jnz .noalignext + mov ebx, [ebp + panel1_colmode - panel1_data] +; sizeof(PanelMode) = 40 + lea ebx, [ebx+ebx*4] + cmp [colmodes+ebx*8+PanelMode.bAlignExtensions], 0 + jz .noalignext + push ecx + sub ecx, [column_width] + neg ecx + jz .noalignext2 + dec esi +@@: + dec esi + cmp byte [esi], '.' + loopnz @b + jnz .noalignext2 + inc esi + sub ecx, [column_width] + neg ecx + sub ecx, [esp] + sub edi, ecx + sub edi, ecx + dec ecx + mov ebx, [esp+4] + cmp ecx, 3 + ja @f + mov cl, 3 +@@: + sub ecx, [column_width] + sub ebx, edi + sar ebx, 1 + sub ebx, ecx + pop ecx + inc ecx + push 0 + cmp ecx, ebx + jbe @f + sub ecx, ebx + mov [esp], ecx + mov ecx, ebx @@: mov al, ' ' rep stosw +@@: + lodsb + test al, al + jz .noalignext2 + stosw + jmp @b +.noalignext2: + pop ecx +.noalignext: + mov al, ' ' + rep stosw +.continue: pop edi add edi, [cur_width] add edi, [cur_width] @@ -2822,6 +3585,8 @@ end if dec ecx jnz .l .ret: + mov eax, [ebp + panel1_colsz - panel1_data] + add [ebp + panel1_colst - panel1_data], eax cmp ebp, panel1_data jnz .ret2 ; Число экранов @@ -2855,6 +3620,267 @@ end if mov ah, [panel_nscreens_color] stosw .ret2: +draw_empty_column: + ret + +draw_size_column: + add edi, [column_width] + add edi, [column_width] + dec edi + dec edi + std + mov ecx, [column_height] + dec ecx + push [last_column_index] +.l: + mov edx, [ebp + panel1_numfiles - panel1_data] + cmp [last_column_index], edx + jae .ret + push ecx + push edi + mov ecx, [last_column_index] + mov esi, [ebp + panel1_files - panel1_data] + mov esi, [esi+ecx*4] + call get_file_color + mov ecx, [column_width] +@@: + mov ebx, eax + cmp word [esi+40], '..' + jnz .nodotdot + cmp byte [esi+42], 0 + jnz .nodotdot +if lang eq ru + mov al, 'х' + stosw + mov al, 'р' + stosw + mov al, 'е' + stosw + mov al, 'в' + stosw + mov al, 'В' + stosw + sub ecx, 5 +else + mov al, ' ' + stosw + stosw + mov al, 'p' + stosw + mov al, 'U' + stosw + sub ecx, 4 +end if + jmp .size_written +.nodotdot: + test byte [esi], 10h + jz .nofolder +if lang eq ru + mov al, 'а' + stosw + mov al, 'к' + stosw + mov al, 'п' + stosw + mov al, 'а' + stosw + mov al, 'П' + stosw + sub ecx, 5 +else + mov al, 'r' + stosw + mov al, 'e' + stosw + mov al, 'd' + stosw + mov al, 'l' + stosw + mov al, 'o' + stosw + mov al, 'F' + stosw + sub ecx, 6 +end if + jmp .size_written +.nofolder: + mov eax, [esi+32] + mov edx, [esi+36] + test edx, edx + jz .less_4G + cmp edx, 10000/4*1024 + jb .giga + mov al, 'T' + shr edx, 10 + jmp .write_letter +.giga: + mov al, 'G' + shl edx, 2 + jmp .write_letter +.less_4G: + mov edx, eax + cmp eax, 1000000 + jb .byte + cmp eax, 10000*1024 + jb .kilo + mov al, 'M' + shr edx, 20 + jmp .write_letter +.kilo: + mov al, 'K' + shr edx, 10 +.write_letter: + mov ah, bh + stosw + mov al, ' ' + stosw + dec ecx + dec ecx +.byte: + xchg eax, edx + xor edx, edx + div [_10d] + xchg eax, edx + add al, '0' + mov ah, bh + stosw + dec ecx + test edx, edx + jnz .byte +.size_written: + mov eax, ebx + test ecx, ecx + jle @f + mov al, ' ' + rep stosw +@@: + mov byte [edi+1], ah + pop edi + add edi, [cur_width] + add edi, [cur_width] + inc [last_column_index] + pop ecx + dec ecx + jnz .l +.ret: + pop [last_column_index] + cld + ret + +draw_date_column: + mov ecx, [column_height] + dec ecx + push [last_column_index] +.l: + mov edx, [ebp + panel1_numfiles - panel1_data] + cmp [last_column_index], edx + jae .ret + push ecx + push edi + mov ecx, [last_column_index] + mov esi, [ebp + panel1_files - panel1_data] + mov esi, [esi+ecx*4] + call get_file_color + mov bh, ah + mov byte [edi-1], bh + mov al, [esi+28] + aam + add eax, '00' + push eax + mov al, ah + mov ah, bh + stosw + pop eax + mov ah, bh + stosw + mov al, '.' + stosw + mov al, [esi+29] + aam + add eax, '00' + push eax + mov al, ah + mov ah, bh + stosw + pop eax + mov ah, bh + stosw + mov al, '.' + stosw + movzx eax, word [esi+30] + xor edx, edx + div [_10d] + xchg eax, edx + add al, '0' + mov ah, bh + mov [edi+2], ax + xchg eax, edx + xor edx, edx + div [_10d] + xchg eax, edx + add al, '0' + mov ah, bh + stosw + pop edi + add edi, [cur_width] + add edi, [cur_width] + inc [last_column_index] + pop ecx + dec ecx + jnz .l +.ret: + pop [last_column_index] + cld + ret + +draw_time_column: + mov ecx, [column_height] + dec ecx + push [last_column_index] +.l: + mov edx, [ebp + panel1_numfiles - panel1_data] + cmp [last_column_index], edx + jae .ret + push ecx + push edi + mov ecx, [last_column_index] + mov esi, [ebp + panel1_files - panel1_data] + mov esi, [esi+ecx*4] + call get_file_color + mov bh, ah + mov byte [edi-1], bh + mov al, [esi+26] + aam + add eax, '00' + push eax + mov al, ah + mov ah, bh + stosw + pop eax + mov ah, bh + stosw + mov al, ':' + stosw + mov al, [esi+25] + aam + add eax, '00' + push eax + mov al, ah + mov ah, bh + stosw + pop eax + mov ah, bh + stosw + pop edi + add edi, [cur_width] + add edi, [cur_width] + inc [last_column_index] + pop ecx + dec ecx + jnz .l +.ret: + pop [last_column_index] + cld ret ;insert_last_dot: @@ -2899,6 +3925,13 @@ read_folder: mov [dirinfo.dirdata], eax lea eax, [ebp + panel1_dir - panel1_data] mov [dirinfo.name], eax + xor eax, eax + mov [ebp + panel1_total_num - panel1_data], eax + mov dword [ebp + panel1_total_size - panel1_data], eax + mov dword [ebp + panel1_total_size+4 - panel1_data], eax + mov [ebp + panel1_selected_num - panel1_data], eax + mov dword [ebp + panel1_selected_size - panel1_data], eax + mov dword [ebp + panel1_selected_size+4 - panel1_data], eax .retry: push 70 pop eax @@ -2911,12 +3944,12 @@ read_folder: ; Failed to read folder, notify user cmp [bSilentFolderMode], 0 jnz .dont_notify - push aContinue - push aRetry + push dword aContinue + push dword aRetry mov edx, esp call get_error_msg push [dirinfo.name] - push aCannotReadFolder + push dword aCannotReadFolder push eax mov eax, esp push edx @@ -2925,7 +3958,7 @@ read_folder: push 3 push -1 push -1 - push aError + push dword aError call SayErr add esp, 5*4 test eax, eax @@ -2984,17 +4017,16 @@ read_folder: mov eax, [dirinfo.dirdata] cmp [eax+8], ebx jz .readdone - push eax - mov eax, [ebp + panel1_files - panel1_data] - call mf_free - pop eax - mov eax, [eax+8] - add eax, 0xF - and eax, not 0xF - push eax - imul eax, 4+304 - add eax, 32 - call xmalloc + push dword [eax+8] + mov ecx, [ebp + panel1_files - panel1_data] + call pgfree + pop ecx + add ecx, 0xF + and ecx, not 0xF + push ecx + imul ecx, 4+304 + add ecx, 32 + call xpgalloc test eax, eax jnz .succ1 pop eax @@ -3021,6 +4053,7 @@ read_folder: jz .loopcont test byte [eax], 8 jnz .loopcont + mov byte [eax+303], 0 test edx, edx jnz .nodotdot cmp word [eax+40], '..' @@ -3043,6 +4076,14 @@ read_folder: jmp .dotdot .nodotdot: stosd + xor ebx, ebx + test byte [eax], 10h + setz bl + add [ebp + panel1_total_num - panel1_data], ebx + mov ebx, dword [eax+32] + add dword [ebp + panel1_total_size - panel1_data], ebx + mov ebx, dword [eax+36] + adc dword [ebp + panel1_total_size+4 - panel1_data], ebx .dotdot: ; подсветка ; call insert_last_dot @@ -3051,9 +4092,10 @@ read_folder: lea esi, [ebp+40] mov edi, lower_file_name mov edx, edi + xor eax, eax @@: lodsb - call tolower + mov al, [tolower_table+eax] stosb test al, al jnz @b @@ -3075,13 +4117,25 @@ read_folder: jnz @f mov ah, [panel_normal_color] @@: - mov [ebp+5], ah + mov [ebp+4], ah mov ah, [ebx + highlight.CursorColor] test ah, ah jnz @f mov ah, [panel_cursor_color] +@@: + mov [ebp+5], ah + mov ah, [ebx + highlight.SelectedColor] + test ah, ah + jnz @f + mov ah, [panel_selected_color] @@: mov [ebp+6], ah + mov ah, [ebx + highlight.SelectedCursorColor] + test ah, ah + jnz @f + mov ah, [panel_selected_cursor_color] +@@: + mov [ebp+7], ah jmp .doname .highlight_test_failed: inc ecx @@ -3089,9 +4143,13 @@ read_folder: jb .highlight_test_loop .nohighlight: mov ah, [panel_normal_color] - mov [ebp+5], ah + mov [ebp+4], ah mov ah, [panel_cursor_color] + mov [ebp+5], ah + mov ah, [panel_selected_color] mov [ebp+6], ah + mov ah, [panel_selected_cursor_color] + mov [ebp+7], ah .doname: ; call delete_last_dot popad @@ -3112,9 +4170,9 @@ sort_files: mov ecx, [ebp + panel1_numfiles - panel1_data] jecxz .skip mov eax, [edx] - cmp word [eax], '..' + cmp word [eax+40], '..' jnz .nodotdot - cmp byte [eax+2], 0 + cmp byte [eax+42], 0 jnz .nodotdot dec ecx add edx, 4 @@ -3869,24 +4927,22 @@ match_single_mask_rev: jmp .done_succ end if -tolower: - cmp al, 'A' - jb @f - cmp al, 'Z' - ja @f - add al, ' ' -@@: ret +;tolower: +; push ecx +; movzx ecx, al +; mov al, [tolower_table+ecx] +; pop ecx +; ret match_symbol: ; in: al,[edi]=symbols ; out: flags as 'cmp al,[edi]' - push eax - call tolower - mov ah, [edi] - xchg al, ah - call tolower - cmp ah, al - pop eax + push eax ecx + movzx ecx, al + mov al, [tolower_table+ecx] + movzx ecx, byte [edi] + cmp al, [tolower_table+ecx] + pop ecx eax ret match_mask_rev_lowercase: @@ -3903,6 +4959,8 @@ match_mask_rev_lowercase: jz @f cmp al, ',' jz @f + cmp al, ';' + jz @f cmp al, '|' jnz @b @@: @@ -3914,6 +4972,8 @@ match_mask_rev_lowercase: jnc .found cmp al, ',' jz .main_cycle + cmp al, ';' + jz .main_cycle .done_fail: stc popa @@ -3936,6 +4996,8 @@ match_mask_rev_lowercase: test al, al jz @f cmp al, ',' + jz @f + cmp al, ';' jnz @b @@: dec esi @@ -4079,23 +5141,31 @@ find_extension: ret .found_ext: inc esi - mov edi, associations -@@: + mov edi, [associations] +.find_loop: push esi edi - mov edi, [edi] call strcmpi pop edi esi - jz @f - add edi, 12 - cmp edi, associations_end - jb @b -; unknown extension - inc edi + pushf @@: + inc edi + cmp byte [edi-1], 0 + jnz @b + popf + jz .found +@@: + inc edi + cmp byte [edi-1], 0 + jnz @b + cmp byte [edi], 0 + jnz .find_loop +; unknown extension + stc +.found: pop esi ret -header db 'Kolibri Far 0.21',0 +header db 'Kolibri Far 0.32',0 nomem_draw db 'No memory for redraw.',0 .size = $ - nomem_draw @@ -4121,8 +5191,10 @@ aDrive db 'Drive',0 aScreens db 'Screens',0 end if +align 4 _10d dd 10 _100d dd 100 +muldiv10 dd 429496729 _10 db 10 _100 db 100 @@ -4481,11 +5553,13 @@ console_data_ptr dd 0 cursor_x dd -1 cursor_y dd -1 -old_cursor_x dd -1 -old_cursor_y dd -1 +cur_cursor_pos dd -1 +old_cursor_pos dd -1 active_panel dd panel1_data +associations dd 0 + console_colors dd 0x000000, 0x000080, 0x008000, 0x008080 dd 0x800000, 0x800080, 0x808000, 0xC0C0C0 dd 0x808080, 0x0000FF, 0x00FF00, 0x00FFFF @@ -4555,10 +5629,14 @@ errors2: encodings: .cp866 = 0 .cp1251 = 1 +.koi8r = 2 +.unicode = 3 .names: db 'cp866 ' db 'cp1251 ' + db 'koi8-r ' + db 'Unicode ' .tables: ; cp866 - trivial map @@ -4570,6 +5648,49 @@ encodings: db 0xF8,0x2B,0x49,0x69,0x3F,0xE7,0x14,0xFA,0xF1,0xFC,0xF3,0x3E,0x3F,0x3F,0x3F,0xF5 times 0x30 db %-1+0x80 times 0x10 db %-1+0xE0 +; koi8-r + db 0xC4,0xB3,0xDA,0xBF,0xC0,0xD9,0xC3,0xB4,0xC2,0xC1,0xC5,0xDF,0xDC,0xDB,0xDD,0xDE + db 0xB0,0xB1,0xB2,0xF4,0xFE,0xF9,0xFB,0xF7,0xF3,0xF2,0xFF,0xF5,0xF8,0xFD,0xFA,0xF6 + db 0xCD,0xBA,0xD5,0xF1,0xD6,0xC9,0xB8,0xB7,0xBB,0xD4,0xD3,0xC8,0xBE,0xBD,0xBC,0xC6 + db 0xC7,0xCC,0xB5,0xF0,0xB6,0xB9,0xD1,0xD2,0xCB,0xCF,0xD0,0xCA,0xD8,0xD7,0xCE,0xFC + db 0xEE,0xA0,0xA1,0xE6,0xA4,0xA5,0xE4,0xA3,0xE5,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE + db 0xAF,0xEF,0xE0,0xE1,0xE2,0xE3,0xA6,0xA2,0xEC,0xEB,0xA7,0xE8,0xED,0xE9,0xE7,0xEA + db 0x9E,0x80,0x81,0x96,0x84,0x85,0x94,0x83,0x95,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E + db 0x8F,0x9F,0x90,0x91,0x92,0x93,0x86,0x82,0x9C,0x9B,0x87,0x98,0x9D,0x99,0x97,0x9A + +.menu: + db .cp866 +.menu.1: + dd .menu.2 + dd 0 +if lang eq ru + db '&DOS текст (cp866)',0 +else + db '&DOS text (cp866)',0 +end if + db .cp1251 +.menu.2: + dd .menu.3 + dd .menu.1 +if lang eq ru + db '&Windows текст (cp1251)',0 +else + db '&Windows text (cp1251)',0 +end if + db .koi8r +.menu.3: + dd .menu.4 + dd .menu.2 +if lang eq ru + db '&Linux текст (koi8-r)',0 +else + db '&Linux text (koi8-r)',0 +end if + db .unicode +.menu.4: + dd 0 + dd .menu.3 + db '&Unicode',0 active_screen dd 0 tabsize dd 8 @@ -4608,6 +5729,10 @@ panels_ctrlkeys: dd panels_OnKey.left dw 0x4D, 0 dd panels_OnKey.right + dw 0x51, 0 + dd panels_OnKey.pgdn + dw 0x49, 0 + dd panels_OnKey.pgup dw 0xF, 0 dd panels_OnKey.tab dw 0x47, 0 @@ -4644,6 +5769,24 @@ end repeat dd F12 dw 0x13, 0x10 dd panels_OnKey.ctrl_r + dw 2, 0x30 + dd panels_OnKey.change_mode + dw 3, 0x30 + dd panels_OnKey.change_mode + dw 4, 0x30 + dd panels_OnKey.change_mode + dw 5, 0x30 + dd panels_OnKey.change_mode +repeat 10 + dw %+1, 0x40 + dd panels_OnKey.quick_jump +end repeat + dw 0x52, 0 + dd panels_OnKey.insert + dw 0x4E, 0 + dd panels_OnKey.greyplus + dw 0x4A, 0 + dd panels_OnKey.greyminus db 0 viewer_ctrlkeys: @@ -4679,6 +5822,8 @@ viewer_ctrlkeys: dd viewer_OnKey.f4 dw 0x42, 0 dd viewer_OnKey.f8 + dw 0x42, 1 + dd viewer_OnKey.shift_f8 dw 0x44, 0 dd viewer_OnKey.exit dw 0x47, 0 @@ -4753,11 +5898,15 @@ end if ; Панель panel_normal_color db 1Bh +panel_selected_color db 1Eh panel_border_color db 1Bh panel_cursor_color db 30h +panel_selected_cursor_color db 3Eh panel_header_color db 1Bh panel_active_header_color db 30h column_header_color db 1Eh +panel_number_color db 1Bh +panel_numselected_color db 3Eh panel_nscreens_color db 0Bh ; Диалоги dialog_colors: @@ -4814,151 +5963,71 @@ highlight_groups dd highlight_group0 ; Формат описания группы подсветки: virtual at 0 highlight: + .IncludeAttributes db ? .NormalColor db ? .CursorColor db ? - .IncludeAttributes db ? + .SelectedColor db ? + .SelectedCursorColor db ? .Mask: ; ASCIIZ-string end virtual ; all highlight masks must be in lowercase! highlight_group0: - db 13h - db 38h db 2 + db 13h, 38h, 0, 0 db '*',0 highlight_group1: - db 13h - db 38h db 4 + db 13h, 38h, 0, 0 db '*',0 highlight_group2: - db 1Fh - db 3Fh db 10h + db 1Fh, 3Fh, 0, 0 db '*|..',0 highlight_group3: - db 0 - db 0 db 10h + db 0, 0, 0, 0 db '..',0 highlight_group4: - db 1Ah - db 3Ah db 0 + db 1Ah, 3Ah, 0, 0 db '*.exe,*.com,*.bat,*.cmd',0 highlight_group5: - db 1Ah - db 3Ah db 0 + db 1Ah, 3Ah, 0, 0 db '*|*.*',0 highlight_group6: - db 1Dh - db 3Dh db 0 + db 1Dh, 3Dh, 0, 0 db '*.rar,*.zip,*.[zj],*.[bg7]z,*.[bg]zip,*.tar,*.t[ag]z,*.ar[cj],*.r[0-9][0-9],' db '*.a[0-9][0-9],*.bz2,*.cab,*.msi,*.jar,*.lha,*.lzh,*.ha,*.ac[bei],*.pa[ck],' db '*.rk,*.cpio,*.rpm,*.zoo,*.hqx,*.sit,*.ice,*.uc2,*.ain,*.imp,*.777,*.ufa,*.boa,' db '*.bs[2a],*.sea,*.hpk,*.ddi,*.x2,*.rkv,*.[lw]sz,*.h[ay]p,*.lim,*.sqz,*.chz',0 highlight_group7: - db 16h - db 36h db 0 + db 16h, 36h, 0, 0 db '*.bak,*.tmp',0 highlight_group8: - db 17h - db 37h db 0 + db 17h, 37h, 0, 0 db '*.asm,*.inc',0 highlight_group9: - db 1Fh - db 3Fh db 10h + db 1Fh, 3Fh, 0, 0 db '*',0 -associations: - dd aAsm, tinypad, AsmMenu - dd aInc, tinypad, 0 - dd aTxt, tinypad, 0 - dd aJpg, jpegview, 0 - dd aJpeg, jpegview, 0 - dd aGif, gifview, GifMenu - dd aWav, ac97, 0 - dd aMp3, ac97, 0 - dd aMid, midamp, 0 - dd aBmp, mv, BmpMenu - dd aPng, archer, 0 - dd aRtf, rtfread, 0 - dd a3ds, view3ds, 0 - dd aLif, life2, 0 -associations_end: - -aAsm db 'asm',0 -aInc db 'inc',0 -aTxt db 'txt',0 -tinypad db '/rd/1/TinyPad',0 - -aJpg db 'jpg',0 -aJpeg db 'jpeg',0 -jpegview db '/rd/1/JpegView',0 - -aGif db 'gif',0 -gifview db '/rd/1/GIFVIEW',0 - -aWav db 'wav',0 -aMp3 db 'mp3',0 -ac97 db '/rd/1/AC97SND',0 - -aMid db 'mid',0 -midamp db '/rd/1/MIDAMP',0 - -aBmp db 'bmp',0 -mv db '/rd/1/MV',0 - -aPng db 'png',0 -archer db '/rd/1/@rcher',0 - -aRtf db 'rtf',0 -rtfread db '/rd/1/RtfRead',0 - -a3ds db '3ds',0 -view3ds db '/rd/1/3d/view3ds',0 - -aLif db 'lif',0 -life2 db '/rd/1/demos/life2',0 - -AsmMenu: - dd aEdit, tinypad - dd aCompile, fasm - dd 0 -BmpMenu: - dd aView, mv - dd aEdit, animage - dd 0 -GifMenu: - dd aView, gifview - dd aEdit, animage - dd 0 - -if lang eq en -aView db '&View',0 -aCompile db '&Compile',0 -aEdit db '&Edit',0 -else -aView db '&Просмотр',0 -aCompile db '&Компилировать',0 -aEdit db '&Редактор',0 -end if - -fasm db '/rd/1/develop/fasm',0 -animage db '/rd/1/animage',0 - bConfirmDelete db 1 bConfirmDeleteIncomplete db 0 +FolderShortcuts dd 0,0,0,0,0,0,0,0,0,0 + ; Здесь заканчиваются конфигурационные данные bWasE0 db 0 ctrlstate db 0 +MemForImage dd 0 +restore_semicolon dd 0 +bForHex db 0 align 4 ; Сообщение о обломе при выделении памяти @@ -4986,54 +6055,6 @@ nomem_dlgdata: dd aOk dd 0xD -f8_confirm_dlgdata: - dd 1 -.x dd -1 -.y dd -1 -.width dd ? -.height dd 3 - dd 4 - dd 2 - dd aDeleteCaption -.main_color db ? -.border_color db ? -.header_color db ? - db 0 - dd 0 - dd 0 - dd 4 -; строка "Вы хотите удалить ..." - dd 1 - dd 1,0 -.width2 dd ? - dd 0 - dd aConfirmDeleteTextBuf - dd 1 -; строка с именем файла/папки - dd 1 - dd 1,1 -.width3 dd ? - dd 1 -.name dd ? - dd 1 -; кнопка "удалить" -.del_btn: - dd 2 -.del_x1 dd ? - dd 2 -.del_x2 dd ? - dd 2 - dd aDelete -.flags1 dd 0xC -; кнопка "отменить" - dd 2 -.cnl_x1 dd ? - dd 2 -.cnl_x2 dd ? - dd 2 - dd aCancel -.flags2 dd 8 - ; диалог копирования copy_dlgdata: dd 1 @@ -5124,6 +6145,22 @@ mkdir_dlgdata: dd aCancelB .flags2 dd 8 +; диалог выделения/снятия +mark_dlgdata: + dd 1 + dd -1, -1 + dd 37, 1 + dd 4, 2 +.title dd ? + dd ? + dd 0, 0 + dd 1 +; поле редактирования + dd 3 + dd 1, 0, 35, 0 + dd enter_string_buf +.flags dd ? + RetryOrCancelBtn: dd aRetry dd a_Cancel @@ -5133,17 +6170,21 @@ DeleteOrKeepBtn: RetryOrIgnoreBtn: dd aRetry dd aIgnore +DeleteOrCancelBtn: + dd a_Delete + dd a_Cancel +DeleteErrorBtn: + dd aRetry + dd aSkip + dd aSkipAll + dd a_Cancel if lang eq ru aDeleteCaption db 'Удаление',0 -aConfirmDeleteText db 'Вы хотите удалить ',0 -aDeleteFolder db 'папку',0 +aConfirmDeleteText db 'Вы хотите удалить',0 +aDeleteFolder db ' папку',0 aConfirmDeleteTextMax = $ - aConfirmDeleteText - 2 -aDeleteFile db 'файл',0 -aDelete db ' Удалить ',0 -aDeleteLength = $ - aDelete - 1 -aCancel db ' Отменить ',0 -aCancelLength = $ - aCancel - 1 +aDeleteFile db ' файл',0 aCancelB db '[ Отменить ]',0 aCancelBLength = $ - aCancelB - 1 aCopyCaption db 'Копирование',0 @@ -5158,6 +6199,8 @@ aContinue db ' aRetry db 'Повторить',0 a_Cancel db 'Отменить',0 a_Delete db 'Удалить',0 +aSkip db 'Пропустить',0 +aSkipAll db 'Пропустить все',0 error0msg db 'Странно... Нет ошибки',0 error1msg db 'Странно... Не определена база и/или раздел жёсткого диска',0 error2msg db 'Функция не поддерживается для данной файловой системы',0 @@ -5191,12 +6234,24 @@ aMkDirCaption db ' aMkDir db 'Создать папку',0 aMkDirLen = $ - aMkDir - 1 aCannotMakeFolder db 'Не могу создать папку',0 +aName db 3,'Имя' +aSize db 6,'Размер' +aDate db 4,'Дата' +aTime db 5,'Время' +aCannotLoadDLL db 'Не могу загрузить DLL',0 +aInvalidDLL db 'Файл не найден или имеет неверный формат',0 +aMissingExport db 'Необходимая функция не найдена',0 +aInitFailed db 'Ошибка при инициализации',0 +aIncompatibleVersion db 'Несовместимая версия',0 +aTables db 'Таблицы',0 +aSelect db 'Пометить',0 +aDeselect db 'Снять',0 else aDeleteCaption db 'Delete',0 -aConfirmDeleteText db 'Do you wish to delete ',0 -aDeleteFolder db 'the folder',0 +aConfirmDeleteText db 'Do you wish to delete',0 +aDeleteFolder db ' the folder',0 aConfirmDeleteTextMax = $ - aConfirmDeleteText - 2 -aDeleteFile db 'the file',0 +aDeleteFile db ' the file',0 aDelete db ' Delete ',0 aDeleteLength = $ - aDelete - 1 aCancel db ' Cancel ',0 @@ -5215,6 +6270,8 @@ aContinue db 'Continue',0 aRetry db 'Retry',0 a_Cancel db 'Cancel',0 a_Delete db 'Delete',0 +aSkip db 'Skip',0 +aSkipAll db 'Skip all',0 error0msg db 'Strange... No error',0 error1msg db 'Strange... Hard disk base and/or partition not defined',0 error2msg db 'The file system does not support this function',0 @@ -5240,17 +6297,150 @@ aCannotCopyToSelf db 'File cannot be copied onto itself',0 aCannotReadFile db 'Cannot read file',0 aIncompleteFile db 'Incomplete file was retrieved. Delete it?',0 aKeep db 'Keep',0 -aCannotWriteFile db 'Cannot write file',0 -aCannotDeleteFile db 'Cannot delete file',0 -aCannotDeleteFolder db 'Cannot delete folder',0 +aCannotWriteFile db 'Cannot write to the file',0 +aCannotDeleteFile db 'Cannot delete the file',0 +aCannotDeleteFolder db 'Cannot delete the folder',0 aIgnore db 'Ignore',0 aMkDirCaption db 'Make folder',0 aMkDir db 'Create the folder',0 aMkDirLen = $ - aMkDir - 1 aCannotMakeFolder db 'Cannot create folder',0 +aName db 4,'Name' +aSize db 4,'Size' +aDate db 4,'Date' +aTime db 4,'Time' +aCannotLoadDLL db 'Cannot load DLL',0 +aInvalidDLL db 'File is not found or invalid',0 +aMissingExport db 'Required function is not present',0 +aInitFailed db 'Initialization failed',0 +aIncompatibleVersion db 'Incompatible version',0 +aTables db 'Tables',0 +aSelect db 'Select',0 +aDeselect db 'Deselect',0 end if + aOk db 'OK',0 -aNoMemory db 'No memory!',0 +aNoMemory db 'No memory!' +nullstr db 0 +standard_dll_path: +libini_name db '/rd/1/dll/' +standard_dll_path_size = $ - standard_dll_path + db 'libini.obj',0 +aStart db 'START',0 +aLibInit db 'lib_init',0 +aVersion db 'version',0 +aIniGetInt db 'ini.get_int',0 +aIniGetStr db 'ini.get_str',0 +aIniQuerySec db 'ini.query_sec',0 + +aConfirmations db 'Confirmations',0 +aConfirmDelete db 'Delete',0 +aConfirmDeleteIncomplete db 'DeleteIncomplete',0 + +aAssociations db 'Associations',0 +aMenu db 'Menu',0 +aFolderShortcuts db 'FolderShortcuts',0 +aShortcut db 'Shortcut' +.d db '0',0 + +align 4 +ini_import: +ini.get_int dd aIniGetInt +ini.get_str dd aIniGetStr +ini.query_sec dd aIniQuerySec + dd 0 + +virtual at 0 +PanelMode: +; up to 16 columns on one panel +.NumColumns dd ? +; available column types: +COLUMN_TYPE_NONE = 0 +COLUMN_TYPE_NAME = 1 + COLUMN_NAME_MARK = 10h ; (reserved) + COLUMN_NAME_NOPATH = 20h ; (reserved) + COLUMN_NAME_RIGHTALIGN = 40h ; (reserved) +COLUMN_TYPE_SIZE = 2 + COLUMN_SIZE_COMMA = 10h ; (reserved) +COLUMN_TYPE_PACKED_SIZE = 3 ; (reserved) +COLUMN_TYPE_DATE = 4 +COLUMN_TYPE_TIME = 5 +COLUMN_TYPE_DATETIME = 6 ; (reserved) +COLUMN_TYPE_DATETIME_CREATION = 7 ; (reserved) +COLUMN_TYPE_DATETIME_ACCESS = 8 ; (reserved) +COLUMN_TYPE_ATTRIBUTES = 9 ; (reserved) +COLUMN_TYPE_DESCRIPTION = 10 ; (reserved) +COLUMN_TYPE_OWNER = 11 ; (reserved) +COLUMN_TYPE_NUMLINKS = 12 ; (reserved) +COLUMN_TYPE_CUSTOM = 13 ; (reserved) +.ColumnTypes rb 16 + +.ColumnWidths rb 16 +.bFullScreen db ? ; (reserved) +.bAlignExtensions db ? + rb 2 +.size = $ +end virtual + +align 4 +column_headers: + dd nullstr + dd aName + dd aSize + dd nullstr + dd aDate + dd aTime +draw_column_proc: + dd draw_empty_column + dd draw_name_column + dd draw_size_column + dd -1 + dd draw_date_column + dd draw_time_column +colmodes: +; режим 0 : NM,SC,D + dd 3 + db COLUMN_TYPE_NAME+COLUMN_NAME_MARK, COLUMN_TYPE_SIZE+COLUMN_SIZE_COMMA + db COLUMN_TYPE_DATE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + db 0, 10, 8 + times 13 db 0 + db 0, 1 + times 2 db 0 +; режим 1 : N,N,N + dd 3 + db COLUMN_TYPE_NAME, COLUMN_TYPE_NAME, COLUMN_TYPE_NAME + times 13 db 0 + times 16 db 0 + db 0, 1 + times 2 db 0 +; режим 2 : N,N + dd 2 + db COLUMN_TYPE_NAME, COLUMN_TYPE_NAME + times 14 db 0 + times 16 db 0 + db 0, 0 + times 2 db 0 +; режим 3 : N,S,D,T + dd 4 + db COLUMN_TYPE_NAME, COLUMN_TYPE_SIZE, COLUMN_TYPE_DATE, COLUMN_TYPE_TIME + times 12 db 0 + db 0, 6, 8, 5 + times 12 db 0 + db 0, 1 + times 2 db 0 +; режим 4 : N,S + dd 2 + db COLUMN_TYPE_NAME, COLUMN_TYPE_SIZE + times 14 db 0 + db 0, 6 + times 14 db 0 + db 0, 0 + times 2 db 0 +; режим 5 : N,S,P,DM,DC,DA,A +; режим 6 : N,Z +; режим 7 : N,S,Z +; режим 8 : N,S,O +; режим 9 : N,S,LN execinfo: dd 7 @@ -5286,6 +6476,12 @@ panel1_sortmode db ? panel1_nfa dd ? panel1_numfiles dd ? panel1_files dd ? +panel1_colmode dd ? +panel1_colwidths rd 16+1 +panel1_total_num dd ? +panel1_total_size dq ? +panel1_selected_num dd ? +panel1_selected_size dq ? panel1_dir rb 1024 panel2_data: @@ -5302,6 +6498,12 @@ panel2_sortmode db ? panel2_nfa dd ? panel2_numfiles dd ? panel2_files dd ? +panel2_colmode dd ? +panel2_colwidths rd 16+1 +panel2_total_num dd ? +panel2_total_size dq ? +panel2_selected_num dd ? +panel2_selected_size dq ? panel2_dir rb 1024 ;console_data rb max_width*max_height*2 @@ -5329,6 +6531,7 @@ column_top dd ? column_width dd ? column_height dd ? column_index dd ? +last_column_index dd ? scrpos dq ? viewer_right_side dq ? @@ -5337,6 +6540,8 @@ saved_file_name: procinfo rb 1024 lower_file_name = procinfo + 512 +app_path rb 1100 + error_msg rb 128 prev_dir rb 1024 @@ -5354,12 +6559,26 @@ CopySourceTextBuf rb 512 CopyDestEditBuf rb 12+512+1 .length = $ - CopyDestEditBuf - 13 +enter_string_buf rb 12+512+1 + +bMemForImageValidData db ? + align 4 +tolower_table rb 256 layout rb 128 copy_buffer_size = 32768 copy_buffer rb copy_buffer_size +; data for directory delete +; If directory nested level is >1024, then its full name is too big, +; so we see the overflow when creating full name (we check for this!) +del_dir_stack rd 1024 +del_dir_stack_ptr dd ? +del_dir_query_size = 32 +del_dir_query_area rb 32+304*del_dir_query_size +del_bSkipAll db ? + ; stack align 4 rb 512 diff --git a/programs/fs/kfar/trunk/memalloc.inc b/programs/fs/kfar/trunk/memalloc.inc deleted file mode 100644 index ed79aae18e..0000000000 --- a/programs/fs/kfar/trunk/memalloc.inc +++ /dev/null @@ -1,517 +0,0 @@ -if ~ used memalloc_inc -memalloc_inc_fix: -memalloc_inc fix memalloc_inc_fix -;kglobals.inc required. -;multithread: ;uncomment this for thread-safe version -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Memory allocator for MenuetOS ;; -;; Halyavin Andrey halyavin@land.ru, 2006 ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; allocated mem block structure ;; -;; +0: bit 0 - used flag ;; -;; bits 31..1 - block size ;; -;; +4: address of prev block ;; -;; +8 .. +(blocksize) - allocated memory ;; -;; +(blocksize) - next block ;; -;; ;; -;; free mem block structure ;; -;; +0: bit 0 - used flag ;; -;; bits 31..1 - block size ;; -;; +4: address of prev block ;; -;; +8: prev free block ;; -;; +12: next free block ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -memblock.size=0 -memblock.prevblock=4 -memblock.prevfreeblock=8 -memblock.nextfreeblock=12 -uglobal - heapsmallblocks rd 1 - heapstart rd 1 - heapend rd 1 - heapfreelist rd 1 - heapmutex rd 1 - heaplastblock rd 1 -endg - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; mf_init ;; -;; Initialize memory map for dynamic use ;; -;; input: eax: starting address or 0 ;; -;; output: none ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -mf_init: - push ebx - push ecx - test eax,eax - jnz .noautodet - sub esp,1024 - mov ebx,esp - mov ecx,-1 - mov eax,9 - int 0x40 - mov eax,[esp+26] - add esp,1024 -.noautodet: - add eax,15 - and eax,not 15 - mov [heapsmallblocks],eax - add eax,2048 - mov [heapstart],eax - mov [heapfreelist],eax - mov [heaplastblock],eax - - mov ecx,eax -if defined heapstartsize - add ecx,heapstartsize -else - add ecx,4096 -end if - add ecx,4095 - and ecx,not 4095 - push eax - mov eax,64 - mov ebx,1 - int 0x40 - pop eax - mov [eax+memblock.prevblock],dword 0 - mov [heapend],ecx - mov [eax+memblock.size],ecx - sub [eax+memblock.size],eax - xor ebx,ebx - mov dword [eax+memblock.prevfreeblock],heapfreelist-memblock.nextfreeblock - mov [eax+memblock.nextfreeblock],ebx - mov [heapmutex],ebx - push edi - mov edi,[heapsmallblocks] - mov ecx,512 - xor eax,eax - rep stosd - pop edi - pop ecx - pop ebx - ret - -if defined multithread -heaplock: - push eax - push ebx - mov eax,68 - mov ebx,1 -.loop: - xchg eax,[heapmutex] - test eax,eax - jz .endloop - int 0x40 ;change task - jmp .loop -.endloop: - pop ebx - pop eax - ret - -heapunlock: - mov [heapmutex],dword 0 - ret -end if - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; heap_split_block ;; -;; Split free block to allocated block and free one. ;; -;; input: ;; -;; eax - size of allocated block ;; -;; ebx - block ;; -;; output: ;; -;; eax - real size of allocated block ;; -;; ebx - pointer to new block ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -heap_split_block: - push ecx - mov ecx,[ebx+memblock.size] - sub ecx,16 - cmp ecx,eax - jge .norm - inc dword [ebx+memblock.size] - mov eax,ecx - xor ebx,ebx - pop ecx - ret -.norm: - add ecx,16 - mov [ebx+memblock.size],eax - inc dword [ebx+memblock.size] - mov [ebx+eax+memblock.prevblock],ebx - add ebx,eax - sub ecx,eax - mov [ebx+memblock.size],ecx - mov ecx,eax - mov eax,ebx - call heap_fix_right - mov eax,ecx - pop ecx - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; heap_add_free_block ;; -;; Add free block to one of free block lists. ;; -;; input: ;; -;; eax - address of free block ;; -;; output: ;; -;; none ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -heap_add_free_block: - cmp dword [eax+memblock.size],4096 - push ebx - jge .bigblock - mov ebx,[eax+memblock.size] - shr ebx,1 - add ebx,[heapsmallblocks] - push dword [ebx] - pop dword [eax+memblock.nextfreeblock] - mov [ebx],eax - mov dword [eax+memblock.prevfreeblock],ebx - sub dword [eax+memblock.prevfreeblock],memblock.nextfreeblock - mov ebx,[eax+memblock.nextfreeblock] - test ebx,ebx - jz .no_next_block - mov [ebx+memblock.prevfreeblock],eax -.no_next_block: - pop ebx - ret -.bigblock: - mov ebx,[heapfreelist] - mov [eax+memblock.nextfreeblock],ebx - mov [heapfreelist],eax - mov dword [eax+memblock.prevfreeblock],heapfreelist-memblock.nextfreeblock -; mov ebx,[eax+memblock.nextfreeblock] - test ebx,ebx - jz .no_next_big_block - mov [ebx+memblock.prevfreeblock],eax -.no_next_big_block: - pop ebx - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; heap_remove_block ;; -;; Remove free block from the list of free blocks. ;; -;; input: ;; -;; eax - free block ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -heap_remove_block: - push ebx - push ecx - mov ecx,[eax+memblock.prevfreeblock] - mov ebx,[eax+memblock.nextfreeblock] - mov [ecx+memblock.nextfreeblock],ebx - test ebx,ebx - jz .no_next_block - mov [ebx+memblock.prevfreeblock],ecx -.no_next_block: - pop ecx - pop ebx - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; mf_alloc -;; allocates a block of memory in heap -;; intput: eax: size of block -;; output: eax: address of allocated memory block or 0 if there's no mem. -;; allocator will not create new nodes that contain less that 8b of space, -;; and minimal allocation is actually 16 bytes - 8 for node and 8 for user. -;; allocator will never create non-aligned memory blocks. -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -mf_alloc: - test eax,eax - jg .not_null ; test that we are not allocating null size block - xor eax,eax - ret -.not_null: -if defined multithread - call heaplock -end if - push edi -; push edx - push ecx - push ebx - add eax,7 - and eax,not 7 ; make sure that block size is aligned - - lea edi,[eax+8] ; desired block size - cmp edi,4096 - jge .general_cycle - - mov ebx,[heapsmallblocks] - xor ecx,ecx - shr edi,1 - -.smallloop: - cmp [ebx+edi],ecx - jnz .smallblockfound - add edi,4 - cmp edi,2048 - jl .smallloop - lea edi,[eax+8] - jmp .general_cycle - -.smallblockfound: - lea ecx,[eax+8] - mov eax,[ebx+edi] - call heap_remove_block - mov ebx,eax - xchg eax,ecx - call heap_split_block - test ebx,ebx - jz .perfect_small_block - mov eax,ebx - call heap_add_free_block -.perfect_small_block: - lea eax,[ecx+8] - jmp .ret - -.general_cycle: -;edi - size needed - mov eax,[heapfreelist] - -.loop: - test eax,eax - jz .new_mem - cmp [eax+memblock.size],edi - jge .blockfound - mov eax,[eax+memblock.nextfreeblock] - jmp .loop - -.blockfound: - call heap_remove_block - mov ebx,eax - mov ecx,eax - mov eax,edi - call heap_split_block - test ebx,ebx - jz .perfect_block - mov eax,ebx - call heap_add_free_block -.perfect_block: - lea eax,[ecx+8] -.ret: -if defined multithread - call heapunlock -end if - pop ebx - pop ecx -; pop edx - pop edi - ret - -.new_mem: - mov eax,edi - add eax,4095 - and eax,not 4095 - mov ecx,[heapend] - add [heapend],eax - push eax - mov eax,64 - push ebx - push ecx - mov ecx,[heapend] - mov ebx,1 - int 0x40 - pop ecx - pop ebx - pop eax - mov [ecx+memblock.size],eax - mov eax,[heaplastblock] - mov [ecx+memblock.prevblock],eax - mov [heaplastblock],ecx - mov eax,ecx - call heap_add_free_block - jmp .general_cycle - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; heap_fix_right ;; -;; input: ;; -;; eax - pointer to free block ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -heap_fix_right: - push ebx - mov ebx,eax - add ebx,[eax+memblock.size] - cmp ebx,[heapend] - jz .endblock - mov [ebx+memblock.prevblock],eax - pop ebx - ret -.endblock: - mov [heaplastblock],eax - pop ebx - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; heap_merge_left ;; -;; input: ;; -;; eax - pointer to free block ;; -;; output: ;; -;; eax - pointer to merged block ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -heap_merge_left: - push ebx - mov ebx,[eax+memblock.prevblock] - test ebx,ebx - jz .ret - test byte [ebx+memblock.size],1 - jnz .ret - xchg eax,ebx - call heap_remove_block - mov ebx,[ebx+memblock.size] - add [eax+memblock.size],ebx - call heap_fix_right -.ret: - pop ebx - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; heap_merge_right ;; -;; input: ;; -;; eax - pointer to free block ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -heap_merge_right: - push ebx - mov ebx,eax - add ebx,[eax+memblock.size] - cmp ebx,[heapend] - jz .ret - test byte [ebx+memblock.size],1 - jnz .ret - xchg eax,ebx - call heap_remove_block - xchg eax,ebx - mov ebx,[ebx+memblock.size] - add [eax+memblock.size],ebx - call heap_fix_right -.ret: - pop ebx - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; mf_free ;; -;; input: ;; -;; eax - pointer ;; -;; output: ;; -;; eax=1 - ok ;; -;; eax=0 - failed ;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -mf_free: - test eax,eax - jnz .no_null - inc eax - ret -.no_null: -if defined multithread - call heaplock -end if - sub eax,8 - dec dword [eax+memblock.size] - call heap_merge_left - call heap_merge_right - call heap_add_free_block -.ret: -if defined multithread - call heapunlock -end if - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; heap_try_reloc -;; input: -;; eax - address -;; ebx - new size -;; output: -;; ebx=1 - ok -;; ebx=0 - failed -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -heap_try_reloc: - push eax - sub eax,8 - add ebx,15 - dec dword [eax+memblock.size] - and ebx,not 7 - cmp [eax+memblock.size],ebx - jge .truncate - push ebx - mov ebx,eax - add ebx,[eax+memblock.size] - cmp ebx,[heapend] - jz .fail ;todo: we can allocate new mem here - test [ebx+memblock.size],byte 1 - jnz .fail - xchg eax,ebx - call heap_remove_block - mov eax,[eax+memblock.size] - add [ebx+memblock.size],eax - mov eax,ebx - call heap_fix_right - pop ebx -.truncate: - xchg eax,ebx - call heap_split_block - test ebx,ebx - jz .no_last_block - mov eax,ebx - call heap_add_free_block - call heap_merge_right -.no_last_block: - xor ebx,ebx - pop eax - inc ebx - ret -.fail: - pop ebx - xor ebx,ebx - pop eax - inc dword [eax-8+memblock.size] - ret - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; mf_realloc -;; input: -;; eax - pointer -;; ebx - new size -;; output: -;; eax - new pointer -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -mf_realloc: - push ebx -if defined multithread - call heaplock -end if - call heap_try_reloc - test ebx,ebx - jnz .ret -;allocate new memory - push eax - mov eax,[esp+4] - call mf_alloc - test eax,eax - jz .fail - push esi - push edi - push ecx - mov edi,eax - mov esi,[esp+12] - mov ecx,[esi-8+memblock.size] - shr ecx,2 - rep movsd - pop ecx - pop edi - pop esi - xchg eax,[esp] - call mf_free -.fail: - pop eax -.ret: -if defined multithread - call heapunlock -end if - pop ebx - ret -end if diff --git a/programs/fs/kfar/trunk/tools.inc b/programs/fs/kfar/trunk/tools.inc index 527299cf6b..1f4d868daa 100644 --- a/programs/fs/kfar/trunk/tools.inc +++ b/programs/fs/kfar/trunk/tools.inc @@ -1,7 +1,43 @@ -xmalloc: -; in: eax=size +pgalloc: +; in: ecx=size ; out: eax=pointer or NULL - call mf_alloc + push ebx + push 68 + pop eax + push 12 + pop ebx + int 0x40 + pop ebx + ret + +pgfree: +; in: ecx=pointer +; destroys eax + push ebx + push 68 + pop eax + push 13 + pop ebx + int 0x40 + pop ebx + ret + +pgrealloc: +; in: ecx=size, edx=pointer +; out: eax=pointer + push ebx + push 68 + pop eax + push 20 + pop ebx + int 0x40 + pop ebx + ret + +xpgalloc: +; in: ecx=size +; out: eax=pointer or NULL + call pgalloc .common: test eax, eax jnz @f @@ -10,11 +46,11 @@ xmalloc: @@: ret -xrealloc: -; in: eax=pointer, ebx=new size +xpgrealloc: +; in: edx=pointer, ecx=new size ; out: eax=pointer or NULL - call mf_realloc - jmp xmalloc.common + call pgrealloc + jmp xpgalloc.common get_error_msg: ; in: eax=error code @@ -67,3 +103,171 @@ get_error_msg: pop ecx edx stosb jmp .ret + +libini_alloc: + push ecx + mov ecx, [esp+8] + call xpgalloc + pop ecx + ret 4 +libini_free: + push ecx + mov ecx, [esp+8] + call pgfree + pop ecx + ret 4 +libini_realloc: + push ecx edx + mov edx, [esp+8+4] + mov ecx, [esp+8+8] + call xpgrealloc + pop edx ecx + ret 8 + +libini_dllload: + push esi + mov esi, [esp+8] +.lib: + lodsd + test eax, eax + jz .ret + push eax + lodsd + xchg esi, [esp] + xor ebp, ebp ; no version control + call load_dll_and_import + pop esi + test eax, eax + jz .lib +.ret: + pop esi + ret 4 + +load_dll_and_import: + cmp byte [eax], '/' + jz .do + push esi + mov edi, saved_file_name + push edi + mov esi, standard_dll_path + mov ecx, standard_dll_path_size + rep movsb + mov esi, eax + mov ecx, 1024-standard_dll_path_size +@@: + lodsb + stosb + test al, al + loopnz @b + pop eax + pop esi + jz .do + push eax + mov edi, aFileNameTooBig +.sayerr: + push dword aCannotLoadDLL + push edi + mov eax, esp + push dword aOk + push esp + push 1 + push eax + push 3 + push -1 + push -1 + push dword aError + call SayErr + add esp, 16 + xor eax, eax + inc eax + ret +.do: + push eax + mov ecx, eax + push 68 + pop eax + push 19 + pop ebx + int 0x40 + mov edi, aInvalidDLL + test eax, eax + jz .sayerr +; initialize import + mov edi, aMissingExport + mov edx, eax +.import_loop: + lodsd + test eax, eax + jz .import_done + call .find_exported_function + jc .sayerr + mov [esi-4], eax + jmp .import_loop +.import_done: +; check version + test ebp, ebp + jz .version_ok + mov edi, aIncompatibleVersion + mov eax, aVersion + call .find_exported_function + jc .sayerr + cmp ax, bp + jb .sayerr + shr eax, 16 + cmp eax, ebp + ja .sayerr +.version_ok: +; initialize library + mov eax, aStart + call .find_exported_function + jc @f + push 1 ; DLL_ENTRY + call eax +.ret0: + pop eax + xor eax, eax + ret +@@: + mov eax, aLibInit + call .find_exported_function + jc .ret0 + mov esi, eax + mov eax, libini_alloc + mov ebx, libini_free + mov ecx, libini_realloc + mov edx, libini_dllload + call esi + mov edi, aInitFailed + test eax, eax + jnz .sayerr + jmp .ret0 + +.find_exported_function: + push edx +.import_loop_i: + mov ebx, [edx] + test ebx, ebx + jz .import_notfound + push eax +@@: + mov cl, [eax] + cmp cl, [ebx] + jnz .import_find_next + test cl, cl + jz .import_found + inc eax + inc ebx + jmp @b +.import_find_next: + pop eax + add edx, 8 + jmp .import_loop_i +.import_found: + pop eax + mov eax, [edx+4] + pop edx + ret +.import_notfound: + pop edx + stc + ret diff --git a/programs/fs/kfar/trunk/viewer.inc b/programs/fs/kfar/trunk/viewer.inc index facf5e79df..7bf9891733 100644 --- a/programs/fs/kfar/trunk/viewer.inc +++ b/programs/fs/kfar/trunk/viewer.inc @@ -10,6 +10,7 @@ viewer_data: .bEofReached db ? .flags db ? ; & 1: hex mode ; & 2: unwrap + ; & 4: big-endian unicode rb 1 .filename rb 1024 .buf rb 16384 @@ -24,9 +25,11 @@ view_file: ret .file: lea esi, [ebp + panel1_dir - panel1_data] - mov eax, viewer_data.size + push ecx + mov ecx, viewer_data.size mov edx, viewer_vtable call new_screen + pop ecx test eax, eax jnz @f ret @@ -128,12 +131,40 @@ view_file: jz .attr_retry jmp delete_active_screen .readok: + cmp ebx, 2 + jb .nounicode + cmp word [ebp+viewer_data.buf], 0xFEFF + jz @f + cmp word [ebp+viewer_data.buf], 0xFFFE + jnz .nounicode + or byte [ebp+viewer_data.flags], 4 +@@: + mov [ebp+viewer_data.encoding], encodings.unicode +.nounicode: call viewer_set_keybar call viewer_draw_text ret viewer_get_next_char: pusha + cmp [ebp+viewer_data.encoding], encodings.unicode + jnz @f + cmp [bForHex], 0 + jnz @f + cmp dword [ebp+viewer_data.buf_start], 0 + jnz @f + cmp dword [ebp+viewer_data.buf_start+4], 0 + jnz @f + lea eax, [ebp+viewer_data.buf] + cmp eax, [ebp+viewer_data.buf_pos] + jnz @f + cmp word [eax], 0xFFFE + jz .skip + cmp word [eax], 0xFEFF + jnz @f +.skip: + add [ebp+viewer_data.buf_pos], 2 +@@: mov eax, [ebp+viewer_data.buf_pos] lea ecx, [ebp+viewer_data.buf] add ecx, [ebp+viewer_data.buf_size] @@ -184,6 +215,8 @@ viewer_get_next_char: popa ret .buffered: + cmp [ebp+viewer_data.encoding], encodings.unicode + jz .unicode mov al, [eax] .done: mov [esp+28], al @@ -192,6 +225,17 @@ viewer_get_next_char: popa ret +.unicode: + inc [ebp+viewer_data.buf_pos] + cmp [bForHex], 0 + jnz @f + call read_unicode_char + jmp .done +@@: + mov ax, [eax] + mov [esp+29], ah + jmp .done + viewer_get_prev_char: pusha lea ecx, [ebp+viewer_data.buf] @@ -217,14 +261,61 @@ viewer_get_prev_char: .buffered: mov eax, [ebp+viewer_data.buf_pos] dec eax + cmp [ebp+viewer_data.encoding], encodings.unicode + jz .unicode mov [ebp+viewer_data.buf_pos], eax mov al, [eax] mov [esp+28], al +.done: clc .ret: popa ret +.unicode: + dec eax + mov [ebp+viewer_data.buf_pos], eax + call read_unicode_char + jmp .done + +read_unicode_char: + mov ax, [eax] +uni2ansi_char: + test [ebp+viewer_data.flags], 4 + jz @f + xchg al, ah +@@: + cmp ax, 0x80 + jb .ret + cmp ax, 0x401 + jz .yo1 + cmp ax, 0x451 + jz .yo2 + cmp ax, 0x410 + jb .unk + cmp ax, 0x440 + jb .rus1 + cmp ax, 0x450 + jb .rus2 +.unk: + mov al, ' ' +.ret: + ret +.yo1: + mov al, 'Ё' + ret +.yo2: + mov al, 'ё' + ret +.rus1: +; 0x410-0x43F -> 0x80-0xAF + add al, 0x70 + ret +.rus2: +; 0x440-0x44F -> 0xE0-0xEF + add al, 0xA0 + ret + fld_uint64: fild qword [eax] test byte [eax+7], 80h @@ -508,6 +599,8 @@ end if test al, al jns @f movzx esi, [ebp+viewer_data.encoding] + cmp esi, encodings.unicode + jz @f shl esi, 7 movzx eax, al mov al, [encodings.tables-80h+esi+eax] @@ -609,12 +702,15 @@ end if rep stosw mov ebx, edi pop edi + mov [bForHex], 1 call viewer_get_next_char + mov [bForHex], 0 jc .hexdone push eax push edi add edi, 36*2 mov al, 0xB3 + mov ah, [view_normal_color] call .safechar pop edi mov eax, dword [ebp+viewer_data.cur_pos] @@ -655,9 +751,13 @@ end if pop eax jmp @f .hexchar: + mov [bForHex], 1 call viewer_get_next_char + mov [bForHex], 0 jc .hexdone @@: + cmp [ebp+viewer_data.encoding], encodings.unicode + jz .hexchar_unicode push eax shr al, 4 call .hex_digit @@ -698,6 +798,53 @@ end if @@: cmp ecx, 16 jnz .hexchar + jmp .hexchar_nextline +.hexchar_unicode: + push eax + shr eax, 12 + call .hex_digit + pop eax + push eax + shr eax, 8 + and al, 0xF + call .hex_digit + pop eax + push eax + shr al, 4 + call .hex_digit + pop eax + push eax + and al, 0xF + call .hex_digit + mov al, ' ' + mov ah, [view_normal_color] + call .safechar + pop eax + push edi + add edi, 38*2 + push ecx + shl ecx, 3 + sub edi, ecx + pop ecx + cmp ecx, 4 + jb @f + sub edi, 4 +@@: + call uni2ansi_char + mov ah, [view_normal_color] + call .safechar + pop edi + inc ecx + cmp ecx, 4 + jnz @f + mov al, 0xB3 + call .safechar + mov al, ' ' + call .safechar +@@: + cmp ecx, 8 + jnz .hexchar +.hexchar_nextline: mov edi, ebx add esi, 3 mov edx, esi @@ -932,8 +1079,11 @@ viewer_set_curpos: viewer_next_newline: test [ebp+viewer_data.flags], 1 jz .nohex - push 10h + push 8 pop ecx + cmp [ebp+viewer_data.encoding], encodings.unicode + jz @f + add ecx, ecx @@: call viewer_get_next_char jc @f @@ -978,6 +1128,9 @@ viewer_next_newline: cmp cl, 0xD xor 0xA jz .2 dec [ebp+viewer_data.buf_pos] + cmp [ebp+viewer_data.encoding], encodings.unicode + jnz .2 + dec [ebp+viewer_data.buf_pos] .2: .ret: call viewer_set_curpos @@ -986,8 +1139,11 @@ viewer_next_newline: viewer_prev_newline: test [ebp+viewer_data.flags], 1 jz .nohex - push 10h + push 8 pop ecx + cmp [ebp+viewer_data.encoding], encodings.unicode + jz @f + add ecx, ecx @@: call viewer_get_prev_char jc @f @@ -1096,7 +1252,11 @@ else @@: end if movzx esi, [ebp+viewer_data.encoding] - xor esi, 1 + dec esi + jz @f + push 1 + pop esi +@@: lea esi, [encodings.names+esi*8] lea edi, [eax+keybar_cp-keybar_viewer] movsd @@ -1154,11 +1314,13 @@ viewer_OnKey: ret .f8: movzx esi, [ebp+viewer_data.encoding] - xor [ebp+viewer_data.encoding], 1 - call viewer_set_keybar - jmp .done_redraw + dec [ebp+viewer_data.encoding] + jz .done_redraw_keybar + mov [ebp+viewer_data.encoding], 1 + jmp .done_redraw_keybar .f2: xor [ebp+viewer_data.flags], 2 +.done_redraw_keybar: call viewer_set_keybar jmp .done_redraw .f4: @@ -1167,7 +1329,13 @@ viewer_OnKey: call viewer_set_keybar popf jnz .tohex - add dword [ebp+viewer_data.cur_pos], 1 + push 1 + pop eax + cmp [ebp+viewer_data.encoding], encodings.unicode + jnz @f + add eax, eax +@@: + add dword [ebp+viewer_data.cur_pos], eax adc dword [ebp+viewer_data.cur_pos+4], 0 call viewer_seek_to_current call viewer_prev_newline @@ -1249,6 +1417,29 @@ viewer_OnKey: mov dword [ebp+viewer_data.col], eax mov dword [ebp+viewer_data.col+4], edx jmp .done_redraw +.shift_f8: + mov ecx, encodings.menu.1 + mov al, [ebp+viewer_data.encoding] +@@: + cmp byte [ecx-1], al + jz @f + mov ecx, [ecx] + jmp @b +@@: + push 1 + push aTables + push ecx + call menu + cmp eax, -1 + jz .ret + mov al, [eax-1] + mov [ebp+viewer_data.encoding], al + cmp al, encodings.unicode + jnz .done_redraw_keybar + add dword [ebp+viewer_data.cur_pos], 1 + adc dword [ebp+viewer_data.cur_pos+4], 0 + and dword [ebp+viewer_data.cur_pos], not 1 + jmp .done_redraw_keybar viewer_getname: if lang eq ru diff --git a/programs/network/smtps/trunk/smtps.asm b/programs/network/smtps/trunk/smtps.asm index 9b5cda3850..975b3a3c29 100644 --- a/programs/network/smtps/trunk/smtps.asm +++ b/programs/network/smtps/trunk/smtps.asm @@ -8,7 +8,7 @@ ;; Compile with FASM for Menuet ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -include 'lang.inc' + version equ '0.1' use32 @@ -23,26 +23,22 @@ use32 dd 0xffff0 dd 0,0 +include 'macros.inc' + save_file: - pusha - - cmp [file_start],0x100000+10 - jbe nosub - sub [file_start],8 - nosub: - - mov edi,[file_start] +; cmp [file_start],0x100000+10 +; jbe nosub +; sub [file_start],8 +; nosub: mov eax,[file_start] sub eax,0x100000 - mov [files+8],eax - - mov eax,58 mov ebx,files - int 0x40 + mov [ebx+12],eax - popa + mov eax,70 + int 0x40 ret @@ -51,19 +47,22 @@ START: ; start of execution mov [file_start],0x100000 - mov eax,58 + mov eax,70 mov ebx,filel int 0x40 - cmp eax,0 - jne notfound + test eax,eax + jz @f + cmp eax,6 + jnz notfound +@@: add [file_start],ebx notfound: mov edi,I_END mov ecx,60*120 - mov eax,32 + mov al,32 cld rep stosb @@ -630,17 +629,8 @@ draw_window: mov eax,0 ; draw window mov ebx,5*65536+400 mov ecx,5*65536+200 - mov edx,[wcolor] - add edx,0x03ffffff - mov esi,0x80555599 - mov edi,0x00ffffff - int 0x40 - - mov eax,4 ; label - mov ebx,9*65536+8 - mov ecx,0x10ffffff - mov edx,labelt - mov esi,labellen-labelt + mov edx,0x13ffffff + mov edi,labelt int 0x40 mov eax,8 ; button: open socket @@ -746,7 +736,7 @@ db ' Timeout is set to 15 seconds. ' db ' ' db ' Open SMTP server port 25 Close SMTP ' -db 'x <- END MARKER, DONT DELETE ' +db 'x' ; <- END MARKER, DONT DELETE irc_server_ip db 192,168,1,1 @@ -754,10 +744,10 @@ irc_server_ip db 192,168,1,1 file_start dd 0x100000 files: - dd 1,0,0,0x100000,0xd0000 + dd 2,0,0,?,0x100000 db '/rd/1/smtps.txt',0 filel: - dd 0,0,10000/512,0x100000,0xd0000 + dd 0,0,0,0x100000,0x100000 db '/rd/1/smtps.txt',0 @@ -840,10 +830,6 @@ scroll dd 1 numtext db ' ' -wcolor dd 0x000000 - -labelt db 'Tiny SMTP email server v ',version -labellen: - +labelt db 'Tiny SMTP email server v ',version,0 I_END: