home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / ConversionScripts / TextConversion.tops < prev    next >
Encoding:
Text File  |  1996-01-23  |  9.6 KB  |  225 lines

  1. /*********** TextConversion: NSCell name change *************/
  2.  
  3. replacemethod "setTextAttributes:" with "setUpFieldEditorAttributes:"
  4.  
  5. /*********** TextConversion: monoFont *************/
  6.  
  7. replacemethod "isMonoFont" with "isRichText" {
  8.     replace "<call>" with "(!<call>)"
  9.     }
  10.     within ("<implementation>") {
  11.         replace "return <isMonoFont>;" with "return !(<isMonoFont>);"
  12.     }
  13.     
  14. replacemethod "setMonoFont:<flag>" with "setRichText:<flag>" {
  15.     replace "<flag_arg>" with "!(<flag_arg>)"
  16.     }
  17.     within ("<implementation>") {
  18.         replace "<flag_param>" with "!(<flag_param>)"
  19.     }
  20.     
  21. replace "!(YES)" with "NO"
  22.  
  23. replace "!(NO)" with "YES"
  24.  
  25. replace "!!" with ""
  26.  
  27. replace "!YES" with "NO"
  28.  
  29. replace "!NO" with "YES"
  30.     
  31. /*********** TextConversion: Text length methods *************/
  32.  
  33. replace "[<text> charLength]" with "[[<text> text] length]"
  34.  
  35. replace "[<text> textLength]" with "[[<text> text] length]"
  36.  
  37. replace "[<text> byteLength]" with "[[<text> text] cStringLength]"
  38.     warning "TextConversion: [[<text> text] cStringLength] was [<text> byteLength]. Use of 'cStringLength' to replace 'byteLength' may be wrong"
  39.     
  40. replacemethod "charLength" with same
  41.     error "TextConversion: 'charLength:' is obsolete. If you subclass Text, remove this method."
  42.  
  43. replacemethod "textLength" with same
  44.     error "TextConversion: 'textLength:' is obsolete. If you subclass Text, remove this method."
  45.  
  46. replacemethod "byteLength" with same
  47.     error "TextConversion: 'byteLength:' is obsolete. If you subclass Text, remove this method."
  48.  
  49. /*********** TextConversion: Text contents methods *************/
  50.  
  51. replace "[<text> <b method>]" with "<stream> = [<text> <b newMethodSel><b newMethodArgs>]"
  52.     error "TextConversion: <newMethodSel> (used to be <method>) returns an NSData instance (used to write contents to <steeam>). <stream> must be converted to NSData"
  53.     where ("<method>", "<newMethodSel>", "<newMethodArgs>") isOneOf {
  54.     ("writeRTFDTo:<stream>", "RTFDFromRange:", "NSMakeRange(0, [[<text> text] length])"),
  55.     ("writeRichText:<stream>", "RTFFromRange:", "NSMakeRange(0, [[<text> text] length])"),
  56.     ("writeRichText:<stream> from:<from> to:<to>", "RTFFromRange:", "NSMakeRange(<from>, (<to>) - (<from>))"),
  57.     ("writeRTFDSelectionTo:<stream>", "RTFDFromRange:", "[<text> selectedRange]")
  58.     }
  59.  
  60. replace "[<text> <b methodsel><b methodargs>]" with "<newMethodCall>"
  61.     error "TextConversion: 'replaceCharactersInRange:withRTF...' (used to be <methodsel>) takes an NSData instance as its second argument. <stream> must be converted to NSData"
  62.     where ("<methodsel>", "<methodargs>", "<newMethodCall>") isOneOf {
  63.     ("readRTFDFrom:", "<stream>", "[<text> replaceCharactersInRange:NSMakeRange(0, [[<text> text] length]) withRTFD:<stream>]"),
  64.     ("readRichText:", "<stream>", "[<text> replaceCharactersInRange:NSMakeRange(0, [[<text> text] length]) withRTF:<stream>]"),
  65.     ("replaceSelWithRTFD:", "<stream>", "[<text> replaceCharactersInRange:[<text> selectedRange] withRTFD:<stream>]"),
  66.     ("replaceSelWithRichText:", "<stream>", "[<text> replaceCharactersInRange:[<text> selectedRange] withRTF:<stream>]")
  67.     }
  68.  
  69. replace "[<text> readText:<stream>]" with "[<text> setString:<stream>]"
  70.     error "TextConversion: 'setString:' used to be 'readText' takes an NSString instance (used to take NXStream) ; <stream> must be converted to NSString"
  71.  
  72. replacemethod "<sel>" with same
  73.     error "TextConversion: <sel> is obsolete"
  74.     where "<sel>" isOneOf {
  75.     "writeRTFDTo:",
  76.     "writeRichText:",
  77.     "writeRichText:from:to:",
  78.     "readRTFDFrom:",
  79.     "readRichText:",
  80.     "readRichText:atPosition:",
  81.     "readText:",
  82.     "replaceSelWithRTFD:",
  83.     "replaceSelWithRichText:",
  84.     "writeRTFDSelectionTo:",
  85.     "writeRichText:forRun:atPosition:emitDefaultRichText:"
  86.     }
  87.  
  88. /*********** TextConversion: selected range methods *************/
  89.  
  90. replace "[<text> setSelectionStart:<t startLoc> end:<endLoc>]" with "[<text> setSelectedRange:NSMakeRange(<t startLoc>, <endLoc> - (<t startLoc>))]"
  91.  
  92. replace "[<text> setSelectionStart:<startLoc> end:<endLoc>]" with "[<text> setSelectedRange:NSMakeRange(<startLoc>, <endLoc> - (<startLoc>))]"
  93.     warning "TextConversion: Please make sure that executing <startLoc> twice has no bad side effects."
  94.  
  95. replace "[<text> getSelectionStart:<startLoc> end:<endLoc>]" with same
  96.     warning "TextConversion: If sent to a NSText, please replace with range = [<text> selectedRange]; start is range.location, end is NSMaxRange(range);"
  97.  
  98. /*********** TextConversion: delegate methods *************/
  99.  
  100. replacemethod "<old>" with "<new>" {
  101.     replace "<call>" with "(!<call>)"
  102.     }
  103.     within ("<implementation>") {
  104.         replace "return <retval>;" with "return !(<retval>);"
  105.     }
  106.     where ("<old>", "<new>") isOneOf {
  107.     ("textWillChange:" , "textShouldBeginEditing:"),
  108.     ("textWillEnd:" , "textShouldEndEditing:"),
  109.     }
  110.     
  111. /*********** TextConversion: name changes *************/
  112.  
  113. replacemethod "<old>" with "<new>" 
  114.     where ("<old>", "<new>") isOneOf {
  115.     ("alignSelCenter:", "alignCenter:"),
  116.     ("alignSelLeft:", "alignLeft:"),
  117.     ("alignSelRight:", "alignRight:"),
  118.     ("calcParagraphStyle::", "paragraphStyleForFont:alignment:"),
  119.     ("defaultParaStyle", "defaultParagraphStyle"),
  120.     ("getSel::", "getSelectionStart:end:"), 
  121.     ("initFrame:text:alignment:", "initWithFrame:text:alignment:"),
  122.     ("isFontPanelEnabled", "usesFontPanel"),
  123.     ("isHorizResizeable", "isHorizontallyResizable"),
  124.     ("isVertResizable", "isVerticallyResizable"),
  125.     ("resizeText::", "resizeTextWithOldBounds:maxRect:"), 
  126.     ("setFont:paraStyle:", "setFont:paragraphStyle:"),
  127.     ("setFontPanelEnabled:", "setUsesFontPanel:")
  128.     ("setHorizResizable:", "setHorizontallyResizable:"),
  129.     ("setParaStyle:", "setParagraphStyle:"),
  130.     ("setSel::", "setSelectionStart:end:"), 
  131.     ("setSelFont:paraStyle:", "setSelFont:paragraphStyle:"),
  132.     ("setText:", "setString:"),
  133.     ("setVertResizable:", "setVerticallyResizable:"),
  134.     }
  135.  
  136. /*********** TextConversion: default font *************/
  137.  
  138. replace "[<isKindOf(NSText) text> getDefaultFont]" with "[NSCStringText defaultFont]"
  139.  
  140. replace "= [<isKindOf(NSText) text> setDefaultFont:<font>];" with same
  141.     error "TextConversion: 'setDefaultFont' now returns void"
  142.     
  143. replace "[<isKindOf(NSText) text> setDefaultFont:<font>]" with "[NSCStringText setDefaultFont:<font>]"
  144.  
  145.  
  146. /*********** TextConversion: opening and saving *************/
  147.  
  148. replacemethod "<old>" with "<new>" {
  149.     replace "<flag_arg>" with "YES"
  150.     }
  151.     where ("<old>", "<new>") isOneOf {
  152.     ("openRTFDFrom:","readRTFDFromFile:"),
  153.     ("saveRTFDTo:saveRTFDTo:saveRTFDTo:","writeRTFDToFile:atomically:<flag>")
  154.     }
  155.  
  156. replace "([<text> readRTFDFromFile:<file>] == NSRTFDErrorNone)" with "([<text> readRTFDFromFile:<file>])"
  157.  
  158. replace "([<text> readRTFDFromFile:<file>] != NSRTFDErrorNone)" with "(![<text> readRTFDFromFile:<file>])"
  159.  
  160. replace "([<text> readRTFDFromFile:<file> atomically:<flag>] == NSRTFDErrorNone)" with "([<text> readRTFDFromFile:<file> atomically:<flag>])"
  161.  
  162. replace "([<text> writeRTFDToFile:<file> atomically:<flag>] != NSRTFDErrorNone)" with "(![<text> writeRTFDToFile:<file> atomically:<flag>])"
  163.  
  164. /*********** TextConversion: obsolete methods *************/
  165.  
  166. replacemethod "<sel>" with same
  167.     error "TextConversion: <sel> is obsolete"
  168.     where "<sel>" isOneOf {
  169.     "replaceSelWithView:",
  170.     "locationOfView:",
  171.     "offsetFromPosition:",
  172.     "positionFromOffset:"
  173.     }
  174.  
  175. replacemethod "getSubstring:<buf> start:<start> length:<length>" with "substringFromRange:<range>" {
  176.     replace "<rettype>" with "(NSString *)"
  177.     replace "<call>" with "<buf_arg> = [<call> cString]"
  178.     replace "<range_type>" with "(NSRange)"
  179.     replace "<range_param>" with "range"
  180.     replace "<range_arg>" with "NSMakeRange(<start_arg>, <length_arg>)"
  181.     }
  182.     within ("<implementation>") {
  183.     replace "<start_param>" with "range.location"
  184.     replace "<length_param>" with "range.length"
  185.     }
  186.     warning "TextConversion: 'substringFromRange:' used to be 'getSubstring:start:length:'; make sure the range is valid."
  187.  
  188. /*********** TextConversion: other streams *************/
  189.  
  190. replacemethod "readRichText:forView:" with same
  191.     error "TextConversion: 'readRichText:forView:' takes an NSString instance as its first argument (used to take NXStream)"
  192.     
  193. replacemethod "writeRichText:<stream>forView:<view>" with "richTextForView:<view>" {
  194.     replace "<rettype>" with "(NSString *)"
  195.     replace "<call>" with "<stream_arg> = <call>"
  196.     }
  197.     error "TextConversion: 'richTextForView:' (used to be 'writeRichText:forView') now returns the rich text as an NSString instance (used to write to an NXStream)"
  198.     
  199.  
  200. /*********** TextConversion: word tables *************/
  201.  
  202. replace    "NXWriteWordTable(<stream>, <b args>)" with "<stream> = NSDataWithWordTable(<b args>)"
  203.     error "TextConversion: NSDataWithWordTable() (used to be NXWriteWordTable()) returns an NSData instance (used to receive NSStream: <stream>)"
  204.     
  205. replace    "NXReadWordTable(<b args>)" with "NSReadWordTable(<b args>)"
  206.     error "TextConversion: NSReadWordTable() (used to be NXReadWordTable()) takes an NSData instance for its second argument (used to take NSStream)"
  207.  
  208. /*********** TextConversion: string cleanup *************/
  209.  
  210. replace "[NSString stringWithCString:[NSString stringWithCString:<aString>]]" with "[NSString stringWithCString:<aString>]"
  211.  
  212. replace "[[NSString stringWithCString:<aString>] cString]" with "<aString>"
  213.  
  214. replace "[[<aString> cString] cString]" with "[<aString> cString]"
  215.  
  216. replace "[NSString stringWithCString:[<aString> cString]]" with "<aString>"
  217.  
  218. replace "[NSString stringWithCString:@<string stringconst>]" with "@<string stringconst>"
  219.  
  220. replace "[NSString stringWithCString:<string stringconst>]" with "@<string stringconst>"
  221.  
  222. replace "[<aString> cString] = [<anotherString> cString]" with "<aString> = <anotherString>"
  223. replace "[@<string stringconst> cString]" with "<string stringconst>"
  224.  
  225.