Subversion Repositories Kolibri OS

Rev

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