Support for Tab in code completion.
Pressing Tab when code completion window is open completes longes common prefix
of items matching already typed text. If no text can be completed, flashes the completion
popup.
"{ Package: 'jv:smallsense' }"
"{ NameSpace: SmallSense }"
SimpleView subclass:#CompletionView
instanceVariableNames:'completionController list listHolder listView selectionHolder'
classVariableNames:''
poolDictionaries:''
category:'SmallSense-Core-Interface'
!
!CompletionView methodsFor:'accessing'!
completionController
^ completionController
!
completionController:aCompletionController
completionController := aCompletionController.
!
font: aFont
super font: aFont.
listView font: aFont.
"Created: / 27-09-2013 / 14:03:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
list
^ list
!
list: aCollection
list := aCollection.
listHolder value: aCollection.
"Created: / 27-09-2013 / 14:02:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
selection
^ (listView value at: selectionHolder value).
"Created: / 27-09-2013 / 15:41:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
selection: po
selectionHolder value: (listHolder value identityIndexOf: po)
"Created: / 27-09-2013 / 16:09:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompletionView methodsFor:'actions'!
complete: index
self assert: selectionHolder value == index.
completionController complete.
"Created: / 27-02-2014 / 10:09:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompletionView methodsFor:'event handling'!
keyPress:key x:x y:y
^ listView keyPress:key x:x y:y
"Created: / 27-09-2013 / 14:05:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 31-03-2014 / 22:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompletionView methodsFor:'initialization & release'!
initialize
| listViewScroller |
super initialize.
listHolder := ValueHolder new.
selectionHolder := ValueHolder new.
listViewScroller := ScrollableView for: SelectionInListModelView.
self addSubView: listViewScroller.
listViewScroller origin: 0.0 @ 0.0 corner: 1.0 @ 1.0.
listView := listViewScroller scrolledView.
listView listHolder: listHolder.
listView model: selectionHolder.
listView highlightMode: #line.
listView doubleClickAction:[:index | self complete: index ].
self extent: 400 @ 250
"Created: / 27-09-2013 / 13:56:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 27-02-2014 / 10:09:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompletionView methodsFor:'queries'!
hasSelection
^listView hasSelection
"Created: / 27-09-2013 / 14:10:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
isPopUpView
^ true
"Created: / 27-09-2013 / 13:56:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!CompletionView methodsFor:'redrawing'!
flash
listView flash.
"Created: / 31-03-2014 / 22:56:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !