sendAction Question

View: New views
1 Messages — Rating Filter:   Alert me  

sendAction Question

by Hans-Jörg Bibiko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

_______________________________________________
textmate-plugins mailing list
textmate-plugins@...
http://lists.macromates.com/mailman/listinfo/textmate-plugins