Subversion Repositories Kolibri OS

Rev

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

  1. ;Ž£à®¬­ ï ¡« £®¤ à­®áâì Maxxxx32, Diamond, Heavyiron
  2. ;¨ ¤à㣨¬ ¯à®£à ¬¬¨áâ ¬,   â ª¦¥
  3. ;’¥¯«®¢ã €«¥ªá¥î (<Lrz> www.lrz.land.ru)
  4.  
  5.  
  6. use32
  7.   org 0x0
  8.   db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
  9.   dd 0x01
  10.   dd start
  11.   dd i_end ; à §¬¥à ¯à¨«®¦¥­¨ï
  12.   dd mem
  13.   dd stacktop
  14.   dd file_name ; command line
  15.   dd sys_path
  16.  
  17. MAX_COLOR_WORD_LEN equ 40
  18. maxChars equ 100002 ;(...+2)
  19. BUF_SIZE equ 1000 ;buffer for copy|paste
  20. maxSyntaxFileSize equ 410000
  21.  
  22. include '../../proc32.inc'
  23. include '../../macros.inc'
  24. include 'mem.inc'
  25. include '../../develop/libraries/box_lib/load_lib.mac'
  26. include '../../develop/libraries/box_lib/trunk/box_lib.mac'
  27. include 'lang.inc'
  28.  
  29. include 't_data.inc'
  30. include 'strlen.inc'
  31. include 't_draw.inc' ;draw main window functions
  32. include 't_button.inc' ;text work functions
  33.  
  34. @use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,0
  35.  
  36. align 4
  37. start:
  38.   mcall 48,3,sc,sizeof.system_colors
  39.  
  40.   mcall 68,11
  41.   or eax,eax
  42.   jz button.exit
  43.  
  44.   mcall 66,1,1 ;scan code
  45.   ;mcall 26,2,1,conv_tabl
  46.   mcall 40,0x27
  47.  
  48.   mov esi,file_name
  49.   call strlen
  50.   mov ecx,eax
  51.   mov edi,openfile_path
  52.   rep movsb ;ª®¯¨à㥬 ¨¬ï ä ©«  ¢ ¡ãä¥à edit1
  53.  
  54. load_libraries l_libs_start,load_lib_end
  55.  
  56. ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ­ è  «¨¡ 
  57.         mov     ebp,lib0
  58.         cmp     dword [ebp+ll_struc_size-4],0
  59.         jz      @f
  60.         mcall -1 ;exit not correct
  61. @@:
  62.         mov     ebp,lib1 ;
  63.         cmp     dword [ebp+ll_struc_size-4],0
  64.         jz      @f
  65.         mcall -1 ;exit not correct
  66. @@:
  67.  
  68. ;---------------------------------------------------------------------
  69.         stdcall [ted_init], tedit0
  70.         stdcall dword[tl_data_init], tree1
  71.  
  72. ; OpenDialog initialisation
  73.         stdcall [OpenDialog_Init],OpenDialog_data
  74.  
  75. ; init bmp file
  76.   mov ecx,1200*18
  77.   stdcall mem.Alloc,ecx
  78.   mov [bmp_icon],eax
  79.  
  80.   copy_path fn_icon,sys_path,file_name,0x0
  81.  
  82.   mov eax,70 ;load icon file
  83.   mov [run_file_70.Function], 0
  84.   mov [run_file_70.Position], 54
  85.   mov [run_file_70.Flags], 0
  86.   mov [run_file_70.Count], 1200*18
  87.   m2m [run_file_70.Buffer], [bmp_icon]
  88.   mov byte[run_file_70+20], 0
  89.   mov [run_file_70.FileName], file_name
  90.   mov ebx,run_file_70
  91.   int 0x40
  92.  
  93.   cmp ebx,-1
  94.   mov [err_ini0],1
  95.   je @f ;if open file
  96.     mov [err_ini0],0
  97.   @@:
  98.  
  99. ;---------------------------------------------------------------------
  100. ; ç¨â ¥¬ bmp ä ©« á ªãàá®à ¬¨ ¨ «¨­¨ï¬¨
  101.   copy_path fn_icon_tl_sys,sys_path,file_name,0x0
  102.  
  103.   mov ecx,3*256*13
  104.   stdcall mem.Alloc,ecx
  105.   mov dword[tree1.data_img_sys],eax
  106.  
  107.   ;mov [run_file_70.Function], 0
  108.   ;mov [run_file_70.Position], 54
  109.   ;mov [run_file_70.Flags], 0
  110.   mov [run_file_70.Count], 3*256*13
  111.   mov [run_file_70.Buffer], eax
  112.   ;mov byte[run_file_70+20], 0
  113.   ;mov [run_file_70.FileName], file_name
  114.  
  115.   mov eax,70 ;load icon file
  116.   mov ebx,run_file_70
  117.   int 0x40
  118.   cmp ebx,0
  119.   jg @f
  120.     mov dword[tree1.data_img_sys],0
  121.   @@:
  122. ;---------------------------------------------------------------------
  123. ; ç¨â ¥¬ bmp ä ©« á ¨ª®­ª ¬¨ 㧫®¢
  124.   copy_path fn_icon_tl_nod,sys_path,file_name,0x0
  125.  
  126.   mov ecx,3*256*2
  127.   stdcall mem.Alloc,ecx
  128.   mov dword[tree1.data_img],eax
  129.  
  130. ;  mov [run_file_70.Function], 0
  131. ;  mov [run_file_70.Position], 54
  132. ;  mov [run_file_70.Flags], 0
  133.   mov [run_file_70.Count], 3*256*2
  134.   mov [run_file_70.Buffer], eax
  135. ;  mov byte[run_file_70+20], 0
  136. ;  mov [run_file_70.FileName], file_name
  137.  
  138.   mov eax,70 ;load icon file
  139.   mov ebx,run_file_70
  140.   int 0x40
  141.   cmp ebx,0
  142.   jg @f
  143.     mov dword[tree1.data_img],0
  144.   @@:
  145. ;------------------------------------------------------------------------------
  146.   copy_path fn_syntax_dir,sys_path,file_name,0x0 ;¡¥à¥¬ ¯ãâì ª ¯ ¯ª¥ á ä ©« ¬¨ ᨭ⠪á¨á 
  147.   mov eax,70
  148.   mov ebx,tree_file_struct
  149.   int 0x40
  150.  
  151. cmp ebx,-1
  152. je .end_dir_init
  153.  
  154.   mov eax,dir_mem
  155.   add eax,32+4+1+3+4*6+8
  156. mov ecx,ebx
  157. @@:
  158.   cmp byte[eax],'.' ;䨫ìâà㥬 ä ©«ë á ¨¬¥­ ¬¨ '.' ¨ '..'
  159.   je .filter
  160.     ;0x10000 ;1*2^16 - £¤¥ 1 ­®¬¥à ¨ª®­ª¨ á ª­¨£®©
  161.     stdcall dword[tl_node_add], eax,0x10000, tree1
  162.  
  163.     stdcall dword[tl_cur_next], tree1
  164.   .filter:
  165.   add eax,304
  166.   loop @b
  167. .end_dir_init:
  168.  
  169. ;--- load color option file ---
  170.         mov ebx,dword[fn_col_option]
  171.         copy_path ebx,fn_syntax_dir,file_name_rez,0x0
  172.         copy_path file_name_rez,sys_path,file_name,0x0
  173.         stdcall [ted_init_syntax_file], tedit0,run_file_70,file_name
  174.  
  175. ;--- get cmd line ---
  176.   cmp byte[openfile_path+3],0 ;openfile_path
  177.   je @f ;if file names exist
  178.     mov esi,openfile_path
  179.     call strlen ;eax=strlen
  180.     mov [edit1.size],eax
  181.     call but_no_msg_OpenFile
  182.   @@:
  183.  
  184. align 4
  185. red_win:
  186.   call draw_window
  187.  
  188. align 4
  189. still:
  190.   mov eax,10
  191.   mcall
  192.  
  193.   cmp al,1 ;¨§¬. ¯®«®¦¥­¨¥ ®ª­ 
  194.   jz red_win
  195.   cmp al,2
  196.   jz key
  197.   cmp al,3
  198.   jz button
  199.   cmp al,6
  200.   jz mouse
  201.  
  202.   jmp still
  203.  
  204. align 4
  205. draw_window:
  206.   mcall 12,1
  207.  
  208.   xor eax,eax
  209.   mov ebx,10*65536+485
  210.   mov ecx,10*65536+320
  211.   mov edx,[sc.work]
  212.   or  edx,0x73000000
  213.   mov edi,hed
  214.   int 0x40
  215.  
  216.   mov edi,tedit0
  217.  
  218.   mcall 9,procinfo,-1
  219.   stdcall EvSize,edi
  220.  
  221.   mov eax,13 ;¢¥àå­¨© ¯àאַ㣮«ì­¨ª, ¤«ï ®ç¨á⪨ ¢¥àå­¥© ¯ ­¥«¨
  222.   xor ebx,ebx
  223.   mov ecx,ted_wnd_t
  224.   mov bx,word [procinfo.client_box.width]
  225.   inc bx
  226.   int 0x40
  227.  
  228.         mov eax,4
  229.         mov ebx,185*65536+9
  230.         mov ecx,[sc.work_text]
  231.         or  ecx,0x80000000
  232.         mov edx,txtFile
  233.         int 0x40
  234.  
  235.   stdcall [edit_box_draw], dword edit1
  236.   stdcall [menu_bar_draw], dword menu_data_1
  237.  
  238.   call draw_but_toolbar
  239.  
  240.   cmp [err_ini0],1
  241.   jne @f
  242.     mov eax,4
  243.     mov ebx,ted_wnd_l
  244.     add ebx,ted_rec_l
  245.     shl ebx,16
  246.     add ebx,ted_wnd_t
  247.     add ebx,ted_rec_t
  248.     mov ecx,0x80ff0000
  249.     mov edx,txtErrIni0
  250.     int 0x40
  251.  
  252.     add ebx,10 ;move <--y-->
  253.     mov ecx,0x80ff0080
  254.     mov edx,file_name
  255.     int 0x40
  256.   @@:
  257.  
  258.   cmp [err_ini0],1
  259.   je @f
  260.     stdcall [ted_draw], tedit0
  261.   @@:
  262.  
  263.   mcall 12,2
  264.   ret
  265.  
  266. align 4
  267. mouse:
  268.   stdcall [edit_box_mouse], dword edit1
  269.  
  270.   test word [edit1.flags],10b;ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  271.   jne still
  272.  
  273.   stdcall [ted_mouse], tedit0
  274.  
  275.   cmp byte[tedit0.panel_id],TED_PANEL_FIND ;if not panel
  276.   jne @f
  277.     stdcall [edit_box_mouse], dword edit2
  278.   @@:
  279.   cmp byte[tedit0.panel_id],TED_PANEL_SYNTAX ;if not panel
  280.   jne .menu_bar_1 ;@f
  281.   stdcall [tl_mouse], tree1
  282. ;-----------------------------------------------
  283. .menu_bar_1:
  284.   mov [menu_data_1.get_mouse_flag],1
  285. ; mouse event for Menu 1
  286.   push  dword menu_data_1
  287.   call  [menu_bar_mouse]
  288.   cmp   [menu_data_1.click],dword 1
  289.   jne   .mnu_1
  290.   cmp [menu_data_1.cursor_out],dword 4
  291.   je    button.exit    
  292.   cmp [menu_data_1.cursor_out],dword 3
  293.   jne   @f
  294.     stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text]
  295.   @@:
  296.   cmp [menu_data_1.cursor_out],dword 2
  297.   jne   @f
  298.     call ted_but_open_file
  299.   @@:
  300.   cmp [menu_data_1.cursor_out],dword 1
  301.   jne   @f
  302.     call ted_but_new_file
  303.   @@:
  304.   ;cmp [menu_data_1.cursor_out],dword 0
  305.   ;jne @f
  306. .mnu_1:
  307.   jmp still
  308. ;---------------------------------------------------------------------
  309.  
  310. ;output:
  311. ; ah = symbol
  312. align 4
  313. proc KeyConvertToASCII, table:dword
  314.   push ebx
  315.   mov ebx,dword[table] ;convert scan to ascii
  316.   ror ax,8
  317.   xor ah,ah
  318.   add bx,ax
  319.   mov ah,byte[ebx]
  320.   pop ebx
  321.   ret
  322. endp
  323.  
  324. align 4
  325. key:
  326.   mcall 66,3 ;66.3 ¯®«ãç¨âì á®áâ®ï­¨¥ ã¯à ¢«ïîé¨å ª« ¢¨è
  327.   xor esi,esi
  328.   mov ecx,1
  329.   test al,0x03 ;[Shift]
  330.   jz @f
  331.     mov cl,2
  332.     or esi,KM_SHIFT
  333.   @@:
  334.   test al,0x0c ;[Ctrl]
  335.   jz @f
  336.     or esi,KM_CTRL
  337.   @@:
  338.   test al,0x30 ;[Alt]
  339.   jz @f
  340.     mov cl,3
  341.     or esi,KM_ALT
  342.   @@:
  343.   test al,0x80 ;[NumLock]
  344.   jz @f
  345.     or esi,KM_NUMLOCK
  346.   @@:
  347.  
  348.   mcall 26,2,,conv_tabl ;26.2 ¯®«ãç¨âì à áª« ¤ªã ª« ¢¨ âãàë
  349.   mcall 2 ;¯®«ãç ¥¬ ª®¤ ­ ¦ â®© ª« ¢¨è¨
  350.   stdcall [tl_key], tree1
  351.  
  352.   test word [edit1.flags],10b;ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  353.   je @f
  354.     cmp ah,0x80 ;if key up
  355.     ja still
  356.     cmp ah,42 ;[Shift] (left)
  357.     je still
  358.     cmp ah,54 ;[Shift] (right)
  359.     je still
  360.     cmp ah,56 ;[Alt]
  361.     je still
  362.     cmp ah,29 ;[Ctrl]
  363.     je still
  364.     cmp ah,69 ;[Pause Break]
  365.     je still
  366.  
  367.     stdcall KeyConvertToASCII, dword conv_tabl
  368.     stdcall [edit_box_key], dword edit1
  369.     jmp still
  370.   @@:
  371.  
  372.   test word [edit2.flags],10b;ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  373.   je @f
  374.     cmp ah,0x80 ;if key up
  375.     ja still
  376.     cmp ah,42 ;[Shift] (left)
  377.     je still
  378.     cmp ah,54 ;[Shift] (right)
  379.     je still
  380.     cmp ah,56 ;[Alt]
  381.     je still
  382.     cmp ah,29 ;[Ctrl]
  383.     je still
  384.     cmp ah,69 ;[Pause Break]
  385.     je still
  386.  
  387.     stdcall KeyConvertToASCII, dword conv_tabl
  388.     stdcall [edit_box_key], dword edit2
  389.     jmp still
  390.   @@:
  391.  
  392.   stdcall [ted_key], tedit0, conv_tabl,esi
  393.   jmp still
  394.  
  395. align 4
  396. button:
  397. ;  cmp [menu_active],1 ;¥á«¨ ­ ¦ «¨ ¬¥­î, â® á­ ç «  ॠªæ¨ï ­  ¬¥­î
  398. ;  jne @f ;mouse.menu_bar_1
  399. ;    mov [menu_active],0
  400. ;    jmp still
  401. ;  @@:
  402.  
  403.   mcall 17 ;¯®«ãç¨âì ª®¤ ­ ¦ â®© ª­®¯ª¨
  404.   cmp ah,3
  405.   jne @f
  406.     call ted_but_new_file
  407.   @@:
  408.   cmp ah,4
  409.   jne @f
  410.     call ted_but_open_file
  411.   @@:
  412.   cmp ah,5
  413.   jne @f
  414.     stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text]
  415.   @@:
  416.   cmp ah,6
  417.   jne @f
  418.     stdcall [ted_but_select_word], tedit0
  419.   @@:
  420.   cmp ah,7
  421.   jne @f
  422.     stdcall [ted_but_cut], tedit0
  423.   @@:
  424.   cmp ah,8
  425.   jne @f
  426.     stdcall [ted_but_copy], tedit0
  427.   @@:
  428.   cmp ah,9
  429.   jne @f
  430.     stdcall [ted_but_paste], tedit0
  431.   @@:
  432.   cmp ah,10
  433.   jne @f
  434.     call ted_but_find
  435.   @@:
  436.   cmp ah,11
  437.   jne @f
  438.     call but_replace
  439.   @@:
  440.   cmp ah,12
  441.   jne @f
  442.     call but_find_key_w
  443.   @@:
  444.   cmp ah,13
  445.   jne @f
  446.     stdcall [ted_but_sumb_upper], tedit0
  447.   @@:
  448.   cmp ah,14
  449.   jne @f
  450.     stdcall [ted_but_sumb_lover], tedit0
  451.   @@:
  452.   cmp ah,15
  453.   jne @f
  454.     stdcall [ted_but_reverse], tedit0
  455.   @@:
  456.   cmp ah,16
  457.   jne @f
  458.     stdcall [ted_but_undo], tedit0
  459.   @@:
  460.   cmp ah,17
  461.   jne @f
  462.     stdcall [ted_but_redo], tedit0
  463.   @@:
  464.   cmp ah,18
  465.   jne @f
  466.     stdcall but_sumb_invis, tedit0
  467.   @@:
  468.   cmp ah,19
  469.   jne @f
  470.     stdcall but_k_words_show, tedit0
  471.   @@:
  472.   cmp ah,20
  473.   jne @f
  474.     stdcall but_synt_show, tedit0
  475.   @@:
  476.  
  477.   cmp ah,200
  478.   jne @f
  479.     stdcall ted_but_open_syntax, tedit0
  480.   @@:
  481.   cmp ah,201
  482.   jne @f
  483.     stdcall [ted_but_find_next], tedit0
  484.   @@:
  485.  
  486.   cmp ah,1
  487.   jne still
  488. .exit:
  489.   stdcall [ted_can_save], tedit0
  490.   cmp al,1
  491.   jne @f
  492.     stdcall [mb_create],msgbox_8,thread ;message: save changes in file?
  493.     jmp still
  494.   @@:
  495.   stdcall mem.Free,[bmp_icon]
  496.  
  497.   stdcall [ted_delete], tedit0
  498.   stdcall dword[tl_data_clear], tree1
  499.   mcall -1 ;¢ë室 ¨§ ¯à®£à ¬¬ë
  500.  
  501.  
  502.  
  503. txtErrIni0 db '¥ ®âªàë«áï ä ©« á ¨ª®­ª ¬¨',0
  504. err_ini0 db 0
  505.  
  506. edit1 edit_box 250, 220, 5, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 4090, openfile_path, mouse_dd, 0
  507. edit2 edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_find, mouse_dd, 0
  508.  
  509. buf_find db 302 dup(0)
  510.  
  511. if lang eq ru
  512.   head_f_i0:
  513.   head_f_l0  db '‘¨á⥬­ ï ®è¨¡ª ',0
  514.   err_message_found_lib0 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'box_lib.obj',39,0
  515.   err_message_import0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib.obj',39,0
  516.   err_message_found_lib1 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'msgbox.obj',39,0
  517.   err_message_import1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'msgbox.obj',39,0
  518.   err_message_found_lib2 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,0
  519.   err_message_import2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,0
  520. else
  521.   head_f_i0:
  522.   head_f_l0  db 'System error',0
  523.   err_message_found_lib0 db 'Sorry I cannot found library ',39,'box_lib.obj',39,0
  524.   err_message_import0 db 'Error on load import library ',39,'box_lib.obj',39,0
  525.   err_message_found_lib1 db 'Sorry I cannot found library ',39,'msgbox.obj',39,0
  526.   err_message_import1 db 'Error on load import library ',39,'msgbox.obj',39,0
  527.   err_message_found_lib2 db 'Sorry I cannot found library ',39,'proc_lib.obj',39,0
  528.   err_message_import2 db 'Error on load import library ',39,'proc_lib.obj',39,0
  529. end if
  530.  
  531. ;library structures
  532. l_libs_start:
  533.   lib0 l_libs lib0_name, sys_path, file_name, system_dir0, err_message_found_lib0, head_f_l0, boxlib_import,err_message_import0, head_f_i0
  534.   lib1 l_libs lib1_name, sys_path, file_name, system_dir1, err_message_found_lib1, head_f_l0, msgbox_lib_import, err_message_import1, head_f_i0
  535.   lib2 l_libs lib2_name, sys_path, file_name, system_dir2, err_message_found_lib2, head_f_l0, proclib_import, err_message_import2, head_f_i0
  536. load_lib_end:
  537.  
  538.  
  539. i_end:
  540.         rb 1024
  541.         align 16
  542.         procinfo process_information
  543.         thread:
  544.                 rb 1024
  545. stacktop:
  546.   sys_path:
  547.     rb 4096
  548.   file_name:
  549.     rb 4096
  550.   file_name_rez:
  551.     rb 4096
  552.   plugin_path:
  553.     rb 4096
  554.   openfile_path:
  555.     rb 4096
  556.   filename_area:
  557.     rb 256
  558.   file_info:
  559.     rb 40
  560. mem:
  561.