idebar.cpp

Zbigniew Rebacz, 01/04/2014 08:06 PM

Download (21 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
                if(GetFileExt(editfile) == ".t") {
169
                        if(editastext.Find(editfile) >= 0)
170
                                menu.Add(AK_DESIGNER, THISBACK(EditUsingDesigner))
171
                                    .Help("Edit converted strings");
172
                        else                                
173
                                menu.Add(AK_EDITASTEXT, THISBACK(EditAsText))
174
                                    .Help("Edit raw strings");
175
                        menu.MenuSeparator();
176
                }
177
                else
178
                if(editastext.Find(editfile) >= 0) {
179
                        menu.Add(AK_DESIGNER, THISBACK(EditUsingDesigner))
180
                            .Help("Edit using the designer (not as text)");
181
                        menu.MenuSeparator();
182
                }
183
                Bar::Item& (Bar::*add)(const char *s, const Image& m, Callback cb) = &Bar::Add;
184
                if(toolbar_in_row) add = &MenuBar::AddMenu;
185
                (menu.*add)("Undo", CtrlImg::undo(), callback(&editor, &LineEdit::Undo))
186
                        .Key(K_CTRL_Z)
187
                        .Help("Undo changes to text");
188
                (menu.*add)("Redo", CtrlImg::redo(), callback(&editor, &LineEdit::Redo))
189
                        .Key(K_SHIFT|K_CTRL_Z)
190
                        .Help("Redo undone changes");
191
                if(!toolbar_in_row || menu.IsMenuBar())
192
                        menu.Separator();
193
                (menu.*add)("Cut", CtrlImg::cut(), callback(&editor, &LineEdit::Cut))
194
                        .Key(K_CTRL_X)
195
                        .Help("Cut selection and place it on the system clipboard");
196
                (menu.*add)("Copy", CtrlImg::copy(), callback(&editor, &LineEdit::Copy))
197
                        .Key(K_CTRL_C)
198
                        .Help("Copy current selection on the system clipboard");
199
                (menu.*add)("Paste", CtrlImg::paste(), THISBACK(EditPaste))
200
                        .Key(K_CTRL_V)
201
                        .Help("Insert text from clipboard at cursor location");
202

    
203
                if(!toolbar_in_row || menu.IsMenuBar())
204
                        menu.Separator();
205

    
206
                (menu.*add)("Select all", CtrlImg::select_all(), callback(&editor, &LineEdit::SelectAll))
207
                        .Key(K_CTRL_A);
208
        }
209

    
210
        menu.MenuSeparator();
211
        
212
        if(menu.IsMenuBar())
213
                menu.Add("Find and Replace", THISBACK(SearchMenu));
214

    
215
        if(!designer && menu.IsMenuBar())
216
                InsertAdvanced(menu);
217

    
218
        if(editor.GetLineCount() && editor.GetUtf8Line(0) == "$uvs: PENDING CONFLICT") {
219
                menu.MenuSeparator();
220
                menu.Add("Resolve pending uvs conflict", THISBACK(ResolveUvsConflict))
221
                .Help("Merge $uvs: pending conflicts generated by UVS series of versioning software");
222
        }
223
}
224

    
225
bool Ide::HasMacros()
226
{
227
        const Array<IdeMacro>& mlist = UscMacros();
228
        if(!mlist.IsEmpty())
229
                for(int i = 0; i < mlist.GetCount(); i++) {
230
                        const IdeMacro& m = mlist[i];
231
                        if(!IsNull(m.menu))
232
                                return true;
233
                }
234
        return false;
235
}
236

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

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

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

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

    
328
void Ide::ProjectSvn(Bar& menu)
329
{
330
        Vector<String> w = SvnDirs(true);
331
        for(int i = 0; i < w.GetCount(); i++)
332
                menu.Add("Synchronize " + w[i], IdeImg::svn_dir(), THISBACK1(SyncSvnDir, w[i]));
333
        menu.Add("Synchronize everything..", IdeImg::svn(), THISBACK(SyncSvn));
334
}
335

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

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

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

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

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

    
433
//        menu.MenuSeparator();
434

    
435
//        menu.Add(b, AK_CREATEMAKEFILE, THISBACK(CreateMakefile))
436
//                .Help("Create makefile enabling IDE-independent project building");
437

    
438
        menu.MenuSeparator();
439

    
440
        if(menu.IsMenuBar()) {
441
                BuildPackageMenu(menu);
442
                menu.MenuSeparator();
443
        }
444

    
445
        BuildFileMenu(menu);
446
        
447
        menu.MenuSeparator();
448

    
449
        menu.Add("Stop on errors", THISBACK(ToggleStopOnErrors))
450
                .Check(stoponerrors)
451
                .Help("Stop build after package when the package has errors");
452

    
453
        menu.MenuSeparator();
454

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

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

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

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

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

    
563
void Ide::MainTool(Bar& bar)
564
{
565
        Edit(bar);
566
        if(debugger) {
567
                if(!designer)
568
                        bar.Separator();
569
                DebugMenu(bar);
570
        }
571
        if(!designer)
572
                bar.Separator();
573
        Project(bar);
574
        BuildMenu(bar);
575
        if(!debugger) {
576
                bar.Separator();
577
                DebugMenu(bar);
578
        }
579
        Setup(bar);
580
        BrowseMenu(bar);
581
}
582

    
583
void Ide::ConsoleMenu(Bar& menu)
584
{
585
        String selection = GetConsole().GetSelection();
586
        
587
        menu.Add("Copy", CtrlImg::copy(), THISBACK(ConsoleCopy))
588
                .Key(K_CTRL_C)
589
                .Enable(!selection.IsEmpty())
590
                .Help("Copy selection on system clipboard");
591
        menu.Add("Paste", CtrlImg::paste(), THISBACK(ConsolePaste))
592
                .Key(K_CTRL_V)
593
                .Help("Append selection to system console");
594
        menu.Separator();
595
        menu.Add("Clear", THISBACK(ConsoleClear))
596
                .Help("Empty system console");
597
}
598

    
599
void Ide::SetBar()
600
{
601
        menubar.Set(THISBACK(MainMenu));
602
        toolbar.Set(THISBACK(MainTool));
603
}