Mercurial > dwindows
comparison mac/dw.m @ 992:2d80b4dcff9a
A few MLE fixes on the Mac... and a slightly updated dwtest for MLE testing.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 07 May 2011 19:39:45 +0000 |
parents | 6de00477d627 |
children | a943f973c3ff |
comparison
equal
deleted
inserted
replaced
991:64c4c40c5835 | 992:2d80b4dcff9a |
---|---|
4232 NSScrollView *sv = handle; | 4232 NSScrollView *sv = handle; |
4233 DWMLE *mle = [sv documentView]; | 4233 DWMLE *mle = [sv documentView]; |
4234 NSTextStorage *ts = [mle textStorage]; | 4234 NSTextStorage *ts = [mle textStorage]; |
4235 NSString *nstr = [NSString stringWithUTF8String:buffer]; | 4235 NSString *nstr = [NSString stringWithUTF8String:buffer]; |
4236 NSMutableString *ms = [ts mutableString]; | 4236 NSMutableString *ms = [ts mutableString]; |
4237 [ms insertString:nstr atIndex:(startpoint+1)]; | 4237 NSUInteger length = [ms length]; |
4238 if(startpoint < 0) | |
4239 startpoint = 0; | |
4240 if(startpoint > length) | |
4241 startpoint = (int)length; | |
4242 [ms insertString:nstr atIndex:startpoint]; | |
4238 return (unsigned int)strlen(buffer) + startpoint; | 4243 return (unsigned int)strlen(buffer) + startpoint; |
4239 } | 4244 } |
4240 | 4245 |
4241 /* | 4246 /* |
4242 * Grabs text from an MLE box. | 4247 * Grabs text from an MLE box. |
4268 DWMLE *mle = [sv documentView]; | 4273 DWMLE *mle = [sv documentView]; |
4269 NSTextStorage *ts = [mle textStorage]; | 4274 NSTextStorage *ts = [mle textStorage]; |
4270 NSMutableString *ms = [ts mutableString]; | 4275 NSMutableString *ms = [ts mutableString]; |
4271 NSUInteger numberOfLines, index, stringLength = [ms length]; | 4276 NSUInteger numberOfLines, index, stringLength = [ms length]; |
4272 | 4277 |
4273 for(index=0, numberOfLines=0; index < stringLength; numberOfLines++) | 4278 if(bytes) |
4274 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]); | 4279 *bytes = stringLength; |
4275 | 4280 if(lines) |
4276 *bytes = stringLength; | 4281 { |
4277 *lines = numberOfLines; | 4282 for(index=0, numberOfLines=0; index < stringLength; numberOfLines++) |
4283 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]); | |
4284 | |
4285 *lines = numberOfLines; | |
4286 } | |
4278 } | 4287 } |
4279 | 4288 |
4280 /* | 4289 /* |
4281 * Deletes text from an MLE box. | 4290 * Deletes text from an MLE box. |
4282 * Parameters: | 4291 * Parameters: |
4288 { | 4297 { |
4289 NSScrollView *sv = handle; | 4298 NSScrollView *sv = handle; |
4290 DWMLE *mle = [sv documentView]; | 4299 DWMLE *mle = [sv documentView]; |
4291 NSTextStorage *ts = [mle textStorage]; | 4300 NSTextStorage *ts = [mle textStorage]; |
4292 NSMutableString *ms = [ts mutableString]; | 4301 NSMutableString *ms = [ts mutableString]; |
4293 [ms deleteCharactersInRange:NSMakeRange(startpoint+1, length)]; | 4302 NSUInteger mslength = [ms length]; |
4303 if(startpoint < 0) | |
4304 startpoint = 0; | |
4305 if(startpoint > mslength) | |
4306 startpoint = (int)mslength; | |
4307 if(startpoint + length > mslength) | |
4308 length = (int)mslength - startpoint; | |
4309 [ms deleteCharactersInRange:NSMakeRange(startpoint, length)]; | |
4294 } | 4310 } |
4295 | 4311 |
4296 /* | 4312 /* |
4297 * Clears all text from an MLE box. | 4313 * Clears all text from an MLE box. |
4298 * Parameters: | 4314 * Parameters: |