Subversion Repositories Kolibri OS

Rev

Rev 7583 | Go to most recent revision | 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.         mcall SF_FILE,tree_file_struct
  100.  
  101.         cmp ebx,0
  102.         jle .end_dir_init
  103.                 mov eax,dir_mem+32+40
  104.                 mov ecx,ebx
  105.                 @@:
  106.                         cmp byte[eax],'.' ;䨫ìâà㥬 ä ©«ë á ¨¬¥­ ¬¨ '.' ¨ '..'
  107.                         je .filter
  108.                         ;0x10000 ;1*2^16 - £¤¥ 1 ­®¬¥à ¨ª®­ª¨ á ª­¨£®©
  109.                         stdcall [tl_node_add], tree1,0x10000,eax
  110.                         stdcall [tl_cur_next], tree1
  111.                         .filter:
  112.                         add eax,304
  113.                         loop @b
  114.                 stdcall [tl_cur_beg],tree1 ;áâ ¢¨¬ ªãàá®à ­  ­ ç «® ᯨ᪠
  115.                 or dword[tree1.style], tl_cursor_pos_limited ;®£à ­¨ç¨¢ ¥¬ ¤¢¨¦¥­¨¥ ªãàá®à  ¢ ¯à¥¤¥« å ᯨ᪠
  116.         .end_dir_init:
  117.  
  118. ;--- load ini file ---
  119.         copy_path ini_name,sys_path,file_name,0
  120.         ;window startup pozition
  121.         stdcall [ini_get_int],file_name,ini_sec_window,key_window_l,ini_def_window_l
  122.         mov word[wnd_s_pos+2],ax
  123.         stdcall [ini_get_int],file_name,ini_sec_window,key_window_w,ini_def_window_w
  124.         mov word[wnd_s_pos],ax
  125.         stdcall [ini_get_int],file_name,ini_sec_window,key_window_t,ini_def_window_t
  126.         mov word[wnd_s_pos+6],ax
  127.         stdcall [ini_get_int],file_name,ini_sec_window,key_window_h,ini_def_window_h
  128.         mov word[wnd_s_pos+4],ax
  129.         ;scrool type
  130.         stdcall [ini_get_int],file_name,ini_sec_window,key_scroll_type,ini_def_scroll_type
  131.         mov [wScr.type],eax
  132.         mov [hScr.type],eax
  133.         mov [ws_dir_lbox.type],eax
  134.     mov [w_scr_t3.type],eax
  135.         ;symbol size
  136.         stdcall [ini_get_int],file_name,ini_sec_window,key_symbol_w,ini_def_symbol_w
  137.         mov dword[tedit0.rec.width],eax
  138.         stdcall [ini_get_int],file_name,ini_sec_window,key_symbol_h,ini_def_symbol_h
  139.         mov dword[tedit0.rec.height],eax
  140.         ;lea eax,[eax+eax*2]
  141.         ;mov dword[tedit0.rec.top],eax
  142.         ;font size
  143.         stdcall [ini_get_int],file_name,ini_sec_window,key_font_s,ini_def_font_s
  144.         shl eax,24
  145.         mov dword[tedit0.font_size],eax
  146.         ;ª­®¯ª¨ ­  ¯ ­¥«¨
  147.         ini_panel key_but_new,    ID_BUT_NEW
  148.         ini_panel key_but_open,   ID_BUT_OPEN
  149.         ini_panel key_but_save,   ID_BUT_SAVE
  150.         ini_panel key_but_save_as,ID_BUT_SAVE_AS
  151.         ini_panel key_but_select, ID_BUT_SELECT
  152.         ini_panel key_but_cut,    ID_BUT_CUT
  153.         ini_panel key_but_copy,   ID_BUT_COPY
  154.         ini_panel key_but_paste,  ID_BUT_PASTE
  155.         ini_panel key_but_find,   ID_BUT_FIND
  156.         ini_panel key_but_replace,ID_BUT_REPLACE
  157.         ini_panel key_but_key_words,ID_BUT_KEY_WORDS
  158.         ini_panel key_but_upper,  ID_BUT_UPPER
  159.         ini_panel key_but_lower,  ID_BUT_LOWER
  160.         ini_panel key_but_reverse,ID_BUT_REVERSE
  161.         ini_panel key_but_undo,   ID_BUT_UNDO
  162.         ini_panel key_but_redo,   ID_BUT_REDO
  163.         ini_panel key_but_invisible,ID_BUT_INVISIBLE
  164.         ini_panel key_but_syntax_list,ID_BUT_SYNTAX_LIST
  165.         ini_panel key_but_syntax_mode,ID_BUT_SYNTAX_MODE
  166.         ini_panel key_but_convert_1251_866,ID_BUT_CONVERT_1251_866
  167.         ini_panel key_but_convert_866_1251,ID_BUT_CONVERT_866_1251
  168.         ;ä ©«®¢ë¥ à áè¨à¥­¨ï
  169.         xor edx,edx
  170.         mov ebx,synt_auto_open
  171.         @@:
  172.                 ;¡¥à¥¬ ¨¬ï ä ©« 
  173.                 stdcall [ini_get_str],file_name,ini_sec_options,key_synt_file,ebx,32,ini_def_synt_f
  174.                 cmp byte[ebx],0
  175.                 je @f
  176.                 inc byte[key_synt_file.numb]
  177.                 add ebx,32
  178.                 ;¡¥à¥¬ à áè¨à¥­¨ï
  179.                 stdcall [ini_get_str],file_name,ini_sec_options,key_synt_ext,ebx,32,ini_def_synt_f
  180.                 inc byte[key_synt_ext.numb]
  181.                 add ebx,32
  182.                 inc edx
  183.                 cmp edx,max_synt_auto_open
  184.                 jl @b
  185.         @@:
  186.  
  187. ;--- load color option file ---
  188.         stdcall open_unpac_synt_file,[fn_col_option]
  189.  
  190. ;--- get cmd line ---
  191.         cmp byte[openfile_path+3],0 ;openfile_path
  192.         je @f ;if file names exist
  193.                 mov esi,openfile_path
  194.                 stdcall auto_open_syntax,esi
  195.                 call but_no_msg_OpenFile
  196.         @@:
  197.  
  198.  
  199.  
  200. align 16
  201. red_win:
  202.         call draw_window
  203.  
  204. align 16
  205. still:
  206.         mcall SF_WAIT_EVENT
  207.         cmp dword[exit_code],1
  208.         jne @f
  209.                 call ted_Exit
  210.                 jmp still
  211.         @@:
  212.  
  213.         cmp al,1 ;¨§¬¥­¨«®áì ¯®«®¦¥­¨¥ ®ª­ 
  214.         jz red_win
  215.         cmp al,2
  216.         jz key
  217.         cmp al,3
  218.         jz button
  219.         cmp al,6 ;¬ëèì
  220.         jne @f
  221.                 call mouse
  222.         @@:
  223.         jmp still
  224.  
  225. align 16
  226. mouse:
  227.         stdcall [kmainmenu_dispatch_cursorevent], [main_menu]
  228.  
  229.         mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
  230.         cmp word[tedit0.wnd.top],ax
  231.         jg .no_edit
  232.         shr eax,16
  233.         cmp word[tedit0.wnd.left],ax
  234.         jg .no_edit
  235.         mcall SF_MOUSE_GET,SSF_BUTTON_EXT
  236.         bt eax,24 ;¤¢®©­®© 饫çñª «¥¢®© ª­®¯ª®©
  237.         jnc @f
  238.                 stdcall [ted_but_select_word], tedit0
  239.                 ret
  240.         @@:
  241.                 stdcall [ted_mouse], tedit0
  242.         .no_edit:
  243.  
  244.         ;¯à®¢¥àª  ¡®ª®¢ëå ¯ ­¥«¥©
  245.         cmp byte[tedit0.panel_id],TED_PANEL_FIND
  246.         jne @f
  247.                 stdcall [edit_box_mouse], edit_find
  248.                 stdcall [option_box_mouse], opt_grlist1
  249.                 stdcall [check_box_mouse], ch1
  250.         @@:
  251.         cmp byte[tedit0.panel_id],TED_PANEL_REPLACE
  252.         jne @f
  253.                 stdcall [edit_box_mouse], edit_find
  254.                 stdcall [edit_box_mouse], edit_replace
  255.                 stdcall [option_box_mouse], opt_grlist1
  256.         @@:
  257.         cmp byte[tedit0.panel_id],TED_PANEL_SYNTAX
  258.         jne @f
  259.                 stdcall [tl_mouse], tree1
  260.         @@:
  261.         cmp byte[tedit0.panel_id],TED_PANEL_GOTO
  262.         jne @f
  263.                 stdcall [edit_box_mouse], edit_goto
  264.         @@:
  265.         ret
  266. ;---------------------------------------------------------------------
  267.  
  268. ;output:
  269. ; ah = symbol
  270. align 16
  271. proc KeyConvertToASCII uses ebx, table:dword
  272.         mov ebx,dword[table] ;convert scan to ascii
  273.         shr ax,8
  274.         add bx,ax
  275.         mov ah,byte[ebx]
  276.         ret
  277. endp
  278.  
  279. align 16
  280. key:
  281.         mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS ;66.3 ¯®«ãç¨âì á®áâ®ï­¨¥ ã¯à ¢«ïîé¨å ª« ¢¨è
  282.         xor esi,esi
  283.         mov ecx,1
  284.         test al,3 ;[Shift]
  285.         jz @f
  286.                 mov cl,2
  287.                 or esi,KM_SHIFT
  288.         @@:
  289.         test al,0x0c ;[Ctrl]
  290.         jz @f
  291.                 or esi,KM_CTRL
  292.         @@:
  293.         test al,0x30 ;[Alt]
  294.         jz @f
  295.                 mov cl,3
  296.                 or esi,KM_ALT
  297.         @@:
  298.         test al,0x80 ;[NumLock]
  299.         jz @f
  300.                 or esi,KM_NUMLOCK
  301.         @@:
  302.  
  303.         mcall SF_SYSTEM_GET,SSF_KEYBOARD_LAYOUT,,conv_tabl ;26.2 ¯®«ãç¨âì à áª« ¤ªã ª« ¢¨ âãàë
  304.         mcall SF_GET_KEY
  305.         stdcall [tl_key], tree1
  306.  
  307.         test word[edit_replace.flags],ed_focus ;¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  308.         je @f
  309.                 cmp ah,0x80 ;if key up
  310.                 ja still
  311.                 cmp ah,42 ;[Shift] (left)
  312.                 je still
  313.                 cmp ah,54 ;[Shift] (right)
  314.                 je still
  315.                 cmp ah,56 ;[Alt]
  316.                 je still
  317.                 cmp ah,29 ;[Ctrl]
  318.                 je still
  319.                 cmp ah,69 ;[Pause Break]
  320.                 je still
  321.  
  322.                 stdcall KeyConvertToASCII, conv_tabl
  323.                 stdcall [edit_box_key], edit_replace
  324.                 jmp still
  325.         @@:
  326.         test word[edit_find.flags],ed_focus ;¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  327.         je @f
  328.                 cmp ah,0x80 ;if key up
  329.                 ja still
  330.                 cmp ah,42 ;[Shift] (left)
  331.                 je still
  332.                 cmp ah,54 ;[Shift] (right)
  333.                 je still
  334.                 cmp ah,56 ;[Alt]
  335.                 je still
  336.                 cmp ah,29 ;[Ctrl]
  337.                 je still
  338.                 cmp ah,69 ;[Pause Break]
  339.                 je still
  340.  
  341.                 stdcall KeyConvertToASCII, conv_tabl
  342.                 stdcall [edit_box_key], edit_find
  343.                 jmp still
  344.         @@:
  345.         test word[edit_goto.flags],ed_focus ;¥á«¨ ­¥ ¢ 䮪ãá¥, ¢ë室¨¬
  346.         je @f
  347.                 cmp ah,0x80 ;if key up
  348.                 ja still
  349.                 cmp ah,42 ;[Shift] (left)
  350.                 je still
  351.                 cmp ah,54 ;[Shift] (right)
  352.                 je still
  353.                 cmp ah,56 ;[Alt]
  354.                 je still
  355.                 cmp ah,29 ;[Ctrl]
  356.                 je still
  357.                 cmp ah,69 ;[Pause Break]
  358.                 je still
  359.  
  360.                 stdcall KeyConvertToASCII, conv_tabl
  361.                 stdcall [edit_box_key], edit_goto
  362.                 jmp still
  363.         @@:
  364.  
  365.         stdcall [ted_key], tedit0, conv_tabl,esi
  366.         jmp still
  367.  
  368. align 4
  369. edit_replace edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_replace, mouse_dd, 0
  370. edit_find edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 300, buf_find, mouse_dd, 0
  371. edit_goto edit_box TED_PANEL_WIDTH-1, 0, 20, 0xffffff, 0xff80, 0xff0000, 0xff, 0x4080, 10, buf_goto, mouse_dd, 0
  372.  
  373. unpac_mem dd 0
  374.  
  375. ;library structures
  376. l_libs_start:
  377.         lib0 l_libs lib_name_0, file_name, system_dir_0, import_box_lib
  378.         lib1 l_libs lib_name_1, file_name, system_dir_1, import_msgbox_lib
  379.         lib2 l_libs lib_name_2, file_name, system_dir_2, import_proclib
  380.         lib3 l_libs lib_name_3, file_name, system_dir_3, import_libimg
  381.         lib4 l_libs lib_name_4, file_name, system_dir_4, import_libini
  382.         lib5 l_libs lib_name_5, file_name, system_dir_5, import_libkmenu
  383. load_lib_end:
  384.  
  385. IncludeIGlobals
  386. hed db 'TextEdit '
  387. i_end:
  388.         openfile_path: ;¯®«­ë© ¯ãâì ª ä ©«ã á ª®â®àë¬ ¨¤¥â à ¡®â 
  389.                 rb 4096
  390.         dir_mem rb 32+304*count_of_dir_list_files
  391.         wnd_s_pos: ;¬¥áâ® ¤«ï ­ áâ஥ª áâ à⮢®© ¯®§¨æ¨¨ ®ª­ 
  392.                 rq 1
  393.         last_open_synt_file rb 32 ;¨¬ï ¯®á«¥¤­¥£® ¯®¤ª«î祭­®£® ä ©«  ᨭ⠪á¨á 
  394.         buf rb BUF_SIZE ;¡ãä¥à ¤«ï ª®¯¨à®¢ ­¨ï ¨ ¢áâ ¢ª¨
  395.         buf_find rb 302 ;¡ãä¥à ¤«ï ¯®¨áª  ⥪áâ 
  396.         buf_replace rb 302 ;¡ãä¥à ¤«ï § ¬¥­ë ⥪áâ 
  397.         buf_goto rb 12 ;¡ãä¥à ¤«ï ¯¥à室  ­  áâபã
  398.         sc system_colors
  399. IncludeUGlobals
  400.         align 16
  401.         procinfo process_information
  402.                 rb 1024
  403.         thread:
  404.                 rb 4096
  405. align 16
  406.     thread_coords:
  407.         rb 4096
  408. align 16
  409. stacktop:
  410.         sys_path: ;¯ãâì ®âªã¤  § ¯ãá⨫áï ¨á¯®«­ï¥¬ë© ä ©«
  411.                 rb 4096
  412.         file_name: ;¯ à ¬¥âàë § ¯ã᪠
  413.                 rb 4096
  414.         syntax_path: ;¨¬ï ¯®¤ª«îç ¥¬®£® ä ©«  ᨭ⠪á¨á 
  415.                 rb 4096
  416.         plugin_path:
  417.                 rb 4096
  418.         text_work_area: ;¯ãâì ª ä ©«ã, ª®â®àë© ¯®ª §ë¢ ¥âáï ¢ ®ª­¥
  419.                 rb 4096
  420.         filename_area: ;¨¬ï ä ©«  ¤«ï ¤¨ «®£  ®âªàëâ¨ï/§ ªàëâ¨ï
  421.                 rb 256
  422.         file_info:
  423.                 rb 40
  424. mem:
  425.