[TxMt Plugins] sendAction Question

Hans-Joerg Bibiko bibiko at eva.mpg.de
Thu Sep 20 14:43:25 UTC 2007


Hi,

I just found this thread in the net. I don't know whether it is too  
late ;)

Regarding to make a selection in a TM document.

Did you try this way:

-(void)setSelectionTo:(NSDictionary*)someOptions
{
	NSString* line;
	NSString* column;
	if(![someOptions objectForKey:@"toLine"])
		line = [[[NSApp targetForAction:@selector(allEnvironmentVariables)]  
allEnvironmentVariables] objectForKey:@"TM_LINE_NUMBER"];
	else
		line = [someOptions objectForKey:@"toLine"];
	if(![someOptions objectForKey:@"toColumn"])
		column = @"1";
	else
		if([[someOptions objectForKey:@"toColumn"] isEqualToString:@"end"])
			column = [NSString stringWithFormat:@"%d",([[[[NSApp  
targetForAction:@selector(allEnvironmentVariables)]  
allEnvironmentVariables] objectForKey:@"TM_CURRENT_LINE"] length] + 1)];
	else
		column = [someOptions objectForKey:@"toColumn"];
	if([someOptions objectForKey:@"length"])
		column = [NSString stringWithFormat:@"%d",[[[[NSApp  
targetForAction:@selector(allEnvironmentVariables)]  
allEnvironmentVariables] objectForKey:@"TM_COLUMN_NUMBER"] intValue] +
			[[someOptions objectForKey:@"length"] intValue]];
	id d = [NSApp targetForAction:@selector(document)];
	[d selectToLine:line andColumn:column];
}

For me it works perfectly ;)

Regards,

Hans




More information about the textmate-plugins mailing list