Subversion Repositories Kolibri OS

Rev

Rev 1476 | 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.         call draw_window
  156.  
  157.         .no_colors:
  158.         popad
  159.         ret
  160.  
  161. align 4
  162. proc print_color, color:dword
  163.         pushad
  164.         mov eax,dword[color]
  165.  
  166.         mov ebx,eax ;ìåíÿåì ìåñòàìè red è blue
  167.         shr ebx,16
  168.         xchg al,bl
  169.         and eax,0xffff
  170.         and ebx,0xff
  171.         shl ebx,16
  172.         or eax,ebx
  173.  
  174.         ror al,4
  175.         ror eax,8
  176.         ror al,4
  177.         ror eax,8
  178.         ror al,4
  179.         rol eax,16
  180.         mov edi,text_buffer
  181.         mov word[edi],'0x'
  182.         add edi,2
  183.         mov ecx,6
  184.         @@:
  185.                 mov ebx,eax
  186.                 and ebx,0xf
  187.                 cmp bx,9
  188.                 jle .cifra
  189.                         add bx,39
  190.                 .cifra:
  191.                 add bx,48
  192.                 mov byte[edi],bl
  193.                 inc edi
  194.                 shr eax,4
  195.         loop @b
  196.         mov byte[edi],13
  197.         mov ebx,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  198.         stdcall [ted_text_add], tedit0,text_buffer,9,ebx
  199.         popad
  200.         ret
  201. endp
  202.  
  203. align 4
  204. proc print_capt, capt:dword
  205.         pushad
  206.         mov esi,dword[capt]
  207.         stdcall str_len,esi
  208.         stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  209.         popad
  210.         ret
  211. endp
  212.  
  213. align 4
  214. proc print_word, text:dword, index:dword
  215.         pushad
  216.         mov esi,text_buffer
  217.         mov byte[esi],0
  218.         stdcall str_cat,esi,capt_beg_word
  219.         stdcall str_len,esi
  220.         add esi,eax
  221.  
  222.         mov edi,dword[text]    
  223.         stdcall code_string,edi,esi ;êîäèðóåì ñòðîêó ñ êëþ÷åâûì ñëîâîì
  224.         stdcall str_cat,esi,capt_end_word
  225.  
  226.         cmp dword[edi+MAX_COLOR_WORD_LEN],0 ;f1
  227.         je @f
  228.                 stdcall str_cat,esi,capt_calc_f1
  229.                 stdcall str_cat_value,esi,[index]
  230.                 stdcall str_cat,esi,capt_lbl_f1_use
  231.                 jmp .end_f1_calc
  232.         @@:
  233.                 stdcall str_cat,esi,capt_null
  234.         .end_f1_calc:
  235.  
  236.         mov esi,text_buffer
  237.         stdcall str_len,esi ;óçíàåì äëèííó âñåé ñòðîêè
  238.         stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_change_time+ted_opt_ed_move_cursor
  239.  
  240. mov ecx,edi
  241. mov edi,text_buffer
  242. mov byte[edi],','
  243. inc edi
  244. mov byte[edi],0
  245.         xor eax,eax
  246.         mov al,byte[ecx+MAX_COLOR_WORD_LEN+4] ;wwo
  247.         stdcall str_cat_value,edi,eax
  248.         stdcall str_len,edi
  249.         add edi,eax
  250.         mov byte[edi],','
  251.         inc edi
  252.  
  253.         xor eax,eax
  254.         mov al,byte[ecx+MAX_COLOR_WORD_LEN+4+1] ;endc
  255.         cmp al,0
  256.         je @f
  257.                 stdcall str_cat_value,edi,eax
  258.                 stdcall str_len,edi
  259.                 add edi,eax
  260.         @@:
  261.         mov byte[edi],','
  262.         inc edi
  263.  
  264.         xor eax,eax
  265.         mov al,byte[ecx+MAX_COLOR_WORD_LEN+4+2] ;color
  266.         stdcall str_cat_value,edi,eax
  267.         stdcall str_len,edi
  268.         add edi,eax
  269.         mov byte[edi],13
  270.         inc edi
  271.         mov byte[edi],0
  272.  
  273.         mov esi,text_buffer
  274.         stdcall str_len,esi
  275.         stdcall [ted_text_add], tedit0,esi,eax,ted_opt_ed_move_cursor
  276.  
  277.         popad
  278.         ret
  279. endp
  280.  
  281. align 4
  282. proc print_word_f1, text:dword, index:dword
  283.         pushad
  284.         mov edi,dword[text]
  285.         mov esi,dword[edi+MAX_COLOR_WORD_LEN] ;f1
  286.         cmp esi,0
  287.         je @f
  288.                 mov ebx,text_buffer
  289.                 mov byte[ebx],0
  290.                 stdcall str_cat,ebx,capt_point
  291.                 stdcall str_cat_value,ebx,[index]
  292.                 stdcall str_cat,ebx,capt_beg_db
  293.                 stdcall str_len,ebx
  294.                 add ebx,eax
  295.                
  296.                 add esi,dword[tex_help_f1]
  297.                 stdcall code_string,esi,ebx ;êîäèðóåì ñòðîêó
  298.                 stdcall str_cat,ebx,capt_end_word_f1
  299.  
  300.                 mov ebx,text_buffer
  301.                 stdcall str_len,ebx
  302.                 stdcall [ted_text_add], tedit0,ebx,eax,ted_opt_ed_move_cursor
  303.         @@:
  304.         popad
  305.         ret
  306. endp
  307.  
  308. align 4
  309. proc code_string, text:dword, out_text:dword
  310.         pushad
  311.         mov esi,dword[text]
  312.         stdcall str_len,esi
  313.         mov ecx,eax
  314.         mov edi,dword[out_text]
  315.  
  316.         .copy:
  317.                 mov al,byte[esi]
  318.                 inc esi
  319.                 cmp al,9
  320.                 je @f
  321.                 cmp al,13
  322.                 je @f
  323.                 cmp al,39
  324.                 je @f
  325.                         mov byte[edi],al
  326.                         inc edi
  327.                         loop .copy
  328.                         jmp .end_copy
  329.                 @@:
  330.                         mov byte[edi],39
  331.                         mov byte[edi+1],','
  332.                         add edi,2
  333.                         and eax,0xff
  334.                         mov dword[edi],0
  335.                         call tl_convert_to_str
  336.                         stdcall str_len,edi
  337.                         add edi,eax
  338.                         mov byte[edi],','
  339.                         mov byte[edi+1],39
  340.                         add edi,2
  341.         loop .copy
  342.         .end_copy:
  343.         mov byte[edi],0
  344.         popad
  345.         ret
  346. endp
  347.  
  348. align 4
  349. proc mem_clear, mem:dword, len:dword
  350.         push eax ecx edi
  351.         cld
  352.         xor al,al
  353.         mov edi, dword[mem]
  354.         mov ecx, dword[len]
  355.         repne stosb
  356.         pop edi ecx eax
  357.         ret
  358. endp
  359.  
  360. align 4
  361. proc str_cat, str1:dword, str2:dword
  362.         push eax ecx edi esi
  363.         mov esi,dword[str2]
  364.         stdcall str_len,esi
  365.         mov ecx,eax
  366.         inc ecx
  367.         mov edi,dword[str1]
  368.         stdcall str_len,edi
  369.         add edi,eax
  370.         cld
  371.         repne movsb
  372.         pop esi edi ecx eax
  373.         ret
  374. endp
  375.  
  376. align 4
  377. proc str_cat_value, str1:dword, value:dword
  378.         pushad
  379.         mov edi,[str1]
  380.         stdcall str_len,edi
  381.         add edi,eax
  382.         mov eax,[value]
  383.         call tl_convert_to_str
  384.         popad
  385.         ret
  386. endp
  387.  
  388. ;output:
  389. ; eax = strlen
  390. align 4
  391. proc str_len, str1:dword
  392.         mov eax,[str1]
  393.         @@:
  394.                 cmp byte[eax],0
  395.                 je @f
  396.                 inc eax
  397.                 jmp @b
  398.         @@:
  399.         sub eax,[str1]
  400.         ret
  401. endp
  402.  
  403. ;input:
  404. ; eax = value
  405. ; edi = string buffer
  406. align 4
  407. tl_convert_to_str:
  408.         pushad
  409.         stdcall mem_clear,edi,12
  410.         call .str
  411.         popad
  412.         ret
  413.  
  414. align 4
  415. .str:
  416.         mov ecx,0x0a ;çàäàåòñÿ ñèñòåìà ñ÷èñëåíèÿ èçìåíÿþòñÿ ðåãèñòðû ebx,eax,ecx,edx âõîäíûå ïàðàìåòðû eax - ÷èñëî
  417.                 ;ïðåðåâîä ÷èñëà â ASCII ñòðîêó âõîäíûå äàííûå ecx=ñèñòåìà ñ÷èñëåíÿ edi àäðåñ êóäà çàïèñûâàòü, áóäåì ñòðîêó, ïðè÷åì êîíåö ïåðåìåííîé
  418.         cmp eax,ecx  ;ñðàâíèòü åñëè â eax ìåíüøå ÷åì â ecx òî ïåðåéòè íà @@-1 ò.å. íà pop eax
  419.         jb @f
  420.                 xor edx,edx ;î÷èñòèòü edx
  421.                 div ecx     ;ðàçäåëèòü - îñòàòîê â edx
  422.                 push edx    ;ïîëîæèòü â ñòåê
  423.                 ;dec edi    ;ñìåùåíèå íåîáõîäèìîå äëÿ çàïèñè ñ êîíöà ñòðîêè
  424.                 call .str   ;ïåðåéòè íà ñàìó ñåáÿ ò.å. âûçâàòü ñàìó ñåáÿ è òàê äî òîãî ìîìåíòà ïîêà â eax íå ñòàíåò ìåíüøå ÷åì â ecx
  425.                 pop eax
  426.         @@: ;cmp al,10 ;ïðîâåðèòü íå ìåíüøå ëè çíà÷åíèå â al ÷åì 10 (äëÿ ñèñòåìû ñ÷èñëåíÿ 10 äàííàÿ êîìàíäà - ëèøíàÿ))
  427.         or al,0x30  ;äàííàÿ êîìàíäà êîðî÷å  ÷åì äâå âûøå
  428.         stosb       ;çàïèñàòü ýëåìåíò èç ðåãèñòðà al â ÿ÷åêó ïàìÿòè es:edi
  429.         ret
  430.