So it can play with the same mechanism as O/ECompletion does.
Attached is a changeset with a little class.
I'm not sure how to package it yet, but I think it has to be packaged along
with SelectorChooserMorph and others.
It's related to this issue:
http://code.google.com/p/pharo/issues/detail?id=439&q=cmd%20q&colspec=ID%20Type%20Status%20Summary%20Milestone%20Difficulty
Guille
'From Pharo1.4a of ''16 June 2011'' [Latest update: #14348] on 23 February 2012 at 4:36:18 pm'!
Object subclass: #SimpleCompletion
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'SimpleCompletion'!
!String methodsFor: '*SimpleCompletion' stamp: 'GuillermoPolito 2/23/2012 16:29'!
wordBefore: anIndex
| sep tok |
tok := false.
sep := anIndex.
[ sep > 0 and: [ (self at: sep) tokenish ] ] whileTrue:
[ tok := true.
sep := sep - 1 ].
^ tok
ifTrue:
[ self
copyFrom: sep + 1
to: anIndex ]
ifFalse: [ String new ]! !
!SimpleCompletion methodsFor: 'as yet unclassified' stamp: 'GuillermoPolito 2/23/2012 16:28'!
codeCompletionAround: aBlock textMorph: aTextMorph keyStroke: anEvent
| wordAtCaret |
wordAtCaret := aTextMorph editor paragraph text asString wordBefore: aTextMorph editor startIndex - 1.
(anEvent keyCharacter = Character tab and: [(wordAtCaret notEmpty)])
ifTrue: [ aTextMorph editor closeTypeIn.
aTextMorph editor editingState closeSelectorChooser.
aTextMorph editor editingState querySymbolFrom: aTextMorph. ]
ifFalse: aBlock! !
!SimpleCompletion methodsFor: 'as yet unclassified' stamp: 'GuillermoPolito 2/23/2012 16:12'!
register
Smalltalk tools register: self as: #codeCompletion.! !
!String reorganize!
('*Collections-arithmetic' * + - / // \\)
('*Compiler-Kernel' inviolateInstanceVariableNames isLegalClassName isLegalInstVarName)
('*Graphics-Display Objects' displayAt: displayOn: displayOn:at: displayOn:at:textColor:)
('*Morphic' asDraggableMorph)
('*Morphic-Pluggable Widgets' beginsWith:fromList:)
('*Morphic-Widgets' listRenderOn:atRow:bounds:color:from: widthToDisplayInList:)
('*Network-MIME' base64Decoded decodeMimeHeader decodeQuotedPrintable)
('*Network-UUID' asAlphaNumeric:extraChars:mergeUID:)
('*UIManager-Support' displayProgressAt:from:to:during: displayProgressFrom:to:during:)
('*compression' unzipped zipped)
('*files' asFileName asVmPathName)
('*fs-core-converting' asDirectory asFile asPath asPathWith: asReference asResolvedBy:)
('*monticello' extractNumber)
('*morphic' asMorph asStringMorph)
('*network-mime' asMIMEType base64Encoded)
('*network-protocols' encodeForHTTP encodeForHTTPWithTextEncoding: encodeForHTTPWithTextEncoding:conditionBlock:)
('*network-uri' asURI unescapePercents unescapePercentsWithTextEncoding:)
('*network-url' asUrl asUrlRelativeTo:)
('*regex-core' allRangesOfRegexMatches: allRegexMatches: asRegex asRegexIgnoringCase copyWithRegex:matchesReplacedWith: copyWithRegex:matchesTranslatedUsing: matchesRegex: matchesRegexIgnoringCase: prefixMatchesRegex: prefixMatchesRegexIgnoringCase: regex:matchesCollect: regex:matchesDo: search:)
('*zinc-http' asZnMimeType asZnUrl)
('accessing' allRangesOfSubString: byteAt: byteAt:put: byteSize do:toFieldNumber: endsWithDigit findAnySubStr:startingAt: findBetweenSubStrs: findCloseParenthesisFor: findDelimiters:startingAt: findLastOccurrenceOfString:startingAt: findString: findString:startingAt: findString:startingAt:caseSensitive: findTokens: findTokens:escapedBy: findTokens:includes: findTokens:keep: findWordStart:startingAt: includesSubString: includesSubstring:caseSensitive: indexOf: indexOf:startingAt: indexOf:startingAt:ifAbsent: indexOfSubCollection: indexOfSubCollection:startingAt:ifAbsent: lastIndexOfPKSignature: leadingCharRunLengthAt: lineCorrespondingToIndex: lineCount lineIndicesDo: lineNumber: lineNumberCorrespondingToIndex: lines linesDo: skipAnySubStr:startingAt: skipDelimiters:startingAt: startsWithDigit string tabDelimitedFieldsDo: typeTable)
('comparing' < <= = > >= alike: caseInsensitiveLessOrEqual: caseSensitiveLessOrEqual: charactersExactlyMatching: compare: compare:caseSensitive: compare:with:collated: crc16 endsWith: endsWithAnyOf: hash howManyMatch: match: sameAs: startingAt:match:startingAt:)
('converting' adaptToCollection:andSend: adaptToNumber:andSend: adaptToPoint:andSend: adaptToString:andSend: asByteArray asByteString asCamelCase asDate asDateAndTime asDuration asFourCode asHTMLString asHex asIdentifier: asInteger asLegalSelector asLowercase asNumber asOctetString asPacked asPluralBasedOn: asSignedInteger asSmalltalkComment asSqueakPathName asString asStringOrText asSymbol asText asTime asTimeStamp asUnsignedInteger asUppercase asWideString capitalized compressWithTable: contractTo: convertFromEncoding: convertFromWithConverter: convertToEncoding: convertToSystemString convertToWithConverter: correctAgainst: correctAgainst:continuedFrom: correctAgainstDictionary:continuedFrom: findSelector initialIntegerOrNil keywords numericSuffix onlyLetters romanNumber splitInteger squeezeOutNumber stemAndNumericSuffix subStrings subStrings: substrings surroundedBySingleQuotes translateFrom:to:table: translateToLowercase translateToUppercase translateWith: truncateTo: truncateWithElipsisTo: unparenthetically withBlanksCondensed withBlanksTrimmed withFirstCharacterDownshifted withNoLineLongerThan: withoutJustTrailingDigits withoutLeadingBlanks withSeparatorsCompacted withoutLeadingDigits withoutPeriodSuffix withoutTrailingBlanks withoutTrailingDigits)
('copying' copyReplaceTokens:with: deepCopy padded:to:with: trimBoth trimBoth: trimLeft trimLeft: trimLeft:right: trimRight trimRight:)
('encoding' writeLeadingCharRunsOn:)
('filter streaming' putOn:)
('formatting' expandMacros expandMacrosWithArguments: expandMacrosWith: expandMacrosWith:with: expandMacrosWith:with:with: expandMacrosWith:with:with:with: format: withCRs)
('internet' withInternetLineEndings withSqueakLineEndings withUnixLineEndings withoutQuoting withoutWrappingDoubleQuotes)
('paragraph support' encompassLine: encompassParagraph: endOfParagraphBefore: indentationIfBlank:)
('printing' encodeDoublingQuoteOn: isLiteral printOn: storeOn: stringRepresentation)
('splitjoin' join:)
('system primitives' endsWithAColon findSubstring:in:startingAt:matchTable: numArgs)
('testing' hasContentsInExplorer hasWideCharacterFrom:to: includesUnifiedCharacter indexOfWideCharacterFrom:to: isAllAlphaNumerics isAllDigits isAllSeparators isAsciiString isByteString isLiteralSymbol isOctetString isString isWideString lastSpacePosition)
('translating' translated translatedIfCorresponds translatedTo:)
('private' correctAgainstEnumerator:continuedFrom: evaluateExpression:parameters: getEnclosedExpressionFrom: replaceFrom:to:with:startingAt: stringhash)
('*SimpleCompletion' wordBefore:)
!