Subversion Repositories Kolibri OS

Rev

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