'From Squeak3.2gamma of 22 April 2002 [latest update: #4827] on 24 April 2002 at 5:04:44 pm'! "Change Set: changesFileBrowsing-hk Date: 24 April 2002 Author: Hunter Kelly Adds methods to allow browsing of .changes files in a fashion similar to the 'recently logged changes' menu item from the changes menu. Adds an item in FileLists if the file ends in .changes. Useful for cherry-picking from the changes files when working with different images."! !ChangeList class methodsFor: 'public access' stamp: 'HK 4/18/2002 15:02'! browseRecent: charCount "ChangeList browseRecent: 5000" "Opens a changeList on the end of the changes log file" ^ self browseRecent: charCount on: (SourceFiles at: 2) ! ! !ChangeList class methodsFor: 'public access' stamp: 'HK 4/18/2002 15:02'! browseRecent: charCount on: origChangesFile "Opens a changeList on the end of the specified changes log file" | changeList end changesFile | changesFile _ origChangesFile readOnlyCopy. end _ changesFile size. Cursor read showWhile: [changeList _ self new scanFile: changesFile from: (0 max: end - charCount) to: end]. changesFile close. self open: changeList name: 'Recent changes' multiSelect: true! ! !ChangeList class methodsFor: 'public access' stamp: 'HK 4/24/2002 16:55'! browseRecentLog "ChangeList browseRecentLog" "Prompt with a menu of how far back to go to browse the current image's changes log file" ^ self browseRecentLogOn: (SourceFiles at: 2) startingFrom: Smalltalk lastQuitLogPosition! ! !ChangeList class methodsFor: 'public access' stamp: 'HK 4/24/2002 16:50'! browseRecentLogOn: origChangesFile "figure out where the last snapshot or quit was, then browse the recent entries." | end done block pos chunk changesFile positions prevBlock | changesFile _ origChangesFile readOnlyCopy. positions _ SortedCollection new. end _ changesFile size. prevBlock _ end. block _ end - 1024 max: 0. done _ false. [done or: [positions size > 0]] whileFalse: [changesFile position: block. "ignore first fragment" changesFile nextChunk. [changesFile position < prevBlock] whileTrue: [pos _ changesFile position. chunk _ changesFile nextChunk. ((chunk indexOfSubCollection: '----SNAPSHOT----' startingAt: 1) = 1 or: [(chunk indexOfSubCollection: '----QUIT----' startingAt: 1) = 1]) ifTrue: [positions add: pos]]. block = 0 ifTrue: [done _ true] ifFalse: [prevBlock _ block. block _ block - 1024 max: 0]]. changesFile close. positions isEmpty ifTrue: [self inform: 'File ' , changesFile name , ' doesnt appear to be a changes file'] ifFalse: [self browseRecentLogOn: origChangesFile startingFrom: positions last]! ! !ChangeList class methodsFor: 'public access' stamp: 'HK 4/24/2002 16:52'! browseRecentLogOn: origChangesFile startingFrom: initialPos "Prompt with a menu of how far back to go when browsing a changes file." | end banners positions pos chunk i changesFile | changesFile _ origChangesFile readOnlyCopy. banners _ OrderedCollection new. positions _ OrderedCollection new. end _ changesFile size. pos _ initialPos. [pos = 0 or: [banners size > 20]] whileFalse: [changesFile position: pos. chunk _ changesFile nextChunk. i _ chunk indexOfSubCollection: 'priorSource: ' startingAt: 1. i > 0 ifTrue: [positions addLast: pos. banners addLast: (chunk copyFrom: 5 to: i - 2). pos _ Number readFrom: (chunk copyFrom: i + 13 to: chunk size)] ifFalse: [pos _ 0]]. changesFile close. pos _ (SelectionMenu labelList: banners selections: positions) startUpWithCaption: 'Browse as far back as...'. pos == nil ifTrue: [^ self]. self browseRecent: end - pos on: origChangesFile! ! !FileList methodsFor: 'file list menu' stamp: 'HK 4/24/2002 15:38'! browseRecentChanges "Browse the selected file's recently logged changes" fileName ifNil: [self beep] ifNotNil: [ChangeList browseRecentLogOn: (directory readOnlyFileNamed: fileName)]! ! !FileList methodsFor: 'file list menu' stamp: 'HK 4/24/2002 15:36'! itemsForFileEnding: suffix | labels lines selectors | labels _ OrderedCollection new. lines _ OrderedCollection new. selectors _ OrderedCollection new. suffix = 'bmp' | (suffix = 'gif') | (suffix = 'jpg') | (suffix = 'form') | (suffix = '*') | (suffix = 'png') ifTrue: [labels addAll: #('open image in a window' 'read image into ImageImports' 'open image as background' ). selectors addAll: #(#openImageInWindow #importImage #openAsBackground )]. suffix = 'morph' | (suffix = 'morphs') | (suffix = 'sp') | (suffix = '*') ifTrue: [labels add: 'load as morph'. selectors add: #openMorphFromFile. labels add: 'load as project'. selectors add: #openProjectFromFile]. suffix = 'mdl' ifTrue: [labels add: 'load into Wonderland'. selectors add: #openModelintoAlice]. suffix = 'extseg' | (suffix = 'project') | (suffix = 'pr') ifTrue: [labels add: 'load as project'. selectors add: #openProjectFromFile]. suffix = 'bo' | (suffix = '*') ifTrue: [labels add: 'load as book'. selectors add: #openBookFromFile]. suffix = 'mid' | (suffix = '*') ifTrue: [labels add: 'play midi file'. selectors add: #playMidiFile]. suffix = 'movie' | (suffix = '*') ifTrue: [labels add: 'open as movie'. selectors add: #openAsMovie]. suffix = 'changes' | (suffix = '*') ifTrue: [labels add: 'browse recent changes'. selectors add: #browseRecentChanges]. suffix = 'st' | (suffix = 'cs') | (suffix = '*') ifTrue: [suffix = '*' ifTrue: [lines add: labels size]. labels addAll: #('fileIn' 'file into new change set' 'browse changes' 'browse code' 'remove line feeds' 'broadcast as update' ). lines add: labels size - 1. selectors addAll: #(#fileInSelection #fileIntoNewChangeSet #browseChanges #browseFile #removeLinefeeds #putUpdate )]. suffix = 'swf' | (suffix = '*') ifTrue: [labels add: 'open as Flash'. selectors add: #openAsFlash]. suffix = 'ttf' | (suffix = '*') ifTrue: [labels add: 'open true type font'. selectors add: #openAsTTF]. suffix = 'gz' | (suffix = '*') ifTrue: [labels addAll: #('view decompressed' 'decompress to file' ). selectors addAll: #(#viewGZipContents #saveGZipContents )]. suffix = '3ds' | (suffix = '*') ifTrue: [labels add: 'Open 3DS file'. selectors add: #open3DSFile]. suffix = 'tape' | (suffix = '*') ifTrue: [labels add: 'open for playback'. selectors add: #openTapeFromFile]. suffix = 'wrl' | (suffix = '*') ifTrue: [labels add: 'open in Wonderland'. selectors add: #openVRMLFile]. suffix = 'htm' | (suffix = 'html') ifTrue: [labels add: 'open in browser'. selectors add: #openInBrowser]. suffix = 'zip' | (suffix = '*') ifTrue: [labels add: 'open archive viewer'. selectors add: #openArchiveViewer]. suffix = '*' ifTrue: [labels addAll: #('generate HTML' ). lines add: labels size - 1. selectors addAll: #(#renderFile )]. suffix = CRDictionary fileNameSuffix ifTrue: [labels add: 'load Genie Gesture Dictionary'. selectors add: #loadCRDictionary]. suffix = CRDisplayProperties fileNameSuffix ifTrue: [labels add: 'load Genie Display Properties'. selectors add: #loadCRDisplayProperties]. ^ Array with: labels with: lines with: selectors! !