226 startTimeoutForEditViewLostFocus |
226 startTimeoutForEditViewLostFocus |
227 "see comment in #editViewLostFocus" |
227 "see comment in #editViewLostFocus" |
228 |
228 |
229 editViewLostFocusBlock isNil ifTrue:[ |
229 editViewLostFocusBlock isNil ifTrue:[ |
230 editViewLostFocusBlock := [self editViewLostFocus]. |
230 editViewLostFocusBlock := [self editViewLostFocus]. |
|
231 "/ Pro: This saves some warnings about timeout for dead process. |
|
232 "/ Con: Can add more than a single exit action |
|
233 "/ Processor activeProcess |
|
234 "/ addExitAction:[Processor removeTimedBlock:editViewLostFocusBlock]. |
231 ]. |
235 ]. |
232 Processor addTimedBlock:editViewLostFocusBlock afterMilliseconds:200. |
236 Processor addTimedBlock:editViewLostFocusBlock afterMilliseconds:200. |
|
237 |
|
238 "Modified: / 24-10-2019 / 18:44:41 / Stefan Vogel" |
233 ! ! |
239 ! ! |
234 |
240 |
235 !EditTextViewCompletionSupport methodsFor:'private'! |
241 !EditTextViewCompletionSupport methodsFor:'private'! |
236 |
242 |
237 computeAndShowCompletions |
243 computeAndShowCompletions |
370 |
376 |
371 adjustSizeOfCompletionView:topView |
377 adjustSizeOfCompletionView:topView |
372 |screenBounds screenBoundsCorner |
378 |screenBounds screenBoundsCorner |
373 helpViewsExtent helpViewsWidth helpViewsHeight |
379 helpViewsExtent helpViewsWidth helpViewsHeight |
374 textCursorPosInTextView textCursorPosOnScreen |
380 textCursorPosInTextView textCursorPosOnScreen |
375 newX newY cursorX cursorY distanceFromCursorIfBelow distanceFromCursorIfAbove | |
381 newX newY cursorX cursorY distanceFromCursorIfBelow distanceFromCursorIfAbove| |
376 |
382 |
377 textCursorPosInTextView := editView xOfCursor @ editView yOfCursor. |
383 textCursorPosInTextView := editView xOfCursor @ editView yOfCursor. |
378 textCursorPosOnScreen := editView device |
384 textCursorPosOnScreen := editView device |
379 translatePoint:textCursorPosInTextView |
385 translatePoint:textCursorPosInTextView |
380 fromView:editView toView:nil. |
386 fromView:editView toView:nil. |
385 distanceFromCursorIfBelow := distanceFromCursorIfAbove * 2. |
391 distanceFromCursorIfBelow := distanceFromCursorIfAbove * 2. |
386 |
392 |
387 topView resizeToFit. |
393 topView resizeToFit. |
388 |
394 |
389 "/ make sure, the window is visible |
395 "/ make sure, the window is visible |
390 screenBounds := topView device monitorBoundsAt:topView origin. |
396 screenBounds := topView device monitorBoundsAt:editView topView origin. |
391 screenBoundsCorner := screenBounds corner. |
397 screenBoundsCorner := screenBounds corner. |
392 |
398 |
393 helpViewsExtent := topView extent. |
399 helpViewsExtent := topView extent. |
394 helpViewsWidth := helpViewsExtent x. |
400 helpViewsWidth := helpViewsExtent x. |
395 helpViewsHeight := helpViewsExtent y. |
401 helpViewsHeight := helpViewsExtent y. |
451 |
459 |
452 |cursorX cursorY textCursorPosInTextView textCursorPosOnScreen movePos topView| |
460 |cursorX cursorY textCursorPosInTextView textCursorPosOnScreen movePos topView| |
453 |
461 |
454 "/ race here - openCompletionView may arrive late, when the user started to do something else |
462 "/ race here - openCompletionView may arrive late, when the user started to do something else |
455 "/ (scroll or select). Then it could happen the no cursor is currently visible. |
463 "/ (scroll or select). Then it could happen the no cursor is currently visible. |
456 cursorX := editView xOfCursor. |
464 "/ Disable dead code: |
457 cursorY := editView yOfCursor. |
465 "/ cursorX := editView xOfCursor. |
458 (cursorX isNil or:[cursorY isNil]) ifTrue:[^ self]. |
466 "/ cursorY := editView yOfCursor. |
459 |
467 "/ (cursorX isNil or:[cursorY isNil]) ifTrue:[^ self]. |
460 "/ move the window away from the text cursor (to not cover what user types in) |
468 "/ |
461 "/ get the screen-relative position of the text cursor |
469 "/ "/ move the window away from the text cursor (to not cover what user types in) |
462 textCursorPosInTextView := cursorX @ cursorY. |
470 "/ "/ get the screen-relative position of the text cursor |
463 |
471 "/ textCursorPosInTextView := cursorX @ cursorY. |
464 "/ care for the scroll-offset (xOfCursor/yOFCursor gives me |
472 "/ |
465 textCursorPosInTextView := textCursorPosInTextView - (editView viewOrigin x @ 0). |
473 "/ "/ care for the scroll-offset (xOfCursor/yOFCursor gives me |
466 |
474 "/ textCursorPosInTextView := textCursorPosInTextView - (editView viewOrigin x @ 0). |
467 textCursorPosOnScreen := editView device |
475 "/ |
468 translatePoint:textCursorPosInTextView |
476 "/ textCursorPosOnScreen := editView device |
469 fromView:editView toView:nil. |
477 "/ translatePoint:textCursorPosInTextView |
470 |
478 "/ fromView:editView toView:nil. |
471 "/ currently, we have to stay away a bit, to avoid getting the focus |
479 "/ |
472 "/ this will be somewhat to the down-right of the textCursor |
480 "/ "/ currently, we have to stay away a bit, to avoid getting the focus |
473 movePos := textCursorPosOnScreen + (60 @ (editView font height)). |
481 "/ "/ this will be somewhat to the down-right of the textCursor |
|
482 "/ movePos := textCursorPosOnScreen + (60 @ (editView font height)). |
474 |
483 |
475 completionView isNil ifTrue:[ |
484 completionView isNil ifTrue:[ |
476 completionView := CodeCompletionHelpMenuView new. |
485 completionView := CodeCompletionHelpMenuView new. |
477 completionView name:'completion'. |
486 completionView name:'completion'. |
478 completionView level:0. |
487 completionView level:0. |