<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>src/NeoUtils.h</filename>
    </added>
    <added>
      <filename>src/NeoUtils.m</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -11,6 +11,9 @@
 		1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD582A0DA1D0D100B32029 /* MainMenu.xib */; };
 		77B489B40ECA62EF00534EB4 /* NeoTextViewTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B489B30ECA62EF00534EB4 /* NeoTextViewTest.m */; };
 		77B489DD0ECA65A200534EB4 /* NeoTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 77F891A80EC47EBF002CA36A /* NeoTextView.m */; };
+		77C0EF4E10271F000019E013 /* NeoUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C0EF4D10271F000019E013 /* NeoUtils.m */; };
+		77C0EF7D1027223F0019E013 /* NeoUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 77C0EF4D10271F000019E013 /* NeoUtils.m */; };
+		77C0EF7E102722420019E013 /* NeoDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 77F891670EC473A2002CA36A /* NeoDocument.m */; };
 		77D1762F0EC66CCC00E788AD /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77D1762E0EC66CCC00E788AD /* ApplicationServices.framework */; };
 		77F891690EC473A2002CA36A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 77F891650EC473A2002CA36A /* main.m */; };
 		77F8916A0EC473A2002CA36A /* NeoDocument.m in Sources */ = {isa = PBXBuildFile; fileRef = 77F891670EC473A2002CA36A /* NeoDocument.m */; };
@@ -43,6 +46,8 @@
 		77B489A30ECA618A00534EB4 /* UnitTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = &quot;UnitTests-Info.plist&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
 		77B489B20ECA62EF00534EB4 /* NeoTextViewTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NeoTextViewTest.h; sourceTree = &quot;&lt;group&gt;&quot;; };
 		77B489B30ECA62EF00534EB4 /* NeoTextViewTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NeoTextViewTest.m; sourceTree = &quot;&lt;group&gt;&quot;; };
+		77C0EF4C10271F000019E013 /* NeoUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NeoUtils.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+		77C0EF4D10271F000019E013 /* NeoUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NeoUtils.m; sourceTree = &quot;&lt;group&gt;&quot;; };
 		77D1762E0EC66CCC00E788AD /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = &quot;&lt;absolute&gt;&quot;; };
 		77F891650EC473A2002CA36A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = &quot;&lt;group&gt;&quot;; };
 		77F891660EC473A2002CA36A /* NeoDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NeoDocument.h; sourceTree = &quot;&lt;group&gt;&quot;; };
@@ -154,6 +159,8 @@
 				77F891670EC473A2002CA36A /* NeoDocument.m */,
 				77F891A70EC47EBF002CA36A /* NeoTextView.h */,
 				77F891A80EC47EBF002CA36A /* NeoTextView.m */,
+				77C0EF4C10271F000019E013 /* NeoUtils.h */,
+				77C0EF4D10271F000019E013 /* NeoUtils.m */,
 			);
 			path = src;
 			sourceTree = &quot;&lt;group&gt;&quot;;
@@ -260,6 +267,8 @@
 			files = (
 				77B489B40ECA62EF00534EB4 /* NeoTextViewTest.m in Sources */,
 				77B489DD0ECA65A200534EB4 /* NeoTextView.m in Sources */,
+				77C0EF7D1027223F0019E013 /* NeoUtils.m in Sources */,
+				77C0EF7E102722420019E013 /* NeoDocument.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -270,6 +279,7 @@
 				77F891690EC473A2002CA36A /* main.m in Sources */,
 				77F8916A0EC473A2002CA36A /* NeoDocument.m in Sources */,
 				77F891A90EC47EBF002CA36A /* NeoTextView.m in Sources */,
+				77C0EF4E10271F000019E013 /* NeoUtils.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};</diff>
      <filename>Neuro.xcodeproj/project.pbxproj</filename>
    </modified>
    <modified>
      <diff>@@ -30,51 +30,3 @@
 - (void) replaceTextStorage: (NSTextStorage *) newTextStorage;
 
 @end
-
-
-// ----------------------------------------------------------------
-// Utilities
-// ----------------------------------------------------------------
-/**
- * Returns a Boolean value that indicates whether
- * a specified position is in a given range.
- */
-NS_INLINE Boolean NeoLocationInCFRange(CFIndex loc, CFRange range) {
-  const CFIndex t = loc - range.location;
-  return t &gt;= 0 &amp;&amp; t &lt; range.length;
-}
-
-NS_INLINE CFIndex NeoCFMaxRange(CFRange r) {
-  return r.location + r.length;
-}
-
-/**
- * Returns an NSRange from a CFRange
- */
-NS_INLINE NSRange NeoNSRangeFromCFRange(CFRange range) {
-  return NSMakeRange(range.location, range.length);
-}
-NS_INLINE NSSize NeoNSSizeFromCGSize(CGSize size) {
-  return NSMakeSize(size.width, size.height);
-}
-
-NS_INLINE BOOL NeoNSUIntegerCanAdvance(NSUInteger index, NSUInteger exclusiveLimit, NSInteger advance) {
-  return
-    !(index == NSNotFound || advance == 0) &amp;&amp;
-    !(advance &lt; 0 &amp;&amp; (advance + index) &gt;= index) &amp;&amp;
-    !(advance &gt; 0 &amp;&amp; (index &gt;= exclusiveLimit || advance &gt;= (exclusiveLimit - index)));
-}
-
-
-// ----------------------------------------------------------------
-// Core Text Utilities
-// ----------------------------------------------------------------
-/**
- * Returns the lowest index of the matching line in the frame,
- * or -1 if no line in the frame matched.
- */
-extern CFIndex MTFrameGetFirstLine(
-  CTFrameRef frame,
-  CFIndex charIndex,
-  CTLineRef *found,
-  CFRange *characterRange);</diff>
      <filename>src/NeoTextView.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,71 +1,22 @@
 #import &quot;NeoTextView.h&quot;
+#import &quot;NeoUtils.h&quot;
 
 
 /**
- * Returns the bounding box of the path used to create the frame.
- */
-NS_INLINE CGRect MTFrameGetBoundingBox(CTFrameRef frame) {
-  const CGPathRef path = CTFrameGetPath(frame);
-  return path != NULL ? CGPathGetBoundingBox(path) : CGRectZero;
-}
-
-CFIndex MTFrameGetFirstLine(
-            CTFrameRef frame,
-            CFIndex    charIndex,
-            CTLineRef *found,
-            CFRange   *characterRange)
-{
-  const CFArrayRef lines = CTFrameGetLines(frame);
-  CFIndex l = 0, u = CFArrayGetCount(lines);
-
-  while (l &lt; u) {
-    const CFIndex   m     = l + ((u - l) / 2);
-    const CTLineRef line  = CFArrayGetValueAtIndex(lines, m);
-    const CFRange   range = CTLineGetStringRange(line);
-    const CFIndex   t     = charIndex - range.location;
-
-    if (t &lt; 0) u = m;
-    else if (t &gt;= range.length) l = m + 1;
-    else {
-      if (found != NULL) *found = line;
-      if (characterRange != NULL) *characterRange = range;
-      return m;
-    }
-  }
-
-  return -1;
-}
-
-/**
- * Returns a line origin for a frame.
- */
-CGPoint MTFrameGetLineOriginAtIndex(CTFrameRef frame, CFIndex index) {
-  CGPoint origin;
-  CTFrameGetLineOrigins(frame, CFRangeMake(index, 1), &amp;origin);
-  return origin;
-}
-
-static CGFloat MTLineGetTypographicWidth(CTLineRef line) {
-  double width = CTLineGetTypographicBounds(line, NULL, NULL, NULL) -
-                 CTLineGetTrailingWhitespaceWidth(line);
-  return width &gt; CGFLOAT_MAX ? CGFLOAT_MAX : (CGFloat) width;
-}
-
-/**
  * Calculates the typographic bounds of a line.
  */
 static CGSize MTLineGetTypographicSize(CTLineRef line) {
   CGFloat ascent, descent, leading;
   double w = CTLineGetTypographicBounds(line, &amp;ascent, &amp;descent, &amp;leading);
-
+  
   if (w &gt; 0.0) {
     const double h = ascent + descent + leading;
     w -= CTLineGetTrailingWhitespaceWidth(line);
-
+    
     return CGSizeMake(
-      w &gt; CGFLOAT_MAX ? CGFLOAT_MAX : (CGFloat) w,
-      h &gt; CGFLOAT_MAX ? CGFLOAT_MAX : (CGFloat) h
-    );
+                      w &gt; CGFLOAT_MAX ? CGFLOAT_MAX : (CGFloat) w,
+                      h &gt; CGFLOAT_MAX ? CGFLOAT_MAX : (CGFloat) h
+                      );
   }
   return CGSizeZero;
 }
@@ -75,22 +26,22 @@ static CGRect MTLineGetFirstRectForCharacterAtIndex(CTFrameRef frame, CTLineRef
   const CGPoint origin = MTFrameGetLineOriginAtIndex(frame, lineIndex);
   const CGFloat offset = CTLineGetOffsetForStringIndex(line, charIndex, NULL);
   const CGSize  size = MTLineGetTypographicSize(line);
-
+  
   if (CGSizeEqualToSize(size, CGSizeZero)) return CGRectNull;
   if (!verticalForms) {
     return CGRectMake(
-      origin.x + CGRectGetMinX(box) + offset,
-      origin.y - CGRectGetMinY(box),
-      size.width - offset,
-      size.height
-    );
+                      origin.x + CGRectGetMinX(box) + offset,
+                      origin.y - CGRectGetMinY(box),
+                      size.width - offset,
+                      size.height
+                      );
   } else {
     return CGRectMake(
-      origin.x,
-      origin.y - size.width + CGRectGetMinY(box),
-      size.height,
-      size.width - offset
-    );
+                      origin.x,
+                      origin.y - size.width + CGRectGetMinY(box),
+                      size.height,
+                      size.width - offset
+                      );
   }
 }
 
@@ -117,7 +68,6 @@ static NSArray *kNeoTextViewValidAttributesForMarkedText = nil;
 @end
 
 @interface NeoTextView(Support)
-- (void) setTextFrame: (CTFrameRef) frame;
 - (CTFrameRef) firstFrameForCharacterAtIndex: (NSUInteger) location;
 
 /**
@@ -132,12 +82,6 @@ static NSArray *kNeoTextViewValidAttributesForMarkedText = nil;
 
 
 @implementation NeoTextView(Support)
-- (void) setTextFrame: (CTFrameRef) frame {
-  id oldFrames = _frames;
-  _frames = [[NSArray alloc] initWithObjects:(const id*)&amp;frame count:1];
-  [oldFrames release];
-}
-
 - (CTFrameRef) firstFrameForCharacterAtIndex: (NSUInteger) location {
   if (location != NSNotFound) {
     for (id element in _frames) {
@@ -293,7 +237,8 @@ static NSArray *kNeoTextViewValidAttributesForMarkedText = nil;
       CFRangeMake(0, 0),
       container, settings);
 
-  [self setTextFrame: frame];
+  self.textFrames = [NSArray arrayWithObject:(id)frame];
+
   CFRelease(frame);
   CFRelease(framesetter);
 }</diff>
      <filename>src/NeoTextView.m</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 #import &quot;NeoTextViewTest.h&quot;
 #import &quot;NeoTextView.h&quot;
+#import &quot;NeoUtils.h&quot;
 
 
 @implementation NeoTextViewTest</diff>
      <filename>tests/NeoTextViewTest.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>139892f9f0378a58699e709d3ea319c627b578da</id>
    </parent>
  </parents>
  <author>
    <name>Takanori Ishikawa</name>
    <email>takanori.ishikawa@gmail.com</email>
  </author>
  <url>http://github.com/ishikawa/neuro/commit/280526b7ec5739140612d41d55aadb39099915c7</url>
  <id>280526b7ec5739140612d41d55aadb39099915c7</id>
  <committed-date>2009-08-03T06:59:35-07:00</committed-date>
  <authored-date>2009-08-03T06:59:35-07:00</authored-date>
  <message>Added NeoUtils</message>
  <tree>ecdd0aeb9f7e0651c8b599178ffea2558d15cfa6</tree>
  <committer>
    <name>Takanori Ishikawa</name>
    <email>takanori.ishikawa@gmail.com</email>
  </committer>
</commit>
