Subversion Repositories Kolibri OS

Rev

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