Subversion Repositories Kolibri OS

Rev

Rev 2159 | Rev 7575 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. struct FileInfoBlock
  2.         Function dd ?
  3.         Position dd ?
  4.         Flags    dd ?
  5.         Count    dd ?
  6.         Buffer   dd ?
  7.                 db ?
  8.         FileName dd ?
  9. ends
  10.  
  11. struct TexColViv
  12.         Text  rb MAX_COLOR_WORD_LEN ; ñëîâî äëÿ ïîäñâåòêè
  13.         f1    dd 0 ; ñïðàâêà ïî ñëîâó
  14.         flags db ? ; f1+4 ôëàãè èñïîëüçóåìûå ïðè âûäåëåíèè
  15.         endc  db ? ; f1+5 ñèìâîë êîíöà âûäåëåíèÿ (èñïîëüçóåòñÿ ïðè flags&4)
  16.         escc  db ? ; f1+6 ýêðàíèðóþùèé ñèìâîë (èñïîëüçóåòñÿ ïðè flags&4)
  17.         color db ? ; f1+7 íîìåð öâåòà
  18. ends
  19.  
  20. count_colors_text dd 1
  21. ColWords dd 0
  22. color_cursor dd ?
  23. color_wnd_capt dd ?
  24. color_wnd_work dd ?
  25. color_wnd_bord dd ?
  26. color_select dd ?
  27. color_cur_text dd ?
  28. color_wnd_text dd ?
  29.  
  30. options_file dd 0
  31. options_file_end dd 0
  32. tex_colors dd 0
  33. tex_help_f1 dd 0
  34.  
  35. Col dd 0 ;óêàçàòåëü íà ñòðóêòóðû êëþ÷åâûõ ñëîâ TexColViv
  36.  
  37. keyUpr dd 0
  38. err_opn db 0 ;îøèáêà îòêðûòèÿ ôàéëà
  39. err_sav db 0 ;îøèáêà ñîõðàíåíèÿ ôàéëà
  40.  
  41. sc system_colors
  42.  
  43. run_file_70 FileInfoBlock
  44.  
  45. align 4
  46. InitColText:
  47.         pushad
  48.  
  49.         mov  ebx,dword[fn_col_option]
  50.         copy_path ebx,fn_syntax_dir,file_name_rez,0
  51.         copy_path file_name_rez,sys_path,file_name,0
  52.  
  53.         mov eax,70
  54.         mov [run_file_70.Function], 0
  55.         mov [run_file_70.Position], 0
  56.         mov [run_file_70.Flags], 0
  57.         mov ebx,[options_file_end]
  58.         sub ebx,[options_file]
  59.         mov [run_file_70.Count], ebx
  60.         m2m [run_file_70.Buffer], [options_file]
  61.         mov byte[run_file_70+20], 0
  62.         mov [run_file_70.FileName], file_name
  63.         mov ebx,run_file_70
  64.         int 0x40
  65.  
  66.  
  67.         ;init: count_colors_text, ColWords, ...
  68.         mov dword[count_colors_text],1
  69.         mov dword[ColWords],0
  70.         mov dword[tex_help_f1],0
  71.  
  72.         cmp eax,6
  73.         je @f
  74.         cmp eax,0
  75.         je @f
  76.                 cmp ax,10
  77.                 jl .zifra_0_9
  78.                         mov al,'?'
  79.                         sub ax,48
  80.                 .zifra_0_9:
  81.                 add ax,48
  82.                 jmp .no_colors
  83.         @@:
  84.  
  85.         mov esi,[options_file]
  86.         cmp dword[esi],'KPCK'
  87.         jne @f
  88.                 notify_window_run txt_no_kpack ; ñîçäàåì îêíî @notify
  89.                 jmp .no_colors
  90.         @@:
  91.         mov edi,count_colors_text
  92.         mov ecx,9*4
  93.         rep movsb
  94.  
  95.         mov eax,[options_file]
  96.         add eax,32
  97.         mov dword[tex_colors],eax
  98.  
  99.         mov eax,dword[count_colors_text] ;init: Col (offset to key words)
  100.         add eax,8
  101.         shl eax,2
  102.         add eax,[options_file]
  103.         mov dword[Col],eax
  104.  
  105.         ;init: tex_help_f1
  106.         mov ecx,dword[ColWords]
  107.         imul ecx,sizeof.TexColViv
  108.         add ecx,dword[Col]
  109.         mov dword[tex_help_f1],ecx
  110.  
  111.         ;ôîðìèðîâàíèå òåêñòà â îêíå òåêñòîâîãî ðåäàêòîðà
  112.         stdcall [ted_clear], tedit0,1
  113.  
  114.         stdcall print_capt,capt_header
  115.  
  116.         stdcall print_capt,col_1
  117.         stdcall print_color,[color_cursor]
  118.         stdcall print_capt,col_2
  119.         stdcall print_color,[color_wnd_capt]
  120.         stdcall print_capt,col_3
  121.         stdcall print_color,[color_wnd_work]
  122.         stdcall print_capt,col_4
  123.         stdcall print_color,[color_wnd_bord]
  124.         stdcall print_capt,col_5
  125.         stdcall print_color,[color_select]
  126.         stdcall print_capt,col_6
  127.         stdcall print_color,[color_cur_text]
  128.  
  129.         stdcall print_capt,col_7
  130.         mov ecx,[count_colors_text] ;êîëè÷åñòâî öâåòîâ òåêñòà
  131.         mov eax,[tex_colors]
  132.         @@:
  133.                 stdcall print_capt,capt_type_dd
  134.                 stdcall print_color,[eax]
  135.                 add eax,4
  136.         loop @b
  137.  
  138.         stdcall print_capt,capt_lbl_wo
  139.         mov ecx,dword[ColWords]
  140.         mov eax,[Col]
  141.         xor ebx,ebx
  142.         @@:
  143.                 inc ebx
  144.                 stdcall print_word,eax,ebx
  145.                 add eax,sizeof.TexColViv
  146.         loop @b
  147.  
  148.         stdcall print_capt,capt_lbl_f1
  149.         mov ecx,dword[ColWords]
  150.         mov eax,[Col]
  151.         xor ebx,ebx
  152.         @@:
  153.                 inc ebx
  154.                 stdcall print_word_f1,eax,ebx
  155.                 add eax,sizeof.TexColViv
  156.         loop @b
  157.        
  158.         ; ïîäãîòîâêà äëÿ  PathShow
  159.         push dword PathShow_data_1
  160.         call [PathShow_prepare]
  161.         call draw_window
  162.  
  163.         .no_colors:
  164.         popad
  165.         ret
  166.  
  167. align 4
  168. proc print_color, color:dword
  169.         pushad
  170.         mov eax,dword[color]
  171.  
  172.         mov ebx,eax ;ìåíÿåì ìåñòàìè red è blue
  173.         shr ebx,16
  174.         xchg al,bl
  175.         and eax,0xffff
  176.         and ebx,0xff
  177.         shl ebx,16
  178.         or eax,ebx
  179.  
  180.         ror al,4
  181.         ror eax,8
  182.         ror al,4
  183.         ror eax,8
  184.         ror al,4
  185.         rol eax,16
  186.         mov edi,text_buffer
  187.         mov word[edi],'0x'
  188.         add edi,2
  189.         mov ecx,6
  190.         @@:
  191.                 mov ebx,eax
  192.                 and ebx,0xf
  193.                 cmp bx,9
  194.                 jle .cifra
  195.                         add bx,39
  196.                 .cifra:
  197.                 add bx,48
  198.                 mov byte[edi],bl
  199.                 inc edi
  200.                 shr eax,4
  201.         loop @b
  202.         mov byte[edi],13
  203.         mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  204.         stdcall [ted_text_add], tedit0,text_buffer,9,ebx
  205.         popad
  206.         ret
  207. endp
  208.  
  209. align 4
  210. proc print_capt, capt:dword
  211.         pushad
  212.         mov esi,dword[capt]
  213.         stdcall str_len,esi
  214.         stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  215.         popad
  216.         ret
  217. endp
  218.  
  219. align 4
  220. proc print_word, text:dword, index:dword
  221.         pushad
  222.         mov esi,text_buffer
  223.         mov byte[esi],0
  224.         stdcall str_cat,esi,capt_beg_word
  225.         stdcall str_len,esi
  226.         add esi,eax
  227.  
  228.         mov edi,dword[text]    
  229.         stdcall code_string,edi,esi ;êîäèðóåì ñòðîêó ñ êëþ÷åâûì ñëîâîì
  230.         stdcall str_cat,esi,capt_end_word
  231.  
  232.         cmp dword[edi+MAX_COLOR_WORD_LEN],0 ;f1
  233.         je @f
  234.                 stdcall str_cat,esi,capt_calc_f1
  235.                 stdcall str_cat_value,esi,[index]
  236.                 stdcall str_cat,esi,capt_lbl_f1_use
  237.         @@:
  238.  
  239.         mov esi,text_buffer
  240.         stdcall str_len,esi ;óçíàåì äëèííó âñåé ñòðîêè
  241.         stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  242.  
  243. mov ecx,edi
  244. mov edi,text_buffer
  245. mov byte[edi],','
  246. inc edi
  247. mov byte[edi],0
  248.         xor eax,eax
  249.         mov al,byte[ecx+MAX_COLOR_WORD_LEN+4] ;wwo
  250.         stdcall str_cat_value,edi,eax
  251.         stdcall str_len,edi
  252.         add edi,eax
  253.         mov byte[edi],','
  254.         inc edi
  255.  
  256.         xor eax,eax
  257.         mov ax,word[ecx+MAX_COLOR_WORD_LEN+4+1] ;(escc shl 8)+endc
  258.         cmp ax,0 ;ïðîâåðÿåì åñòü ëè çàâåðøàþùèé è ýêðàíèíóþùèé ñèìâîë
  259.         je @f
  260.                 stdcall str_cat_value,edi,eax
  261.                 stdcall str_len,edi
  262.                 add edi,eax
  263.         @@:
  264.         mov byte[edi],','
  265.         inc edi
  266.  
  267.         xor eax,eax
  268.         mov al,byte[ecx+MAX_COLOR_WORD_LEN+4+3] ;color
  269.         stdcall str_cat_value,edi,eax
  270.         stdcall str_len,edi
  271.         add edi,eax
  272.         mov byte[edi],13
  273.         inc edi
  274.         mov byte[edi],0
  275.  
  276.         mov esi,text_buffer
  277.         stdcall str_len,esi
  278.         stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_move_cursor
  279.  
  280.         popad
  281.         ret
  282. endp
  283.  
  284. align 4
  285. proc print_word_f1, text:dword, index:dword
  286.         pushad
  287.         mov edi,dword[text]
  288.         mov esi,dword[edi+MAX_COLOR_WORD_LEN] ;f1
  289.         cmp esi,0
  290.         je @f
  291.                 mov ebx,text_buffer
  292.                 mov byte[ebx],0
  293.                 stdcall str_cat,ebx,capt_point
  294.                 stdcall str_cat_value,ebx,[index]
  295.                 stdcall str_cat,ebx,capt_beg_db
  296.                 stdcall str_len,ebx
  297.                 add ebx,eax
  298.                
  299.                 add esi,dword[tex_help_f1]
  300.                 stdcall code_string,esi,ebx ;êîäèðóåì ñòðîêó
  301.                 stdcall str_cat,ebx,capt_end_word_f1
  302.  
  303.                 mov ebx,text_buffer
  304.                 stdcall str_len,ebx
  305.                 stdcall [ted_text_add], tedit0,ebx,eax,ted_opt_ed_move_cursor
  306.         @@:
  307.         popad
  308.         ret
  309. endp
  310.  
  311. align 4
  312. proc code_string, text:dword, out_text:dword
  313.         pushad
  314.         mov esi,dword[text]
  315.         stdcall str_len,esi
  316.         mov ecx,eax
  317.         mov edi,dword[out_text]
  318.  
  319.         .copy:
  320.                 mov al,byte[esi]
  321.                 inc esi
  322.                 cmp al,9
  323.                 je @f
  324.                 cmp al,13
  325.                 je @f
  326.                 cmp al,39
  327.                 je @f
  328.                         mov byte[edi],al
  329.                         inc edi
  330.                         loop .copy
  331.                         jmp .end_copy
  332.                 @@:
  333.                         mov byte[edi],39
  334.                         mov byte[edi+1],','
  335.                         add edi,2
  336.                         and eax,0xff
  337.                         mov dword[edi],0
  338.                         call tl_convert_to_str
  339.                         stdcall str_len,edi
  340.                         add edi,eax
  341.                         mov byte[edi],','
  342.                         mov byte[edi+1],39
  343.                         add edi,2
  344.         loop .copy
  345.         .end_copy:
  346.         mov byte[edi],0
  347.         popad
  348.         ret
  349. endp
  350.  
  351. align 4
  352. proc mem_clear, mem:dword, len:dword
  353.         push eax ecx edi
  354.         cld
  355.         xor al,al
  356.         mov edi, dword[mem]
  357.         mov ecx, dword[len]
  358.         repne stosb
  359.         pop edi ecx eax
  360.         ret
  361. endp
  362.  
  363. align 4
  364. proc str_cat, str1:dword, str2:dword
  365.         push eax ecx edi esi
  366.         mov esi,dword[str2]
  367.         stdcall str_len,esi
  368.         mov ecx,eax
  369.         inc ecx
  370.         mov edi,dword[str1]
  371.         stdcall str_len,edi
  372.         add edi,eax
  373.         cld
  374.         repne movsb
  375.         pop esi edi ecx eax
  376.         ret
  377. endp
  378.  
  379. align 4
  380. proc str_cat_value, str1:dword, value:dword
  381.         pushad
  382.         mov edi,[str1]
  383.         stdcall str_len,edi
  384.         add edi,eax
  385.         mov eax,[value]
  386.         call tl_convert_to_str
  387.         popad
  388.         ret
  389. endp
  390.  
  391. ;output:
  392. ; eax = strlen
  393. align 4
  394. proc str_len, str1:dword
  395.         mov eax,[str1]
  396.         @@:
  397.                 cmp byte[eax],0
  398.                 je @f
  399.                 inc eax
  400.                 jmp @b
  401.         @@:
  402.         sub eax,[str1]
  403.         ret
  404. endp
  405.  
  406. ;input:
  407. ; eax = value
  408. ; edi = string buffer
  409. align 4
  410. tl_convert_to_str:
  411.         pushad
  412.         stdcall mem_clear,edi,12
  413.         call .str
  414.         popad
  415.         ret
  416.  
  417. align 4
  418. .str:
  419.         mov ecx,0x0a ;çàäàåòñÿ ñèñòåìà ñ÷èñëåíèÿ èçìåíÿþòñÿ ðåãèñòðû ebx,eax,ecx,edx âõîäíûå ïàðàìåòðû eax - ÷èñëî
  420.                 ;ïðåðåâîä ÷èñëà â ASCII ñòðîêó âõîäíûå äàííûå ecx=ñèñòåìà ñ÷èñëåíÿ edi àäðåñ êóäà çàïèñûâàòü, áóäåì ñòðîêó, ïðè÷åì êîíåö ïåðåìåííîé
  421.         cmp eax,ecx  ;ñðàâíèòü åñëè â eax ìåíüøå ÷åì â ecx òî ïåðåéòè íà @@-1 ò.å. íà pop eax
  422.         jb @f
  423.                 xor edx,edx ;î÷èñòèòü edx
  424.                 div ecx     ;ðàçäåëèòü - îñòàòîê â edx
  425.                 push edx    ;ïîëîæèòü â ñòåê
  426.                 ;dec edi    ;ñìåùåíèå íåîáõîäèìîå äëÿ çàïèñè ñ êîíöà ñòðîêè
  427.                 call .str   ;ïåðåéòè íà ñàìó ñåáÿ ò.å. âûçâàòü ñàìó ñåáÿ è òàê äî òîãî ìîìåíòà ïîêà â eax íå ñòàíåò ìåíüøå ÷åì â ecx
  428.                 pop eax
  429.         @@: ;cmp al,10 ;ïðîâåðèòü íå ìåíüøå ëè çíà÷åíèå â al ÷åì 10 (äëÿ ñèñòåìû ñ÷èñëåíÿ 10 äàííàÿ êîìàíäà - ëèøíàÿ))
  430.         or al,0x30  ;äàííàÿ êîìàíäà êîðî÷å  ÷åì äâå âûøå
  431.         stosb       ;çàïèñàòü ýëåìåíò èç ðåãèñòðà al â ÿ÷åêó ïàìÿòè es:edi
  432.         ret
  433.