idebar.cpp

Zbigniew Rebacz, 01/05/2014 01:36 AM

Download (21.3 KB)

 
1
#include "ide.h"
2

    
3
#define KEYGROUPNAME "Ide"
4
#define KEYNAMESPACE IdeKeys
5
#define KEYFILE      <ide/ide.key>
6
#include             <CtrlLib/key_source.h>
7

    
8
using namespace IdeKeys;
9

    
10
void Ide::PackageMenu(Bar& menu) {
11
        Project(menu);
12
}
13

    
14
void Ide::FileBookmark(Bar& menu) {
15
        int i;
16
        for(i = 0; i < 10; i++) {
17
                const Bookmark& b = bookmark[i];
18
                String txt = Format("Goto bookmark &%d", i);
19
                if(!b.file.IsEmpty())
20
                        txt << " (" << bookmark[i].file << ')';
21
                menu.Add(!b.file.IsEmpty(), txt, THISBACK1(BookKey, K_CTRL_0 + i))
22
                        .Key(K_CTRL_0 + i);
23
        }
24
        menu.MenuBreak();
25
        for(i = 0; i < 10; i++)
26
                menu.Add("Set", THISBACK1(BookKey, K_SHIFT_CTRL_0 + i))
27
                    .Key(K_SHIFT_CTRL_0 + i);
28
}
29

    
30
void Ide::File(Bar& menu) {
31
        menu.Add(AK_SETMAIN, THISBACK(NewMainPackage))
32
                .Help("Select global configuration (var), select / add main project package");
33

    
34
        menu.AddMenu(AK_EDITFILE, CtrlImg::open(), THISBACK(EditAnyFile))
35
                .Help("Select any file in file selector and open it in editor");
36
        menu.AddMenu(!IsNull(GetOpposite()), AK_OPPOSITE, IdeImg::opposite(), THISBACK(GoOpposite))
37
                .Help("Switch between source and header file");
38
        menu.AddMenu(AK_SAVEFILE, CtrlImg::save(), THISBACK(DoSaveFile))
39
                .Help("Save current file");
40
        if(!designer)
41
                menu.AddMenu(CanToggleReadOnly(), AK_READONLY, IdeImg::read_only(), THISBACK(ToggleReadOnly))
42
                        .Check(editor.IsReadOnly())
43
                        .Help("Set / clear read-only flag for current file");
44

    
45
        menu.AddMenu(!designer, AK_PRINT, CtrlImg::print(), THISBACK(Print));
46

    
47
//        menu.Add("Export project", THISBACK(ExportProject))
48
//                .Help("Copy all project files into given directory");
49

    
50
        if(menu.IsMenuBar())
51
        {
52
                menu.Separator();
53
                menu.Add(AK_CLOSETAB, THISBACK(ClearTab))
54
                    .Help("Close the current file tab");
55
                menu.Add(AK_CLOSETABS, THISBACK(ClearTabs))
56
                    .Help("Close all file tabs");
57
                menu.Add("Go back", THISBACK(HistoryBk))
58
                    .Key(K_ALT_LEFT);
59
                menu.Add("Go forward", THISBACK(HistoryFw))
60
                    .Key(K_ALT_RIGHT);
61
                if(!designer) {
62
                        menu.Add("Bookmarks", THISBACK(FileBookmark))
63
                                .Help("Set one of available bookmarks (1..9, 0) on current file");
64
                        menu.MenuSeparator();
65
                }
66
                menu.Add("Show/hide bottom pane", THISBACK(SwapBottom))
67
                        .Check(IsBottomShown())
68
                        .Key(K_ESCAPE)
69
                        .Help("Show / hide bottom pane (with console, calc and browser tabs)");
70
        }
71

    
72
        menu.Add(AK_PACKAGESFILES, THISBACK(SwapPackagesFiles));
73

    
74
        menu.MenuSeparator();
75

    
76
        bool split = editorsplit.GetZoom() < 0;
77
        menu.Add(AK_SPLIT, THISBACK1(KeySplit, false))
78
            .Check(split && editorsplit.IsVert());
79
        menu.Add(AK_VSPLIT, THISBACK1(KeySplit, true))
80
            .Check(split && editorsplit.IsHorz());
81
        menu.Add(split, AK_SWAP, THISBACK(SwapEditors));
82

    
83
        menu.MenuSeparator();
84
        
85
        menu.Add(AK_OPENFILEDIR, THISBACK(OpenFileFolder));
86
        menu.MenuSeparator();
87

    
88
        menu.Add(AK_STATISTICS, THISBACK(Statistics))
89
                .Help("Display various statistics");
90

    
91
        menu.Add("Elapsed times..", THISBACK(Times));
92

    
93
        menu.Add(AK_EXIT, THISBACK(Exit));
94
}
95

    
96
void Ide::EditSpecial(Bar& menu)
97
{
98
        menu.Add(AK_SPACESTOTABS, THISBACK(EditMakeTabs))
99
                .Help("Convert leading blanks on each line to tabs");
100
        menu.Add(AK_TABSTOSPACES, THISBACK(EditMakeSpaces))
101
                .Help("Convert all tabs to spaces");
102
        menu.Add(AK_LINEENDINGS, THISBACK(EditMakeLineEnds))
103
                .Help("Remove tabs and spaces at line endings");
104
        menu.Add(AK_TRANSLATESTRING, THISBACK(TranslateString))
105
                .Help("Mark the current selection as translated string");
106
        menu.Add(AK_SWAPCHARS, THISBACK(SwapChars))
107
            .Help("Transpose characters");
108
        menu.Add(AK_COPYWORD, THISBACK(CopyWord))
109
            .Help("Copy the current identifier to the clipboard");
110
        menu.Add(AK_FORMATCODE, THISBACK(FormatCode))
111
            .Help("Reformat code in editor");
112
        menu.Add(AK_TOUPPER, THISBACK(TextToUpper))
113
            .Help("Convert letters in selection to uppercase"); 
114
        menu.Add(AK_TOLOWER, THISBACK(TextToLower))
115
            .Help("Convert letters in selection to lowercase"); 
116
        menu.Add(AK_TOASCII, THISBACK(TextToAscii))
117
                .Help("Covert text to 7-bit ASCII removing all accents and special symbols");
118
        menu.Add(AK_INITCAPS, THISBACK(TextInitCaps))
119
            .Help("Capitalize the first character of words in selection"); 
120
        menu.Add(AK_SWAPCASE, THISBACK(SwapCase))
121
            .Help("Swap the case of letters in selection"); 
122
        menu.Add(AK_TOCSTRING, THISBACK(ToCString))
123
            .Help("Convert selection to CString");
124
}
125

    
126
void Ide::SearchMenu(Bar& menu)
127
{
128
        if(!designer) {
129
                menu.Add(AK_FIND, THISBACK(EditFind))
130
                        .Help("Search for text or text pattern");
131
                menu.Add(AK_REPLACE, THISBACK(EditReplace))
132
                        .Help("Search for text or text pattern, with replace option");
133
//                menu.Add(AK_FINDSEL, THISBACK(EditFindReplacePickText))
134
//                        .Help("Show find / replace dialog & set active text as the 'find' text");
135

    
136
                menu.Add(AK_FINDNEXT, THISBACK(EditFindNext))
137
                        .Help("Find next occurrence");
138
                menu.Add(AK_FINDPREV, THISBACK(EditFindPrevious))
139
                        .Help("Find previous occurrence");
140

    
141
                menu.MenuSeparator();
142

    
143
                menu.Add(AK_FINDSTRING, THISBACK1(FindString, false))
144
                        .Help("Find any ordinary string constant (\"\" - delimited)");
145
                menu.Add(AK_FINDSTRINGBACK, THISBACK1(FindString, true))
146
                        .Help("Find any ordinary string constant (\"\" - delimited) backwards");        
147
                menu.MenuSeparator();
148
        }
149
        menu.Add(AK_FINDINFILES, THISBACK1(FindInFiles, false))
150
                .Help("Find text or text pattern in subtree of given path");
151
        menu.Add(AK_REPLACEINFILES, THISBACK1(FindInFiles, true))
152
                .Help("Find text or text pattern in subtree of given path, with replace option(s)");
153
        menu.Add(AK_FINDFILE, THISBACK(FindFileName))
154
                .Help("Locate file by filename (use *, ? when you're not sure)");
155
}
156

    
157
void Ide::Edit(Bar& menu) {
158
        if(designer) {
159
                if(FileExists(designer->GetFileName())) {
160
                        menu.Add(AK_EDITASTEXT, THISBACK(EditAsText))
161
                            .Help("Edit as text file (do not use a designer)");
162
                        menu.MenuSeparator();
163
                }
164
                if(menu.IsMenuBar())
165
                        designer->EditMenu(menu);
166
        }
167
        else {
168
                String selection = editor.GetSelection();
169
                
170
                if(GetFileExt(editfile) == ".t") {
171
                        if(editastext.Find(editfile) >= 0)
172
                                menu.Add(AK_DESIGNER, THISBACK(EditUsingDesigner))
173
                                    .Help("Edit converted strings");
174
                        else                                
175
                                menu.Add(AK_EDITASTEXT, THISBACK(EditAsText))
176
                                    .Help("Edit raw strings");
177
                        menu.MenuSeparator();
178
                }
179
                else
180
                if(editastext.Find(editfile) >= 0) {
181
                        menu.Add(AK_DESIGNER, THISBACK(EditUsingDesigner))
182
                            .Help("Edit using the designer (not as text)");
183
                        menu.MenuSeparator();
184
                }
185
                Bar::Item& (Bar::*add)(const char *s, const Image& m, Callback cb) = &Bar::Add;
186
                if(toolbar_in_row) add = &MenuBar::AddMenu;
187
                (menu.*add)("Undo", CtrlImg::undo(), callback(&editor, &LineEdit::Undo))
188
                        .Key(K_CTRL_Z)
189
                        .Enable(editor.IsUndo())
190
                        .Help("Undo changes to text");
191
                (menu.*add)("Redo", CtrlImg::redo(), callback(&editor, &LineEdit::Redo))
192
                        .Key(K_SHIFT|K_CTRL_Z)
193
                        .Enable(editor.IsRedo())
194
                        .Help("Redo undone changes");
195
                if(!toolbar_in_row || menu.IsMenuBar())
196
                        menu.Separator();
197
                (menu.*add)("Cut", CtrlImg::cut(), callback(&editor, &LineEdit::Cut))
198
                        .Key(K_CTRL_X)
199
                        .Enable(!selection.IsEmpty())
200
                        .Help("Cut selection and place it on the system clipboard");
201
                (menu.*add)("Copy", CtrlImg::copy(), callback(&editor, &LineEdit::Copy))
202
                        .Key(K_CTRL_C)
203
                        .Enable(!selection.IsEmpty())
204
                        .Help("Copy current selection on the system clipboard");
205
                (menu.*add)("Paste", CtrlImg::paste(), THISBACK(EditPaste))
206
                        .Key(K_CTRL_V)
207
                        .Help("Insert text from clipboard at cursor location");
208

    
209
                if(!toolbar_in_row || menu.IsMenuBar())
210
                        menu.Separator();
211

    
212
                (menu.*add)("Select all", CtrlImg::select_all(), callback(&editor, &LineEdit::SelectAll))
213
                        .Key(K_CTRL_A);
214
        }
215

    
216
        menu.MenuSeparator();
217
        
218
        if(menu.IsMenuBar())
219
                menu.Add("Find and Replace", THISBACK(SearchMenu));
220

    
221
        if(!designer && menu.IsMenuBar())
222
                InsertAdvanced(menu);
223

    
224
        if(editor.GetLineCount() && editor.GetUtf8Line(0) == "$uvs: PENDING CONFLICT") {
225
                menu.MenuSeparator();
226
                menu.Add("Resolve pending uvs conflict", THISBACK(ResolveUvsConflict))
227
                .Help("Merge $uvs: pending conflicts generated by UVS series of versioning software");
228
        }
229
}
230

    
231
bool Ide::HasMacros()
232
{
233
        const Array<IdeMacro>& mlist = UscMacros();
234
        if(!mlist.IsEmpty())
235
                for(int i = 0; i < mlist.GetCount(); i++) {
236
                        const IdeMacro& m = mlist[i];
237
                        if(!IsNull(m.menu))
238
                                return true;
239
                }
240
        return false;
241
}
242

    
243
void Ide::MacroMenu(Bar& menu)
244
{
245
        const Array<IdeMacro>& mlist = UscMacros();
246
        if(!mlist.IsEmpty() && menu.IsMenuBar()) {
247
                VectorMap< String, Vector<int> > submenu_map;
248
                for(int i = 0; i < mlist.GetCount(); i++) {
249
                        const IdeMacro& m = mlist[i];
250
                        if(!IsNull(m.menu))
251
                                if(IsNull(m.submenu))
252
                                        submenu_map.GetAdd(Null).Add(i);
253
                                else
254
                                        submenu_map.GetAdd(m.menu).Add(i);
255
                }
256
                if(!submenu_map.IsEmpty()) {
257
                        Vector<int> order = GetSortOrder(submenu_map.GetKeys());
258
                        for(int o = 0; o < order.GetCount(); o++) {
259
                                String m = submenu_map.GetKey(order[o]);
260
                                Vector<int>& mx = submenu_map[order[o]];
261
                                if(!IsNull(m))
262
                                        menu.Add(m, THISBACK1(EditMacroMenu, mx));
263
                                else
264
                                        EditMacroMenu(menu, mx);
265
                        }
266
                }
267
        }
268
}
269

    
270
void Ide::EditMacroMenu(Bar& menu, const Vector<int>& mx)
271
{
272
        const Array<IdeMacro>& mlist = UscMacros();
273
        Vector<String> names;
274
        Vector<int> index;
275
        names.Reserve(mx.GetCount());
276
        for(int i = 0; i < mx.GetCount(); i++)
277
                if(mx[i] >= 0 && mx[i] < mlist.GetCount()) {
278
                        const IdeMacro& m = mlist[mx[i]];
279
                        names.Add(Nvl(m.submenu, m.menu));
280
                        index.Add(mx[i]);
281
                }
282
        IndexSort(names, index);
283
        for(int i = 0; i < index.GetCount(); i++)
284
                menu.Add(names[i], THISBACK1(EditMacro, index[i]))
285
                        .Key(mlist[index[i]].hotkey);
286
}
287

    
288
void Ide::EditMacro(int i)
289
{
290
        const Array<IdeMacro>& mlist = UscMacros();
291
        if(i >= 0 && i < mlist.GetCount()) {
292
                const IdeMacro& m = mlist[i];
293
                try {
294
                        Vector<EscValue> arg;
295
                        EscValue api = macro_api, code = m.code;
296
                        ::Execute(UscGlobal(), &api, code, arg, 1000000);
297
                }
298
                catch(Exc e) {
299
                        PutConsole(e);
300
                }
301
        }
302
}
303

    
304
void Ide::Setup(Bar& menu) {
305
        menu.Add("Be verbose", THISBACK(ToggleVerboseBuild))
306
                .Check(console.verbosebuild)
307
                .Help("Log detailed description of build and debug");
308
        menu.Add("Environment..", THISBACK(SetupFormat))
309
                .Help("Fonts, tabs, indentation, status bar");
310
        menu.Add("Abbreviations..", THISBACK(Abbreviations))
311
                .Help("Edit abbreviation keywords and code");
312
        menu.Add("Keyboard shortcuts..", callback(EditKeys))
313
                .Help("Edit key bindings");
314
        menu.Add("Build methods..", THISBACK(SetupBuildMethods))
315
            .Help("Setup build methods");
316
#ifdef PLATFORM_WIN32
317
        menu.Add("Automatic setup..", THISBACK(AutoSetup))
318
            .Help("Automatic setup of build methods..");
319
#endif
320
#ifdef PLATFORM_POSIX
321
        menu.Add("Source managment..", THISBACK(AutoSetup))
322
            .Help("Source code updater settings..");
323
        menu.Separator();
324
        if(UpdaterCfg().method%2==0) //local copy or svn
325
                if(UpdaterCfg().available)
326
                        menu.Add("Install updates..", IdeImg::install_updates(), THISBACK(CheckUpdatesManual))
327
                            .Help("Install newer version of source codes..");
328
                else
329
                        menu.Add("Check for updates..", IdeImg::check_updates(), THISBACK(CheckUpdatesManual))
330
                            .Help("Check for availability of newer source codes..");
331
#endif
332
}
333

    
334
void Ide::ProjectSvn(Bar& menu)
335
{
336
        Vector<String> w = SvnDirs(true);
337
        for(int i = 0; i < w.GetCount(); i++)
338
                menu.Add("Synchronize " + w[i], IdeImg::svn_dir(), THISBACK1(SyncSvnDir, w[i]));
339
        menu.Add("Synchronize everything..", IdeImg::svn(), THISBACK(SyncSvn));
340
}
341

    
342
void Ide::Project(Bar& menu) {
343
        if(menu.IsToolBar() && !debugger)
344
        {
345
                mainconfiglist.Enable(idestate == EDITING);
346
                buildmode.Enable(idestate == EDITING);
347
                menu.Add(mainconfiglist, 180);
348
                menu.Gap(4);
349
                menu.Add(buildmode, 180);
350
                menu.Separator();
351
        }
352
        WorkspaceWork::PackageMenu(menu);
353
        menu.MenuSeparator();
354
        menu.Add(AK_ORGANIZER, IdeImg::package_organizer(), THISBACK(EditWorkspace))
355
                .Help("Package dependencies, compiler & linker options, output path override");
356
        menu.Add(AK_CUSTOM, THISBACK(CustomSteps))
357
                .Help("Building intermediate files using custom commands / applications");
358
        if(menu.IsMenuBar())
359
                menu.Add(AK_MAINCONFIG, IdeImg::main_package(), THISBACK(MainConfig))
360
                        .Help("Configuring compiler, operating system, output application parameters, custom flags");
361
        menu.Separator();
362
        menu.Add(AK_SYNCT, IdeImg::Language(), THISBACK1(SyncT, 0))
363
            .Help("Synchronize all language translation files of current workspace");
364
        menu.AddMenu(AK_TRIMPORT, IdeImg::Language(), THISBACK1(SyncT, 1))
365
            .Help("Import runtime translation file");
366
        menu.AddMenu(AK_TREXPORT, IdeImg::Language(), THISBACK1(SyncT, 2))
367
            .Help("Export runtime translation file");
368
        if(OldLang())
369
                menu.Add("Convert s_ -> t_", THISBACK(ConvertST));
370
        FilePropertiesMenu(menu);
371
        if(SvnDirs(true).GetCount())
372
                if(menu.IsMenuBar())
373
                        menu.Add("SVN", THISBACK(ProjectSvn));
374
                else
375
                        menu.Add("SVN Synchronize everything..", IdeImg::svn(), THISBACK(SyncSvn));
376
}
377

    
378
void Ide::FilePropertiesMenu(Bar& menu)
379
{
380
        menu.MenuSeparator();
381
        menu.Add(IsActiveFile(), AK_FILEPROPERTIES, THISBACK(FileProperties))
382
                .Help("File properties stored in package");
383
        menu.Add(IsActiveFile(), AK_SAVEENCODING, THISBACK(ChangeCharset))
384
            .Help("Convert actual file to different encoding");
385
        menu.AddMenu(IsActiveFile() && !IsFolder(editfile), AK_DIFF, IdeImg::Diff(), THISBACK(Diff))
386
            .Help("Show differences between the project and arbitrary files");
387
        menu.AddMenu(IsActiveFile() && !IsFolder(editfile), AK_PATCH, IdeImg::Patch(), THISBACK(Patch))
388
            .Help("Show differences with patch file applied");
389
        if(IsSvnDir(GetFileFolder(editfile)))
390
                menu.AddMenu(IsActiveFile() && !IsFolder(editfile), AK_SVNDIFF, IdeImg::SvnDiff(), THISBACK(SvnHistory))
391
                    .Help("Show svn history of file");
392
}
393

    
394
void Ide::BuildFileMenu(Bar& menu)
395
{
396
        bool b = idestate == EDITING && !IdeIsDebugLock();
397
        menu.Add(b, "Compile " + GetFileName(editfile), IdeImg::Source(), THISBACK(FileCompile))
398
                .Key(AK_COMPILEFILE)
399
                .Help("Compile current file");
400
        menu.Add(b, "Preprocess " + GetFileName(editfile), IdeImg::Header(), THISBACK1(Preprocess, false))
401
                .Key(AK_PREPROCESSFILE)
402
                .Help("Preprocess current file into temporary file & open in editor");
403
        if(GetMethodVars(method).Get("BUILDER", "") == "GCC")
404
                menu.Add(b, "Show assembler code for " + GetFileName(editfile), THISBACK1(Preprocess, true))
405
                        .Key(AK_ASSEMBLERCODE)
406
                        .Help("Compile the file into assembler code");
407
}
408

    
409
void Ide::BuildPackageMenu(Bar& menu)
410
{
411
        int pi = GetPackageIndex();
412
        bool b = !IdeIsDebugLock() && idestate == EDITING && pi >= 0 && pi < IdeWorkspace().GetCount();
413
        menu.Add(b, AK_BUILDPACKAGE, THISBACK(PackageBuild))
414
                .Help("Build current package");
415
        menu.Add(b, AK_CLEANPACKAGE, THISBACK(PackageClean))
416
                .Help("Remove all intermediate files of the current package");
417
}
418

    
419
void Ide::BuildMenu(Bar& menu) {
420
        bool b = !IdeIsDebugLock();
421
        menu.Add(AK_OUTPUTMODE, THISBACK(SetupOutputMode))
422
            .Help("Setup how to build the target");
423
        if(idestate == BUILDING)
424
                menu.Add(b, "Stop build", IdeImg::build_stop(), THISBACK(StopBuild))
425
                        .Key(AK_BUILD)
426
                        .Help("Stop building");
427
        else
428
                menu.Add(b, "Build", IdeImg::build_make(), THISBACK(DoBuild))
429
                        .Key(AK_BUILD)
430
                        .Help("Perform minimal application rebuild");
431
        b = b && idestate == EDITING;
432
        menu.Add(b, AK_CLEAN, THISBACK(Clean))
433
                .Help("Remove all intermediate files");
434
        menu.Add(b, AK_REBUILDALL, IdeImg::build_rebuild_all(), THISBACK(RebuildAll))
435
                .Help("Remove all intermediate files & build");
436
        menu.Add(b, AK_CLEANUPPOUT, THISBACK(CleanUppOut))
437
                .Help("Remove all files and subdirectories in the output & intermediate directory (see Base setup)");
438

    
439
//        menu.MenuSeparator();
440

    
441
//        menu.Add(b, AK_CREATEMAKEFILE, THISBACK(CreateMakefile))
442
//                .Help("Create makefile enabling IDE-independent project building");
443

    
444
        menu.MenuSeparator();
445

    
446
        if(menu.IsMenuBar()) {
447
                BuildPackageMenu(menu);
448
                menu.MenuSeparator();
449
        }
450

    
451
        BuildFileMenu(menu);
452
        
453
        menu.MenuSeparator();
454

    
455
        menu.Add("Stop on errors", THISBACK(ToggleStopOnErrors))
456
                .Check(stoponerrors)
457
                .Help("Stop build after package when the package has errors");
458

    
459
        menu.MenuSeparator();
460

    
461
        menu.Add(GetConsole().GetLineCount(), AK_FINDNEXTERROR, THISBACK(FindNextError))
462
                .Help("Find next " + String(btabs.GetCursor() == BCONSOLE2 ? "position" : "error line")
463
                   + "according to console pane");
464
        menu.Add(GetConsole().GetLineCount(), AK_FINDPREVERROR, THISBACK(FindPrevError))
465
                .Help("Find previous " + String(btabs.GetCursor() == BCONSOLE2 ? "position" : "error line")
466
                  + "according to console pane");
467
#if defined(PLATFORM_WIN32) || defined(PLATFORM_POSIX)
468
        menu.MenuSeparator();
469
        menu.Add(!IsNull(target), AK_OPENOUTDIR, THISBACK(OpenOutputFolder));
470
#endif
471
}
472

    
473
void Ide::DebugMenu(Bar& menu)
474
{
475
        bool b = idestate == EDITING && !IdeIsDebugLock();
476
        if(debugger) {
477
                debugger->DebugBar(menu);
478
                menu.MenuSeparator();
479
        }
480
        else {
481
                if(console.IsRunning())
482
                        menu.Add("Stop !", THISBACK(StopDebug))
483
                            .Help("Stop controlled process");
484
                if(menu.IsMenuBar()) 
485
                        menu.Add(AK_RUNOPTIONS, THISBACK(RunArgs))
486
                                .Help("Current directory, command line, stdout redirection");
487
                menu.Add(b, AK_EXECUTE, IdeImg::execute(), THISBACK(BuildAndExecute))
488
                        .Help("Build and execute the application");
489
                menu.Add(b, AK_DEBUG, IdeImg::debug_run(), THISBACK1(BuildAndDebug, false))
490
                        .Help("Build application & run debugger");
491
                if(menu.IsMenuBar()) {
492
                        menu.Add(b, AK_DEBUGTO, THISBACK1(BuildAndDebug, true))
493
                                .Help("Build application & run to cursor in debugger");
494
                        menu.Add(b, AK_DEBUGEXT, THISBACK(BuildAndExtDebug))
495
                                .Help("Build application & run external debugger (see Base setup, default \"msdev.exe\")");
496
                        menu.Add(b, AK_DEBUGFILEEXT, THISBACK(BuildAndExtDebugFile))
497
                                .Help("Build application & run external debugger, trying to start with current file");
498
                #ifdef PLATFORM_POSIX
499
                        if(IsValgrind())
500
                                menu.Add(b, AK_VALGRIND, THISBACK(Valgrind))
501
                                        .Help("Build application & run in valgring");
502
                #endif
503

    
504
                        menu.Separator();
505
                }
506
        }
507
        if(menu.IsMenuBar()) {
508
                menu.Add(!editfile.IsEmpty() /*&& !debuglock*/, AK_BREAKPOINT, THISBACK(DebugToggleBreak))
509
                        .Help("Set / clear breakpoint on current line");
510
                menu.Add(!editfile.IsEmpty(), AK_CONDBREAKPOINT, THISBACK(ConditionalBreak))
511
                        .Help("Edit conditional breakpoint");
512
                menu.Add(!editfile.IsEmpty() /*&& !debuglock*/, AK_CLEARBREAKPOINTS, THISBACK(DebugClearBreakpoints))
513
                        .Help("Clear all breakpoints");
514
                menu.Separator();
515
                menu.Add(target.GetCount() && FileExists(GetLogPath()), AK_OPENLOG, THISBACK(OpenLog));
516
        }
517
}
518

    
519
void Ide::BrowseMenu(Bar& menu) {
520
        if (menu.IsMenuBar()) {
521
                menu.AddMenu(AK_NAVIGATOR, IdeImg::Navigator(), THISBACK(ToggleNavigator))
522
                     .Check(editor.IsNavigator());
523
                menu.Add(AK_SEARCHCODE, THISBACK(SearchCode));
524
                menu.Add(!designer, AK_GOTO, THISBACK(Goto));
525
                menu.Add(AK_GOTOGLOBAL, THISBACK(GotoGlobal));
526
                menu.Add(!designer, AK_JUMPS, THISBACK(ContextGoto));
527
                menu.Add(!designer, AK_SWAPS, THISBACK(SwapS));
528
                menu.Add(!designer, AK_ASSIST, callback(&editor, &AssistEditor::Assist));
529
                menu.Add(!designer, AK_DCOPY, callback(&editor, &AssistEditor::DCopy));
530
                menu.Add(!designer, AK_VIRTUALS, callback(&editor, &AssistEditor::Virtuals));
531
                menu.Add(!designer, AK_THISBACKS, callback(&editor, &AssistEditor::Thisbacks));
532
                menu.Add(!designer, AK_COMPLETE, callback(&editor, &AssistEditor::Complete));
533
                menu.Add(!designer, AK_COMPLETE2, callback(&editor, &AssistEditor::Complete2));
534
                menu.Add(!designer, AK_ABBR, callback(&editor, &AssistEditor::Abbr));
535
                menu.Add(!designer, "Insert", THISBACK(InsertMenu));
536
                menu.MenuSeparator();
537
                menu.Add("Rescan code", THISBACK(RescanCode));
538
                menu.MenuSeparator();
539
                menu.AddMenu(AK_CALC, IdeImg::calc(), THISBACK1(ToggleBottom, BCALC))
540
             .Check(IsBottomShown() && btabs.GetCursor() == BCALC);
541
                menu.AddMenu(AK_QTF, IdeCommonImg::Qtf(), THISBACK(Qtf));
542
                menu.AddMenu(!designer, AK_XML, IdeCommonImg::xml(), THISBACK(Xml));
543
                menu.AddMenu(!designer, AK_JSON, IdeCommonImg::json(), THISBACK(Json));
544
        }
545
        menu.Separator();
546
        menu.Add(AK_BROWSETOPICS, IdeImg::help(), THISBACK(ShowTopics));
547
        menu.Add(AK_SEARCHTOPICS, THISBACK(SearchTopics));
548
        menu.Add("About..", THISBACK(About));
549
}
550

    
551
void Ide::MainMenu(Bar& menu) {
552
        menu.Add("File", THISBACK(File))
553
                .Help("Package & file functions, exports, bookmarks");
554
        menu.Add("Edit", THISBACK(Edit))
555
                .Help("Clipboard, find & replace, spaces / tabs conversion, scope highlighting");
556
        if(HasMacros())
557
                menu.Add("Macro", THISBACK(MacroMenu))
558
                        .Help("Editor & IDE macros");
559
        menu.Add("Project", THISBACK(Project))
560
                .Help("Package organizer, custom steps, configuration manager");
561
        menu.Add("Build", THISBACK(BuildMenu))
562
                .Help("Building & debugging, minor build options, showing errors");
563
        menu.Add("Debug", THISBACK(DebugMenu))
564
                .Help("Debugger commands (currently supports gdb-connection only)");
565
        menu.Add("Assist", THISBACK(BrowseMenu))
566
                .Help("Informations, code browsing and assistance");
567
        menu.Add("Setup", THISBACK(Setup))
568
                .Help("Paths, editor settings, connection to remote host");
569
}
570

    
571
void Ide::MainTool(Bar& bar)
572
{
573
        Edit(bar);
574
        if(debugger) {
575
                if(!designer)
576
                        bar.Separator();
577
                DebugMenu(bar);
578
        }
579
        if(!designer)
580
                bar.Separator();
581
        Project(bar);
582
        BuildMenu(bar);
583
        
584
        if(!debugger) {
585
                bar.Separator();
586
                DebugMenu(bar);
587
        }
588
        Setup(bar);
589
        BrowseMenu(bar);
590
}
591

    
592
void Ide::ConsoleMenu(Bar& menu)
593
{
594
        String selection = GetConsole().GetSelection();
595
        
596
        menu.Add("Copy", CtrlImg::copy(), THISBACK(ConsoleCopy))
597
                .Key(K_CTRL_C)
598
                .Enable(!selection.IsEmpty())
599
                .Help("Copy selection on system clipboard");
600
        menu.Add("Paste", CtrlImg::paste(), THISBACK(ConsolePaste))
601
                .Key(K_CTRL_V)
602
                .Help("Append selection to system console");
603
        menu.Separator();
604
        menu.Add("Clear", THISBACK(ConsoleClear))
605
                .Help("Empty system console");
606
}
607

    
608
void Ide::SetBar()
609
{
610
        SetMenuBar();
611
        SetToolBar();
612
}
613

    
614
void Ide::SetMenuBar()
615
{
616
        menubar.Set(THISBACK(MainMenu));
617
}
618

    
619
void Ide::SetToolBar()
620
{
621
        toolbar.Set(THISBACK(MainTool));
622
}