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 » Developing U++ » U++ TheIDE and Library: Releases and ChangeLogs » Some macro enhancements for TheIde
Some macro enhancements for TheIde [message #10404] Fri, 06 July 2007 16:03 Go to next message
Zardos is currently offline  Zardos
Messages: 62
Registered: April 2007
Member
Hello,

I needed some enhancements for Macros in TheIde, so I made some small changes in the upp source. May be you can consider introducing them into the repository, again...

1.) I wanted to run some external programs on a source file. For example a source beautifier like AStyle. This kind of macro should be always available and independent of the selected package.
To accomplis this I changed:

In Ide.cpp the function void Ide::SyncUsc() to this code:
void Ide::SyncUsc()
{
	CleanUsc();
	::Workspace wspc;
	static String scan[] = { main, ConfigFile("ide.aux") };
	for(int t = 0; t < (sizeof scan / sizeof scan[0]); t++) {
		wspc.Scan(scan[t]);
		int i;
		for(i = 0; i < wspc.GetCount(); i++) {
			const Package& p = wspc.GetPackage(i);
			for(int j = 0; j < p.file.GetCount(); j++) {
				String file = SourcePath(wspc[i], p.file[j]);
				if(ToLower(GetFileExt(file)) == ".usc")
					UscFile(file);
			}
		}
	}
	UscProcessDir(GetCommonDir());
	UscProcessDir(GetLocalDir());
	UscProcessDir(GetFileFolder(ConfigFile("x")));

}

Now, not only the current package is searched for macros - in addition the files in <ide-aux> are searched for macros, too.


The next step was to add 3 functions to "Ide::MacroEditor()":

SaveCurrentFile() : Save the current source file
ProjectDir() : Get the package directory. I need this for some other stufff... OOps PackageDir or PackagePath would be better I gues Neutral
FileName() : Get the current Name of the current file.


I changed Ide.h and added the following lines to:
struct Ide : public TopWindow, public WorkspaceWork, public IdeContext {
		void  MacroSaveCurrentFile(EscEscape& e);
		void  MacroProjectDir(EscEscape& e);
		void  MacroFileName(EscEscape& e);


and in Macro.cpp I added the following lines to:
EscValue Ide::MacroEditor()
	out.Escape("SaveCurrentFile()", THISBACK(MacroSaveCurrentFile));
	out.Escape("ProjectDir()", THISBACK(MacroProjectDir));
	out.Escape("FileName()", THISBACK(MacroFileName));


and these functions to Macro.cpp:
void Ide::MacroSaveCurrentFile(EscEscape& e)
{
	SaveFile();
}

void Ide::MacroProjectDir(EscEscape& e)
{
	e = GetFileFolder(PackagePathA(GetActivePackage()));
}

void Ide::MacroFileName(EscEscape& e)
{
	e = editfile;
}




As an example you can now add a macro file to <ide-aux> and call a beautifier like this from the macro menu:
macro "Beautify" Ctrl+Shift+B {
	ClearConsole();
	cout("Beautifying...");
	SaveCurrentFile();
	Execute("astyle.exe --style=java --indent=tab=4 --indent-cases --one-line=keep-blocks --unpad=paren --pad=oper --break-blocks " + FileName());
}


- Ralf
Re: Some macro enhancements for TheIde [message #10425 is a reply to message #10404] Mon, 09 July 2007 09:23 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Patch applied, except the first step (ide-aux):

	UscProcessDir(GetLocalDir());
	UscProcessDir(GetFileFolder(ConfigFile("x")));


This adds all *.usc files in theide.exe (or ~/.ide) directory and (ide)/UppLocal (or ~/.ide/UppLocal), which I think should be enough here. I am afraid that adding ide-aux package could lead to problems as it is being used to view existing files, including perhaps some .usc files that you want just to view (e.g. to copy stuff from them), not to run...
Re: Some macro enhancements for TheIde [message #10442 is a reply to message #10425] Mon, 09 July 2007 16:02 Go to previous message
Zardos is currently offline  Zardos
Messages: 62
Registered: April 2007
Member
luzr wrote on Mon, 09 July 2007 09:23

Patch applied, except the first step (ide-aux):
This adds all *.usc files in theide.exe (or ~/.ide) directory and (ide)/UppLocal (or ~/.ide/UppLocal), which I think should be enough here. I am afraid that adding ide-aux package could lead to problems as it is being used to view existing files, including perhaps some .usc files that you want just to view (e.g. to copy stuff from them), not to run...



It's allways nice if there is no need to have a special personal version of Ultimate++
Thanks for applying the patch!

- Ralf
Previous Topic: Small ToolBar improvements
Next Topic: Quiz: What is wrong with this code?
Goto Forum:
  


Current Time: Wed Apr 24 13:32:46 CEST 2024

Total time taken to generate the page: 0.02608 seconds