add opening files from the command line

git-svn-id: svn://kolibrios.org@7662 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
IgorA 2019-05-22 12:15:56 +00:00
parent 4b31a55f25
commit 4ed472dca1
2 changed files with 749 additions and 669 deletions

View File

@ -8,7 +8,7 @@ format binary as ""
use32 use32
org 0 org 0
db 'MENUET01' db 'MENUET01'
dd 1,start,i_end,mem,stacktop,0,sys_path dd 1,start,i_end,mem,stacktop,file_name,sys_path
include '../../macros.inc' include '../../macros.inc'
include '../../proc32.inc' include '../../proc32.inc'
@ -25,7 +25,7 @@ KMENUITEM_SUBMENU equ 1
KMENUITEM_SEPARATOR equ 2 KMENUITEM_SEPARATOR equ 2
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load @use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
caption db 'CNC Control 08.10.18',0 ;¯®¤¯¨áì ®ª­  caption db 'CNC Control 22.05.19',0 ;¯®¤¯¨áì ®ª­ 
run_file_70 FileInfoBlock run_file_70 FileInfoBlock
@ -38,6 +38,18 @@ icon_toolbar dd 0 ;㪠
align 4 align 4
start: start:
;--- copy cmd line ---
mov esi,file_name
mov edi,openfile_path
@@:
lodsd
or eax,eax
jz @f ;¢ë室, ¥á«¨ 0
stosd
jmp @b
@@:
stosd
load_libraries l_libs_start,l_libs_end load_libraries l_libs_start,l_libs_end
;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ¡¨¡«¨®â¥ª  ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ¡¨¡«¨®â¥ª 
mov ebp,lib_0 mov ebp,lib_0
@ -100,6 +112,12 @@ start:
stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_PortMenu, [port_menu] stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_PortMenu, [port_menu]
;stdcall [ksubmenu_add], [main_menu], eax ;stdcall [ksubmenu_add], [main_menu], eax
;open file from cmd line
cmp dword[openfile_path],0
je @f
call but_open_file.no_dlg
@@:
align 4 align 4
red_win: red_win:
call draw_window call draw_window
@ -308,26 +326,6 @@ pushad
mov edi,caption mov edi,caption
mcall SF_CREATE_WINDOW,(20 shl 16)+WINDOW_WIDTH,(20 shl 16)+WINDOW_HEIGHT mcall SF_CREATE_WINDOW,(20 shl 16)+WINDOW_WIDTH,(20 shl 16)+WINDOW_HEIGHT
;;mcall SF_THREAD_INFO,procinfo,-1
;;mov eax,dword[procinfo.box.height]
;;cmp eax,120
;;jge @f
;;mov eax,120 ;min size
;;@@:
;;sub eax,65
;;mov ebx,dword[procinfo.box.width]
;;cmp ebx,270
;;jge @f
;;mov ebx,270
;;@@:
;;sub ebx,215
;;cmp eax,dword[buf_0.h] ;ᬮâਬ à §¬¥à ¡ãä¥à 
;;jne @f
;;cmp ebx,dword[buf_0.w]
;;jne @f
;;jmp .end0
;;@@:
;;stdcall [buf2d_resize],buf_0,ebx,eax,1
mov ecx,[ObjData.FigCount] mov ecx,[ObjData.FigCount]
or ecx,ecx or ecx,ecx
jz .end0 jz .end0
@ -484,14 +482,31 @@ open_file_size dd 0 ;ࠧ
align 4 align 4
but_open_file: but_open_file:
pushad
copy_path open_dialog_name,communication_area_default_path,file_name,0 copy_path open_dialog_name,communication_area_default_path,file_name,0
pushad
mov [OpenDialog_data.type],0 mov [OpenDialog_data.type],0
stdcall [OpenDialog_Start],OpenDialog_data stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],2 cmp [OpenDialog_data.status],2
je .end_open_file je .end_open_file
;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£  ;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
jmp .end0
.no_dlg: ;¥á«¨ ¬¨­ã¥¬ ¤¨ «®£ ®âªàëâ¨ï ä ©« 
pushad
mov esi,openfile_path
stdcall str_len,esi
add esi,eax
@@: ;横« ¤«ï ¯®¨áª  ­ ç «  ¨¬¥­¨ ä ©« 
dec esi
cmp byte[esi],'/'
je @f
cmp byte[esi],0x5c ;'\'
je @f
cmp esi,openfile_path
jg @b
@@:
inc esi
stdcall [OpenDialog_Set_file_name],OpenDialog_data,esi ;ª®¯¨à㥬 ¨¬ï ä ©«  ¢ ¤¨ «®£ á®åà ­¥­¨ï
.end0:
push eax ebx ecx edx ;copy file name path from OpenDialog push eax ebx ecx edx ;copy file name path from OpenDialog
mov eax, openfile_path mov eax, openfile_path
mov ebx, fileNameBuffer ;.data mov ebx, fileNameBuffer ;.data
@ -725,34 +740,46 @@ coord:
.y dw 200 .y dw 200
;] ;]
head_f_i: align 4
head_f_l db '‘¨á⥬­ ï ®è¨¡ª ',0
system_dir_0 db '/sys/lib/' system_dir_0 db '/sys/lib/'
lib_name_0 db 'proc_lib.obj',0 lib_name_0 db 'proc_lib.obj',0
err_message_found_lib_0 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,0
err_message_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,0
system_dir_1 db '/sys/lib/' system_dir_1 db '/sys/lib/'
lib_name_1 db 'libimg.obj',0 lib_name_1 db 'libimg.obj',0
err_message_found_lib_1 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libimg.obj',39,0
err_message_import_1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,0
system_dir_2 db '/sys/lib/' system_dir_2 db '/sys/lib/'
lib_name_2 db 'buf2d.obj',0 lib_name_2 db 'buf2d.obj',0
err_msg_found_lib_2 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'buf2d.obj',39,0
err_msg_import_2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,0
system_dir_3 db '/sys/lib/' system_dir_3 db '/sys/lib/'
lib_name_3 db 'box_lib.obj',0 lib_name_3 db 'box_lib.obj',0
err_msg_found_lib_3 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'box_lib.obj',39,0
err_msg_import_3 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib',39,0
system_dir_4 db '/sys/lib/' system_dir_4 db '/sys/lib/'
lib_name_4 db 'kmenu.obj',0 lib_name_4 db 'kmenu.obj',0
err_msg_found_lib_4 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'kmenu.obj',39,0
err_msg_import_4 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'kmenu',39,0
head_f_i:
if lang eq ru
head_f_l db '"‘¨á⥬­ ï ®è¨¡ª ',0
err_message_found_lib_0 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,'" -tE',0
err_message_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,'" -tW',0
err_message_found_lib_1 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libimg.obj',39,'" -tE',0
err_message_import_1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,'" -tW',0
err_msg_found_lib_2 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'buf2d.obj',39,'" -tE',0
err_msg_import_2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,'" -tW',0
err_msg_found_lib_3 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'box_lib.obj',39,'" -tE',0
err_msg_import_3 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib',39,'" -tW',0
err_msg_found_lib_4 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'kmenu.obj',39,'" -tE',0
err_msg_import_4 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'kmenu',39,'" -tW',0
else
head_f_l db '"System error',0
err_message_found_lib_0 db 'Sorry I cannot found library ',39,'proc_lib.obj',39,'" -tE',0
err_message_import_0 db 'Error on load import library ',39,'proc_lib.obj',39,'" -tW',0
err_message_found_lib_1 db 'Sorry I cannot found library ',39,'libimg.obj',39,'" -tE',0
err_message_import_1 db 'Error on load import library ',39,'libimg.obj',39,'" -tW',0
err_msg_found_lib_2 db 'Sorry I cannot found library ',39,'buf2d.obj',39,'" -tE',0
err_msg_import_2 db 'Error on load import library ',39,'buf2d',39,'" -tW',0
err_msg_found_lib_3 db 'Sorry I cannot found library ',39,'box_lib.obj',39,'" -tE',0
err_msg_import_3 db 'Error on load import library ',39,'box_lib',39,'" -tW',0
err_msg_found_lib_4 db 'Sorry I cannot found library ',39,'kmenu.obj',39,'" -tE',0
err_msg_import_4 db 'Error on load import library ',39,'kmenu',39,'" -tW',0
end if
align 4
l_libs_start: l_libs_start:
lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\ lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i
@ -817,9 +844,13 @@ align 4
proclib_import: ;®¯¨á ­¨¥ íªá¯®àâ¨à㥬ëå ä㭪権 proclib_import: ;®¯¨á ­¨¥ íªá¯®àâ¨à㥬ëå ä㭪権
OpenDialog_Init dd aOpenDialog_Init OpenDialog_Init dd aOpenDialog_Init
OpenDialog_Start dd aOpenDialog_Start OpenDialog_Start dd aOpenDialog_Start
OpenDialog_Set_file_name dd aOpenDialog_Set_file_name
;OpenDialog_Set_file_ext dd aOpenDialog_Set_file_ext
dd 0,0 dd 0,0
aOpenDialog_Init db 'OpenDialog_init',0 aOpenDialog_Init db 'OpenDialog_init',0
aOpenDialog_Start db 'OpenDialog_start',0 aOpenDialog_Start db 'OpenDialog_start',0
aOpenDialog_Set_file_name db 'OpenDialog_set_file_name',0
;aOpenDialog_Set_file_ext db 'OpenDialog_set_file_ext',0
align 4 align 4
import_buf2d: import_buf2d:

View File

@ -1,7 +1,7 @@
use32 use32
org 0 org 0
db 'MENUET01' db 'MENUET01'
dd 1,start,i_end,mem,stacktop,0,sys_path dd 1,start,i_end,mem,stacktop,file_name,sys_path
include '../../macros.inc' include '../../macros.inc'
include '../../proc32.inc' include '../../proc32.inc'
@ -14,7 +14,7 @@ include 'cnc_editor.inc'
include '../../develop/info3ds/info_fun_float.inc' include '../../develop/info3ds/info_fun_float.inc'
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load @use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
caption db 'CNC editor 30.10.18',0 ;¯®¤¯¨áì ®ª­  caption db 'CNC editor 22.05.19',0 ;¯®¤¯¨áì ®ª­ 
run_file_70 FileInfoBlock run_file_70 FileInfoBlock
@ -31,6 +31,18 @@ include 'wnd_new_file.inc'
align 4 align 4
start: start:
;--- copy cmd line ---
mov esi,file_name
mov edi,openfile_path
@@:
lodsd
or eax,eax
jz @f ;¢ë室, ¥á«¨ 0
stosd
jmp @b
@@:
stosd
load_libraries l_libs_start,l_libs_end load_libraries l_libs_start,l_libs_end
;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ¡¨¡«¨®â¥ª  ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ¡¨¡«¨®â¥ª 
mov ebp,lib_0 mov ebp,lib_0
@ -71,7 +83,11 @@ start:
mcall SF_SYSTEM_GET,SSF_TIME_COUNT mcall SF_SYSTEM_GET,SSF_TIME_COUNT
mov [last_time],eax mov [last_time],eax
;call but_new_file ;open file from cmd line
cmp dword[openfile_path],0
je @f
call but_open_file.no_dlg
@@:
align 4 align 4
red_win: red_win:
@ -670,13 +686,31 @@ open_file_size dd 0 ;ࠧ
align 4 align 4
but_open_file: but_open_file:
pushad
copy_path open_dialog_name,communication_area_default_path,file_name,0 copy_path open_dialog_name,communication_area_default_path,file_name,0
pushad
mov [OpenDialog_data.type],0 mov [OpenDialog_data.type],0
stdcall [OpenDialog_Start],OpenDialog_data stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],2 cmp [OpenDialog_data.status],2
je .end_open_file je .end_open_file
;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£  ;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
jmp .end0
.no_dlg: ;¥á«¨ ¬¨­ã¥¬ ¤¨ «®£ ®âªàëâ¨ï ä ©« 
pushad
mov esi,openfile_path
stdcall str_len,esi
add esi,eax
@@: ;横« ¤«ï ¯®¨áª  ­ ç «  ¨¬¥­¨ ä ©« 
dec esi
cmp byte[esi],'/'
je @f
cmp byte[esi],0x5c ;'\'
je @f
cmp esi,openfile_path
jg @b
@@:
inc esi
stdcall [OpenDialog_Set_file_name],OpenDialog_data,esi ;ª®¯¨à㥬 ¨¬ï ä ©«  ¢ ¤¨ «®£ á®åà ­¥­¨ï
.end0:
mov [run_file_70.Function], SSF_GET_INFO mov [run_file_70.Function], SSF_GET_INFO
mov [run_file_70.Position], 0 mov [run_file_70.Position], 0
@ -729,6 +763,7 @@ endl
pushad pushad
copy_path open_dialog_name,communication_area_default_path,file_name,0 copy_path open_dialog_name,communication_area_default_path,file_name,0
mov [OpenDialog_data.type],1 mov [OpenDialog_data.type],1
stdcall [OpenDialog_Set_file_ext],OpenDialog_data,Filter.1 ;.nc
stdcall [OpenDialog_Start],OpenDialog_data stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],2 cmp [OpenDialog_data.status],2
je .end_save_file je .end_save_file
@ -933,9 +968,10 @@ but_save_png:
.beg0: .beg0:
copy_path open_dialog_name,communication_area_default_path,file_name,0 copy_path open_dialog_name,communication_area_default_path,file_name,0
mov [OpenDialog_data.type],1 mov [OpenDialog_data.type],1
stdcall [OpenDialog_Set_file_ext],OpenDialog_data,Filter.2 ;.png
stdcall [OpenDialog_Start],OpenDialog_data stdcall [OpenDialog_Start],OpenDialog_data
cmp [OpenDialog_data.status],2 cmp [OpenDialog_data.status],1
je .end_save_file jne .end_save_file
;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£  ;ª®¤ ¯à¨ 㤠筮¬ ®âªàë⨨ ¤¨ «®£ 
mov dword[png_data],0 mov dword[png_data],0
@ -2019,37 +2055,46 @@ communication_area_default_path:
Filter: Filter:
dd Filter.end - Filter ;.1 dd Filter.end - Filter ;.1
.1: .1: db 'NC',0
db 'NC',0 .2: db 'PNG',0
db 'PNG',0
.end: .end:
db 0 db 0
align 4
head_f_i:
head_f_l db '‘¨á⥬­ ï ®è¨¡ª ',0
system_dir_0 db '/sys/lib/' system_dir_0 db '/sys/lib/'
lib_name_0 db 'proc_lib.obj',0 lib_name_0 db 'proc_lib.obj',0
err_message_found_lib_0 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,0
err_message_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,0
system_dir_1 db '/sys/lib/' system_dir_1 db '/sys/lib/'
lib_name_1 db 'libimg.obj',0 lib_name_1 db 'libimg.obj',0
err_message_found_lib_1 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libimg.obj',39,0
err_message_import_1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,0
system_dir_2 db '/sys/lib/' system_dir_2 db '/sys/lib/'
lib_name_2 db 'buf2d.obj',0 lib_name_2 db 'buf2d.obj',0
err_msg_found_lib_2 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'buf2d.obj',39,0
err_msg_import_2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,0
system_dir_3 db '/sys/lib/' system_dir_3 db '/sys/lib/'
lib_name_3 db 'box_lib.obj',0 lib_name_3 db 'box_lib.obj',0
err_msg_found_lib_3 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'box_lib.obj',39,0
err_msg_import_3 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib',39,0
head_f_i:
if lang eq ru
head_f_l db '"‘¨á⥬­ ï ®è¨¡ª ',0
err_message_found_lib_0 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,'" -tE',0
err_message_import_0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,'" -tW',0
err_message_found_lib_1 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'libimg.obj',39,'" -tE',0
err_message_import_1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'libimg.obj',39,'" -tW',0
err_msg_found_lib_2 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'buf2d.obj',39,'" -tE',0
err_msg_import_2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'buf2d',39,'" -tW',0
err_msg_found_lib_3 db '<27>¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'box_lib.obj',39,'" -tE',0
err_msg_import_3 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib',39,'" -tW',0
else
head_f_l db '"System error',0
err_message_found_lib_0 db 'Sorry I cannot found library ',39,'proc_lib.obj',39,'" -tE',0
err_message_import_0 db 'Error on load import library ',39,'proc_lib.obj',39,'" -tW',0
err_message_found_lib_1 db 'Sorry I cannot found library ',39,'libimg.obj',39,'" -tE',0
err_message_import_1 db 'Error on load import library ',39,'libimg.obj',39,'" -tW',0
err_msg_found_lib_2 db 'Sorry I cannot found library ',39,'buf2d.obj',39,'" -tE',0
err_msg_import_2 db 'Error on load import library ',39,'buf2d',39,'" -tW',0
err_msg_found_lib_3 db 'Sorry I cannot found library ',39,'box_lib.obj',39,'" -tE',0
err_msg_import_3 db 'Error on load import library ',39,'box_lib',39,'" -tW',0
end if
align 4
l_libs_start: l_libs_start:
lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\ lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i
@ -2112,9 +2157,13 @@ align 4
proclib_import: ;®¯¨á ­¨¥ íªá¯®àâ¨à㥬ëå ä㭪権 proclib_import: ;®¯¨á ­¨¥ íªá¯®àâ¨à㥬ëå ä㭪権
OpenDialog_Init dd aOpenDialog_Init OpenDialog_Init dd aOpenDialog_Init
OpenDialog_Start dd aOpenDialog_Start OpenDialog_Start dd aOpenDialog_Start
OpenDialog_Set_file_name dd aOpenDialog_Set_file_name
OpenDialog_Set_file_ext dd aOpenDialog_Set_file_ext
dd 0,0 dd 0,0
aOpenDialog_Init db 'OpenDialog_init',0 aOpenDialog_Init db 'OpenDialog_init',0
aOpenDialog_Start db 'OpenDialog_start',0 aOpenDialog_Start db 'OpenDialog_start',0
aOpenDialog_Set_file_name db 'OpenDialog_set_file_name',0
aOpenDialog_Set_file_ext db 'OpenDialog_set_file_ext',0
align 4 align 4
import_buf2d: import_buf2d: