IDE_ST.patch

Razvan Oprea, 02/14/2011 08:09 AM

Download (33 KB)

View differences:

Assist.cpp (working copy)
24 24
	assist.NoGrid();
25 25
	assist.AddColumn().Margin(0).SetDisplay(Single<CppItemInfoDisplay>());
26 26
	assist.WhenLeftClick = THISBACK(AssistInsert);
27
	
28
	
29
	files.AutoHideSb(true).NoHeader().NoGrid().AddColumn().Margin(0).SetDisplay(Single<IncludeFileItem::MyDisplay>());
30
	files.SetFrame(BlackFrame()).BackPaint();
31
	files.WhenLeftClick = THISBACK(AssistFileInsert);
32
	mAssistSearchStringConfig = "h;hpp";
33
	mUseIncludeAssist = true;
34
//	mWorkerBusy = false;
35
	mIncludePathDepth = 0;
36
	mAssistFrontCharacter = 0;
37
	
38
	
39
	
27 40
	type.NoHeader();
28 41
	type.NoGrid();
29 42
	type.AddColumn();
......
110 123
	return id;
111 124
}
112 125

  
126
inline bool IsSpc(int c)
127
{
128
	return c > 0 && c <= 32;
129
}
130
/**/
131

  
113 132
void AssistEditor::DirtyFrom(int line)
114 133
{
115 134
	if(line >= cachedln) {
......
123 142
int AssistEditor::Ch(int i)
124 143
{
125 144
	if(i >= 0 && i < GetLength()) {
126
		if(i < cachedpos || i - cachedpos > cachedline.GetCount()) {
145
		if(i < cachedpos || i - cachedpos > cachedline.GetCount()) 
146
		{
127 147
			cachedln = GetLine(i);
128 148
			cachedline = GetWLine(cachedln);
129 149
			cachedpos = GetPos(cachedln);
......
149 169
	return max(0, q);
150 170
}
151 171

  
152
bool IsSpc(int c)
153
{
154
	return c > 0 && c <= 32;
155
}
156

  
157 172
void AssistEditor::SkipSpcBack(int& q)
158 173
{
159 174
	while(q > 0 && IsSpc(Ch(q - 1)))
......
285 300

  
286 301
int memcmp_i(const char *s, const char *t, int n)
287 302
{
288
	while(n--) {
303
	while(n--) 
304
	{
289 305
		int q = ToUpper(*s++) - ToUpper(*t++);
290 306
		if(q)
291 307
			return q;
......
299 315
	name = ReadIdBack(GetCursor());
300 316
	assist.Clear();
301 317
	int typei = type.GetCursor() - 1;
302
	for(int p = 0; p < 2; p++) {
318
	
319
	if(typei < 0)
320
	{
303 321
		VectorMap<String, int> over;
304
		for(int i = 0; i < assist_item.GetCount(); i++) {
322
		for(int i = 0; i < assist_item.GetCount(); i++) 
323
		{
305 324
			const CppItemInfo& m = assist_item[i];
325
			if(memcmp_i(name, m.name, name.GetCount()) == 0)
326
			{
327
				int q = over.Find(m.name);
328
				if(m.scope.GetCount() && q < 0)
329
				{
330
					assist.Add(RawToValue(m));
331
					over.Add(m.name);
332
				}
333
			}
334
		}
335
	}
336
	else
337
	{
338
		for(int i = 0; i < assist_item.GetCount(); i++) 
339
		{
340
			const CppItemInfo& m = assist_item[i];
341
			if(	m.typei == typei && (memcmp_i(name, m.name, name.GetCount()) == 0) )
342
			{
343
				if(m.scope.GetCount())
344
					assist.Add(RawToValue(m));
345
			}
346
		}
347
	}
348
	
349
	/*/
350
	for(int p = 0; p < 2; p++) 
351
	{
352
		
353
		VectorMap<String, int> over;
354
		
355
		for(int i = 0; i < assist_item.GetCount(); i++) 
356
		{
357
			const CppItemInfo& m = assist_item[i];
358
			
306 359
			if((typei < 0 || m.typei == typei) &&
307 360
			   (p ? memcmp_i(name, m.name, name.GetCount()) == 0
308 361
			        && memcmp(name, m.name, name.GetCount())
309
			      : memcmp(name, m.name, name.GetCount()) == 0)) {
362
			      : memcmp(name, m.name, name.GetCount()) == 0)) 
363
			      {
310 364
				int q = over.Find(m.name);
311
				if(q < 0 || over[q] == m.typei && m.scope.GetCount()) {
365
				if(q < 0 || over[q] == m.typei && m.scope.GetCount()) 
366
				{
312 367
					assist.Add(RawToValue(m));
313 368
					if(q < 0)
314 369
						over.Add(m.name, m.typei);
......
316 371
			}
317 372
		}
318 373
	}
374
	/**/
319 375
	assist.Sort(0, CppItemInfoOrder);
320 376
}
321 377

  
......
330 386
	assist_cursor = q;
331 387
	assist_type.Clear();
332 388
	assist_item.Clear();
389

  
333 390
	Index<String> in_types;
334 391
	while(iscid(Ch(q - 1)))
335 392
		q--;
336 393
	SkipSpcBack(q);
337 394
	thisback = false;
338
	if(Ch(q - 1) == '(') {
395
	
396
	int Character = Ch(q-1);
397
	
398
	if(Character == '(')
399
	{
339 400
		--q;
340 401
		String id = IdBack(q);
341
		if(id == "THISBACK") {
402
		if(id == "THISBACK") 
403
		{
342 404
			thisback = true;
343 405
			thisbackn = false;
344 406
			GatherItems(parser.current_scope, false, in_types, false);
345 407
			PopUpAssist();
346 408
			return;
347 409
		}
348
		if(id == "THISBACK1" || id == "THISBACK2" || id == "THISBACK3" || id == "THISBACK4") {
410
		if(id == "THISBACK1" || id == "THISBACK2" || id == "THISBACK3" || id == "THISBACK4") 
411
		{
349 412
			thisback = true;
350 413
			thisbackn = true;
351 414
			GatherItems(parser.current_scope, false, in_types, false);
......
353 416
			return;
354 417
		}
355 418
	}
356
	if(Ch(q - 1) == ':') {
419
	else if(Character == ':') 
420
	{
357 421
		while(Ch(q - 1) == ':')
358 422
			q--;
359 423
		Vector<String> tparam;
360 424
		String scope = ParseTemplatedType(Qualify(parser.current_scope, CompleteIdBack(q)), tparam);
361 425
		GatherItems(scope, false, in_types, true);
362 426
	}
363
	else {
427
	else 
428
	{
364 429
		String tp;
365 430
		Vector<String> xp = ReadBack(q);
366 431
		if(xp.GetCount()) {
......
570 635
		}
571 636
	}
572 637
	
573
	if(popup.IsOpen()) {
638
	if(popup.IsOpen()) 
639
	{
574 640
		int k = key & ~K_CTRL;
575 641
		ArrayCtrl& kt = key & K_CTRL ? type : assist;
576 642
		if(k == K_UP || k == K_PAGEUP || k == K_CTRL_PAGEUP || k == K_CTRL_END)
......
587 653
				kt.SetCursor(0);
588 654
				return true;
589 655
			}
590
		if(key == K_ENTER && assist.IsCursor()) {
656
		if(key == K_ENTER && assist.IsCursor()) 
657
		{
591 658
			AssistInsert();
592 659
			return true;
593 660
		}
594
		if(key == K_TAB && !assist.IsCursor() && assist.GetCount()) {
661
		if(key == K_TAB && !assist.IsCursor() && assist.GetCount()) 
662
		{
595 663
			assist.GoBegin();
596 664
			AssistInsert();
597 665
			return true;
598 666
		}
599 667
	}
668
	else if(files.IsOpen())
669
	{
670
		int k = key & ~K_CTRL;
671
		if(k == K_UP || k == K_PAGEUP || k == K_CTRL_PAGEUP || k == K_CTRL_END)
672
			if(files.IsCursor())
673
				return files.Key(k, count);
674
			else {
675
				files.SetCursor(files.GetCount() - 1);
676
				return true;
677
			}
678
		if(k == K_DOWN || k == K_PAGEDOWN || k == K_CTRL_PAGEDOWN || k == K_CTRL_HOME)
679
			if(files.IsCursor())
680
				return files.Key(k, count);
681
			else {
682
				files.SetCursor(0);
683
				return true;
684
			}
685
		if(files.IsCursor())
686
		{
687
			if(key == K_ENTER)
688
			{
689
				AssistFileInsert();
690
				return true;
691
			}
692
		}
693
		else if(key == K_TAB && files.GetCount())
694
		{
695
			files.GoBegin();
696
			AssistFileInsert();
697
			return true;
698
		}
699
		else if(key == '/')
700
		{
701
			if(AssistFileManualInsert())
702
				return true;
703
		}
704
	}
705
	
600 706
	int c = GetCursor();
601 707
	int cc = GetChar(c);
602 708
	int bcc = c > 0 ? GetChar(c - 1) : 0;
603 709
	bool b = CodeEditor::Key(key, count);
604
	if(assist.IsOpen()) {
710
	
711
	if(assist.IsOpen()) 
712
	{
605 713
		if(!iscid(key) &&
606 714
		   !(iscid(cc) && (key == K_DELETE || key == K_RIGHT)) &&
607
		   !(iscid(bcc) && (key == K_LEFT || key == K_BACKSPACE))) {
608
			if(b) {
715
		   !(iscid(bcc) && (key == K_LEFT || key == K_BACKSPACE))) 
716
		   {
717
			if(b) 
718
			{
609 719
				CloseAssist();
610 720
				if(key == '.')
611 721
					Assist();
......
614 724
		else
615 725
			SyncAssist();
616 726
	}
617
	else
618
	if(auto_assist && InCode()) {
619
		if(key == '.' || key == '>' && Ch(GetCursor() - 2) == '-' ||
620
		   key == ':' && Ch(GetCursor() - 2) == ':')
727
	else if(files.IsOpen())
728
	{
729
		if(!(iscid(key) || key == '.' || key == '/' || (key == K_DELETE || key == K_RIGHT) || (bcc != '<' && bcc != '"' && (key == K_LEFT || key == K_BACKSPACE)) ))
730
		{
731
			if(b) 
732
				CloseFiles();
733
		}
734
		else if(/*mWorkerBusy == false &&*/ key != '/')
735
		{
736
			HandleIncludePopup();
737
		}
738
	}
739
	else if((key == '"' || key == '<') && IsIncludeAssistAvailable())
740
	{
741
		if(IncludeAssist())
742
			return true;
743
	}
744
	if(auto_assist && InCode()) 
745
	{
746
		int CH = Ch(GetCursor() - 2);
747
		if(key == '.' || (key == '>' && CH == '-') ||
748
		   (key == ':' && CH == ':')
749
		   )
621 750
			Assist();
622
		else
623
		if(key == '(') {
751
		else if(key == '(') 
752
		{
624 753
			int q = GetCursor() - 1;
625 754
			String id = IdBack(q);
626 755
			if(id == "THISBACK" || id == "THISBACK1" || id == "THISBACK2" || id == "THISBACK3" || id == "THISBACK4")
......
630 759
	return b;
631 760
}
632 761

  
762

  
633 763
void AssistEditor::MouseWheel(Point p, int zdelta, dword keyflags)
634 764
{
635 765
	if(keyflags & K_CTRL)
......
650 780
void AssistEditor::LostFocus()
651 781
{
652 782
	CloseAssist();
783
	if(files.IsOpen())
784
		CloseFiles();
653 785
}
654 786

  
655 787
String AssistEditor::RemoveDefPar(const char *s)
656 788
{
789
	
657 790
	String r;
658 791
	int lvl = 0;
659 792
	bool dp = true;
......
850 983
	return GetIdScope(os, scope, id, done);
851 984
}
852 985

  
853
bool IsPif(const String& l)
986
inline bool IsPif(const String& l)
854 987
{
855 988
	return l.Find("#if") >= 0;
856 989
}
857 990

  
858
bool IsPelse(const String& l)
991
inline bool IsPelse(const String& l)
859 992
{
860 993
	return l.Find("#el") >= 0;
861 994
}
862 995

  
863
bool IsPendif(const String& l)
996
inline bool IsPendif(const String& l)
864 997
{
865 998
	return l.Find("#endif") >= 0;
866 999
}
......
1084 1217
bool AssistEditor::Esc()
1085 1218
{
1086 1219
	bool r = false;
1087
	if(assist.IsOpen()) {
1220
	if(assist.IsOpen()) 
1221
	{
1088 1222
		CloseAssist();
1089 1223
		r = true;
1090 1224
	}
1225
	else if(files.IsOpen())
1226
	{
1227
		CloseFiles();
1228
		r = true;
1229
	}
1091 1230
	if(param_info.IsOpen()) {
1092 1231
		for(int i = 0; i < PARAMN; i++)
1093 1232
			param[i].line = -1;
Browser/Browser.h (working copy)
112 112
	CppItemInfoDisplay() { namestart = false; showtopic = false; }
113 113
};
114 114

  
115
class IncludeFileDisplayClass;
116
struct IncludeFileItem : Moveable<IncludeFileItem> 
117
{
118
	int 			Type;
119
	String 			name;
120
	String			fullPath;
121
				
122
	inline IncludeFileItem(const String & nm,const String& Path,int tp):Type(tp),name(nm),fullPath(Path)
123
	{
124
	}
125
	IncludeFileItem();
126
	IncludeFileItem(const char *);
127
	
128
	inline bool IsFile()const { return (Type > 0); }
129
	inline bool IsFolder()const { return (Type == 0); }
130
	inline bool IsRefreshSymbol()const { return (Type == -1); }
131
	inline bool IsValid()const { return (Type>=0); }
132
	typedef IncludeFileDisplayClass MyDisplay;
133
	
134
	static IncludeFileItem& GetLoadingItem();
135
	static IncludeFileItem& GetEmptyItem();
136
	static IncludeFileItem&	GetInvalidItem();
137
	
138
	static int CompareForArrayCtrl(const Value& va,const Value& vb);
139
};
140

  
141
class IncludeFileDisplayClass : public Display
142
{
143
public:
144
	virtual void Paint0(Draw& draw, const Rect& rc, const Value& v, Color ink, Color paper, dword style) const;
145
	virtual void Paint(Draw& draw, const Rect& rc, const Value& v, Color ink, Color paper, dword style) const;
146
	virtual Size GetStdSize(const Value& q) const;
147
};
148

  
115 149
int SearchItemFilter(int c);
116 150

  
117 151
struct CodeBrowser {
Browser/ItemDisplay.cpp (working copy)
189 189
	            max(16, BrowserFont().Info().GetHeight()));
190 190
}
191 191

  
192

  
193
void IncludeFileDisplayClass::Paint0(Draw& w, const Rect& r, const Value& q,
194
                             Color ink, Color paper, dword s) const
195
{
196
	WString txt;
197
	Font font = StdFont();
198
	int x = r.left+3;
199
	int y = r.top;
200
	int width = r.GetWidth();
201
	
202
	const IncludeFileItem& t = ValueTo<IncludeFileItem>(q);
203
	txt = t.name.ToWString();
204
	if(t.IsFile()) 
205
	{
206
		//const Image & img = BrowserImg::IncludeFile();
207
		const Image & img = CtrlImg::File();
208
		Size isz = img.GetSize();
209
		w.DrawImage(x, y + max((r.Height() - isz.cy) / 2, 0), img);
210
		x += isz.cx + 4;
211
	}
212
	else if(t.IsFolder())
213
	{
214
		//const Image & img = BrowserImg::IncludeFolder();
215
		const Image & img = CtrlImg::Dir();		
216
		Size isz = img.GetSize();
217
		w.DrawImage(x, y + max((r.Height() - isz.cy) / 2, 0), img);
218
		x += isz.cx + 4;
219
	}
220
	else if(t.IsRefreshSymbol())
221
	{
222
		//refresh symbol
223
		//const Image & img = BrowserImg::IncludeRefresh();
224
		const Image & img = CtrlImg::Toggle();
225
		Size isz = img.GetSize();
226
		w.DrawImage(x, y + max((r.Height() - isz.cy) / 2, 0), img);
227
		x += isz.cx + 4;
228
	}
229
	else
230
	{
231
		const Image & img = CtrlImg::Remove();
232
		Size isz = img.GetSize();
233
		w.DrawImage(x, y + max((r.Height() - isz.cy) / 2, 0), img);
234
		x += isz.cx + 4;
235
	}
236
	
237
	int tcy = GetTLTextHeight(txt, font);
238
	int tt = y + max((r.Height() - tcy) / 2, 0);
239
	DrawTLText(w, x, tt, width, txt, font, ink);/**/
240
}
241
void IncludeFileDisplayClass::Paint(Draw& w, const Rect& r, const Value& q,
242
                    Color ink, Color paper, dword s) const
243
{
244
	PaintBackground(w, r, q, ink, paper, s);
245
	Paint0(w, r, q, ink, paper, s);
246
}
247
Size IncludeFileDisplayClass::GetStdSize(const Value& q) const
248
{
249
	Font font = StdFont();
250
	WString txt;
251
	Size isz(0, 0);
252
	
253
	const IncludeFileItem& t = ValueTo<IncludeFileItem>(q);
254
	
255
	txt = t.name.ToWString();
256
	isz = CtrlImg::Dir().GetSize();
257
	
258
	isz.cx += 4;//t.imgspc
259
	
260
	Size sz = GetTLTextSize(txt, font);
261
	
262
	return Size(sz.cx + isz.cx, max(sz.cy, isz.cy));
263
}
264

  
Browser/Util.cpp (working copy)
1 1
#include "Browser.h"
2 2

  
3

  
3 4
void SplitCodeRef(const String& s, String& scope, String& item)
4 5
{
5 6
	int q = s.FindFirstOf("( ");
......
60 61
{
61 62
	return GetCodeRefItem(ref, Null);
62 63
}
64

  
65
IncludeFileItem::IncludeFileItem():Type(-1),name("Loading...")
66
{
67
}
68
IncludeFileItem::IncludeFileItem(const char * text):Type(-2),name(text)
69
{
70
}
71
IncludeFileItem& IncludeFileItem::GetLoadingItem()
72
{
73
	static IncludeFileItem item;
74
	return item;
75
}
76
IncludeFileItem& IncludeFileItem::GetEmptyItem()
77
{
78
	static IncludeFileItem item("No files.");
79
	return item;
80
}
81
IncludeFileItem& IncludeFileItem::GetInvalidItem()
82
{
83
	static IncludeFileItem item("Invalid path!");
84
	return item;
85
}
86

  
87
int IncludeFileItem::CompareForArrayCtrl(const Value& va,const Value& vb)
88
{
89
	const IncludeFileItem& a = ValueTo<IncludeFileItem>(va);
90
	const IncludeFileItem& b = ValueTo<IncludeFileItem>(vb);
91
	return a.name.Compare(b.name);
92
}
93
                                                
ide.h (working copy)
329 329
	int            cachedpos;
330 330
	int            cachedln;
331 331
	
332
	
333
	//----------------------------------------------
334
	ArrayCtrl					files;//control to display the include assist
335
	Array<IncludeFileItem>		mMainIncludeFiles;//will hold all the files from VC Include directories + all files/folders from the current assembly
336
	Array<IncludeFileItem>		mTempIncludeFiles;//temporarely hold some scanned filed depending on context
337
	Vector<String> 				mIncludeSearchExtTypes;	
338
	Vector<String>				mIncludePathStack;
339

  
340
	int							mIncludePathDepth;	
341
	
342
	String						mFolderNameStringCache;
343
	String						mCurentBuildMethod;//keeps the build method saved in order to check for changes
344
	//bool						mWorkerBusy;//scanning some files in the background?
345
	int							mAssistFrontCharacter;//stores the character with which include assist was started
346
	
347
	bool						mUseIncludeAssist;
348
	String						mAssistSearchStringConfig;
349
	//----------------------------------------------
350
	
351
	
332 352
	RichTextCtrl   param_info;
333 353
	String         param_qtf;
334 354
	struct ParamInfo {
......
344 364
	ParamInfo param[PARAMN];
345 365
	int       parami;
346 366
	
367
	
368
	//----------------------------------------------
369
	void			PopUpFiles();
370
	void			ShapeFilesPopup();
371
	void 			CloseFiles();
372
	void 			SyncFiles();
373
	void			InsertFiles(bool get_local);
374
	bool 			IncludeAssist();//returnes true if file assist was opened
375
	
376
	void			ScanFrontFiles();
377
	void			ScanLocalFiles();
378
	void			NotifyScanFinish();
379
	bool			AssistFileManualInsert();
380
	void 			AssistFileInsert();
381
	int 			ReadPathBack(int q);//returnes true if has the character < or " in front
382
	bool			ComposeSearchPath();
383
	bool			UpdateFileSync(int count);
384
	void			HandleIncludePopup();
385
	void			InclLocateFolderPath(int &left,int &right);
386
	void 			InsertInvalidPath();
387
	bool			IsBuildMethodChanged()const;
388
	bool			IsIncludeAssistAvailable()const;
389
	void			NotifyIncludeConfigChange();
390
	//----------------------------------------------
391
	
347 392
	void           PopUpAssist(bool auto_insert = false);
348 393
	void           CloseAssist();
349 394
	void           Assist();
......
610 655
	String    recent_stdout_file;
611 656

  
612 657
// ------------------------------------
613

  
658
	//CoWork		mWork;
659
// ------------------------------------
614 660
	One<Debugger> debugger;
615 661

  
616 662
	Time      start_time;
ide.lay (working copy)
442 442
	ITEM(Option, tabs_serialize, SetLabel(t_("Persistent tabs")).LeftPosZ(272, 108).TopPosZ(108, 16))
443 443
END_LAYOUT
444 444

  
445
LAYOUT(SetupAssistLayout, 520, 124)
446
	ITEM(Option, assist, SetLabel(t_("Automatic assist")).HSizePosZ(4, 280).TopPosZ(4, 16))
445
LAYOUT(SetupAssistLayout, 440, 124)
446
	ITEM(Option, assist, SetLabel(t_("Automatic assist")).HSizePosZ(4, 200).TopPosZ(4, 16))
447 447
	ITEM(Option, commentdp, SetLabel(t_("Comment out default parameters")).Tip(t_("Comment out default parameters when converting declaration to definition instead of removing them")).LeftPosZ(4, 236).TopPosZ(24, 16))
448 448
	ITEM(Option, auto_enclose, SetLabel(t_("[ { ( \" / * enclose selection")).LeftPosZ(4, 236).TopPosZ(44, 16))
449 449
	ITEM(Option, mark_lines, SetLabel(t_("Mark lines with errors, warning and changes")).LeftPosZ(4, 236).TopPosZ(64, 16))
450 450
	ITEM(Option, barline, SetLabel(t_("Highlight line in the left bar")).LeftPosZ(4, 236).TopPosZ(84, 16))
451 451
	ITEM(Option, qtfsel, SetLabel(t_("QTF designer edits selection")).LeftPosZ(4, 236).TopPosZ(104, 16))
452 452
	ITEM(Option, header_guards, SetLabel(t_("Insert guards to new headers")).LeftPosZ(272, 164).TopPosZ(4, 16))
453
	ITEM(Switch, insert_include, SetLabel(t_("No #include in new sources\n#include first\n#include previous")).LeftPosZ(272, 156).TopPosZ(24, 52))
453
	ITEM(Option, use_assist, SetLabel(t_("Start Assist for #include")).Tip(t_("In c/c++ code the assist will popup when needed showing you the files you can include.")).LeftPosZ(272, 164).TopPosZ(80, 16))
454
	ITEM(Switch, insert_include, SetLabel(t_("No #include in new sources\n#include first\n#include previous")).LeftPosZ(272, 164).TopPosZ(24, 52))
455
	ITEM(EditString, include_assist_headers, Tip(t_("The extensions of the files to search for will be specified here separated by ';'")).LeftPosZ(272, 164).TopPosZ(100, 19))
454 456
END_LAYOUT
455 457

  
456 458
LAYOUT(SetupIdeLayout, 512, 264)
ide.upp (working copy)
40 40
	Bottom.cpp,
41 41
	t.cpp,
42 42
	Cpp.cpp,
43
	IncludeAssist.cpp,
43 44
	Assist.cpp,
44 45
	ParamInfo.cpp,
45 46
	Navigator.cpp,
idebar.cpp (working copy)
427 427
	}
428 428

  
429 429
	BuildFileMenu(menu);
430

  
430
	
431 431
	menu.MenuSeparator();
432 432

  
433 433
	menu.Add("Stop on errors", THISBACK(ToggleStopOnErrors))
idewin.cpp (working copy)
79 79
	}
80 80
}
81 81

  
82
void Ide::Serialize(Stream& s) {
83
	int version = 18;
82
void Ide::Serialize(Stream& s) 
83
{
84
	int version = 19;
84 85
	s.Magic(0x1234);
85 86
	s / version;
86 87
	s % main;
......
101 102
	s % font2;
102 103
	s % show_status_bar;
103 104
	s % toolbar_in_row;
105
	
106
	if(version >= 19)
107
	{
108
		s % editor.mUseIncludeAssist;
109
		s % editor.mAssistSearchStringConfig;
110
		/*if(s.IsLoading())
111
			editor.NotifyIncludeConfigChange();/**/
112
	}
104 113
	if(version >= 18) {
105 114
		s % filetabs;
106 115
	}
......
1015 1024
		ide.editor_bottom.Zoom(0);
1016 1025
		ide.right_split.Zoom(0);
1017 1026
		ide.UpdateFormat();
1027
		ide.editor.NotifyIncludeConfigChange();
1028
		
1018 1029
		RestoreKeys(LoadFile(ConfigFile("ide.key")));
1019 1030
		ide.editor.LoadHlStyles(LoadFile(ConfigFile("ide.colors")));
1020 1031
		if(FileExists(ConfigFile("developide"))) {
IncludeAssist.cpp (revision 0)
1
#include "ide.h"
2

  
3

  
4
int memcmp_i(const char *s, const char *t, int n);
5
bool IsFolderChar(int c)
6
{
7
	//need all of them???
8
	return (iscid(c) || (c == '!')|| (c == '@')|| (c == '#')|| (c == '$')|| (c == '%')|| (c == '^')|| (c == '&')|| (c == '(')|| (c == ')')|| (c == '_')
9
	|| (c == '-')|| (c == '+')|| (c == '=')|| (c == ',')|| (c == '.')|| (c == '`')|| (c == '~'));
10
	//posix folders have even more characters
11
}
12
inline bool IsSpc0(int c)
13
{
14
	return c > 0 && c <= 32;
15
}
16
bool AssistEditor::IsIncludeAssistAvailable()const
17
{
18
	return mUseIncludeAssist;
19
}
20
int AssistEditor::ReadPathBack(int q)
21
{
22
	int ch;
23
	int ids = q;
24
	int len;
25
	int depth = 0;
26
#ifdef PLATFORM_WIN32
27
	int depth2 = 0;
28
#endif
29
	if(ids > 0)
30
	{
31
		ch = GetChar(ids - 1);
32
		if(IsSpc0(ch))
33
			return -1;
34
		while(ids > 0 && IsFolderChar(ch))
35
		{
36
			ids--;
37
			ch = GetChar(ids - 1);
38
		}
39
		len = q - ids;
40
#ifdef PLATFORM_WIN32
41
		while(ids > 0 && (IsFolderChar(ch) || ch == '/' || ch == '.' || ch == '\\'))
42
#else
43
		while(ids > 0 && (IsFolderChar(ch) || ch == '/' || ch == '.'))
44
#endif
45
		{
46
			depth += (int)(ch == '/');
47
#ifdef PLATFORM_WIN32
48
			depth2 += (int)(ch == '\\');
49
#endif	
50

  
51
			ids--;
52
			ch = GetChar(ids - 1);
53
		}
54
		if(!((ch == '<') || (ch == '"')))
55
			return -1;
56
	}
57
	else 
58
		return -1;
59
	mFolderNameStringCache.Clear();
60
	while(len!=0 && len < GetLength())
61
	{
62
		ch = GetChar(q-len);
63
		//path << (char)ch;
64
		mFolderNameStringCache << (char)ch;
65
		len--;
66
	}
67
#ifdef PLATFORM_WIN32
68
	return depth + depth2/2;//will this work??
69
#else
70
	return depth;
71
#endif
72
}
73

  
74
bool AssistEditor::IncludeAssist()
75
{
76
	CloseFiles();
77
	
78
	int q = GetCursor();
79
	int Character = Ch(q-1);
80
	
81
	if(Character == '"' || Character == '<')//this check should not happen
82
	{
83
		--q;
84
		SkipSpcBack(q);
85
		String id = IdBack(q);
86
		
87
		//if(id == "include")
88
		if(memcmp_i(id,"include",id.GetCount()) == 0)
89
		{
90
			mAssistFrontCharacter = Character;
91
//			if(mWorkerBusy == false)
92
//			{
93
				
94
				InsertFiles(Character == '"');
95
				PopUpFiles();
96
				return true;
97
//			}
98
		}
99
	}
100
	return false;
101
}
102

  
103
void			AssistEditor::NotifyIncludeConfigChange()
104
{
105
	Vector<String> local = Split(mAssistSearchStringConfig,";");
106

  
107
	mIncludeSearchExtTypes.Clear();
108
	mIncludeSearchExtTypes.Reserve(local.GetCount()+1);
109
	mIncludeSearchExtTypes.Add("*");//add the folder
110
	String tmp = "*.";
111
	for(int i = 0; i < local.GetCount(); i++)
112
	{
113
		if(local[i].GetCount() != 0)
114
			mIncludeSearchExtTypes.Add(tmp+local[i]);
115
	}
116
	mCurentBuildMethod.Clear();
117
}
118

  
119
void			AssistEditor::ShapeFilesPopup()
120
{
121
	int lcy = max(16, BrowserFont().Info().GetHeight());
122
	int cy;
123
	
124
	if(files.GetCount() > 0)
125
		cy = lcy * min(16,(files.GetCount()-1)) + HeaderCtrl::GetStdHeight() + 4;
126
	else
127
		cy = 4 + HeaderCtrl::GetStdHeight() ;
128

  
129
	files.SetLineCy(lcy);
130
	
131
	Point p = GetCaretPoint() + GetScreenView().TopLeft();
132
	Rect wa = GetWorkArea();
133
	int cx = min(wa.Width() - 100, HorzLayoutZoom(250));
134
	
135
	if(p.x + cx > wa.right)
136
		p.x = wa.right - cx;
137
	if(p.y + cy + GetFontSize().cy < wa.bottom)
138
		files.SetRect(p.x, p.y + GetFontSize().cy, cx, cy);
139
	else
140
		files.SetRect(p.x, p.y - cy, cx, cy);
141
}
142
void			AssistEditor::PopUpFiles()
143
{
144
	ShapeFilesPopup();
145
	files.Ctrl::PopUp(this, false, false, true);
146
}
147
bool AssistEditor::UpdateFileSync(int count)
148
{
149
	if(count == 0)
150
	{
151
		mIncludePathDepth = 0;
152
		mIncludePathStack.Clear();
153
		if(mAssistFrontCharacter == '"')
154
		{
155
//			mWorkerBusy = true;
156
			files.Clear();
157
			files.Add(RawToValue(IncludeFileItem::GetLoadingItem()));
158
			mIncludePathStack.Add(GetFileDirectory(theide->editfile));
159
//			theide->mWork.Do(THISBACK(ScanLocalFiles));
160
			ScanLocalFiles();
161
		}
162
		else if(IsBuildMethodChanged())
163
		{
164
//			mWorkerBusy = true;
165
			files.Clear();
166
			files.Add(RawToValue(IncludeFileItem::GetLoadingItem()));
167
			mCurentBuildMethod = theide->method;
168
			mIncludePathStack.Clear();
169
//			theide->mWork.Do(THISBACK(ScanFrontFiles));
170
			ScanFrontFiles();
171
		}
172
		else
173
			return true;
174
	}
175
	else
176
	{
177
		if(count < mIncludePathDepth)
178
		{
179
			while(mIncludePathDepth != count)
180
			{
181
				mIncludePathStack.Pop();
182
				mIncludePathDepth--;
183
			}
184
		}
185
		else
186
		{
187
			//...u lalalaaa
188
		}
189
//		mWorkerBusy = true;
190
//		theide->mWork.Do(THISBACK(ScanLocalFiles));
191
		ScanLocalFiles();
192
	}
193
	return false;
194
}
195
void AssistEditor::InclLocateFolderPath(int &left,int &right)
196
{
197
	while(left > 0 && IsFolderChar(Ch(left-1)))
198
		left--;
199
	if(right<GetLength())
200
	{
201
		int temp = Ch(right);
202
#ifdef PLATFORM_WIN32
203
		while(right < GetLength() && (IsFolderChar(temp) || temp == '/' || temp == '\\'))
204
#else
205
		while(right < GetLength() && (IsFolderChar(temp) || temp == '/'))
206
#endif
207
			temp = Ch(++right);
208
	}
209
}
210
bool AssistEditor::IsBuildMethodChanged()const
211
{
212
	return (mCurentBuildMethod != theide->method);
213
}
214
bool AssistEditor::AssistFileManualInsert()
215
{
216
	if(mFolderNameStringCache == "..")
217
	{
218
		if(mIncludePathStack.GetCount() == 0)
219
		{
220
			mTempIncludeFiles.Clear();
221
			InsertInvalidPath();
222
		}
223
		else
224
		{
225
			String new_path = mIncludePathStack.Top();
226
#ifdef PLATFORM_WIN32
227
			if(new_path.GetLength() <= 3)
228
#else
229
			if(new_path == "/" || new_path.GetCount()<=1)
230
#endif
231
			{
232
				//invalid Path
233
				mTempIncludeFiles.Clear();
234
				InsertInvalidPath();
235
			}
236
			else
237
			{
238
				mIncludePathDepth++;
239
				new_path.Trim(new_path.GetLength()-1);
240
				new_path = GetFileDirectory(new_path);
241
				mIncludePathStack.Add(new_path);
242
//				mWorkerBusy = true;
243
//				theide->mWork.Do(THISBACK(ScanLocalFiles));
244
				ScanLocalFiles();
245
			}
246
		}
247
		return false;
248
	}
249
	
250
	int cursor_pos = GetCursor();
251
	int cursor_aux_pos = cursor_pos;
252
	String txt;
253
	Array<IncludeFileItem> & touse = (mIncludePathDepth==0 && mAssistFrontCharacter == '<') ? mMainIncludeFiles : mTempIncludeFiles;
254
	int found_index = -1;
255
	
256
	//find best fit for the name
257
	for(int i = 0; i < touse.GetCount(); i++) 
258
	{
259
		const IncludeFileItem & item = touse[i];
260
		if(!item.IsFolder())
261
			continue;
262
		if(mFolderNameStringCache == item.name)//exact fit
263
		{
264
			mIncludePathDepth++;
265
			mIncludePathStack.Add(AppendFileName(item.fullPath,item.name+"/"));
266
//			mWorkerBusy = true;
267
//			theide->mWork.Do(THISBACK(ScanLocalFiles));
268
			ScanLocalFiles();
269
			return false;
270
		}
271
		else if(memcmp_i(item.name,mFolderNameStringCache,item.name.GetCount()) == 0)
272
			found_index = i;
273
	}
274
	if(found_index != -1)
275
	{
276
		const IncludeFileItem & item = touse[found_index];
277
		txt = item.name;
278
		InclLocateFolderPath(cursor_pos,cursor_aux_pos);
279
		
280
		Remove(cursor_pos, cursor_aux_pos - cursor_pos);
281
		SetCursor(cursor_pos);
282
		
283
		mIncludePathDepth++;
284
		txt+="/";
285
		Paste(ToUnicode(txt, CHARSET_WIN1250));
286

  
287
		mIncludePathStack.Add(AppendFileName(item.fullPath,txt));
288
//		mWorkerBusy = true;
289
//		theide->mWork.Do(THISBACK(ScanLocalFiles));
290
		ScanLocalFiles();
291
		
292
		return true;
293
	}
294
	else
295
	{
296
		InsertInvalidPath();
297
		return false;
298
	}
299
}
300
void AssistEditor::AssistFileInsert()
301
{
302
//	if(mWorkerBusy)
303
//		return;
304
	
305
	String txt;
306
	
307
	int cursor_pos = GetCursor();
308
	int cursor_aux_pos = cursor_pos;
309
	int depth = 0;
310
	
311
	const IncludeFileItem& item = ValueTo<IncludeFileItem>(files.Get(0));
312
	if(!item.IsValid())
313
		return;
314
	
315
	txt = item.name;
316
	InclLocateFolderPath(cursor_pos,cursor_aux_pos);
317
	
318
	Remove(cursor_pos, cursor_aux_pos - cursor_pos);
319
	SetCursor(cursor_pos);
320
		
321
	if(item.IsFile())
322
	{
323
		if(mAssistFrontCharacter == '"')
324
			txt+="\"";
325
		else if(mAssistFrontCharacter == '<')
326
			txt+=">";
327
			
328
		Paste(ToUnicode(txt, CHARSET_WIN1250));
329
		CloseFiles();
330
		IgnoreMouseUp();
331
	}
332
	else
333
	{
334
		mIncludePathDepth++;
335
		txt+="/";
336
		Paste(ToUnicode(txt, CHARSET_WIN1250));
337

  
338
		mIncludePathStack.Add(AppendFileName(item.fullPath,txt));
339
//		mWorkerBusy = true;
340
//		theide->mWork.Do(THISBACK(ScanLocalFiles));
341
		ScanLocalFiles();
342
	}
343
}
344
void AssistEditor::InsertInvalidPath()
345
{
346
	mIncludePathDepth++;
347
	mIncludePathStack.Add();
348
	files.Clear();
349
	files.Add(RawToValue(IncludeFileItem::GetInvalidItem()));
350
	ShapeFilesPopup();
351
}
352
void AssistEditor::NotifyScanFinish()
353
{
354
	if(files.IsOpen())//still opened then use 
355
	{
356
		int Count = (mIncludePathDepth==0 && mAssistFrontCharacter == '<') ? mMainIncludeFiles.GetCount() : mTempIncludeFiles.GetCount();
357

  
358
		files.Clear();
359
		if(Count == 0)
360
		{
361
			files.Add(RawToValue(IncludeFileItem::GetEmptyItem()));
362
			ShapeFilesPopup();
363
		}
364
		else
365
		{
366
			int rezult = ReadPathBack(GetCursor());
367
			if(rezult != -1)
368
			{
369
				if(rezult != mIncludePathDepth)
370
				{
371
					if(UpdateFileSync(rezult))
372
					{
373
						SyncFiles();
374
						ShapeFilesPopup();
375
					}
376
				}
377
				else
378
				{
379
					SyncFiles();
380
					ShapeFilesPopup();
381
				}
382
			}
383
			else
384
				CloseFiles();
385
		}
386
	}
387
//	mWorkerBusy = false;
388
}
389
void AssistEditor::HandleIncludePopup()
390
{
391
	int rezult = ReadPathBack(GetCursor());
392
	if(rezult != -1)
393
	{
394
		if(rezult != mIncludePathDepth)
395
		{
396
			if(UpdateFileSync(rezult))
397
			{
398
				SyncFiles();
399
				ShapeFilesPopup();
400
			}
401
		}
402
		else 
403
		{
404
			SyncFiles();
405
			ShapeFilesPopup();
406
		}
407
	}
408
	else
409
		CloseFiles();
410
}
411
#ifdef PLATFORM_LINUX
412
void GCC_HARDWIRE_INCLUDE_HACK(Vector<String> & l)
413
{
414
	String a = "/usr/include";
415
	String b = "/usr/local/include";
416
	
417
	bool oka = true;
418
	bool okb = true;
419
	for(int i = 0; i < l.GetCount(); i++)
420
	{
421
		String s = NativePath(l[i]);
422
		if(s == a)
423
			oka = false;
424
		else if(s == b)
425
			okb = false;
426
	}
427
	if(oka)
428
		l.Add(a);
429
	if(okb)
430
		l.Add(b);
431
}
432
#endif
433

  
434
void AssistEditor::ScanFrontFiles()
435
{
436
	VectorMap<String, String> BuildMethodMap = GetMethodVars(theide->method);
437
	Vector<String> SearchPaths = SplitDirs(GetVar("UPP") + ';' + BuildMethodMap.Get("INCLUDE", ""));
438
	
439
#ifdef PLATFORM_WIN32
440
	const char * intermediate = "\\";
441
#else
442

  
443
#ifdef PLATFORM_LINUX
444
	GCC_HARDWIRE_INCLUDE_HACK(SearchPaths);
445
#endif
446
	const char * intermediate = "/";
447

  
448
#endif
449

  
450
	mMainIncludeFiles.Clear();
451
	for(int i = 0; i < SearchPaths.GetCount(); i++)
452
		for(int j = 0; j < mIncludeSearchExtTypes.GetCount(); j++)
453
			for(FindFile ff(SearchPaths[i] + intermediate + mIncludeSearchExtTypes[j]);ff;ff.Next()){
454
				if(ff.IsFolder() || (ff.IsFile() && j != 0))
455
					mMainIncludeFiles.Add(IncludeFileItem(ff.GetName(),SearchPaths[i],j));
456
				ProcessEvents();
457
			}
458
	Call(THISBACK(NotifyScanFinish));
459
}
460

  
461
void AssistEditor::ScanLocalFiles()
462
{
463
	const String &top = mIncludePathStack.Top();
464
	mTempIncludeFiles.Clear();
465
	if(top.GetCount()!=0)
466
	{
467
		String search_path = NativePath(top);
468
		for(int i = 0; i < mIncludeSearchExtTypes.GetCount(); i++)
469
			for(FindFile ff(search_path + mIncludeSearchExtTypes[i]);ff;ff.Next()){
470
				if(ff.IsFolder() || (ff.IsFile() && i != 0))
471
					mTempIncludeFiles.Add(IncludeFileItem(ff.GetName(),search_path,i));
472
				ProcessEvents();
473
			}
474
	}
475
	Call(THISBACK(NotifyScanFinish));
476
}
477
void AssistEditor::InsertFiles(bool get_local)
478
{
479
	if(get_local)
480
	{
481
//		mWorkerBusy = true;
482
		if(files.GetCount() == 0)
483
			files.Add(RawToValue(IncludeFileItem::GetLoadingItem()));
484
		mIncludePathStack.Add(GetFileDirectory(theide->editfile));
485
//		theide->mWork.Do(THISBACK(ScanLocalFiles));
486
		ScanLocalFiles();
487
	}
488
	else if(IsBuildMethodChanged())
489
	{
490
		
491
//		mWorkerBusy = true;
492
		files.Add(RawToValue(IncludeFileItem::GetLoadingItem()));
493
		mCurentBuildMethod = theide->method;
494
//		theide->mWork.Do(THISBACK(ScanFrontFiles));
495
		ScanFrontFiles();
496
}
497
	else
498
	{
499
		Array<IncludeFileItem> & touse = (mIncludePathDepth==0 && mAssistFrontCharacter == '<') ? mMainIncludeFiles : mTempIncludeFiles;
500
		for(int i = 0; i < touse.GetCount(); i++)
501
			files.Add(RawToValue(touse[i]));
502
		files.Sort(0,IncludeFileItem::CompareForArrayCtrl);
503
	}
504
}
505
void AssistEditor::SyncFiles()
506
{
507
	Array<IncludeFileItem> & touse = (mIncludePathDepth==0 && mAssistFrontCharacter == '<') ? mMainIncludeFiles : mTempIncludeFiles;
508
	//int active_count = files.GetCount();
509
	files.Clear();
510
	if(mFolderNameStringCache.GetCount() == 0)
511
	{
512
		for(int i = 0; i < touse.GetCount(); i++)
513
			files.Add(RawToValue(touse[i]));
514
		//active_count -= touse.GetCount();
515
	}
516
	else
517
	{
518
		for(int i = 0; i < touse.GetCount(); i++) 
519
		{
520
			const IncludeFileItem & item = touse[i];
521
			if(memcmp_i(mFolderNameStringCache,item.name,mFolderNameStringCache.GetCount())==0)
522
			{
523
				files.Add(RawToValue(item));
524
				//active_count--;
525
			}
526
		}
527
	}
528
	if(files.GetCount() == 0)
529
		files.Add(RawToValue(IncludeFileItem::GetEmptyItem()));
530
	else
531
		files.Sort(0,IncludeFileItem::CompareForArrayCtrl);
532
	//return active_count;
533
};
534
void AssistEditor::CloseFiles()
535
{
536
	mFolderNameStringCache.Clear();
537
	mIncludePathStack.Clear();
538
	files.Close();
539
	files.Clear();
540
	mIncludePathDepth = 0;
541
}
init (working copy)
17 17
#include "usvn/init"
18 18
#include "TextDiffCtrl/init"
19 19
#include "TabBar/init"
20
#include "Docedit/init"
21 20
#endif
Methods.cpp (working copy)
402 402
		int c = m.Run();
403 403
		if(c == IDCANCEL)
404 404
			break;
405
		if(c == IDOK && m.Save()) {
405
		if(c == IDOK && m.Save()) 
406
		{
406 407
			use_target = m.use_target;
408
			editor.NotifyIncludeConfigChange();
407 409
			break;
408 410
		}
409 411
	}
Setup.cpp (working copy)
390 390
		(assist.mark_lines, mark_lines)
391 391
		(assist.qtfsel, qtfsel)
392 392
		(assist.assist, editor.auto_assist)
393
		(assist.use_assist, editor.mUseIncludeAssist)
394
		(assist.include_assist_headers, editor.mAssistSearchStringConfig)
393 395

  
394 396
		(ide.showtime, showtime)
395 397
		(ide.show_status_bar, show_status_bar)
......
481 483
		FlushFile();
482 484
		FileCursor();
483 485
	}
486
	editor.NotifyIncludeConfigChange();
484 487
	FileSetTime(ConfigFile("version"), ToTime(~ide.showtimeafter));
485 488
	SaveLoadPackage();
486 489
	SyncCh();
version.h (working copy)
1
#define IDE_VERSION    ""
1
#define IDE_VERSION    "3201-Arch"