Subversion Repositories Kolibri OS

Rev

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

  1. use32
  2.   org 0x0
  3.   db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
  4.   dd 0x01
  5.   dd start
  6.   dd i_end ; à §¬¥à ¯à¨«®¦¥­¨ï
  7.   dd mem
  8.   dd stacktop
  9.   dd file_name
  10.   dd sys_path
  11.  
  12. MAX_COLOR_WORD_LEN equ 40
  13. BUF_SIZE equ 4096 ;buffer for copy|paste
  14. maxSyntaxFileSize equ 310000
  15. CAPT_PATH_WIDTH equ 50 ;è¨à¨­  ¯®¤¯¨á¨ ¯¥à¥¤ ⥪áâ®¢ë¬ ¯®«¥¬
  16.  
  17. include '../../macros.inc'
  18. include '../../proc32.inc'
  19. include '../../develop/libraries/box_lib/load_lib.mac'
  20. include '../../develop/libraries/box_lib/trunk/box_lib.mac'
  21. include '../../dll.inc'
  22. include 'te_data.inc'
  23. include 'te_work.inc' ;text work functions
  24.  
  25. @use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
  26.  
  27. ;Œ ªà®á ¤«ï § £à㧪¨ ¨§®¡à ¦¥­¨© á ¨á¯®«ì§®¢ ­¨¥¬ ¡¨¡«¨®â¥ª¨ libimg.obj
  28. ;¤«ï ¨á¯®«ì§®¢ ­¨ï ¬ ªà®á  ­ã¦­ë ¯¥à¥¬¥­­ë¥:
  29. ; - run_file_70 FileInfoBlock
  30. ; - image_data dd 0
  31. macro load_image_file path,buf,size
  32. {
  33.         ;path - ¬®¦¥â ¡ëâì ¯¥à¥¬¥­­®© ¨«¨ áâப®¢ë¬ ¯ à ¬¥â஬
  34.         if path eqtype '' ;¯à®¢¥à塞 § ¤ ­ «¨ áâப®© ¯ à ¬¥âà path
  35.                 jmp @f
  36.                         local .path_str
  37.                         .path_str db path ;ä®à¬¨à㥬 «®ª «ì­ãî ¯¥à¥¬¥­­ãî
  38.                         db 0
  39.                 @@:
  40.                 ;32 - áâ ­¤ àâ­ë©  ¤à¥á ¯® ª®â®à®¬ã ¤®«¦¥­ ¡ëâì ¡ãä¥à á á¨á⥬­ë¬ ¯ã⥬
  41.                 copy_path .path_str,[32],file_name,0x0
  42.         else
  43.                 copy_path path,[32],file_name,0x0 ;ä®à¬¨à㥬 ¯®«­ë© ¯ãâì ª ä ©«ã ¨§®¡à ¦¥­¨ï, ¯®¤à §ã¬¥¢ ¥¬ çâ® ®­ ¢ ®¤­®© ¯ ¯ª¥ á ¯à®£à ¬¬®©
  44.         end if
  45.  
  46.         stdcall mem.Alloc, dword size ;¢ë¤¥«ï¥¬ ¯ ¬ïâì ¤«ï ¨§®¡à ¦¥­¨ï
  47.         mov [buf],eax
  48.  
  49.         mov eax,70 ;70-ï äã­ªæ¨ï à ¡®â  á ä ©« ¬¨
  50.         mov [run_file_70.Function], 0
  51.         mov [run_file_70.Position], 0
  52.         mov [run_file_70.Flags], 0
  53.         mov [run_file_70.Count], dword size
  54.         m2m [run_file_70.Buffer], [buf]
  55.         mov byte[run_file_70+20], 0
  56.         mov [run_file_70.FileName], file_name
  57.         mov ebx,run_file_70
  58.         int 0x40 ;§ £à㦠¥¬ ä ©« ¨§®¡à ¦¥­¨ï
  59.         cmp ebx,0xffffffff
  60.         je @f
  61.                 ;®¯à¥¤¥«ï¥¬ ¢¨¤ ¨§®¡à ¦¥­¨ï ¨ ¯¥à¥¢®¤¨¬ ¥£® ¢® ¢à¥¬¥­­ë© ¡ãä¥à image_data
  62.                 stdcall dword[img_decode], dword[buf],ebx,0
  63.                 mov dword[image_data],eax
  64.                 ;¯à¥®¡à §ã¥¬ ¨§®¡à ¦¥­¨¥ ª ä®à¬ âã rgb
  65.                 stdcall dword[img_to_rgb2], dword[image_data],dword[buf]
  66.                 ;㤠«ï¥¬ ¢à¥¬¥­­ë© ¡ãä¥à image_data
  67.                 stdcall dword[img_destroy], dword[image_data]
  68.         @@:
  69. }
  70.  
  71. image_data dd 0 ;㪠§ â¥«ì ­  ¢à¥¬¥­­ãî ¯ ¬ïâì. ¤«ï ­ã¦¥­ ¯à¥®¡à §®¢ ­¨ï ¨§®¡à ¦¥­¨ï
  72. icon_tl_sys dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï åà ­¥­¨ï á¨á⥬­ëå ¨ª®­®ª
  73.  
  74. align 4
  75. start:
  76.         mcall 48,3,sc,sizeof.system_colors
  77.  
  78.         mcall 68,11
  79.         or eax,eax
  80.         jz button.exit
  81.  
  82.         mcall 66,1,1 ;scan code
  83.         mcall 40,0x27
  84.  
  85. ;-------------------------------------------------
  86.         mov ecx,maxSyntaxFileSize
  87.         stdcall mem.Alloc,ecx
  88.         mov [options_file],eax
  89.         mov [options_file_end],eax
  90.         add [options_file_end],ecx
  91.  
  92.  
  93. load_libraries l_libs_start,load_lib_end
  94.  
  95. ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨« áì ­ è  «¨¡ 
  96.         mov     ebp,lib0
  97.         cmp     dword [ebp+ll_struc_size-4],0
  98.         jz      @f
  99.         mcall   -1      ;exit not correct
  100. @@:
  101.  
  102. ;---------------------------------------------------------------------
  103.         stdcall dword[tl_data_init],dword tree1
  104.  
  105. ; ç¨â ¥¬ ä ©« á ªãàá®à ¬¨ ¨ «¨­¨ï¬¨
  106.         load_image_file 'tl_sys_16.png', icon_tl_sys,54+3*256*13
  107.         mov eax,dword[icon_tl_sys]
  108.         mov dword[tree1.data_img_sys],eax
  109. ;---------------------------------------------------------------------
  110. ; ç¨â ¥¬ bmp ä ©« á ¨ª®­ª ¬¨ 㧫®¢
  111.         load_image_file 'tl_nod_16.png', icon_tl_sys,54+3*256*2
  112.         mov eax,dword[icon_tl_sys]
  113.         mov dword[tree1.data_img],eax
  114. ;------------------------------------------------------------------------------
  115.   copy_path fn_syntax_dir,sys_path,file_name,0 ;¡¥à¥¬ ¯ãâì ª ¯ ¯ª¥ á ä ©« ¬¨ ᨭ⠪á¨á 
  116.   mov eax,70
  117.   mov ebx,tree_file_struct
  118.   int 0x40
  119.  
  120. cmp ebx,-1
  121. je .end_dir_init
  122.  
  123.   mov eax,dir_mem
  124.   add eax,32+4+1+3+4*6+8
  125. mov ecx,ebx
  126. @@:
  127.   cmp byte[eax],'.' ;䨫ìâà㥬 ä ©«ë á ¨¬¥­ ¬¨ '.' ¨ '..'
  128.   je .filter
  129.     push dword tree1
  130.     push dword 0x10000 ;1*2^16 - £¤¥ 1 ­®¬¥à ¨ª®­ª¨ á ª­¨£®©
  131.     push dword eax
  132.     call dword[tl_node_add]
  133.  
  134.     stdcall dword[tl_cur_next],tree1
  135.   .filter:
  136.   add eax,304
  137.   loop @b
  138.   stdcall dword[tl_cur_beg],tree1 ;áâ ¢¨¬ ªãàá®à ­  ­ ç «® ᯨ᪠
  139. .end_dir_init:
  140.  
  141. ;--- load color option file ---
  142. stdcall [ted_init], tedit0
  143. mov byte[file_name],0
  144.  
  145. align 4
  146. red_win:
  147.         call draw_window
  148.  
  149. align 4
  150. still:
  151.   mcall 10
  152.  
  153.   cmp al,1 ;¨§¬. ¯®«®¦¥­¨¥ ®ª­ 
  154.   jz red_win
  155.   cmp al,2
  156.   jz key
  157.   cmp al,3
  158.   jz button
  159.   cmp al,6
  160.   jz mouse
  161.  
  162.   jmp still
  163.  
  164.  
  165. align 4
  166. draw_window:
  167.         pushad
  168.         mcall 12,1
  169.  
  170.         mov edx,[sc.work]
  171.         or  edx,0x33000000
  172.         mov edi,hed
  173.         mcall 0,<10,555>,<10,333>
  174.  
  175.         mcall 9,procinfo,-1
  176.  
  177.         mov eax,8 ;ª­®¯ª 
  178.         mov ebx,5*65536+90
  179.         mov ecx,195*65536+20
  180.         mov edx,200
  181.         mov esi,[sc.work_button];0xd0
  182.         mcall
  183.  
  184.         ;mov eax,8
  185.         mov ebx,100*65536+85
  186.         mov ecx,195*65536+20
  187.         mov edx,201
  188.         mov esi,0xd00000
  189.         mcall
  190.  
  191.         mov eax,4 ;à¨á®¢ ­¨¥ ⥪áâ 
  192.         mov ebx,10*65536+200
  193.         mov ecx,[sc.work_button_text]
  194.         or  ecx,0x80000000
  195.         mov edx,txt122
  196.         mcall
  197.  
  198.         mov ebx,105*65536+200
  199.         mov ecx,0xffff00
  200.         or  ecx,0x80000000
  201.         mov edx,txt148
  202.         mcall
  203.  
  204.         mov ebx,195*65536+10
  205.         mov ecx,[sc.work_text]
  206.         or  ecx,0x80000000
  207.         mov edx,txt_inp_file
  208.         int 0x40
  209.  
  210.         add ebx,20
  211.         mov edx,txt_out_file
  212.         int 0x40
  213.  
  214.         push dword PathShow_data_1
  215.         call [PathShow_draw]
  216.        
  217.         stdcall [edit_box_draw],dword edit1
  218.         stdcall [tl_draw],dword tree1
  219.  
  220.         ;scroll 1
  221.         mov [ws_dir_lbox.all_redraw],1
  222.         stdcall [scrollbar_ver_draw],dword ws_dir_lbox
  223.         stdcall [ted_draw], tedit0
  224.  
  225.         mcall 12,2
  226.         popad
  227.         ret
  228.  
  229. align 4
  230. mouse:
  231.         stdcall [tl_mouse],tree1
  232.         stdcall [edit_box_mouse],edit1
  233.         stdcall [ted_mouse], tedit0
  234.         jmp still
  235.  
  236. ;output:
  237. ; ah = symbol
  238. align 4
  239. proc KeyConvertToASCII, table:dword
  240.         push ebx
  241.         mov ebx,dword[table] ;convert scan to ascii
  242.         ror ax,8
  243.         xor ah,ah
  244.         add bx,ax
  245.         mov ah,byte[ebx]
  246.         pop ebx
  247.         ret
  248. endp
  249.  
  250. align 4
  251. key:
  252.         mcall 66,3 ;66.3 ¯®«ãç¨âì á®áâ®ï­¨¥ ã¯à ¢«ïîé¨å ª« ¢¨è
  253.         xor esi,esi
  254.         mov ecx,1
  255.         test al,0x03 ;[Shift]
  256.         jz @f
  257.                 mov cl,2
  258.                 or esi,KM_SHIFT
  259.         @@:
  260.         test al,0x0c ;[Ctrl]
  261.         jz @f
  262.                 or esi,KM_CTRL
  263.         @@:
  264.         test al,0x30 ;[Alt]
  265.         jz @f
  266.                 mov cl,3
  267.                 or esi,KM_ALT
  268.         @@:
  269.         test al,0x80 ;[NumLock]
  270.         jz @f
  271.                 or esi,KM_NUMLOCK
  272.         @@:
  273.  
  274.         mcall 26,2,,conv_tabl ;26.2 ¯®«ãç¨âì à áª« ¤ªã ª« ¢¨ âãàë
  275.         mcall 2
  276.         stdcall [tl_key],tree1
  277.  
  278.         test word [edit1.flags],10b;ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  279.         je @f
  280.                 cmp ah,0x80 ;if key up
  281.                 ja still
  282.                 cmp ah,42 ;[Shift] (left)
  283.                 je still
  284.                 cmp ah,54 ;[Shift] (right)
  285.                 je still
  286.                 cmp ah,56 ;[Alt]
  287.                 je still
  288.                 cmp ah,29 ;[Ctrl]
  289.                 je still
  290.                 cmp ah,69 ;[Pause Break]
  291.                 je still
  292.  
  293.                 stdcall KeyConvertToASCII, dword conv_tabl
  294.                 stdcall [edit_box_key],edit1
  295.                 jmp still
  296.         @@:
  297.  
  298.         stdcall [ted_key], tedit0, conv_tabl,esi
  299.         jmp still
  300.  
  301. align 4
  302. button:
  303. ;  cmp [menu_active],1 ;¥á«¨ ­ ¦ «¨ ¬¥­î, â® á­ ç «  ॠªæ¨ï ­  ¬¥­î
  304. ;  jne @f ;mouse.menu_bar_1
  305. ;    mov [menu_active],0
  306. ;    jmp still
  307. ;  @@:
  308.  
  309.   mcall 17 ;¯®«ãç¨âì ª®¤ ­ ¦ â®© ª­®¯ª¨
  310.  
  311.   cmp ah,200
  312.   jne @f
  313.     call but_OpenSyntax
  314.   @@:
  315.   cmp ah,201
  316.   jne @f
  317.     call but_SaveSyntax
  318.   @@:
  319.  
  320.   cmp ah,1
  321.   jne still
  322. .exit:
  323.   ;push eax
  324.  
  325.   stdcall mem.Free,[options_file]
  326.  
  327.   stdcall [tl_data_clear], tree1
  328.   stdcall [ted_delete], tedit0
  329.   mcall -1 ;¢ë室 ¨§ ¯à®£à ¬¬ë
  330.  
  331. align 4
  332. but_OpenSyntax:
  333.   stdcall [tl_node_get_data],tree1
  334.   pop dword [fn_col_option]
  335.   call InitColText
  336.   ret
  337.  
  338. align 4
  339. but_SaveSyntax:
  340.         stdcall [ted_save_file], tedit0,run_file_70,[edit1.text]
  341.         ret
  342.  
  343. align 4
  344. but_ctrl_o:
  345.         push eax
  346.         call get_wnd_in_focus
  347.         cmp eax,0
  348.         je @f
  349.                 stdcall [ted_open_file], eax,str_file_70,[edit1.text]
  350.         @@:
  351.         pop eax
  352.         ret
  353.  
  354. ;ᮧ¤ ­¨¥ ­®¢®£® ä ©« 
  355. align 4
  356. but_ctrl_n:
  357.         push eax
  358.         call get_wnd_in_focus
  359.         cmp eax,0
  360.         je @f
  361.                 stdcall [ted_clear], eax,1
  362.                 stdcall [ted_draw], eax
  363.         @@:
  364.         pop eax
  365.         ret
  366.  
  367. ;®¯à¥¤¥«ï¥¬ ª ª®¥ ¨§ ®ª®­ । ªâ®à  ¢ 䮪ãá¥
  368. align 4
  369. get_wnd_in_focus:
  370.         xor eax,eax
  371.         cmp dword[el_focus],tedit0
  372.         jne @f
  373.                 mov eax,tedit0
  374.         @@:
  375.         ;cmp dword[el_focus],tedit1
  376.         ;jne @f
  377.         ;       mov eax,tedit1
  378.         ;@@:
  379.         ret
  380.  
  381. hed db 'TextEditor syntax file converter 01.07.14',0 ;¯®¤¯¨áì ®ª­ 
  382. conv_tabl rb 128 ; â ¡«¨æ  ¤«ï ª®­¢¥àâ¨à®¢ ­¨ï scan-ª®¤  ¢ ascii-ª®¤
  383.  
  384. txt122 db '‡ £à. ä ©«',0
  385. txt148 db '‘®åà. ä ©«',0
  386. txt_inp_file db 'ˆáå. ä ©«:',0
  387. txt_out_file db '‚ëå. ä ©«:',0
  388.  
  389. txt_no_kpack db 'Žâªà뢠¥¬ë© ä ©« ᦠâ Kpack-®¬.',13,10,'„«ï à ¡®âë á ä ©«®¬ à á¯ ªã©â¥ ¥£® ¨á¯®«ì§ãï á¨á⥬­ãî ¯à®£à ¬¬ã Kpack.',13,10,' ¡®â  ᮠᦠâ묨 ä ©« ¬¨ ¯®ª  ­¥ ¯®¤¤¥à¦¨¢ ¥âáï.',0
  390.  
  391. head_f_i:
  392. head_f_l db 'System error',0
  393. err_message_found_lib_0 db 'Sorry I cannot found library ',39,'box_lib.obj',39,0
  394. err_message_import_0 db 'Error on load import library ',39,'box_lib.obj',39,0
  395. err_message_found_lib_1 db 'Sorry I cannot found library ',39,'libimg.obj',39,0
  396. err_message_import_1 db 'Error on load import library ',39,'libimg.obj',39,0
  397.  
  398. ;library structures
  399. l_libs_start:
  400.         lib0 l_libs lib_name_0, sys_path, file_name, system_dir_0, err_message_found_lib_0, head_f_l, import_box_lib,err_message_import_0, head_f_i
  401.         lib1 l_libs lib_name_1, sys_path, file_name, system_dir_1, err_message_found_lib_1, head_f_l, import_libimg,err_message_import_1, head_f_i
  402. load_lib_end:
  403.  
  404.  
  405. i_end:
  406.         rb 1024
  407.         align 16
  408.         procinfo process_information
  409.         thread:
  410.                 rb 1024
  411. stacktop:
  412.   sys_path:
  413.     rb 4096
  414.   file_name:
  415.     rb 4096
  416.   file_name_rez:
  417.     rb 4096
  418. mem:
  419.