Home » U++ TheIDE » U++ TheIDE: Other Features Wishlist and/or Bugs » [FEATURE] Add submenu "Macro /Edit" to package that use usc macro (patch included)
[FEATURE] Add submenu "Macro /Edit" to package that use usc macro (patch included) [message #46572] |
Thu, 02 June 2016 13:12  |
omari
Messages: 276 Registered: March 2010
|
Experienced Member |
|
|
Hi,
by default, a macro file can reside outside from package that using it, in this case, editing a macro, necessit using a file explorer and a manuel search.
it is usefull if we can edit a macro file from inside theide, from any package that use this macro.
this is the objectif of this pach.

the patch:
1 - file ide/Core/Core.h, line 146
add a new field "filename" to the struct IdeMacro
struct IdeMacro {
IdeMacro();
int hotkey;
String menu;
String submenu;
EscValue code;
String filename; // added field
};
2 - file ide/Common/Util.cpp, line 177
set filename for each IdeMacro from CParser::GetFileName
static void ReadMacro(CParser& p)
{
IdeMacro macro;
macro.filename = p.GetFileName(); // added line
if(p.IsString()) {
3 - file ide/idebar.cpp, line 293
add a menu separator, and the "Edit" menu:
void Ide::MacroMenu(Bar& menu)
{
const Array<IdeMacro>& mlist = UscMacros();
if(!mlist.IsEmpty() && menu.IsMenuBar()) {
VectorMap< String, Vector<int> > submenu_map;
for(int i = 0; i < mlist.GetCount(); i++) {
const IdeMacro& m = mlist[i];
if(!IsNull(m.menu)) {
if(IsNull(m.submenu))
submenu_map.GetAdd(Null).Add(i);
else
submenu_map.GetAdd(m.menu).Add(i);
}
}
if(!submenu_map.IsEmpty()) {
Vector<int> order = GetSortOrder(submenu_map.GetKeys());
for(int o = 0; o < order.GetCount(); o++) {
String m = submenu_map.GetKey(order[o]);
Vector<int>& mx = submenu_map[order[o]];
ValueArray va;
for(int i = 0; i < mx.GetCount(); i++)
va.Add(mx[i]);
if(!IsNull(m))
menu.Add(m, THISBACK1(EditMacroMenu, va));
else
EditMacroMenu(menu, va);
}
}
static SortedIndex<String> files; // the added code START HERE
files.Clear();
for(int i = 0; i < mlist.GetCount(); i++)
files.FindAdd(mlist[i].filename);
Event<Bar&> ev;
ev <<
[&](Bar& b)
{
for(int i = 0; i < files.GetCount(); i++)
b.Add(files[i],THISBACK1(EditFile, files[i]));
}
;
menu.Separator();
menu.Add("Edit", ev); // the added code END HERE
}
}
-
Attachment: macro.png
(Size: 20.33KB, Downloaded 486 times)
regards
omari.
|
|
|
Goto Forum:
Current Time: Mon Apr 28 11:11:51 CEST 2025
Total time taken to generate the page: 0.00796 seconds
|