By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,956 Members | 1,657 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,956 IT Pros & Developers. It's quick & easy.

Borland Builder c++ faster syntax highlighting??

P: n/a
Hi,I have a question about syntax highlighting. I wrote on Borland Builder c++ and The code works correct. But ,when ı write so many codes on RichEdit,The computer gets slow,and The special codes are colored later, and I can not write perfectly on RichEdit anymore. Because,computer gets slow. What can ı do.I share the codes below. Please answer...




Expand|Select|Wrap|Line Numbers
  1. void __fastcall TForm1::Timer1Timer(TObject *Sender){
  2. ::SendMessage(RichEdit1->Handle, WM_SETREDRAW, false, 0);
  3. int sp = RichEdit1->SelStart;
  4.  
  5. RichEdit1->SelectAll();
  6. RichEdit1->SelAttributes->Color=clBlack;
  7. RichEdit1->SelAttributes->Style=first;
  8.  
  9. String dizi[]={"abstract","do","if","package","synchronized",
  10.                "boolean","double","implements","private","this","break","else","import","protected","throw",
  11.                "byte","extends","instanceof","public","throws","case","false","int","return","transient",
  12.                "catch","final","interface","short","true","char","finally","long","static","try",
  13.                "class","float","native","strictfp","void","const","for","new","super","volatile",
  14.                "continue","goto","null","switch","while","default","assert","String"
  15.  
  16.                };
  17. int sonuc,uzunluk;
  18. String x;
  19. TSearchTypes secenek;
  20. uzunluk=RichEdit1->Text.Length();
  21. secenek=secenek<<stWholeWord;
  22. for(int i=0;i<54;i++){
  23. sonuc=0;
  24.  
  25. a:
  26.  
  27.  sonuc=RichEdit1->FindTextA(dizi[i],sonuc,uzunluk,secenek);
  28.  if(sonuc!=-1){//1.
  29.         RichEdit1->SelStart=sonuc;
  30.         RichEdit1->SelLength=dizi[i].Length();
  31.  
  32.                 if(RichEdit1->SelText==dizi[i])  {
  33.                      RichEdit1->SelAttributes->Style=RichEdit1->SelAttributes->Style<<fsBold;
  34.                      RichEdit1->SelAttributes->Color=clMaroon;
  35.                                                  }
  36.                    else RichEdit1->SelAttributes->Color=clBlack;
  37.                      sonuc=RichEdit1->SelStart+RichEdit1->SelLength;
  38.                      goto a;
  39.  
  40.              }//sonuc!=-1 condition end
  41.  
  42.  
  43.                       }//for loop end
  44.  
  45.  
  46.  
  47.  
  48.  RichEdit1->SelStart = sp;
  49.  
  50.  ::SendMessage(RichEdit1->Handle, WM_SETREDRAW, true, 0);
  51.   RichEdit1->Repaint();
  52.  
  53.  
  54.  
  55.  
  56.  ::SendMessage(RichEdit1->Handle, WM_SETREDRAW, false, 0);
  57.  sp = RichEdit1->SelStart;
  58.  
  59.  
  60. ::SendMessage(RichEdit1->Handle, WM_SETREDRAW, false, 0);
  61. String dizi2[]={"//","/*","*/","\"","\"","\'","\'"};
  62.  
  63.  
  64.  
  65. uzunluk=RichEdit1->Text.Length();
  66. secenek=secenek>>stWholeWord;
  67. secenek=secenek<<stMatchCase;
  68. for(int i=0;i<7;i++){
  69. sonuc=0;
  70.  
  71. b:
  72.  
  73.  sonuc=RichEdit1->FindTextA(dizi2[i],sonuc,uzunluk,secenek);
  74.  if(sonuc!=-1){//1.
  75.  
  76.            if(i==0){
  77.  RichEdit1->SelStart=sonuc;
  78.  RichEdit1->SelLength=RichEdit1->Lines->Strings[RichEdit1->CaretPos.y].Length()-RichEdit1->CaretPos.x;
  79.  
  80.  RichEdit1->SelAttributes->Style=RichEdit1->SelAttributes->Style<<fsItalic;
  81.  RichEdit1->SelAttributes->Color=clGreen;
  82.                     }
  83.      else  if(i==1){
  84.  RichEdit1->SelStart=sonuc;
  85.  int temp=RichEdit1->FindTextA("*/",sonuc+2,uzunluk,secenek);
  86.  
  87.  RichEdit1->SelLength=temp-sonuc;
  88. RichEdit1->SelAttributes->Style=RichEdit1->SelAttributes->Style<<fsItalic;
  89.  RichEdit1->SelAttributes->Color=clGreen;
  90.  
  91.                  }
  92.  else if(i==2){
  93.  RichEdit1->SelStart=sonuc;
  94.  RichEdit1->SelLength=dizi2[i].Length();
  95.     RichEdit1->SelAttributes->Style=RichEdit1->SelAttributes->Style<<fsItalic;
  96.  RichEdit1->SelAttributes->Color=clGreen;
  97.              }
  98.  else if(i==3){
  99.  
  100.  RichEdit1->SelStart=sonuc;
  101.  int temp=RichEdit1->FindTextA("\"",sonuc+1,uzunluk,secenek);
  102.  RichEdit1->SelLength=temp-sonuc;
  103.   RichEdit1->SelAttributes->Style=RichEdit1->SelAttributes->Style<<fsBold;
  104.  RichEdit1->SelAttributes->Color=clBlue;
  105.  if(temp!=-1){
  106.   RichEdit1->SelStart=temp+1;
  107.   RichEdit1->SelLength=0;
  108.   RichEdit1->SelAttributes->Color=clBlack;
  109.              }
  110.  
  111.                }
  112.   else if(i==4){
  113.  RichEdit1->SelStart=sonuc;
  114.  RichEdit1->SelLength=dizi2[i].Length();
  115.     RichEdit1->SelAttributes->Style=RichEdit1->SelAttributes->Style<<fsBold;
  116.  RichEdit1->SelAttributes->Color=clBlue;
  117.  
  118.                 }
  119.  else if(i==5) {
  120.     RichEdit1->SelStart=sonuc;
  121.  int temp=RichEdit1->FindTextA("\'",sonuc+1,uzunluk,secenek);
  122.  RichEdit1->SelLength=temp-sonuc;
  123.   RichEdit1->SelAttributes->Style=RichEdit1->SelAttributes->Style<<fsBold;
  124.  RichEdit1->SelAttributes->Color=clBlue;
  125.  if(temp!=-1){
  126.   RichEdit1->SelStart=temp+1;
  127.   RichEdit1->SelLength=0;
  128.   RichEdit1->SelAttributes->Color=clBlack;
  129.                }
  130.  
  131.                    }
  132.      else if(i==6){
  133.  RichEdit1->SelStart=sonuc;
  134.  RichEdit1->SelLength=dizi2[i].Length();
  135.     RichEdit1->SelAttributes->Style=RichEdit1->SelAttributes->Style<<fsBold;
  136.  RichEdit1->SelAttributes->Color=clBlue;
  137.  
  138.                 }
  139.  
  140.  
  141.                   else RichEdit1->SelAttributes->Color=clBlack;
  142.                      sonuc=RichEdit1->SelStart+RichEdit1->SelLength;
  143.                      goto b;
  144.  
  145.              }//sonuc!=-1 condition end
  146.  
  147.  
  148.                       }//for loop end
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.   RichEdit1->SelStart = sp;
  156.  
  157. ::SendMessage(RichEdit1->Handle, WM_SETREDRAW, true, 0);
  158.  RichEdit1->Repaint();
  159.   RichEdit1->SetFocus();
  160.   //finish
  161.  
  162. }
  163.  
Oct 10 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.