Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
omari is currently offline  omari
Messages: 266
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.

index.php?t=getfile&id=5026&private=0

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 398 times)


regards
omari.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [ACCEPTED] New file
Next Topic: Bookmarks hotkeys Ctrl+0-9 and Ctrl+Shift+0-9 dont works
Goto Forum:
  


Current Time: Thu May 09 15:35:42 CEST 2024

Total time taken to generate the page: 0.02292 seconds