diff --git a/Frameworks/AppKit/Browser.environment/AppKit.sj b/Frameworks/AppKit/Browser.environment/AppKit.sj index dbb47a9ca..799733023 100644 --- a/Frameworks/AppKit/Browser.environment/AppKit.sj +++ b/Frameworks/AppKit/Browser.environment/AppKit.sj @@ -68532,7 +68532,7 @@ CPRuleEditorNestingModeSimple = 3; objj_registerTypeDef(the_typedef); }CPRuleEditorRowTypeSimple = 0; CPRuleEditorRowTypeCompound = 1; -p;14;_CPRTFParser.jt;33053;@STATIC;1.0;I;31;Foundation/CPAttributedString.jI;23;Foundation/CPGeometry.ji;15;CPFontManager.ji;18;CPParagraphStyle.jt;32926;objj_executeFile("Foundation/CPAttributedString.j", NO);objj_executeFile("Foundation/CPGeometry.j", NO);objj_executeFile("CPFontManager.j", YES);objj_executeFile("CPParagraphStyle.j", YES);var hexTable = []; +p;14;_CPRTFParser.jt;56413;@STATIC;1.0;I;31;Foundation/CPAttributedString.jI;23;Foundation/CPGeometry.ji;15;CPTextStorage.ji;15;CPFontManager.ji;18;CPParagraphStyle.ji;24;_CPTableTextAttachment.jt;56237;objj_executeFile("Foundation/CPAttributedString.j", NO);objj_executeFile("Foundation/CPGeometry.j", NO);objj_executeFile("CPTextStorage.j", YES);objj_executeFile("CPFontManager.j", YES);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("_CPTableTextAttachment.j", YES);var hexTable = []; var cp1252Map = {0x80: 0x20AC, 0x82: 0x201A, 0x83: 0x0192, 0x84: 0x201E, 0x85: 0x2026, 0x86: 0x2020, 0x87: 0x2021, 0x88: 0x02C6, 0x89: 0x2030, 0x8A: 0x0160, 0x8B: 0x2039, 0x8C: 0x0152, 0x8E: 0x017D, 0x91: 0x2018, 0x92: 0x2019, 0x93: 0x201C, 0x94: 0x201D, 0x95: 0x2022, 0x96: 0x2013, 0x97: 0x2014, 0x98: 0x02DC, 0x99: 0x2122, 0x9A: 0x0161, 0x9B: 0x203A, 0x9C: 0x0153, 0x9E: 0x017E, 0x9F: 0x0178}; {var the_class = objj_allocateClassPair(CPObject, "_RTFAttribute"), @@ -68629,7 +68629,14 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $_RTFA ,["void"]), new objj_method(sel_getUid("addTab:type:"), function $_RTFAttribute__addTab_type_(self, _cmd, location, type) { - var tab = ((___r1 = (CPTextTab.isa.method_msgSend["alloc"] || _objj_forward)(CPTextTab, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithType:location:"] || _objj_forward)(___r1, "initWithType:location:", type, location)); + var alignment = CPLeftTextAlignment; + if (type === CPCenterTabStopType || type === CPCenterTextAlignment) + alignment = CPCenterTextAlignment; + else if (type === CPRightTabStopType || type === CPRightTextAlignment) + alignment = CPRightTextAlignment; + else if (type === CPDecimalTabStopType) + alignment = CPRightTextAlignment; + var tab = ((___r1 = (CPTextTab.isa.method_msgSend["alloc"] || _objj_forward)(CPTextTab, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithType:location:"] || _objj_forward)(___r1, "initWithType:location:", alignment, location)); if (!self._tabChanged) { ((___r1 = self.paragraph), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setTabStops:"] || _objj_forward)(___r1, "setTabStops:", [tab])); @@ -68652,6 +68659,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $_RTFA (ret == null ? ret : (ret.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(ret, "setObject:forKey:", self.fgColour, CPForegroundColorAttributeName)); if (self.bgColour) (ret == null ? ret : (ret.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(ret, "setObject:forKey:", self.bgColour, CPBackgroundColorAttributeName)); + if (self.underline) + (ret == null ? ret : (ret.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(ret, "setObject:forKey:", (CPNumber.isa.method_msgSend["numberWithInt:"] || _objj_forward)(CPNumber, "numberWithInt:", 1), CPUnderlineStyleAttributeName)); return ret; var ___r1; } @@ -68662,10 +68671,10 @@ var kRTFParserType_char = 0, kRTFParserType_dest = 1, kRTFParserType_prop = 2, kRTFParserType_spec = 3; -var kRgsymRtf = {"b": ["b", 1, false, kRTFParserType_prop, "propBold"], "ul": ["ul", 1, false, kRTFParserType_prop, "propUnderline"], "i": ["i", 1, false, kRTFParserType_prop, "propItalic"], "pgnucltr": ["pgnucltr", "pgULtr", true, kRTFParserType_prop, "propPgnFormat"], "pgnlcltr": ["pgnlcltr", "pgLLtr", true, kRTFParserType_prop, "propPgnFormat"], "qc": ["qc", "justC", true, kRTFParserType_prop, "propJust"], "ql": ["ql", "justL", true, kRTFParserType_prop, "propJust"], "qr": ["qr", "justR", true, kRTFParserType_prop, "propJust"], "qj": ["qj", "justF", true, kRTFParserType_prop, "propJust"], "paperw": ["paperw", 12240, false, kRTFParserType_prop, "propXaPage"], "paperh": ["paperh", 15480, false, kRTFParserType_prop, "propYaPage"], "margl": ["margl", 1800, false, kRTFParserType_prop, "propXaLeft"], "margr": ["margr", 1800, false, kRTFParserType_prop, "propXaRight"], "margt": ["margt", 1440, false, kRTFParserType_prop, "propYaTop"], "margb": ["margb", 1440, false, kRTFParserType_prop, "propYaBottom"], "pgnstart": ["pgnstart", 1, true, kRTFParserType_prop, "propPgnStart"], "facingp": ["facingp", 1, true, kRTFParserType_prop, "propFacingp"], "landscape": ["landscape", 1, true, kRTFParserType_prop, "propLandscape"], "par": ["par", 0, false, kRTFParserType_char, "\n"], "pard": ["pard", 0, false, kRTFParserType_prop, "propDefaultPara"], "\0x0a": ["\0x0a", 0, false, kRTFParserType_char, "\n"], "\0x0d": ["\0x0d", 0, false, kRTFParserType_char, ""], "tab": ["tab", 0, false, kRTFParserType_char, "\t"], "ldblquote": ["ldblquote", 0, false, kRTFParserType_char, '"'], "rdblquote": ["rdblquote", 0, false, kRTFParserType_char, '"'], "bin": ["bin", 0, false, kRTFParserType_spec, "ipfnBin"], "*": ["*", 0, false, kRTFParserType_spec, "ipfnDestSkip"], "'": ["'", 0, false, kRTFParserType_spec, "ipfnHex"], "author": ["author", 0, false, kRTFParserType_dest, "destSkip"], "buptim": ["buptim", 0, false, kRTFParserType_dest, "destSkip"], "colortbl": ["colortbl", 0, false, kRTFParserType_dest, "destSkip"], "comment": ["comment", 0, false, kRTFParserType_dest, "destSkip"], "creatim": ["creatim", 0, false, kRTFParserType_dest, "destSkip"], "doccomm": ["doccomm", 0, false, kRTFParserType_dest, "destSkip"], "fonttbl": ["fonttbl", 0, false, kRTFParserType_dest, "destSkip"], "footer": ["footer", 0, false, kRTFParserType_dest, "destSkip"], "footerf": ["footerf", 0, false, kRTFParserType_dest, "destSkip"], "footerl": ["footerl", 0, false, kRTFParserType_dest, "destSkip"], "footerr": ["footerr", 0, false, kRTFParserType_dest, "destSkip"], "footnote": ["footnote", 0, false, kRTFParserType_dest, "destSkip"], "ftncn": ["ftncn", 0, false, kRTFParserType_dest, "destSkip"], "ftnsep": ["ftnsep", 0, false, kRTFParserType_dest, "destSkip"], "ftnsepc": ["ftnsepc", 0, false, kRTFParserType_dest, "destSkip"], "fprq": ["fprq", 0, false, kRTFParserType_dest, "destSkip"], "rquote": ["rquote", 0, false, kRTFParserType_char, "'"], "header": ["header", 0, false, kRTFParserType_dest, "destSkip"], "headerf": ["headerf", 0, false, kRTFParserType_dest, "destSkip"], "headerl": ["headerl", 0, false, kRTFParserType_dest, "destSkip"], "headerr": ["headerr", 0, false, kRTFParserType_dest, "destSkip"], "info": ["info", 0, false, kRTFParserType_dest, "destSkip"], "keywords": ["keywords", 0, false, kRTFParserType_dest, "destSkip"], "operator": ["operator", 0, false, kRTFParserType_dest, "destSkip"], "pict": ["pict", 0, false, kRTFParserType_dest, "destSkip"], "printim": ["printim", 0, false, kRTFParserType_dest, "destSkip"], "private1": ["private1", 0, false, kRTFParserType_dest, "destSkip"], "revtim": ["revtim", 0, false, kRTFParserType_dest, "destSkip"], "rxe": ["rxe", 0, false, kRTFParserType_dest, "destSkip"], "stylesheet": ["stylesheet", 0, false, kRTFParserType_dest, "destSkip"], "subject": ["subject", 0, false, kRTFParserType_dest, "destSkip"], "tc": ["tc", 0, false, kRTFParserType_dest, "destSkip"], "title": ["title", 0, false, kRTFParserType_dest, "destSkip"], "txe": ["txe", 0, false, kRTFParserType_dest, "destSkip"], "xe": ["xe", 0, false, kRTFParserType_dest, "destSkip"], "[": ["[", 0, false, kRTFParserType_char, '['], " ": [" ", 0, false, kRTFParserType_char, ' '], "]": ["]", 0, false, kRTFParserType_char, ']'], "{": ["{", 0, false, kRTFParserType_char, '{'], "}": ["}", 0, false, kRTFParserType_char, '}'], "\\": ["\\", 0, false, kRTFParserType_char, '\\']}; +var kRgsymRtf = {"b": ["b", 1, false, kRTFParserType_prop, "propBold"], "ul": ["ul", 1, false, kRTFParserType_prop, "propUnderline"], "i": ["i", 1, false, kRTFParserType_prop, "propItalic"], "pgnucltr": ["pgnucltr", "pgULtr", true, kRTFParserType_prop, "propPgnFormat"], "pgnlcltr": ["pgnlcltr", "pgLLtr", true, kRTFParserType_prop, "propPgnFormat"], "qc": ["qc", "justC", true, kRTFParserType_prop, "propJust"], "ql": ["ql", "justL", true, kRTFParserType_prop, "propJust"], "qr": ["qr", "justR", true, kRTFParserType_prop, "propJust"], "qj": ["qj", "justF", true, kRTFParserType_prop, "propJust"], "paperw": ["paperw", 12240, false, kRTFParserType_prop, "propXaPage"], "paperh": ["paperh", 15480, false, kRTFParserType_prop, "propYaPage"], "margl": ["margl", 1800, false, kRTFParserType_prop, "propXaLeft"], "margr": ["margr", 1800, false, kRTFParserType_prop, "propXaRight"], "margt": ["margt", 1440, false, kRTFParserType_prop, "propYaTop"], "margb": ["margb", 1440, false, kRTFParserType_prop, "propYaBottom"], "pgnstart": ["pgnstart", 1, true, kRTFParserType_prop, "propPgnStart"], "facingp": ["facingp", 1, true, kRTFParserType_prop, "propFacingp"], "landscape": ["landscape", 1, true, kRTFParserType_prop, "propLandscape"], "par": ["par", 0, false, kRTFParserType_char, "\n"], "pard": ["pard", 0, false, kRTFParserType_prop, "propDefaultPara"], "\0x0a": ["\0x0a", 0, false, kRTFParserType_char, "\n"], "\0x0d": ["\0x0d", 0, false, kRTFParserType_char, ""], "tab": ["tab", 0, false, kRTFParserType_char, "\t"], "ldblquote": ["ldblquote", 0, false, kRTFParserType_char, '"'], "rdblquote": ["rdblquote", 0, false, kRTFParserType_char, '"'], "bin": ["bin", 0, false, kRTFParserType_spec, "ipfnBin"], "*": ["*", 0, false, kRTFParserType_spec, "ipfnDestSkip"], "'": ["'", 0, false, kRTFParserType_spec, "ipfnHex"], "author": ["author", 0, false, kRTFParserType_dest, "destSkip"], "buptim": ["buptim", 0, false, kRTFParserType_dest, "destSkip"], "colortbl": ["colortbl", 0, false, kRTFParserType_dest, "destSkip"], "comment": ["comment", 0, false, kRTFParserType_dest, "destSkip"], "creatim": ["creatim", 0, false, kRTFParserType_dest, "destSkip"], "doccomm": ["doccomm", 0, false, kRTFParserType_dest, "destSkip"], "fonttbl": ["fonttbl", 0, false, kRTFParserType_dest, "destSkip"], "footer": ["footer", 0, false, kRTFParserType_dest, "destSkip"], "footerf": ["footerf", 0, false, kRTFParserType_dest, "destSkip"], "footerl": ["footerl", 0, false, kRTFParserType_dest, "destSkip"], "footerr": ["footerr", 0, false, kRTFParserType_dest, "destSkip"], "footnote": ["footnote", 0, false, kRTFParserType_dest, "destSkip"], "ftncn": ["ftncn", 0, false, kRTFParserType_dest, "destSkip"], "ftnsep": ["ftnsep", 0, false, kRTFParserType_dest, "destSkip"], "ftnsepc": ["ftnsepc", 0, false, kRTFParserType_dest, "destSkip"], "fprq": ["fprq", 0, false, kRTFParserType_dest, "destSkip"], "rquote": ["rquote", 0, false, kRTFParserType_char, "'"], "header": ["header", 0, false, kRTFParserType_dest, "destSkip"], "headerf": ["headerf", 0, false, kRTFParserType_dest, "destSkip"], "headerl": ["headerl", 0, false, kRTFParserType_dest, "destSkip"], "headerr": ["headerr", 0, false, kRTFParserType_dest, "destSkip"], "info": ["info", 0, false, kRTFParserType_dest, "destSkip"], "keywords": ["keywords", 0, false, kRTFParserType_dest, "destSkip"], "operator": ["operator", 0, false, kRTFParserType_dest, "destSkip"], "pict": ["pict", 0, false, kRTFParserType_dest, "destSkip"], "printim": ["printim", 0, false, kRTFParserType_dest, "destSkip"], "private1": ["private1", 0, false, kRTFParserType_dest, "destSkip"], "revtim": ["revtim", 0, false, kRTFParserType_dest, "destSkip"], "rxe": ["rxe", 0, false, kRTFParserType_dest, "destSkip"], "stylesheet": ["stylesheet", 0, false, kRTFParserType_dest, "destSkip"], "subject": ["subject", 0, false, kRTFParserType_dest, "destSkip"], "tc": ["tc", 0, false, kRTFParserType_dest, "destSkip"], "title": ["title", 0, false, kRTFParserType_dest, "destSkip"], "txe": ["txe", 0, false, kRTFParserType_dest, "destSkip"], "xe": ["xe", 0, false, kRTFParserType_dest, "destSkip"], "[": ["[", 0, false, kRTFParserType_char, '['], " ": [" ", 0, false, kRTFParserType_char, ' '], "]": ["]", 0, false, kRTFParserType_char, ']'], "{": ["{", 0, false, kRTFParserType_char, '{'], "}": ["}", 0, false, kRTFParserType_char, '}'], "\\": ["\\", 0, false, kRTFParserType_char, '\\'], "trowd": ["trowd", 0, false, kRTFParserType_spec, "ipfnTrowd"], "cell": ["cell", 0, false, kRTFParserType_spec, "ipfnCell"], "row": ["row", 0, false, kRTFParserType_spec, "ipfnRow"], "cellx": ["cellx", 0, false, kRTFParserType_spec, "ipfnCellx"], "intbl": ["intbl", 0, false, kRTFParserType_spec, "ipfnIntbl"]}; {var the_class = objj_allocateClassPair(CPObject, "_CPRTFParser"), -meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_codePage", "CPString"), new objj_ivar("_paper", "CGSize"), new objj_ivar("_rtf", "CPString"), new objj_ivar("_curState", "unsigned"), new objj_ivar("_states", "CPArray"), new objj_ivar("_currentParseIndex", "unsigned"), new objj_ivar("_hexreturn", "BOOL"), new objj_ivar("_currentRun", "_RTFAttribute"), new objj_ivar("_result", "CPAttributedString"), new objj_ivar("_colorArray", "CPArray"), new objj_ivar("_fontArray", "CPArray"), new objj_ivar("_freename", "CPString"), new objj_ivar("_parsingFontTable", "BOOL")]);objj_registerClassPair(the_class); +meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_codePage", "CPString"), new objj_ivar("_paper", "CGSize"), new objj_ivar("_rtf", "CPString"), new objj_ivar("_curState", "unsigned"), new objj_ivar("_states", "CPArray"), new objj_ivar("_currentParseIndex", "unsigned"), new objj_ivar("_hexreturn", "BOOL"), new objj_ivar("_currentRun", "_RTFAttribute"), new objj_ivar("_result", "CPAttributedString"), new objj_ivar("_colorArray", "CPArray"), new objj_ivar("_fontArray", "CPArray"), new objj_ivar("_freename", "CPString"), new objj_ivar("_parsingFontTable", "BOOL"), new objj_ivar("_inTableActive", "BOOL"), new objj_ivar("_waitingForNextRow", "BOOL"), new objj_ivar("_tableRows", "CPMutableArray"), new objj_ivar("_currentRow", "CPMutableArray"), new objj_ivar("_currentCellText", "CPString")]);objj_registerClassPair(the_class); class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $_CPRTFParser__init(self, _cmd) { if (self = (objj_getClass("_CPRTFParser").super_class.method_dtable["init"] || _objj_forward)(self, "init")) @@ -68681,6 +68690,12 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $_CPRT self._fontArray = ['Arial']; self._freename = ""; self._parsingFontTable = NO; + self._inTableActive = NO; + self._waitingForNextRow = NO; + self._tableRows = nil; + self._currentRow = nil; + self._currentCellText = ""; + self._currentRun = (_RTFAttribute.isa.method_msgSend["new"] || _objj_forward)(_RTFAttribute, "new"); } return self; } @@ -68714,7 +68729,15 @@ default: self._curState = state.curState; (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); self._currentRun = state.run; + if (!self._currentRun) + { + self._currentRun = (_RTFAttribute.isa.method_msgSend["new"] || _objj_forward)(_RTFAttribute, "new"); + } self._currentRun._range = CPMakeRange(((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["length"] || _objj_forward)(___r1, "length")), 0); + if (self._curState == 0) + { + self._parsingFontTable = NO; + } } return YES; var ___r1; @@ -68759,11 +68782,78 @@ default: self._codePage = code; self._currentParseIndex--; break; + case "ipfnTrowd": + if (self._waitingForNextRow) + { + self._waitingForNextRow = NO; + } + if (!self._inTableActive) + { + self._inTableActive = YES; + self._tableRows = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + self._currentRow = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + self._currentCellText = ""; + } + else + { + self._currentRow = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + } + return ''; + case "ipfnIntbl": + return ''; + case "ipfnCell": + if (self._inTableActive) + { + if (!self._currentRow) + self._currentRow = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + ((___r1 = self._currentRow), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addObject:"] || _objj_forward)(___r1, "addObject:", self._currentCellText)); + self._currentCellText = ""; + } + return ''; + case "ipfnRow": + if (self._inTableActive) + { + if (!self._currentRow) + self._currentRow = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addObject:"] || _objj_forward)(___r1, "addObject:", self._currentRow)); + self._waitingForNextRow = YES; + } + return ''; + case "ipfnCellx": + return ''; } return ''; + var ___r1; } -,["CPString","CPArray","CPString"]), new objj_method(sel_getUid("_flushCurrentRun"), function $_CPRTFParser___flushCurrentRun(self, _cmd) +,["CPString","CPArray","CPString"]), new objj_method(sel_getUid("_flushTableIfAny"), function $_CPRTFParser___flushTableIfAny(self, _cmd) +{ + if (self._tableRows && ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + { + (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); + var headers = ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", 0)); + var rows = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + for (var idx = 1; idx < ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); idx++) + { + (rows == null ? rows : (rows.isa.method_msgSend["addObject:"] || _objj_forward)(rows, "addObject:", ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", idx)))); + } + var attachment = ((___r1 = (_CPTableTextAttachment.isa.method_msgSend["alloc"] || _objj_forward)(_CPTableTextAttachment, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithHeaders:rows:width:"] || _objj_forward)(___r1, "initWithHeaders:rows:width:", headers, rows, 500.0)); + var tableAttrStr = (CPTextStorage.isa.method_msgSend["attributedStringWithAttachment:"] || _objj_forward)(CPTextStorage, "attributedStringWithAttachment:", attachment); + ((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(___r1, "appendAttributedString:", tableAttrStr)); + if (self._currentRun) + { + self._currentRun._range = CPMakeRange(((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["length"] || _objj_forward)(___r1, "length")), 0); + } + self._tableRows = nil; + self._currentRow = nil; + self._currentCellText = ""; + self._inTableActive = NO; + self._waitingForNextRow = NO; + } + var ___r1; +} + +,["void"]), new objj_method(sel_getUid("_flushCurrentRun"), function $_CPRTFParser___flushCurrentRun(self, _cmd) { var newOffset = 0; if (self._currentRun) @@ -68819,6 +68909,20 @@ default: self._currentRun.italic = YES; } break; + case "ul": + if (param === 0) + { + if (self._currentRun && self._currentRun.underline) + (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); + self._currentRun.underline = NO; + } + else + { + if (self._currentRun && !self._currentRun.underline) + (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); + self._currentRun.underline = YES; + } + break; case "qc": ((___r1 = self._currentRun.paragraph), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setAlignment:"] || _objj_forward)(___r1, "setAlignment:", CPCenterTextAlignment)); break; @@ -68854,7 +68958,6 @@ default: } if (sym[4] == "destSkip") { - CPLogConsole("Dest skip start : [" + sym[0] + "]"); self._curState++; } return ''; @@ -68862,6 +68965,13 @@ default: ,["CPString","CPArray"]), new objj_method(sel_getUid("_translateKeyword:parameter:fParameter:"), function $_CPRTFParser___translateKeyword_parameter_fParameter_(self, _cmd, keyword, param, fParam) { + if (self._waitingForNextRow) + { + if (keyword !== "trowd" && keyword !== "cell" && keyword !== "row" && keyword !== "intbl" && keyword !== "cellx") + { + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); + } + } if (kRgsymRtf[keyword] !== undefined) { var sym = kRgsymRtf[keyword]; @@ -68965,7 +69075,7 @@ default: ((___r1 = self._currentRun), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addTab:type:"] || _objj_forward)(___r1, "addTab:type:", location, self._currentRun._nextTabType)); break; default: - CPLogConsole("skip : " + keyword + " param: " + param); + break; } return ''; } @@ -69010,7 +69120,14 @@ default: ,["CPString","CPString","unsigned"]), new objj_method(sel_getUid("_appendPlainString:"), function $_CPRTFParser___appendPlainString_(self, _cmd, aString) { - ((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["replaceCharactersInRange:withString:"] || _objj_forward)(___r1, "replaceCharactersInRange:withString:", CPMakeRange(((___r2 = self._result), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["length"] || _objj_forward)(___r2, "length")), 0), aString)); + if (self._inTableActive) + { + self._currentCellText += aString; + } + else + { + ((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["replaceCharactersInRange:withString:"] || _objj_forward)(___r1, "replaceCharactersInRange:withString:", CPMakeRange(((___r2 = self._result), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["length"] || _objj_forward)(___r2, "length")), 0), aString)); + } var ___r1, ___r2; } @@ -69028,6 +69145,10 @@ default: while (self._currentParseIndex < len) { tmp = rtf.charAt(++self._currentParseIndex); + if (self._waitingForNextRow && tmp !== "\\" && tmp !== " " && tmp !== "\n" && tmp !== "\r" && tmp !== "\t") + { + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); + } if (tmp !== "\\" && hex.length > 0) { (self.isa.method_msgSend["_appendPlainString:"] || _objj_forward)(self, "_appendPlainString:", String.fromCharCode(parseInt(hex, 16))); @@ -69046,22 +69167,23 @@ default: } break; case "{": + if (self._waitingForNextRow) + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); if ((self.isa.method_msgSend["pushState"] || _objj_forward)(self, "pushState")) - CPLogConsole("push"); - break; + break; case "}": + if (self._waitingForNextRow) + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); if ((self.isa.method_msgSend["popState"] || _objj_forward)(self, "popState")) - CPLogConsole("pop"); - if (self._freename) - { - CPLogConsole(self._freename); - if (self._parsingFontTable) + if (self._freename) { - self._fontArray.push(self._freename); - self._parsingFontTable = NO; + if (self._parsingFontTable) + { + self._fontArray.push(self._freename); + self._parsingFontTable = NO; + } + self._freename = ""; } - self._freename = ""; - } (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); break; case "\\": @@ -69098,18 +69220,283 @@ default: default: lastchar = 0; if (self._curState == 0) + { (self.isa.method_msgSend["_appendPlainString:"] || _objj_forward)(self, "_appendPlainString:", tmp); - else if (tmp !== ';') - self._freename += tmp; + } + else + { + if (tmp === ';') + { + if (self._parsingFontTable && self._freename) + { + var cleanFontName = self._freename.trim(); + var lastSpaceIdx = cleanFontName.lastIndexOf(' '); + if (lastSpaceIdx !== -1) + { + cleanFontName = cleanFontName.substring(lastSpaceIdx + 1); + } + self._fontArray.push(cleanFontName); + self._freename = ""; + } + } + else + { + self._freename += tmp; + } + } break; } } + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); return self._result; } ,["CPAttributedString","CPString"])]); } -p;16;_CPRTFProducer.jt;27423;@STATIC;1.0;I;31;Foundation/CPAttributedString.ji;18;CPParagraphStyle.ji;9;CPColor.ji;12;CPGraphics.ji;15;CPFontManager.jt;27294;objj_executeFile("Foundation/CPAttributedString.j", NO);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPGraphics.j", YES);objj_executeFile("CPFontManager.j", YES);var PAPERSIZE = "PaperSize", + +{var the_class = objj_allocateClassPair(CPObject, "CPMarkdownParser"), +meta_class = the_class.isa;objj_registerClassPair(the_class); +class_addMethods(meta_class, [new objj_method(sel_getUid("attributedStringFromMarkdown:"), function $CPMarkdownParser__attributedStringFromMarkdown_(self, _cmd, markdown) +{ + if (!markdown) + { + return ((___r1 = (CPAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:"] || _objj_forward)(___r1, "initWithString:", "")); + } + var result = ((___r1 = (CPMutableAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPMutableAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:"] || _objj_forward)(___r1, "initWithString:", "")); + var lines = markdown.split(/\r?\n/); + var i = 0; + while (i < lines.length) + { + var line = lines[i]; + if ((self.isa.method_msgSend["isTableHeaderLine:"] || _objj_forward)(self, "isTableHeaderLine:", line) && i + 1 < lines.length && (self.isa.method_msgSend["isTableSeparatorLine:"] || _objj_forward)(self, "isTableSeparatorLine:", lines[i + 1])) + { + var headers = (self.isa.method_msgSend["parseTableCells:"] || _objj_forward)(self, "parseTableCells:", line); + var separatorLine = lines[i + 1]; + var rows = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + i += 2; + while (i < lines.length && (self.isa.method_msgSend["isTableRowLine:"] || _objj_forward)(self, "isTableRowLine:", lines[i])) + { + (rows == null ? rows : (rows.isa.method_msgSend["addObject:"] || _objj_forward)(rows, "addObject:", (self.isa.method_msgSend["parseTableCells:"] || _objj_forward)(self, "parseTableCells:", lines[i]))); + i++; + } + var numCols = (headers == null ? headers : (headers.isa.method_msgSend["count"] || _objj_forward)(headers, "count")); + if (numCols == 0 && (rows == null ? rows : (rows.isa.method_msgSend["count"] || _objj_forward)(rows, "count")) > 0) + { + numCols = ((___r1 = (rows == null ? rows : (rows.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(rows, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + } + var totalNaturalW = 0.0; + var colNaturalWidths = []; + var measureTextField = ((___r1 = (CPTextField.isa.method_msgSend["alloc"] || _objj_forward)(CPTextField, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, 0, 10000.0, 24.0))); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setFont:"] || _objj_forward)(measureTextField, "setFont:", (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 11.0))); + for (var c = 0; c < numCols; c++) + { + var cellW = 80.0; + if (c < headers.length) + { + var parsedText = (self.isa.method_msgSend["parseInlineMarkdown:isHeader:headerLevel:"] || _objj_forward)(self, "parseInlineMarkdown:isHeader:headerLevel:", headers[c], YES, 3); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", (parsedText == null ? parsedText : (parsedText.isa.method_msgSend["string"] || _objj_forward)(parsedText, "string")))); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["sizeToFit"] || _objj_forward)(measureTextField, "sizeToFit")); + cellW = Math.max(cellW, CGRectGetWidth((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["frame"] || _objj_forward)(measureTextField, "frame"))) + 24.0); + } + for (var r = 0; r < (rows == null ? rows : (rows.isa.method_msgSend["count"] || _objj_forward)(rows, "count")); r++) + { + var rowData = (rows == null ? rows : (rows.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(rows, "objectAtIndex:", r)); + if (c < (rowData == null ? rowData : (rowData.isa.method_msgSend["count"] || _objj_forward)(rowData, "count"))) + { + var parsedText = (self.isa.method_msgSend["parseInlineMarkdown:isHeader:headerLevel:"] || _objj_forward)(self, "parseInlineMarkdown:isHeader:headerLevel:", rowData[c], NO, 3); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", (parsedText == null ? parsedText : (parsedText.isa.method_msgSend["string"] || _objj_forward)(parsedText, "string")))); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["sizeToFit"] || _objj_forward)(measureTextField, "sizeToFit")); + cellW = Math.max(cellW, CGRectGetWidth((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["frame"] || _objj_forward)(measureTextField, "frame"))) + 24.0); + } + } + colNaturalWidths[c] = cellW; + totalNaturalW += cellW; + } + var matrixView = ((___r1 = (_CPTableTextAttachment.isa.method_msgSend["alloc"] || _objj_forward)(_CPTableTextAttachment, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithHeaders:rows:width:"] || _objj_forward)(___r1, "initWithHeaders:rows:width:", headers, rows, 500.0)); + var tableAttrStr = (CPTextStorage.isa.method_msgSend["attributedStringWithAttachment:"] || _objj_forward)(CPTextStorage, "attributedStringWithAttachment:", matrixView); + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", tableAttrStr)); + continue; + } + var isHeader = false; + var headerLevel = 0; + var headerMatch = line.match(/^(#{1,6})\s+(.*)$/); + if (headerMatch) + { + headerLevel = headerMatch[1].length; + line = headerMatch[2]; + isHeader = true; + } + var isListItem = false; + var listMatch = line.match(/^(\*|-)\s+(.*)$/); + if (listMatch) + { + line = " • " + listMatch[2]; + isListItem = true; + } + var parsedLine = (self.isa.method_msgSend["parseInlineMarkdown:isHeader:headerLevel:"] || _objj_forward)(self, "parseInlineMarkdown:isHeader:headerLevel:", line, isHeader, headerLevel); + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", parsedLine)); + if (i < lines.length - 1) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", ((___r1 = (CPAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:"] || _objj_forward)(___r1, "initWithString:", "\n")))); + } + i++; + } + return result; + var ___r1; +} + +,["CPAttributedString","CPString"]), new objj_method(sel_getUid("isTableHeaderLine:"), function $CPMarkdownParser__isTableHeaderLine_(self, _cmd, line) +{ + var trimmed = line.trim(); + return trimmed.indexOf('|') !== -1; +} + +,["BOOL","CPString"]), new objj_method(sel_getUid("isTableSeparatorLine:"), function $CPMarkdownParser__isTableSeparatorLine_(self, _cmd, line) +{ + var trimmed = line.trim(); + if (trimmed.indexOf('|') === -1) + return NO; + var stripped = trimmed.replace(/[\s|:\-]/g, ''); + return stripped.length === 0; +} + +,["BOOL","CPString"]), new objj_method(sel_getUid("isTableRowLine:"), function $CPMarkdownParser__isTableRowLine_(self, _cmd, line) +{ + var trimmed = line.trim(); + return trimmed.indexOf('|') !== -1; +} + +,["BOOL","CPString"]), new objj_method(sel_getUid("parseTableCells:"), function $CPMarkdownParser__parseTableCells_(self, _cmd, line) +{ + var parts = line.split('|'); + var cells = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + var startIdx = 0; + var endIdx = parts.length; + if (parts[0].trim() === "") + startIdx = 1; + if (parts[parts.length - 1].trim() === "") + endIdx = parts.length - 1; + for (var j = startIdx; j < endIdx; j++) + { + (cells == null ? cells : (cells.isa.method_msgSend["addObject:"] || _objj_forward)(cells, "addObject:", parts[j].trim())); + } + return cells; +} + +,["CPArray","CPString"]), new objj_method(sel_getUid("parseInlineMarkdown:isHeader:headerLevel:"), function $CPMarkdownParser__parseInlineMarkdown_isHeader_headerLevel_(self, _cmd, text, isHeader, level) +{ + var baseFontSize = 11.0; + var fontSize = baseFontSize; + var isBold = isHeader; + var isItalic = NO; + if (isHeader) + { + if (level == 1) + fontSize = 15.0; + else if (level == 2) + fontSize = 13.0; + else + fontSize = 12.0; + } + var result = ((___r1 = (CPMutableAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPMutableAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:"] || _objj_forward)(___r1, "initWithString:", "")); + var currentSegment = ""; + var i = 0; + var len = text.length; + var defaultFont = (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", fontSize); + if (isBold) + { + defaultFont = (CPFont.isa.method_msgSend["boldSystemFontOfSize:"] || _objj_forward)(CPFont, "boldSystemFontOfSize:", fontSize); + } + while (i < len) + { + if (i + 2 < len && text.substr(i, 3) === "***") + { + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + currentSegment = ""; + } + isBold = !isBold; + isItalic = !isItalic; + i += 3; + continue; + } + if (i + 1 < len && text.substr(i, 2) === "**") + { + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + currentSegment = ""; + } + isBold = !isBold; + i += 2; + continue; + } + if (text.charAt(i) === "*") + { + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + currentSegment = ""; + } + isItalic = !isItalic; + i++; + continue; + } + if (text.charAt(i) === "`") + { + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + currentSegment = ""; + } + var codeText = ""; + i++; + while (i < len && text.charAt(i) !== "`") + { + codeText += text.charAt(i); + i++; + } + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", codeText, defaultFont, NO, NO, YES))); + i++; + continue; + } + currentSegment += text.charAt(i); + i++; + } + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + } + return result; + var ___r1; +} + +,["CPAttributedString","CPString","BOOL","int"]), new objj_method(sel_getUid("attributedStringWithText:font:bold:italic:code:"), function $CPMarkdownParser__attributedStringWithText_font_bold_italic_code_(self, _cmd, text, baseFont, b, it, c) +{ + var fontName = (baseFont == null ? baseFont : (baseFont.isa.method_msgSend["familyName"] || _objj_forward)(baseFont, "familyName")); + var fontSize = (baseFont == null ? baseFont : (baseFont.isa.method_msgSend["size"] || _objj_forward)(baseFont, "size")); + var finalFont = baseFont; + if (c) + { + finalFont = (CPFont.isa.method_msgSend["fontWithName:size:"] || _objj_forward)(CPFont, "fontWithName:size:", "Courier", fontSize); + } + else + { + finalFont = (CPFont.isa.method_msgSend["_fontWithName:size:bold:italic:"] || _objj_forward)(CPFont, "_fontWithName:size:bold:italic:", fontName, fontSize, b, it); + } + if (!finalFont) + { + finalFont = (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", fontSize); + } + var dict = (CPDictionary.isa.method_msgSend["dictionaryWithObjectsAndKeys:"] || _objj_forward)(CPDictionary, "dictionaryWithObjectsAndKeys:", finalFont, CPFontAttributeName, (CPColor.isa.method_msgSend["blackColor"] || _objj_forward)(CPColor, "blackColor"), CPForegroundColorAttributeName); + return ((___r1 = (CPAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:attributes:"] || _objj_forward)(___r1, "initWithString:attributes:", text, dict)); + var ___r1; +} + +,["CPAttributedString","CPString","CPFont","BOOL","BOOL","BOOL"])]); +} +p;16;_CPRTFProducer.jt;39041;@STATIC;1.0;I;31;Foundation/CPAttributedString.ji;18;CPParagraphStyle.ji;9;CPColor.ji;12;CPGraphics.ji;15;CPFontManager.ji;24;_CPTableTextAttachment.jt;38883;objj_executeFile("Foundation/CPAttributedString.j", NO);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPGraphics.j", YES);objj_executeFile("CPFontManager.j", YES);objj_executeFile("_CPTableTextAttachment.j", YES);var PAPERSIZE = "PaperSize", LEFTMARGIN = "LeftMargin", RIGHTMARGIN = "RightMargin", TOPMARGIN = "TopMargin", @@ -69323,8 +69710,23 @@ default: enumerator = ((___r1 = (paraStyle == null ? paraStyle : (paraStyle.isa.method_msgSend["tabStops"] || _objj_forward)(paraStyle, "tabStops"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectEnumerator"] || _objj_forward)(___r1, "objectEnumerator")); while (tab = (enumerator == null ? enumerator : (enumerator.isa.method_msgSend["nextObject"] || _objj_forward)(enumerator, "nextObject"))) { - switch((tab == null ? tab : (tab.isa.method_msgSend["tabStopType"] || _objj_forward)(tab, "tabStopType"))) { + var tabType = (tab == null ? tab : (tab.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tab, "respondsToSelector:", sel_getUid("tabStopType"))) ? (tab == null ? tab : (tab.isa.method_msgSend["tabStopType"] || _objj_forward)(tab, "tabStopType")) : nil; + if (tabType === nil && (tab == null ? tab : (tab.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tab, "respondsToSelector:", sel_getUid("alignment")))) + tabType = (tab == null ? tab : (tab.isa.method_msgSend["alignment"] || _objj_forward)(tab, "alignment")); + switch(tabType) { case CPLeftTabStopType: + case CPLeftTextAlignment: + break; + case CPRightTabStopType: + case CPRightTextAlignment: + headerString += "\\tqr"; + break; + case CPCenterTabStopType: + case CPCenterTextAlignment: + headerString += "\\tqc"; + break; + case CPDecimalTabStopType: + headerString += "\\tqdec"; break; } headerString += (CPString.isa.method_msgSend["stringWithFormat:"] || _objj_forward)(CPString, "stringWithFormat:", "\\tx%d", _points2twips((tab == null ? tab : (tab.isa.method_msgSend["location"] || _objj_forward)(tab, "location")))); @@ -69335,6 +69737,211 @@ default: ,["CPString","CPParagraphStyle"]), new objj_method(sel_getUid("runStringForString:attributes:paragraphStart:"), function $_CPRTFProducer__runStringForString_attributes_paragraphStart_(self, _cmd, substring, attributes, first) { + var unwrap = function(obj) + { + if (!obj) + return null; + if (typeof obj.respondsToSelector === "function" && ((obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("headers"))) || (obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("rows")))) || obj.headers || obj._headers || obj.rows || obj._rows) + { + return obj; + } + var unwrapped = null; + if (typeof obj.respondsToSelector === "function") + { + if ((obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("attachmentCell")))) + { + unwrapped = (obj == null ? obj : (obj.isa.method_msgSend["attachmentCell"] || _objj_forward)(obj, "attachmentCell")); + } + else if ((obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("content")))) + { + unwrapped = (obj == null ? obj : (obj.isa.method_msgSend["content"] || _objj_forward)(obj, "content")); + } + else if ((obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("view")))) + { + unwrapped = (obj == null ? obj : (obj.isa.method_msgSend["view"] || _objj_forward)(obj, "view")); + } + } + if (!unwrapped) + { + unwrapped = obj._attachmentCell || obj._content || obj._view || obj.attachmentCell || obj.content || obj.view; + } + return unwrapped ? unwrapped : obj; + }; + var tableAttachment = null; + if (typeof CPAttachmentAttributeName !== "undefined") + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPAttachmentAttributeName)); + } + if (!tableAttachment) + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", "CPAttachmentAttributeName")); + } + if (!tableAttachment) + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", "TableAttachmentAttribute")); + } + if (!tableAttachment) + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", "_CPAttachmentView")); + } + if (!tableAttachment && typeof _CPAttachmentView !== "undefined") + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", _CPAttachmentView)); + } + tableAttachment = unwrap(tableAttachment); + if (!tableAttachment && (substring === "\uFFFC" || substring === "")) + { + var keys = (attributes == null ? attributes : (attributes.isa.method_msgSend["allKeys"] || _objj_forward)(attributes, "allKeys")), + count = (keys == null ? keys : (keys.isa.method_msgSend["count"] || _objj_forward)(keys, "count")); + for (var i = 0; i < count; i++) + { + var key = (keys == null ? keys : (keys.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(keys, "objectAtIndex:", i)), + val = unwrap((attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", key))); + if (val && (typeof val.respondsToSelector === "function" && (val == null ? val : (val.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(val, "respondsToSelector:", sel_getUid("headers"))) || val._headers || val.headers || typeof _CPTableTextAttachment !== "undefined" && (val == null ? val : (val.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(val, "isKindOfClass:", (_CPTableTextAttachment.isa.method_msgSend["class"] || _objj_forward)(_CPTableTextAttachment, "class"))))) + { + tableAttachment = val; + break; + } + } + } + if (tableAttachment) + { + var headers = null, + rows = null; + var activeView = null; + if (typeof tableAttachment.respondsToSelector === "function" && (tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tableAttachment, "respondsToSelector:", sel_getUid("view")))) + { + activeView = (tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["view"] || _objj_forward)(tableAttachment, "view")); + } + if (!activeView) + { + activeView = tableAttachment._view || tableAttachment.view; + } + if (activeView) + { + if (typeof activeView.respondsToSelector === "function") + { + if ((activeView == null ? activeView : (activeView.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(activeView, "respondsToSelector:", sel_getUid("headers")))) + { + headers = (activeView == null ? activeView : (activeView.isa.method_msgSend["headers"] || _objj_forward)(activeView, "headers")); + } + if ((activeView == null ? activeView : (activeView.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(activeView, "respondsToSelector:", sel_getUid("rows")))) + { + rows = (activeView == null ? activeView : (activeView.isa.method_msgSend["rows"] || _objj_forward)(activeView, "rows")); + } + } + if (!headers) + { + headers = activeView._headers || activeView.headers; + } + if (!rows) + { + rows = activeView._rows || activeView.rows; + } + } + if (!headers || !rows) + { + if (typeof tableAttachment.respondsToSelector === "function") + { + if ((tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tableAttachment, "respondsToSelector:", sel_getUid("headers")))) + { + headers = (tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["headers"] || _objj_forward)(tableAttachment, "headers")); + } + if ((tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tableAttachment, "respondsToSelector:", sel_getUid("rows")))) + { + rows = (tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["rows"] || _objj_forward)(tableAttachment, "rows")); + } + } + if (!headers) + { + headers = tableAttachment._headers || tableAttachment.headers; + } + if (!rows) + { + rows = tableAttachment._rows || tableAttachment.rows; + } + } + var getCount = function(arr) + { + if (!arr) + return 0; + if (typeof arr.count === "function") + return (arr == null ? arr : (arr.isa.method_msgSend["count"] || _objj_forward)(arr, "count")); + return arr.length; + }; + var getObjectAtIndex = function(arr, idx) + { + if (!arr) + return null; + if (typeof arr.objectAtIndex === "function") + return (arr == null ? arr : (arr.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(arr, "objectAtIndex:", idx)); + return arr[idx]; + }; + var numCols = getCount(headers); + if (numCols == 0 && getCount(rows) > 0) + { + numCols = getCount(getObjectAtIndex(rows, 0)); + } + if (numCols > 0) + { + var totalWidthTwips = 10000; + var colWidthTwips = Math.floor(totalWidthTwips / numCols); + var cellBoundaries = []; + var currentBoundary = 0; + for (var i = 0; i < numCols; i++) + { + currentBoundary += colWidthTwips; + cellBoundaries.push(currentBoundary); + } + var tableRTF = ""; + var writeRow = function(rowData, isHeaderRow) + { + var rowRTF = "\\trowd\\trgaph115\\trleft0"; + for (var c = 0; c < numCols; c++) + { + rowRTF += "\\clbrdrt\\brdrs\\brdrw10\\clbrdrb\\brdrs\\brdrw10\\clbrdrl\\brdrs\\brdrw10\\clbrdrr\\brdrs\\brdrw10"; + rowRTF += "\\cellx" + cellBoundaries[c]; + } + for (var c = 0; c < numCols; c++) + { + var cellText = ""; + if (c < getCount(rowData)) + { + cellText = getObjectAtIndex(rowData, c); + } + if (cellText === null || cellText === undefined) + { + cellText = ""; + } + cellText = String(cellText); + cellText = cellText.replace(/\\/g, '\\\\'); + cellText = cellText.replace(/{/g, '\\{'); + cellText = cellText.replace(/}/g, '\\}'); + cellText = cellText.replace(/\n/g, '\\line '); + if (isHeaderRow) + { + rowRTF += "{\\intbl\\b " + cellText + "\\b0\\cell}"; + } + else + { + rowRTF += "{\\intbl " + cellText + "\\cell}"; + } + } + rowRTF += "\\row\n"; + return rowRTF; + }; + if (getCount(headers) > 0) + { + tableRTF += writeRow(headers, YES); + } + var rowCount = getCount(rows); + for (var r = 0; r < rowCount; r++) + { + tableRTF += writeRow(getObjectAtIndex(rows, r), NO); + } + return tableRTF; + } + } var result = "", headerString = "", trailerString = "", @@ -69443,7 +70050,7 @@ default: } substring = substring.replace(/\\/g, '\\\\'); substring = substring.replace(/\n/g, '\\par\n'); - substring = substring.replace(/\t/g, '\\tab'); + substring = substring.replace(/\t/g, '\\tab '); substring = substring.replace(/{/g, '\\{'); substring = substring.replace(/}/g, '\\}'); if (!first) @@ -69459,7 +70066,7 @@ default: { var nobraces; if ((headerString == null ? headerString : (headerString.isa.method_msgSend["length"] || _objj_forward)(headerString, "length"))) - nobraces = (CPString.isa.method_msgSend["stringWithFormat:"] || _objj_forward)(CPString, "stringWithFormat:", "%@ %@", headerString, substring); + nobraces = (CPString.isa.method_msgSend["stringWithFormat:"] || _objj_forward)(CPString, "stringWithFormat:", "%@ %@}", headerString, substring); else nobraces = substring; result += nobraces; @@ -69476,7 +70083,7 @@ default: length = (string == null ? string : (string.isa.method_msgSend["length"] || _objj_forward)(string, "length")), currRange = CPMakeRange(loc, 0), completeRange = CPMakeRange(0, length), - first = YES; + paragraphStart = YES; while (CPMaxRange(currRange) < CPMaxRange(completeRange)) { var attributes, @@ -69484,9 +70091,12 @@ default: runString; attributes = ((___r1 = self.text), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["attributesAtIndex:longestEffectiveRange:inRange:"] || _objj_forward)(___r1, "attributesAtIndex:longestEffectiveRange:inRange:", CPMaxRange(currRange), currRange, completeRange)); substring = (string == null ? string : (string.isa.method_msgSend["substringWithRange:"] || _objj_forward)(string, "substringWithRange:", currRange)); - runString = (self.isa.method_msgSend["runStringForString:attributes:paragraphStart:"] || _objj_forward)(self, "runStringForString:attributes:paragraphStart:", substring, attributes, YES); + runString = (self.isa.method_msgSend["runStringForString:attributes:paragraphStart:"] || _objj_forward)(self, "runStringForString:attributes:paragraphStart:", substring, attributes, paragraphStart); result += runString; - first = NO; + if (substring.length > 0 && substring.charAt(substring.length - 1) === '\n') + paragraphStart = YES; + else + paragraphStart = NO; } return result; var ___r1; @@ -69518,6 +70128,472 @@ class_addMethods(meta_class, [new objj_method(sel_getUid("produceRTF:documentAtt ,["CPString","CPAttributedString","CPDictionary"])]); } +p;24;_CPTableTextAttachment.jt;32409;@STATIC;1.0;i;8;CPView.ji;12;CPTextView.ji;13;CPTextField.jI;31;Foundation/CPAttributedString.jt;32306;objj_executeFile("CPView.j", YES);objj_executeFile("CPTextView.j", YES);objj_executeFile("CPTextField.j", YES);objj_executeFile("Foundation/CPAttributedString.j", NO); +{var the_class = objj_allocateClassPair(CPView, "_CPTableTextAttachment"), +meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_headers", "CPArray"), new objj_ivar("_rows", "CPArray"), new objj_ivar("_isResizing", "BOOL"), new objj_ivar("_isEditable", "BOOL"), new objj_ivar("_acceptsRichText", "BOOL")]);objj_registerClassPair(the_class); +class_addMethods(the_class, [new objj_method(sel_getUid("initWithHeaders:rows:"), function $_CPTableTextAttachment__initWithHeaders_rows_(self, _cmd, headers, rows) +{ + return (self.isa.method_msgSend["initWithHeaders:rows:width:isEditable:acceptsRichText:"] || _objj_forward)(self, "initWithHeaders:rows:width:isEditable:acceptsRichText:", headers, rows, 500.0, YES, YES); +} + +,["id","CPArray","CPArray"]), new objj_method(sel_getUid("initWithHeaders:rows:width:"), function $_CPTableTextAttachment__initWithHeaders_rows_width_(self, _cmd, headers, rows, totalWidth) +{ + return (self.isa.method_msgSend["initWithHeaders:rows:width:isEditable:acceptsRichText:"] || _objj_forward)(self, "initWithHeaders:rows:width:isEditable:acceptsRichText:", headers, rows, totalWidth, YES, NO); +} + +,["id","CPArray","CPArray","float"]), new objj_method(sel_getUid("initWithHeaders:rows:width:isEditable:acceptsRichText:"), function $_CPTableTextAttachment__initWithHeaders_rows_width_isEditable_acceptsRichText_(self, _cmd, headers, rows, totalWidth, isEditable, acceptsRichText) +{ + self = (objj_getClass("_CPTableTextAttachment").super_class.method_dtable["initWithFrame:"] || _objj_forward)(self, "initWithFrame:", CGRectMake(0, 0, totalWidth, 20)); + if (self) + { + self._headers = headers; + self._rows = rows; + self._isEditable = isEditable; + self._acceptsRichText = acceptsRichText; + self._isResizing = NO; + (self == null ? self : (self.isa.method_msgSend["_rebuildTableWithWidth:"] || _objj_forward)(self, "_rebuildTableWithWidth:", totalWidth)); + } + return self; +} + +,["id","CPArray","CPArray","float","BOOL","BOOL"]), new objj_method(sel_getUid("_rebuildTableWithWidth:"), function $_CPTableTextAttachment___rebuildTableWithWidth_(self, _cmd, totalWidth) +{ + var numCols = self._headers ? ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) : 0; + if (numCols == 0 && self._rows && ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + numCols = ((___r1 = ((___r2 = self._rows), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r2, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + if (self._DOMElement) + { + self._DOMElement.style.borderTop = "1px solid #e0e0e0"; + self._DOMElement.style.borderLeft = "1px solid #e0e0e0"; + self._DOMElement.style.boxSizing = "border-box"; + } + if (self._headers && ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + { + for (var c = 0; c < numCols; c++) + { + var headerText = ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", c)); + var cellView = (self.isa.method_msgSend["createCellWithText:frame:isHeader:"] || _objj_forward)(self, "createCellWithText:frame:isHeader:", headerText, CGRectMakeZero(), YES); + (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", cellView); + } + } + if (self._rows) + { + for (var r = 0; r < ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); r++) + { + var rowData = ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", r)); + for (var c = 0; c < numCols; c++) + { + var cellText = ""; + if (c < (rowData == null ? rowData : (rowData.isa.method_msgSend["count"] || _objj_forward)(rowData, "count"))) + cellText = (rowData == null ? rowData : (rowData.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(rowData, "objectAtIndex:", c)); + var cellView = (self.isa.method_msgSend["createCellWithText:frame:isHeader:"] || _objj_forward)(self, "createCellWithText:frame:isHeader:", cellText, CGRectMakeZero(), NO); + (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", cellView); + } + } + } + (self.isa.method_msgSend["resizeToWidth:"] || _objj_forward)(self, "resizeToWidth:", totalWidth); + var textView = (self.isa.method_msgSend["superview"] || _objj_forward)(self, "superview"); + if (textView && (textView == null ? textView : (textView.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(textView, "isKindOfClass:", (CPTextView == null ? CPTextView : (CPTextView.isa.method_msgSend["class"] || _objj_forward)(CPTextView, "class"))))) + { + var layoutManager = (textView == null ? textView : (textView.isa.method_msgSend["layoutManager"] || _objj_forward)(textView, "layoutManager")); + if (layoutManager) + { + var charRange = (self.isa.method_msgSend["_findCharacterRangeInLayoutManager:"] || _objj_forward)(self, "_findCharacterRangeInLayoutManager:", layoutManager); + if (charRange && charRange.location !== CPNotFound) + { + (layoutManager == null ? layoutManager : (layoutManager.isa.method_msgSend["invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:"] || _objj_forward)(layoutManager, "invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:", charRange, NO, nil)); + (layoutManager == null ? layoutManager : (layoutManager.isa.method_msgSend["invalidateDisplayForGlyphRange:"] || _objj_forward)(layoutManager, "invalidateDisplayForGlyphRange:", charRange)); + (layoutManager == null ? layoutManager : (layoutManager.isa.method_msgSend["_validateLayoutAndGlyphs"] || _objj_forward)(layoutManager, "_validateLayoutAndGlyphs")); + (textView == null ? textView : (textView.isa.method_msgSend["sizeToFit"] || _objj_forward)(textView, "sizeToFit")); + } + } + } + var ___r1, ___r2; +} + +,["void","float"]), new objj_method(sel_getUid("_findCharacterRangeInLayoutManager:"), function $_CPTableTextAttachment___findCharacterRangeInLayoutManager_(self, _cmd, layoutManager) +{ + var lineFragments = layoutManager._lineFragments; + if (lineFragments) + { + var l = lineFragments.length; + for (var i = 0; i < l; i++) + { + var fragment = lineFragments[i]; + var runs = fragment._runs; + if (runs) + { + var rc = runs.length; + for (var j = 0; j < rc; j++) + { + if (runs[j].view === self) + { + return runs[j]._range; + } + } + } + } + } + return CPMakeRange(CPNotFound, 0); +} + +,["CPRange","CPLayoutManager"]), new objj_method(sel_getUid("headers"), function $_CPTableTextAttachment__headers(self, _cmd) +{ + var numCols = self._headers ? ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) : 0; + if (numCols == 0 && self._rows && ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + numCols = ((___r1 = ((___r2 = self._rows), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r2, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + if (numCols == 0) + return self._headers; + var subviews = (self.isa.method_msgSend["subviews"] || _objj_forward)(self, "subviews"); + if ((subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count")) < numCols) + return self._headers; + var currentHeaders = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + for (var c = 0; c < numCols; c++) + { + var cellView = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", c)); + var textView = (self.isa.method_msgSend["getTextViewFromCell:"] || _objj_forward)(self, "getTextViewFromCell:", cellView); + var text = ""; + if (textView) + { + text = self._acceptsRichText ? ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textStorage"] || _objj_forward)(textView, "textStorage"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["copy"] || _objj_forward)(___r1, "copy")) : (textView == null ? textView : (textView.isa.method_msgSend["string"] || _objj_forward)(textView, "string")); + } + (currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["addObject:"] || _objj_forward)(currentHeaders, "addObject:", text)); + } + self._headers = currentHeaders; + return self._headers; + var ___r1, ___r2; +} + +,["CPArray"]), new objj_method(sel_getUid("rows"), function $_CPTableTextAttachment__rows(self, _cmd) +{ + var numCols = self._headers ? ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) : 0; + if (numCols == 0 && self._rows && ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + numCols = ((___r1 = ((___r2 = self._rows), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r2, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + if (numCols == 0 || !self._rows) + return self._rows; + var subviews = (self.isa.method_msgSend["subviews"] || _objj_forward)(self, "subviews"); + var headerOffset = self._headers && ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0 ? numCols : 0; + var expectedCount = headerOffset + ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) * numCols; + if ((subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count")) < expectedCount) + return self._rows; + var currentRows = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + var cellIndex = headerOffset; + for (var r = 0; r < ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); r++) + { + var rowData = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + for (var c = 0; c < numCols; c++) + { + var cellView = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", cellIndex++)); + var textView = (self.isa.method_msgSend["getTextViewFromCell:"] || _objj_forward)(self, "getTextViewFromCell:", cellView); + var text = ""; + if (textView) + { + text = self._acceptsRichText ? ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textStorage"] || _objj_forward)(textView, "textStorage"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["copy"] || _objj_forward)(___r1, "copy")) : (textView == null ? textView : (textView.isa.method_msgSend["string"] || _objj_forward)(textView, "string")); + } + (rowData == null ? rowData : (rowData.isa.method_msgSend["addObject:"] || _objj_forward)(rowData, "addObject:", text)); + } + (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["addObject:"] || _objj_forward)(currentRows, "addObject:", rowData)); + } + self._rows = currentRows; + return self._rows; + var ___r1, ___r2; +} + +,["CPArray"]), new objj_method(sel_getUid("viewForWidth:"), function $_CPTableTextAttachment__viewForWidth_(self, _cmd, width) +{ + (self.isa.method_msgSend["resizeToWidth:"] || _objj_forward)(self, "resizeToWidth:", width); + return self; +} + +,["CPView","float"]), new objj_method(sel_getUid("createCellWithText:frame:isHeader:"), function $_CPTableTextAttachment__createCellWithText_frame_isHeader_(self, _cmd, text, frame, isHeader) +{ + var initialWidth = frame.size.width > 0 ? frame.size.width : 120.0; + var initialHeight = frame.size.height > 0 ? frame.size.height : 28.0; + var cellContainer = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(frame.origin.x, frame.origin.y, initialWidth, initialHeight))); + (cellContainer == null ? cellContainer : (cellContainer.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(cellContainer, "setBackgroundColor:", isHeader ? (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.92, 1.0) : (CPColor.isa.method_msgSend["whiteColor"] || _objj_forward)(CPColor, "whiteColor"))); + var borderView = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, 0, initialWidth, initialHeight))); + (borderView == null ? borderView : (borderView.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(borderView, "setBackgroundColor:", (CPColor.isa.method_msgSend["clearColor"] || _objj_forward)(CPColor, "clearColor"))); + (borderView == null ? borderView : (borderView.isa.method_msgSend["setAutoresizingMask:"] || _objj_forward)(borderView, "setAutoresizingMask:", CPViewWidthSizable | CPViewHeightSizable)); + if (borderView._DOMElement) + { + borderView._DOMElement.style.borderBottom = "1px solid #e0e0e0"; + borderView._DOMElement.style.borderRight = "1px solid #e0e0e0"; + borderView._DOMElement.style.boxSizing = "border-box"; + } + (cellContainer == null ? cellContainer : (cellContainer.isa.method_msgSend["addSubview:"] || _objj_forward)(cellContainer, "addSubview:", borderView)); + var textContainer = ((___r1 = (CPTextContainer.isa.method_msgSend["alloc"] || _objj_forward)(CPTextContainer, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithContainerSize:"] || _objj_forward)(___r1, "initWithContainerSize:", CGSizeMake(initialWidth - 8, 1e7))); + var textView = ((___r1 = (CPTextView == null ? CPTextView : (CPTextView.isa.method_msgSend["alloc"] || _objj_forward)(CPTextView, "alloc"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:textContainer:"] || _objj_forward)(___r1, "initWithFrame:textContainer:", CGRectMake(4, 2, initialWidth - 8, initialHeight - 4), textContainer)); + (textView == null ? textView : (textView.isa.method_msgSend["setEditable:"] || _objj_forward)(textView, "setEditable:", self._isEditable)); + (textView == null ? textView : (textView.isa.method_msgSend["setSelectable:"] || _objj_forward)(textView, "setSelectable:", YES)); + (textView == null ? textView : (textView.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(textView, "setBackgroundColor:", (CPColor.isa.method_msgSend["clearColor"] || _objj_forward)(CPColor, "clearColor"))); + (textView == null ? textView : (textView.isa.method_msgSend["setVerticallyResizable:"] || _objj_forward)(textView, "setVerticallyResizable:", YES)); + (textView == null ? textView : (textView.isa.method_msgSend["setHorizontallyResizable:"] || _objj_forward)(textView, "setHorizontallyResizable:", NO)); + ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textContainer"] || _objj_forward)(textView, "textContainer"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setWidthTracksTextView:"] || _objj_forward)(___r1, "setWidthTracksTextView:", YES)); + (textView == null ? textView : (textView.isa.method_msgSend["setRichText:"] || _objj_forward)(textView, "setRichText:", self._acceptsRichText)); + (textView == null ? textView : (textView.isa.method_msgSend["setDelegate:"] || _objj_forward)(textView, "setDelegate:", self)); + var cellFont = isHeader ? (CPFont.isa.method_msgSend["boldSystemFontOfSize:"] || _objj_forward)(CPFont, "boldSystemFontOfSize:", 11.0) : (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 11.0); + (textView == null ? textView : (textView.isa.method_msgSend["setFont:"] || _objj_forward)(textView, "setFont:", cellFont)); + (textView == null ? textView : (textView.isa.method_msgSend["setTextColor:"] || _objj_forward)(textView, "setTextColor:", (CPColor.isa.method_msgSend["blackColor"] || _objj_forward)(CPColor, "blackColor"))); + if (text && (text == null ? text : (text.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(text, "isKindOfClass:", (CPAttributedString.isa.method_msgSend["class"] || _objj_forward)(CPAttributedString, "class")))) + { + ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textStorage"] || _objj_forward)(textView, "textStorage"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setAttributedString:"] || _objj_forward)(___r1, "setAttributedString:", text)); + } + else if (text) + { + (textView == null ? textView : (textView.isa.method_msgSend["setString:"] || _objj_forward)(textView, "setString:", String(text))); + } + else + { + (textView == null ? textView : (textView.isa.method_msgSend["setString:"] || _objj_forward)(textView, "setString:", "")); + } + (cellContainer == null ? cellContainer : (cellContainer.isa.method_msgSend["addSubview:"] || _objj_forward)(cellContainer, "addSubview:", textView)); + return cellContainer; + var ___r1; +} + +,["CPView","id","CGRect","BOOL"]), new objj_method(sel_getUid("textDidChange:"), function $_CPTableTextAttachment__textDidChange_(self, _cmd, aNotification) +{ + (self.isa.method_msgSend["resizeToWidth:"] || _objj_forward)(self, "resizeToWidth:", CGRectGetWidth((self.isa.method_msgSend["frame"] || _objj_forward)(self, "frame"))); +} + +,["void","CPNotification"]), new objj_method(sel_getUid("getTextViewFromCell:"), function $_CPTableTextAttachment__getTextViewFromCell_(self, _cmd, cellView) +{ + var subviews = (cellView == null ? cellView : (cellView.isa.method_msgSend["subviews"] || _objj_forward)(cellView, "subviews")); + for (var i = 0; i < (subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count")); i++) + { + var sub = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", i)); + if ((sub == null ? sub : (sub.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(sub, "isKindOfClass:", (CPTextView == null ? CPTextView : (CPTextView.isa.method_msgSend["class"] || _objj_forward)(CPTextView, "class"))))) + { + return sub; + } + } + return nil; +} + +,["CPTextView","CPView"]), new objj_method(sel_getUid("resizeToWidth:"), function $_CPTableTextAttachment__resizeToWidth_(self, _cmd, newWidth) +{ + if (self._isResizing) + return; + self._isResizing = YES; + var currentHeaders = (self.isa.method_msgSend["headers"] || _objj_forward)(self, "headers"); + var currentRows = (self.isa.method_msgSend["rows"] || _objj_forward)(self, "rows"); + var numCols = currentHeaders ? (currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["count"] || _objj_forward)(currentHeaders, "count")) : 0; + if (numCols == 0 && currentRows && (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["count"] || _objj_forward)(currentRows, "count")) > 0) + { + numCols = ((___r1 = (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(currentRows, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + } + if (numCols == 0) + { + self._isResizing = NO; + return; + } + var subviews = (self.isa.method_msgSend["subviews"] || _objj_forward)(self, "subviews"); + var colNaturalWidths = []; + var colMinWidths = []; + for (var c = 0; c < numCols; c++) + { + colNaturalWidths[c] = 80.0; + colMinWidths[c] = 60.0; + } + var measureTextField = ((___r1 = (CPTextField.isa.method_msgSend["alloc"] || _objj_forward)(CPTextField, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, 0, 10000.0, 24.0))); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setFont:"] || _objj_forward)(measureTextField, "setFont:", (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 13.0))); + var measureCell = function(cellText, isHeader, colIndex) + { + var cellFont = isHeader ? (CPFont.isa.method_msgSend["boldSystemFontOfSize:"] || _objj_forward)(CPFont, "boldSystemFontOfSize:", 11.0) : (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 11.0); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setFont:"] || _objj_forward)(measureTextField, "setFont:", cellFont)); + var plainText = cellText && typeof cellText.string === "function" ? (cellText == null ? cellText : (cellText.isa.method_msgSend["string"] || _objj_forward)(cellText, "string")) : cellText || ""; + plainText = String(plainText); + if (cellText && typeof cellText.string === "function") + { + if ((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(measureTextField, "respondsToSelector:", sel_getUid("setAttributedStringValue:")))) + { + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setAttributedStringValue:"] || _objj_forward)(measureTextField, "setAttributedStringValue:", cellText)); + } + else + { + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", plainText)); + } + } + else + { + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", plainText)); + } + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["sizeToFit"] || _objj_forward)(measureTextField, "sizeToFit")); + var naturalW = CGRectGetWidth((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["frame"] || _objj_forward)(measureTextField, "frame"))) + 24.0; + if (naturalW > colNaturalWidths[colIndex]) + { + colNaturalWidths[colIndex] = naturalW; + } + var words = plainText.split(/[\s\-]/); + var maxWordW = 50.0; + for (var w = 0; w < words.length; w++) + { + var word = words[w].trim(); + if (word.length === 0) + continue; + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", word)); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["sizeToFit"] || _objj_forward)(measureTextField, "sizeToFit")); + var wordW = CGRectGetWidth((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["frame"] || _objj_forward)(measureTextField, "frame"))) + 30.0; + if (wordW > maxWordW) + { + maxWordW = wordW; + } + } + if (maxWordW > colMinWidths[colIndex]) + { + colMinWidths[colIndex] = maxWordW; + } + }; + if (currentHeaders) + { + for (var c = 0; c < (currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["count"] || _objj_forward)(currentHeaders, "count")); c++) + { + measureCell((currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(currentHeaders, "objectAtIndex:", c)), YES, c); + } + } + if (currentRows) + { + for (var r = 0; r < (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["count"] || _objj_forward)(currentRows, "count")); r++) + { + var rowData = (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(currentRows, "objectAtIndex:", r)); + for (var c = 0; c < numCols; c++) + { + var cellText = ""; + if (c < (rowData == null ? rowData : (rowData.isa.method_msgSend["count"] || _objj_forward)(rowData, "count"))) + { + cellText = (rowData == null ? rowData : (rowData.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(rowData, "objectAtIndex:", c)); + } + measureCell(cellText, NO, c); + } + } + } + var totalMinWidth = 0.0; + for (var c = 0; c < numCols; c++) + { + totalMinWidth += colMinWidths[c]; + } + var colWidths = []; + if (newWidth <= totalMinWidth) + { + var remainingWidth = newWidth; + for (var c = 0; c < numCols; c++) + { + var w = Math.floor(colMinWidths[c] / totalMinWidth * newWidth); + colWidths[c] = w; + remainingWidth -= w; + } + if (numCols > 0) + colWidths[numCols - 1] += remainingWidth; + } + else + { + for (var c = 0; c < numCols; c++) + { + colWidths[c] = colMinWidths[c]; + } + var totalGrowthCapacity = 0.0; + var growthCapacities = []; + for (var c = 0; c < numCols; c++) + { + var capacity = Math.max(0.0, colNaturalWidths[c] - colMinWidths[c]); + growthCapacities[c] = capacity; + totalGrowthCapacity += capacity; + } + var extraWidth = newWidth - totalMinWidth; + var remainingExtra = extraWidth; + for (var c = 0; c < numCols; c++) + { + if (totalGrowthCapacity > 0) + { + var w = Math.floor(growthCapacities[c] / totalGrowthCapacity * extraWidth); + colWidths[c] += w; + remainingExtra -= w; + } + } + if (numCols > 0) + { + colWidths[numCols - 1] += remainingExtra; + } + } + var cellIndex = 0; + var currentY = 0; + var layoutRow = function(startIndex) + { + var maxCellHeight = 28.0; + for (var c = 0; c < numCols; c++) + { + var idx = startIndex + c; + if (idx < (subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count"))) + { + var cellView = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", idx)); + var textView = (self.isa.method_msgSend["getTextViewFromCell:"] || _objj_forward)(self, "getTextViewFromCell:", cellView); + if (textView) + { + var targetWidth = Math.max(10.0, colWidths[c] - 8); + ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textContainer"] || _objj_forward)(textView, "textContainer"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setContainerSize:"] || _objj_forward)(___r1, "setContainerSize:", CGSizeMake(targetWidth, 1e7))); + var layoutManager = (textView == null ? textView : (textView.isa.method_msgSend["layoutManager"] || _objj_forward)(textView, "layoutManager")); + var usedRect = layoutManager ? (layoutManager == null ? layoutManager : (layoutManager.isa.method_msgSend["usedRectForTextContainer:"] || _objj_forward)(layoutManager, "usedRectForTextContainer:", (textView == null ? textView : (textView.isa.method_msgSend["textContainer"] || _objj_forward)(textView, "textContainer")))) : nil; + var wrappedHeight = (usedRect ? CGRectGetHeight(usedRect) : 0.0) + 12.0; + if (wrappedHeight > maxCellHeight) + { + maxCellHeight = wrappedHeight; + } + } + } + } + var currentX = 0; + for (var c = 0; c < numCols; c++) + { + var idx = startIndex + c; + if (idx < (subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count"))) + { + var cellView = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", idx)); + (cellView == null ? cellView : (cellView.isa.method_msgSend["setFrame:"] || _objj_forward)(cellView, "setFrame:", CGRectMake(currentX, currentY, colWidths[c], maxCellHeight))); + var textView = (self.isa.method_msgSend["getTextViewFromCell:"] || _objj_forward)(self, "getTextViewFromCell:", cellView); + if (textView) + { + var targetWidth = Math.max(10.0, colWidths[c] - 8); + var textY = 4.0; + var finalTextViewHeight = maxCellHeight - 8.0; + (textView == null ? textView : (textView.isa.method_msgSend["setFrame:"] || _objj_forward)(textView, "setFrame:", CGRectMake(4, textY, targetWidth, finalTextViewHeight))); + } + var cellSubviews = (cellView == null ? cellView : (cellView.isa.method_msgSend["subviews"] || _objj_forward)(cellView, "subviews")); + if ((cellSubviews == null ? cellSubviews : (cellSubviews.isa.method_msgSend["count"] || _objj_forward)(cellSubviews, "count")) > 0) + { + ((___r1 = (cellSubviews == null ? cellSubviews : (cellSubviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(cellSubviews, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setFrame:"] || _objj_forward)(___r1, "setFrame:", CGRectMake(0, 0, colWidths[c], maxCellHeight))); + } + } + currentX += colWidths[c]; + } + return maxCellHeight; + var ___r1; + }; + if (currentHeaders && (currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["count"] || _objj_forward)(currentHeaders, "count")) > 0) + { + var headerHeight = layoutRow(cellIndex); + cellIndex += numCols; + currentY += headerHeight; + } + if (currentRows) + { + for (var r = 0; r < (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["count"] || _objj_forward)(currentRows, "count")); r++) + { + var rowHeight = layoutRow(cellIndex); + cellIndex += numCols; + currentY += rowHeight; + } + } + var currentSize = (self.isa.method_msgSend["frame"] || _objj_forward)(self, "frame").size; + if (ABS(currentSize.width - newWidth) > 0.1 || ABS(currentSize.height - currentY) > 0.1) + { + (self.isa.method_msgSend["setFrameSize:"] || _objj_forward)(self, "setFrameSize:", CGSizeMake(newWidth, currentY)); + } + self._isResizing = NO; + var ___r1; +} + +,["void","float"])]); +} p;18;CPFontDescriptor.jt;13127;@STATIC;1.0;I;21;Foundation/CPObject.jt;13081;objj_executeFile("Foundation/CPObject.j", NO);CPFontNameAttribute = "CPFontNameAttribute"; CPFontSizeAttribute = "CPFontSizeAttribute"; CPFontTraitsAttribute = "CPFontTraitsAttribute"; @@ -70149,7 +71225,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("initWithFrame:"), funct ,["void","CPEvent"])]); } (CPFontManager == null ? CPFontManager : (CPFontManager.isa.method_msgSend["setFontPanelFactory:"] || _objj_forward)(CPFontManager, "setFontPanelFactory:", (CPFontPanel.isa.method_msgSend["class"] || _objj_forward)(CPFontPanel, "class"))); -p;17;CPLayoutManager.jt;62602;@STATIC;1.0;i;8;CPText.ji;17;CPTextContainer.ji;11;CGContext.ji;14;CPTypesetter.ji;8;CPFont.jt;62501;objj_executeFile("CPText.j", YES);objj_executeFile("CPTextContainer.j", YES);objj_executeFile("CGContext.j", YES);objj_executeFile("CPTypesetter.j", YES);objj_executeFile("CPFont.j", YES);_isNewlineCharacter = function(chr) +p;17;CPLayoutManager.jt;66334;@STATIC;1.0;i;8;CPText.ji;17;CPTextContainer.ji;11;CGContext.ji;14;CPTypesetter.ji;8;CPFont.jt;66233;objj_executeFile("CPText.j", YES);objj_executeFile("CPTextContainer.j", YES);objj_executeFile("CGContext.j", YES);objj_executeFile("CPTypesetter.j", YES);objj_executeFile("CPFont.j", YES);_isNewlineCharacter = function(chr) { return chr === '\n' || chr === '\r'; } @@ -70597,13 +71673,18 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), { var frames = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames")), len = fragment._range.length; - for (var j = 0; j < len; j++) + if (frames) { - if (CGRectContainsPoint(frames[j], point)) + var maxLen = MIN(len, frames.length); + for (var j = 0; j < maxLen; j++) { - if (partialFraction) - partialFraction[0] = (point.x - frames[j].origin.x) / frames[j].size.width; - return fragment._range.location + j; + var frame = frames[j]; + if (frame && CGRectContainsPoint(frame, point)) + { + if (partialFraction) + partialFraction[0] = (point.x - frame.origin.x) / frame.size.width; + return fragment._range.location + j; + } } } } @@ -70620,16 +71701,23 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), if (i < c - 1 && self._lineFragments[i + 1]._fragmentRect.origin.y === fragment._fragmentRect.origin.y) continue; var nlLoc = CPMaxRange(fragment._range), - lastFrame = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames"))[fragment._range.length - 1], - firstFrame = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames"))[0]; - if (_isNewlineCharacter(((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["string"] || _objj_forward)(___r2, "string"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["characterAtIndex:"] || _objj_forward)(___r1, "characterAtIndex:", nlLoc > 0 ? nlLoc - 1 : 0)))) - nlLoc--; - if (point.x > CGRectGetMaxX(lastFrame)) - return nlLoc; - else if (point.x <= CGRectGetMinX(firstFrame)) - return fragment._range.location; - else - return nlLoc; + frames = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames")); + if (frames && frames.length > 0) + { + var lastFrame = frames[frames.length - 1], + firstFrame = frames[0]; + if (lastFrame && firstFrame) + { + if (_isNewlineCharacter(((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["string"] || _objj_forward)(___r2, "string"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["characterAtIndex:"] || _objj_forward)(___r1, "characterAtIndex:", nlLoc > 0 ? nlLoc - 1 : 0)))) + nlLoc--; + if (point.x > CGRectGetMaxX(lastFrame)) + return nlLoc; + else if (point.x <= CGRectGetMinX(firstFrame)) + return fragment._range.location; + else + return nlLoc; + } + } } } } @@ -70743,7 +71831,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), if (!lineFragment) return 0.0; var index = location - lineFragment._range.location; - return lineFragment._glyphsOffsets[index]; + if (index < 0 || !lineFragment._glyphsOffsets || index >= lineFragment._glyphsOffsets.length) + return 0.0; + var offset = lineFragment._glyphsOffsets[index]; + return offset === undefined ? 0.0 : offset; } ,["double","unsigned"]), new objj_method(sel_getUid("_descentAtLocation:"), function $CPLayoutManager___descentAtLocation_(self, _cmd, location) @@ -70752,7 +71843,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), if (!lineFragment) return 0.0; var index = location - lineFragment._range.location; - return lineFragment._glyphsFrames[index]._descent; + if (index < 0 || !lineFragment._glyphsFrames || index >= lineFragment._glyphsFrames.length) + return 0.0; + var frame = lineFragment._glyphsFrames[index]; + return frame && frame._descent !== undefined ? frame._descent : 0.0; } ,["double","unsigned"]), new objj_method(sel_getUid("setLineFragmentRect:forGlyphRange:usedRect:"), function $CPLayoutManager__setLineFragmentRect_forGlyphRange_usedRect_(self, _cmd, fragmentRect, glyphRange, usedRect) @@ -70864,8 +71958,12 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), { var lineFragment = self._lineFragments[self._lineFragments.length - 1], glyphFrames = (lineFragment == null ? lineFragment : (lineFragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(lineFragment, "glyphFrames")); - if (glyphFrames.length > 0) - return CGPointCreateCopy(glyphFrames[glyphFrames.length - 1].origin); + if (glyphFrames && glyphFrames.length > 0) + { + var frame = glyphFrames[glyphFrames.length - 1]; + if (frame) + return CGPointCreateCopy(frame.origin); + } } var lineFragment = _objectWithLocationInRange(self._lineFragments, index); if (lineFragment) @@ -70873,7 +71971,14 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), if (index == lineFragment._range.location) return CGPointCreateCopy(lineFragment._location); var glyphFrames = (lineFragment == null ? lineFragment : (lineFragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(lineFragment, "glyphFrames")); - return CGPointCreateCopy(glyphFrames[index - lineFragment._range.location].origin); + var relativeIndex = index - lineFragment._range.location; + if (glyphFrames && relativeIndex >= 0 && relativeIndex < glyphFrames.length) + { + var frame = glyphFrames[relativeIndex]; + if (frame) + return CGPointCreateCopy(frame.origin); + } + return CGPointCreateCopy(lineFragment._location); } return CGPointMakeZero(); } @@ -70924,19 +72029,26 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), var frames = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames")), rect = nil, len = fragment._range.length; - for (var j = 0; j < len; j++) + if (frames) { - if (CPLocationInRange(fragment._range.location + j, selectedCharRange)) + for (var j = 0; j < len; j++) { - var correctedRect = CGRectCreateCopy(frames[j]); - correctedRect.size.height -= frames[j]._descent; - correctedRect.origin.y -= frames[j]._descent; - if (!rect) - rect = CGRectCreateCopy(correctedRect); - else - rect = CGRectUnion(rect, correctedRect); - if (_isNewlineCharacter(((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["string"] || _objj_forward)(___r2, "string"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["characterAtIndex:"] || _objj_forward)(___r1, "characterAtIndex:", MAX(0, CPMaxRange(selectedCharRange) - 1))))) - rect.size.width = containerSize.width - rect.origin.x; + if (j < frames.length && CPLocationInRange(fragment._range.location + j, selectedCharRange)) + { + var frame = frames[j]; + if (frame) + { + var correctedRect = CGRectCreateCopy(frame); + correctedRect.size.height -= frame._descent; + correctedRect.origin.y -= frame._descent; + if (!rect) + rect = CGRectCreateCopy(correctedRect); + else + rect = CGRectUnion(rect, correctedRect); + if (_isNewlineCharacter(((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["string"] || _objj_forward)(___r2, "string"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["characterAtIndex:"] || _objj_forward)(___r1, "characterAtIndex:", MAX(0, CPMaxRange(selectedCharRange) - 1))))) + rect.size.width = containerSize.width - rect.origin.x; + } + } } } if (rect) @@ -71065,6 +72177,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function ,["id","CPString","CPFont","CPColor"]), new objj_method(sel_getUid("createDOMElementWithText:andFont:andColor:andBackgroundColor:andUnderline:"), function $_CPLineFragment__createDOMElementWithText_andFont_andColor_andBackgroundColor_andUnderline_(self, _cmd, aString, aFont, fgColor, bgColor, aUnderline) { + if (!aString || aString.length === 0) + return nil; var style, span = document.createElement("span"); span.oncontextmenu = span.onmousedown = span.onselectstart = _oncontextmenuhandler; @@ -71125,15 +72239,14 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function var attributes = (textStorage == null ? textStorage : (textStorage.isa.method_msgSend["attributesAtIndex:effectiveRange:"] || _objj_forward)(textStorage, "attributesAtIndex:effectiveRange:", location, effectiveRange)); effectiveRange = attributes ? CPIntersectionRange(aRange, effectiveRange) : aRange; var string = ((___r1 = textStorage._string), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["substringWithRange:"] || _objj_forward)(___r1, "substringWithRange:", effectiveRange)), - underline = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPUnderlineStyleAttributeName)) || CPUnderlineStyleNone; + underline = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPUnderlineStyleAttributeName)) || CPUnderlineStyleNone, + paragraphStyle = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPParagraphStyleAttributeName)) || (CPParagraphStyle.isa.method_msgSend["defaultParagraphStyle"] || _objj_forward)(CPParagraphStyle, "defaultParagraphStyle"); if (string === _CPAttachmentCharacterAsString) { if (!(attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", _CPAttachmentInvisible))) { - var view = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", _CPAttachmentView)), - viewCopy = (CPKeyedUnarchiver.isa.method_msgSend["unarchiveObjectWithData:"] || _objj_forward)(CPKeyedUnarchiver, "unarchiveObjectWithData:", (CPKeyedArchiver.isa.method_msgSend["archivedDataWithRootObject:"] || _objj_forward)(CPKeyedArchiver, "archivedDataWithRootObject:", view)), - elem = viewCopy._DOMElement, - run = {_range: CPMakeRangeCopy(effectiveRange), color: nil, font: nil, elem: elem, string: nil, view: viewCopy}; + var view = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", _CPAttachmentView)); + var run = {_range: CPMakeRangeCopy(effectiveRange), color: nil, font: nil, elem: nil, string: nil, view: view, paragraphStyle: paragraphStyle}; self._runs.push(run); } } @@ -71141,9 +72254,34 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function { var color = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPForegroundColorAttributeName)), bgcolor = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPBackgroundColorAttributeName)), - font = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPFontAttributeName)) || (textStorage == null ? textStorage : (textStorage.isa.method_msgSend["font"] || _objj_forward)(textStorage, "font")) || (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 12.0), - run = {_range: CPMakeRangeCopy(effectiveRange), color: color, font: font, elem: nil, string: string, bgcolor: bgcolor}; - self._runs.push(run); + font = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPFontAttributeName)) || (textStorage == null ? textStorage : (textStorage.isa.method_msgSend["font"] || _objj_forward)(textStorage, "font")) || (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 12.0); + var currentLoc = effectiveRange.location, + strLen = string.length, + startIdx = 0; + for (var i = 0; i < strLen; i++) + { + if (string.charCodeAt(i) === 9) + { + if (i > startIdx) + { + var subString = string.substring(startIdx, i), + subRange = CPMakeRange(currentLoc + startIdx, i - startIdx), + run = {_range: subRange, color: color, font: font, elem: nil, string: subString, bgcolor: bgcolor, paragraphStyle: paragraphStyle}; + self._runs.push(run); + } + var tabRange = CPMakeRange(currentLoc + i, 1), + tabRun = {_range: tabRange, color: nil, font: nil, elem: nil, string: nil, bgcolor: nil, paragraphStyle: paragraphStyle}; + self._runs.push(tabRun); + startIdx = i + 1; + } + } + if (startIdx < strLen) + { + var subString = string.substring(startIdx, strLen), + subRange = CPMakeRange(currentLoc + startIdx, strLen - startIdx), + run = {_range: subRange, color: color, font: font, elem: nil, string: subString, bgcolor: bgcolor, paragraphStyle: paragraphStyle}; + self._runs.push(run); + } } if (!CPMaxRange(effectiveRange)) break; @@ -71201,13 +72339,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function var l = self._runs.length; for (var i = 0; i < l; i++) { + if (self._runs[i].view && self._runs[i].DOMactive) + ((___r1 = self._runs[i].view), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["removeFromSuperview"] || _objj_forward)(___r1, "removeFromSuperview")); if (self._runs[i].elem && self._runs[i].DOMactive) - { - if (self._runs[i].view) - ((___r1 = self._runs[i].view), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["removeFromSuperview"] || _objj_forward)(___r1, "removeFromSuperview")); - else - self._textContainer._textView._DOMElement.removeChild(self._runs[i].elem); - } + self._textContainer._textView._DOMElement.removeChild(self._runs[i].elem); self._runs[i].elem = nil; self._runs[i].DOMactive = NO; } @@ -71219,6 +72354,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function var runs = _objectsInRange(self._runs, aRange), c = runs.length, orig = CGPointMake(self._fragmentRect.origin.x, self._fragmentRect.origin.y); + if (self._runs.length === 0) + return; for (var i = 0; i < c; i++) { var run = runs[i]; @@ -71229,19 +72366,24 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function if (!self._glyphsFrames) continue; var loc = run._range.location - self._runs[0]._range.location; + if (loc < 0 || loc >= self._glyphsFrames.length || !self._glyphsFrames[loc] || !self._glyphsOffsets || loc >= self._glyphsOffsets.length) + continue; orig.x = self._glyphsFrames[loc].origin.x + aPoint.x; orig.y = self._glyphsFrames[loc].origin.y + aPoint.y + self._glyphsOffsets[loc]; - if (run.elem) + if (run.elem || run.view) { - run.elem.style.left = orig.x + "px"; - run.elem.style.top = orig.y + "px"; + if (run.elem) + { + run.elem.style.left = orig.x + "px"; + run.elem.style.top = orig.y + "px"; + } if (run.view) ((___r1 = run.view), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setFrameOrigin:"] || _objj_forward)(___r1, "setFrameOrigin:", orig)); if (!run.DOMactive) { if (run.view) ((___r1 = self._textContainer._textView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addSubview:"] || _objj_forward)(___r1, "addSubview:", run.view)); - else + if (run.elem) self._textContainer._textView._DOMElement.appendChild(run.elem); } run.DOMactive = YES; @@ -71274,6 +72416,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function return NO; if (newFragmentRuns[i].color !== oldFragmentRuns[i].color || newFragmentRuns[i].bgcolor !== oldFragmentRuns[i].bgcolor || newFragmentRuns[i].font !== oldFragmentRuns[i].font) return NO; + var oldStyle = oldFragmentRuns[i].paragraphStyle || (CPParagraphStyle.isa.method_msgSend["defaultParagraphStyle"] || _objj_forward)(CPParagraphStyle, "defaultParagraphStyle"), + newStyle = newFragmentRuns[i].paragraphStyle || (CPParagraphStyle.isa.method_msgSend["defaultParagraphStyle"] || _objj_forward)(CPParagraphStyle, "defaultParagraphStyle"); + if (!(oldStyle == null ? oldStyle : (oldStyle.isa.method_msgSend["isEqual:"] || _objj_forward)(oldStyle, "isEqual:", newStyle))) + return NO; } return YES; } @@ -71289,6 +72435,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function { if (self._runs[i].view) self._runs[i].view._frame.origin.y += verticalOffset; + if (self._runs[i].elem) + self._runs[i].elem.top = self._runs[i].elem.top + verticalOffset + 'px'; self._runs[i].DOMpatched = YES; } } @@ -71728,11 +72876,11 @@ class_addMethods(the_class, [new objj_method(sel_getUid("initWithParagraphStyle: ,["id","CPZone"])]); } -p;13;CPRulerView.jt;37335;@STATIC;1.0;I;21;Foundation/CPObject.ji;8;CPView.ji;13;CPTextField.ji;9;CPColor.ji;8;CPFont.ji;8;CPMenu.ji;12;CPMenuItem.jt;37205;objj_executeFile("Foundation/CPObject.j", NO);objj_executeFile("CPView.j", YES);objj_executeFile("CPTextField.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPFont.j", YES);objj_executeFile("CPMenu.j", YES);objj_executeFile("CPMenuItem.j", YES);(CPHorizontalRuler = 0, CPVerticalRuler = 1, CPRulerOrientationHorizontal = 0, CPRulerOrientationVertical = 1); +p;13;CPRulerView.jt;44796;@STATIC;1.0;I;21;Foundation/CPObject.ji;8;CPView.ji;13;CPTextField.ji;9;CPColor.ji;8;CPFont.ji;8;CPMenu.ji;12;CPMenuItem.jt;44666;objj_executeFile("Foundation/CPObject.j", NO);objj_executeFile("CPView.j", YES);objj_executeFile("CPTextField.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPFont.j", YES);objj_executeFile("CPMenu.j", YES);objj_executeFile("CPMenuItem.j", YES);(CPHorizontalRuler = 0, CPVerticalRuler = 1, CPRulerOrientationHorizontal = 0, CPRulerOrientationVertical = 1); ; {var the_class = objj_allocateClassPair(CPView, "CPRulerMarker"), -meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_rulerView", "CPRulerView"), new objj_ivar("_imageValue", "float"), new objj_ivar("_representedObject", "id"), new objj_ivar("_label", "CPTextField")]);objj_registerClassPair(the_class); +meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_rulerView", "CPRulerView"), new objj_ivar("_imageValue", "float"), new objj_ivar("_representedObject", "id"), new objj_ivar("_label", "CPTextField"), new objj_ivar("_customHandleView", "CPView")]);objj_registerClassPair(the_class); class_addMethods(the_class, [new objj_method(sel_getUid("rulerView"), function $CPRulerMarker__rulerView(self, _cmd) { return self._rulerView; @@ -71775,6 +72923,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("rulerView"), function $ ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setTextColor:"] || _objj_forward)(___r1, "setTextColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.2, 1.0))); ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setAlignment:"] || _objj_forward)(___r1, "setAlignment:", CPCenterTextAlignment)); (self == null ? self : (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", self._label)); + self._customHandleView = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMakeZero())); + (self == null ? self : (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", self._customHandleView)); (self == null ? self : (self.isa.method_msgSend["updateMarkerIcon"] || _objj_forward)(self, "updateMarkerIcon")); } return self; @@ -71792,34 +72942,62 @@ class_addMethods(the_class, [new objj_method(sel_getUid("rulerView"), function $ (self.isa.method_msgSend["updateMarkerIcon"] || _objj_forward)(self, "updateMarkerIcon"); } -,["void","id"]), new objj_method(sel_getUid("updateMarkerIcon"), function $CPRulerMarker__updateMarkerIcon(self, _cmd) +,["void","id"]), new objj_method(sel_getUid("setFrame:"), function $CPRulerMarker__setFrame_(self, _cmd, aFrame) { - if (((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(___r1, "isKindOfClass:", (CPTextTab == null ? CPTextTab : (CPTextTab.isa.method_msgSend["class"] || _objj_forward)(CPTextTab, "class"))))) + (objj_getClass("CPRulerMarker").super_class.method_dtable["setFrame:"] || _objj_forward)(self, "setFrame:", aFrame); + (self.isa.method_msgSend["updateMarkerIcon"] || _objj_forward)(self, "updateMarkerIcon"); +} + +,["void","CGRect"]), new objj_method(sel_getUid("updateMarkerIcon"), function $CPRulerMarker__updateMarkerIcon(self, _cmd) +{ + var isIndentMarker = self._representedObject === "CPFirstLineIndent" || self._representedObject === "CPHeadIndent"; + if (isIndentMarker) { - var align = ((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["alignment"] || _objj_forward)(___r1, "alignment")); - if (align === CPLeftTextAlignment) - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "▶")); - else if (align === CPCenterTextAlignment) - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "▼")); - else if (align === CPRightTextAlignment) - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "◀")); - } - else if (((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(___r1, "isKindOfClass:", (CPString.isa.method_msgSend["class"] || _objj_forward)(CPString, "class")))) - { - if (self._representedObject === "CPFirstLineIndent") - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⥔")); - else if (self._representedObject === "CPHeadIndent") - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⥜")); - else if (self._representedObject === "CPTailIndent") - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⥘")); + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setHidden:"] || _objj_forward)(___r1, "setHidden:", YES)); + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setHidden:"] || _objj_forward)(___r1, "setHidden:", NO)); + var frame = (self.isa.method_msgSend["bounds"] || _objj_forward)(self, "bounds"); + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setFrame:"] || _objj_forward)(___r1, "setFrame:", CGRectMake(0, 0, frame.size.width, frame.size.height))); + ((___r1 = ((___r2 = self._customHandleView), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["subviews"] || _objj_forward)(___r2, "subviews"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["makeObjectsPerformSelector:"] || _objj_forward)(___r1, "makeObjectsPerformSelector:", sel_getUid("removeFromSuperview"))); + var isFirstLine = self._representedObject === "CPFirstLineIndent"; + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(___r1, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.5, 1.0))); + var innerView = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(1.0, 1.0, frame.size.width - 2.0, frame.size.height - 2.0))); + if (isFirstLine) + (innerView == null ? innerView : (innerView.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(innerView, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.92, 1.0))); else - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⇡")); + (innerView == null ? innerView : (innerView.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(innerView, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.80, 1.0))); + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addSubview:"] || _objj_forward)(___r1, "addSubview:", innerView)); + var gripLine = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(Math.floor(frame.size.width / 2.0) - 1.0, 2.0, 1.0, frame.size.height - 4.0))); + (gripLine == null ? gripLine : (gripLine.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(gripLine, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.6, 1.0))); + (innerView == null ? innerView : (innerView.isa.method_msgSend["addSubview:"] || _objj_forward)(innerView, "addSubview:", gripLine)); } else { - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⇡")); + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setHidden:"] || _objj_forward)(___r1, "setHidden:", NO)); + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setHidden:"] || _objj_forward)(___r1, "setHidden:", YES)); + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setFrame:"] || _objj_forward)(___r1, "setFrame:", (self.isa.method_msgSend["bounds"] || _objj_forward)(self, "bounds"))); + if (((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(___r1, "isKindOfClass:", (CPTextTab == null ? CPTextTab : (CPTextTab.isa.method_msgSend["class"] || _objj_forward)(CPTextTab, "class"))))) + { + var align = ((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["alignment"] || _objj_forward)(___r1, "alignment")); + if (align === CPLeftTextAlignment) + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "▶")); + else if (align === CPCenterTextAlignment) + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "▼")); + else if (align === CPRightTextAlignment) + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "◀")); + } + else if (((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(___r1, "isKindOfClass:", (CPString.isa.method_msgSend["class"] || _objj_forward)(CPString, "class")))) + { + if (self._representedObject === "CPTailIndent") + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⥘")); + else + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⇡")); + } + else + { + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⇡")); + } } - var ___r1; + var ___r1, ___r2; } ,["void"]), new objj_method(sel_getUid("menuForEvent:"), function $CPRulerMarker__menuForEvent_(self, _cmd, anEvent) @@ -72021,12 +73199,27 @@ class_addMethods(the_class, [new objj_method(sel_getUid("scrollView"), function if (isHorizontal) { var x = markerLocation - scrollPoint.x - 6.0, - y = rulerHeight - 11.0; - if (x < 0.0) - x = 0.0; - else if (x + 12.0 > rulerWidth) - x = rulerWidth - 12.0; - (aMarker == null ? aMarker : (aMarker.isa.method_msgSend["setFrame:"] || _objj_forward)(aMarker, "setFrame:", CGRectMake(x, y, 12.0, 12.0))); + y = rulerHeight - 11.0, + w = 12.0, + h = 12.0; + if ((aMarker == null ? aMarker : (aMarker.isa.method_msgSend["representedObject"] || _objj_forward)(aMarker, "representedObject")) === "CPFirstLineIndent") + { + y = 0.0; + h = Math.floor(rulerHeight / 2.0); + } + else if ((aMarker == null ? aMarker : (aMarker.isa.method_msgSend["representedObject"] || _objj_forward)(aMarker, "representedObject")) === "CPHeadIndent") + { + y = Math.floor(rulerHeight / 2.0); + h = rulerHeight - y - 1.0; + } + else + { + if (x < 0.0) + x = 0.0; + else if (x + 12.0 > rulerWidth) + x = rulerWidth - 12.0; + } + (aMarker == null ? aMarker : (aMarker.isa.method_msgSend["setFrame:"] || _objj_forward)(aMarker, "setFrame:", CGRectMake(x, y, w, h))); } else { @@ -72082,7 +73275,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("scrollView"), function if (newLocation < 0) newLocation = 0; ((___r1 = self._draggingMarker), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setImageValue:"] || _objj_forward)(___r1, "setImageValue:", newLocation)); - (self.isa.method_msgSend["_positionMarker:"] || _objj_forward)(self, "_positionMarker:", self._draggingMarker); + (self.isa.method_msgSend["updateRuler"] || _objj_forward)(self, "updateRuler"); var draggedOff = isHorizontal ? localPoint.y < -15 || localPoint.y > CGRectGetHeight((self.isa.method_msgSend["bounds"] || _objj_forward)(self, "bounds")) + 15 : localPoint.x < -15 || localPoint.x > CGRectGetWidth((self.isa.method_msgSend["bounds"] || _objj_forward)(self, "bounds")) + 15; if (draggedOff) { @@ -72120,6 +73313,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("scrollView"), function ((___r1 = ((___r2 = self._draggingMarker), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["label"] || _objj_forward)(___r2, "label"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setTextColor:"] || _objj_forward)(___r1, "setTextColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.2, 1.0))); } self._draggingMarker = nil; + (self.isa.method_msgSend["updateRuler"] || _objj_forward)(self, "updateRuler"); var ___r1, ___r2; } @@ -72142,6 +73336,37 @@ class_addMethods(the_class, [new objj_method(sel_getUid("scrollView"), function var bottomBorder = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, rulerHeight - 1, rulerWidth, 1))); (bottomBorder == null ? bottomBorder : (bottomBorder.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(bottomBorder, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.75, 1.0))); (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", bottomBorder); + var firstLineMarker = nil, + headMarker = nil; + for (var i = 0; i < ((___r1 = self._markers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); i++) + { + var m = ((___r1 = self._markers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", i)); + if ((m == null ? m : (m.isa.method_msgSend["representedObject"] || _objj_forward)(m, "representedObject")) === "CPFirstLineIndent") + firstLineMarker = m; + else if ((m == null ? m : (m.isa.method_msgSend["representedObject"] || _objj_forward)(m, "representedObject")) === "CPHeadIndent") + headMarker = m; + } + var halfHeight = Math.floor(rulerHeight / 2.0); + if (firstLineMarker) + { + var firstLineX = (firstLineMarker == null ? firstLineMarker : (firstLineMarker.isa.method_msgSend["imageValue"] || _objj_forward)(firstLineMarker, "imageValue")) - scrollPoint.x; + if (firstLineX > 0) + { + var firstLineBg = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, 0, firstLineX, halfHeight))); + (firstLineBg == null ? firstLineBg : (firstLineBg.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(firstLineBg, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.93, 1.0))); + (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", firstLineBg); + } + } + if (headMarker) + { + var headX = (headMarker == null ? headMarker : (headMarker.isa.method_msgSend["imageValue"] || _objj_forward)(headMarker, "imageValue")) - scrollPoint.x; + if (headX > 0) + { + var headBg = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, halfHeight, headX, rulerHeight - halfHeight - 1.0))); + (headBg == null ? headBg : (headBg.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(headBg, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.86, 1.0))); + (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", headBg); + } + } for (var val = start; val <= end; val += 10) { if (val < 0) @@ -72712,7 +73937,7 @@ var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_ ,["void"])]); } -p;12;CPTextView.jt;225939;@STATIC;1.0;i;8;CPText.ji;14;CPPasteboard.ji;14;CPColorPanel.ji;15;CPFontManager.ji;15;CPTextStorage.ji;17;CPTextContainer.ji;17;CPLayoutManager.ji;18;CPParagraphStyle.ji;14;_CPRTFParser.ji;16;_CPRTFProducer.jt;225721;objj_executeFile("CPText.j", YES);objj_executeFile("CPPasteboard.j", YES);objj_executeFile("CPColorPanel.j", YES);objj_executeFile("CPFontManager.j", YES);objj_executeFile("CPTextStorage.j", YES);objj_executeFile("CPTextContainer.j", YES);objj_executeFile("CPLayoutManager.j", YES);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("_CPRTFParser.j", YES);objj_executeFile("_CPRTFProducer.j", YES);; +p;12;CPTextView.jt;227286;@STATIC;1.0;i;8;CPText.ji;14;CPPasteboard.ji;14;CPColorPanel.ji;15;CPFontManager.ji;15;CPTextStorage.ji;17;CPTextContainer.ji;17;CPLayoutManager.ji;18;CPParagraphStyle.ji;14;_CPRTFParser.ji;16;_CPRTFProducer.jt;227068;objj_executeFile("CPText.j", YES);objj_executeFile("CPPasteboard.j", YES);objj_executeFile("CPColorPanel.j", YES);objj_executeFile("CPFontManager.j", YES);objj_executeFile("CPTextStorage.j", YES);objj_executeFile("CPTextContainer.j", YES);objj_executeFile("CPLayoutManager.j", YES);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("_CPRTFParser.j", YES);objj_executeFile("_CPRTFProducer.j", YES);; ; ; ; @@ -73101,6 +74326,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function ,["void","CPNotification"]), new objj_method(sel_getUid("superviewFrameChanged:"), function $CPTextView__superviewFrameChanged_(self, _cmd, aNotification) { self._exposedRect = nil; + (self.isa.method_msgSend["sizeToFit"] || _objj_forward)(self, "sizeToFit"); } ,["void","CPNotification"]), new objj_method(sel_getUid("viewWillMoveToSuperview:"), function $CPTextView__viewWillMoveToSuperview_(self, _cmd, aView) @@ -73886,7 +75112,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function ,["void","int","CPSelectionGranularity"]), new objj_method(sel_getUid("moveLeftAndModifySelection:"), function $CPTextView__moveLeftAndModifySelection_(self, _cmd, sender) { if ((self.isa.method_msgSend["isSelectable"] || _objj_forward)(self, "isSelectable")) + { (self.isa.method_msgSend["_extendSelectionIntoDirection:granularity:"] || _objj_forward)(self, "_extendSelectionIntoDirection:granularity:", -1, CPSelectByCharacter); + (self.isa.method_msgSend["scrollRangeToVisible:"] || _objj_forward)(self, "scrollRangeToVisible:", self._selectionRange); + } } ,["void","id"]), new objj_method(sel_getUid("moveBackward:"), function $CPTextView__moveBackward_(self, _cmd, sender) @@ -73908,7 +75137,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function ,["void","id"]), new objj_method(sel_getUid("moveLeft:"), function $CPTextView__moveLeft_(self, _cmd, sender) { if ((self.isa.method_msgSend["isSelectable"] || _objj_forward)(self, "isSelectable")) + { (self.isa.method_msgSend["_establishSelection:byExtending:"] || _objj_forward)(self, "_establishSelection:byExtending:", CPMakeRange(self._selectionRange.location - (self._selectionRange.length ? 0 : 1), 0), NO); + (self.isa.method_msgSend["scrollRangeToVisible:"] || _objj_forward)(self, "scrollRangeToVisible:", self._selectionRange); + } } ,["void","id"]), new objj_method(sel_getUid("moveToEndOfParagraph:"), function $CPTextView__moveToEndOfParagraph_(self, _cmd, sender) @@ -74133,7 +75365,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function ,["void","id"]), new objj_method(sel_getUid("moveRight:"), function $CPTextView__moveRight_(self, _cmd, sender) { if ((self.isa.method_msgSend["isSelectable"] || _objj_forward)(self, "isSelectable")) + { (self.isa.method_msgSend["_establishSelection:byExtending:"] || _objj_forward)(self, "_establishSelection:byExtending:", CPMakeRange(CPMaxRange(self._selectionRange) + (self._selectionRange.length ? 0 : 1), 0), NO); + (self.isa.method_msgSend["scrollRangeToVisible:"] || _objj_forward)(self, "scrollRangeToVisible:", self._selectionRange); + } } ,["void","id"]), new objj_method(sel_getUid("_deleteForRange:"), function $CPTextView___deleteForRange_(self, _cmd, changedRange) @@ -74536,9 +75771,15 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function if (CPEmptyRange(aRange)) { if (aRange.location >= ((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["numberOfCharacters"] || _objj_forward)(___r1, "numberOfCharacters"))) - rect = ((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["extraLineFragmentRect"] || _objj_forward)(___r1, "extraLineFragmentRect")); + { + rect = CGRectCreateCopy(((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["extraLineFragmentRect"] || _objj_forward)(___r1, "extraLineFragmentRect"))); + rect.size.width = 1.0; + } else - rect = ((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["lineFragmentRectForGlyphAtIndex:effectiveRange:"] || _objj_forward)(___r1, "lineFragmentRectForGlyphAtIndex:effectiveRange:", aRange.location, nil)); + { + rect = CGRectCreateCopy(((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["boundingRectForGlyphRange:inTextContainer:"] || _objj_forward)(___r1, "boundingRectForGlyphRange:inTextContainer:", CPMakeRange(aRange.location, 1), self._textContainer))); + rect.size.width = 1.0; + } } else { @@ -74934,6 +76175,9 @@ class_addMethods(the_class, [new objj_method(sel_getUid("updateRuler"), function ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(___r1, "setObject:forKey:", mutableStyle, CPParagraphStyleAttributeName)); ((___r1 = (CPNotificationCenter.isa.method_msgSend["defaultCenter"] || _objj_forward)(CPNotificationCenter, "defaultCenter")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["postNotificationName:object:"] || _objj_forward)(___r1, "postNotificationName:object:", CPTextViewDidChangeTypingAttributesNotification, self)); } + ((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["_validateLayoutAndGlyphs"] || _objj_forward)(___r1, "_validateLayoutAndGlyphs")); + (self.isa.method_msgSend["sizeToFit"] || _objj_forward)(self, "sizeToFit"); + (self.isa.method_msgSend["setNeedsDisplay:"] || _objj_forward)(self, "setNeedsDisplay:", YES); var ___r1; } @@ -75109,10 +76353,13 @@ var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_ var container = (aCoder == null ? aCoder : (aCoder.isa.method_msgSend["decodeObjectForKey:"] || _objj_forward)(aCoder, "decodeObjectForKey:", CPTextViewContainerKey)); (container == null ? container : (container.isa.method_msgSend["setTextView:"] || _objj_forward)(container, "setTextView:", self)); self._typingAttributes = ((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["attributesAtIndex:effectiveRange:"] || _objj_forward)(___r2, "attributesAtIndex:effectiveRange:", 0, nil))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["copy"] || _objj_forward)(___r1, "copy")); + if (!self._typingAttributes) + self._typingAttributes = (CPMutableDictionary.isa.method_msgSend["dictionary"] || _objj_forward)(CPMutableDictionary, "dictionary"); if (!((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["valueForKey:"] || _objj_forward)(___r1, "valueForKey:", CPForegroundColorAttributeName))) ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(___r1, "setObject:forKey:", (CPColor.isa.method_msgSend["blackColor"] || _objj_forward)(CPColor, "blackColor"), CPForegroundColorAttributeName)); self._textColor = ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["valueForKey:"] || _objj_forward)(___r1, "valueForKey:", CPForegroundColorAttributeName)); - (self == null ? self : (self.isa.method_msgSend["setFont:"] || _objj_forward)(self, "setFont:", ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["valueForKey:"] || _objj_forward)(___r1, "valueForKey:", CPFontAttributeName)))); + var decodedFont = ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["valueForKey:"] || _objj_forward)(___r1, "valueForKey:", CPFontAttributeName)) || (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 12.0); + (self == null ? self : (self.isa.method_msgSend["setFont:"] || _objj_forward)(self, "setFont:", decodedFont)); (self == null ? self : (self.isa.method_msgSend["setString:"] || _objj_forward)(self, "setString:", ((___r1 = self._textStorage), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["string"] || _objj_forward)(___r1, "string")))); (self == null ? self : (self.isa.method_msgSend["setMaxSize:"] || _objj_forward)(self, "setMaxSize:", (aCoder == null ? aCoder : (aCoder.isa.method_msgSend["decodeSizeForKey:"] || _objj_forward)(aCoder, "decodeSizeForKey:", CPMaxSize)))); (self == null ? self : (self.isa.method_msgSend["setHorizontallyResizable:"] || _objj_forward)(self, "setHorizontallyResizable:", (aCoder == null ? aCoder : (aCoder.isa.method_msgSend["decodeBoolForKey:"] || _objj_forward)(aCoder, "decodeBoolForKey:", CPTextViewHorizontallyResizableKey)))); diff --git a/Frameworks/AppKit/CommonJS.environment/AppKit.sj b/Frameworks/AppKit/CommonJS.environment/AppKit.sj index 12214347d..ec9db6c04 100644 --- a/Frameworks/AppKit/CommonJS.environment/AppKit.sj +++ b/Frameworks/AppKit/CommonJS.environment/AppKit.sj @@ -66404,7 +66404,7 @@ CPRuleEditorNestingModeSimple = 3; objj_registerTypeDef(the_typedef); }CPRuleEditorRowTypeSimple = 0; CPRuleEditorRowTypeCompound = 1; -p;14;_CPRTFParser.jt;33053;@STATIC;1.0;I;31;Foundation/CPAttributedString.jI;23;Foundation/CPGeometry.ji;15;CPFontManager.ji;18;CPParagraphStyle.jt;32926;objj_executeFile("Foundation/CPAttributedString.j", NO);objj_executeFile("Foundation/CPGeometry.j", NO);objj_executeFile("CPFontManager.j", YES);objj_executeFile("CPParagraphStyle.j", YES);var hexTable = []; +p;14;_CPRTFParser.jt;56413;@STATIC;1.0;I;31;Foundation/CPAttributedString.jI;23;Foundation/CPGeometry.ji;15;CPTextStorage.ji;15;CPFontManager.ji;18;CPParagraphStyle.ji;24;_CPTableTextAttachment.jt;56237;objj_executeFile("Foundation/CPAttributedString.j", NO);objj_executeFile("Foundation/CPGeometry.j", NO);objj_executeFile("CPTextStorage.j", YES);objj_executeFile("CPFontManager.j", YES);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("_CPTableTextAttachment.j", YES);var hexTable = []; var cp1252Map = {0x80: 0x20AC, 0x82: 0x201A, 0x83: 0x0192, 0x84: 0x201E, 0x85: 0x2026, 0x86: 0x2020, 0x87: 0x2021, 0x88: 0x02C6, 0x89: 0x2030, 0x8A: 0x0160, 0x8B: 0x2039, 0x8C: 0x0152, 0x8E: 0x017D, 0x91: 0x2018, 0x92: 0x2019, 0x93: 0x201C, 0x94: 0x201D, 0x95: 0x2022, 0x96: 0x2013, 0x97: 0x2014, 0x98: 0x02DC, 0x99: 0x2122, 0x9A: 0x0161, 0x9B: 0x203A, 0x9C: 0x0153, 0x9E: 0x017E, 0x9F: 0x0178}; {var the_class = objj_allocateClassPair(CPObject, "_RTFAttribute"), @@ -66501,7 +66501,14 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $_RTFA ,["void"]), new objj_method(sel_getUid("addTab:type:"), function $_RTFAttribute__addTab_type_(self, _cmd, location, type) { - var tab = ((___r1 = (CPTextTab.isa.method_msgSend["alloc"] || _objj_forward)(CPTextTab, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithType:location:"] || _objj_forward)(___r1, "initWithType:location:", type, location)); + var alignment = CPLeftTextAlignment; + if (type === CPCenterTabStopType || type === CPCenterTextAlignment) + alignment = CPCenterTextAlignment; + else if (type === CPRightTabStopType || type === CPRightTextAlignment) + alignment = CPRightTextAlignment; + else if (type === CPDecimalTabStopType) + alignment = CPRightTextAlignment; + var tab = ((___r1 = (CPTextTab.isa.method_msgSend["alloc"] || _objj_forward)(CPTextTab, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithType:location:"] || _objj_forward)(___r1, "initWithType:location:", alignment, location)); if (!self._tabChanged) { ((___r1 = self.paragraph), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setTabStops:"] || _objj_forward)(___r1, "setTabStops:", [tab])); @@ -66524,6 +66531,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $_RTFA (ret == null ? ret : (ret.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(ret, "setObject:forKey:", self.fgColour, CPForegroundColorAttributeName)); if (self.bgColour) (ret == null ? ret : (ret.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(ret, "setObject:forKey:", self.bgColour, CPBackgroundColorAttributeName)); + if (self.underline) + (ret == null ? ret : (ret.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(ret, "setObject:forKey:", (CPNumber.isa.method_msgSend["numberWithInt:"] || _objj_forward)(CPNumber, "numberWithInt:", 1), CPUnderlineStyleAttributeName)); return ret; var ___r1; } @@ -66534,10 +66543,10 @@ var kRTFParserType_char = 0, kRTFParserType_dest = 1, kRTFParserType_prop = 2, kRTFParserType_spec = 3; -var kRgsymRtf = {"b": ["b", 1, false, kRTFParserType_prop, "propBold"], "ul": ["ul", 1, false, kRTFParserType_prop, "propUnderline"], "i": ["i", 1, false, kRTFParserType_prop, "propItalic"], "pgnucltr": ["pgnucltr", "pgULtr", true, kRTFParserType_prop, "propPgnFormat"], "pgnlcltr": ["pgnlcltr", "pgLLtr", true, kRTFParserType_prop, "propPgnFormat"], "qc": ["qc", "justC", true, kRTFParserType_prop, "propJust"], "ql": ["ql", "justL", true, kRTFParserType_prop, "propJust"], "qr": ["qr", "justR", true, kRTFParserType_prop, "propJust"], "qj": ["qj", "justF", true, kRTFParserType_prop, "propJust"], "paperw": ["paperw", 12240, false, kRTFParserType_prop, "propXaPage"], "paperh": ["paperh", 15480, false, kRTFParserType_prop, "propYaPage"], "margl": ["margl", 1800, false, kRTFParserType_prop, "propXaLeft"], "margr": ["margr", 1800, false, kRTFParserType_prop, "propXaRight"], "margt": ["margt", 1440, false, kRTFParserType_prop, "propYaTop"], "margb": ["margb", 1440, false, kRTFParserType_prop, "propYaBottom"], "pgnstart": ["pgnstart", 1, true, kRTFParserType_prop, "propPgnStart"], "facingp": ["facingp", 1, true, kRTFParserType_prop, "propFacingp"], "landscape": ["landscape", 1, true, kRTFParserType_prop, "propLandscape"], "par": ["par", 0, false, kRTFParserType_char, "\n"], "pard": ["pard", 0, false, kRTFParserType_prop, "propDefaultPara"], "\0x0a": ["\0x0a", 0, false, kRTFParserType_char, "\n"], "\0x0d": ["\0x0d", 0, false, kRTFParserType_char, ""], "tab": ["tab", 0, false, kRTFParserType_char, "\t"], "ldblquote": ["ldblquote", 0, false, kRTFParserType_char, '"'], "rdblquote": ["rdblquote", 0, false, kRTFParserType_char, '"'], "bin": ["bin", 0, false, kRTFParserType_spec, "ipfnBin"], "*": ["*", 0, false, kRTFParserType_spec, "ipfnDestSkip"], "'": ["'", 0, false, kRTFParserType_spec, "ipfnHex"], "author": ["author", 0, false, kRTFParserType_dest, "destSkip"], "buptim": ["buptim", 0, false, kRTFParserType_dest, "destSkip"], "colortbl": ["colortbl", 0, false, kRTFParserType_dest, "destSkip"], "comment": ["comment", 0, false, kRTFParserType_dest, "destSkip"], "creatim": ["creatim", 0, false, kRTFParserType_dest, "destSkip"], "doccomm": ["doccomm", 0, false, kRTFParserType_dest, "destSkip"], "fonttbl": ["fonttbl", 0, false, kRTFParserType_dest, "destSkip"], "footer": ["footer", 0, false, kRTFParserType_dest, "destSkip"], "footerf": ["footerf", 0, false, kRTFParserType_dest, "destSkip"], "footerl": ["footerl", 0, false, kRTFParserType_dest, "destSkip"], "footerr": ["footerr", 0, false, kRTFParserType_dest, "destSkip"], "footnote": ["footnote", 0, false, kRTFParserType_dest, "destSkip"], "ftncn": ["ftncn", 0, false, kRTFParserType_dest, "destSkip"], "ftnsep": ["ftnsep", 0, false, kRTFParserType_dest, "destSkip"], "ftnsepc": ["ftnsepc", 0, false, kRTFParserType_dest, "destSkip"], "fprq": ["fprq", 0, false, kRTFParserType_dest, "destSkip"], "rquote": ["rquote", 0, false, kRTFParserType_char, "'"], "header": ["header", 0, false, kRTFParserType_dest, "destSkip"], "headerf": ["headerf", 0, false, kRTFParserType_dest, "destSkip"], "headerl": ["headerl", 0, false, kRTFParserType_dest, "destSkip"], "headerr": ["headerr", 0, false, kRTFParserType_dest, "destSkip"], "info": ["info", 0, false, kRTFParserType_dest, "destSkip"], "keywords": ["keywords", 0, false, kRTFParserType_dest, "destSkip"], "operator": ["operator", 0, false, kRTFParserType_dest, "destSkip"], "pict": ["pict", 0, false, kRTFParserType_dest, "destSkip"], "printim": ["printim", 0, false, kRTFParserType_dest, "destSkip"], "private1": ["private1", 0, false, kRTFParserType_dest, "destSkip"], "revtim": ["revtim", 0, false, kRTFParserType_dest, "destSkip"], "rxe": ["rxe", 0, false, kRTFParserType_dest, "destSkip"], "stylesheet": ["stylesheet", 0, false, kRTFParserType_dest, "destSkip"], "subject": ["subject", 0, false, kRTFParserType_dest, "destSkip"], "tc": ["tc", 0, false, kRTFParserType_dest, "destSkip"], "title": ["title", 0, false, kRTFParserType_dest, "destSkip"], "txe": ["txe", 0, false, kRTFParserType_dest, "destSkip"], "xe": ["xe", 0, false, kRTFParserType_dest, "destSkip"], "[": ["[", 0, false, kRTFParserType_char, '['], " ": [" ", 0, false, kRTFParserType_char, ' '], "]": ["]", 0, false, kRTFParserType_char, ']'], "{": ["{", 0, false, kRTFParserType_char, '{'], "}": ["}", 0, false, kRTFParserType_char, '}'], "\\": ["\\", 0, false, kRTFParserType_char, '\\']}; +var kRgsymRtf = {"b": ["b", 1, false, kRTFParserType_prop, "propBold"], "ul": ["ul", 1, false, kRTFParserType_prop, "propUnderline"], "i": ["i", 1, false, kRTFParserType_prop, "propItalic"], "pgnucltr": ["pgnucltr", "pgULtr", true, kRTFParserType_prop, "propPgnFormat"], "pgnlcltr": ["pgnlcltr", "pgLLtr", true, kRTFParserType_prop, "propPgnFormat"], "qc": ["qc", "justC", true, kRTFParserType_prop, "propJust"], "ql": ["ql", "justL", true, kRTFParserType_prop, "propJust"], "qr": ["qr", "justR", true, kRTFParserType_prop, "propJust"], "qj": ["qj", "justF", true, kRTFParserType_prop, "propJust"], "paperw": ["paperw", 12240, false, kRTFParserType_prop, "propXaPage"], "paperh": ["paperh", 15480, false, kRTFParserType_prop, "propYaPage"], "margl": ["margl", 1800, false, kRTFParserType_prop, "propXaLeft"], "margr": ["margr", 1800, false, kRTFParserType_prop, "propXaRight"], "margt": ["margt", 1440, false, kRTFParserType_prop, "propYaTop"], "margb": ["margb", 1440, false, kRTFParserType_prop, "propYaBottom"], "pgnstart": ["pgnstart", 1, true, kRTFParserType_prop, "propPgnStart"], "facingp": ["facingp", 1, true, kRTFParserType_prop, "propFacingp"], "landscape": ["landscape", 1, true, kRTFParserType_prop, "propLandscape"], "par": ["par", 0, false, kRTFParserType_char, "\n"], "pard": ["pard", 0, false, kRTFParserType_prop, "propDefaultPara"], "\0x0a": ["\0x0a", 0, false, kRTFParserType_char, "\n"], "\0x0d": ["\0x0d", 0, false, kRTFParserType_char, ""], "tab": ["tab", 0, false, kRTFParserType_char, "\t"], "ldblquote": ["ldblquote", 0, false, kRTFParserType_char, '"'], "rdblquote": ["rdblquote", 0, false, kRTFParserType_char, '"'], "bin": ["bin", 0, false, kRTFParserType_spec, "ipfnBin"], "*": ["*", 0, false, kRTFParserType_spec, "ipfnDestSkip"], "'": ["'", 0, false, kRTFParserType_spec, "ipfnHex"], "author": ["author", 0, false, kRTFParserType_dest, "destSkip"], "buptim": ["buptim", 0, false, kRTFParserType_dest, "destSkip"], "colortbl": ["colortbl", 0, false, kRTFParserType_dest, "destSkip"], "comment": ["comment", 0, false, kRTFParserType_dest, "destSkip"], "creatim": ["creatim", 0, false, kRTFParserType_dest, "destSkip"], "doccomm": ["doccomm", 0, false, kRTFParserType_dest, "destSkip"], "fonttbl": ["fonttbl", 0, false, kRTFParserType_dest, "destSkip"], "footer": ["footer", 0, false, kRTFParserType_dest, "destSkip"], "footerf": ["footerf", 0, false, kRTFParserType_dest, "destSkip"], "footerl": ["footerl", 0, false, kRTFParserType_dest, "destSkip"], "footerr": ["footerr", 0, false, kRTFParserType_dest, "destSkip"], "footnote": ["footnote", 0, false, kRTFParserType_dest, "destSkip"], "ftncn": ["ftncn", 0, false, kRTFParserType_dest, "destSkip"], "ftnsep": ["ftnsep", 0, false, kRTFParserType_dest, "destSkip"], "ftnsepc": ["ftnsepc", 0, false, kRTFParserType_dest, "destSkip"], "fprq": ["fprq", 0, false, kRTFParserType_dest, "destSkip"], "rquote": ["rquote", 0, false, kRTFParserType_char, "'"], "header": ["header", 0, false, kRTFParserType_dest, "destSkip"], "headerf": ["headerf", 0, false, kRTFParserType_dest, "destSkip"], "headerl": ["headerl", 0, false, kRTFParserType_dest, "destSkip"], "headerr": ["headerr", 0, false, kRTFParserType_dest, "destSkip"], "info": ["info", 0, false, kRTFParserType_dest, "destSkip"], "keywords": ["keywords", 0, false, kRTFParserType_dest, "destSkip"], "operator": ["operator", 0, false, kRTFParserType_dest, "destSkip"], "pict": ["pict", 0, false, kRTFParserType_dest, "destSkip"], "printim": ["printim", 0, false, kRTFParserType_dest, "destSkip"], "private1": ["private1", 0, false, kRTFParserType_dest, "destSkip"], "revtim": ["revtim", 0, false, kRTFParserType_dest, "destSkip"], "rxe": ["rxe", 0, false, kRTFParserType_dest, "destSkip"], "stylesheet": ["stylesheet", 0, false, kRTFParserType_dest, "destSkip"], "subject": ["subject", 0, false, kRTFParserType_dest, "destSkip"], "tc": ["tc", 0, false, kRTFParserType_dest, "destSkip"], "title": ["title", 0, false, kRTFParserType_dest, "destSkip"], "txe": ["txe", 0, false, kRTFParserType_dest, "destSkip"], "xe": ["xe", 0, false, kRTFParserType_dest, "destSkip"], "[": ["[", 0, false, kRTFParserType_char, '['], " ": [" ", 0, false, kRTFParserType_char, ' '], "]": ["]", 0, false, kRTFParserType_char, ']'], "{": ["{", 0, false, kRTFParserType_char, '{'], "}": ["}", 0, false, kRTFParserType_char, '}'], "\\": ["\\", 0, false, kRTFParserType_char, '\\'], "trowd": ["trowd", 0, false, kRTFParserType_spec, "ipfnTrowd"], "cell": ["cell", 0, false, kRTFParserType_spec, "ipfnCell"], "row": ["row", 0, false, kRTFParserType_spec, "ipfnRow"], "cellx": ["cellx", 0, false, kRTFParserType_spec, "ipfnCellx"], "intbl": ["intbl", 0, false, kRTFParserType_spec, "ipfnIntbl"]}; {var the_class = objj_allocateClassPair(CPObject, "_CPRTFParser"), -meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_codePage", "CPString"), new objj_ivar("_paper", "CGSize"), new objj_ivar("_rtf", "CPString"), new objj_ivar("_curState", "unsigned"), new objj_ivar("_states", "CPArray"), new objj_ivar("_currentParseIndex", "unsigned"), new objj_ivar("_hexreturn", "BOOL"), new objj_ivar("_currentRun", "_RTFAttribute"), new objj_ivar("_result", "CPAttributedString"), new objj_ivar("_colorArray", "CPArray"), new objj_ivar("_fontArray", "CPArray"), new objj_ivar("_freename", "CPString"), new objj_ivar("_parsingFontTable", "BOOL")]);objj_registerClassPair(the_class); +meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_codePage", "CPString"), new objj_ivar("_paper", "CGSize"), new objj_ivar("_rtf", "CPString"), new objj_ivar("_curState", "unsigned"), new objj_ivar("_states", "CPArray"), new objj_ivar("_currentParseIndex", "unsigned"), new objj_ivar("_hexreturn", "BOOL"), new objj_ivar("_currentRun", "_RTFAttribute"), new objj_ivar("_result", "CPAttributedString"), new objj_ivar("_colorArray", "CPArray"), new objj_ivar("_fontArray", "CPArray"), new objj_ivar("_freename", "CPString"), new objj_ivar("_parsingFontTable", "BOOL"), new objj_ivar("_inTableActive", "BOOL"), new objj_ivar("_waitingForNextRow", "BOOL"), new objj_ivar("_tableRows", "CPMutableArray"), new objj_ivar("_currentRow", "CPMutableArray"), new objj_ivar("_currentCellText", "CPString")]);objj_registerClassPair(the_class); class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $_CPRTFParser__init(self, _cmd) { if (self = (objj_getClass("_CPRTFParser").super_class.method_dtable["init"] || _objj_forward)(self, "init")) @@ -66553,6 +66562,12 @@ class_addMethods(the_class, [new objj_method(sel_getUid("init"), function $_CPRT self._fontArray = ['Arial']; self._freename = ""; self._parsingFontTable = NO; + self._inTableActive = NO; + self._waitingForNextRow = NO; + self._tableRows = nil; + self._currentRow = nil; + self._currentCellText = ""; + self._currentRun = (_RTFAttribute.isa.method_msgSend["new"] || _objj_forward)(_RTFAttribute, "new"); } return self; } @@ -66586,7 +66601,15 @@ default: self._curState = state.curState; (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); self._currentRun = state.run; + if (!self._currentRun) + { + self._currentRun = (_RTFAttribute.isa.method_msgSend["new"] || _objj_forward)(_RTFAttribute, "new"); + } self._currentRun._range = CPMakeRange(((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["length"] || _objj_forward)(___r1, "length")), 0); + if (self._curState == 0) + { + self._parsingFontTable = NO; + } } return YES; var ___r1; @@ -66631,11 +66654,78 @@ default: self._codePage = code; self._currentParseIndex--; break; + case "ipfnTrowd": + if (self._waitingForNextRow) + { + self._waitingForNextRow = NO; + } + if (!self._inTableActive) + { + self._inTableActive = YES; + self._tableRows = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + self._currentRow = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + self._currentCellText = ""; + } + else + { + self._currentRow = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + } + return ''; + case "ipfnIntbl": + return ''; + case "ipfnCell": + if (self._inTableActive) + { + if (!self._currentRow) + self._currentRow = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + ((___r1 = self._currentRow), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addObject:"] || _objj_forward)(___r1, "addObject:", self._currentCellText)); + self._currentCellText = ""; + } + return ''; + case "ipfnRow": + if (self._inTableActive) + { + if (!self._currentRow) + self._currentRow = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addObject:"] || _objj_forward)(___r1, "addObject:", self._currentRow)); + self._waitingForNextRow = YES; + } + return ''; + case "ipfnCellx": + return ''; } return ''; + var ___r1; } -,["CPString","CPArray","CPString"]), new objj_method(sel_getUid("_flushCurrentRun"), function $_CPRTFParser___flushCurrentRun(self, _cmd) +,["CPString","CPArray","CPString"]), new objj_method(sel_getUid("_flushTableIfAny"), function $_CPRTFParser___flushTableIfAny(self, _cmd) +{ + if (self._tableRows && ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + { + (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); + var headers = ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", 0)); + var rows = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + for (var idx = 1; idx < ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); idx++) + { + (rows == null ? rows : (rows.isa.method_msgSend["addObject:"] || _objj_forward)(rows, "addObject:", ((___r1 = self._tableRows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", idx)))); + } + var attachment = ((___r1 = (_CPTableTextAttachment.isa.method_msgSend["alloc"] || _objj_forward)(_CPTableTextAttachment, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithHeaders:rows:width:"] || _objj_forward)(___r1, "initWithHeaders:rows:width:", headers, rows, 500.0)); + var tableAttrStr = (CPTextStorage.isa.method_msgSend["attributedStringWithAttachment:"] || _objj_forward)(CPTextStorage, "attributedStringWithAttachment:", attachment); + ((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(___r1, "appendAttributedString:", tableAttrStr)); + if (self._currentRun) + { + self._currentRun._range = CPMakeRange(((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["length"] || _objj_forward)(___r1, "length")), 0); + } + self._tableRows = nil; + self._currentRow = nil; + self._currentCellText = ""; + self._inTableActive = NO; + self._waitingForNextRow = NO; + } + var ___r1; +} + +,["void"]), new objj_method(sel_getUid("_flushCurrentRun"), function $_CPRTFParser___flushCurrentRun(self, _cmd) { var newOffset = 0; if (self._currentRun) @@ -66691,6 +66781,20 @@ default: self._currentRun.italic = YES; } break; + case "ul": + if (param === 0) + { + if (self._currentRun && self._currentRun.underline) + (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); + self._currentRun.underline = NO; + } + else + { + if (self._currentRun && !self._currentRun.underline) + (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); + self._currentRun.underline = YES; + } + break; case "qc": ((___r1 = self._currentRun.paragraph), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setAlignment:"] || _objj_forward)(___r1, "setAlignment:", CPCenterTextAlignment)); break; @@ -66726,7 +66830,6 @@ default: } if (sym[4] == "destSkip") { - CPLogConsole("Dest skip start : [" + sym[0] + "]"); self._curState++; } return ''; @@ -66734,6 +66837,13 @@ default: ,["CPString","CPArray"]), new objj_method(sel_getUid("_translateKeyword:parameter:fParameter:"), function $_CPRTFParser___translateKeyword_parameter_fParameter_(self, _cmd, keyword, param, fParam) { + if (self._waitingForNextRow) + { + if (keyword !== "trowd" && keyword !== "cell" && keyword !== "row" && keyword !== "intbl" && keyword !== "cellx") + { + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); + } + } if (kRgsymRtf[keyword] !== undefined) { var sym = kRgsymRtf[keyword]; @@ -66837,7 +66947,7 @@ default: ((___r1 = self._currentRun), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addTab:type:"] || _objj_forward)(___r1, "addTab:type:", location, self._currentRun._nextTabType)); break; default: - CPLogConsole("skip : " + keyword + " param: " + param); + break; } return ''; } @@ -66882,7 +66992,14 @@ default: ,["CPString","CPString","unsigned"]), new objj_method(sel_getUid("_appendPlainString:"), function $_CPRTFParser___appendPlainString_(self, _cmd, aString) { - ((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["replaceCharactersInRange:withString:"] || _objj_forward)(___r1, "replaceCharactersInRange:withString:", CPMakeRange(((___r2 = self._result), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["length"] || _objj_forward)(___r2, "length")), 0), aString)); + if (self._inTableActive) + { + self._currentCellText += aString; + } + else + { + ((___r1 = self._result), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["replaceCharactersInRange:withString:"] || _objj_forward)(___r1, "replaceCharactersInRange:withString:", CPMakeRange(((___r2 = self._result), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["length"] || _objj_forward)(___r2, "length")), 0), aString)); + } var ___r1, ___r2; } @@ -66900,6 +67017,10 @@ default: while (self._currentParseIndex < len) { tmp = rtf.charAt(++self._currentParseIndex); + if (self._waitingForNextRow && tmp !== "\\" && tmp !== " " && tmp !== "\n" && tmp !== "\r" && tmp !== "\t") + { + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); + } if (tmp !== "\\" && hex.length > 0) { (self.isa.method_msgSend["_appendPlainString:"] || _objj_forward)(self, "_appendPlainString:", String.fromCharCode(parseInt(hex, 16))); @@ -66918,22 +67039,23 @@ default: } break; case "{": + if (self._waitingForNextRow) + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); if ((self.isa.method_msgSend["pushState"] || _objj_forward)(self, "pushState")) - CPLogConsole("push"); - break; + break; case "}": + if (self._waitingForNextRow) + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); if ((self.isa.method_msgSend["popState"] || _objj_forward)(self, "popState")) - CPLogConsole("pop"); - if (self._freename) - { - CPLogConsole(self._freename); - if (self._parsingFontTable) + if (self._freename) { - self._fontArray.push(self._freename); - self._parsingFontTable = NO; + if (self._parsingFontTable) + { + self._fontArray.push(self._freename); + self._parsingFontTable = NO; + } + self._freename = ""; } - self._freename = ""; - } (self.isa.method_msgSend["_flushCurrentRun"] || _objj_forward)(self, "_flushCurrentRun"); break; case "\\": @@ -66970,18 +67092,283 @@ default: default: lastchar = 0; if (self._curState == 0) + { (self.isa.method_msgSend["_appendPlainString:"] || _objj_forward)(self, "_appendPlainString:", tmp); - else if (tmp !== ';') - self._freename += tmp; + } + else + { + if (tmp === ';') + { + if (self._parsingFontTable && self._freename) + { + var cleanFontName = self._freename.trim(); + var lastSpaceIdx = cleanFontName.lastIndexOf(' '); + if (lastSpaceIdx !== -1) + { + cleanFontName = cleanFontName.substring(lastSpaceIdx + 1); + } + self._fontArray.push(cleanFontName); + self._freename = ""; + } + } + else + { + self._freename += tmp; + } + } break; } } + (self.isa.method_msgSend["_flushTableIfAny"] || _objj_forward)(self, "_flushTableIfAny"); return self._result; } ,["CPAttributedString","CPString"])]); } -p;16;_CPRTFProducer.jt;27423;@STATIC;1.0;I;31;Foundation/CPAttributedString.ji;18;CPParagraphStyle.ji;9;CPColor.ji;12;CPGraphics.ji;15;CPFontManager.jt;27294;objj_executeFile("Foundation/CPAttributedString.j", NO);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPGraphics.j", YES);objj_executeFile("CPFontManager.j", YES);var PAPERSIZE = "PaperSize", + +{var the_class = objj_allocateClassPair(CPObject, "CPMarkdownParser"), +meta_class = the_class.isa;objj_registerClassPair(the_class); +class_addMethods(meta_class, [new objj_method(sel_getUid("attributedStringFromMarkdown:"), function $CPMarkdownParser__attributedStringFromMarkdown_(self, _cmd, markdown) +{ + if (!markdown) + { + return ((___r1 = (CPAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:"] || _objj_forward)(___r1, "initWithString:", "")); + } + var result = ((___r1 = (CPMutableAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPMutableAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:"] || _objj_forward)(___r1, "initWithString:", "")); + var lines = markdown.split(/\r?\n/); + var i = 0; + while (i < lines.length) + { + var line = lines[i]; + if ((self.isa.method_msgSend["isTableHeaderLine:"] || _objj_forward)(self, "isTableHeaderLine:", line) && i + 1 < lines.length && (self.isa.method_msgSend["isTableSeparatorLine:"] || _objj_forward)(self, "isTableSeparatorLine:", lines[i + 1])) + { + var headers = (self.isa.method_msgSend["parseTableCells:"] || _objj_forward)(self, "parseTableCells:", line); + var separatorLine = lines[i + 1]; + var rows = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + i += 2; + while (i < lines.length && (self.isa.method_msgSend["isTableRowLine:"] || _objj_forward)(self, "isTableRowLine:", lines[i])) + { + (rows == null ? rows : (rows.isa.method_msgSend["addObject:"] || _objj_forward)(rows, "addObject:", (self.isa.method_msgSend["parseTableCells:"] || _objj_forward)(self, "parseTableCells:", lines[i]))); + i++; + } + var numCols = (headers == null ? headers : (headers.isa.method_msgSend["count"] || _objj_forward)(headers, "count")); + if (numCols == 0 && (rows == null ? rows : (rows.isa.method_msgSend["count"] || _objj_forward)(rows, "count")) > 0) + { + numCols = ((___r1 = (rows == null ? rows : (rows.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(rows, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + } + var totalNaturalW = 0.0; + var colNaturalWidths = []; + var measureTextField = ((___r1 = (CPTextField.isa.method_msgSend["alloc"] || _objj_forward)(CPTextField, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, 0, 10000.0, 24.0))); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setFont:"] || _objj_forward)(measureTextField, "setFont:", (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 11.0))); + for (var c = 0; c < numCols; c++) + { + var cellW = 80.0; + if (c < headers.length) + { + var parsedText = (self.isa.method_msgSend["parseInlineMarkdown:isHeader:headerLevel:"] || _objj_forward)(self, "parseInlineMarkdown:isHeader:headerLevel:", headers[c], YES, 3); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", (parsedText == null ? parsedText : (parsedText.isa.method_msgSend["string"] || _objj_forward)(parsedText, "string")))); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["sizeToFit"] || _objj_forward)(measureTextField, "sizeToFit")); + cellW = Math.max(cellW, CGRectGetWidth((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["frame"] || _objj_forward)(measureTextField, "frame"))) + 24.0); + } + for (var r = 0; r < (rows == null ? rows : (rows.isa.method_msgSend["count"] || _objj_forward)(rows, "count")); r++) + { + var rowData = (rows == null ? rows : (rows.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(rows, "objectAtIndex:", r)); + if (c < (rowData == null ? rowData : (rowData.isa.method_msgSend["count"] || _objj_forward)(rowData, "count"))) + { + var parsedText = (self.isa.method_msgSend["parseInlineMarkdown:isHeader:headerLevel:"] || _objj_forward)(self, "parseInlineMarkdown:isHeader:headerLevel:", rowData[c], NO, 3); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", (parsedText == null ? parsedText : (parsedText.isa.method_msgSend["string"] || _objj_forward)(parsedText, "string")))); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["sizeToFit"] || _objj_forward)(measureTextField, "sizeToFit")); + cellW = Math.max(cellW, CGRectGetWidth((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["frame"] || _objj_forward)(measureTextField, "frame"))) + 24.0); + } + } + colNaturalWidths[c] = cellW; + totalNaturalW += cellW; + } + var matrixView = ((___r1 = (_CPTableTextAttachment.isa.method_msgSend["alloc"] || _objj_forward)(_CPTableTextAttachment, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithHeaders:rows:width:"] || _objj_forward)(___r1, "initWithHeaders:rows:width:", headers, rows, 500.0)); + var tableAttrStr = (CPTextStorage.isa.method_msgSend["attributedStringWithAttachment:"] || _objj_forward)(CPTextStorage, "attributedStringWithAttachment:", matrixView); + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", tableAttrStr)); + continue; + } + var isHeader = false; + var headerLevel = 0; + var headerMatch = line.match(/^(#{1,6})\s+(.*)$/); + if (headerMatch) + { + headerLevel = headerMatch[1].length; + line = headerMatch[2]; + isHeader = true; + } + var isListItem = false; + var listMatch = line.match(/^(\*|-)\s+(.*)$/); + if (listMatch) + { + line = " • " + listMatch[2]; + isListItem = true; + } + var parsedLine = (self.isa.method_msgSend["parseInlineMarkdown:isHeader:headerLevel:"] || _objj_forward)(self, "parseInlineMarkdown:isHeader:headerLevel:", line, isHeader, headerLevel); + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", parsedLine)); + if (i < lines.length - 1) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", ((___r1 = (CPAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:"] || _objj_forward)(___r1, "initWithString:", "\n")))); + } + i++; + } + return result; + var ___r1; +} + +,["CPAttributedString","CPString"]), new objj_method(sel_getUid("isTableHeaderLine:"), function $CPMarkdownParser__isTableHeaderLine_(self, _cmd, line) +{ + var trimmed = line.trim(); + return trimmed.indexOf('|') !== -1; +} + +,["BOOL","CPString"]), new objj_method(sel_getUid("isTableSeparatorLine:"), function $CPMarkdownParser__isTableSeparatorLine_(self, _cmd, line) +{ + var trimmed = line.trim(); + if (trimmed.indexOf('|') === -1) + return NO; + var stripped = trimmed.replace(/[\s|:\-]/g, ''); + return stripped.length === 0; +} + +,["BOOL","CPString"]), new objj_method(sel_getUid("isTableRowLine:"), function $CPMarkdownParser__isTableRowLine_(self, _cmd, line) +{ + var trimmed = line.trim(); + return trimmed.indexOf('|') !== -1; +} + +,["BOOL","CPString"]), new objj_method(sel_getUid("parseTableCells:"), function $CPMarkdownParser__parseTableCells_(self, _cmd, line) +{ + var parts = line.split('|'); + var cells = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + var startIdx = 0; + var endIdx = parts.length; + if (parts[0].trim() === "") + startIdx = 1; + if (parts[parts.length - 1].trim() === "") + endIdx = parts.length - 1; + for (var j = startIdx; j < endIdx; j++) + { + (cells == null ? cells : (cells.isa.method_msgSend["addObject:"] || _objj_forward)(cells, "addObject:", parts[j].trim())); + } + return cells; +} + +,["CPArray","CPString"]), new objj_method(sel_getUid("parseInlineMarkdown:isHeader:headerLevel:"), function $CPMarkdownParser__parseInlineMarkdown_isHeader_headerLevel_(self, _cmd, text, isHeader, level) +{ + var baseFontSize = 11.0; + var fontSize = baseFontSize; + var isBold = isHeader; + var isItalic = NO; + if (isHeader) + { + if (level == 1) + fontSize = 15.0; + else if (level == 2) + fontSize = 13.0; + else + fontSize = 12.0; + } + var result = ((___r1 = (CPMutableAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPMutableAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:"] || _objj_forward)(___r1, "initWithString:", "")); + var currentSegment = ""; + var i = 0; + var len = text.length; + var defaultFont = (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", fontSize); + if (isBold) + { + defaultFont = (CPFont.isa.method_msgSend["boldSystemFontOfSize:"] || _objj_forward)(CPFont, "boldSystemFontOfSize:", fontSize); + } + while (i < len) + { + if (i + 2 < len && text.substr(i, 3) === "***") + { + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + currentSegment = ""; + } + isBold = !isBold; + isItalic = !isItalic; + i += 3; + continue; + } + if (i + 1 < len && text.substr(i, 2) === "**") + { + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + currentSegment = ""; + } + isBold = !isBold; + i += 2; + continue; + } + if (text.charAt(i) === "*") + { + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + currentSegment = ""; + } + isItalic = !isItalic; + i++; + continue; + } + if (text.charAt(i) === "`") + { + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + currentSegment = ""; + } + var codeText = ""; + i++; + while (i < len && text.charAt(i) !== "`") + { + codeText += text.charAt(i); + i++; + } + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", codeText, defaultFont, NO, NO, YES))); + i++; + continue; + } + currentSegment += text.charAt(i); + i++; + } + if (currentSegment.length > 0) + { + (result == null ? result : (result.isa.method_msgSend["appendAttributedString:"] || _objj_forward)(result, "appendAttributedString:", (self.isa.method_msgSend["attributedStringWithText:font:bold:italic:code:"] || _objj_forward)(self, "attributedStringWithText:font:bold:italic:code:", currentSegment, defaultFont, isBold, isItalic, NO))); + } + return result; + var ___r1; +} + +,["CPAttributedString","CPString","BOOL","int"]), new objj_method(sel_getUid("attributedStringWithText:font:bold:italic:code:"), function $CPMarkdownParser__attributedStringWithText_font_bold_italic_code_(self, _cmd, text, baseFont, b, it, c) +{ + var fontName = (baseFont == null ? baseFont : (baseFont.isa.method_msgSend["familyName"] || _objj_forward)(baseFont, "familyName")); + var fontSize = (baseFont == null ? baseFont : (baseFont.isa.method_msgSend["size"] || _objj_forward)(baseFont, "size")); + var finalFont = baseFont; + if (c) + { + finalFont = (CPFont.isa.method_msgSend["fontWithName:size:"] || _objj_forward)(CPFont, "fontWithName:size:", "Courier", fontSize); + } + else + { + finalFont = (CPFont.isa.method_msgSend["_fontWithName:size:bold:italic:"] || _objj_forward)(CPFont, "_fontWithName:size:bold:italic:", fontName, fontSize, b, it); + } + if (!finalFont) + { + finalFont = (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", fontSize); + } + var dict = (CPDictionary.isa.method_msgSend["dictionaryWithObjectsAndKeys:"] || _objj_forward)(CPDictionary, "dictionaryWithObjectsAndKeys:", finalFont, CPFontAttributeName, (CPColor.isa.method_msgSend["blackColor"] || _objj_forward)(CPColor, "blackColor"), CPForegroundColorAttributeName); + return ((___r1 = (CPAttributedString.isa.method_msgSend["alloc"] || _objj_forward)(CPAttributedString, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithString:attributes:"] || _objj_forward)(___r1, "initWithString:attributes:", text, dict)); + var ___r1; +} + +,["CPAttributedString","CPString","CPFont","BOOL","BOOL","BOOL"])]); +} +p;16;_CPRTFProducer.jt;39041;@STATIC;1.0;I;31;Foundation/CPAttributedString.ji;18;CPParagraphStyle.ji;9;CPColor.ji;12;CPGraphics.ji;15;CPFontManager.ji;24;_CPTableTextAttachment.jt;38883;objj_executeFile("Foundation/CPAttributedString.j", NO);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPGraphics.j", YES);objj_executeFile("CPFontManager.j", YES);objj_executeFile("_CPTableTextAttachment.j", YES);var PAPERSIZE = "PaperSize", LEFTMARGIN = "LeftMargin", RIGHTMARGIN = "RightMargin", TOPMARGIN = "TopMargin", @@ -67195,8 +67582,23 @@ default: enumerator = ((___r1 = (paraStyle == null ? paraStyle : (paraStyle.isa.method_msgSend["tabStops"] || _objj_forward)(paraStyle, "tabStops"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectEnumerator"] || _objj_forward)(___r1, "objectEnumerator")); while (tab = (enumerator == null ? enumerator : (enumerator.isa.method_msgSend["nextObject"] || _objj_forward)(enumerator, "nextObject"))) { - switch((tab == null ? tab : (tab.isa.method_msgSend["tabStopType"] || _objj_forward)(tab, "tabStopType"))) { + var tabType = (tab == null ? tab : (tab.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tab, "respondsToSelector:", sel_getUid("tabStopType"))) ? (tab == null ? tab : (tab.isa.method_msgSend["tabStopType"] || _objj_forward)(tab, "tabStopType")) : nil; + if (tabType === nil && (tab == null ? tab : (tab.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tab, "respondsToSelector:", sel_getUid("alignment")))) + tabType = (tab == null ? tab : (tab.isa.method_msgSend["alignment"] || _objj_forward)(tab, "alignment")); + switch(tabType) { case CPLeftTabStopType: + case CPLeftTextAlignment: + break; + case CPRightTabStopType: + case CPRightTextAlignment: + headerString += "\\tqr"; + break; + case CPCenterTabStopType: + case CPCenterTextAlignment: + headerString += "\\tqc"; + break; + case CPDecimalTabStopType: + headerString += "\\tqdec"; break; } headerString += (CPString.isa.method_msgSend["stringWithFormat:"] || _objj_forward)(CPString, "stringWithFormat:", "\\tx%d", _points2twips((tab == null ? tab : (tab.isa.method_msgSend["location"] || _objj_forward)(tab, "location")))); @@ -67207,6 +67609,211 @@ default: ,["CPString","CPParagraphStyle"]), new objj_method(sel_getUid("runStringForString:attributes:paragraphStart:"), function $_CPRTFProducer__runStringForString_attributes_paragraphStart_(self, _cmd, substring, attributes, first) { + var unwrap = function(obj) + { + if (!obj) + return null; + if (typeof obj.respondsToSelector === "function" && ((obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("headers"))) || (obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("rows")))) || obj.headers || obj._headers || obj.rows || obj._rows) + { + return obj; + } + var unwrapped = null; + if (typeof obj.respondsToSelector === "function") + { + if ((obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("attachmentCell")))) + { + unwrapped = (obj == null ? obj : (obj.isa.method_msgSend["attachmentCell"] || _objj_forward)(obj, "attachmentCell")); + } + else if ((obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("content")))) + { + unwrapped = (obj == null ? obj : (obj.isa.method_msgSend["content"] || _objj_forward)(obj, "content")); + } + else if ((obj == null ? obj : (obj.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(obj, "respondsToSelector:", sel_getUid("view")))) + { + unwrapped = (obj == null ? obj : (obj.isa.method_msgSend["view"] || _objj_forward)(obj, "view")); + } + } + if (!unwrapped) + { + unwrapped = obj._attachmentCell || obj._content || obj._view || obj.attachmentCell || obj.content || obj.view; + } + return unwrapped ? unwrapped : obj; + }; + var tableAttachment = null; + if (typeof CPAttachmentAttributeName !== "undefined") + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPAttachmentAttributeName)); + } + if (!tableAttachment) + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", "CPAttachmentAttributeName")); + } + if (!tableAttachment) + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", "TableAttachmentAttribute")); + } + if (!tableAttachment) + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", "_CPAttachmentView")); + } + if (!tableAttachment && typeof _CPAttachmentView !== "undefined") + { + tableAttachment = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", _CPAttachmentView)); + } + tableAttachment = unwrap(tableAttachment); + if (!tableAttachment && (substring === "\uFFFC" || substring === "")) + { + var keys = (attributes == null ? attributes : (attributes.isa.method_msgSend["allKeys"] || _objj_forward)(attributes, "allKeys")), + count = (keys == null ? keys : (keys.isa.method_msgSend["count"] || _objj_forward)(keys, "count")); + for (var i = 0; i < count; i++) + { + var key = (keys == null ? keys : (keys.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(keys, "objectAtIndex:", i)), + val = unwrap((attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", key))); + if (val && (typeof val.respondsToSelector === "function" && (val == null ? val : (val.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(val, "respondsToSelector:", sel_getUid("headers"))) || val._headers || val.headers || typeof _CPTableTextAttachment !== "undefined" && (val == null ? val : (val.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(val, "isKindOfClass:", (_CPTableTextAttachment.isa.method_msgSend["class"] || _objj_forward)(_CPTableTextAttachment, "class"))))) + { + tableAttachment = val; + break; + } + } + } + if (tableAttachment) + { + var headers = null, + rows = null; + var activeView = null; + if (typeof tableAttachment.respondsToSelector === "function" && (tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tableAttachment, "respondsToSelector:", sel_getUid("view")))) + { + activeView = (tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["view"] || _objj_forward)(tableAttachment, "view")); + } + if (!activeView) + { + activeView = tableAttachment._view || tableAttachment.view; + } + if (activeView) + { + if (typeof activeView.respondsToSelector === "function") + { + if ((activeView == null ? activeView : (activeView.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(activeView, "respondsToSelector:", sel_getUid("headers")))) + { + headers = (activeView == null ? activeView : (activeView.isa.method_msgSend["headers"] || _objj_forward)(activeView, "headers")); + } + if ((activeView == null ? activeView : (activeView.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(activeView, "respondsToSelector:", sel_getUid("rows")))) + { + rows = (activeView == null ? activeView : (activeView.isa.method_msgSend["rows"] || _objj_forward)(activeView, "rows")); + } + } + if (!headers) + { + headers = activeView._headers || activeView.headers; + } + if (!rows) + { + rows = activeView._rows || activeView.rows; + } + } + if (!headers || !rows) + { + if (typeof tableAttachment.respondsToSelector === "function") + { + if ((tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tableAttachment, "respondsToSelector:", sel_getUid("headers")))) + { + headers = (tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["headers"] || _objj_forward)(tableAttachment, "headers")); + } + if ((tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(tableAttachment, "respondsToSelector:", sel_getUid("rows")))) + { + rows = (tableAttachment == null ? tableAttachment : (tableAttachment.isa.method_msgSend["rows"] || _objj_forward)(tableAttachment, "rows")); + } + } + if (!headers) + { + headers = tableAttachment._headers || tableAttachment.headers; + } + if (!rows) + { + rows = tableAttachment._rows || tableAttachment.rows; + } + } + var getCount = function(arr) + { + if (!arr) + return 0; + if (typeof arr.count === "function") + return (arr == null ? arr : (arr.isa.method_msgSend["count"] || _objj_forward)(arr, "count")); + return arr.length; + }; + var getObjectAtIndex = function(arr, idx) + { + if (!arr) + return null; + if (typeof arr.objectAtIndex === "function") + return (arr == null ? arr : (arr.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(arr, "objectAtIndex:", idx)); + return arr[idx]; + }; + var numCols = getCount(headers); + if (numCols == 0 && getCount(rows) > 0) + { + numCols = getCount(getObjectAtIndex(rows, 0)); + } + if (numCols > 0) + { + var totalWidthTwips = 10000; + var colWidthTwips = Math.floor(totalWidthTwips / numCols); + var cellBoundaries = []; + var currentBoundary = 0; + for (var i = 0; i < numCols; i++) + { + currentBoundary += colWidthTwips; + cellBoundaries.push(currentBoundary); + } + var tableRTF = ""; + var writeRow = function(rowData, isHeaderRow) + { + var rowRTF = "\\trowd\\trgaph115\\trleft0"; + for (var c = 0; c < numCols; c++) + { + rowRTF += "\\clbrdrt\\brdrs\\brdrw10\\clbrdrb\\brdrs\\brdrw10\\clbrdrl\\brdrs\\brdrw10\\clbrdrr\\brdrs\\brdrw10"; + rowRTF += "\\cellx" + cellBoundaries[c]; + } + for (var c = 0; c < numCols; c++) + { + var cellText = ""; + if (c < getCount(rowData)) + { + cellText = getObjectAtIndex(rowData, c); + } + if (cellText === null || cellText === undefined) + { + cellText = ""; + } + cellText = String(cellText); + cellText = cellText.replace(/\\/g, '\\\\'); + cellText = cellText.replace(/{/g, '\\{'); + cellText = cellText.replace(/}/g, '\\}'); + cellText = cellText.replace(/\n/g, '\\line '); + if (isHeaderRow) + { + rowRTF += "{\\intbl\\b " + cellText + "\\b0\\cell}"; + } + else + { + rowRTF += "{\\intbl " + cellText + "\\cell}"; + } + } + rowRTF += "\\row\n"; + return rowRTF; + }; + if (getCount(headers) > 0) + { + tableRTF += writeRow(headers, YES); + } + var rowCount = getCount(rows); + for (var r = 0; r < rowCount; r++) + { + tableRTF += writeRow(getObjectAtIndex(rows, r), NO); + } + return tableRTF; + } + } var result = "", headerString = "", trailerString = "", @@ -67315,7 +67922,7 @@ default: } substring = substring.replace(/\\/g, '\\\\'); substring = substring.replace(/\n/g, '\\par\n'); - substring = substring.replace(/\t/g, '\\tab'); + substring = substring.replace(/\t/g, '\\tab '); substring = substring.replace(/{/g, '\\{'); substring = substring.replace(/}/g, '\\}'); if (!first) @@ -67331,7 +67938,7 @@ default: { var nobraces; if ((headerString == null ? headerString : (headerString.isa.method_msgSend["length"] || _objj_forward)(headerString, "length"))) - nobraces = (CPString.isa.method_msgSend["stringWithFormat:"] || _objj_forward)(CPString, "stringWithFormat:", "%@ %@", headerString, substring); + nobraces = (CPString.isa.method_msgSend["stringWithFormat:"] || _objj_forward)(CPString, "stringWithFormat:", "%@ %@}", headerString, substring); else nobraces = substring; result += nobraces; @@ -67348,7 +67955,7 @@ default: length = (string == null ? string : (string.isa.method_msgSend["length"] || _objj_forward)(string, "length")), currRange = CPMakeRange(loc, 0), completeRange = CPMakeRange(0, length), - first = YES; + paragraphStart = YES; while (CPMaxRange(currRange) < CPMaxRange(completeRange)) { var attributes, @@ -67356,9 +67963,12 @@ default: runString; attributes = ((___r1 = self.text), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["attributesAtIndex:longestEffectiveRange:inRange:"] || _objj_forward)(___r1, "attributesAtIndex:longestEffectiveRange:inRange:", CPMaxRange(currRange), currRange, completeRange)); substring = (string == null ? string : (string.isa.method_msgSend["substringWithRange:"] || _objj_forward)(string, "substringWithRange:", currRange)); - runString = (self.isa.method_msgSend["runStringForString:attributes:paragraphStart:"] || _objj_forward)(self, "runStringForString:attributes:paragraphStart:", substring, attributes, YES); + runString = (self.isa.method_msgSend["runStringForString:attributes:paragraphStart:"] || _objj_forward)(self, "runStringForString:attributes:paragraphStart:", substring, attributes, paragraphStart); result += runString; - first = NO; + if (substring.length > 0 && substring.charAt(substring.length - 1) === '\n') + paragraphStart = YES; + else + paragraphStart = NO; } return result; var ___r1; @@ -67390,6 +68000,472 @@ class_addMethods(meta_class, [new objj_method(sel_getUid("produceRTF:documentAtt ,["CPString","CPAttributedString","CPDictionary"])]); } +p;24;_CPTableTextAttachment.jt;32409;@STATIC;1.0;i;8;CPView.ji;12;CPTextView.ji;13;CPTextField.jI;31;Foundation/CPAttributedString.jt;32306;objj_executeFile("CPView.j", YES);objj_executeFile("CPTextView.j", YES);objj_executeFile("CPTextField.j", YES);objj_executeFile("Foundation/CPAttributedString.j", NO); +{var the_class = objj_allocateClassPair(CPView, "_CPTableTextAttachment"), +meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_headers", "CPArray"), new objj_ivar("_rows", "CPArray"), new objj_ivar("_isResizing", "BOOL"), new objj_ivar("_isEditable", "BOOL"), new objj_ivar("_acceptsRichText", "BOOL")]);objj_registerClassPair(the_class); +class_addMethods(the_class, [new objj_method(sel_getUid("initWithHeaders:rows:"), function $_CPTableTextAttachment__initWithHeaders_rows_(self, _cmd, headers, rows) +{ + return (self.isa.method_msgSend["initWithHeaders:rows:width:isEditable:acceptsRichText:"] || _objj_forward)(self, "initWithHeaders:rows:width:isEditable:acceptsRichText:", headers, rows, 500.0, YES, YES); +} + +,["id","CPArray","CPArray"]), new objj_method(sel_getUid("initWithHeaders:rows:width:"), function $_CPTableTextAttachment__initWithHeaders_rows_width_(self, _cmd, headers, rows, totalWidth) +{ + return (self.isa.method_msgSend["initWithHeaders:rows:width:isEditable:acceptsRichText:"] || _objj_forward)(self, "initWithHeaders:rows:width:isEditable:acceptsRichText:", headers, rows, totalWidth, YES, NO); +} + +,["id","CPArray","CPArray","float"]), new objj_method(sel_getUid("initWithHeaders:rows:width:isEditable:acceptsRichText:"), function $_CPTableTextAttachment__initWithHeaders_rows_width_isEditable_acceptsRichText_(self, _cmd, headers, rows, totalWidth, isEditable, acceptsRichText) +{ + self = (objj_getClass("_CPTableTextAttachment").super_class.method_dtable["initWithFrame:"] || _objj_forward)(self, "initWithFrame:", CGRectMake(0, 0, totalWidth, 20)); + if (self) + { + self._headers = headers; + self._rows = rows; + self._isEditable = isEditable; + self._acceptsRichText = acceptsRichText; + self._isResizing = NO; + (self == null ? self : (self.isa.method_msgSend["_rebuildTableWithWidth:"] || _objj_forward)(self, "_rebuildTableWithWidth:", totalWidth)); + } + return self; +} + +,["id","CPArray","CPArray","float","BOOL","BOOL"]), new objj_method(sel_getUid("_rebuildTableWithWidth:"), function $_CPTableTextAttachment___rebuildTableWithWidth_(self, _cmd, totalWidth) +{ + var numCols = self._headers ? ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) : 0; + if (numCols == 0 && self._rows && ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + numCols = ((___r1 = ((___r2 = self._rows), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r2, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + if (self._DOMElement) + { + self._DOMElement.style.borderTop = "1px solid #e0e0e0"; + self._DOMElement.style.borderLeft = "1px solid #e0e0e0"; + self._DOMElement.style.boxSizing = "border-box"; + } + if (self._headers && ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + { + for (var c = 0; c < numCols; c++) + { + var headerText = ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", c)); + var cellView = (self.isa.method_msgSend["createCellWithText:frame:isHeader:"] || _objj_forward)(self, "createCellWithText:frame:isHeader:", headerText, CGRectMakeZero(), YES); + (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", cellView); + } + } + if (self._rows) + { + for (var r = 0; r < ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); r++) + { + var rowData = ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", r)); + for (var c = 0; c < numCols; c++) + { + var cellText = ""; + if (c < (rowData == null ? rowData : (rowData.isa.method_msgSend["count"] || _objj_forward)(rowData, "count"))) + cellText = (rowData == null ? rowData : (rowData.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(rowData, "objectAtIndex:", c)); + var cellView = (self.isa.method_msgSend["createCellWithText:frame:isHeader:"] || _objj_forward)(self, "createCellWithText:frame:isHeader:", cellText, CGRectMakeZero(), NO); + (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", cellView); + } + } + } + (self.isa.method_msgSend["resizeToWidth:"] || _objj_forward)(self, "resizeToWidth:", totalWidth); + var textView = (self.isa.method_msgSend["superview"] || _objj_forward)(self, "superview"); + if (textView && (textView == null ? textView : (textView.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(textView, "isKindOfClass:", (CPTextView == null ? CPTextView : (CPTextView.isa.method_msgSend["class"] || _objj_forward)(CPTextView, "class"))))) + { + var layoutManager = (textView == null ? textView : (textView.isa.method_msgSend["layoutManager"] || _objj_forward)(textView, "layoutManager")); + if (layoutManager) + { + var charRange = (self.isa.method_msgSend["_findCharacterRangeInLayoutManager:"] || _objj_forward)(self, "_findCharacterRangeInLayoutManager:", layoutManager); + if (charRange && charRange.location !== CPNotFound) + { + (layoutManager == null ? layoutManager : (layoutManager.isa.method_msgSend["invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:"] || _objj_forward)(layoutManager, "invalidateLayoutForCharacterRange:isSoft:actualCharacterRange:", charRange, NO, nil)); + (layoutManager == null ? layoutManager : (layoutManager.isa.method_msgSend["invalidateDisplayForGlyphRange:"] || _objj_forward)(layoutManager, "invalidateDisplayForGlyphRange:", charRange)); + (layoutManager == null ? layoutManager : (layoutManager.isa.method_msgSend["_validateLayoutAndGlyphs"] || _objj_forward)(layoutManager, "_validateLayoutAndGlyphs")); + (textView == null ? textView : (textView.isa.method_msgSend["sizeToFit"] || _objj_forward)(textView, "sizeToFit")); + } + } + } + var ___r1, ___r2; +} + +,["void","float"]), new objj_method(sel_getUid("_findCharacterRangeInLayoutManager:"), function $_CPTableTextAttachment___findCharacterRangeInLayoutManager_(self, _cmd, layoutManager) +{ + var lineFragments = layoutManager._lineFragments; + if (lineFragments) + { + var l = lineFragments.length; + for (var i = 0; i < l; i++) + { + var fragment = lineFragments[i]; + var runs = fragment._runs; + if (runs) + { + var rc = runs.length; + for (var j = 0; j < rc; j++) + { + if (runs[j].view === self) + { + return runs[j]._range; + } + } + } + } + } + return CPMakeRange(CPNotFound, 0); +} + +,["CPRange","CPLayoutManager"]), new objj_method(sel_getUid("headers"), function $_CPTableTextAttachment__headers(self, _cmd) +{ + var numCols = self._headers ? ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) : 0; + if (numCols == 0 && self._rows && ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + numCols = ((___r1 = ((___r2 = self._rows), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r2, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + if (numCols == 0) + return self._headers; + var subviews = (self.isa.method_msgSend["subviews"] || _objj_forward)(self, "subviews"); + if ((subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count")) < numCols) + return self._headers; + var currentHeaders = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + for (var c = 0; c < numCols; c++) + { + var cellView = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", c)); + var textView = (self.isa.method_msgSend["getTextViewFromCell:"] || _objj_forward)(self, "getTextViewFromCell:", cellView); + var text = ""; + if (textView) + { + text = self._acceptsRichText ? ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textStorage"] || _objj_forward)(textView, "textStorage"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["copy"] || _objj_forward)(___r1, "copy")) : (textView == null ? textView : (textView.isa.method_msgSend["string"] || _objj_forward)(textView, "string")); + } + (currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["addObject:"] || _objj_forward)(currentHeaders, "addObject:", text)); + } + self._headers = currentHeaders; + return self._headers; + var ___r1, ___r2; +} + +,["CPArray"]), new objj_method(sel_getUid("rows"), function $_CPTableTextAttachment__rows(self, _cmd) +{ + var numCols = self._headers ? ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) : 0; + if (numCols == 0 && self._rows && ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0) + numCols = ((___r1 = ((___r2 = self._rows), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r2, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + if (numCols == 0 || !self._rows) + return self._rows; + var subviews = (self.isa.method_msgSend["subviews"] || _objj_forward)(self, "subviews"); + var headerOffset = self._headers && ((___r1 = self._headers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) > 0 ? numCols : 0; + var expectedCount = headerOffset + ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")) * numCols; + if ((subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count")) < expectedCount) + return self._rows; + var currentRows = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + var cellIndex = headerOffset; + for (var r = 0; r < ((___r1 = self._rows), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); r++) + { + var rowData = (CPMutableArray.isa.method_msgSend["array"] || _objj_forward)(CPMutableArray, "array"); + for (var c = 0; c < numCols; c++) + { + var cellView = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", cellIndex++)); + var textView = (self.isa.method_msgSend["getTextViewFromCell:"] || _objj_forward)(self, "getTextViewFromCell:", cellView); + var text = ""; + if (textView) + { + text = self._acceptsRichText ? ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textStorage"] || _objj_forward)(textView, "textStorage"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["copy"] || _objj_forward)(___r1, "copy")) : (textView == null ? textView : (textView.isa.method_msgSend["string"] || _objj_forward)(textView, "string")); + } + (rowData == null ? rowData : (rowData.isa.method_msgSend["addObject:"] || _objj_forward)(rowData, "addObject:", text)); + } + (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["addObject:"] || _objj_forward)(currentRows, "addObject:", rowData)); + } + self._rows = currentRows; + return self._rows; + var ___r1, ___r2; +} + +,["CPArray"]), new objj_method(sel_getUid("viewForWidth:"), function $_CPTableTextAttachment__viewForWidth_(self, _cmd, width) +{ + (self.isa.method_msgSend["resizeToWidth:"] || _objj_forward)(self, "resizeToWidth:", width); + return self; +} + +,["CPView","float"]), new objj_method(sel_getUid("createCellWithText:frame:isHeader:"), function $_CPTableTextAttachment__createCellWithText_frame_isHeader_(self, _cmd, text, frame, isHeader) +{ + var initialWidth = frame.size.width > 0 ? frame.size.width : 120.0; + var initialHeight = frame.size.height > 0 ? frame.size.height : 28.0; + var cellContainer = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(frame.origin.x, frame.origin.y, initialWidth, initialHeight))); + (cellContainer == null ? cellContainer : (cellContainer.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(cellContainer, "setBackgroundColor:", isHeader ? (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.92, 1.0) : (CPColor.isa.method_msgSend["whiteColor"] || _objj_forward)(CPColor, "whiteColor"))); + var borderView = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, 0, initialWidth, initialHeight))); + (borderView == null ? borderView : (borderView.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(borderView, "setBackgroundColor:", (CPColor.isa.method_msgSend["clearColor"] || _objj_forward)(CPColor, "clearColor"))); + (borderView == null ? borderView : (borderView.isa.method_msgSend["setAutoresizingMask:"] || _objj_forward)(borderView, "setAutoresizingMask:", CPViewWidthSizable | CPViewHeightSizable)); + if (borderView._DOMElement) + { + borderView._DOMElement.style.borderBottom = "1px solid #e0e0e0"; + borderView._DOMElement.style.borderRight = "1px solid #e0e0e0"; + borderView._DOMElement.style.boxSizing = "border-box"; + } + (cellContainer == null ? cellContainer : (cellContainer.isa.method_msgSend["addSubview:"] || _objj_forward)(cellContainer, "addSubview:", borderView)); + var textContainer = ((___r1 = (CPTextContainer.isa.method_msgSend["alloc"] || _objj_forward)(CPTextContainer, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithContainerSize:"] || _objj_forward)(___r1, "initWithContainerSize:", CGSizeMake(initialWidth - 8, 1e7))); + var textView = ((___r1 = (CPTextView == null ? CPTextView : (CPTextView.isa.method_msgSend["alloc"] || _objj_forward)(CPTextView, "alloc"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:textContainer:"] || _objj_forward)(___r1, "initWithFrame:textContainer:", CGRectMake(4, 2, initialWidth - 8, initialHeight - 4), textContainer)); + (textView == null ? textView : (textView.isa.method_msgSend["setEditable:"] || _objj_forward)(textView, "setEditable:", self._isEditable)); + (textView == null ? textView : (textView.isa.method_msgSend["setSelectable:"] || _objj_forward)(textView, "setSelectable:", YES)); + (textView == null ? textView : (textView.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(textView, "setBackgroundColor:", (CPColor.isa.method_msgSend["clearColor"] || _objj_forward)(CPColor, "clearColor"))); + (textView == null ? textView : (textView.isa.method_msgSend["setVerticallyResizable:"] || _objj_forward)(textView, "setVerticallyResizable:", YES)); + (textView == null ? textView : (textView.isa.method_msgSend["setHorizontallyResizable:"] || _objj_forward)(textView, "setHorizontallyResizable:", NO)); + ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textContainer"] || _objj_forward)(textView, "textContainer"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setWidthTracksTextView:"] || _objj_forward)(___r1, "setWidthTracksTextView:", YES)); + (textView == null ? textView : (textView.isa.method_msgSend["setRichText:"] || _objj_forward)(textView, "setRichText:", self._acceptsRichText)); + (textView == null ? textView : (textView.isa.method_msgSend["setDelegate:"] || _objj_forward)(textView, "setDelegate:", self)); + var cellFont = isHeader ? (CPFont.isa.method_msgSend["boldSystemFontOfSize:"] || _objj_forward)(CPFont, "boldSystemFontOfSize:", 11.0) : (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 11.0); + (textView == null ? textView : (textView.isa.method_msgSend["setFont:"] || _objj_forward)(textView, "setFont:", cellFont)); + (textView == null ? textView : (textView.isa.method_msgSend["setTextColor:"] || _objj_forward)(textView, "setTextColor:", (CPColor.isa.method_msgSend["blackColor"] || _objj_forward)(CPColor, "blackColor"))); + if (text && (text == null ? text : (text.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(text, "isKindOfClass:", (CPAttributedString.isa.method_msgSend["class"] || _objj_forward)(CPAttributedString, "class")))) + { + ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textStorage"] || _objj_forward)(textView, "textStorage"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setAttributedString:"] || _objj_forward)(___r1, "setAttributedString:", text)); + } + else if (text) + { + (textView == null ? textView : (textView.isa.method_msgSend["setString:"] || _objj_forward)(textView, "setString:", String(text))); + } + else + { + (textView == null ? textView : (textView.isa.method_msgSend["setString:"] || _objj_forward)(textView, "setString:", "")); + } + (cellContainer == null ? cellContainer : (cellContainer.isa.method_msgSend["addSubview:"] || _objj_forward)(cellContainer, "addSubview:", textView)); + return cellContainer; + var ___r1; +} + +,["CPView","id","CGRect","BOOL"]), new objj_method(sel_getUid("textDidChange:"), function $_CPTableTextAttachment__textDidChange_(self, _cmd, aNotification) +{ + (self.isa.method_msgSend["resizeToWidth:"] || _objj_forward)(self, "resizeToWidth:", CGRectGetWidth((self.isa.method_msgSend["frame"] || _objj_forward)(self, "frame"))); +} + +,["void","CPNotification"]), new objj_method(sel_getUid("getTextViewFromCell:"), function $_CPTableTextAttachment__getTextViewFromCell_(self, _cmd, cellView) +{ + var subviews = (cellView == null ? cellView : (cellView.isa.method_msgSend["subviews"] || _objj_forward)(cellView, "subviews")); + for (var i = 0; i < (subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count")); i++) + { + var sub = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", i)); + if ((sub == null ? sub : (sub.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(sub, "isKindOfClass:", (CPTextView == null ? CPTextView : (CPTextView.isa.method_msgSend["class"] || _objj_forward)(CPTextView, "class"))))) + { + return sub; + } + } + return nil; +} + +,["CPTextView","CPView"]), new objj_method(sel_getUid("resizeToWidth:"), function $_CPTableTextAttachment__resizeToWidth_(self, _cmd, newWidth) +{ + if (self._isResizing) + return; + self._isResizing = YES; + var currentHeaders = (self.isa.method_msgSend["headers"] || _objj_forward)(self, "headers"); + var currentRows = (self.isa.method_msgSend["rows"] || _objj_forward)(self, "rows"); + var numCols = currentHeaders ? (currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["count"] || _objj_forward)(currentHeaders, "count")) : 0; + if (numCols == 0 && currentRows && (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["count"] || _objj_forward)(currentRows, "count")) > 0) + { + numCols = ((___r1 = (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(currentRows, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); + } + if (numCols == 0) + { + self._isResizing = NO; + return; + } + var subviews = (self.isa.method_msgSend["subviews"] || _objj_forward)(self, "subviews"); + var colNaturalWidths = []; + var colMinWidths = []; + for (var c = 0; c < numCols; c++) + { + colNaturalWidths[c] = 80.0; + colMinWidths[c] = 60.0; + } + var measureTextField = ((___r1 = (CPTextField.isa.method_msgSend["alloc"] || _objj_forward)(CPTextField, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, 0, 10000.0, 24.0))); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setFont:"] || _objj_forward)(measureTextField, "setFont:", (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 13.0))); + var measureCell = function(cellText, isHeader, colIndex) + { + var cellFont = isHeader ? (CPFont.isa.method_msgSend["boldSystemFontOfSize:"] || _objj_forward)(CPFont, "boldSystemFontOfSize:", 11.0) : (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 11.0); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setFont:"] || _objj_forward)(measureTextField, "setFont:", cellFont)); + var plainText = cellText && typeof cellText.string === "function" ? (cellText == null ? cellText : (cellText.isa.method_msgSend["string"] || _objj_forward)(cellText, "string")) : cellText || ""; + plainText = String(plainText); + if (cellText && typeof cellText.string === "function") + { + if ((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["respondsToSelector:"] || _objj_forward)(measureTextField, "respondsToSelector:", sel_getUid("setAttributedStringValue:")))) + { + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setAttributedStringValue:"] || _objj_forward)(measureTextField, "setAttributedStringValue:", cellText)); + } + else + { + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", plainText)); + } + } + else + { + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", plainText)); + } + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["sizeToFit"] || _objj_forward)(measureTextField, "sizeToFit")); + var naturalW = CGRectGetWidth((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["frame"] || _objj_forward)(measureTextField, "frame"))) + 24.0; + if (naturalW > colNaturalWidths[colIndex]) + { + colNaturalWidths[colIndex] = naturalW; + } + var words = plainText.split(/[\s\-]/); + var maxWordW = 50.0; + for (var w = 0; w < words.length; w++) + { + var word = words[w].trim(); + if (word.length === 0) + continue; + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["setStringValue:"] || _objj_forward)(measureTextField, "setStringValue:", word)); + (measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["sizeToFit"] || _objj_forward)(measureTextField, "sizeToFit")); + var wordW = CGRectGetWidth((measureTextField == null ? measureTextField : (measureTextField.isa.method_msgSend["frame"] || _objj_forward)(measureTextField, "frame"))) + 30.0; + if (wordW > maxWordW) + { + maxWordW = wordW; + } + } + if (maxWordW > colMinWidths[colIndex]) + { + colMinWidths[colIndex] = maxWordW; + } + }; + if (currentHeaders) + { + for (var c = 0; c < (currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["count"] || _objj_forward)(currentHeaders, "count")); c++) + { + measureCell((currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(currentHeaders, "objectAtIndex:", c)), YES, c); + } + } + if (currentRows) + { + for (var r = 0; r < (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["count"] || _objj_forward)(currentRows, "count")); r++) + { + var rowData = (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(currentRows, "objectAtIndex:", r)); + for (var c = 0; c < numCols; c++) + { + var cellText = ""; + if (c < (rowData == null ? rowData : (rowData.isa.method_msgSend["count"] || _objj_forward)(rowData, "count"))) + { + cellText = (rowData == null ? rowData : (rowData.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(rowData, "objectAtIndex:", c)); + } + measureCell(cellText, NO, c); + } + } + } + var totalMinWidth = 0.0; + for (var c = 0; c < numCols; c++) + { + totalMinWidth += colMinWidths[c]; + } + var colWidths = []; + if (newWidth <= totalMinWidth) + { + var remainingWidth = newWidth; + for (var c = 0; c < numCols; c++) + { + var w = Math.floor(colMinWidths[c] / totalMinWidth * newWidth); + colWidths[c] = w; + remainingWidth -= w; + } + if (numCols > 0) + colWidths[numCols - 1] += remainingWidth; + } + else + { + for (var c = 0; c < numCols; c++) + { + colWidths[c] = colMinWidths[c]; + } + var totalGrowthCapacity = 0.0; + var growthCapacities = []; + for (var c = 0; c < numCols; c++) + { + var capacity = Math.max(0.0, colNaturalWidths[c] - colMinWidths[c]); + growthCapacities[c] = capacity; + totalGrowthCapacity += capacity; + } + var extraWidth = newWidth - totalMinWidth; + var remainingExtra = extraWidth; + for (var c = 0; c < numCols; c++) + { + if (totalGrowthCapacity > 0) + { + var w = Math.floor(growthCapacities[c] / totalGrowthCapacity * extraWidth); + colWidths[c] += w; + remainingExtra -= w; + } + } + if (numCols > 0) + { + colWidths[numCols - 1] += remainingExtra; + } + } + var cellIndex = 0; + var currentY = 0; + var layoutRow = function(startIndex) + { + var maxCellHeight = 28.0; + for (var c = 0; c < numCols; c++) + { + var idx = startIndex + c; + if (idx < (subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count"))) + { + var cellView = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", idx)); + var textView = (self.isa.method_msgSend["getTextViewFromCell:"] || _objj_forward)(self, "getTextViewFromCell:", cellView); + if (textView) + { + var targetWidth = Math.max(10.0, colWidths[c] - 8); + ((___r1 = (textView == null ? textView : (textView.isa.method_msgSend["textContainer"] || _objj_forward)(textView, "textContainer"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setContainerSize:"] || _objj_forward)(___r1, "setContainerSize:", CGSizeMake(targetWidth, 1e7))); + var layoutManager = (textView == null ? textView : (textView.isa.method_msgSend["layoutManager"] || _objj_forward)(textView, "layoutManager")); + var usedRect = layoutManager ? (layoutManager == null ? layoutManager : (layoutManager.isa.method_msgSend["usedRectForTextContainer:"] || _objj_forward)(layoutManager, "usedRectForTextContainer:", (textView == null ? textView : (textView.isa.method_msgSend["textContainer"] || _objj_forward)(textView, "textContainer")))) : nil; + var wrappedHeight = (usedRect ? CGRectGetHeight(usedRect) : 0.0) + 12.0; + if (wrappedHeight > maxCellHeight) + { + maxCellHeight = wrappedHeight; + } + } + } + } + var currentX = 0; + for (var c = 0; c < numCols; c++) + { + var idx = startIndex + c; + if (idx < (subviews == null ? subviews : (subviews.isa.method_msgSend["count"] || _objj_forward)(subviews, "count"))) + { + var cellView = (subviews == null ? subviews : (subviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(subviews, "objectAtIndex:", idx)); + (cellView == null ? cellView : (cellView.isa.method_msgSend["setFrame:"] || _objj_forward)(cellView, "setFrame:", CGRectMake(currentX, currentY, colWidths[c], maxCellHeight))); + var textView = (self.isa.method_msgSend["getTextViewFromCell:"] || _objj_forward)(self, "getTextViewFromCell:", cellView); + if (textView) + { + var targetWidth = Math.max(10.0, colWidths[c] - 8); + var textY = 4.0; + var finalTextViewHeight = maxCellHeight - 8.0; + (textView == null ? textView : (textView.isa.method_msgSend["setFrame:"] || _objj_forward)(textView, "setFrame:", CGRectMake(4, textY, targetWidth, finalTextViewHeight))); + } + var cellSubviews = (cellView == null ? cellView : (cellView.isa.method_msgSend["subviews"] || _objj_forward)(cellView, "subviews")); + if ((cellSubviews == null ? cellSubviews : (cellSubviews.isa.method_msgSend["count"] || _objj_forward)(cellSubviews, "count")) > 0) + { + ((___r1 = (cellSubviews == null ? cellSubviews : (cellSubviews.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(cellSubviews, "objectAtIndex:", 0))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setFrame:"] || _objj_forward)(___r1, "setFrame:", CGRectMake(0, 0, colWidths[c], maxCellHeight))); + } + } + currentX += colWidths[c]; + } + return maxCellHeight; + var ___r1; + }; + if (currentHeaders && (currentHeaders == null ? currentHeaders : (currentHeaders.isa.method_msgSend["count"] || _objj_forward)(currentHeaders, "count")) > 0) + { + var headerHeight = layoutRow(cellIndex); + cellIndex += numCols; + currentY += headerHeight; + } + if (currentRows) + { + for (var r = 0; r < (currentRows == null ? currentRows : (currentRows.isa.method_msgSend["count"] || _objj_forward)(currentRows, "count")); r++) + { + var rowHeight = layoutRow(cellIndex); + cellIndex += numCols; + currentY += rowHeight; + } + } + var currentSize = (self.isa.method_msgSend["frame"] || _objj_forward)(self, "frame").size; + if (ABS(currentSize.width - newWidth) > 0.1 || ABS(currentSize.height - currentY) > 0.1) + { + (self.isa.method_msgSend["setFrameSize:"] || _objj_forward)(self, "setFrameSize:", CGSizeMake(newWidth, currentY)); + } + self._isResizing = NO; + var ___r1; +} + +,["void","float"])]); +} p;18;CPFontDescriptor.jt;13127;@STATIC;1.0;I;21;Foundation/CPObject.jt;13081;objj_executeFile("Foundation/CPObject.j", NO);CPFontNameAttribute = "CPFontNameAttribute"; CPFontSizeAttribute = "CPFontSizeAttribute"; CPFontTraitsAttribute = "CPFontTraitsAttribute"; @@ -68021,7 +69097,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("initWithFrame:"), funct ,["void","CPEvent"])]); } (CPFontManager == null ? CPFontManager : (CPFontManager.isa.method_msgSend["setFontPanelFactory:"] || _objj_forward)(CPFontManager, "setFontPanelFactory:", (CPFontPanel.isa.method_msgSend["class"] || _objj_forward)(CPFontPanel, "class"))); -p;17;CPLayoutManager.jt;60923;@STATIC;1.0;i;8;CPText.ji;17;CPTextContainer.ji;11;CGContext.ji;14;CPTypesetter.ji;8;CPFont.jt;60822;objj_executeFile("CPText.j", YES);objj_executeFile("CPTextContainer.j", YES);objj_executeFile("CGContext.j", YES);objj_executeFile("CPTypesetter.j", YES);objj_executeFile("CPFont.j", YES);_isNewlineCharacter = function(chr) +p;17;CPLayoutManager.jt;64655;@STATIC;1.0;i;8;CPText.ji;17;CPTextContainer.ji;11;CGContext.ji;14;CPTypesetter.ji;8;CPFont.jt;64554;objj_executeFile("CPText.j", YES);objj_executeFile("CPTextContainer.j", YES);objj_executeFile("CGContext.j", YES);objj_executeFile("CPTypesetter.j", YES);objj_executeFile("CPFont.j", YES);_isNewlineCharacter = function(chr) { return chr === '\n' || chr === '\r'; } @@ -68468,13 +69544,18 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), { var frames = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames")), len = fragment._range.length; - for (var j = 0; j < len; j++) + if (frames) { - if (CGRectContainsPoint(frames[j], point)) + var maxLen = MIN(len, frames.length); + for (var j = 0; j < maxLen; j++) { - if (partialFraction) - partialFraction[0] = (point.x - frames[j].origin.x) / frames[j].size.width; - return fragment._range.location + j; + var frame = frames[j]; + if (frame && CGRectContainsPoint(frame, point)) + { + if (partialFraction) + partialFraction[0] = (point.x - frame.origin.x) / frame.size.width; + return fragment._range.location + j; + } } } } @@ -68491,16 +69572,23 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), if (i < c - 1 && self._lineFragments[i + 1]._fragmentRect.origin.y === fragment._fragmentRect.origin.y) continue; var nlLoc = CPMaxRange(fragment._range), - lastFrame = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames"))[fragment._range.length - 1], - firstFrame = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames"))[0]; - if (_isNewlineCharacter(((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["string"] || _objj_forward)(___r2, "string"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["characterAtIndex:"] || _objj_forward)(___r1, "characterAtIndex:", nlLoc > 0 ? nlLoc - 1 : 0)))) - nlLoc--; - if (point.x > CGRectGetMaxX(lastFrame)) - return nlLoc; - else if (point.x <= CGRectGetMinX(firstFrame)) - return fragment._range.location; - else - return nlLoc; + frames = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames")); + if (frames && frames.length > 0) + { + var lastFrame = frames[frames.length - 1], + firstFrame = frames[0]; + if (lastFrame && firstFrame) + { + if (_isNewlineCharacter(((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["string"] || _objj_forward)(___r2, "string"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["characterAtIndex:"] || _objj_forward)(___r1, "characterAtIndex:", nlLoc > 0 ? nlLoc - 1 : 0)))) + nlLoc--; + if (point.x > CGRectGetMaxX(lastFrame)) + return nlLoc; + else if (point.x <= CGRectGetMinX(firstFrame)) + return fragment._range.location; + else + return nlLoc; + } + } } } } @@ -68614,7 +69702,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), if (!lineFragment) return 0.0; var index = location - lineFragment._range.location; - return lineFragment._glyphsOffsets[index]; + if (index < 0 || !lineFragment._glyphsOffsets || index >= lineFragment._glyphsOffsets.length) + return 0.0; + var offset = lineFragment._glyphsOffsets[index]; + return offset === undefined ? 0.0 : offset; } ,["double","unsigned"]), new objj_method(sel_getUid("_descentAtLocation:"), function $CPLayoutManager___descentAtLocation_(self, _cmd, location) @@ -68623,7 +69714,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), if (!lineFragment) return 0.0; var index = location - lineFragment._range.location; - return lineFragment._glyphsFrames[index]._descent; + if (index < 0 || !lineFragment._glyphsFrames || index >= lineFragment._glyphsFrames.length) + return 0.0; + var frame = lineFragment._glyphsFrames[index]; + return frame && frame._descent !== undefined ? frame._descent : 0.0; } ,["double","unsigned"]), new objj_method(sel_getUid("setLineFragmentRect:forGlyphRange:usedRect:"), function $CPLayoutManager__setLineFragmentRect_forGlyphRange_usedRect_(self, _cmd, fragmentRect, glyphRange, usedRect) @@ -68735,8 +69829,12 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), { var lineFragment = self._lineFragments[self._lineFragments.length - 1], glyphFrames = (lineFragment == null ? lineFragment : (lineFragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(lineFragment, "glyphFrames")); - if (glyphFrames.length > 0) - return CGPointCreateCopy(glyphFrames[glyphFrames.length - 1].origin); + if (glyphFrames && glyphFrames.length > 0) + { + var frame = glyphFrames[glyphFrames.length - 1]; + if (frame) + return CGPointCreateCopy(frame.origin); + } } var lineFragment = _objectWithLocationInRange(self._lineFragments, index); if (lineFragment) @@ -68744,7 +69842,14 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), if (index == lineFragment._range.location) return CGPointCreateCopy(lineFragment._location); var glyphFrames = (lineFragment == null ? lineFragment : (lineFragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(lineFragment, "glyphFrames")); - return CGPointCreateCopy(glyphFrames[index - lineFragment._range.location].origin); + var relativeIndex = index - lineFragment._range.location; + if (glyphFrames && relativeIndex >= 0 && relativeIndex < glyphFrames.length) + { + var frame = glyphFrames[relativeIndex]; + if (frame) + return CGPointCreateCopy(frame.origin); + } + return CGPointCreateCopy(lineFragment._location); } return CGPointMakeZero(); } @@ -68795,19 +69900,26 @@ class_addMethods(the_class, [new objj_method(sel_getUid("_lineFragmentFactory"), var frames = (fragment == null ? fragment : (fragment.isa.method_msgSend["glyphFrames"] || _objj_forward)(fragment, "glyphFrames")), rect = nil, len = fragment._range.length; - for (var j = 0; j < len; j++) + if (frames) { - if (CPLocationInRange(fragment._range.location + j, selectedCharRange)) + for (var j = 0; j < len; j++) { - var correctedRect = CGRectCreateCopy(frames[j]); - correctedRect.size.height -= frames[j]._descent; - correctedRect.origin.y -= frames[j]._descent; - if (!rect) - rect = CGRectCreateCopy(correctedRect); - else - rect = CGRectUnion(rect, correctedRect); - if (_isNewlineCharacter(((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["string"] || _objj_forward)(___r2, "string"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["characterAtIndex:"] || _objj_forward)(___r1, "characterAtIndex:", MAX(0, CPMaxRange(selectedCharRange) - 1))))) - rect.size.width = containerSize.width - rect.origin.x; + if (j < frames.length && CPLocationInRange(fragment._range.location + j, selectedCharRange)) + { + var frame = frames[j]; + if (frame) + { + var correctedRect = CGRectCreateCopy(frame); + correctedRect.size.height -= frame._descent; + correctedRect.origin.y -= frame._descent; + if (!rect) + rect = CGRectCreateCopy(correctedRect); + else + rect = CGRectUnion(rect, correctedRect); + if (_isNewlineCharacter(((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["string"] || _objj_forward)(___r2, "string"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["characterAtIndex:"] || _objj_forward)(___r1, "characterAtIndex:", MAX(0, CPMaxRange(selectedCharRange) - 1))))) + rect.size.width = containerSize.width - rect.origin.x; + } + } } } if (rect) @@ -68936,6 +70048,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function ,["id","CPString","CPFont","CPColor"]), new objj_method(sel_getUid("createDOMElementWithText:andFont:andColor:andBackgroundColor:andUnderline:"), function $_CPLineFragment__createDOMElementWithText_andFont_andColor_andBackgroundColor_andUnderline_(self, _cmd, aString, aFont, fgColor, bgColor, aUnderline) { + if (!aString || aString.length === 0) + return nil; return nil; } @@ -68959,15 +70073,14 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function var attributes = (textStorage == null ? textStorage : (textStorage.isa.method_msgSend["attributesAtIndex:effectiveRange:"] || _objj_forward)(textStorage, "attributesAtIndex:effectiveRange:", location, effectiveRange)); effectiveRange = attributes ? CPIntersectionRange(aRange, effectiveRange) : aRange; var string = ((___r1 = textStorage._string), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["substringWithRange:"] || _objj_forward)(___r1, "substringWithRange:", effectiveRange)), - underline = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPUnderlineStyleAttributeName)) || CPUnderlineStyleNone; + underline = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPUnderlineStyleAttributeName)) || CPUnderlineStyleNone, + paragraphStyle = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPParagraphStyleAttributeName)) || (CPParagraphStyle.isa.method_msgSend["defaultParagraphStyle"] || _objj_forward)(CPParagraphStyle, "defaultParagraphStyle"); if (string === _CPAttachmentCharacterAsString) { if (!(attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", _CPAttachmentInvisible))) { - var view = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", _CPAttachmentView)), - viewCopy = (CPKeyedUnarchiver.isa.method_msgSend["unarchiveObjectWithData:"] || _objj_forward)(CPKeyedUnarchiver, "unarchiveObjectWithData:", (CPKeyedArchiver.isa.method_msgSend["archivedDataWithRootObject:"] || _objj_forward)(CPKeyedArchiver, "archivedDataWithRootObject:", view)), - elem = viewCopy._DOMElement, - run = {_range: CPMakeRangeCopy(effectiveRange), color: nil, font: nil, elem: elem, string: nil, view: viewCopy}; + var view = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", _CPAttachmentView)); + var run = {_range: CPMakeRangeCopy(effectiveRange), color: nil, font: nil, elem: nil, string: nil, view: view, paragraphStyle: paragraphStyle}; self._runs.push(run); } } @@ -68975,9 +70088,34 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function { var color = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPForegroundColorAttributeName)), bgcolor = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPBackgroundColorAttributeName)), - font = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPFontAttributeName)) || (textStorage == null ? textStorage : (textStorage.isa.method_msgSend["font"] || _objj_forward)(textStorage, "font")) || (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 12.0), - run = {_range: CPMakeRangeCopy(effectiveRange), color: color, font: font, elem: nil, string: string, bgcolor: bgcolor}; - self._runs.push(run); + font = (attributes == null ? attributes : (attributes.isa.method_msgSend["objectForKey:"] || _objj_forward)(attributes, "objectForKey:", CPFontAttributeName)) || (textStorage == null ? textStorage : (textStorage.isa.method_msgSend["font"] || _objj_forward)(textStorage, "font")) || (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 12.0); + var currentLoc = effectiveRange.location, + strLen = string.length, + startIdx = 0; + for (var i = 0; i < strLen; i++) + { + if (string.charCodeAt(i) === 9) + { + if (i > startIdx) + { + var subString = string.substring(startIdx, i), + subRange = CPMakeRange(currentLoc + startIdx, i - startIdx), + run = {_range: subRange, color: color, font: font, elem: nil, string: subString, bgcolor: bgcolor, paragraphStyle: paragraphStyle}; + self._runs.push(run); + } + var tabRange = CPMakeRange(currentLoc + i, 1), + tabRun = {_range: tabRange, color: nil, font: nil, elem: nil, string: nil, bgcolor: nil, paragraphStyle: paragraphStyle}; + self._runs.push(tabRun); + startIdx = i + 1; + } + } + if (startIdx < strLen) + { + var subString = string.substring(startIdx, strLen), + subRange = CPMakeRange(currentLoc + startIdx, strLen - startIdx), + run = {_range: subRange, color: color, font: font, elem: nil, string: subString, bgcolor: bgcolor, paragraphStyle: paragraphStyle}; + self._runs.push(run); + } } if (!CPMaxRange(effectiveRange)) break; @@ -69035,13 +70173,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function var l = self._runs.length; for (var i = 0; i < l; i++) { + if (self._runs[i].view && self._runs[i].DOMactive) + ((___r1 = self._runs[i].view), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["removeFromSuperview"] || _objj_forward)(___r1, "removeFromSuperview")); if (self._runs[i].elem && self._runs[i].DOMactive) - { - if (self._runs[i].view) - ((___r1 = self._runs[i].view), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["removeFromSuperview"] || _objj_forward)(___r1, "removeFromSuperview")); - else - self._textContainer._textView._DOMElement.removeChild(self._runs[i].elem); - } + self._textContainer._textView._DOMElement.removeChild(self._runs[i].elem); self._runs[i].elem = nil; self._runs[i].DOMactive = NO; } @@ -69053,6 +70188,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function var runs = _objectsInRange(self._runs, aRange), c = runs.length, orig = CGPointMake(self._fragmentRect.origin.x, self._fragmentRect.origin.y); + if (self._runs.length === 0) + return; for (var i = 0; i < c; i++) { var run = runs[i]; @@ -69063,19 +70200,24 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function if (!self._glyphsFrames) continue; var loc = run._range.location - self._runs[0]._range.location; + if (loc < 0 || loc >= self._glyphsFrames.length || !self._glyphsFrames[loc] || !self._glyphsOffsets || loc >= self._glyphsOffsets.length) + continue; orig.x = self._glyphsFrames[loc].origin.x + aPoint.x; orig.y = self._glyphsFrames[loc].origin.y + aPoint.y + self._glyphsOffsets[loc]; - if (run.elem) + if (run.elem || run.view) { - run.elem.style.left = orig.x + "px"; - run.elem.style.top = orig.y + "px"; + if (run.elem) + { + run.elem.style.left = orig.x + "px"; + run.elem.style.top = orig.y + "px"; + } if (run.view) ((___r1 = run.view), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setFrameOrigin:"] || _objj_forward)(___r1, "setFrameOrigin:", orig)); if (!run.DOMactive) { if (run.view) ((___r1 = self._textContainer._textView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addSubview:"] || _objj_forward)(___r1, "addSubview:", run.view)); - else + if (run.elem) self._textContainer._textView._DOMElement.appendChild(run.elem); } run.DOMactive = YES; @@ -69108,6 +70250,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function return NO; if (newFragmentRuns[i].color !== oldFragmentRuns[i].color || newFragmentRuns[i].bgcolor !== oldFragmentRuns[i].bgcolor || newFragmentRuns[i].font !== oldFragmentRuns[i].font) return NO; + var oldStyle = oldFragmentRuns[i].paragraphStyle || (CPParagraphStyle.isa.method_msgSend["defaultParagraphStyle"] || _objj_forward)(CPParagraphStyle, "defaultParagraphStyle"), + newStyle = newFragmentRuns[i].paragraphStyle || (CPParagraphStyle.isa.method_msgSend["defaultParagraphStyle"] || _objj_forward)(CPParagraphStyle, "defaultParagraphStyle"); + if (!(oldStyle == null ? oldStyle : (oldStyle.isa.method_msgSend["isEqual:"] || _objj_forward)(oldStyle, "isEqual:", newStyle))) + return NO; } return YES; } @@ -69123,6 +70269,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("glyphFrames"), function { if (self._runs[i].view) self._runs[i].view._frame.origin.y += verticalOffset; + if (self._runs[i].elem) + self._runs[i].elem.top = self._runs[i].elem.top + verticalOffset + 'px'; self._runs[i].DOMpatched = YES; } } @@ -69562,11 +70710,11 @@ class_addMethods(the_class, [new objj_method(sel_getUid("initWithParagraphStyle: ,["id","CPZone"])]); } -p;13;CPRulerView.jt;37335;@STATIC;1.0;I;21;Foundation/CPObject.ji;8;CPView.ji;13;CPTextField.ji;9;CPColor.ji;8;CPFont.ji;8;CPMenu.ji;12;CPMenuItem.jt;37205;objj_executeFile("Foundation/CPObject.j", NO);objj_executeFile("CPView.j", YES);objj_executeFile("CPTextField.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPFont.j", YES);objj_executeFile("CPMenu.j", YES);objj_executeFile("CPMenuItem.j", YES);(CPHorizontalRuler = 0, CPVerticalRuler = 1, CPRulerOrientationHorizontal = 0, CPRulerOrientationVertical = 1); +p;13;CPRulerView.jt;44796;@STATIC;1.0;I;21;Foundation/CPObject.ji;8;CPView.ji;13;CPTextField.ji;9;CPColor.ji;8;CPFont.ji;8;CPMenu.ji;12;CPMenuItem.jt;44666;objj_executeFile("Foundation/CPObject.j", NO);objj_executeFile("CPView.j", YES);objj_executeFile("CPTextField.j", YES);objj_executeFile("CPColor.j", YES);objj_executeFile("CPFont.j", YES);objj_executeFile("CPMenu.j", YES);objj_executeFile("CPMenuItem.j", YES);(CPHorizontalRuler = 0, CPVerticalRuler = 1, CPRulerOrientationHorizontal = 0, CPRulerOrientationVertical = 1); ; {var the_class = objj_allocateClassPair(CPView, "CPRulerMarker"), -meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_rulerView", "CPRulerView"), new objj_ivar("_imageValue", "float"), new objj_ivar("_representedObject", "id"), new objj_ivar("_label", "CPTextField")]);objj_registerClassPair(the_class); +meta_class = the_class.isa;class_addIvars(the_class, [new objj_ivar("_rulerView", "CPRulerView"), new objj_ivar("_imageValue", "float"), new objj_ivar("_representedObject", "id"), new objj_ivar("_label", "CPTextField"), new objj_ivar("_customHandleView", "CPView")]);objj_registerClassPair(the_class); class_addMethods(the_class, [new objj_method(sel_getUid("rulerView"), function $CPRulerMarker__rulerView(self, _cmd) { return self._rulerView; @@ -69609,6 +70757,8 @@ class_addMethods(the_class, [new objj_method(sel_getUid("rulerView"), function $ ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setTextColor:"] || _objj_forward)(___r1, "setTextColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.2, 1.0))); ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setAlignment:"] || _objj_forward)(___r1, "setAlignment:", CPCenterTextAlignment)); (self == null ? self : (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", self._label)); + self._customHandleView = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMakeZero())); + (self == null ? self : (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", self._customHandleView)); (self == null ? self : (self.isa.method_msgSend["updateMarkerIcon"] || _objj_forward)(self, "updateMarkerIcon")); } return self; @@ -69626,34 +70776,62 @@ class_addMethods(the_class, [new objj_method(sel_getUid("rulerView"), function $ (self.isa.method_msgSend["updateMarkerIcon"] || _objj_forward)(self, "updateMarkerIcon"); } -,["void","id"]), new objj_method(sel_getUid("updateMarkerIcon"), function $CPRulerMarker__updateMarkerIcon(self, _cmd) +,["void","id"]), new objj_method(sel_getUid("setFrame:"), function $CPRulerMarker__setFrame_(self, _cmd, aFrame) { - if (((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(___r1, "isKindOfClass:", (CPTextTab == null ? CPTextTab : (CPTextTab.isa.method_msgSend["class"] || _objj_forward)(CPTextTab, "class"))))) + (objj_getClass("CPRulerMarker").super_class.method_dtable["setFrame:"] || _objj_forward)(self, "setFrame:", aFrame); + (self.isa.method_msgSend["updateMarkerIcon"] || _objj_forward)(self, "updateMarkerIcon"); +} + +,["void","CGRect"]), new objj_method(sel_getUid("updateMarkerIcon"), function $CPRulerMarker__updateMarkerIcon(self, _cmd) +{ + var isIndentMarker = self._representedObject === "CPFirstLineIndent" || self._representedObject === "CPHeadIndent"; + if (isIndentMarker) { - var align = ((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["alignment"] || _objj_forward)(___r1, "alignment")); - if (align === CPLeftTextAlignment) - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "▶")); - else if (align === CPCenterTextAlignment) - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "▼")); - else if (align === CPRightTextAlignment) - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "◀")); - } - else if (((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(___r1, "isKindOfClass:", (CPString.isa.method_msgSend["class"] || _objj_forward)(CPString, "class")))) - { - if (self._representedObject === "CPFirstLineIndent") - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⥔")); - else if (self._representedObject === "CPHeadIndent") - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⥜")); - else if (self._representedObject === "CPTailIndent") - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⥘")); + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setHidden:"] || _objj_forward)(___r1, "setHidden:", YES)); + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setHidden:"] || _objj_forward)(___r1, "setHidden:", NO)); + var frame = (self.isa.method_msgSend["bounds"] || _objj_forward)(self, "bounds"); + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setFrame:"] || _objj_forward)(___r1, "setFrame:", CGRectMake(0, 0, frame.size.width, frame.size.height))); + ((___r1 = ((___r2 = self._customHandleView), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["subviews"] || _objj_forward)(___r2, "subviews"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["makeObjectsPerformSelector:"] || _objj_forward)(___r1, "makeObjectsPerformSelector:", sel_getUid("removeFromSuperview"))); + var isFirstLine = self._representedObject === "CPFirstLineIndent"; + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(___r1, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.5, 1.0))); + var innerView = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(1.0, 1.0, frame.size.width - 2.0, frame.size.height - 2.0))); + if (isFirstLine) + (innerView == null ? innerView : (innerView.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(innerView, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.92, 1.0))); else - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⇡")); + (innerView == null ? innerView : (innerView.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(innerView, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.80, 1.0))); + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["addSubview:"] || _objj_forward)(___r1, "addSubview:", innerView)); + var gripLine = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(Math.floor(frame.size.width / 2.0) - 1.0, 2.0, 1.0, frame.size.height - 4.0))); + (gripLine == null ? gripLine : (gripLine.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(gripLine, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.6, 1.0))); + (innerView == null ? innerView : (innerView.isa.method_msgSend["addSubview:"] || _objj_forward)(innerView, "addSubview:", gripLine)); } else { - ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⇡")); + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setHidden:"] || _objj_forward)(___r1, "setHidden:", NO)); + ((___r1 = self._customHandleView), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setHidden:"] || _objj_forward)(___r1, "setHidden:", YES)); + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setFrame:"] || _objj_forward)(___r1, "setFrame:", (self.isa.method_msgSend["bounds"] || _objj_forward)(self, "bounds"))); + if (((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(___r1, "isKindOfClass:", (CPTextTab == null ? CPTextTab : (CPTextTab.isa.method_msgSend["class"] || _objj_forward)(CPTextTab, "class"))))) + { + var align = ((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["alignment"] || _objj_forward)(___r1, "alignment")); + if (align === CPLeftTextAlignment) + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "▶")); + else if (align === CPCenterTextAlignment) + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "▼")); + else if (align === CPRightTextAlignment) + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "◀")); + } + else if (((___r1 = self._representedObject), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["isKindOfClass:"] || _objj_forward)(___r1, "isKindOfClass:", (CPString.isa.method_msgSend["class"] || _objj_forward)(CPString, "class")))) + { + if (self._representedObject === "CPTailIndent") + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⥘")); + else + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⇡")); + } + else + { + ((___r1 = self._label), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setStringValue:"] || _objj_forward)(___r1, "setStringValue:", "⇡")); + } } - var ___r1; + var ___r1, ___r2; } ,["void"]), new objj_method(sel_getUid("menuForEvent:"), function $CPRulerMarker__menuForEvent_(self, _cmd, anEvent) @@ -69855,12 +71033,27 @@ class_addMethods(the_class, [new objj_method(sel_getUid("scrollView"), function if (isHorizontal) { var x = markerLocation - scrollPoint.x - 6.0, - y = rulerHeight - 11.0; - if (x < 0.0) - x = 0.0; - else if (x + 12.0 > rulerWidth) - x = rulerWidth - 12.0; - (aMarker == null ? aMarker : (aMarker.isa.method_msgSend["setFrame:"] || _objj_forward)(aMarker, "setFrame:", CGRectMake(x, y, 12.0, 12.0))); + y = rulerHeight - 11.0, + w = 12.0, + h = 12.0; + if ((aMarker == null ? aMarker : (aMarker.isa.method_msgSend["representedObject"] || _objj_forward)(aMarker, "representedObject")) === "CPFirstLineIndent") + { + y = 0.0; + h = Math.floor(rulerHeight / 2.0); + } + else if ((aMarker == null ? aMarker : (aMarker.isa.method_msgSend["representedObject"] || _objj_forward)(aMarker, "representedObject")) === "CPHeadIndent") + { + y = Math.floor(rulerHeight / 2.0); + h = rulerHeight - y - 1.0; + } + else + { + if (x < 0.0) + x = 0.0; + else if (x + 12.0 > rulerWidth) + x = rulerWidth - 12.0; + } + (aMarker == null ? aMarker : (aMarker.isa.method_msgSend["setFrame:"] || _objj_forward)(aMarker, "setFrame:", CGRectMake(x, y, w, h))); } else { @@ -69916,7 +71109,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("scrollView"), function if (newLocation < 0) newLocation = 0; ((___r1 = self._draggingMarker), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setImageValue:"] || _objj_forward)(___r1, "setImageValue:", newLocation)); - (self.isa.method_msgSend["_positionMarker:"] || _objj_forward)(self, "_positionMarker:", self._draggingMarker); + (self.isa.method_msgSend["updateRuler"] || _objj_forward)(self, "updateRuler"); var draggedOff = isHorizontal ? localPoint.y < -15 || localPoint.y > CGRectGetHeight((self.isa.method_msgSend["bounds"] || _objj_forward)(self, "bounds")) + 15 : localPoint.x < -15 || localPoint.x > CGRectGetWidth((self.isa.method_msgSend["bounds"] || _objj_forward)(self, "bounds")) + 15; if (draggedOff) { @@ -69954,6 +71147,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("scrollView"), function ((___r1 = ((___r2 = self._draggingMarker), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["label"] || _objj_forward)(___r2, "label"))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setTextColor:"] || _objj_forward)(___r1, "setTextColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.2, 1.0))); } self._draggingMarker = nil; + (self.isa.method_msgSend["updateRuler"] || _objj_forward)(self, "updateRuler"); var ___r1, ___r2; } @@ -69976,6 +71170,37 @@ class_addMethods(the_class, [new objj_method(sel_getUid("scrollView"), function var bottomBorder = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, rulerHeight - 1, rulerWidth, 1))); (bottomBorder == null ? bottomBorder : (bottomBorder.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(bottomBorder, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.75, 1.0))); (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", bottomBorder); + var firstLineMarker = nil, + headMarker = nil; + for (var i = 0; i < ((___r1 = self._markers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["count"] || _objj_forward)(___r1, "count")); i++) + { + var m = ((___r1 = self._markers), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["objectAtIndex:"] || _objj_forward)(___r1, "objectAtIndex:", i)); + if ((m == null ? m : (m.isa.method_msgSend["representedObject"] || _objj_forward)(m, "representedObject")) === "CPFirstLineIndent") + firstLineMarker = m; + else if ((m == null ? m : (m.isa.method_msgSend["representedObject"] || _objj_forward)(m, "representedObject")) === "CPHeadIndent") + headMarker = m; + } + var halfHeight = Math.floor(rulerHeight / 2.0); + if (firstLineMarker) + { + var firstLineX = (firstLineMarker == null ? firstLineMarker : (firstLineMarker.isa.method_msgSend["imageValue"] || _objj_forward)(firstLineMarker, "imageValue")) - scrollPoint.x; + if (firstLineX > 0) + { + var firstLineBg = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, 0, firstLineX, halfHeight))); + (firstLineBg == null ? firstLineBg : (firstLineBg.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(firstLineBg, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.93, 1.0))); + (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", firstLineBg); + } + } + if (headMarker) + { + var headX = (headMarker == null ? headMarker : (headMarker.isa.method_msgSend["imageValue"] || _objj_forward)(headMarker, "imageValue")) - scrollPoint.x; + if (headX > 0) + { + var headBg = ((___r1 = (CPView.isa.method_msgSend["alloc"] || _objj_forward)(CPView, "alloc")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["initWithFrame:"] || _objj_forward)(___r1, "initWithFrame:", CGRectMake(0, halfHeight, headX, rulerHeight - halfHeight - 1.0))); + (headBg == null ? headBg : (headBg.isa.method_msgSend["setBackgroundColor:"] || _objj_forward)(headBg, "setBackgroundColor:", (CPColor.isa.method_msgSend["colorWithWhite:alpha:"] || _objj_forward)(CPColor, "colorWithWhite:alpha:", 0.86, 1.0))); + (self.isa.method_msgSend["addSubview:"] || _objj_forward)(self, "addSubview:", headBg); + } + } for (var val = start; val <= end; val += 10) { if (val < 0) @@ -70546,7 +71771,7 @@ var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_ ,["void"])]); } -p;12;CPTextView.jt;211344;@STATIC;1.0;i;8;CPText.ji;14;CPPasteboard.ji;14;CPColorPanel.ji;15;CPFontManager.ji;15;CPTextStorage.ji;17;CPTextContainer.ji;17;CPLayoutManager.ji;18;CPParagraphStyle.ji;14;_CPRTFParser.ji;16;_CPRTFProducer.jt;211126;objj_executeFile("CPText.j", YES);objj_executeFile("CPPasteboard.j", YES);objj_executeFile("CPColorPanel.j", YES);objj_executeFile("CPFontManager.j", YES);objj_executeFile("CPTextStorage.j", YES);objj_executeFile("CPTextContainer.j", YES);objj_executeFile("CPLayoutManager.j", YES);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("_CPRTFParser.j", YES);objj_executeFile("_CPRTFProducer.j", YES);; +p;12;CPTextView.jt;212691;@STATIC;1.0;i;8;CPText.ji;14;CPPasteboard.ji;14;CPColorPanel.ji;15;CPFontManager.ji;15;CPTextStorage.ji;17;CPTextContainer.ji;17;CPLayoutManager.ji;18;CPParagraphStyle.ji;14;_CPRTFParser.ji;16;_CPRTFProducer.jt;212473;objj_executeFile("CPText.j", YES);objj_executeFile("CPPasteboard.j", YES);objj_executeFile("CPColorPanel.j", YES);objj_executeFile("CPFontManager.j", YES);objj_executeFile("CPTextStorage.j", YES);objj_executeFile("CPTextContainer.j", YES);objj_executeFile("CPLayoutManager.j", YES);objj_executeFile("CPParagraphStyle.j", YES);objj_executeFile("_CPRTFParser.j", YES);objj_executeFile("_CPRTFProducer.j", YES);; ; ; ; @@ -70934,6 +72159,7 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function ,["void","CPNotification"]), new objj_method(sel_getUid("superviewFrameChanged:"), function $CPTextView__superviewFrameChanged_(self, _cmd, aNotification) { self._exposedRect = nil; + (self.isa.method_msgSend["sizeToFit"] || _objj_forward)(self, "sizeToFit"); } ,["void","CPNotification"]), new objj_method(sel_getUid("viewWillMoveToSuperview:"), function $CPTextView__viewWillMoveToSuperview_(self, _cmd, aView) @@ -71677,7 +72903,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function ,["void","int","CPSelectionGranularity"]), new objj_method(sel_getUid("moveLeftAndModifySelection:"), function $CPTextView__moveLeftAndModifySelection_(self, _cmd, sender) { if ((self.isa.method_msgSend["isSelectable"] || _objj_forward)(self, "isSelectable")) + { (self.isa.method_msgSend["_extendSelectionIntoDirection:granularity:"] || _objj_forward)(self, "_extendSelectionIntoDirection:granularity:", -1, CPSelectByCharacter); + (self.isa.method_msgSend["scrollRangeToVisible:"] || _objj_forward)(self, "scrollRangeToVisible:", self._selectionRange); + } } ,["void","id"]), new objj_method(sel_getUid("moveBackward:"), function $CPTextView__moveBackward_(self, _cmd, sender) @@ -71699,7 +72928,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function ,["void","id"]), new objj_method(sel_getUid("moveLeft:"), function $CPTextView__moveLeft_(self, _cmd, sender) { if ((self.isa.method_msgSend["isSelectable"] || _objj_forward)(self, "isSelectable")) + { (self.isa.method_msgSend["_establishSelection:byExtending:"] || _objj_forward)(self, "_establishSelection:byExtending:", CPMakeRange(self._selectionRange.location - (self._selectionRange.length ? 0 : 1), 0), NO); + (self.isa.method_msgSend["scrollRangeToVisible:"] || _objj_forward)(self, "scrollRangeToVisible:", self._selectionRange); + } } ,["void","id"]), new objj_method(sel_getUid("moveToEndOfParagraph:"), function $CPTextView__moveToEndOfParagraph_(self, _cmd, sender) @@ -71924,7 +73156,10 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function ,["void","id"]), new objj_method(sel_getUid("moveRight:"), function $CPTextView__moveRight_(self, _cmd, sender) { if ((self.isa.method_msgSend["isSelectable"] || _objj_forward)(self, "isSelectable")) + { (self.isa.method_msgSend["_establishSelection:byExtending:"] || _objj_forward)(self, "_establishSelection:byExtending:", CPMakeRange(CPMaxRange(self._selectionRange) + (self._selectionRange.length ? 0 : 1), 0), NO); + (self.isa.method_msgSend["scrollRangeToVisible:"] || _objj_forward)(self, "scrollRangeToVisible:", self._selectionRange); + } } ,["void","id"]), new objj_method(sel_getUid("_deleteForRange:"), function $CPTextView___deleteForRange_(self, _cmd, changedRange) @@ -72327,9 +73562,15 @@ class_addMethods(the_class, [new objj_method(sel_getUid("allowsUndo"), function if (CPEmptyRange(aRange)) { if (aRange.location >= ((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["numberOfCharacters"] || _objj_forward)(___r1, "numberOfCharacters"))) - rect = ((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["extraLineFragmentRect"] || _objj_forward)(___r1, "extraLineFragmentRect")); + { + rect = CGRectCreateCopy(((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["extraLineFragmentRect"] || _objj_forward)(___r1, "extraLineFragmentRect"))); + rect.size.width = 1.0; + } else - rect = ((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["lineFragmentRectForGlyphAtIndex:effectiveRange:"] || _objj_forward)(___r1, "lineFragmentRectForGlyphAtIndex:effectiveRange:", aRange.location, nil)); + { + rect = CGRectCreateCopy(((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["boundingRectForGlyphRange:inTextContainer:"] || _objj_forward)(___r1, "boundingRectForGlyphRange:inTextContainer:", CPMakeRange(aRange.location, 1), self._textContainer))); + rect.size.width = 1.0; + } } else { @@ -72725,6 +73966,9 @@ class_addMethods(the_class, [new objj_method(sel_getUid("updateRuler"), function ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(___r1, "setObject:forKey:", mutableStyle, CPParagraphStyleAttributeName)); ((___r1 = (CPNotificationCenter.isa.method_msgSend["defaultCenter"] || _objj_forward)(CPNotificationCenter, "defaultCenter")), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["postNotificationName:object:"] || _objj_forward)(___r1, "postNotificationName:object:", CPTextViewDidChangeTypingAttributesNotification, self)); } + ((___r1 = self._layoutManager), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["_validateLayoutAndGlyphs"] || _objj_forward)(___r1, "_validateLayoutAndGlyphs")); + (self.isa.method_msgSend["sizeToFit"] || _objj_forward)(self, "sizeToFit"); + (self.isa.method_msgSend["setNeedsDisplay:"] || _objj_forward)(self, "setNeedsDisplay:", YES); var ___r1; } @@ -72900,10 +74144,13 @@ var meta_class = the_class.isa;class_addMethods(the_class, [new objj_method(sel_ var container = (aCoder == null ? aCoder : (aCoder.isa.method_msgSend["decodeObjectForKey:"] || _objj_forward)(aCoder, "decodeObjectForKey:", CPTextViewContainerKey)); (container == null ? container : (container.isa.method_msgSend["setTextView:"] || _objj_forward)(container, "setTextView:", self)); self._typingAttributes = ((___r1 = ((___r2 = self._textStorage), ___r2 == null ? ___r2 : (___r2.isa.method_msgSend["attributesAtIndex:effectiveRange:"] || _objj_forward)(___r2, "attributesAtIndex:effectiveRange:", 0, nil))), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["copy"] || _objj_forward)(___r1, "copy")); + if (!self._typingAttributes) + self._typingAttributes = (CPMutableDictionary.isa.method_msgSend["dictionary"] || _objj_forward)(CPMutableDictionary, "dictionary"); if (!((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["valueForKey:"] || _objj_forward)(___r1, "valueForKey:", CPForegroundColorAttributeName))) ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["setObject:forKey:"] || _objj_forward)(___r1, "setObject:forKey:", (CPColor.isa.method_msgSend["blackColor"] || _objj_forward)(CPColor, "blackColor"), CPForegroundColorAttributeName)); self._textColor = ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["valueForKey:"] || _objj_forward)(___r1, "valueForKey:", CPForegroundColorAttributeName)); - (self == null ? self : (self.isa.method_msgSend["setFont:"] || _objj_forward)(self, "setFont:", ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["valueForKey:"] || _objj_forward)(___r1, "valueForKey:", CPFontAttributeName)))); + var decodedFont = ((___r1 = self._typingAttributes), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["valueForKey:"] || _objj_forward)(___r1, "valueForKey:", CPFontAttributeName)) || (CPFont.isa.method_msgSend["systemFontOfSize:"] || _objj_forward)(CPFont, "systemFontOfSize:", 12.0); + (self == null ? self : (self.isa.method_msgSend["setFont:"] || _objj_forward)(self, "setFont:", decodedFont)); (self == null ? self : (self.isa.method_msgSend["setString:"] || _objj_forward)(self, "setString:", ((___r1 = self._textStorage), ___r1 == null ? ___r1 : (___r1.isa.method_msgSend["string"] || _objj_forward)(___r1, "string")))); (self == null ? self : (self.isa.method_msgSend["setMaxSize:"] || _objj_forward)(self, "setMaxSize:", (aCoder == null ? aCoder : (aCoder.isa.method_msgSend["decodeSizeForKey:"] || _objj_forward)(aCoder, "decodeSizeForKey:", CPMaxSize)))); (self == null ? self : (self.isa.method_msgSend["setHorizontallyResizable:"] || _objj_forward)(self, "setHorizontallyResizable:", (aCoder == null ? aCoder : (aCoder.isa.method_msgSend["decodeBoolForKey:"] || _objj_forward)(aCoder, "decodeBoolForKey:", CPTextViewHorizontallyResizableKey)))); diff --git a/Resources/CPTextView/AppController.j b/Resources/CPTextView/AppController.j index 7abb6d277..3fab7a14c 100755 --- a/Resources/CPTextView/AppController.j +++ b/Resources/CPTextView/AppController.j @@ -2,7 +2,7 @@ * AppController.j * * Manual test application for the cappuccino text system - * Copyright (C) 2014 Daniel Boehringer + * Copyright (C) 2026 Daniel Boehringer */ @import @@ -14,6 +14,8 @@ @import @import @import +@import +@import @implementation AppController : CPObject { @@ -90,6 +92,25 @@ [_textView insertText:@" "]; } +- (void)insertTable:(id)sender +{ + var headers = [@"Item Description", @"Quantity", @"Unit Price"]; + var rows = [ + [@"Cappuccino Web Framework Lic.", @"2", @"$199.00"], + [@"Objective-J Development Support", @"5", @"$150.00"], + [@"Cloud Compilation VM Server", @"1", @"$49.00"] + ]; + + var tableAttachment = [[_CPTableTextAttachment alloc] initWithHeaders:headers rows:rows width:500.0]; + + // Insert single-character atomic text attachment + var tableAttrStr = [CPTextStorage attributedStringWithAttachment:tableAttachment]; + + [_textView insertText:@"\ntable (own line)\n"]; + [_textView insertText:tableAttrStr]; + [_textView insertText:@"\nend table"]; +} + - (void)applicationDidFinishLaunching:(CPNotification)aNotification { var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], @@ -133,10 +154,18 @@ var rtfButton = [[CPButton alloc] initWithFrame:CGRectMake(currentX, 15, 150, 30)]; [rtfButton setTitle:@"RTF Round-trip ➔"]; [rtfButton setTarget:self]; - [rtfButton setAction:@selector(makeRTF:)]; + [rtfButton setAction:@selector(rtfRoundTrip:)]; [toolbarView addSubview:rtfButton]; currentX += 160; + // NEW: Markdown Converter Trigger + var mdButton = [[CPButton alloc] initWithFrame:CGRectMake(currentX, 15, 120, 30)]; + [mdButton setTitle:@"← Markdown"]; + [mdButton setTarget:self]; + [mdButton setAction:@selector(convertMarkdownToRichText:)]; + [toolbarView addSubview:mdButton]; + currentX += 130; + // Insert Attachment Trigger var attachButton = [[CPButton alloc] initWithFrame:CGRectMake(currentX, 15, 140, 30)]; [attachButton setTitle:@"Insert Attachment"]; @@ -145,6 +174,14 @@ [toolbarView addSubview:attachButton]; currentX += 150; + // Add Table Trigger + var tableButton = [[CPButton alloc] initWithFrame:CGRectMake(currentX, 15, 100, 30)]; + [tableButton setTitle:@"Add Table"]; + [tableButton setTarget:self]; + [tableButton setAction:@selector(insertTable:)]; + [toolbarView addSubview:tableButton]; + currentX += 110; + // Text Alignment Group var labelAlign = [[CPTextField alloc] initWithFrame:CGRectMake(currentX, 22, 45, 20)]; [labelAlign setStringValue:@"Align:"]; @@ -210,9 +247,10 @@ [leftLabel setAutoresizingMask:CPViewWidthSizable]; [leftContainer addSubview:leftLabel]; - _textView = [[CPTextView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([leftContainer bounds]) - 30, CGRectGetHeight([leftContainer bounds]) - 70)]; + _textView = [[CPTextView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([leftContainer bounds]) - 30, 0)]; [_textView setRichText:YES]; [_textView setBackgroundColor:[CPColor whiteColor]]; + [[_textView textContainer] setWidthTracksTextView:YES]; _scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(15, 40, CGRectGetWidth([leftContainer bounds]) - 30, CGRectGetHeight([leftContainer bounds]) - 65)]; [_scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; @@ -225,7 +263,7 @@ // Right Container: RTF Plain-Text Source and Parser Window var rightLabel = [[CPTextField alloc] initWithFrame:CGRectMake(15, 10, CGRectGetWidth([rightContainer bounds]) - 30, 20)]; - [rightLabel setStringValue:@"RTF Raw Output & Source Parser Window"]; + [rightLabel setStringValue:@"Markdown Source & RTF Source Code Window"]; [rightLabel setFont:[CPFont boldSystemFontOfSize:14]]; [rightLabel setAutoresizingMask:CPViewWidthSizable]; [rightContainer addSubview:rightLabel]; @@ -257,8 +295,6 @@ [editMenu addItemWithTitle:@"Redo" action:@selector(redo:) keyEquivalent:@"Z"]; [mainMenu setSubmenu:editMenu forItem:item]; - item = [mainMenu insertItemWithTitle:@"Format" action:nil keyEquivalent:nil atIndex:0]; - // Format Menu item = [mainMenu insertItemWithTitle:@"Format" action:nil keyEquivalent:nil atIndex:0]; var formatMenu = [[CPMenu alloc] initWithTitle:@"Format Menu"]; @@ -321,6 +357,21 @@ [_textView insertText:[[CPAttributedString alloc] initWithString:@"This paragraph has a first-line indent of 30pt, a head indent of 50pt, and a tail indent of -30pt. Check the horizontal ruler above to see how the indent markers align with this paragraph, and adjust them directly!\n" attributes:[CPDictionary dictionaryWithObject:indentParagraph forKey:CPParagraphStyleAttributeName]]]; + [_textView insertText:@"\n"]; + + // 5. Pre-populate Markdown editor with rich table sample content + [_textView2 setString:@"# Markdown Parser Output\n\n" + + "You can type markdown directly in this side panel and click **← Markdown** above to convert it!\n\n" + + "## Inline styling showcase\n\n" + + "• Combine ***bold and italic*** styles.\n" + + "• Monospaced `code elements` represent code blocks.\n\n" + + "## Data Table\n\n" + + "| Item Description | Quantity | Unit Price |\n" + + "| :--- | :---: | :---: |\n" + + "| Cappuccino Web Framework Lic. | 2 | $199.00 |\n" + + "| Objective-J Development Support | 5 | $150.00 |\n" + + "| Cloud Compilation VM Server | 1 | $49.00 |"]; + [theWindow orderFront:self]; [CPMenu setMenuBarVisible:YES]; } @@ -334,4 +385,49 @@ [_textView insertText: mystr]; } +// Action tied to the "RTF Round-trip ->" button in the demo app +- (void)rtfRoundTrip:(id)sender +{ + // 1. Retrieve the rich text storage from the editor on the left + var textStorage = [_textView textStorage]; + if (!textStorage || [textStorage length] == 0) + { + return; + } + + // 2. Serialize the CPAttributedString into an RTF string + var docAttributes = @{ @"PaperSize": CPMakeSize(612, 792) }; + var generatedRTF = [_CPRTFProducer produceRTF:textStorage documentAttributes:docAttributes]; + + // 3. Set the generated RTF string into the raw output pane on the right + [_textView2 setString:generatedRTF]; + + // 4. Parse that exact RTF text back into a new CPAttributedString + var parser = [[_CPRTFParser alloc] init]; + var roundTrippedString = [parser parseRTF:generatedRTF]; + + // Safe fallback sequence + [_textView setEditable:YES]; + [_textView setString:@""]; + [_textView insertText:roundTrippedString]; +} + +// Action tied to the "Markdown ->" button to generate rich text +- (void)convertMarkdownToRichText:(id)sender +{ + // 1. Retrieve markdown string from the right pane + var markdownInput = [_textView2 string]; + if (!markdownInput || [markdownInput length] == 0) + { + return; + } + + // 2. Parse the markdown using the updated MarkdownParser class + var parsedAttrStr = [CPMarkdownParser attributedStringFromMarkdown:markdownInput]; + + [_textView setEditable:YES]; + [_textView setString:@""]; + [_textView insertText:parsedAttrStr]; +} + @end diff --git a/Resources/recipes.txt b/Resources/recipes.txt index 953ae7d20..922e6bff3 100644 --- a/Resources/recipes.txt +++ b/Resources/recipes.txt @@ -1,146 +1,146 @@ -1781383704109|ArrayController1| -1781383704123|ArrayControllerInitialSelectionTest| -1781383704137|ArrayControllerRemovingFirstTest| -1781383704150|AttachedSheet| -1781383704164|AttachedSheet2| -1781383704177|Bindings| -1781383704191|CGCanvasContext| -1781383704204|CGPath| -1781383704217|CPAlertTest| -1781383704231|CPAnimatablePropertyContainerTest| -1781383704244|CPAnimationContextTest| -1781383704258|CPAnimationTest| -1781383704271|CPBinder-echo-bug| -1781383704285|CPBoxCibTest| -1781383704298|CPBoxTest| -1781383704312|CPBrowserTest| -1781383704325|CPButtonBarTest| -1781383704339|CPButtonKeyEquivalentDefaultTest| -1781383704352|CPButtonTest| -1781383704366|CPByteCountFormatter| -1781383704379|CPCollectionViewNibTest| -1781383704393|CPColor-CPImage-description| -1781383704406|CPColorWellBindings| -1781383704419|CPComboBoxTest| -1781383704433|CPControlPerformClickExceptionTest| -1781383704447|CPControlSize| -1781383704460|CPCursor| -1781383704474|CPDateFormatterTest| -1781383704487|CPDatePickerTest| -1781383704501|CPDictionaryControllerTest| -1781383704514|CPDocumentControllerTest| -1781383704528|CPFormatterTest| -1781383704541|CPGraphicsTest| -1781383704555|CPImageAndTextViewImageScaling| -1781383704568|CPImageViewAlignmentScaling| -1781383704582|CPImageViewTest| -1781383704595|CPImageViewbindingsTest| -1781383704609|CPLevelIndicator| -1781383704623|CPLocalizationTest| -1781383704636|CPLogTest| -1781383704649|CPMenuCALayerTest| -1781383704663|CPMenuEnabledBindingsTest| -1781383704676|CPMenuKeyEquivalents| -1781383704690|CPMenuRemoveAllTest| -1781383704703|CPMenuSubmenuPlacementConstraints| -1781383704717|CPMenuTest| -1781383704731|CPOutlineViewCibTest| -1781383704744|CPOutlineViewTest| -1781383704758|CPOutlineViewViewBasedCibTest| -1781383704771|CPPanelTest| -1781383704785|CPPlatformWindow| -1781383704798|CPPlattformWindowMinSize| -1781383704812|CPPopUpButtonBindings| -1781383704825|CPPopUpButtonTest| -1781383704839|CPPopover| -1781383704852|CPPredicateEditorCibTest| -1781383704866|CPProgressIndicator| -1781383704879|CPPropertyListSerializationTest| -1781383704892|CPRadioBindings| -1781383704906|CPRuleEditorCibTest| -1781383704919|CPRuleEditorTestI8N| -1781383704933|CPScrollView| -1781383704947|CPScrollView2| -1781383704960|CPSearchField| -1781383704973|CPSearchFieldPredicateBinding| -1781383704987|CPSegmentedControlBindings| -1781383705000|CPSegmentedControlTest| -1781383705014|CPSoundTest| -1781383705027|CPSplitViewDivider| -1781383705041|CPSplitViewTest| -1781383705054|CPStackViewTest| -1781383705068|CPStepperBindings| -1781383705081|CPStepperNibTest| -1781383705094|CPTabView2| -1781383705108|CPTabViewBindings| -1781383705121|CPTabViewNib| -1781383705135|CPTableViewGroupRows| -1781383705148|CPTextField| -1781383705162|CPTextFieldEditingStyleTest| -1781383705175|CPTextFieldHeightTest| -1781383705189|CPTextFieldMovementsTest| -1781383705202|CPTextFieldMultiline| -1781383705215|CPTextView| -1781383705229|CPTextViewCibTest| -1781383705242|CPTextViewDelegateAndNotifications| -1781383705255|CPTimeZone| -1781383705269|CPTokenFieldTest| -1781383705282|CPToolTip| -1781383705296|CPToolbarTest| -1781383705309|CPTreeControllerTest| -1781383705323|CPURLConnectionAsyncTest| -1781383705336|CPURLConnectionSynchronousTest| -1781383705349|CPUserDefaults| -1781383705363|CPUserDefaultsControllerTest| -1781383705377|CPUserNotificationTest| -1781383705390|CPViewController| -1781383705404|CPVisualEffectViewTest| -1781383705417|CPWebViewTest| -1781383705431|CPWebViewTest2| -1781383705444|CPWindowLiveResizeTest| -1781383705457|CPWindowMovableTest| -1781383705471|CPWindowResizeStyle| -1781383705484|ChildWindows| -1781383705498|CompilationTests| -1781383705511|ContinuouslyUpdatesValueBinding| -1781383705525|CopyAndPaste| -1781383705538|CrossOriginTest| -1781383705552|FF4096Test| -1781383705565|FontEnhancementTest| -1781383705578|FontMetricsExplorer| -1781383705592|KeyEquivalents| -1781383705605|KeyViewLoopTest| -1781383705619|KeyWindowInTheBackgroundActivation| -1781383705632|LayoutTest| -1781383705646|LoadTimeTest| -1781383705660|LongBindings| -1781383705673|MobileTest| -1781383705687|MultipleValueBindings| -1781383705701|NSBoxTest| -1781383705714|NSBrowserTest| -1781383705728|NewTextFieldBezel| -1781383705741|Nib2CibAlignment| -1781383705755|Nib2CibBaselineAlignementTest| -1781383705769|Nib2CibSubviewsOrderTest| -1781383705782|NibAppRemixed| -1781383705796|PatternFillTest| -1781383705809|PlatformWindows| -1781383705822|PopUpButtonEscTest| -1781383705836|ScalingTest| -1781383705849|ScalingTest2| -1781383705863|ScrollviewTheming| -1781383705876|SheetWindowOrderFrontIssue| -1781383705890|SimpleBindings2| -1781383705903|SmartFoldersDemo| -1781383705917|TableTest| -1781383705930|ThemeBrowser| -1781383705944|ThemeKitchenSink| -1781383705957|TrackingArea| -1781383705971|UndoRedoWithMenuUpdate| -1781383705984|UserlandNSTest| -1781383705998|layoutEphemeralSubviewTest| -1781383706011|loadDynamicFrameworks| -1781383706025|performKeyEquivalentTest| -1781383706039|predicateWithFormat| -1781383706052|resignFirstResponder-CPControlTextDidEndEditing| -1781383706066|sizeToFitFix| +1781630976304|ArrayController1| +1781630976318|ArrayControllerInitialSelectionTest| +1781630976331|ArrayControllerRemovingFirstTest| +1781630976345|AttachedSheet| +1781630976358|AttachedSheet2| +1781630976371|Bindings| +1781630976385|CGCanvasContext| +1781630976398|CGPath| +1781630976412|CPAlertTest| +1781630976425|CPAnimatablePropertyContainerTest| +1781630976439|CPAnimationContextTest| +1781630976452|CPAnimationTest| +1781630976466|CPBinder-echo-bug| +1781630976479|CPBoxCibTest| +1781630976493|CPBoxTest| +1781630976506|CPBrowserTest| +1781630976520|CPButtonBarTest| +1781630976533|CPButtonKeyEquivalentDefaultTest| +1781630976547|CPButtonTest| +1781630976560|CPByteCountFormatter| +1781630976574|CPCollectionViewNibTest| +1781630976587|CPColor-CPImage-description| +1781630976600|CPColorWellBindings| +1781630976614|CPComboBoxTest| +1781630976627|CPControlPerformClickExceptionTest| +1781630976640|CPControlSize| +1781630976654|CPCursor| +1781630976667|CPDateFormatterTest| +1781630976680|CPDatePickerTest| +1781630976694|CPDictionaryControllerTest| +1781630976707|CPDocumentControllerTest| +1781630976720|CPFormatterTest| +1781630976733|CPGraphicsTest| +1781630976747|CPImageAndTextViewImageScaling| +1781630976760|CPImageViewAlignmentScaling| +1781630976773|CPImageViewTest| +1781630976787|CPImageViewbindingsTest| +1781630976800|CPLevelIndicator| +1781630976813|CPLocalizationTest| +1781630976827|CPLogTest| +1781630976840|CPMenuCALayerTest| +1781630976853|CPMenuEnabledBindingsTest| +1781630976867|CPMenuKeyEquivalents| +1781630976880|CPMenuRemoveAllTest| +1781630976893|CPMenuSubmenuPlacementConstraints| +1781630976907|CPMenuTest| +1781630976920|CPOutlineViewCibTest| +1781630976933|CPOutlineViewTest| +1781630976947|CPOutlineViewViewBasedCibTest| +1781630976960|CPPanelTest| +1781630976973|CPPlatformWindow| +1781630976987|CPPlattformWindowMinSize| +1781630977000|CPPopUpButtonBindings| +1781630977013|CPPopUpButtonTest| +1781630977026|CPPopover| +1781630977040|CPPredicateEditorCibTest| +1781630977053|CPProgressIndicator| +1781630977067|CPPropertyListSerializationTest| +1781630977080|CPRadioBindings| +1781630977093|CPRuleEditorCibTest| +1781630977107|CPRuleEditorTestI8N| +1781630977120|CPScrollView| +1781630977134|CPScrollView2| +1781630977148|CPSearchField| +1781630977161|CPSearchFieldPredicateBinding| +1781630977175|CPSegmentedControlBindings| +1781630977188|CPSegmentedControlTest| +1781630977202|CPSoundTest| +1781630977215|CPSplitViewDivider| +1781630977228|CPSplitViewTest| +1781630977241|CPStackViewTest| +1781630977255|CPStepperBindings| +1781630977268|CPStepperNibTest| +1781630977281|CPTabView2| +1781630977295|CPTabViewBindings| +1781630977308|CPTabViewNib| +1781630977321|CPTableViewGroupRows| +1781630977335|CPTextField| +1781630977348|CPTextFieldEditingStyleTest| +1781630977362|CPTextFieldHeightTest| +1781630977375|CPTextFieldMovementsTest| +1781630977388|CPTextFieldMultiline| +1781630977402|CPTextView| +1781630977415|CPTextViewCibTest| +1781630977428|CPTextViewDelegateAndNotifications| +1781630977442|CPTimeZone| +1781630977455|CPTokenFieldTest| +1781630977468|CPToolTip| +1781630977482|CPToolbarTest| +1781630977495|CPTreeControllerTest| +1781630977508|CPURLConnectionAsyncTest| +1781630977522|CPURLConnectionSynchronousTest| +1781630977535|CPUserDefaults| +1781630977548|CPUserDefaultsControllerTest| +1781630977562|CPUserNotificationTest| +1781630977575|CPViewController| +1781630977589|CPVisualEffectViewTest| +1781630977602|CPWebViewTest| +1781630977615|CPWebViewTest2| +1781630977628|CPWindowLiveResizeTest| +1781630977642|CPWindowMovableTest| +1781630977655|CPWindowResizeStyle| +1781630977669|ChildWindows| +1781630977682|CompilationTests| +1781630977695|ContinuouslyUpdatesValueBinding| +1781630977709|CopyAndPaste| +1781630977723|CrossOriginTest| +1781630977737|FF4096Test| +1781630977751|FontEnhancementTest| +1781630977765|FontMetricsExplorer| +1781630977779|KeyEquivalents| +1781630977792|KeyViewLoopTest| +1781630977806|KeyWindowInTheBackgroundActivation| +1781630977820|LayoutTest| +1781630977834|LoadTimeTest| +1781630977848|LongBindings| +1781630977862|MobileTest| +1781630977876|MultipleValueBindings| +1781630977890|NSBoxTest| +1781630977903|NSBrowserTest| +1781630977916|NewTextFieldBezel| +1781630977930|Nib2CibAlignment| +1781630977943|Nib2CibBaselineAlignementTest| +1781630977957|Nib2CibSubviewsOrderTest| +1781630977970|NibAppRemixed| +1781630977983|PatternFillTest| +1781630977997|PlatformWindows| +1781630978010|PopUpButtonEscTest| +1781630978023|ScalingTest| +1781630978036|ScalingTest2| +1781630978050|ScrollviewTheming| +1781630978063|SheetWindowOrderFrontIssue| +1781630978076|SimpleBindings2| +1781630978090|SmartFoldersDemo| +1781630978104|TableTest| +1781630978118|ThemeBrowser| +1781630978132|ThemeKitchenSink| +1781630978146|TrackingArea| +1781630978160|UndoRedoWithMenuUpdate| +1781630978173|UserlandNSTest| +1781630978187|layoutEphemeralSubviewTest| +1781630978200|loadDynamicFrameworks| +1781630978213|performKeyEquivalentTest| +1781630978227|predicateWithFormat| +1781630978240|resignFirstResponder-CPControlTextDidEndEditing| +1781630978253|sizeToFitFix|