[Biococoa-dev] strider and gck format

Alexander Griekspoor mek at mekentosj.com
Mon Mar 20 05:04:59 EST 2006

Hi Koen,

Indeed, I use a stripForeignCharacters method in EnzymeX and iRNAi,  
still have to move it to the shouldChangeTextinRange method  
(currently it is still invoked on the whole textStorage every time).  
It indeed also does the case conversion. I'm not sure if you can use  
a formatter in combination with a textview, I thought only with a  
textfield (update, just checked. setformatter: indeed only works with  
NSCell, but perhaps you could set it on the fieldeditor. probably  
also not, because that one is also of class NSText).

- (void)stripForeignCharacters{
         NSRange oldRange = [sequenceView selectedRange];

         NSTextStorage* textstorage = [sequenceView textStorage];
         NSString* strippedString = @"";
         NSString* oldString = [[textstorage string] uppercaseString];
         NSMutableString* newString = [NSMutableString  
stringWithCapacity: [textstorage length]];

         NSScanner* scanner = [NSScanner scannerWithString: oldString];
         [scanner scanUpToCharactersFromSet: charSet intoString: nil];
         while ( [scanner isAtEnd] == NO) {
             if(![scanner scanCharactersFromSet: charSet intoString:  
&strippedString]) continue;
             [newString appendString: strippedString];
             if(![scanner scanUpToCharactersFromSet: charSet  
intoString: nil]) continue;

         NSAttributedString* attstring = [[NSAttributedString alloc]  
initWithString: newString];
         [textstorage setAttributedString: attstring];

         [textstorage addAttribute: NSFontAttributeName
                             value: [NSFont fontWithName: @"Courier"  
size: 12.0]
                             range: NSMakeRange (0,[[textstorage  
mutableString] length])];

         [attstring release];

          if(oldRange.length == 0 && ([[textstorage mutableString]  
length] > oldRange.location)){
             [sequenceView setSelectedRange: NSMakeRange 
(oldRange.location, 0)];
		 [mainWindow makeFirstResponder: sequenceView];


On 20-mrt-2006, at 2:25, Koen van der Drift wrote:

> On Mar 19, 2006, at 6:34 PM, Koen van der Drift wrote:
>> One thing that the BCSequenceView will also need (or actually  
>> maybe its controller) is a method that checks whether what the  
>> user types is part of the symbolset of the sequence. If the  
>> controller does that, it's probably needed in a delegate method,  
>> such as
>> - (BOOL)textView:(NSTextView *)aTextView
>> 		shouldChangeTextInRange:(NSRange)affectedCharRange
>> 		replacementString:(NSString *)replacementString
>> And also a way to change every typed letter to uppercase/lowercase  
>> automagically.
> Hmm, replying to myself here :) Another possibilty could be to make  
> a formatter that takes care of these things. I will look into that,  
> unless someone thinks that's a bad idea.
> cheers,
> - Koen.

Mek (Alexander Griekspoor)
Web: http://www.mekentosj.com
Mail:  mek at mekentosj.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.bioinformatics.org/pipermail/biococoa-dev/attachments/20060320/9ad29655/attachment.html>

More information about the Biococoa-dev mailing list