Subversion Repositories Kolibri OS

Rev

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