May 01, 2024, 12:50:41 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Change IDE settings

Started by Parker, August 13, 2006, 02:40:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Parker

Do you not like the IDE's operator color? Or maybe you want your comments in italics? How about adding a new set of keywords?

All of these are not possible with Aurora currently, until now.

Note that adding a new keyword group requires some calls to WriteProcessMemory and other such APIs so you can get the string into the IDE's memory space. But changing other things is easy - just a call to SendMessage.

Get your Scintilla constants from:
http://scintilla.cvs.sourceforge.net/scintilla/scintilla/include/SciLexer.h?revision=1.139&view=markup
http://scintilla.cvs.sourceforge.net/scintilla/scintilla/include/Scintilla.h?revision=1.176&view=markup

Edit the first function, MDIChildCb, to change your settings. Don't mind the others, sorry the code is so messy. In my screenshot I have shown an editor with some unchangeable settings changed. You can do much more than the IDE lets you with Scintilla. Experiment with it, find the settings you like. You'll have to run the program each time you create a source file, though you could change that with a hook if you like.

Parker

Okay, now you can assign new keyword sets. It requires calling WriteAuroraString, which allocates memory in the IDE and copies a string to it. In my demo, I changed the list of types to contain only "acstr".

Paul, maybe this can be a demo? I think it shows flexability of the language, as well as enables users to customize the IDE. I could clean it up a bit too, using constants instead of numbers, if you'd like.

import int EnumWindows( unsigned int hProc, void *lParam );
import int GetWindowText alias "GetWindowTextA" ( unsigned int hWnd, string *text, int max );
import int EnumChildWindows( unsigned int hWndParent, unsigned int hProc, void *lParam );
import int GetClassName alias "GetClassNameA" ( unsigned int hWnd, string *name, int max );
import int SendMessage alias "SendMessageA" ( unsigned int hWnd, unsigned int msg, unsigned int wParam, int lParam );
import unsigned int GetWindowThreadProcessId( unsigned int hWnd, unsigned int *hProcess = 0 );
import unsigned int OpenProcess( unsigned int dwDesiredAccess, int bInheritHandle, unsigned int dwProcessId );
import int WriteProcessMemory( unsigned int hProcess, void *lpBaseAddress, void *lpBuffer, uint nSize,
uint *lpNumberOfBytesWritten );
import int CloseHandle( unsigned int hObject );
import pointer VirtualAllocEx( uint hProcess, void *lpaddress, uint dwSize, uint flAllocationType, uint flProtect );

unsigned int aurora_process;

//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
sub MDIChildCb( unsigned int hChild, void *lParam ),int
{
unsigned int hScintilla;
hScintilla = GetScintilla( hChild );
if( hScintilla == 0 ) return true; // for example, dialog editors

print( "Found scintilla" );

// Change the scintilla's operator color. operator style is 10 (SCE_C_OPERATOR)
// Message to change foreground is 2051 (SCI_STYLESETFORE)
/****** EDIT ME *******/
SendMessage( hScintilla, 2051, 10, 0x0000FF ); // Operators red
// Other stuff...
SendMessage( hScintilla, 2054, 6, 1 ); // Strings italic
SendMessage( hScintilla, 2188, 2, 0 ); // Caret width 2
SendMessage( hScintilla, 2053, 2, 1 ); // Comment line bold
string *acstr;
acstr = WriteAuroraString( "acstr" );
SendMessage( hScintilla, 4005, 2, acstr ); // Change the types list to "acstr"
/****** EDIT ME *******/

return true;
}
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------

sub WriteAuroraString( string s ),string*
{
unsigned int sl = len( s ), t;
void *ptr;
if( aurora_process = 0 ) return 0;

ptr = VirtualAllocEx( aurora_process, null, sl + 1, 0x1000, 4 );
if ptr == 0 return 0;
WriteProcessMemory( aurora_process, ptr, &s, sl+1, &t );
return ptr;
}

global sub main( )
{
unsigned int aurora, amdi, pid;
aurora = GetAuroraWindow( );
GetWindowThreadProcessId( aurora, &pid );

aurora_process = OpenProcess( 0x0038, true, pid );

if( aurora )
{
print( "Found Aurora" );
mdi = GetMDI( aurora );
if( mdi )
{
print( "Found MDI" );
EnumChildWindows( mdi, &MDIChildCb, 0 );
}
}
if aurora_process CloseHandle( aurora_process );
do{}until(getkey()!="");
}

sub GetAuroraWindow( ),unsigned int
{
unsigned int acwnd = 0;
EnumWindows( &EnumCallback, &acwnd );
return acwnd;
}

sub EnumCallback( unsigned int hWnd, void *lParam ),int
{
dstring wtext[16];
GetWindowText( hWnd, &wtext, 16 );

if( wtext == "Aurora Compiler" )
{
*(unsigned int)lParam = hWnd;
return false;
}

return true;
}

sub GetMDI( unsigned int hAurora ),unsigned int
{
unsigned int mdi = 0;
EnumChildWindows( hAurora, &GetMDICallback, &mdi );
return mdi;
}

sub GetMDICallback( unsigned int hWnd, void *lParam ),int
{
dstring cname[10];
GetClassName( hWnd, &cname, 10 );

if( strlower( cname ) == "mdiclient" )
{
*(unsigned int)lParam = hWnd;
return false;
}

return true;
}

sub GetScintilla( unsigned int hChild ),unsigned int
{
unsigned int sci = 0;
EnumChildWindows( hChild, &GetSciCallback, &sci );
return sci;
}

sub GetSciCallback( unsigned int hWnd, void *lParam ),int
{
dstring cname[10];
GetClassName( hWnd, &cname, 10 );

if( strlower( cname ) == "scintilla" )
{
*(unsigned int)lParam = hWnd;
return false;
}

return true;
}