Skip to content

Commit

Permalink
dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-krivanek committed Oct 30, 2019
1 parent 6f7d6bf commit 92c6186
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
47 changes: 43 additions & 4 deletions src/Rubric/SpecRubDialog.class.st
Expand Up @@ -4,7 +4,16 @@ Class {
#instVars : [
'service',
'findInput',
'findButton'
'findButton',
'regExpCheckBox',
'backwardsCheckBox',
'caseCheckBox',
'wrapCheckBox',
'entireCheckBox',
'replaceButton',
'replaceAllButton',
'cancelButton',
'updateFromModel'
],
#category : #'Rubric-Editing-FindReplaceService'
}
Expand All @@ -14,7 +23,22 @@ SpecRubDialog class >> defaultSpec [
<spec>
^ SpBoxLayout newVertical
add: #findInput;
add: #findButton;
add: (SpGridLayout new
beColumnHomogeneous;
beRowHomogeneous;
add: #regExpCheckBox at: 1@1;
add: #backwardsCheckBox at: 2@1;
add: #caseCheckBox at: 1@2;
add: #wrapCheckBox at: 2@2;
add: #entireCheckBox at: 1@3;
yourself);
addLast: (SpBoxLayout newHorizontal
borderWidth: 5;
spacing: 5;
add: #findButton;
add: #replaceButton;
add: #replaceAllButton;
add: #cancelButton);
yourself
]

Expand All @@ -40,11 +64,26 @@ SpecRubDialog >> findInput: anObject [

{ #category : #initialization }
SpecRubDialog >> initializePresenters [
findInput := self newTextInput autoAccept: true.
findInput := self newTextInput autoAccept: true; placeholder: 'Text to find'.
findInput whenTextChangedDo: [ self updateFindText ].

regExpCheckBox := self newCheckBox label: 'Regular expression'.
backwardsCheckBox := self newCheckBox label: 'Search backwards'.
caseCheckBox := self newCheckBox label: 'Case sensitive'.
wrapCheckBox := self newCheckBox label: 'Wrap around'.
entireCheckBox := self newCheckBox label: 'Entire words only'.

findButton := self newButton label: 'Find'.
findButton action: [ service find ].
self updateFromModel

replaceButton := self newButton label: 'Replace';
action: [ service find ].
replaceAllButton := self newButton label: 'Replace';
action: [ service find ].
cancelButton := self newButton label: 'Replace all';
action: [ service find ].
updateFromModel := self newButton label: 'Cancel';
action: [ service find ].
]

{ #category : #accessing }
Expand Down
11 changes: 9 additions & 2 deletions src/Rubric/SpecRubFindReplaceService.class.st
Expand Up @@ -159,7 +159,14 @@ SpecRubFindReplaceService >> textArea: aTextArea [

{ #category : #updating }
SpecRubFindReplaceService >> updateFindStartIndex [

| si |
self textArea
ifNil: [ ^self ]
ifNotNil: [ :aTextArea |
aTextArea changed.
self changed: #replaceEnabled.
si := aTextArea selectionInterval.
self findStartIndex: (self searchBackwards ifTrue: [si first - 1] ifFalse: [si last + 1]) ]
]

{ #category : #'user-interface' }
Expand Down Expand Up @@ -188,5 +195,5 @@ SpecRubFindReplaceService >> whenTextAreaLostFocus: anAnnounce [

{ #category : #'events handling' }
SpecRubFindReplaceService >> whenTextAreaSelectionChanged: anAnnouncement [

self updateFindStartIndex
]

0 comments on commit 92c6186

Please sign in to comment.