Workspace.st
changeset 4722 ff80b5a0b8b6
parent 4717 cabfcd0e5737
child 4725 aff6517a3471
equal deleted inserted replaced
4721:59fc420ce5b0 4722:ff80b5a0b8b6
  2361         p terminate.
  2361         p terminate.
  2362     ].
  2362     ].
  2363 !
  2363 !
  2364 
  2364 
  2365 suggestionsArrived:suggestions actions:actions
  2365 suggestionsArrived:suggestions actions:actions
  2366     |v list suggestionOffset keyAndSniplet|
  2366     |v list suggestionOffset keyAndSniplet lastEntryIsSniplet|
  2367 
  2367 
  2368     (editView sensor hasKeyPressEventFor:nil) ifTrue:[ 
  2368     (editView sensor hasKeyPressEventFor:nil) ifTrue:[ 
  2369         self closeCompletionView. 
  2369         self closeCompletionView. 
  2370         ^ self
  2370         ^ self
  2371     ].
  2371     ].
  2373     list := suggestions ? #().
  2373     list := suggestions ? #().
  2374     list size > 20 ifTrue:[ list := list copyTo:20 ].
  2374     list size > 20 ifTrue:[ list := list copyTo:20 ].
  2375 
  2375 
  2376     "/ append snipplets, if any (can be easily reached via CRSR-up)
  2376     "/ append snipplets, if any (can be easily reached via CRSR-up)
  2377     suggestionOffset := 0.
  2377     suggestionOffset := 0.
       
  2378     lastEntryIsSniplet := false.
  2378     (keyAndSniplet := editView findAbbreviationKeyBeforeCursor) notNil ifTrue:[
  2379     (keyAndSniplet := editView findAbbreviationKeyBeforeCursor) notNil ifTrue:[
  2379         |abbrev sniplet i line|
  2380         |abbrev sniplet i line|
  2380 
  2381 
  2381         abbrev := keyAndSniplet first.
  2382         abbrev := keyAndSniplet first.
  2382         sniplet := keyAndSniplet second.
  2383         sniplet := keyAndSniplet second.
  2391             (list includes:sniplet) ifFalse:[   
  2392             (list includes:sniplet) ifFalse:[   
  2392                 list isEmpty ifFalse:[ list := list copyWith: '-' ]. 
  2393                 list isEmpty ifFalse:[ list := list copyWith: '-' ]. 
  2393                 list := list copyWith: ( '%1 %2'
  2394                 list := list copyWith: ( '%1 %2'
  2394                                         bindWith:(sniplet asStringCollection first "contractTo:25")
  2395                                         bindWith:(sniplet asStringCollection first "contractTo:25")
  2395                                         with: ( ('("',abbrev,'" sniplet)') colorizeAllWith:Color grey)).
  2396                                         with: ( ('("',abbrev,'" sniplet)') colorizeAllWith:Color grey)).
       
  2397                 lastEntryIsSniplet := true.
  2396 
  2398 
  2397                 "/ change below, when reversing the order in above code
  2399                 "/ change below, when reversing the order in above code
  2398                 "/ suggestionOffset := 2.
  2400                 "/ suggestionOffset := 2.
  2399             ]
  2401             ]
  2400         ]
  2402         ]
  2427                     [:selectedListIndex | 
  2429                     [:selectedListIndex | 
  2428                         |indexInSuggestions|
  2430                         |indexInSuggestions|
  2429 
  2431 
  2430                         self closeCompletionView.
  2432                         self closeCompletionView.
  2431                         indexInSuggestions := selectedListIndex - suggestionOffset.
  2433                         indexInSuggestions := selectedListIndex - suggestionOffset.
  2432                         (keyAndSniplet notNil 
  2434                         (lastEntryIsSniplet and:[ selectedListIndex == list size]) ifTrue:[
  2433                         and:[ selectedListIndex == list size]) ifTrue:[
       
  2434                             "/ replace the sniplet
  2435                             "/ replace the sniplet
  2435                             editView sensor
  2436                             editView sensor
  2436                                 pushUserEvent:#value
  2437                                 pushUserEvent:#value
  2437                                 for:[
  2438                                 for:[
  2438                                     editView expandAbbreviation
  2439                                     editView expandAbbreviation
  2476 ! !
  2477 ! !
  2477 
  2478 
  2478 !Workspace class methodsFor:'documentation'!
  2479 !Workspace class methodsFor:'documentation'!
  2479 
  2480 
  2480 version
  2481 version
  2481     ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.284 2013-09-02 09:01:14 cg Exp $'
  2482     ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.285 2013-09-02 17:57:36 cg Exp $'
  2482 !
  2483 !
  2483 
  2484 
  2484 version_CVS
  2485 version_CVS
  2485     ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.284 2013-09-02 09:01:14 cg Exp $'
  2486     ^ '$Header: /cvs/stx/stx/libwidg/Workspace.st,v 1.285 2013-09-02 17:57:36 cg Exp $'
  2486 ! !
  2487 ! !
  2487 
  2488