<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -425,11 +425,7 @@ var a = [o class]
 				var whitespace = prevtoken.line != token.line ? line.substr(0, token.from) : line.substr(prevtoken.character, token.from-prevtoken.character)
 				tokenStream.push(String(whitespace.match(/\s*/)))
 
-
-
 				prevtoken = token
-				
-				
 
 				// Handle shortcut function token
 				if (token.value == '&#402;')</diff>
      <filename>ObjC syntax.html</filename>
    </modified>
    <modified>
      <diff>@@ -145,7 +145,11 @@
 
 		.newline
 		{
+/*
 			white-space: normal;
+			white-space: wrap;
+			white-space: nowrap;
+*/
 			eborder: solid 3px red;
 			edisplay: inline-block;
 		}</diff>
      <filename>code colorer.css</filename>
    </modified>
    <modified>
      <diff>@@ -19,6 +19,8 @@
 		#coloredCode
 		{
 			outline: none;
+			position: relative;
+			z-index: 20;
 		}
 	
 		/*
@@ -30,6 +32,29 @@
 		{
 			vertical-align: top;
 		}
+		
+		.selectedLine
+		{
+			position: absolute;
+			width: 100%;
+			ebackground-color: red;
+			border: solid 1px #fc8;
+			border-left: 0;
+			border-right: 0;
+			margin-top: -2px;
+			background: -webkit-gradient(linear, left top, left bottom, from(#fec), to(#fda));
+		}
+		.selectedLinePosition
+		{
+			position: absolute;
+			right: 0;
+			bottom: 0;
+			text-align: right;
+			color: #f80;
+			vertical-align: bottom;
+			margin-right: 4px;
+			efont-size: 70%;
+		}
 	&lt;/style&gt;
 &lt;/head&gt;
 &lt;body&gt;
@@ -45,71 +70,7 @@ REMOVE STYLESHEET
 	&lt;/td&gt;
 &lt;/tr&gt;&lt;/table&gt;
 
-	&lt;textarea style='display: none'&gt;function va(a, b, c)
-{
-	if (a)
-		return 
-		
-	return alert('hop'), a+b*c+d, 2544.5*3455.8+55, 'hello world'
-
-	var z = a [+] b
-	
-	return if (!z)
-	return unless (z)
-
-	var view = [[NSView alloc] initWithSomething:'he' andSomethingElse:'b' andThatAgain:[1, 2, 3]]
-	var view2 = [[NSView alloc]]
-	var view3 = [[[[[NSView alloc] initWithFrame:'blah']]]]
-				
-	var objCString = @'hello'
-	var selector = @selector(initWithA:andB:andC:) + 'world' + @selector(addX:andY:) + 'hello' + @selector(alloc)
-	
-	if (a)
-	{
-		log('ehll')
-		
-		return 454,564 if (!a)
-	}
-
-	return a + b
-}
-
-	class MyClass &lt; NSView
-	{
-		// a method
-		- (void)hello:(NSView*)world andOthers:(SomeObject*)w
-		{
-			
-		}
-		// a method
-		/* hop */
-		// and another
-		// and another
-		// and another
-		/*
-			gep
-			kl
-		*/
-/* 1*/		+ (int)hop /* 2 */
-		{
-			return 4
-		}
-		IBOutlet blah
-		IBAction hop
-		{
-			
-		}
-		IBAction hop2(notifier)
-		{
-			
-		}
-		
-		swizzle - (void)drawRect:(NSRect)rect // 4
-		{
-			
-		}
-	}
-	
+	&lt;textarea style='display: none'&gt;	
 	// List launched applications
 	var apps = [[NSWorkspace sharedWorkspace] launchedApplications]
 	for (var i=0; i&lt;apps.length; i++)
@@ -671,6 +632,8 @@ REMOVE STYLESHEET
 */			
 			function	keydown()
 			{
+				
+				
 				setTimeout(postKeydown, 0)
 //				alert(event.keyCode)
 				var keyCode = event.keyCode
@@ -1818,6 +1781,9 @@ collapseToStart=function collapseToStart() {
 				this.selectedLinePosition	= newNodeAsChildOf(this.selectedLine)
 				this.tracesContainer	= newNodeAsChildOf(this.containerNode)
 				this.whiteSpaceRevealer	= newNodeAsChildOf(this.containerNode)
+				
+				this.selectedLine.className	= 'selectedLine'
+				this.selectedLinePosition.className	= 'selectedLinePosition'
 
 
 				// Measure width of one character
@@ -1845,6 +1811,7 @@ collapseToStart=function collapseToStart() {
 				this.editorNode.oncopy			= function () { return self.copy.apply(self, arguments) }
 				this.editorNode.oncut			= function () { return self.cut.apply(self, arguments) }
 				this.editorNode.onpaste			= function () { return self.paste.apply(self, arguments) }
+				this.editorNode.onmousedown		= function () { return self.mousedown.apply(self, arguments) }
 				this.postKeydownEventFunction	= function () { return self.postKeydown.apply(self, arguments) }
 			}
 			
@@ -1898,10 +1865,10 @@ collapseToStart=function collapseToStart() {
 				this.charWidth = this.fontWidthMeasurer.firstChild.offsetWidth
 			}
 
-			CCp.rawSourceFromLine = function(line)
+			CCp.sourceFromLine = function(line)
 			{
 				var t = line.innerText
-				if (line.lastChild &amp;&amp; line.lastChild.className == 'newline') t += '\n'
+//				if (line.lastChild &amp;&amp; line.lastChild.className == 'newline') t += '\n'
 				return	t
 			}
 			
@@ -1956,7 +1923,7 @@ collapseToStart=function collapseToStart() {
 						var n2 = n.previousSibling
 						while (n2)
 						{
-							if (n2.nodeType == 1)	offset2 += this.rawSourceFromLine(n2).length
+							if (n2.nodeType == 1)	offset2 += this.sourceFromLine(n2).length
 							if (n2.nodeType == 3)	offset2 += n2.nodeValue.length
 							n2 = n2.previousSibling
 						}
@@ -2076,6 +2043,18 @@ collapseToStart=function collapseToStart() {
 				this.popCaretSelection()
 			}
 			
+			// Return position - offset differs from selection offset, as tabs will count for 1 to 4 chars
+			CCp.textPositionAsLineAndOffset = function ()
+			{
+				var sel = getSelection()
+				var s = this.selectionAsLineAndOffset()
+				var line	= this.lineNodeFromNode(sel.baseNode)
+				var str = this.sourceFromLine(line).substr(0, s.offset)
+
+				var o = {}
+				this.replaceTabsInLine(str, str, null, o)
+				return { line : s.line, offset : o.totalWidth }
+			}
 
 
 			CCp.gatherLinesToLint = function ()
@@ -2084,7 +2063,7 @@ collapseToStart=function collapseToStart() {
 				var f = this.editorNode.firstChild
 				while (f)
 				{
-					var text = this.rawSourceFromLine(f)
+					var text = this.sourceFromLine(f)
 					lines.push(text)
 					f = f.nextSibling
 				}
@@ -2142,7 +2121,7 @@ collapseToStart=function collapseToStart() {
 			// Write functions
 			// 
 			//
-			CCp.replaceTabsInLine = function (line, html, customReplaceFunction)
+			CCp.replaceTabsInLine = function (line, html, customReplaceFunction, o)
 			{
 				var tabWidths = []
 				function	countTabs(str, idx)
@@ -2154,11 +2133,13 @@ collapseToStart=function collapseToStart() {
 					
 					tabWidths.push(length)
 				}
+
 				var tabIndex = 0
 				var charWidth = this.charWidth
 				function	replaceTabs(str, idx)
 				{
 					// A tab is surrounded by a SPAN nulling its width (with negative letter-spacing) and padding it to the correct 4-size with charWidth (measured in fontWidthMeasurer)
+					totalWidth += tabWidths[tabIndex]
 					var w1 = charWidth
 					var w2 = tabWidths[tabIndex++]*charWidth
 					return '&lt;span class=&quot;fakeTab&quot; style=&quot;letter-spacing: -' + w1 + 'px; padding-right: ' + w2 + 'px&quot;&gt;	&lt;/span&gt;'
@@ -2166,9 +2147,16 @@ collapseToStart=function collapseToStart() {
 				var tabWidth = this.tabWidth()
 				var deltaTabPosition = 0
 
+				// Count tabs
 				line.replace(/\t/g, countTabs)
-				var fn = customReplaceFunction ? function () { return customReplaceFunction(tabWidths[tabIndex++]) } : replaceTabs
-				html = html.replace(/\t/g, fn)
+				// Total character width of line (counting a full tab as tabWidth())
+				var totalWidth = line.length - tabWidths.length
+				// Replace tabs
+				html = html.replace(/\t/g, customReplaceFunction ? function () { return customReplaceFunction(tabWidths[tabIndex++]) } : replaceTabs)
+				
+				// Output totalWidth
+				if (o)	o.totalWidth = totalWidth
+				
 				return	html
 			}
 			CCp.tabWidth = function ()
@@ -2274,6 +2262,10 @@ collapseToStart=function collapseToStart() {
 			// 
 			CCp.keydown = function ()
 			{
+				var str = getTickCount() + ' keydown&lt;br&gt;'
+				str += event.keyCode
+				this.birdViewNode.innerHTML = str
+
 				setTimeout(this.postKeydownEventFunction, 0)
 //				alert(event.keyCode)
 				var keyCode = event.keyCode
@@ -2303,7 +2295,7 @@ collapseToStart=function collapseToStart() {
 				lineCount			= this.editorNode.childNodes.length
 				currentLineNumber 	= this.lineNumberFromNode(sel.baseNode)
 //				currentLineText 	= lineNode.innerText
-				currentLineText		= this.rawSourceFromLine(lineNode)
+				currentLineText		= this.sourceFromLine(lineNode)
 //				previousLineText	= lineNode.previousSibling ? lineNode.previousSibling.innerText : null
 //				nextLineText		= lineNode.nextSibling ? lineNode.nextSibling.innerText : null
 				
@@ -2385,8 +2377,8 @@ collapseToStart=function collapseToStart() {
 						{
 							var line = this.nodeFromLineNumber(i)
 							var t
-							if (!event.shiftKey)	t = '\t' + this.rawSourceFromLine(line)
-							else					t = this.rawSourceFromLine(line).toString().replace(/^\s/, '')
+							if (!event.shiftKey)	t = '\t' + this.sourceFromLine(line)
+							else					t = this.sourceFromLine(line).toString().replace(/^\s/, '')
 							
 							line.innerHTML = this.replaceTabsInLine(t, t)
 						}
@@ -2409,7 +2401,7 @@ collapseToStart=function collapseToStart() {
 					{
 						event.preventDefault()
 						this.pushCaretSelection()
-						lineNode.innerText = this.rawSourceFromLine(lineNode)
+						lineNode.innerText = this.sourceFromLine(lineNode)
 						this.popCaretSelection()
 						var l = this.lineNumberFromNode(sel.baseNode)
 						
@@ -2434,13 +2426,13 @@ collapseToStart=function collapseToStart() {
 						n.className = 'line'
 						
 						// Add \n if it's not here (happens on one-line documents)
-						var rightText = this.rawSourceFromLine(line).substr(leftLength)
+						var rightText = this.sourceFromLine(line).substr(leftLength)
 						if (!rightText.match(/\n/)) rightText += '\n'
 						// Get space (minus \n) on cursor left
-						var leftSpace = this.rawSourceFromLine(line).substr(0, leftLength).toString().match(/^\s*/).toString().replace(/(\r|\n)/g, '').toString()
+						var leftSpace = this.sourceFromLine(line).substr(0, leftLength).toString().match(/^\s*/).toString().replace(/(\r|\n)/g, '').toString()
 						
 						// Add a tab if we're pressing enter AFTER a brace
-						if (this.rawSourceFromLine(line).match(/^\s*\{/) &amp;&amp; !rightText.match(/\{/))	leftSpace += '	'
+						if (this.sourceFromLine(line).match(/^\s*\{/) &amp;&amp; !rightText.match(/\{/))	leftSpace += '	'
 						
 //						alert(line.innerText)
 						
@@ -2450,7 +2442,7 @@ collapseToStart=function collapseToStart() {
 						
 						line.insertAdjacentElement('afterEnd', n)
 //						line.innerText = line.innerText.substr(0, leftLength) + '\n'
-						var text = this.rawSourceFromLine(line).substr(0, leftLength) + '\n'
+						var text = this.sourceFromLine(line).substr(0, leftLength) + '\n'
 						lineNode.innerHTML = this.replaceTabsInLine(text, text)
 
 						if (keyCode == 13)
@@ -2477,8 +2469,19 @@ collapseToStart=function collapseToStart() {
 				*/
 			}
 			
+			CCp.mousedown = function()
+			{
+				var self = this
+				function h()
+				{
+					self.highlightSelectedLine()
+				}
+				setTimeout(h, 0)
+			}
+			
 			CCp.postKeydown = function ()
 			{
+				this.highlightSelectedLine()
 				var sel = getSelection()
 //				var lineNumber = lineNumberFromNode(sel.baseNode)
 				
@@ -2517,7 +2520,7 @@ collapseToStart=function collapseToStart() {
 				var lineCount2			= this.editorNode.childNodes.length
 				var currentLineNumber2 	= this.lineNumberFromNode(sel.baseNode)
 				
-				var currentLineText2 	= this.rawSourceFromLine(this.lineNodeFromNode(sel.baseNode))
+				var currentLineText2 	= this.sourceFromLine(this.lineNodeFromNode(sel.baseNode))
 
 				
 
@@ -2610,6 +2613,22 @@ var str = getTickCount()
 
 //				alert(lines)
 				
+				
+			}
+			CCp.highlightSelectedLine = function ()
+			{
+				var sel = getSelection()
+				var line	= this.lineNodeFromNode(sel.baseNode)
+				this.selectedLine.style.top		= line.offsetTop + 'px'
+				this.selectedLine.style.height	= (line.offsetHeight+1) + 'px'
+
+//				var s = this.selectionAsLineAndOffset()
+
+
+				var s = this.textPositionAsLineAndOffset()
+				this.selectedLinePosition.innerHTML = (s.line+1) + ',' + (s.offset+1)
+
+//				this.selectedLine.style
 			}
 			
 			CCp.copy = function ()
@@ -2645,7 +2664,7 @@ var str = getTickCount()
 
 				// Split line according to caret : prefix (caret) suffix
 				var ll		= this.nodeFromLineNumber(caret.line)
-				var text	= this.rawSourceFromLine(ll)
+				var text	= this.sourceFromLine(ll)
 				var prefix	= text.substr(0, caret.offset)
 				var suffix	= text.substr(caret.offset)
 
@@ -2668,7 +2687,7 @@ var str = getTickCount()
 					newLineForCaret++
 				}
 				// Append suffix to last line
-				var newOffsetForCaret = this.rawSourceFromLine(currentLine).length
+				var newOffsetForCaret = this.sourceFromLine(currentLine).length
 				currentLine.innerText += suffix
 				
 				this.setSelectionAsLineAndOffset(newLineForCaret, newOffsetForCaret)
@@ -2738,6 +2757,25 @@ var str = getTickCount()
 * DO NOT LINT below a line where we typed ?
 * markdown : allow custom tags like &amp;lt;ObjC&amp;gt;NSView&amp;lt;/ObjC&amp;gt;, linking to google &quot;innerText reference&quot; site:apple.com, lucky=yes
 * css classes to highlight return (eg add an arrow), continue to indicate where the loop is continuing, break ... ?
-* non-dot on non selector call
+* BUG : ctrl+o
+	MOVE
+		ctrl+A line start
+		ctrl+E line end
+		ctrl+T invert pre and post caret chars, advance caret
+		ctrl+Y paste?
+		ctrl+P move to end of previous line
+		ctrl+F advance caret
+		ctrl+B backwards caret
+		ctrl+N move to next line
+	EDIT
+		ctrl+O insert line in place
+		ctrl+Q ?????
+		ctrl+D front delete
+		ctrl+H backwards delete
+		ctrl+K delete to end of line
+		
+* before undo, or after move, call commitTypingTransaction() to save undo state		
+
+
 &lt;/body&gt;
 &lt;/html&gt;</diff>
      <filename>code colorer.html</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6278d1cc7dbb5176b2fe29c1c5ad0cae88990125</id>
    </parent>
  </parents>
  <author>
    <name>Patrick Geiller</name>
    <email>parmanoir@gmail.com</email>
  </author>
  <url>http://github.com/parmanoir/lintex/commit/4e66c76242a5d7e6a1bc4fb756ca009bccab81a6</url>
  <id>4e66c76242a5d7e6a1bc4fb756ca009bccab81a6</id>
  <committed-date>2009-10-06T12:23:46-07:00</committed-date>
  <authored-date>2009-10-06T12:23:46-07:00</authored-date>
  <message>pre clean away old non class functions</message>
  <tree>e4301f31068b8f46b3ccb9168f6f3ec03058c2e9</tree>
  <committer>
    <name>Patrick Geiller</name>
    <email>parmanoir@gmail.com</email>
  </committer>
</commit>
