Subversion Repositories Kolibri OS

Rev

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