Subversion Repositories Kolibri OS

Rev

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