Subversion Repositories Kolibri OS

Rev

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