Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor model #120

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ keyStroke: aKeyboardEvent
returnValue := super keyStroke: aKeyboardEvent.
(self isNewCharacter: aKeyboardEvent)
ifTrue: [self model applyCurrentStructures].
(self isStructureShortcut: aKeyboardEvent) ifFalse:
[self model unbufferStructures].
(self isCtrlA: aKeyboardEvent)
ifTrue: [self selectAll].
self model precedingStructuresChanged.
(self isStructureShortcut: aKeyboardEvent) ifFalse:
[self model updateSelectedStructures].
self model updateFooter.
^ returnValue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mouseDown: anEvent

| returnValue |
returnValue := super mouseDown: anEvent.
self model precedingStructuresChanged.
self model ifNotNil: #unbufferStructures.
self model updateSelectedStructures.
self model updateFooter.
^ returnValue
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
"crWithIndent:" : "lh 7/24/2019 22:30",
"getParagraphCharacter" : "LM 5/26/2019 22:52",
"isCtrlA:" : "lh 7/24/2019 16:59",
"keyStroke:" : "JEH 6/14/2020 09:53",
"mouseDown:" : "JEH 6/14/2020 10:07",
"returnValue" : "ls 6/19/2019 19:14",
"isNewCharacter:" : "tok 6/13/2020 12:03",
"isSpecialCharacter:" : "OS 6/12/2020 12:03",
"isStructureShortcut:" : "OS 6/12/2020 12:09",
"isValidCharacter:" : "tok 6/13/2020 12:04",
"keyStroke:" : "OS 6/12/2020 12:09",
"mouseDown:" : "OS 6/1/2020 00:56",
"keyStroke:" : "OS 6/19/2020 20:51",
"mouseDown:" : "OS 6/19/2020 21:31",
"setEmphasisHere" : "6/1/2020 14:03:21",
"specialCharacters" : "tok 6/13/2020 12:14",
"storeSelectionInParagraph" : "lh 7/24/2019 21:51",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ text structure
addAttribute: aTextAttribute

self setTextFromView.
self bufferDocument addAttribute: aTextAttribute from: self selectionStart to: self selectionStop
self bufferDocument
addAttribute: aTextAttribute
from: self selectionStart
to: self selectionStop.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
text structure
addExtendableStructures

(self currentStructures
(self selectedStructures
collect: [:each | self symbolToStructure: each]
thenSelect: [:each | each isExtendable]) do: [:each | self addAttribute: each]

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
text structure
getStructureSelectionAt: anIndex

| structures |

self isIntervalNotEmpty ifTrue:[structures := self selectedStructures]
ifFalse: [structures := self currentStructures].
^ structures includes: (self textStructureSymbols at: anIndex ifAbsent: false)
^ self selectedStructures includes: (self textStructureSymbols at: anIndex ifAbsent: [^ false])
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ initialize
self
initializeDocuments;
label: self class initialLabel;
selectedStructures: Set new;
bufferedStructures: Set new;
debufferedStructures: Set new;
precedingStructures: Set new
selectedStructures: Set new
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testing
isCursorBetweenText

^ self isIntervalEmpty and: [self isTextEmpty not]
^ self isTextSelected and: [self isTextEmpty not]

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isNoTextSelected

^ self isTextSelected not
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
isTextSelected

^ (self selectionInterval first > self selectionInterval last)

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
text structure
removeAttribute: aTextAttribute

self bufferDocument
removeTextAttribute: aTextAttribute
from: self selectionStart
to: self selectionStop.
self selectionChanged
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
change
selectionChanged

self selectedStructures: (self textStructureSymbols select:
[:structure | self hasStructure: structure]) asSet.
self isNoTextSelected ifTrue: [self selectedStructures: (self textStructureSymbols select:
[:structure | self hasStructure: structure]) asSet.].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one dot to many

self changed: #allSelections
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
text structure
structureSelectionAt: anIndex put: aBoolean

| targetSymbol targetStructure |
targetSymbol := self textStructureSymbols at: anIndex ifAbsent: [^self].
targetStructure := self textStructures at: anIndex ifAbsent: [^self].
(aBoolean and: [self isIntervalEmpty])
ifTrue: [self bufferedStructures add: targetSymbol. self debufferedStructures remove: targetSymbol ifAbsent: []].
(aBoolean and: [self isIntervalNotEmpty])
ifTrue: [self addAttribute: targetStructure].
(aBoolean not and: [self isIntervalEmpty])
ifTrue: [self debufferedStructures add: targetSymbol. self bufferedStructures remove: targetSymbol ifAbsent: []].
(aBoolean not and: [self isIntervalNotEmpty])
ifTrue: [self removeTextAttribute: targetStructure].

| targetSymbol |
targetSymbol := self textStructureSymbols at: anIndex ifAbsent: [^ self].
aBoolean ifTrue: [self selectedStructures add: targetSymbol]
ifFalse: [self selectedStructures remove: targetSymbol ifAbsent: []].
self updateSelectedText: aBoolean with: targetSymbol.
self selectionChanged

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
as yet unclassified
precedingStructuresChanged
updateSelectedStructures

self precedingStructures: (self textStructureSymbols select:
self selectedStructures: (self textStructureSymbols select:
[:structure | self hasStructure: structure between: self selectionStart to: self selectionStart]) asSet.
self changed: #allSelections
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
as yet unclassified
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

categorize

updateSelectedText: aBoolean with: targetSymbol

self isTextSelected ifTrue: [^ self].
aBoolean ifTrue: [self addAttribute: (self symbolToStructure: targetSymbol)]
ifFalse: [self removeTextAttribute: (self symbolToStructure: targetSymbol)]
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
"toggleAutocompletion" : "kh 5/18/2020 13:54",
"yellowButtonMenuItems" : "tok 5/31/2020 20:54" },
"instance" : {
"addAttribute:" : "ls 7/24/2019 20:26",
"addExtendableStructures" : "OS 5/31/2020 23:59",
"addAttribute:" : "OS 6/19/2020 21:50",
"addExtendableStructures" : "OS 6/19/2020 20:18",
"applyCurrentStructures" : "OS 6/3/2020 22:35",
"bufferDocument" : "ls 6/26/2019 17:45",
"bufferDocument:" : "ls 7/24/2019 20:57",
"bufferedStructures" : "ls 6/19/2019 17:30",
"bufferedStructures:" : "ls 6/26/2019 17:46",
"buildFooterWith:" : "JEH 6/14/2020 11:33",
"buildHelpButtonWith:" : "kh 6/1/2020 14:21",
"buildInfoButtonWith:" : "kh 6/1/2020 14:21",
Expand All @@ -36,9 +34,6 @@
"currentPositionInText" : "JEH 6/14/2020 11:15",
"currentSaveName" : "ls 6/26/2019 17:58",
"currentSaveName:" : "ls 6/26/2019 17:58",
"currentStructures" : "OS 6/1/2020 00:02",
"debufferedStructures" : "OS 5/31/2020 13:08",
"debufferedStructures:" : "OS 5/31/2020 13:08",
"displayedLines" : "JEH 6/14/2020 09:57",
"documentClass" : "ls 7/10/2019 15:53",
"documentTimeText" : "OS 6/14/2020 18:22",
Expand All @@ -47,18 +42,18 @@
"footer" : "frc 5/25/2020 15:40",
"footer:" : "frc 5/25/2020 15:22",
"footerText" : "JEH 6/14/2020 11:16",
"getStructureSelectionAt:" : "OS 6/3/2020 23:53",
"getStructureSelectionAt:" : "OS 6/19/2020 20:15",
"hasStructure:" : "AG 7/25/2019 13:13",
"hasStructure:between:to:" : "6/1/2020 14:03:21",
"hasUnacceptedEdits" : "ls 5/9/2019 10:34",
"help" : "kh 5/25/2020 16:35",
"initialize" : "ls 7/24/2019 15:10",
"initialize" : "OS 6/19/2020 21:29",
"initializeDocuments" : "lh 7/24/2019 22:37",
"inspectDocument" : "ls 6/26/2019 18:57",
"isCursorBetweenText" : "ls 7/24/2019 15:33",
"isIntervalEmpty" : "OS 5/31/2020 23:41",
"isIntervalNotEmpty" : "lh 7/24/2019 18:27",
"isCursorBetweenText" : "OS 6/19/2020 22:03",
"isNoTextSelected" : "OS 6/19/2020 22:03",
"isTextEmpty" : "AG 7/25/2019 13:13",
"isTextSelected" : "OS 6/19/2020 22:03",
"label" : "ls 5/11/2019 12:23",
"label:" : "ls 6/26/2019 17:46",
"loadDocumentFromSaver" : "lh 7/24/2019 18:11",
Expand All @@ -67,10 +62,8 @@
"openNewEditor" : "ls 6/12/2019 18:10",
"openStructureEditor" : "ls 7/24/2019 16:53",
"positionInTextAtIndex:" : "JEH 6/14/2020 18:14",
"precedingStructures" : "OS 5/31/2020 23:22",
"precedingStructures:" : "OS 5/31/2020 23:22",
"precedingStructuresChanged" : "OS 6/1/2020 00:04",
"redo" : "AG 5/29/2019 18:37",
"removeAttribute:" : "OS 6/19/2020 21:50",
"removeTextAttribute:" : "MB 7/24/2019 20:39",
"renameDocuments:" : "ls 6/26/2019 19:13",
"resetSaver" : "ls 6/26/2019 18:44",
Expand All @@ -82,7 +75,7 @@
"selectInvisibly" : "lh 7/24/2019 18:02",
"selectedStructures" : "MB 6/19/2019 17:36",
"selectedStructures:" : "AG 7/25/2019 11:18",
"selectionChanged" : "OS 5/28/2020 22:05",
"selectionChanged" : "OS 6/19/2020 22:03",
"selectionInterval" : "lh 7/24/2019 17:20",
"selectionStart" : "OS 5/31/2020 13:38",
"selectionStop" : "OS 5/31/2020 14:35",
Expand All @@ -92,7 +85,7 @@
"setText:" : "AG 5/29/2019 18:35",
"setTextFromView" : "ls 7/24/2019 20:27",
"showInfo" : "frc 5/19/2020 22:52",
"structureSelectionAt:put:" : "OS 6/4/2020 00:04",
"structureSelectionAt:put:" : "OS 6/19/2020 20:41",
"structuresChanged" : "ls 6/26/2019 23:03",
"symbolToStructure:" : "ls 7/24/2019 14:24",
"targetDocument" : "ls 6/26/2019 18:10",
Expand All @@ -109,8 +102,9 @@
"textView:" : "AG 7/25/2019 11:16",
"toggleStructureSelectionAt:" : "OS 5/16/2020 22:55",
"unacceptedEdits" : "ls 7/24/2019 21:06",
"unbufferStructures" : "OS 5/31/2020 13:09",
"undo" : "AG 5/29/2019 18:37",
"update:" : "ls 7/24/2019 14:56",
"updateFooter" : "frc 5/25/2020 15:40",
"updateSelectedStructures" : "OS 6/19/2020 20:51",
"updateSelectedText:with:" : "OS 6/19/2020 22:03",
"wantsAutocompletion" : "kh 5/5/2020 22:18" } }