Subversion Repositories Kolibri OS

Rev

Rev 1705 | Rev 2125 | 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.   mov eax,10
  198.   mcall
  199.  
  200.   cmp al,1 ;¨§¬. ¯®«®¦¥­¨¥ ®ª­ 
  201.   jz red_win
  202.   cmp al,2
  203.   jz key
  204.   cmp al,3
  205.   jz button
  206.   cmp al,6
  207.   jz mouse
  208.  
  209.   jmp still
  210.  
  211. align 4
  212. draw_window:
  213.   mcall 12,1
  214.  
  215.   xor eax,eax
  216.   mov ebx,10*65536+485
  217.   mov ecx,10*65536+320
  218.   mov edx,[sc.work]
  219.   or  edx,0x73000000
  220.   mov edi,hed
  221.   int 0x40
  222.  
  223.   mov edi,tedit0
  224.  
  225.   mcall 9,procinfo,-1
  226.   stdcall EvSize,edi
  227.  
  228.   mov eax,13 ;¢¥àå­¨© ¯àאַ㣮«ì­¨ª, ¤«ï ®ç¨á⪨ ¢¥àå­¥© ¯ ­¥«¨
  229.   xor ebx,ebx
  230.   mov ecx,ted_wnd_t
  231.   mov bx,word [procinfo.client_box.width]
  232.   inc bx
  233.   int 0x40
  234.  
  235.         mov eax,4
  236.         mov ebx,185*65536+9
  237.         mov ecx,[sc.work_text]
  238.         or  ecx,0x80000000
  239.         mov edx,txtFile
  240.         int 0x40
  241.  
  242.   stdcall [edit_box_draw], dword edit1
  243.   stdcall [menu_bar_draw], dword menu_data_1
  244.  
  245.   call draw_but_toolbar
  246.  
  247.   cmp [err_ini0],1
  248.   jne @f
  249.     mov eax,4
  250.     mov ebx,ted_wnd_l
  251.     add ebx,ted_rec_l
  252.     shl ebx,16
  253.     add ebx,ted_wnd_t
  254.     add ebx,ted_rec_t
  255.     mov ecx,0x80ff0000
  256.     mov edx,txtErrIni0
  257.     int 0x40
  258.  
  259.     add ebx,10 ;move <--y-->
  260.     mov ecx,0x80ff0080
  261.     mov edx,file_name
  262.     int 0x40
  263.   @@:
  264.  
  265.   cmp [err_ini0],1
  266.   je @f
  267.     stdcall [ted_draw], tedit0
  268.   @@:
  269.  
  270.   mcall 12,2
  271.   ret
  272.  
  273. align 4
  274. mouse:
  275.   stdcall [edit_box_mouse], dword edit1
  276.  
  277.   test word [edit1.flags],10b;ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  278.   jne still
  279.  
  280.   stdcall [ted_mouse], tedit0
  281.  
  282.   cmp byte[tedit0.panel_id],TED_PANEL_FIND ;if not panel
  283.   jne @f
  284.     stdcall [edit_box_mouse], dword edit2
  285.   @@:
  286.   cmp byte[tedit0.panel_id],TED_PANEL_SYNTAX ;if not panel
  287.   jne .menu_bar_1 ;@f
  288.   stdcall [tl_mouse], tree1
  289. ;-----------------------------------------------
  290. .menu_bar_1:
  291.   mov [menu_data_1.get_mouse_flag],1
  292. ; mouse event for Menu 1
  293.   push  dword menu_data_1
  294.   call  [menu_bar_mouse]
  295.   cmp   [menu_data_1.click],dword 1
  296.   jne   .mnu_1
  297.   cmp [menu_data_1.cursor_out],dword 4
  298.   je    button.exit    
  299.   cmp [menu_data_1.cursor_out],dword 3
  300.   jne   @f
  301.     stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text]
  302.   @@:
  303.   cmp [menu_data_1.cursor_out],dword 2
  304.   jne   @f
  305.     call ted_but_open_file
  306.   @@:
  307.   cmp [menu_data_1.cursor_out],dword 1
  308.   jne   @f
  309.     call ted_but_new_file
  310.   @@:
  311.   ;cmp [menu_data_1.cursor_out],dword 0
  312.   ;jne @f
  313. .mnu_1:
  314.   jmp still
  315. ;---------------------------------------------------------------------
  316.  
  317. ;output:
  318. ; ah = symbol
  319. align 4
  320. proc KeyConvertToASCII, table:dword
  321.   push ebx
  322.   mov ebx,dword[table] ;convert scan to ascii
  323.   ror ax,8
  324.   xor ah,ah
  325.   add bx,ax
  326.   mov ah,byte[ebx]
  327.   pop ebx
  328.   ret
  329. endp
  330.  
  331. align 4
  332. key:
  333.   mcall 66,3 ;66.3 ¯®«ãç¨âì á®áâ®ï­¨¥ ã¯à ¢«ïîé¨å ª« ¢¨è
  334.   xor esi,esi
  335.   mov ecx,1
  336.   test al,0x03 ;[Shift]
  337.   jz @f
  338.     mov cl,2
  339.     or esi,KM_SHIFT
  340.   @@:
  341.   test al,0x0c ;[Ctrl]
  342.   jz @f
  343.     or esi,KM_CTRL
  344.   @@:
  345.   test al,0x30 ;[Alt]
  346.   jz @f
  347.     mov cl,3
  348.     or esi,KM_ALT
  349.   @@:
  350.   test al,0x80 ;[NumLock]
  351.   jz @f
  352.     or esi,KM_NUMLOCK
  353.   @@:
  354.  
  355.   mcall 26,2,,conv_tabl ;26.2 ¯®«ãç¨âì à áª« ¤ªã ª« ¢¨ âãàë
  356.   mcall 2 ;¯®«ãç ¥¬ ª®¤ ­ ¦ â®© ª« ¢¨è¨
  357.   stdcall [tl_key], tree1
  358.  
  359.   test word [edit1.flags],10b;ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  360.   je @f
  361.     cmp ah,0x80 ;if key up
  362.     ja still
  363.     cmp ah,42 ;[Shift] (left)
  364.     je still
  365.     cmp ah,54 ;[Shift] (right)
  366.     je still
  367.     cmp ah,56 ;[Alt]
  368.     je still
  369.     cmp ah,29 ;[Ctrl]
  370.     je still
  371.     cmp ah,69 ;[Pause Break]
  372.     je still
  373.  
  374.     stdcall KeyConvertToASCII, dword conv_tabl
  375.     stdcall [edit_box_key], dword edit1
  376.     jmp still
  377.   @@:
  378.  
  379.   test word [edit2.flags],10b;ed_focus ; ¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  380.   je @f
  381.     cmp ah,0x80 ;if key up
  382.     ja still
  383.     cmp ah,42 ;[Shift] (left)
  384.     je still
  385.     cmp ah,54 ;[Shift] (right)
  386.     je still
  387.     cmp ah,56 ;[Alt]
  388.     je still
  389.     cmp ah,29 ;[Ctrl]
  390.     je still
  391.     cmp ah,69 ;[Pause Break]
  392.     je still
  393.  
  394.     stdcall KeyConvertToASCII, dword conv_tabl
  395.     stdcall [edit_box_key], dword edit2
  396.     jmp still
  397.   @@:
  398.  
  399.   stdcall [ted_key], tedit0, conv_tabl,esi
  400.   jmp still
  401.  
  402. align 4
  403. button:
  404. ;  cmp [menu_active],1 ;¥á«¨ ­ ¦ «¨ ¬¥­î, â® á­ ç «  ॠªæ¨ï ­  ¬¥­î
  405. ;  jne @f ;mouse.menu_bar_1
  406. ;    mov [menu_active],0
  407. ;    jmp still
  408. ;  @@:
  409.  
  410.   mcall 17 ;¯®«ãç¨âì ª®¤ ­ ¦ â®© ª­®¯ª¨
  411.   cmp ah,3
  412.   jne @f
  413.     call ted_but_new_file
  414.   @@:
  415.   cmp ah,4
  416.   jne @f
  417.     call ted_but_open_file
  418.   @@:
  419.   cmp ah,5
  420.   jne @f
  421.     stdcall [ted_but_save_file], tedit0,run_file_70,[edit1.text]
  422.   @@:
  423.   cmp ah,6
  424.   jne @f
  425.     stdcall [ted_but_select_word], tedit0
  426.   @@:
  427.   cmp ah,7
  428.   jne @f
  429.     stdcall [ted_but_cut], tedit0
  430.   @@:
  431.   cmp ah,8
  432.   jne @f
  433.     stdcall [ted_but_copy], tedit0
  434.   @@:
  435.   cmp ah,9
  436.   jne @f
  437.     stdcall [ted_but_paste], tedit0
  438.   @@:
  439.   cmp ah,10
  440.   jne @f
  441.     call ted_but_find
  442.   @@:
  443.   cmp ah,11
  444.   jne @f
  445.     call but_replace
  446.   @@:
  447.   cmp ah,12
  448.   jne @f
  449.     call but_find_key_w
  450.   @@:
  451.   cmp ah,13
  452.   jne @f
  453.     stdcall [ted_but_sumb_upper], tedit0
  454.   @@:
  455.   cmp ah,14
  456.   jne @f
  457.     stdcall [ted_but_sumb_lover], tedit0
  458.   @@:
  459.   cmp ah,15
  460.   jne @f
  461.     stdcall [ted_but_reverse], tedit0
  462.   @@:
  463.   cmp ah,16
  464.   jne @f
  465.     stdcall [ted_but_undo], tedit0
  466.   @@:
  467.   cmp ah,17
  468.   jne @f
  469.     stdcall [ted_but_redo], tedit0
  470.   @@:
  471.   cmp ah,18
  472.   jne @f
  473.     stdcall but_sumb_invis, tedit0
  474.   @@:
  475.   cmp ah,19
  476.   jne @f
  477.     stdcall but_k_words_show, tedit0
  478.   @@:
  479.   cmp ah,20
  480.   jne @f
  481.     stdcall but_synt_show, tedit0
  482.   @@:
  483.  
  484.   cmp ah,200
  485.   jne @f
  486.     stdcall ted_but_open_syntax, tedit0
  487.   @@:
  488.   cmp ah,201
  489.   jne @f
  490.     stdcall [ted_but_find_next], tedit0
  491.   @@:
  492.  
  493.   cmp ah,1
  494.   jne still
  495. .exit:
  496.   stdcall [ted_can_save], tedit0
  497.   cmp al,1
  498.   jne @f
  499.     stdcall [mb_create],msgbox_8,thread ;message: save changes in file?
  500.     jmp still
  501.   @@:
  502.   stdcall mem.Free,[bmp_icon]
  503.  
  504.   stdcall [ted_delete], tedit0
  505.   stdcall dword[tl_data_clear], tree1
  506.   mcall -1 ;¢ë室 ¨§ ¯à®£à ¬¬ë
  507.  
  508.  
  509.  
  510. txtErrIni0 db '¥ ®âªàë«áï ä ©« á ¨ª®­ª ¬¨',0
  511. err_ini0 db 0
  512.  
  513. edit1 edit_box 250, 220, 5, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 4090, openfile_path, mouse_dd, 0
  514. edit2 edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_find, mouse_dd, 0
  515.  
  516. buf_find db 302 dup(0)
  517.  
  518. if lang eq ru
  519.   head_f_i0:
  520.   head_f_l0  db '‘¨á⥬­ ï ®è¨¡ª ',0
  521.   err_message_found_lib0 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'box_lib.obj',39,0
  522.   err_message_import0 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'box_lib.obj',39,0
  523.   err_message_found_lib1 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'msgbox.obj',39,0
  524.   err_message_import1 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'msgbox.obj',39,0
  525.   err_message_found_lib2 db '¥ ­ ©¤¥­  ¡¨¡«¨®â¥ª  ',39,'proc_lib.obj',39,0
  526.   err_message_import2 db 'Žè¨¡ª  ¯à¨ ¨¬¯®à⥠¡¨¡«¨®â¥ª¨ ',39,'proc_lib.obj',39,0
  527. else
  528.   head_f_i0:
  529.   head_f_l0  db 'System error',0
  530.   err_message_found_lib0 db 'Sorry I cannot found library ',39,'box_lib.obj',39,0
  531.   err_message_import0 db 'Error on load import library ',39,'box_lib.obj',39,0
  532.   err_message_found_lib1 db 'Sorry I cannot found library ',39,'msgbox.obj',39,0
  533.   err_message_import1 db 'Error on load import library ',39,'msgbox.obj',39,0
  534.   err_message_found_lib2 db 'Sorry I cannot found library ',39,'proc_lib.obj',39,0
  535.   err_message_import2 db 'Error on load import library ',39,'proc_lib.obj',39,0
  536. end if
  537.  
  538. ;library structures
  539. l_libs_start:
  540.         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
  541.         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
  542.         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
  543. load_lib_end:
  544.  
  545.  
  546. i_end:
  547.         rb 1024
  548.         align 16
  549.         procinfo process_information
  550.                 rb 1024
  551.         thread:
  552.         rb 1024
  553. stacktop:
  554.         sys_path:
  555.                 rb 4096
  556.         file_name:
  557.                 rb 4096
  558.         file_name_rez:
  559.                 rb 4096
  560.         plugin_path:
  561.                 rb 4096
  562.         openfile_path:
  563.                 rb 4096
  564.         filename_area:
  565.                 rb 256
  566.         file_info:
  567.                 rb 40
  568. mem:
  569.