'From Squeak3.1alpha of 28 February 2001 [latest update: #4143] on 8 June 2001 at 12:56:34 am'! "Change Set: chgListDiffs-sw Date: 8 June 2001 Author: Scott Wallace For change-list browsers and versions browsers, stop offering various irrelevant code-viewing options (byteCodes, tiles, etc.), but *do* offer diffs and prettyDiffs, and make the right thing happen in both kinds of browsers when prettyDiffs are in effect (neither had been working right.) If the optional button pane is showing for either kind of browser, offer checkbox toggles for both kinds of diffs."! !CodeHolder methodsFor: 'diffs' stamp: 'sw 6/8/2001 00:37'! prettyDiffButton "Return a checkbox that lets the user decide whether prettyDiffs should be shown or not" | outerButton aButton | outerButton _ AlignmentMorph newRow. outerButton wrapCentering: #center; cellPositioning: #leftCenter. outerButton color: Color transparent. outerButton hResizing: #shrinkWrap; vResizing: #shrinkWrap. outerButton addMorph: (aButton _ UpdatingThreePhaseButtonMorph checkBox). aButton target: self; actionSelector: #togglePrettyDiffing; getSelector: #showingPrettyDiffs. outerButton addMorphBack: (StringMorph contents: 'prettyDiffs') lock. (self isKindOf: VersionsBrowser) ifTrue: [outerButton setBalloonText: 'If checked, then pretty-printed code differences from the previous version, if any, will be shown.'] ifFalse: [outerButton setBalloonText: 'If checked, then pretty-printed code differences between the file-based method and the in-memory version, if any, will be shown.']. ^ outerButton ! ! !CodeHolder methodsFor: 'misc' stamp: 'sw 6/7/2001 21:53'! okayToAccept "Answer whether it is okay to accept the receiver's input" self showingDocumentation ifTrue: [self inform: 'Sorry, for the moment you can only submit changes here when you are showing source. Later, you will be able to edit the isolated comment here and save it back, but only if YOU implement it!!.'. ^ false]. (#(showDiffs prettyDiffs) includes: contentsSymbol) ifFalse: [^ true]. ^ SelectionMenu confirm: 'Caution!! You are "showing diffs" here, so there is a danger that some of the text in the code pane is contaminated by the "diff" display' trueChoice: 'accept anyway -- I''ll take my chances' falseChoice: 'um, let me reconsider' ! ! !ChangeList methodsFor: 'menu actions' stamp: 'sw 6/8/2001 00:55'! optionalButtonRow "Answer a row of buttons to occur in a tool pane" | aRow aButton | aRow _ AlignmentMorph newRow. aRow hResizing: #spaceFill. aRow clipSubmorphs: true. aRow addTransparentSpacerOfSize: (5@0). aRow wrapCentering: #center; cellPositioning: #leftCenter. self changeListButtonSpecs do: [:triplet | aButton _ PluggableButtonMorph on: self getState: nil action: triplet second. aButton hResizing: #spaceFill; vResizing: #spaceFill; useRoundedCorners; label: triplet first asString; askBeforeChanging: true; onColor: Color transparent offColor: Color transparent. aRow addMorphBack: aButton. aRow addTransparentSpacerOfSize: (3 @ 0). aButton setBalloonText: triplet third. ]. aRow addMorphBack: self diffButton. aRow addMorphBack: self prettyDiffButton. ^ aRow! ! !ChangeList methodsFor: 'viewing access' stamp: 'sw 6/8/2001 00:42'! contents "Answer the contents string, obeying diffing directives if needed" ^ (#(showDiffs prettyDiffs) includes: contentsSymbol) ifFalse: [self undiffedContents] ifTrue: [self showsVersions ifTrue: [self diffedVersionContents] ifFalse: [self contentsDiffedFromCurrent]]! ! !ChangeList methodsFor: 'viewing access' stamp: 'sw 6/7/2001 21:45'! contentsSymbolQuints "Answer a list of quintuplets representing information on the alternative views available in the code pane first element: the contentsSymbol used second element: the selector to call when this item is chosen. third element: the selector to call to obtain the wording of the menu item. fourth element: the wording to represent this view fifth element: balloon help A hypen indicates a need for a seperator line in a menu of such choices" ^ #( (source togglePlainSource showingPlainSourceString 'source' 'the textual source code as writen') (showDiffs toggleDiffing showingDiffsString 'showDiffs' 'the textual source diffed from its prior version') (prettyDiffs togglePrettyDiffing showingPrettyDiffsString 'prettyDiffs' 'formatted textual source diffed from formatted form of prior version'))! ! !ChangeList methodsFor: 'viewing access' stamp: 'sw 6/7/2001 23:54'! diffedVersionContents "Answer diffed version contents, maybe pretty maybe not" | change class earlier later | (listIndex = 0 or: [changeList size < listIndex]) ifTrue: [^ '']. change _ changeList at: listIndex. later _ change text. class _ change methodClass. (listIndex == changeList size or: [class == nil]) ifTrue: [^ later]. earlier _ (changeList at: listIndex + 1) text. ^ TextDiffBuilder buildDisplayPatchFrom: earlier to: later inClass: class prettyDiffs: self showingPrettyDiffs! ! !Utilities class methodsFor: 'miscellaneous' stamp: 'sw 6/8/2001 00:25'! methodDiffFor: aString class: aClass selector: aSelector prettyDiffs: prettyDiffBoolean. "Return a string comprising a source-code diff between an existing method and the source-code in aString. DO prettyDiff if prettyDiffBoolean is true." ^ (aClass notNil and: [aClass includesSelector: aSelector]) ifTrue: [TextDiffBuilder buildDisplayPatchFrom: (aClass sourceCodeAt: aSelector) to: aString inClass: aClass prettyDiffs: prettyDiffBoolean] ifFalse: [aString copy]! !