Subversion Repositories Kolibri OS

Rev

Rev 8255 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;Ž£à®¬­ ï ¡« £®¤ à­®áâì ¢á¥¬, ªâ® ¯®¬®£ «: ª®¤®¬/ᮢ¥â®¬/¤¨§ ©­®¬ ...
  2.  
  3. use32
  4.   org 0
  5.   db 'MENUET01' ;¨¤¥­â¨ä. ¨á¯®«­ï¥¬®£® ä ©«  ¢á¥£¤  8 ¡ ©â
  6.   dd 1, start, i_end, mem, stacktop, file_name, sys_path
  7.  
  8. MAX_COLOR_WORD_LEN equ 40
  9. maxChars equ 100002 ;(ª®««¨ç¥á⢮ ᨬ¢®«®¢ ¢ ­®¢®¬ ¤®ªã¬¥­â¥ + 2)
  10. BUF_SIZE equ 4096 ;buffer for copy|paste
  11. maxSyntaxFileSize equ 410000
  12. TOOLBAR_ICONS_SIZE equ 1200*21
  13.  
  14. include '../../proc32.inc'
  15. include '../../macros.inc'
  16. include '../../KOSfuncs.inc'
  17. include '../../load_img.inc'
  18. include '../../load_lib.mac'
  19. include '../../develop/libraries/box_lib/trunk/box_lib.mac'
  20. include '../../system/skincfg/trunk/kglobals.inc'
  21. include '../../system/skincfg/trunk/unpacker.inc'
  22. include 'lang.inc'
  23.  
  24. include 't_data.inc'
  25. include 't_button.inc'
  26. include 't_menu.inc'
  27. include 'strlen.inc'
  28. include 't_draw.inc' ;draw main window functions
  29. include 'wnd_k_words.inc'
  30.  
  31. @use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
  32.  
  33. align 4
  34. icon_tl_sys dd 0 ;㪠§ â¥«ì ­  ¯ ¬ïâì ¤«ï åà ­¥­¨ï á¨á⥬­ëå ¨ª®­®ª
  35. run_file_70 FileInfoBlock
  36.  
  37. align 4
  38. start:
  39.         mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
  40.  
  41.         mcall SF_SYS_MISC,SSF_HEAP_INIT
  42.         or eax,eax
  43.         jnz @f
  44.                 call ted_Exit
  45.         @@:
  46.  
  47.         mcall SF_KEYBOARD,SSF_SET_INPUT_MODE,1 ;scan code
  48.         mcall SF_SET_EVENTS_MASK,0xC0000027
  49.  
  50.         mov esi,file_name
  51.         stdcall str_len,esi
  52.         mov ecx,eax
  53.         mov edi,openfile_path
  54.         cld
  55.         rep movsb ;ª®¯¨à㥬 ¨¬ï ä ©«  ¢ ¡ãä¥à openfile_path
  56.  
  57. load_libraries l_libs_start,load_lib_end
  58.  
  59. ;¯à®¢¥àª  ­  ᪮«ìª® 㤠筮 § £ã§¨«¨áì ¡¨¡«¨®â¥ª¨
  60. mov     ebp,lib0
  61. .test_lib_open:
  62.         cmp     dword [ebp+ll_struc_size-4],0
  63.         jz      @f
  64.         mcall SF_TERMINATE_PROCESS ;exit not correct
  65. @@:
  66.         add ebp,ll_struc_size
  67.         cmp ebp,load_lib_end
  68.         jl .test_lib_open
  69.  
  70. ;---------------------------------------------------------------------
  71.         stdcall [ted_init], tedit0
  72.         stdcall [tl_data_init], tree1
  73.         option_boxes_set_sys_color sc,opt_grlist1
  74.         init_checkboxes2 check_boxes,check_boxes_end
  75.         check_boxes_set_sys_color2 check_boxes,check_boxes_end,sc
  76.  
  77. ; OpenDialog initialisation
  78.         stdcall [OpenDialog_Init],OpenDialog_data
  79.  
  80. ; kmenu initialisation
  81.         call tedit_menu_init
  82.  
  83. ; init toolbar file
  84.         include_image_file 'te_icon.png', bmp_icon,,,6 ;6 ¤«ï á¥àëå ª­®¯®ª
  85.         mov eax,[bmp_icon]
  86.         add eax,TOOLBAR_ICONS_SIZE
  87.         stdcall img_to_gray, [bmp_icon],eax,(TOOLBAR_ICONS_SIZE)/3
  88. ;---------------------------------------------------------------------
  89. ; ¢­¥¤à塞 ä ©« á ªãàá®à ¬¨ ¨ «¨­¨ï¬¨
  90.         include_image_file '..\..\media\log_el\trunk\tl_sys_16.png', icon_tl_sys
  91.         mov eax,dword[icon_tl_sys]
  92.         mov dword[tree1.data_img_sys],eax
  93. ; ¢­¥¤à塞 ä ©« á ¨ª®­ª ¬¨ 㧫®¢
  94.         include_image_file 'tl_nod_16.png', icon_tl_sys
  95.         mov eax,dword[icon_tl_sys]
  96.         mov dword[tree1.data_img],eax
  97. ;------------------------------------------------------------------------------
  98.         copy_path fn_syntax_dir,sys_path,file_name,0 ;¡¥à¥¬ ¯ãâì ª ¯ ¯ª¥ á ä ©« ¬¨ ᨭ⠪á¨á 
  99.         xor eax,eax
  100.         mov ecx,4096
  101.         mov edi,file_name
  102.         repnz scasb
  103.         mov byte[edi-2],al ;㡨ࠥ¬ '/' ¢ ª®­æ¥ ¨¬¥­¨ ¯ ¯ª¨ (­ã¦­® ¤«ï ç⥭¨ï á CD)
  104.         mcall SF_FILE,tree_file_struct
  105.  
  106.         or ebx,ebx
  107.         jz .end_dir_init
  108.                 mov eax,dir_mem+32+40
  109.                 mov ecx,ebx
  110.                 @@:
  111.                         cmp byte[eax],'.' ;䨫ìâà㥬 ä ©«ë á ¨¬¥­ ¬¨ '.' ¨ '..'
  112.                         je .filter
  113.                         ;0x10000 ;1*2^16 - £¤¥ 1 ­®¬¥à ¨ª®­ª¨ á ª­¨£®©
  114.                         stdcall [tl_node_add], tree1,0x10000,eax
  115.                         stdcall [tl_cur_next], tree1
  116.                         .filter:
  117.                         add eax,304
  118.                         loop @b
  119.                 stdcall [tl_cur_beg],tree1 ;áâ ¢¨¬ ªãàá®à ­  ­ ç «® ᯨ᪠
  120.                 or dword[tree1.style], tl_cursor_pos_limited ;®£à ­¨ç¨¢ ¥¬ ¤¢¨¦¥­¨¥ ªãàá®à  ¢ ¯à¥¤¥« å ᯨ᪠
  121.         .end_dir_init:
  122.  
  123. ;--- load ini file ---
  124.         copy_path ini_name,sys_path,file_name,0
  125.         ;window startup pozition
  126.         stdcall [ini_get_int],file_name,ini_sec_window,key_window_l,ini_def_window_l
  127.         mov word[wnd_s_pos+2],ax
  128.         stdcall [ini_get_int],file_name,ini_sec_window,key_window_w,ini_def_window_w
  129.         mov word[wnd_s_pos],ax
  130.         stdcall [ini_get_int],file_name,ini_sec_window,key_window_t,ini_def_window_t
  131.         mov word[wnd_s_pos+6],ax
  132.         stdcall [ini_get_int],file_name,ini_sec_window,key_window_h,ini_def_window_h
  133.         mov word[wnd_s_pos+4],ax
  134.         ;scrool type
  135.         stdcall [ini_get_int],file_name,ini_sec_window,key_scroll_type,ini_def_scroll_type
  136.         mov [wScr.type],eax
  137.         mov [hScr.type],eax
  138.         mov [ws_dir_lbox.type],eax
  139.     mov [w_scr_t3.type],eax
  140.         ;symbol size
  141.         stdcall [ini_get_int],file_name,ini_sec_window,key_symbol_w,ini_def_symbol_w
  142.         mov dword[tedit0.rec.width],eax
  143.         stdcall [ini_get_int],file_name,ini_sec_window,key_symbol_h,ini_def_symbol_h
  144.         mov dword[tedit0.rec.height],eax
  145.         ;lea eax,[eax+eax*2]
  146.         ;mov dword[tedit0.rec.top],eax
  147.         ;font size
  148.         stdcall [ini_get_int],file_name,ini_sec_window,key_font_s,ini_def_font_s
  149.         shl eax,24
  150.         mov dword[tedit0.font_size],eax
  151.         ;ª­®¯ª¨ ­  ¯ ­¥«¨
  152.         ini_panel key_but_new,    ID_BUT_NEW
  153.         ini_panel key_but_open,   ID_BUT_OPEN
  154.         ini_panel key_but_save,   ID_BUT_SAVE
  155.         ini_panel key_but_save_as,ID_BUT_SAVE_AS
  156.         ini_panel key_but_select, ID_BUT_SELECT
  157.         ini_panel key_but_cut,    ID_BUT_CUT
  158.         ini_panel key_but_copy,   ID_BUT_COPY
  159.         ini_panel key_but_paste,  ID_BUT_PASTE
  160.         ini_panel key_but_find,   ID_BUT_FIND
  161.         ini_panel key_but_replace,ID_BUT_REPLACE
  162.         ini_panel key_but_key_words,ID_BUT_KEY_WORDS
  163.         ini_panel key_but_upper,  ID_BUT_UPPER
  164.         ini_panel key_but_lower,  ID_BUT_LOWER
  165.         ini_panel key_but_reverse,ID_BUT_REVERSE
  166.         ini_panel key_but_undo,   ID_BUT_UNDO
  167.         ini_panel key_but_redo,   ID_BUT_REDO
  168.         ini_panel key_but_invisible,ID_BUT_INVISIBLE
  169.         ini_panel key_but_syntax_list,ID_BUT_SYNTAX_LIST
  170.         ini_panel key_but_syntax_mode,ID_BUT_SYNTAX_MODE
  171.         ini_panel key_but_convert_1251_866,ID_BUT_CONVERT_1251_866
  172.         ini_panel key_but_convert_866_1251,ID_BUT_CONVERT_866_1251
  173.         ;ä ©«®¢ë¥ à áè¨à¥­¨ï
  174.         xor edx,edx
  175.         mov ebx,synt_auto_open
  176.         @@:
  177.                 ;¡¥à¥¬ ¨¬ï ä ©« 
  178.                 stdcall [ini_get_str],file_name,ini_sec_options,key_synt_file,ebx,32,ini_def_synt_f
  179.                 cmp byte[ebx],0
  180.                 je @f
  181.                 inc byte[key_synt_file.numb]
  182.                 add ebx,32
  183.                 ;¡¥à¥¬ à áè¨à¥­¨ï
  184.                 stdcall [ini_get_str],file_name,ini_sec_options,key_synt_ext,ebx,32,ini_def_synt_f
  185.                 inc byte[key_synt_ext.numb]
  186.                 add ebx,32
  187.                 inc edx
  188.                 cmp edx,max_synt_auto_open
  189.                 jl @b
  190.         @@:
  191.  
  192. ;--- load color option file ---
  193.         stdcall open_unpac_synt_file,[fn_col_option]
  194.  
  195. ;--- get cmd line ---
  196.         cmp byte[openfile_path+3],0 ;openfile_path
  197.         je @f ;if file names exist
  198.                 mov esi,openfile_path
  199.                 stdcall auto_open_syntax,esi
  200.                 call but_no_msg_OpenFile
  201.         @@:
  202.  
  203.  
  204.  
  205. align 16
  206. red_win:
  207.         call draw_window
  208.  
  209. align 16
  210. still:
  211.         mcall SF_WAIT_EVENT
  212.         cmp dword[exit_code],1
  213.         jne @f
  214.                 call ted_Exit
  215.                 jmp still
  216.         @@:
  217.  
  218.         cmp al,1 ;¨§¬¥­¨«®áì ¯®«®¦¥­¨¥ ®ª­ 
  219.         jz red_win
  220.         cmp al,2
  221.         jz key
  222.         cmp al,3
  223.         jz button
  224.         cmp al,6 ;¬ëèì
  225.         jne @f
  226.                 call mouse
  227.         @@:
  228.         jmp still
  229.  
  230. align 16
  231. mouse:
  232.         stdcall [kmainmenu_dispatch_cursorevent], [main_menu]
  233.  
  234.         mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
  235.         cmp word[tedit0.wnd.top],ax
  236.         jg .no_edit
  237.         shr eax,16
  238.         cmp word[tedit0.wnd.left],ax
  239.         jg .no_edit
  240.         mcall SF_MOUSE_GET,SSF_BUTTON_EXT
  241.         bt eax,24 ;¤¢®©­®© 饫çñª «¥¢®© ª­®¯ª®©
  242.         jnc @f
  243.                 stdcall [ted_but_select_word], tedit0
  244.                 ret
  245.         @@:
  246.                 stdcall [ted_mouse], tedit0
  247.         .no_edit:
  248.  
  249.         ;¯à®¢¥àª  ¡®ª®¢ëå ¯ ­¥«¥©
  250.         cmp byte[tedit0.panel_id],TED_PANEL_FIND
  251.         jne @f
  252.                 stdcall [edit_box_mouse], edit_find
  253.                 stdcall [option_box_mouse], opt_grlist1
  254.                 stdcall [check_box_mouse], ch1
  255.         @@:
  256.         cmp byte[tedit0.panel_id],TED_PANEL_REPLACE
  257.         jne @f
  258.                 stdcall [edit_box_mouse], edit_find
  259.                 stdcall [edit_box_mouse], edit_replace
  260.                 stdcall [option_box_mouse], opt_grlist1
  261.         @@:
  262.         cmp byte[tedit0.panel_id],TED_PANEL_SYNTAX
  263.         jne @f
  264.                 stdcall [tl_mouse], tree1
  265.         @@:
  266.         cmp byte[tedit0.panel_id],TED_PANEL_GOTO
  267.         jne @f
  268.                 stdcall [edit_box_mouse], edit_goto
  269.         @@:
  270.         ret
  271. ;---------------------------------------------------------------------
  272.  
  273. ;output:
  274. ; ah = symbol
  275. align 16
  276. proc KeyConvertToASCII uses ebx, table:dword
  277.         mov ebx,dword[table] ;convert scan to ascii
  278.         shr ax,8
  279.         add bx,ax
  280.         mov ah,byte[ebx]
  281.         ret
  282. endp
  283.  
  284. align 16
  285. key:
  286.         mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS ;66.3 ¯®«ãç¨âì á®áâ®ï­¨¥ ã¯à ¢«ïîé¨å ª« ¢¨è
  287.         xor esi,esi
  288.         mov ecx,1
  289.         test al,3 ;[Shift]
  290.         jz @f
  291.                 mov cl,2
  292.                 or esi,KM_SHIFT
  293.         @@:
  294.         test al,0x0c ;[Ctrl]
  295.         jz @f
  296.                 or esi,KM_CTRL
  297.         @@:
  298.         test al,0x30 ;[Alt]
  299.         jz @f
  300.                 mov cl,3
  301.                 or esi,KM_ALT
  302.         @@:
  303.         test al,0x80 ;[NumLock]
  304.         jz @f
  305.                 or esi,KM_NUMLOCK
  306.         @@:
  307.  
  308.         mcall SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT,,conv_tabl ;26.2 ¯®«ãç¨âì à áª« ¤ªã ª« ¢¨ âãàë
  309.         mcall SF_GET_KEY
  310.         stdcall [tl_key], tree1
  311.  
  312.         test word[edit_replace.flags],ed_focus ;¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  313.         je @f
  314.                 cmp ah,0x80 ;if key up
  315.                 ja still
  316.                 cmp ah,42 ;[Shift] (left)
  317.                 je still
  318.                 cmp ah,54 ;[Shift] (right)
  319.                 je still
  320.                 cmp ah,56 ;[Alt]
  321.                 je still
  322.                 cmp ah,29 ;[Ctrl]
  323.                 je still
  324.                 cmp ah,69 ;[Pause Break]
  325.                 je still
  326.  
  327.                 stdcall KeyConvertToASCII, conv_tabl
  328.                 stdcall [edit_box_key], edit_replace
  329.                 jmp still
  330.         @@:
  331.         test word[edit_find.flags],ed_focus ;¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  332.         je @f
  333.                 cmp ah,0x80 ;if key up
  334.                 ja still
  335.                 cmp ah,42 ;[Shift] (left)
  336.                 je still
  337.                 cmp ah,54 ;[Shift] (right)
  338.                 je still
  339.                 cmp ah,56 ;[Alt]
  340.                 je still
  341.                 cmp ah,29 ;[Ctrl]
  342.                 je still
  343.                 cmp ah,69 ;[Pause Break]
  344.                 je still
  345.  
  346.                 stdcall KeyConvertToASCII, conv_tabl
  347.                 stdcall [edit_box_key], edit_find
  348.                 jmp still
  349.         @@:
  350.         test word[edit_goto.flags],ed_focus ;¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  351.         je @f
  352.                 cmp ah,0x80 ;if key up
  353.                 ja still
  354.                 cmp ah,42 ;[Shift] (left)
  355.                 je still
  356.                 cmp ah,54 ;[Shift] (right)
  357.                 je still
  358.                 cmp ah,56 ;[Alt]
  359.                 je still
  360.                 cmp ah,29 ;[Ctrl]
  361.                 je still
  362.                 cmp ah,69 ;[Pause Break]
  363.                 je still
  364.  
  365.                 stdcall KeyConvertToASCII, conv_tabl
  366.                 stdcall [edit_box_key], edit_goto
  367.                 jmp still
  368.         @@:
  369.  
  370.         stdcall [ted_key], tedit0, conv_tabl,esi
  371.         jmp still
  372.  
  373. align 4
  374. edit_replace edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_replace, mouse_dd, 0
  375. edit_find edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_find, mouse_dd, 0
  376. edit_goto edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 10, buf_goto, mouse_dd, 0
  377.  
  378. unpac_mem dd 0
  379.  
  380. ;library structures
  381. l_libs_start:
  382.         lib0 l_libs lib_name_0, file_name, system_dir_0, import_box_lib
  383.         lib1 l_libs lib_name_1, file_name, system_dir_1, import_msgbox_lib
  384.         lib2 l_libs lib_name_2, file_name, system_dir_2, import_proclib
  385.         lib3 l_libs lib_name_3, file_name, system_dir_3, import_libimg
  386.         lib4 l_libs lib_name_4, file_name, system_dir_4, import_libini
  387.         lib5 l_libs lib_name_5, file_name, system_dir_5, import_libkmenu
  388. load_lib_end:
  389.  
  390. IncludeIGlobals
  391. hed db 'TextEdit '
  392. i_end:
  393.         openfile_path: ;¯®«­ë© ¯ãâì ª ä ©«ã á ª®â®àë¬ ¨¤¥â à ¡®â 
  394.                 rb 4096
  395.         dir_mem rb 32+304*count_of_dir_list_files
  396.         wnd_s_pos: ;¬¥áâ® ¤«ï ­ áâ஥ª áâ à⮢®© ¯®§¨æ¨¨ ®ª­ 
  397.                 rq 1
  398.         last_open_synt_file rb 32 ;¨¬ï ¯®á«¥¤­¥£® ¯®¤ª«î祭­®£® ä ©«  ᨭ⠪á¨á 
  399.         buf rb BUF_SIZE ;¡ãä¥à ¤«ï ª®¯¨à®¢ ­¨ï ¨ ¢áâ ¢ª¨
  400.         buf_find rb 302 ;¡ãä¥à ¤«ï ¯®¨áª  ⥪áâ 
  401.         buf_replace rb 302 ;¡ãä¥à ¤«ï § ¬¥­ë ⥪áâ 
  402.         buf_goto rb 12 ;¡ãä¥à ¤«ï ¯¥à室  ­  áâபã
  403.         sc system_colors
  404. IncludeUGlobals
  405.         align 16
  406.         procinfo process_information
  407.                 rb 1024
  408.         thread:
  409.                 rb 4096
  410. align 16
  411.     thread_coords:
  412.         rb 4096
  413. align 16
  414. stacktop:
  415.         sys_path: ;¯ãâì ®âªã¤  § ¯ãá⨫áï ¨á¯®«­ï¥¬ë© ä ©«
  416.                 rb 4096
  417.         file_name: ;¯ à ¬¥âàë § ¯ã᪠
  418.                 rb 4096
  419.         syntax_path: ;¨¬ï ¯®¤ª«îç ¥¬®£® ä ©«  ᨭ⠪á¨á 
  420.                 rb 4096
  421.         plugin_path:
  422.                 rb 4096
  423.         text_work_area: ;¯ãâì ª ä ©«ã, ª®â®àë© ¯®ª §ë¢ ¥âáï ¢ ®ª­¥
  424.                 rb 4096
  425.         filename_area: ;¨¬ï ä ©«  ¤«ï ¤¨ «®£  ®âªàëâ¨ï/§ ªàëâ¨ï
  426.                 rb 256
  427.         file_info:
  428.                 rb 40
  429. mem:
  430.