From bf9ffb8a95dfbe9963ec8a48f406aeca6c2c20ca Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Sun, 14 Sep 2008 13:40:58 -0700 Subject: [PATCH 1/9] Add missing setX and X methods on CPControl. Moved the logic for setStringValue to setObjectValue on CPTextField. Now, all setX's call setObject. We store native objects, and cast to the appropriate type in the getter methods. --- AppKit/CPControl.j | 66 +++++++++++++++++++++++++++++++++++++++++++- AppKit/CPTextField.j | 19 ++++++++----- 2 files changed, 77 insertions(+), 8 deletions(-) diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index d76594e3b..421b89b08 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -282,7 +282,71 @@ var CPControlBlackColor = [CPColor blackColor]; */ - (void)setFloatValue:(float)aValue { - _value = aValue; + [self setObjectValue:aValue]; +} + +/* + Returns the receiver's object value +*/ +- (id)objectValue +{ + return _value; +} + +/* + Set's the receiver's object value +*/ +- (void)setObjectValue:(id)anObject +{ + _value = anObject; +} + +/* + Returns the receiver's double value +*/ +- (id)doubleValue +{ + return [self floatValue]; +} + +/* + Set's the receiver's double value +*/ +- (void)setDoubleValue:(id)anObject +{ + [self setObjectValue:anObject]; +} + +/* + Returns the receiver's int value +*/ +- (id)intValue +{ + return _value ? parseInt(_value, 10) : 0; +} + +/* + Set's the receiver's int value +*/ +- (void)setIntValue:(id)anObject +{ + [self setObjectValue:anObject]; +} + +/* + Returns the receiver's int value +*/ +- (id)stringValue +{ + return _value ? ""+_value : ""; +} + +/* + Set's the receiver's int value +*/ +- (void)setStringValue:(id)anObject +{ + [self setObjectValue:anObject]; } - (void)setBackgroundColor:(CPColor)aColor diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 2737de94a..f1ba2d329 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -432,23 +432,28 @@ var _CPTextFieldSquareBezelColor = nil; return [[self class] _inputElement].value; #endif - return [_value string]; + return [self stringValue]; } /* - Sets the string the text field. + @ignore */ -- (void)setStringValue:(CPString)aStringValue +- (void)setObjectValue:(id)aValue { - _value = aStringValue; + [super setObjectValue:aValue]; #if PLATFORM(DOM) - var cssString = _value ? [_value cssString] : @""; + var displayString = ""; + + if ([aValue respondsToSelector:@selector(string)]) + displayString = [aValue string]; + else + displayString += aValue; if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature)) - _DOMTextElement.innerText = cssString; + _DOMTextElement.innerText = displayString; else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature)) - _DOMTextElement.textContent = cssString; + _DOMTextElement.textContent = displayString; #endif } From 6a5545b316ec5fd47a1918cf3f52e663bf4c0f51 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Mon, 15 Sep 2008 00:26:02 -0700 Subject: [PATCH 2/9] Added missing vim folder. [#40 state:resolved]. Reviewed by me. --- Tools/Vim/objj.vim | 197 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 Tools/Vim/objj.vim diff --git a/Tools/Vim/objj.vim b/Tools/Vim/objj.vim new file mode 100644 index 000000000..530fdbac8 --- /dev/null +++ b/Tools/Vim/objj.vim @@ -0,0 +1,197 @@ +" Vim syntax file +" Language: Objective-J +" Maintainer: Shawn MacIntyre +" Updaters: +" URL: +" Changes: (sm) merged javascript syntax Claudio Fleiner and Scott Shattuck and objc syntax by Kazunobu Kuriyama and Anthony Hodsdon +" Last Change: 2008 Sep 8 + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +" tuning parameters: +" unlet objj_fold + +if !exists("main_syntax") + if version < 600 + syntax clear + elseif exists("b:current_syntax") + finish + endif + let main_syntax = 'objj' +endif + +" Drop fold if it set but vim doesn't support it. +if version < 600 && exists("objj_fold") + unlet objj_fold +endif + +syn case ignore + +" objj keywords, types, type qualifiers etc. +syn keyword objjStatement self super _cmd +syn keyword objjType id Class SEL IMP BOOL +"syn keyword objjTypeModifier bycopy in out inout oneway +syn keyword objjConstant nil Nil + +" Match the objj #import directive (like C's #include) +syn region objjImported display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ +syn match objjImported display contained "<[_0-9a-zA-Z.\/]*>" +syn match objjImport display "^\s*\(%:\|#\)\s*import\>\s*["<]" contains=objjImported + +" Match the important objj directives +syn match objjScopeDecl "@public\|@private\|@protected" +syn match objjDirective "@interface\|@implementation" +syn match objjDirective "@class\|@end\|@defs" +syn match objjDirective "@encode\|@protocol\|@selector" +syn match objjDirective "@try\|@catch\|@finally\|@throw\|@synchronized" + +" Match the ObjC method types +" +" NOTE: here I match only the indicators, this looks +" much nicer and reduces cluttering color highlightings. +" However, if you prefer full method declaration matching +" append .* at the end of the next two patterns! +" +syn match objjInstMethod "^\s*-\s*" +syn match objjFactMethod "^\s*+\s*" + +" To distinguish from a header inclusion from a protocol list. +"syn match objjProtocol display "<[_a-zA-Z][_a-zA-Z0-9]*>" contains=objjType,cType,Type + + +" To distinguish labels from the keyword for a method's parameter. +syn region objjKeyForMethodParam display + \ start="^\s*[_a-zA-Z][_a-zA-Z0-9]*\s*:\s*(" + \ end=")\s*[_a-zA-Z][_a-zA-Z0-9]*" + \ contains=objjType,Type + +" Objective-C Constant Strings +syn match objjSpecial display "%@" contained +syn region objjString start=+\(@"\|"\)+ skip=+\\\\\|\\"+ end=+"+ contains=cFormat,cSpecial,objcSpecial + +" Objective-C Message Expressions +syn region objjMessage display start="\[" end="\]" contains=objjMessage,objjStatement,objjType,objjTypeModifier,objjString,objjConstant,objjDirective + +syn cluster cParenGroup add=objjMessage +syn cluster cPreProcGroup add=objjMessage + + +syn keyword objjCommentTodo TODO FIXME XXX TBD contained +syn match objjLineComment "\/\/.*" contains=objjCommentTodo +syn match objjCommentSkip "^[ \t]*\*\($\|[ \t]\+\)" +syn region objjComment start="/\*" end="\*/" contains=objjCommentTodo +syn match objjSpecial "\\\d\d\d\|\\." +syn region objjStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=objjSpecial,@htmlPreproc +syn region objjStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=objjSpecial,@htmlPreproc + +syn match objjSpecialCharacter "'\\.'" +syn match objjNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>" +syn region objjRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gi]\{0,2\}\s*$+ end=+/[gi]\{0,2\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline + +syn keyword objjConditional if else switch +syn keyword objjRepeat while for do in +syn keyword objjBranch break continue +syn keyword objjOperator new delete instanceof typeof +syn keyword objjType Array Boolean Date Function Number Object String RegExp +syn keyword objjStatement return with +syn keyword objjBoolean true false +syn keyword objjNull null undefined +syn keyword objjIdentifier arguments this var +syn keyword objjLabel case default +syn keyword objjException try catch finally throw +syn keyword objjMessage alert confirm prompt status +syn keyword objjGlobal self window top parent +syn keyword objjMember document event location +syn keyword objjDeprecated escape unescape +syn keyword objjReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile + +if exists("objj_fold") + syn match objjFunction "\" + syn region objjFunctionFold start="\.*[^};]$" end="^\z1}.*$" transparent fold keepend + + syn sync match objjSync grouphere objjFunctionFold "\" + syn sync match objjSync grouphere NONE "^}" + + setlocal foldmethod=syntax + setlocal foldtext=getline(v:foldstart) +else + syn keyword objjFunction function + syn match objjBraces "[{}\[\]]" + syn match objjParens "[()]" +endif + +syn sync fromstart +syn sync maxlines=100 + +if main_syntax == "objj" + syn sync ccomment objjComment +endif + +" Define the default highlighting. +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later: only when an item doesn't have highlighting yet +if version >= 508 || !exists("did_objj_syn_inits") + if version < 508 + let did_objj_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + HiLink objjComment Comment + HiLink objjLineComment Comment + HiLink objjCommentTodo Todo + HiLink objjSpecial Special + HiLink objjStringS String + HiLink objjStringD String + HiLink objjCharacter Character + HiLink objjSpecialCharacter objjSpecial + HiLink objjNumber objjValue + HiLink objjConditional Conditional + HiLink objjRepeat Repeat + HiLink objjBranch Conditional + HiLink objjOperator Operator + HiLink objjType Type + HiLink objjStatement Statement + HiLink objjFunction Function + HiLink objjBraces Function + HiLink objjError Error + HiLink javaScrParenError objjError + HiLink objjNull Keyword + HiLink objjBoolean Boolean + HiLink objjRegexpString String + + HiLink objjIdentifier Identifier + HiLink objjLabel Label + HiLink objjException Exception + HiLink objjMessage Keyword + HiLink objjGlobal Keyword + HiLink objjMember Keyword + HiLink objjDeprecated Exception + HiLink objjReserved Keyword + HiLink objjDebug Debug + HiLink objjConstant Label + + HiLink objjImport Include + HiLink objjImported String + HiLink objjTypeModifier objjType + HiLink objjType Type + HiLink objjScopeDecl Statement + HiLink objjInstMethod Function + HiLink objjFactMethod Function + HiLink objjStatement Statement + HiLink objjDirective Statement + HiLink objjKeyForMethodParam None + HiLink objjString String + HiLink objjSpecial Special + HiLink objjProtocol None + HiLink objjConstant Constant + + delcommand HiLink +endif + +let b:current_syntax = "objj" +if main_syntax == 'objj' + unlet main_syntax +endif + +" vim: ts=8 \ No newline at end of file From a9e9dab7e693d0a357abd966d151edda55f2d25e Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Mon, 15 Sep 2008 02:02:12 -0700 Subject: [PATCH 3/9] Fix for broken new selector. [#37 state:resolved]. Reviewed by me. --- Objective-J/preprocess.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Objective-J/preprocess.js b/Objective-J/preprocess.js index b7e736214..df246bce9 100644 --- a/Objective-J/preprocess.js +++ b/Objective-J/preprocess.js @@ -322,12 +322,9 @@ var objj_preprocess_brackets = function(tokens) // not within parenthesis or a tertiary statement. var preprocess = !braces && !tertiary && !parenthesis && !array; - // Generally we are unconcerned with whitespace, however the new - // operator is a special case since it could alse be part of an identifier. - if(token == TOKEN_NEW) token = "new "; // We handle the special case where the receiver is super. In this case, // use an objj_super object and use objj_msgSendSuper instead of objj_msgSend. - else if(token == TOKEN_SUPER) + if (token == TOKEN_SUPER) { if (!receiver.length) { @@ -385,15 +382,21 @@ var objj_preprocess_brackets = function(tokens) } } else - { + { + // Generally we are unconcerned with whitespace, however the new + // operator requires it. + if (previous == TOKEN_NEW) + previous = "new "; + // If we've already begun building our selector, then the token // should be applied to the current argument. if (selector.length) marg_list[marg_list.length - 1] += previous; - // If not, then it belongs to the receiver. - else - receiver += previous; + // If not, then it belongs to the receiver. + else + receiver += previous; + previous = token; } } @@ -409,8 +412,12 @@ var objj_preprocess_brackets = function(tokens) } // The literal interpretation is always handled in the same - // manner, simply aggregate the tokens. - literal += token; + // manner, simply aggregate the tokens, unless we have a new token, + // in which case we need to add back the whitespace we removed. + if (token == TOKEN_NEW) + literal += "new "; + else + literal += token; } // If we have a selector, then add the remaining string to the argument. @@ -425,7 +432,7 @@ var objj_preprocess_brackets = function(tokens) // array[i%] becomes arrayobjj_msgSend(i,"%") if not. This is an error either // way though. https://trac.280north.com/ticket/6 else if(!array && receiver.length && !((/[\:\+\-\*\/\=\<\>\&\|\!\.\%]/).test(receiver.charAt(receiver.length - 1))) && - receiver != "new " && !(/[\+\-\*\/\=\<\>\&\|\!\.\[\^\(]/).test(previous.charAt(0))) + receiver != TOKEN_NEW && !(/[\+\-\*\/\=\<\>\&\|\!\.\[\^\(]/).test(previous.charAt(0))) selector = previous; // If we did not build a selector through the parsing process, then we // are either a single entry literal array, or an array index, and so From 525493574cb55690b7aa8b618a5511ba162e0b42 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Wed, 17 Sep 2008 02:43:07 -0700 Subject: [PATCH 4/9] Forgot to commit this README change from 0.5.1. Reviewed by me. --- Tools/READMEs/TOOLS-README | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Tools/READMEs/TOOLS-README b/Tools/READMEs/TOOLS-README index 76a60cc24..0213d784a 100644 --- a/Tools/READMEs/TOOLS-README +++ b/Tools/READMEs/TOOLS-README @@ -13,14 +13,15 @@ This package includes syntax highlighting modes for both SubEthaEdit, Coda, Text + Coda - Unarchive Tools/Editors/Objective-J.mode.zip - - Place the generated Objective-J.mode file in ~/Library/Application\ Support/Coda/Modes + - Place the generated Objective-J.mode file in ~/Library/Application Support/Coda/Modes -+ TextMate ++ TextMate (Thanks to Michael Sheets for providing us with this!) - - Unarchive Tools/Editors/Objective-J.tmbundle.zip - - Double click the generated Objective-J.tmbundle file + - Unarchive Tools/Editors/JavaScript Objective-J.tmbundle.zip + - Double click the generated "JavaScript Objective-J.tmbundle" file + ++ Vim (Thanks to Shawn MacIntyre for providing us with this!) -+ Vim - Place Tools/Editors/objj.vim in ~/.vim/syntax/ - in ~/.vimrc, add: From b6f61029709e1d384672087bcdbc661c832a620e Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Wed, 17 Sep 2008 03:50:03 -0700 Subject: [PATCH 5/9] Fixed awakeAfterUsingCoder:. Reviewed by me. --- Foundation/CPKeyedUnarchiver.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Foundation/CPKeyedUnarchiver.j b/Foundation/CPKeyedUnarchiver.j index 009f74985..8ad737c4a 100644 --- a/Foundation/CPKeyedUnarchiver.j +++ b/Foundation/CPKeyedUnarchiver.j @@ -419,7 +419,7 @@ var _CPKeyedUnarchiverDecodeObjectAtIndex = function(self, anIndex) processedObject = [object awakeAfterUsingCoder:self]; - if (processedObject == object) + if (processedObject != object) { if (self._delegateSelectors & _CPKeyedUnarchiverWillReplaceObjectWithObjectSelector) [self._delegate unarchiver:self willReplaceObject:object withObject:processedObject]; From 6a6348e841a9274a74a73eb4102f7693f45eabf2 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 17 Sep 2008 16:06:35 -0700 Subject: [PATCH 6/9] Fix the "additional items" button in the toolbar to not be bordered. --- AppKit/CPToolbar.j | 1 + 1 file changed, 1 insertion(+) diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index 41fd31005..dc3c112c9 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -373,6 +373,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) [self setBackgroundColor:_CPToolbarViewBackgroundColor]; _additionalItemsButton = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 10.0, 15.0) pullsDown:YES]; + [_additionalItemsButton setBordered:NO]; [_additionalItemsButton setImagePosition:CPImageOnly]; [[_additionalItemsButton menu] setShowsStateColumn:NO]; From 323c6342d89e2e3ab1e32abed2f4de4e25989b72 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 17 Sep 2008 16:19:54 -0700 Subject: [PATCH 7/9] Fix for the last commit, where null values were displayed as n instead of an empty string. --- AppKit/CPTextField.j | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index f1ba2d329..26bf63952 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -439,15 +439,15 @@ var _CPTextFieldSquareBezelColor = nil; @ignore */ - (void)setObjectValue:(id)aValue -{ +{CPLog(aValue); [super setObjectValue:aValue]; #if PLATFORM(DOM) var displayString = ""; - if ([aValue respondsToSelector:@selector(string)]) + if (aValue && [aValue respondsToSelector:@selector(string)]) displayString = [aValue string]; - else + else if (aValue) displayString += aValue; if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature)) From fcc4d340982327e4b83da0d459558bae5fb325b3 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 17 Sep 2008 16:21:21 -0700 Subject: [PATCH 8/9] remove cplog --- AppKit/CPTextField.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 26bf63952..b7c8cde04 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -439,7 +439,7 @@ var _CPTextFieldSquareBezelColor = nil; @ignore */ - (void)setObjectValue:(id)aValue -{CPLog(aValue); +{ [super setObjectValue:aValue]; #if PLATFORM(DOM) From 0b81dd718c8566ec86551a668e6a2ee5441fd87a Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 17 Sep 2008 16:26:05 -0700 Subject: [PATCH 9/9] Add isEditable to the list of encoded attributes on CPTextField. reviewed by Francisco. --- AppKit/CPTextField.j | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index b7c8cde04..900015de8 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -473,7 +473,8 @@ var _CPTextFieldSquareBezelColor = nil; var CPTextFieldIsSelectableKey = @"CPTextFieldIsSelectableKey", CPTextFieldLineBreakModeKey = @"CPTextFieldLineBreakModeKey", - CPTextFieldStringValueKey = @"CPTextFieldStringValueKey"; + CPTextFieldStringValueKey = @"CPTextFieldStringValueKey", + CPTextFieldIsEditableKey = @"CPTextFieldIsEditableKey"; @implementation CPTextField (CPCoding) @@ -508,6 +509,7 @@ var CPTextFieldIsSelectableKey = @"CPTextFieldIsSelectableKey", _DOMElement.appendChild(_DOMTextElement); #endif + [self setEditable:[aCoder decodeBoolForKey:CPTextFieldIsEditableKey]]; [self setSelectable:[aCoder decodeBoolForKey:CPTextFieldIsSelectableKey]]; [self setLineBreakMode:[aCoder decodeIntForKey:CPTextFieldLineBreakModeKey]]; @@ -531,6 +533,8 @@ var CPTextFieldIsSelectableKey = @"CPTextFieldIsSelectableKey", [aCoder encodeInt:_lineBreakMode forKey:CPTextFieldLineBreakModeKey]; [aCoder encodeObject:_value forKey:CPTextFieldStringValueKey]; + + [aCoder encodeBool:_isEditable forKey:CPTextFieldIsEditableKey]; } @end