root/trunk/ElephantView.cpp

Revision 5, 59.8 kB (checked in by qbert, 6 years ago)

Initial ( and last :( ) commit

Line 
1 // ElephantView.cpp : implementation of the CElephantView class
2 //
3
4
5
6 #include "stdafx.h"
7 #include "Elephant.h"
8
9 #include "ElephantDoc.h"
10 #include "ElephantView.h"
11 #include "CodeBrowsingDlg.h"
12 #include "rdragdropfiles.h"
13 #include <Scilexer.h>
14
15
16 #ifdef _DEBUG
17 #define new DEBUG_NEW
18 #undef THIS_FILE
19 static char THIS_FILE[] = __FILE__;
20 #endif
21
22 /////////////////////////////////////////////////////////////////////////////
23 // CElephantView
24
25 IMPLEMENT_DYNCREATE(CElephantView, CScintillaView)
26
27 BEGIN_MESSAGE_MAP(CElephantView, CScintillaView)
28 //{{AFX_MSG_MAP(CElephantView)
29 ON_WM_CONTEXTMENU() 
30     ON_WM_DESTROY()
31     //}}AFX_MSG_MAP
32 // Standard printing commands
33 ON_WM_DROPFILES()
34 ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
35 ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
36 ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
37
38 END_MESSAGE_MAP()
39
40
41
42 void dumpFileParser()
43 {
44    
45    
46 }
47
48 bool IsWordBreak(char ch)
49 {
50     if ( ch == '.' || ch == ' ' || ch == '\t' || ch == ')' || ch == '('
51         || ch == '*' || ch == '+' || ch == '-' || ch == '/' || ch == '&'
52         || ch == ']' || ch == '[' || ch == '}' || ch == '\r' || ch == '\n'
53         || ch == ',' || ch == '=' || ch == ';' || ch == '!' ) return true;
54     return false;
55 }
56
57
58 bool isInSkipCalltip ( const string& word )
59 {
60    
61     if ( word == "if" )  return true;
62     return false;
63    
64 }
65
66 void  StripClassForAutoComplete( string& s)
67 {
68    
69     unsigned long pos = s.find_first_of('(');
70     s = s.substr(0,pos);
71     strip(s);
72     return;
73 }
74 string parseListingsAndKeywordsForDisplay(vector<SymbolListing*> & listings ,vector<string> & matches)
75 {
76     vector<string> uniques;
77     int i = 0 ;
78     for ( i = 0 ; i < listings.size(); i++ )
79     {
80        
81         if ( std::find(uniques.begin(), uniques.end() ,listings[i]->name ) != uniques.end() )  continue;
82         else uniques.push_back(listings[i]->name );
83     }
84    
85     for ( i = 0 ;i < matches.size(); i++)
86     {
87         if ( std::find(uniques.begin(), uniques.end() ,matches[i] ) != uniques.end() )  continue;
88         else uniques.push_back(matches[i] );
89        
90     }
91    
92    
93    
94     std::sort(uniques.begin(),uniques.end());
95    
96     string ret = Join(uniques," " );   
97     return ret;
98    
99 }
100
101 string parseKeywordsForDisplay(vector<string> & matches)
102 {
103    
104     if ( matches.size() )
105     {
106        
107         std::sort(matches.begin(),matches.end());
108        
109         string list;
110         for ( int i = 0 ;i < matches.size(); i++)
111         {
112             list += matches[i] + " ";
113         }
114        
115         return list.substr(0,list.length() - 1);
116     }
117     else return "";
118 }
119 string parseListingsForDisplay( vector<SymbolListing*> & listings )
120 {
121    
122     //remove duplicates , then return a 'space' seperated string of listings
123    
124     vector<string> uniques;
125     for ( int i = 0 ; i < listings.size(); i++ )
126     {
127         //AfxMessageBox(listings[i]->name.c_str() );
128         if ( std::find(uniques.begin(), uniques.end() ,listings[i]->name ) != uniques.end() )  continue;
129         else uniques.push_back(listings[i]->name );
130     }   
131    
132     std::sort(uniques.begin(),uniques.end());
133     string ret = Join(uniques," " );       
134     return ret;
135    
136 }
137
138 bool CElephantView::LineBeginsWithImport()
139 {
140     CScintillaCtrl &rCtrl = GetCtrl();
141     char text[5000];
142     rCtrl.GetCurLine(5000,text);   
143     if ( strncmp(text,"import",6) == 0 || strncmp(text,"private import",14) == 0
144         || strncmp(text,"public import",13) == 0 || strncmp(text,"protected import",16) == 0 ) return true;
145     return false;
146    
147 }
148
149 bool CElephantView::IsFunctionEnd()
150 {
151     CScintillaCtrl& rCtrl = GetCtrl();
152     int pos = rCtrl.GetCurrentPos() -  2;
153     //char x[10];
154     //sprintf(x,"%c",rCtrl.GetCharAt(pos));
155     //::MessageBox(0,x,"here",0);
156    
157     while ( rCtrl.GetCharAt(pos) == ' ' ) pos--;
158    
159    
160     return rCtrl.GetCharAt(pos) == ')';
161    
162 }
163
164 bool CElephantView::IsArrayEnd()
165 {
166     CScintillaCtrl& rCtrl = GetCtrl();
167     int pos = rCtrl.GetCurrentPos() -  2;
168     //char x[10];
169     //sprintf(x,"%c",rCtrl.GetCharAt(pos));
170     //::MessageBox(0,x,"here",0);
171    
172     while ( rCtrl.GetCharAt(pos) == ' ' ) pos--;
173    
174    
175     return rCtrl.GetCharAt(pos) == ']';
176    
177 }
178
179
180 void CElephantView::SkipOverWhitespace(int & pos)
181 {
182     CScintillaCtrl& rCtrl = GetCtrl();
183     while ( rCtrl.GetCharAt(pos--) == ' ' ) ;
184    
185     pos++;
186 }
187
188 string CElephantView::ReadOverArray()
189 {
190     CScintillaCtrl& rCtrl = GetCtrl();
191    
192    
193     int pos =  rCtrl.GetCurrentPos();
194     string word ;
195     char ch = rCtrl.GetCharAt(--pos);
196    
197     //  char x[10];
198     //  sprintf(x,"%c",rCtrl.GetCharAt(pos));
199     //  ::MessageBox(0,x, "char first",0);
200    
201     while ( rCtrl.GetCharAt(pos--) != '[' )
202     {
203         if ( pos < 0 ) break;
204         continue;
205     }
206    
207     SkipOverWhitespace(pos);
208     //  sprintf(x,"%c",rCtrl.GetCharAt(pos));
209     //  ::MessageBox(0,x, "char",0);
210    
211     ch = rCtrl.GetCharAt(pos);
212    
213     while ( !IsWordBreak(ch ) )
214     {
215         ch = rCtrl.GetCharAt(pos--);
216         //      sprintf(x,"%c &d",ch,pos);
217         //      ::MessageBox(0,x, "char",0);
218         word += ch;
219         if (pos < 0 ) break;
220     }
221     if ( word.length() > 1 )
222         std::reverse(word.begin(),word.end() - 1);
223     else {
224         //ElephantMessageBox(string("return blank " + word) .c_str());
225         return "";
226     }
227    
228     if ( IsWordBreak(word[word.length() - 1] ))
229         word = word.substr(0,word.length() - 1) ;
230    
231     //ElephantMessageBox(word.c_str());
232     return word;
233    
234    
235    
236 }
237
238 string CElephantView::ReadOverFunction()
239 {
240     CScintillaCtrl& rCtrl = GetCtrl();
241    
242    
243     int pos =  rCtrl.GetCurrentPos();
244     string word ;
245     char ch = rCtrl.GetCharAt(--pos);
246    
247     //  char x[10];
248     //  sprintf(x,"%c",rCtrl.GetCharAt(pos));
249     //  ::MessageBox(0,x, "char first",0);
250    
251     while ( rCtrl.GetCharAt(pos--) != '(' )
252     {
253         if ( pos < 0 ) break;
254         continue;
255     }
256    
257     SkipOverWhitespace(pos);
258     //  sprintf(x,"%c",rCtrl.GetCharAt(pos));
259     //  ::MessageBox(0,x, "char",0);
260    
261     ch = rCtrl.GetCharAt(pos);
262    
263     while ( !IsWordBreak(ch ) )
264     {
265         ch = rCtrl.GetCharAt(pos--);
266         //      sprintf(x,"%c &d",ch,pos);
267         //      ::MessageBox(0,x, "char",0);
268         word += ch;
269         if (pos < 0 ) break;
270     }
271     if ( word.length() > 1 )
272         std::reverse(word.begin(),word.end() - 1);
273     else {
274         //ElephantMessageBox(string("return blank " + word) .c_str());
275         return "";
276     }
277    
278     if ( IsWordBreak(word[word.length() - 1] ))
279         word = word.substr(0,word.length() - 1) ;
280    
281     //ElephantMessageBox(word.c_str());
282     return word;
283    
284    
285    
286 }
287
288 string CElephantView::ReadImportWord()
289 {
290
291     CScintillaCtrl& rCtrl = GetCtrl();
292     int pos =  rCtrl.GetCurrentPos();
293     int length = rCtrl.GetLength();
294
295     string word = strip(ReadLastImportWord() );
296
297     char ch = rCtrl.GetCharAt(pos++);
298     while ( ch != ';' && ch != ',' && ch != '\r' && ch != '\n')
299     {
300         word += ch;
301         ch = rCtrl.GetCharAt(pos);
302
303         pos++;
304
305         if ( pos >= length ) return strip(word);
306        
307
308     }
309
310     return strip(word);
311
312
313 }
314
315 string CElephantView::ReadLastImportWord()
316 {
317     CScintillaCtrl& rCtrl = GetCtrl();
318     int pos =  rCtrl.GetCurrentPos();
319     string word ;
320     char ch = rCtrl.GetCharAt(--pos);
321     while ( ch != ' ' && ch != '\n' && ch != '\r' )
322     {
323         ch = rCtrl.GetCharAt(pos--);
324         word += ch;
325         if (pos < 0 ) break;
326     }
327    
328     if ( word.length() > 1 )
329         std::reverse(word.begin(),word.end() - 1);
330    
331     return word;
332    
333 }
334
335 string CElephantView::ReadLastWord(bool skipOverWordBreaks )
336 {
337     CScintillaCtrl& rCtrl = GetCtrl();
338    
339    
340     int pos =  rCtrl.GetCurrentPos();
341     string word ;
342     char ch = rCtrl.GetCharAt(--pos);
343     //  char x[10];
344     //  sprintf(x,"%c",ch);
345     //  ElephantMessageBox(x);
346     if ( skipOverWordBreaks )
347     {
348         while ( IsWordBreak(ch))
349         {
350             ch = rCtrl.GetCharAt(pos--);
351         }
352        
353         pos++;
354     }
355     while ( !IsWordBreak(ch ) )
356     {
357         ch = rCtrl.GetCharAt(pos--);
358         word += ch;
359         if (pos < 0 ) break;
360     }
361     if ( word.length() > 1 )
362         std::reverse(word.begin(),word.end() - 1);
363     else {
364         //ElephantMessageBox(word.c_str());
365         return "";
366     }
367    
368     if ( IsWordBreak(word[word.length() - 1] ))
369         word = word.substr(0,word.length() - 1) ;
370    
371     //ElephantMessageBox(word.c_str());
372     return word;
373    
374 }
375
376 void CElephantView::PerformLibraryCompletion()
377 {
378     CScintillaCtrl& rCtrl = GetCtrl();
379     string list = parseKeywordsForDisplay(Globals::proxyParser->libraryClass->libs);
380     //rCtrl.AutoCSetSeparator(' ');
381    
382     if ( list != "" )   rCtrl.AutoCShow(0 , list.c_str() );
383    
384 }
385
386 void CElephantView::PerformImportStart()
387 {
388     CScintillaCtrl& rCtrl = GetCtrl();
389     vector<string> words = Globals::proxyParser->importClass->initalImports();
390     string expansion = parseKeywordsForDisplay(words);         
391     if ( Globals::settings->baseSettings->GetCache("m_showImportAC") == "1" )
392         if ( expansion != "" )
393         {
394             rCtrl.AutoCShow(0 , expansion.c_str());
395             //rCtrl.AutoCShow(0, expansion.c_str() );
396         }
397        
398        
399        
400        
401 }
402
403 bool CElephantView::PerformImportCompletion()
404 {
405     CScintillaCtrl& rCtrl = GetCtrl();
406    
407     string word = ReadLastImportWord();
408    
409     std::replace(word .begin(),word .end(),'.','\\');
410     word = strip(word);
411     //AfxMessageBox(ITOA(word.length()).c_str());
412     vector<string> matches = Globals::proxyParser->importClass->search(word);
413     rCtrl.AutoCSetSeparator(' ');
414     string list = parseKeywordsForDisplay(matches);
415     if ( list.length() ) {
416        
417         if ( list.length() > 2 )
418             if ( list[list.length() - 1] == '\n' )
419                 list = list.substr(0,list.length() - 1 ); // strip off newline
420            
421             if ( Globals::settings->baseSettings->GetCache("m_showImportAC") == "1" )           
422                 //rCtrl.AutoCShow(0 , list.c_str() );   
423                 rCtrl.AutoCShow(0 , list.c_str() );
424            
425            
426     }
427    
428     return true;
429 }
430
431 void CElephantView::PerformAutoComplete()
432 {
433     string word = ReadLastWord();
434    
435
436
437     if ( word.length() >= 2) {
438
439       Globals::theApp.LogEvent(CODE_COMPLETE ,word);       
440        
441         CScintillaCtrl& rCtrl = GetCtrl();
442        
443        
444        
445        
446        
447         if ( rCtrl.AutoCActive() ) return;
448         rCtrl.AutoCSetSeparator(' ');
449        
450         vector<SymbolListing*> listings = Globals::proxyParser->rootSearch(word, D_CLASS| D_GLOBAL_FUNCTION | D_ALIAS | D_TYPEDEF| D_TEMPLATE | D_STRUCT| D_UNION| D_ENUM| D_INTERFACE | D_VARIABLE);
451        
452         vector<string> matches;
453         Globals::proxyParser->keywords->rootSearch(word,matches );
454        
455         vector<string> mruMatches;
456         Globals::proxyParser->mruClass->rootSearch(word,mruMatches);
457        
458         if ( mruMatches.size() )
459         {
460             string list = parseKeywordsForDisplay(mruMatches);
461             rCtrl.AutoCShow(word.length() , list.c_str() );
462             return;
463         }
464         else {
465            
466             string list = parseListingsAndKeywordsForDisplay(listings,matches);
467             if ( list != "" ) {
468                
469                 //  ElephantMessageBox(list.c_str());
470                 //                  ElephantMessageBox(ITOA(listings.size()) .c_str() );
471                 //         
472                 if ( Globals::settings->baseSettings->GetCache("m_useAC") == "1" )
473                     //rCtrl.AutoCShow(word.length() , list.c_str() );
474                     rCtrl.AutoCShow(word.length() , list.c_str() );
475                
476                
477             }
478         }       
479        
480     }
481 }
482
483 void CElephantView::PerformAutoCompleteForce()
484 {
485    
486    
487     CScintillaCtrl& rCtrl = GetCtrl();
488    
489    
490     if ( rCtrl.AutoCActive() ) rCtrl.AutoCCancel();
491    
492     rCtrl.AutoCSetSeparator(' ');
493    
494    
495     string word = ReadLastWord();
496    
497     if ( word.length() ) {
498        
499         vector<SymbolListing*> listings = Globals::proxyParser->rootSearch(word);
500        
501         vector<string> matches;
502         Globals::proxyParser->keywords->rootSearch(word,matches );
503        
504        
505        
506        
507         string list = parseListingsAndKeywordsForDisplay(listings,matches);
508         if ( list != "" ) {
509            
510             //  ElephantMessageBox(list.c_str());
511             //                  ElephantMessageBox(ITOA(listings.size()) .c_str() );
512             //         
513             if ( Globals::settings->baseSettings->GetCache("m_useAC") == "1" )
514                 //rCtrl.AutoCShow(word.length() , list.c_str() );
515                 rCtrl.AutoCShow(word.length() , list.c_str() );
516            
517            
518         }
519        
520        
521        
522     }
523 }
524
525
526 void CElephantView::PerformAbbreviationExpand()
527 {
528
529   if ( Globals::settings->baseSettings->GetCache("m_useAbbreviations") != "1" ) return;
530
531     CScintillaCtrl& rCtrl = GetCtrl();
532     int s,e;
533     string word = GetLastTypedWord(s,e);
534     //          ::MessageBox(0,word.c_str(),"IN IF.CPP " ,0);
535     char   buffer[4096];
536     // get tabs
537     int currentLine = rCtrl.LineFromPosition(rCtrl.GetCurrentPos() );
538     rCtrl.GetLine(currentLine,buffer);
539     if (rCtrl.LineLength(currentLine)  <= 0) return;
540     buffer[rCtrl.LineLength(currentLine)] = '\0';           
541    
542    
543    
544    
545     {
546         std::map<string,string>::iterator cur  = Globals::settings->abbreviations.begin();
547        
548         string tabs = GetTabs(buffer);
549         //              ElephantMessageBox(string(tabs + "HEYA").c_str() );
550        
551         for ( cur;cur != Globals::settings->abbreviations.end(); cur++) {
552            
553             if ( (*cur).first == word ) {
554                
555                 string value = Globals::settings->abbreviations[word];
556                
557                 unsigned long mtPos = value.find_last_of("||~");
558                 if ( mtPos == string::npos ) return;
559                 string maintain = value.substr(mtPos+1); // grab MT value
560                 value[mtPos-2] = '\0'; // cut off of
561                 unsigned long curPos = value.find("||~");
562                 if ( curPos == string::npos ) return;
563                 string cursor = value.substr(curPos+3);
564                 value[curPos] = '\0';
565                
566                 //ReplaceConstants(value, globals.name);
567                
568                 string newValue = value;
569                 if ( maintain == "1" ) {
570                     newValue = "";
571                     Strtok token(&value,"\n");
572                     newValue = token.NextToken(); // the first line is at the desired point
573                     while (token.HasMoreTokens() ) {
574                         string x = tabs + token.NextToken() + "\n";
575                         //                              ElephantMessageBox(x.c_str() );
576                         newValue += x;
577                     }
578                    
579                 }
580                
581                 rCtrl.SetSelectionStart(s);
582                 rCtrl.SetSelectionEnd(e);
583                 rCtrl.ReplaceSel(newValue.c_str() );
584                
585                 rCtrl.SetSelectionStart(s + atoi(cursor.c_str() ));
586                 rCtrl.SetSelectionEnd(s + atoi(cursor.c_str() ));
587                 return;
588             }
589            
590         }
591     }
592    
593 }
594 void CElephantView::OnAutoCSelection(SCNotification* pSCNotification)
595 {
596
597   Globals::theApp.LogEvent(CODE_COMPLETE ,pSCNotification->text );
598
599     SymbolListing* l = Globals::proxyParser->search(pSCNotification->text);
600     if ( l) Globals::proxyParser->mruClass->AddItem(pSCNotification->text);
601     //ElephantMessageBox(pSCNotification->text);       
602    
603 }
604
605 bool CElephantView::IsBuiltInType(const string& type, string& listStr)
606 {
607    
608     string integralList = "alignof init max min sizeof";
609     string floatList = "alignof dig epsilon infinity init min min_10_exp min_exp mant_dig max max_10_exp max_exp nan sizeof";
610     string arrayList = "dup length ptr reverse sizeof sort";
611     string end;
612    
613     if ( type.length() > 2)
614     {
615         end = type.substr(type.length() - 2);
616         //AfxMessageBox(end.c_str());
617         if ( end == "[]" )
618         {
619             listStr = arrayList;
620             return true;
621         }
622     }
623    
624    
625    
626     if ( type == "int" )
627     {
628         listStr = integralList;
629         return true;
630     }
631     else if ( type == "uint")
632     {
633         listStr = integralList;
634         return true;
635        
636     }
637     else if ( type == "bit")
638     {
639         listStr = integralList;
640         return true;
641        
642     }
643     else if ( type == "byte")
644     {
645         listStr = integralList;
646         return true;
647        
648     }
649     else if ( type == "ubyte")
650     {
651         listStr = integralList;
652         return true;
653        
654     }
655     else if ( type == "short")
656     {
657         listStr = integralList;
658         return true;
659        
660     }
661     else if ( type == "ushort")
662     {
663         listStr = integralList;
664         return true;
665        
666     }
667     else if ( type == "long")
668     {
669         listStr = integralList;
670         return true;
671        
672     }
673     else if ( type == "ulong")
674     {
675         listStr = integralList;
676         return true;
677        
678     }
679     else if ( type == "char")
680     {
681         listStr = integralList;
682         return true;
683        
684     }
685     else if ( type == "wchar")
686     {
687         listStr = integralList;
688         return true;
689        
690     }
691     else if ( type == "dchar")
692     {
693         listStr = integralList;
694         return true;
695        
696     }
697     else if ( type == "cent")
698     {
699         listStr = floatList;
700         return true;
701        
702     }
703     else if ( type == "ucent")
704     {
705         listStr = floatList;
706         return true;
707        
708     }
709     else if ( type == "float")
710     {
711         listStr = floatList;
712         return true;
713        
714     }
715     else if ( type == "double")
716     {
717         listStr = floatList;
718         return true;
719        
720     }
721     else if ( type == "real")
722     {
723         listStr = floatList;
724         return true;
725        
726     }
727     else if ( type == "ifloat")
728     {
729         listStr = floatList;
730         return true;
731        
732     }
733     else if ( type == "idouble")
734     {
735         listStr = floatList;
736         return true;
737        
738     }
739     else if ( type == "ireal")
740     {
741         listStr = floatList;
742         return true;
743        
744     }
745     else if ( type == "cfloat")
746     {
747         listStr = floatList;
748         return true;
749        
750     }
751     else if ( type == "cdouble")
752     {
753         listStr = floatList;
754         return true;
755        
756     }
757     else if ( type == "creal")
758     {
759         listStr = floatList;
760         return true;
761        
762     }
763    
764    
765    
766    
767    
768    
769    
770    
771    
772    
773    
774    
775    
776    
777     return false;
778 }
779 void CElephantView::PerformDotCompletion()
780 {
781    
782     CScintillaCtrl& rCtrl = GetCtrl(); 
783     string word , list;
784    
785     bool stripBrackets = false;
786    
787     char x[10];
788     sprintf(x,"%c",rCtrl.GetCharAt(rCtrl.GetCurrentPos() - 2 )) ;
789    
790     if ( IsFunctionEnd () )
791     {
792         //ElephantMessageBox("function end");
793         word = ReadOverFunction();
794         //ElephantMessageBox(word.c_str());
795     }
796     else if ( IsArrayEnd())
797     {
798         word = ReadOverArray();
799         stripBrackets = true;
800     }
801    
802     else word = ReadLastWord(true);
803    
804     vector<SymbolListing*> allSymbols;
805     vector<SymbolListing*> symbols = Globals::proxyParser->rootSearch(word);
806    
807     SymbolListing * listing = Globals::proxyParser->search(word);
808    
809     if ( listing )
810     {
811        
812        
813            
814         if ( listing->type == D_FUNCTION || listing->type == D_GLOBAL_FUNCTION )
815            
816         {
817                
818             FuncDeclaration* f = (FuncDeclaration*)listing->sym;
819             if ( f ) if (  f->type )
820             {
821                
822                 string clas = f->type->toChars();
823                
824                 StripClassForAutoComplete(clas);
825                     ClassListing* l = Globals::proxyParser->getClass(clas);
826                 if ( l )
827                 {
828                     vector<SymbolListing*> ls;
829                     for ( int j = 0 ; j < l->symbols.size(); j++ )
830                     {
831                             ls.push_back(l->symbols[j]);
832                        
833                     }
834                             list = parseListingsForDisplay(ls);
835                            
836                 }
837                
838             }
839            
840         }
841         else if ( listing->type == D_CLASS )
842         {
843            
844             ClassListing* l = Globals::proxyParser->getClass(word);
845                
846             vector<SymbolListing*> classListings = Globals::proxyParser->getClassMembers(l);
847            
848        
849             if ( classListings.size())
850             {
851                     list = parseListingsForDisplay(classListings);
852                
853             }
854            
855            
856             else if ( l )
857             {
858                 vector<SymbolListing*> ls;
859                 for ( int j = 0 ; j < l->symbols.size(); j++ )
860                 {
861                         ls.push_back(l->symbols[j]);
862                    
863                 }
864                
865                     list = parseListingsForDisplay(ls);
866                
867                        
868             }
869            
870         }
871        
872         else if ( listing->type == D_STRUCT)
873         {
874            
875             ClassListing* l = Globals::proxyParser->getClass(word);
876            
877             if ( l )
878             {
879                 vector<SymbolListing*> ls;
880                 for ( int j = 0 ; j < l->symbols.size(); j++ )
881                 {
882                         ls.push_back(l->symbols[j]);
883                    
884                 }
885                
886                         list = parseListingsForDisplay(ls);
887                
888                    
889             }
890            
891         }
892        
893         else if ( listing->type == D_INTERFACE )
894         {
895            
896             ClassListing* l = Globals::proxyParser->getClass(word);
897            
898             if ( l )
899             {
900                 vector<SymbolListing*> ls;
901                 for ( int j = 0 ; j < l->symbols.size(); j++ )
902                 {
903                     ls.push_back(l->symbols[j]);
904                    
905                 }
906                     list = parseListingsForDisplay(ls);
907                
908                
909                
910             }
911            
912         }
913         else if ( listing->type == D_ENUM )
914         {
915             vector<string> items;
916             Globals::proxyParser->projectParser->display.parseEnumsForDisplay(listing->sym,items);
917             list = parseKeywordsForDisplay(items);
918            
919         }
920         else if ( listing->type == D_IMPORT )
921         {
922             string word = ReadLastImportWord();
923            
924             std::replace(word .begin(),word .end(),'.','\\');
925             word = strip(word);
926
927             vector<string> words = Globals::proxyParser->importClass->search(word);
928             if ( words.size() )
929             {
930                
931                 list = parseKeywordsForDisplay(words);
932                
933             }
934            
935            
936         }
937         else if ( listing->type == D_UNION )
938         {
939            
940             ClassListing* l = Globals::proxyParser->getClass(word);
941            
942             if ( l )
943             {
944                 vector<SymbolListing*> ls;
945                 for ( int j = 0 ; j < l->symbols.size(); j++ )
946                 {
947                    
948                     ls.push_back(l->symbols[j]);
949                    
950                 }
951                
952                 list = parseListingsForDisplay(ls);
953                
954                
955                
956             }
957         }
958         else if ( listing->type == D_VARIABLE )
959         {
960            
961            
962             VarDeclaration* vd = listing->sym->isVarDeclaration();
963
964            
965             if ( vd )
966             {                   
967                
968                 if ( vd->type )
969                 {
970                     string lookup = vd->type->toChars();
971                     if ( stripBrackets)
972                     {
973                         CString l(lookup.c_str());
974                         l.Replace("[","");
975                         l.Replace("]","");
976                         lookup = l.GetBuffer(0);
977                     }
978                    
979                     //AfxMessageBox(lookup.c_str());
980                     if ( IsBuiltInType(lookup, list) )
981                     {
982                        
983                     }
984                     else {
985                         //ElephantMessageBox(lookup.c_str() );
986                        
987                         vector<SymbolListing*> types = Globals::proxyParser->searchMany(lookup);
988                        
989                        
990                        
991                         for ( int i = 0 ; i < types.size(); i++ )
992                         {
993                            
994                            
995                             SymbolListing* type = types[i];
996                            
997                            
998                             if ( type )
999                             {
1000                                 //ElephantMessageBox(toChars(type->type) );
1001                                
1002                                
1003                                 if ( type->type == D_CLASS || type->type == D_STRUCT || type->type == D_INTERFACE || type->type == D_UNION )
1004                                 {                               
1005                                    
1006                                     ClassListing* l = Globals::proxyParser->getClass(type->name);
1007                                    
1008                            
1009                                    
1010                                     if ( l )
1011                                     {
1012                                        
1013                                        
1014                                         vector<SymbolListing*> ls;
1015                                                    
1016                                         ls = Globals::proxyParser->getClassMembers(l);
1017    
1018                                         list = parseListingsForDisplay(ls);
1019                                        
1020    
1021                                        
1022                                     }
1023                                    
1024                                    
1025                                 } // end if type->type == D_CLASS
1026                                
1027                                 else if ( type->type == D_ENUM )
1028                                 {
1029                                     vector<string> items;
1030                                     Globals::proxyParser->projectParser->display.parseEnumsForDisplay(type->sym,items);
1031                                     list = parseKeywordsForDisplay(items);
1032                                 }
1033                             } // end if type
1034                            
1035                             if ( list != "" ) break;
1036                         } // end for ( int i = 0 ; i < types.size ()
1037                        
1038                        
1039                     } // end if else
1040                    
1041                    
1042                 } //end if v->type
1043                
1044                
1045             } //end if vd
1046            
1047             //} // end try {}
1048             //catch ( ... ) {}
1049             //break;
1050         }
1051        
1052        
1053        
1054        
1055     }
1056     else // is import
1057     {
1058        
1059         string word = ReadLastImportWord();
1060        
1061         std::replace(word .begin(),word .end(),'.','\\');
1062         word = strip(word);     
1063         vector<string> words = Globals::proxyParser->importClass->search(word);
1064         // get possible file/directory list for displaying
1065         list = parseKeywordsForDisplay(words);
1066        
1067         if ( !words.size()) //if not found, check if its a file and offer those tags
1068         {
1069             string file;
1070             if ( Globals::proxyParser->importClass->isFile(word,file) )
1071             {               
1072                 vector<string> files;
1073                 if ( FileExists(file))
1074                 {
1075                    
1076                     files.push_back(file);
1077                     //AfxMessageBox(file.c_str());
1078                     ElephantParser e(files);
1079                     list = parseListingsForDisplay(e.listings);
1080                     //AfxMessageBox(list.c_str());
1081                     //e.parse(files);
1082                 }
1083             }
1084            
1085         }
1086        
1087        
1088        
1089     }
1090    
1091     if ( list != "" )
1092         //rCtrl.AutoCShow(0 , list.c_str());
1093         rCtrl.AutoCShow(0 , list.c_str());
1094 }
1095
1096 void CElephantView::PerformWordHover()
1097 {
1098    
1099    
1100     string word = ReadHoverWord();
1101    
1102     if ( word.length() && word != "-1" )
1103     {
1104        
1105        
1106         vector<SymbolListing*> listings;
1107        
1108        
1109        
1110        
1111         try
1112         {
1113             listings = Globals::proxyParser->rootSearch(word);
1114         }
1115         catch ( ... )
1116         {
1117             ElephantMessageBox("cough... this is an error thats not supposed to happen.  I'm gonna go ahead and bail out, cya.");
1118             listings.clear();           
1119         }
1120        
1121         if ( listings.size () )
1122         {
1123             Globals::theApp.ShowHelperInfo(listings );
1124             CScintillaCtrl& rCtrl = GetCtrl();
1125             //rCtrl.CallTipShow(rCtrl.GetCurrentPos(),Globals::proxyParser->projectParser->display.parseSymbolForDisplay(listings[0]->sym).c_str());
1126            
1127         }
1128         else {
1129             //Globals::theApp.ShowHelperInfo(word.c_str(),0,"");
1130         }
1131        
1132        
1133        
1134     }
1135    
1136 }
1137
1138 void CElephantView::PerformBraceMatch() {
1139    
1140     CScintillaCtrl& rCtrl = GetCtrl();
1141    
1142     int currentPos = rCtrl.GetCurrentPos();
1143    
1144     int matchingBrace = -1;
1145    
1146     if ( IsBrace(rCtrl.GetCharAt(currentPos - 1) ) ) {
1147        
1148        
1149         //          StyleClearAll();
1150         //      StyleSetBold(STYLE_BRACELIGHT,true);
1151         //          StyleSetItalic(STYLE_BRACELIGHT,true);
1152        
1153        
1154        
1155         matchingBrace = rCtrl.BraceMatch(currentPos-1);
1156         if ( matchingBrace == -1 ) {
1157             rCtrl.BraceBadLight(currentPos-1);
1158             //rCtrl.CallTipCancel();
1159            
1160         }
1161         else {
1162             if ( rCtrl.GetCharAt(currentPos - 1 ) == '}' ) {
1163                
1164                 string line;
1165                 int start = 0 ,end = 0;
1166                
1167                 if ( FindToControl(matchingBrace, line ,start,end) ) {
1168                  
1169                   CString rep(line.c_str() );
1170                   int numOfNewLines = rep.Replace("\r\n","" );
1171                   if ( numOfNewLines < 2 )
1172                     {
1173                       if ( Globals::settings->baseSettings->GetCache("m_showScopeTips") == "1" )
1174                     {
1175                       rCtrl.CallTipShow(rCtrl.GetCurrentPos(),strip(line).c_str() );
1176                     }
1177                       Globals::theApp.SetStatusBarText(strip(line) );
1178
1179                     }
1180                     //rCtrl.CallTipSetHlt(start,end);
1181                     //rCtrl.CallTipShow(rCtrl.GetCurrentPos(), WhiteSpace::ReplaceWithCodes(strip(line) ) .c_str() );
1182                    
1183                 }
1184                
1185                
1186                
1187             }
1188             rCtrl.BraceHighlight(currentPos-1,matchingBrace);
1189            
1190             // autoindent
1191             int col1 = rCtrl.GetColumn(currentPos-1);
1192             int col2 = rCtrl.GetColumn(matchingBrace);
1193                
1194             if ( Globals::settings->editorSettings->GetCache("autoIndentGuides") == "1" )
1195             {
1196
1197                 char ch = rCtrl.GetCharAt(currentPos - 1);
1198                 if (  ch == '{'  || ch == '}' )
1199                     rCtrl.SetIndentationGuides(true );         
1200
1201             }
1202
1203             rCtrl.SetHighlightGuide(min(col1, col2));
1204            
1205                
1206         }
1207        
1208     }
1209    
1210     else {
1211         //Globals::theApp.ShowHelperInfo("",-1);
1212         if ( Globals::settings->editorSettings->GetCache("autoIndentGuides") == "1" )
1213             if ( rCtrl.GetIndentationGuides() != 0)
1214                 rCtrl.SetIndentationGuides(false );
1215            
1216         rCtrl.BraceBadLight(-1);
1217     }
1218
1219
1220 }
1221
1222
1223 /////////////////////////////////////////////////////////////////////////////
1224 // CElephantView construction/destruction
1225
1226 const char cppKeyWords[] =
1227 "and and_eq asm auto bitand bitor bool break "
1228 "case catch char class compl const const_cast continue "
1229 "default delete do double dynamic_cast else enum explicit export extern false float for "
1230 "friend goto if inline int long mutable namespace new not not_eq "
1231 "operator or or_eq"
1232 "register reinterpret_cast return short signed sizeof static static_cast struct switch "
1233 "template this throw true try typedef typeid typename union unsigned using "
1234 "virtual void volatile wchar_t while xor xor_eq ";
1235
1236 const char dKeyWords[] =
1237 "if else while for do foreach switch case cast ";
1238
1239 const char dKeyWords3[] =
1240 "public protected private ";
1241
1242 const char dKeyWords4[] =
1243 "module import alias package typedef typeof typeid sizeof mixin ";
1244
1245 const char dKeyWords2[] =
1246 "class struct template union enum ";
1247
1248 const char dKeyWords5[] =
1249 "version pragma debug synchronized asm ";
1250
1251 const char dKeyWords6[] =
1252 "const static extern export ";
1253
1254 const char dKeyWords7 [] =
1255 "try throw catch finally ";
1256
1257 const char dKeyWords8 [] =
1258 "continue return break goto ";
1259
1260
1261 const char dKeyWords9 [] =
1262 "void int uint long ulong char dchar wchar short ushort ";
1263
1264
1265
1266 CElephantView::CElephantView()
1267 {
1268     m_line = 0;
1269     active = NULL;
1270
1271
1272 }
1273
1274 CElephantView::~CElephantView()
1275 {
1276 }
1277
1278
1279
1280 BOOL CElephantView::PreCreateWindow(CREATESTRUCT& cs)
1281 {
1282     if (!CView::PreCreateWindow(cs))
1283         return FALSE;
1284    
1285    
1286     return TRUE;
1287 }
1288
1289 /////////////////////////////////////////////////////////////////////////////
1290 // CElephantView drawing
1291
1292 void CElephantView::OnDraw(CDC* pDC)
1293 {
1294     CElephantDoc* pDoc = GetDocument();
1295     ASSERT_VALID(pDoc);
1296 }
1297
1298 /////////////////////////////////////////////////////////////////////////////
1299 // CElephantView printing
1300
1301 BOOL CElephantView::OnPreparePrinting(CPrintInfo* pInfo)
1302 {
1303     // default preparation
1304     return DoPreparePrinting(pInfo);
1305 }
1306
1307 void CElephantView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
1308 {
1309 }
1310
1311 void CElephantView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
1312 {
1313 }
1314
1315 /////////////////////////////////////////////////////////////////////////////
1316 // CElephantView diagnostics
1317
1318 #ifdef _DEBUG
1319 void CElephantView::AssertValid() const
1320 {
1321     CView::AssertValid();
1322 }
1323
1324 void CElephantView::Dump(CDumpContext& dc) const
1325 {
1326     CView::Dump(dc);
1327 }
1328
1329 CElephantDoc* CElephantView::GetDocument() // non-debug version is inline
1330 {
1331     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CElephantDoc)));
1332     return (CElephantDoc*)m_pDocument;
1333 }
1334 #endif //_DEBUG
1335
1336 /////////////////////////////////////////////////////////////////////////////
1337 // CElephantView message handlers
1338
1339 void CElephantView::OnInitialUpdate()
1340 {
1341     CScintillaView::OnInitialUpdate();
1342    
1343     CScintillaCtrl &rCtrl = GetCtrl();
1344    
1345
1346     CString path = GetDocument()->GetPathName();
1347     if ( path != "" )
1348         if ( FileIsReadOnly(path.GetBuffer(0) ) )
1349             rCtrl.SetReadOnly(true);
1350            
1351    
1352     DragAcceptFiles();
1353    
1354     rCtrl.SetLexer(SCLEX_D);
1355    
1356     rCtrl.StyleResetDefault();
1357    
1358     int height  = -MulDiv(atoi(Globals::settings->editorSettings->GetCache("fontSize").c_str() ) +4, GetDeviceCaps(AfxGetMainWnd()->GetDC()->m_hDC, LOGPIXELSY), 72);
1359    
1360    
1361     //SetAStyle(STYLE_DEFAULT, RGB(0, 0, 0), RGB(0xff, 0xff, 0xff), atoi(Globals::settings->editorSettings->GetCache("fontSize").c_str() ), Globals::settings->editorSettings->GetCache("fontFaceName").c_str() );
1362     rCtrl.StyleSetFont(STYLE_DEFAULT,Globals::settings->editorSettings->GetCache("fontFaceName").c_str());
1363     rCtrl.StyleSetSize(STYLE_DEFAULT,height );
1364     rCtrl.UsePopUp(false);
1365    
1366     rCtrl.StyleClearAll();
1367     /*
1368     
1369       rCtrl.SetKeyWords(0, dKeyWords);
1370       rCtrl.SetKeyWords(1, dKeyWords2);
1371       rCtrl.SetKeyWords(2, dKeyWords3);
1372       rCtrl.SetKeyWords(3, dKeyWords4);
1373       rCtrl.SetKeyWords(4, dKeyWords5);
1374       rCtrl.SetKeyWords(5, dKeyWords6);
1375       rCtrl.SetKeyWords(6, dKeyWords7);
1376       rCtrl.SetKeyWords(7, dKeyWords8);
1377       rCtrl.SetKeyWords(8, dKeyWords9);
1378       
1379     */
1380    
1381     SetKeywords();
1382     rCtrl.AutoCSetIgnoreCase(true);
1383     //Setup styles
1384    
1385    
1386    
1387     //Setup folding and tabs
1388     if ( Globals::settings->editorSettings->GetCache("foldingMargins") == "1") rCtrl.SetMarginWidthN(2, 16);
1389     else rCtrl.SetMarginWidthN(2, 0);
1390
1391
1392    
1393     if ( Globals::settings->editorSettings->GetCache("autoIndentGuides" ) == "1" ) rCtrl.SetIndentationGuides(false);
1394     else if ( Globals::settings->editorSettings->GetCache("indentGuides" ) == "1" ) rCtrl.SetIndentationGuides(true );
1395
1396     rCtrl.SetMarginSensitiveN(2, TRUE);
1397     rCtrl.SetMarginTypeN(2, SC_MARGIN_SYMBOL);
1398     rCtrl.SetMarginMaskN(2, SC_MASK_FOLDERS);
1399     rCtrl.SetProperty(_T("fold"), _T("1"));
1400     rCtrl.SetTabWidth(4);
1401     rCtrl.SetWrapMode(Globals::settings->editorSettings->GetCache("wordWrap") == "1");
1402     rCtrl.SetCaretLineVisible(true);
1403     rCtrl.SetCaretPeriod(1000);
1404     rCtrl.SetBufferedDraw(true);
1405     rCtrl.AutoCSetCancelAtStart(false);
1406
1407    
1408    
1409    
1410    
1411    
1412     SetLineNumbers();
1413     SetupMarker();
1414     //Setup markers
1415     rCtrl.SetEOLMode(SC_EOL_CRLF); 
1416     //rCtrl.AutoCStops("\r\n");
1417     rCtrl.AutoCSetFillUps("][");
1418    
1419    
1420    
1421     if ( Globals::currentProject )
1422     {
1423         string title = "[" + Globals::currentProject->path + "]" + " [" + Globals::currentProject->name + "]";
1424         GetParentFrame()->SetTitle(title.c_str());
1425     }
1426    
1427 }
1428
1429 void CElephantView::SetLineNumbers()
1430 {
1431     CScintillaCtrl &rCtrl = GetCtrl();
1432     if ( Globals::settings->editorSettings->GetCache("lineNumbers") == "1" )
1433     {
1434        
1435         int pixelWidth = rCtrl.TextWidth(STYLE_LINENUMBER,Globals::settings->editorSettings->GetCache("lineNumberSize").c_str());
1436         rCtrl.SetMarginWidthN(0, pixelWidth);
1437         rCtrl.SetMarginWidthN(1,0);
1438     }
1439     else
1440     {
1441         rCtrl.SetMarginWidthN(0, 0);
1442         rCtrl.SetMarginWidthN(1,0);
1443     }
1444    
1445 }
1446
1447 void CElephantView::SetupMarker()
1448 {
1449     int style = atoi(Globals::settings->baseSettings->GetCache("foldingStyle").c_str() );
1450    
1451     switch (style)
1452     {
1453     case 0: // vs net
1454         {
1455             DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS, RGB(0xff, 0xff, 0xff), RGB(0x80, 0x80, 0x80));
1456             DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS, RGB(0xff, 0xff, 0xff), RGB(0x80, 0x80, 0x80));
1457             DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE, RGB(0xff, 0xff, 0xff), RGB(0x80, 0x80, 0x80));
1458             DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER, RGB(0xff, 0xff, 0xff), RGB(0x80, 0x80, 0x80));
1459             DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED, RGB(0xff, 0xff, 0xff), RGB(0x80, 0x80, 0x80));
1460             DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED, RGB(0xff, 0xff, 0xff), RGB(0x80, 0x80, 0x80));
1461             DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER, RGB(0xff, 0xff, 0xff), RGB(0x80, 0x80, 0x80));
1462         }
1463         break;
1464     case 1: // vs net circle
1465         {
1466             DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_CIRCLEMINUS, RGB(0xff, 0xff, 0xff), RGB(0x40, 0x40, 0x40));
1467             DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_CIRCLEPLUS, RGB(0xff, 0xff, 0xff), RGB(0x40, 0x40, 0x40));
1468             DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE, RGB(0xff, 0xff, 0xff), RGB(0x40, 0x40, 0x40));
1469             DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNERCURVE, RGB(0xff, 0xff, 0xff), RGB(0x40, 0x40, 0x40));
1470             DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_CIRCLEPLUSCONNECTED, RGB(0xff, 0xff, 0xff), RGB(0x40, 0x40, 0x40));
1471             DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_CIRCLEMINUSCONNECTED, RGB(0xff, 0xff, 0xff), RGB(0x40, 0x40, 0x40));
1472             DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNERCURVE, RGB(0xff, 0xff, 0xff), RGB(0x40, 0x40, 0x40));
1473         }
1474         break;
1475     case 2: // plus
1476         {
1477             DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0xFF));
1478             DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_PLUS, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
1479             DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
1480             DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
1481             DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
1482             DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
1483             DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
1484         }
1485         break;
1486     default:
1487     case 3: // arrow
1488         {
1489             DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_ARROWDOWN, RGB(0, 0, 0), RGB(0, 0, 0));
1490             DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_ARROW, RGB(0, 0, 0), RGB(0, 0, 0));
1491             DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY, RGB(0, 0, 0), RGB(0, 0, 0));
1492             DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY, RGB(0, 0, 0), RGB(0, 0, 0));
1493             DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
1494             DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
1495             DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY, RGB(0xff, 0xff, 0xff), RGB(0, 0, 0));
1496         }
1497         break;
1498     }
1499 }
1500
1501 void CElephantView::SetAStyle(int style, COLORREF fore, COLORREF back, int size, const char* face)
1502 {
1503     CScintillaCtrl& rCtrl = GetCtrl();
1504    
1505     rCtrl.StyleSetFore(style, fore);
1506     rCtrl.StyleSetBack(style, back);
1507    
1508 }
1509
1510 void CElephantView::DefineMarker(int marker, int markerType, COLORREF fore, COLORREF back)
1511 {
1512     CScintillaCtrl& rCtrl = GetCtrl();
1513    
1514     rCtrl.MarkerDefine(marker, markerType);
1515     rCtrl.MarkerSetFore(marker, fore);
1516     rCtrl.MarkerSetBack(marker, back);
1517 }
1518
1519 void CElephantView::OnFileOpen()
1520 {
1521    
1522    
1523 }
1524
1525
1526 void CElephantView::OnModified(SCNotification* scn)
1527 {
1528     GetDocument()->FileModified();
1529     CScintillaCtrl& rCtrl = GetCtrl();
1530    
1531     m_line = rCtrl.LineFromPosition(scn->position);
1532    
1533    
1534     /*
1535     if (0 != (scn->modificationType & SC_MOD_CHANGEFOLD))
1536     {
1537     rCtrl.FoldChanged(scn->line, scn->foldLevelNow, scn->foldLevelPrev);
1538     }
1539     */
1540 }
1541
1542 void CElephantView::OnCharAdded(SCNotification* scn)
1543 {
1544    
1545     CScintillaCtrl& rCtrl = GetCtrl();
1546     int pos = rCtrl.PositionFromLine(m_line+1);
1547    
1548    
1549    
1550     char x[10];
1551     sprintf(x,"%c",scn->ch);
1552     //ElephantMessageBox(x);
1553     if (scn->ch == '\r') { // autmoatic indend
1554        
1555        
1556         char buffer[4096];
1557        
1558         rCtrl.GetLine(m_line,buffer);
1559         buffer[rCtrl.LineLength(m_line)] = '\0';
1560        
1561         string tabs = GetTabs(buffer);
1562        
1563         if (LastCharIsCurlyBrace(buffer) ) {
1564             //m_tabsForBrace.push_back(tabs);
1565             tabs += "\t";
1566         }
1567        
1568         rCtrl.InsertText(pos,tabs.c_str());
1569         rCtrl.SetCurrentPos(pos+tabs.size());
1570         rCtrl.SetSelectionStart(pos+tabs.size());
1571        
1572     }
1573    
1574     else if ( scn->ch == ' ' ) { // abreviations
1575         string word = ReadLastWord(true);
1576         if ( word == "import" )
1577         {
1578             PerformImportStart();
1579            
1580         }
1581         else PerformAbbreviationExpand();
1582        
1583        
1584        
1585     }
1586    
1587     else if ( scn->ch == '}' )
1588     {
1589         char text[500];
1590         rCtrl.GetCurLine(500,text);
1591         if ( strstr(text,"{") == NULL )
1592         {
1593            
1594             int in = rCtrl.GetLineIndentation(m_line); 
1595             rCtrl.SetLineIndentation(m_line,in - 4 );
1596            
1597         }
1598        
1599        
1600        
1601     }
1602    
1603    
1604    
1605     else if ( scn->ch == '.')
1606     {
1607         if ( LineBeginsWithImport() )
1608         {
1609             PerformImportCompletion();
1610         }
1611         else PerformDotCompletion();
1612        
1613     }
1614    
1615    
1616    
1617    
1618    
1619    
1620     else if ( scn->ch == ',' )
1621     {
1622         char text[100] ;
1623         rCtrl.GetCurLine(100,text);
1624         CString line = text;
1625         if ( line.Find("pragma") != -1 && line.Find("link") != -1 )
1626         {
1627             PerformLibraryCompletion();
1628             CMainFrame* m = static_cast<CMainFrame*>(Globals::theApp.m_pMainWnd);
1629             m->SetStatusBarText("You can list available libraries with Ctrl-L");
1630         }
1631        
1632        
1633     }
1634    
1635    
1636    
1637    
1638    
1639    
1640     else if ( scn->ch == '(' )
1641     {
1642        
1643        
1644        
1645        
1646         string display, tempDisplay;
1647         string  word = ReadLastWord(true);
1648         if ( isInSkipCalltip ( word ) || word == "this") return;
1649        
1650         SymbolListing* listing = Globals::proxyParser->search(word);
1651        
1652         if ( listing )
1653         {
1654             if ( listing->sym->isClassDeclaration() || listing->sym->isInterfaceDeclaration() )
1655             {
1656                 ClassListing* cl = Globals::proxyParser->getClass(word);
1657                 if ( cl )
1658                 {
1659                    
1660                     for ( int i = 0; i < cl->constructors.size();i++ )
1661                     {
1662                         string temp = "";
1663                         Globals::proxyParser->projectParser->display.parseCtorForDisplay(cl->constructors[i],temp);
1664                         display += word + temp + "\n";
1665                        
1666                     }
1667                     display = display.substr(0,display.length() - 1); // cutt of new line
1668                 }
1669             }
1670            
1671            
1672            
1673             vector<SymbolListing*> listings = Globals::proxyParser->rootSearch(word);
1674             vector<string> uniques;
1675             for ( int i = 0 ; i < listings.size(); i++ )
1676             {
1677                
1678                 string temp = Globals::proxyParser->supplementalParser->display.parseSymbolForDisplay(listings[i]->sym) + "\n";             
1679                 if ( std::find(uniques.begin(), uniques.end() , temp) != uniques.end() )  continue;
1680                 else {             
1681                     display += temp;
1682                     uniques.push_back(temp);
1683                 }
1684             }   
1685            
1686             display = display.substr(0,display.length() - 1); // cutt of new line
1687            
1688         }
1689        
1690         if ( display.length () )
1691             if ( Globals::settings->baseSettings->GetCache("m_showToolTips") == "1" )
1692                 rCtrl.CallTipShow(rCtrl.GetCurrentPos(),display.c_str() );
1693            
1694            
1695            
1696            
1697            
1698     }
1699    
1700    
1701    
1702     if ( rCtrl.AutoCActive()) return;
1703    
1704    
1705     //AfxMessageBox(ITOA(rCtrl.GetCurrentPos() - 1) .c_str());
1706     //AfxMessageBox(ITOA(rCtrl.GetStyleAt(rCtrl.GetCurrentPos() - 1)).c_str() );
1707     if ( rCtrl.GetStyleAt(rCtrl.GetCurrentPos() ) == SCE_D_STRING 
1708         || rCtrl.GetStyleAt(rCtrl.GetCurrentPos() ) == SCE_D_STRINGEOL 
1709         || rCtrl.GetStyleAt(rCtrl.GetCurrentPos() ) == SCE_D_COMMENT
1710         || rCtrl.GetStyleAt(rCtrl.GetCurrentPos() ) == SCE_D_COMMENTLINE
1711        
1712         )
1713     {
1714         //xMessageBox("here");
1715         //return;
1716     }
1717    
1718     else PerformAutoComplete();
1719 }
1720
1721
1722
1723 string CElephantView::ReadHoverWord()
1724 {
1725     CScintillaCtrl& rCtrl = GetCtrl();
1726    
1727     if ( rCtrl.GetLineCount() <= 2 ) return "-1";
1728     int pos =  rCtrl.GetCurrentPos();
1729     int endLine = rCtrl.GetLineCount();
1730     int endPos = rCtrl.PositionFromLine(endLine);
1731     string wordForward, wordBackward, word;
1732    
1733     char ch = rCtrl.GetCharAt(pos++);
1734     wordForward += ch;
1735     //      char x[10];
1736     //      sprintf(x,"%c",ch);
1737     //      ElephantMessageBox(x);
1738     while ( !IsWordBreak(ch ) )
1739     {
1740         ch = rCtrl.GetCharAt(pos++);
1741         wordForward += ch;
1742         if (pos >= endPos ) break;
1743     }
1744    
1745     pos = rCtrl.GetCurrentPos();
1746     ch = rCtrl.GetCharAt(--pos);
1747    
1748     while (!IsWordBreak(ch))
1749     {
1750         ch = rCtrl.GetCharAt(pos--);
1751         wordBackward += ch;
1752         if (pos <= 0 ) break;
1753        
1754     }
1755    
1756     std::reverse(wordBackward.begin(),wordBackward.end() );
1757    
1758     word = wordBackward + wordForward;
1759    
1760     if ( IsWordBreak(word[word.length() - 1] ))
1761         word = word.substr(0,word.length() - 1) ;
1762     if ( IsWordBreak(word[0] ))
1763         word = word.substr(1 );
1764    
1765     return strip(word);
1766 }
1767
1768
1769
1770
1771
1772
1773
1774 void CElephantView::OnUpdateUI(SCNotification* scn)
1775 {
1776    
1777     PerformBraceMatch();
1778     CScintillaCtrl& rCtrl = GetCtrl();
1779    
1780     if ( rCtrl.GetStyleAt(rCtrl.GetCurrentPos() ) == SCE_D_STRING 
1781         || rCtrl.GetStyleAt(rCtrl.GetCurrentPos() ) == SCE_D_STRINGEOL  )
1782     {
1783         //xMessageBox("here");
1784         //return;
1785     }       
1786     else PerformWordHover();
1787    
1788    
1789    
1790 }
1791
1792
1793 // bool CElephantView::FindToControl(int pos , string& line, int& startHighlight, int& endHighlight)
1794 // {
1795
1796
1797 //  CScintillaCtrl &rCtrl = GetCtrl();
1798    
1799 //  string backwardText;
1800 //  string text;
1801 //  char ch;
1802 //  bool closingBraceMatched = false, curlyBraceMatched = false ;
1803    
1804
1805
1806 // //   ifReg.study();
1807
1808 //  int i = 0 ;
1809 //  for ( i = pos; i > 0; i-- ) {
1810 //      //    if (  i + 100 <= pos ) return false;
1811 //      if (  i + 100 <= pos ) break;
1812        
1813 //      ch = rCtrl.GetCharAt(i);
1814 // //       if ( ch == '\r' || ch == '\n')
1815 // //       {
1816 // // //            AfxMessageBox (text.c_str() );
1817 // //           backwardText = "";
1818 // //       }
1819 //          if ( isspace(ch  ) ) {
1820 // //           backwardText += ch;
1821 //              continue;
1822 //          }
1823        
1824        
1825        
1826 //      backwardText += ch;
1827
1828
1829
1830 //  }
1831
1832 //      text = backwardText;
1833 //      std::reverse(text.begin(), text.end() );
1834
1835
1836 //  if ( ifReg->match(text) > 0 )
1837 //  {
1838 //      line = text;
1839 //      AfxMessageBox(text.c_str() );       
1840 //      return true;
1841 //  }
1842 //  //AfxMessageBox(text.c_str() );     
1843
1844 //  line = text;
1845 //  return true;
1846
1847 // };
1848
1849 bool CElephantView::FindToControl(int pos , string& line, int& startHighlight, int& endHighlight)
1850 {
1851    
1852     CScintillaCtrl &rCtrl = GetCtrl();
1853    
1854     string backwardText;
1855     string text;
1856     char ch;
1857     bool closingBraceMatched = false, curlyBraceMatched = false ;
1858    
1859     int i = 0 ;
1860     for ( i = pos; i > 0; i-- ) {
1861         if (  i + 100 <= pos ) return false;
1862        
1863         ch = rCtrl.GetCharAt(i);
1864         // check for ) thats needed if its to succeed
1865         {
1866             if ( isspace(ch  ) ) {
1867                 backwardText += ch;
1868                 continue;
1869             }
1870            
1871             //          if ( ch == '{' ) { // we cant have two of these !
1872             //              if ( !curlyBraceMatched ) {
1873             //                  curlyBraceMatched = true;
1874             //                  continue;
1875             //              }
1876             //              else return false;
1877             //          }
1878            
1879             //          if (! closingBraceMatched ) {
1880             //              if (ch != ')' ) return false;
1881             //              else closingBraceMatched = true;
1882             //          }
1883            
1884            
1885         }
1886        
1887        
1888         backwardText += ch;
1889         text = backwardText;
1890         //      std::reverse(text.begin(), text.end() );
1891        
1892        
1893         //      if ( StartsWithBackward("try",text ) ) {
1894         if ( StartsWithBackward("yrt",text ) ) {
1895          
1896            
1897             line = text.substr(1);
1898             Reverse(line );
1899
1900             return true;
1901            
1902            
1903         }
1904        
1905         //      if ( StartsWithBackward("invariant",text ) ) {
1906         if ( StartsWithBackward("tnairavni",text ) ) {
1907            
1908
1909             line = text.substr(1);
1910             Reverse(line);
1911          
1912             return true;
1913         }
1914        
1915
1916        
1917         //      if ( StartsWithBackward("private",text ) ) {
1918         if ( StartsWithBackward("etavirp",text ) ) {
1919            
1920          
1921             line = text.substr(1);
1922             Reverse(line);
1923             return true;
1924        
1925        
1926         }
1927        
1928         //      if ( StartsWithBackward("public",text ) ) {
1929         if ( StartsWithBackward("cilbup",text ) ) {
1930            
1931          
1932             line = text.substr(1);
1933             Reverse(line);
1934             return true;
1935
1936            
1937         }
1938        
1939        
1940        
1941         //      if ( StartsWithBackward("catch",text ) ) {
1942         if ( StartsWithBackward("hctac",text ) ) {
1943            
1944             line = text.substr(1);
1945             Reverse(line);
1946             return true;
1947
1948            
1949         }
1950        
1951        
1952        
1953         //      if ( StartsWithBackward("switch",text ) ) {
1954         if ( StartsWithBackward("hctiws",text ) ) {
1955          
1956             line = text.substr(1);
1957             Reverse(line);
1958             return true;
1959
1960            
1961         }
1962        
1963         //      if ( StartsWithBackward("if",text ) ) {
1964         if ( StartsWithBackward("fi",text ) ) {
1965           // HERE
1966             if ( NextCharIsBackward('(',text , 2) )
1967             {
1968                 line = text.substr(1);
1969                 Reverse(line);
1970                 return true;
1971             }
1972
1973         }
1974        
1975         //      if ( StartsWithBackward("else",text ) ) {
1976         if ( StartsWithBackward("esle",text ) ) {
1977
1978           if ( NextCharIsBackward('{',text , 4) )
1979             {
1980
1981                 line = text.substr(1);
1982                 Reverse(line);
1983                 return true;
1984             }
1985
1986
1987
1988           else if ( NextCharIsBackward('(',text , 4) )
1989             {
1990
1991                 line = text.substr(1);
1992                 Reverse(line);
1993                 return true;
1994             }
1995
1996            
1997                 return true;
1998
1999         }
2000        
2001         //      if ( StartsWithBackward("body",text ) ) {
2002         if ( StartsWithBackward("ydob",text ) ) {
2003
2004           if ( NextCharIsBackward('{',text , 4) )
2005             {
2006
2007                 line = text.substr(1);
2008                 Reverse(line);
2009                 return true;
2010             }
2011
2012
2013
2014           else if ( NextCharIsBackward('(',text , 4) )
2015             {
2016
2017                 line = text.substr(1);
2018                 Reverse(line);
2019                 return true;
2020             }
2021
2022            
2023                 return true;
2024
2025         }
2026
2027         //      if ( StartsWithBackward("in",text ) ) {
2028         if ( StartsWithBackward("ni",text ) ) {
2029
2030           if ( NextCharIsBackward('{',text , 4) )
2031             {
2032
2033                 line = text.substr(1);
2034                 Reverse(line);
2035                 return true;
2036             }
2037
2038
2039
2040         }
2041        
2042        
2043        
2044         //      if ( StartsWithBackward ("foreach",text ) ) {
2045         if ( StartsWithBackward ("hcaerof",text ) ) {
2046            
2047             line = text.substr(1);
2048             Reverse(line);
2049             return true;
2050
2051         }       
2052
2053         //      if ( StartsWithBackward ("template",text ) ) {
2054         if ( StartsWithBackward ("etalpmet",text ) ) {
2055            
2056             line = text.substr(1);
2057             Reverse(line);
2058             return true;
2059
2060         }       
2061        
2062         //      if ( StartsWithBackward ("for",text ) )  {y
2063         if ( StartsWithBackward ("rof",text ) )  {
2064            
2065             if ( NextCharIsBackward('(',text,3 ) ) {
2066                 line = text.substr(1);
2067                 Reverse(line);
2068                 return true;
2069             }
2070            
2071         }
2072        
2073        
2074        
2075         //      if ( StartsWithBackward ("while",text ) ) {
2076         if ( StartsWithBackward ("elihw",text ) ) {
2077            
2078             line = text.substr(1);
2079             Reverse(line);
2080             return true;
2081
2082         }       
2083        
2084         //      if ( StartsWithBackward ("extern",text ) ) {
2085         if ( StartsWithBackward ("nretxe",text ) ) {
2086            
2087            
2088             line = text.substr(1);
2089             Reverse(line);
2090             return true;
2091         }
2092        
2093        
2094         //      if ( StartsWithBackward ("with",text ) ) {
2095         if ( StartsWithBackward ("htiw",text ) ) {
2096            
2097             if ( NextCharIsBackward('(',text ,4) ) {
2098                 line = text.substr(1);
2099                 Reverse(line);
2100                 return true;
2101             }
2102            
2103         }       
2104        
2105        
2106        
2107         //      if ( StartsWithBackward ("this",text ) ) {
2108         if ( StartsWithBackward ("siht",text ) ) {
2109             line = text.substr(1); 
2110             Reverse(line);
2111             return true;
2112
2113         }       
2114        
2115
2116        
2117        
2118         //      if ( StartsWithBackward ("enum",text ) ) {
2119         if ( StartsWithBackward ("mune",text ) ) {
2120            
2121          
2122               line = text.substr(1);
2123               Reverse(line);
2124
2125               return true;
2126            
2127            
2128         }       
2129        
2130        
2131        
2132        
2133         //      if ( StartsWithBackward ("unittest",text ) ) {
2134         if ( StartsWithBackward ("tsettinu",text ) ) {
2135
2136             if ( NextCharIsBackward('(',text , 8) )
2137               {
2138                 line = text.substr(1);
2139                 Reverse(line);
2140                 return true;
2141               }
2142
2143
2144             if ( NextCharIsBackward('{',text , 8) )
2145               {
2146                 line = text.substr(1);
2147                 Reverse(line);
2148                 return true;
2149               }
2150          
2151            
2152            
2153         }       
2154        
2155        
2156         //      if ( StartsWithBackward ("debug",text ) ) {
2157         if ( StartsWithBackward ("gubed",text ) ) {
2158
2159
2160             if ( NextCharIsBackward('(',text , 5) )
2161               {
2162                 line = text.substr(1);
2163                 Reverse(line);
2164                 return true;
2165               }
2166
2167
2168             if ( NextCharIsBackward('{',text , 5) )
2169               {
2170                 line = text.substr(1);
2171                 Reverse(line);
2172                 return true;
2173               }
2174
2175            
2176         }       
2177        
2178        
2179         //      if ( StartsWithBackward ("version",text ) ) {
2180         if ( StartsWithBackward ("noisrev",text ) ) {
2181
2182
2183             if ( NextCharIsBackward('(',text , 7) )
2184               {
2185                 line = text.substr(1);
2186                 Reverse(line);
2187                 return true;
2188               }
2189
2190
2191             if ( NextCharIsBackward('{',text , 7) )
2192               {
2193                 line = text.substr(1);
2194                 Reverse(line);
2195                 return true;
2196               }
2197
2198
2199            
2200         }       
2201        
2202         //      if (StartsWithBackward("class",text ) ) {
2203         if (StartsWithBackward("ssalc",text ) ) {
2204           line = text.substr(1);
2205           Reverse(line);
2206           return true;
2207            
2208         }
2209        
2210         //      if (StartsWithBackward("struct",text ) ) {
2211         if (StartsWithBackward("tcurts",text ) ) {
2212           line = text.substr(1);
2213           Reverse(line);
2214           return true;
2215            
2216         }
2217        
2218        
2219        
2220
2221         //      if (StartsWithBackward("interface",text ) ) {
2222         if (StartsWithBackward("ecafretni",text ) ) {
2223           line = text.substr(1);
2224           Reverse(line);
2225           return true;
2226            
2227         }
2228
2229        
2230
2231        
2232 //      if ( MatchesFunctionDefinition(text ) ) {
2233 //        line = text.substr(1);
2234 //        Reverse(line);
2235 //        return true;         
2236
2237            
2238 //      }
2239        
2240     }
2241     return false;
2242    
2243 }
2244
2245
2246
2247 void CElephantView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
2248 {
2249     if ( bActivate) {       
2250         if ( pActivateView ) { 
2251             Globals::recentViews.Add( LastView (static_cast<CElephantDoc*>( pActivateView->GetDocument() ), static_cast<CElephantView*>(pActivateView)->m_line ));         
2252             //CString c = pActivateView->GetDocument()->GetTitle();
2253            
2254             CString path = pActivateView->GetDocument()->GetPathName();
2255             //Globals::theApp.SetStatusBarText(path.GetBuffer(0));
2256             CString title = pActivateView->GetDocument()->GetTitle();
2257             if ( path != "" )   
2258             {
2259                
2260                 Globals::proxyParser->SetFileParser(path.GetBuffer(0));
2261                 Globals::theApp.UpdateFileCodeCombo(Globals::proxyParser->fileParser->listings);
2262                 //Globals::theApp.SelectFileItem(title.GetBuffer(0) );
2263                
2264                
2265                
2266             }
2267             //         
2268             //          catch ( ... )
2269             //          {
2270             //              ElephantMessageBox("couaght 1602 elephant view");
2271             //              ;
2272             //          }
2273            
2274         }
2275     }
2276     else
2277     {
2278        
2279         CString path = pDeactiveView->GetDocument()->GetPathName();
2280        
2281     }
2282    
2283    
2284     CScintillaView::OnActivateView(bActivate, pActivateView, pDeactiveView);
2285 }
2286
2287
2288 void CElephantView::SetKeywords()
2289 {
2290    
2291     CScintillaCtrl &rCtrl = GetCtrl();
2292    
2293     string codePage = Globals::settings->editorSettings->GetCache("codePage");
2294     int icodePage = SC_CP_UTF8 ;
2295     if ( codePage == "UTF-8" ) icodePage = SC_CP_UTF8 ;
2296     else if ( codePage == "Shift JIS" ) icodePage = 932 ;
2297     else if ( codePage == "Simplified Chinese" ) icodePage = 936  ;
2298     else if ( codePage == "Korean" ) icodePage = 949 ;
2299     else if ( codePage == "Traditional Chinese" ) icodePage = 950 ;
2300    
2301     rCtrl.SetCodePage(icodePage);
2302    
2303    
2304    
2305     CString keywords1 = Globals::settings->colorSettings->settings->GetCache("Built-in Types").c_str();
2306     CString keywords2 = Globals::settings->colorSettings->settings->GetCache("Attribute").c_str();
2307     CString keywords3 = Globals::settings->colorSettings->settings->GetCache("User Defined Type").c_str();
2308     CString keywords4 = Globals::settings->colorSettings->settings->GetCache("User Keywords").c_str();
2309     CString keywords5 = Globals::settings->colorSettings->settings->GetCache("Control").c_str();
2310     CString keywords6 = Globals::settings->colorSettings->settings->GetCache("Name Resolution").c_str();
2311     CString keywords7 = Globals::settings->colorSettings->settings->GetCache("Templates and Mixins").c_str();
2312     CString keywords8 = Globals::settings->colorSettings->settings->GetCache("Modifiers").c_str();
2313    
2314     ElephantColor word  = Globals::settings->colorSettings->colors["Built-in Types_color"];
2315     ElephantColor word2 = Globals::settings->colorSettings->colors["Attribute_color"];
2316     ElephantColor word3 = Globals::settings->colorSettings->colors["User Defined Type_color"];
2317     ElephantColor word4 = Globals::settings->colorSettings->colors["User Keywords_color"];
2318     ElephantColor word5 = Globals::settings->colorSettings->colors["Control_color"]; ///Globals::settings->colorSettings->colors["User Keywords_color"];
2319     //ElephantColor word6 = Globals::settings->colorSettings->colors["Control_color"]; ///Globals::settings->colorSettings->colors["User Keywords_color"];
2320     ElephantColor word6 = Globals::settings->colorSettings->colors["Name Resolution_color"];
2321     ElephantColor word7 = Globals::settings->colorSettings->colors["Templates and Mixins_color"];
2322     ElephantColor word8 = Globals::settings->colorSettings->colors["Modifiers_color"];
2323    
2324    
2325     keywords1.Replace(","," ");
2326     keywords2.Replace(","," ");
2327     keywords3.Replace(","," ");
2328     keywords4.Replace(","," ");
2329     keywords5.Replace(","," ");
2330     keywords6.Replace(","," ");
2331     keywords7.Replace(","," ");
2332     keywords8.Replace(","," ");
2333    
2334    
2335     /*
2336     ElephantMessageBox(keywords1);
2337     ElephantMessageBox(keywords2);
2338     ElephantMessageBox(keywords3);
2339     ElephantMessageBox(keywords4);
2340     ElephantMessageBox(keywords5);
2341     ElephantMessageBox(keywords6);
2342     ElephantMessageBox(keywords7);
2343     ElephantMessageBox(keywords8);
2344     */
2345    
2346     rCtrl.SetKeyWords(0,keywords1.GetBuffer(0));   
2347     rCtrl.SetKeyWords(1,keywords2.GetBuffer(0));
2348     rCtrl.SetKeyWords(2,keywords3.GetBuffer(0));
2349     rCtrl.SetKeyWords(3,keywords4.GetBuffer(0));
2350     rCtrl.SetKeyWords(4,keywords5.GetBuffer(0));
2351     rCtrl.SetKeyWords(5,keywords6.GetBuffer(0));
2352     rCtrl.SetKeyWords(6,keywords7.GetBuffer(0));
2353     rCtrl.SetKeyWords(7,keywords8.GetBuffer(0));
2354     rCtrl.SetKeyWords(8,keywords8.GetBuffer(0));
2355    
2356    
2357    
2358     //  string word2 = Globals::settings->colorSettings->settings->GetCache("Built-in Types_color");
2359     //  string word3 = Globals::settings->colorSettings->settings->GetCache("Attribute_color");
2360     //  string word4 = Globals::settings->colorSettings->settings->GetCache("User Defined Type_color");
2361     //  string word5 = Globals::settings->colorSettings->settings->GetCache("User Keywords_color");
2362    
2363     //  string word6 = Globals::settings->colorSettings->settings->GetCache("Control_color");
2364     //  string word7 = Globals::settings->colorSettings->settings->GetCache("Name Resolution_color");
2365     //  string word8 = Globals::settings->colorSettings->settings->GetCache("Templates and Mixins_color");
2366     //  string word9 = Globals::settings->colorSettings->settings->GetCache("Modifiers_color");
2367    
2368     //  string comments  = Globals::settings->colorSettings->settings->GetCache("Comments_color");
2369     //  string numbers = Globals::settings->colorSettings->settings->GetCache("Numbers_color");
2370     //  string strings = Globals::settings->colorSettings->settings->GetCache("Strings_color");
2371     //  string operators = Globals::settings->colorSettings->settings->GetCache("Operators_color");
2372    
2373    
2374    
2375     ElephantColor comments = Globals::settings->colorSettings->colors["Comments_color"];
2376     ElephantColor numbers = Globals::settings->colorSettings->colors["Numbers_color"];
2377     ElephantColor strings = Globals::settings->colorSettings->colors["Strings_color"];
2378     ElephantColor operators = Globals::settings->colorSettings->colors["Operators_color"];
2379    
2380     ElephantColor ide = Globals::settings->colorSettings->colors["Editor Background_color"];
2381     ElephantColor caretLine = Globals::settings->colorSettings->colors["Line Highlight_color"];
2382     ElephantColor braceH = Globals::settings->colorSettings->colors["Brace Highlight_color"];
2383     ElephantColor braceB = Globals::settings->colorSettings->colors["Brace Badlight_color"];
2384     ElephantColor lineN = Globals::settings->colorSettings->colors["Line Number_color"];
2385     ElephantColor margin = Globals::settings->colorSettings->colors["Margin_color"];
2386     ElephantColor ident = Globals::settings->colorSettings->colors["Identifier_color"];
2387     ElephantColor callTip = Globals::settings->colorSettings->colors["Calltip_color"];
2388     ElephantColor caret = Globals::settings->colorSettings->colors["Caret_color"];
2389     ElephantColor selection = Globals::settings->colorSettings->colors["Selection_color"];
2390     ElephantColor char_ = Globals::settings->colorSettings->colors["Character Literals_color"];
2391     ElephantColor stringeol = Globals::settings->colorSettings->colors["String EOL_color"];
2392     ElephantColor regex = Globals::settings->colorSettings->colors["Regex_color"];
2393     ElephantColor verbatim = Globals::settings->colorSettings->colors["Verbatim Strings_color"];
2394     ElephantColor nestedComment = Globals::settings->colorSettings->colors["Nested Comments_color"];
2395     ElephantColor indentGuide = Globals::settings->colorSettings->colors["Indent Guide_color"];
2396    
2397    
2398    
2399    
2400    
2401     //rCtrl.StyleSetBold(SCE_D_WORD, 1);
2402     rCtrl.StyleSetBold(SCE_D_WORD2, 1);
2403     rCtrl.StyleSetBold(SCE_D_WORD, 1);
2404     rCtrl.StyleSetBold(SCE_D_WORD3, 1);
2405     rCtrl.StyleSetBold(SCE_D_WORD4, 1);
2406     rCtrl.StyleSetBold(SCE_D_WORD5, 1);
2407     rCtrl.StyleSetBold(SCE_D_WORD6, 1);
2408     rCtrl.StyleSetBold(SCE_D_WORD7, 1);
2409     rCtrl.StyleSetBold(SCE_D_WORD8, 1);
2410     rCtrl.StyleSetBold(SCE_D_WORD9, 1);
2411    
2412    
2413     if ( caret.fore != -1 ) rCtrl.SetCaretFore(caret.fore );
2414    
2415     if ( selection.fore != -1 ) rCtrl.SetSelFore(true,selection.fore );
2416     if ( selection.back!= -1 ) rCtrl.SetSelBack(true, selection.back);
2417    
2418    
2419    
2420     if ( callTip.back != -1 ) rCtrl.CallTipSetBack(callTip.back);
2421     if ( callTip.fore!= -1 ) rCtrl.CallTipSetFore(callTip.fore);
2422    
2423     rCtrl.SetCaretLineBack(caretLine.fore);
2424     if ( margin.back != -1 ) rCtrl.SetFoldMarginColour(true,margin.back);
2425     if ( margin.fore != -1 ) rCtrl.SetFoldMarginHiColour(true,margin.fore);
2426    
2427     if ( lineN.fore != -1 ) SetAStyle(STYLE_LINENUMBER,lineN.fore, lineN.back );
2428    
2429    
2430     SetAStyle(STYLE_BRACELIGHT,braceH.fore, braceH.back);
2431     SetAStyle(STYLE_BRACEBAD,braceB.fore, braceB.back);
2432    
2433    
2434     //  rCtrl.StyleSetFore(STYLE_BRACELIGHT,10040115 );
2435     rCtrl.StyleSetBold(STYLE_BRACELIGHT,1);
2436     // 
2437     //  rCtrl.StyleSetFore(STYLE_BRACEBAD,RGB(255,10,10 ) );
2438     rCtrl.StyleSetBold(STYLE_BRACEBAD,1);
2439     // 
2440     //rCtrl.RegisterImage()
2441    
2442     SetAStyle(SCE_D_WORD,word.fore, word2.back );
2443     SetAStyle(SCE_D_WORD2,word2.fore, word2.back );
2444     SetAStyle(SCE_D_WORD3,word3.fore, word3.back );
2445     SetAStyle(SCE_D_WORD4,word4.fore, word4.back );
2446     SetAStyle(SCE_D_WORD5,word5.fore, word5.back );
2447     SetAStyle(SCE_D_WORD6,word6.fore, word6.back );
2448     SetAStyle(SCE_D_WORD7,word7.fore, word7.back );
2449     SetAStyle(SCE_D_WORD8,word8.fore, word8.back );
2450     SetAStyle(SCE_D_WORD9,word.fore, word.back );
2451    
2452    
2453     SetAStyle(SCE_D_DEFAULT, ide.fore, ide.back);
2454     SetAStyle(SCE_D_COMMENT, comments.fore,comments.back);
2455     SetAStyle(SCE_D_NESTCOMMENT, nestedComment.fore,nestedComment.back);
2456     SetAStyle(SCE_D_NESTCOMMENT1, nestedComment.fore,nestedComment.back);
2457     SetAStyle(SCE_D_NESTCOMMENT2, nestedComment.fore,nestedComment.back);
2458     SetAStyle(SCE_D_NESTCOMMENT3, nestedComment.fore,nestedComment.back);
2459     SetAStyle(SCE_D_NESTCOMMENT4, nestedComment.fore,nestedComment.back);
2460
2461     SetAStyle(SCE_D_COMMENTLINE, comments.fore,comments.back);
2462     SetAStyle(SCE_D_COMMENTDOC, comments.fore,comments.back);
2463     SetAStyle(SCE_D_COMMENTLINEDOC, comments.fore,comments.back);
2464     SetAStyle(SCE_D_COMMENTDOCKEYWORDERROR, comments.fore,comments.back);
2465    
2466    
2467     SetAStyle(STYLE_INDENTGUIDE, indentGuide.fore, indentGuide.back );
2468     SetAStyle(SCE_D_NUMBER, numbers.fore, numbers.back );
2469     SetAStyle(SCE_D_STRING, strings.fore , strings.back);
2470     SetAStyle(SCE_D_VERBATIMTICK, verbatim.fore , verbatim.back);
2471     SetAStyle(SCE_D_VERBATIM, verbatim.fore , verbatim.back);
2472     SetAStyle(SCE_D_IDENTIFIER, ident.fore, ident.back );
2473     SetAStyle(SCE_D_PREPROCESSOR, RGB(0x80, 0, 0));
2474     SetAStyle(SCE_D_OPERATOR, operators.fore , operators.back);
2475     SetAStyle(SCE_D_CHARACTER, char_.fore , char_.back);
2476     SetAStyle(SCE_D_STRINGEOL, stringeol.fore , stringeol.back);
2477     SetAStyle(SCE_D_REGEX, regex.fore , regex.back);
2478     SetAStyle(STYLE_DEFAULT,ide.fore,ide.back);
2479    
2480    
2481     //  rCtrl.AutoCSetChooseSingle(true);
2482    
2483    
2484 }
2485
2486
2487 void CElephantView::OnMacroRecord(SCNotification* scn)
2488 {
2489     char* t;
2490     t = (char*)(scn->lParam);
2491    
2492     if ( t != NULL )
2493         active->Record(-1,t );
2494     else
2495         active->Record(scn->message,scn->wParam,scn->lParam );
2496 }
2497
2498 void CElephantView::ExecuteMacro(ElephantMacro &m )
2499 {
2500    
2501     CScintillaCtrl& rCtrl = GetCtrl();
2502     for ( int i = 0; i < m.msgs.size()  ;i++) {
2503         //      ElephantMessageBox(ITOA(m.msgs[i].msg).c_str() );
2504         if ( m.msgs[i].msg == -1 ){
2505             rCtrl.AddText(m.msgs[i].text.length() , m.msgs[i].text.c_str() );
2506         }
2507         else {
2508             rCtrl.Call(m.msgs[i].msg, m.msgs[i].wparam, m.msgs[i].lparam );
2509         }
2510     }
2511 }
2512
2513
2514 void CElephantView::OnDropFiles(        HDROP hDropInfo ) {
2515    
2516     rjc::RDragDropFiles myFiles (hDropInfo);
2517     CString buf;
2518    
2519     int iStat = 0;
2520     int iL = 0;
2521     while (myFiles ()) {
2522         myFiles.sNextFile (buf);
2523        
2524         string ext = FileExtension( (LPCSTR)  buf) ;
2525        
2526        
2527         if ( LowerCase(ext) == "dprj")
2528         {
2529             string path = StripDirPath( (LPCSTR)buf.GetBuffer(0));
2530             string file = StripFileName(buf.GetBuffer(0));
2531             StripExtension(file);
2532            
2533             ProjectSettings * p = new ProjectSettings(path,file );
2534             Globals::SetProject(p);
2535         }
2536        
2537         else Globals::theApp.OpenFile(buf.GetBuffer(0),true);
2538        
2539     }
2540 }
2541
2542
2543 void CElephantView::OnContextMenu(CWnd* pWnd, CPoint point)
2544 {
2545    
2546     CPoint pt = point;
2547     ClientToScreen(&pt);
2548    
2549     CXTMenu menu;
2550     VERIFY(menu.LoadMenu(IDR_MAINFRAME));
2551    
2552     CWnd* pWndPopupOwner = this;
2553     while (pWndPopupOwner->GetStyle() & WS_CHILD)
2554         pWndPopupOwner = pWndPopupOwner->GetParent();
2555    
2556    
2557     CXTMenu* pPopup = menu.GetSubMenu(2);
2558    
2559    
2560     // Load bitmaps from resource. Both m_CheckBitmap and m_UnCheckBitmap
2561     // are member variables of CMainFrame class of type CBitmap.
2562    
2563    
2564     // Associate bitmaps with the "Test" menu item.
2565    
2566     pPopup->TrackPopupMenu(TPM_RIGHTBUTTON,
2567         point.x, point.y, pWndPopupOwner);
2568    
2569 }
2570
2571
2572 int CElephantView::IndentOfBlock(int line) {
2573     return 0;
2574 }
2575
2576 void CElephantView::OnDestroy()
2577 {
2578     CScintillaView::OnDestroy();
2579    
2580    
2581 }
Note: See TracBrowser for help on using the browser.