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 textstructure #118

Merged
merged 13 commits into from
Jul 3, 2020
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
as yet unclassified
konradh marked this conversation as resolved.
Show resolved Hide resolved
mayBeExtended

^ true
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"class" : {
},
"instance" : {
"mayBeExtended" : "kh 6/18/2020 16:48" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"category" : "RichTextEditing-Core",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"structureIdentifier",
"color",
"font",
"styleSet",
"stylesActivated",
"attributes" ],
"name" : "ExtendableText",
"pools" : [
],
"super" : "TextAttribute",
"type" : "normal" }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
adding
add: aTextAttribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
at: aSymbol ifAbsent: aBlock

^ NullTextStructure new
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
testing
includes: aTextAttribute

^ false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
removing
remove: aTextAttribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
accessing
structureIdentifier: aSymbol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
"class" : {
"warningText" : "tok 6/12/2020 12:41" },
"instance" : {
"add:" : "kh 6/18/2020 21:24",
"at:ifAbsent:" : "kh 6/18/2020 21:25",
"includes:" : "kh 6/18/2020 21:25",
"noCurrentStructureWarning" : "tok 6/12/2020 12:41",
"openColorPicker" : "ls 7/24/2019 21:54",
"openFontChooser" : "ls 7/24/2019 21:22",
"remove:" : "kh 6/18/2020 21:24",
"resetColor" : "ls 7/24/2019 21:57",
"resetFont" : "ls 7/24/2019 21:23",
"structureIdentifier" : "ls 7/24/2019 22:17" } }
"structureIdentifier" : "ls 7/24/2019 22:17",
"structureIdentifier:" : "kh 6/18/2020 21:57" } }
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ I am a RichTextDocument. I represent the text someone wrote in order to improve

I am independent from the RichTextEditorModel, as the textStructures as well as my name and my text can be manipulated directly, so the RichTextEditorModel is not always needed, even though it can always be used.

You can add a new structure to the structures available in new instances of me by adding a new TextStructure to my initialTextStructures method on class side.

My instance variables are:
name - aString
text - aText
textStructures - anOrderedCollection
textStructures - anOrderedCollection
timeLastSaved - aDateAndTime

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
commonStyles

^ {TextStructure extendable} asSet
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
constants
defaultStyles

^ {TextStructure extendableStyle} asSet
^ self commonStyles
konradh marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
constants
initial structures
initialBoldStructure

^ TextStructure
newWith: #bold
withStyles: (self defaultStyles union: {TextStructure boldStyle})
^ TextStructure
new: #bold
with: (self commonStyles union: {TextStructure bold})
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
constants
initial structures
initialFootnoteStructure

^ (TextStructure
newWith: #footnote
withStyles: self defaultStyles)
font: (StrikeFont createDejaVuDark: 9)

^ TextStructure
new: #footnote
with: (self commonStyles union: {TextStructure font: (StrikeFont createDejaVuDark: 9)})
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
constants
initial structures
initialHeading1Structure

^ (TextStructure
newWith: #heading1
withStyles: (self defaultStyles union: {TextStructure boldStyle}))
font: (StrikeFont createDejaVuDark: 20)

^ TextStructure
new: #heading1
with: (self commonStyles union:
{TextStructure font: (StrikeFont createDejaVuDark: 20).
TextStructure bold})
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
constants
initial structures
initialHeading2Structure

^ (TextStructure
newWith: #heading2
withStyles: (self defaultStyles union: {TextStructure boldStyle}))
font: (StrikeFont createDejaVuDark: 17)

^ TextStructure
new: #heading2
with: (self commonStyles union:
{TextStructure font: (StrikeFont createDejaVuDark: 17).
TextStructure bold})
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
constants
initial structures
initialHeading3Structure

^ (TextStructure
newWith: #heading3
withStyles: (self defaultStyles union: {TextStructure boldStyle}))
font: (StrikeFont createDejaVuDark: 14)

^ TextStructure
new: #heading3
with: (self commonStyles union:
{TextStructure font: (StrikeFont createDejaVuDark: 14).
TextStructure bold})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
constants
initial structures
initialItalicStructure

^ TextStructure
newWith: #italic
withStyles: (self defaultStyles union: {TextStructure italicStyle})
new: #italic
with: (self commonStyles union: {TextStructure italic})
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
constants
initial structures
initialListStructure

^ TextStructure
newWith: #list
withStyles: (self defaultStyles union: {TextStructure indentedStyle})
new: #list
with: (self commonStyles union: {TextStructure indented})
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
constants
initial structures
initialTextStructures

^ {self initialBoldStructure.
self initialItalicStructure.
self initialUnderlinedStructure.
self initialFootnoteStructure.
self initialHeading1Structure.
self initialHeading2Structure.
self initialHeading3Structure.
self initialFootnoteStructure.
self initialListStructure} asOrderedCollection
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
constants
initial structures
initialUnderlinedStructure

^ TextStructure
newWith: #underlined
withStyles: (self defaultStyles union: {TextStructure underlinedStyle})
^ TextStructure
new: #underlined
with: (self commonStyles union: {TextStructure underlined})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
text structures
getTextStructure: aSymbol
konradh marked this conversation as resolved.
Show resolved Hide resolved

^ self textStructures detect: [:each | each structureIdentifier = aSymbol]
ifNone: [^ NullTextStructure new]
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
text structures
initializeStructure: aSymbol

self initializeStructure: aSymbol withEmphasis: self class defaultStyles
"self initializeStructure: aSymbol withEmphasis: self class defaultStyles"
konradh marked this conversation as resolved.
Show resolved Hide resolved
self textStructures add: (TextStructure new: aSymbol with: self class defaultStyles)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
text structures
removeStructure: aSymbol

self textStructures remove: (self symbolToStructure: aSymbol).
self textStructures remove: (self symbolToStructure: aSymbol) ifAbsent: [].
konradh marked this conversation as resolved.
Show resolved Hide resolved
self
textChanged;
structuresChanged
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
{
"class" : {
"defaultStyles" : "tok 6/8/2020 12:21",
"commonStyles" : "kh 6/18/2020 21:39",
"defaultStyles" : "kh 6/18/2020 22:35",
"editorClass" : "ls 6/26/2019 17:33",
"fromText:withStructures:" : "ls 6/26/2019 17:31",
"initialBoldStructure" : "tok 6/8/2020 12:22",
"initialFootnoteStructure" : "tok 6/8/2020 12:06",
"initialHeading1Structure" : "tok 6/8/2020 12:22",
"initialHeading2Structure" : "tok 6/8/2020 12:22",
"initialHeading3Structure" : "tok 6/8/2020 12:22",
"initialItalicStructure" : "tok 6/8/2020 12:22",
"initialListStructure" : "tok 6/8/2020 12:22",
"initialTextStructures" : "tok 5/31/2020 21:15",
"initialUnderlinedStructure" : "tok 6/8/2020 12:23" },
"initialBoldStructure" : "kh 6/19/2020 00:28",
"initialFootnoteStructure" : "kh 6/19/2020 00:29",
"initialHeading1Structure" : "kh 6/19/2020 00:30",
"initialHeading2Structure" : "kh 6/19/2020 00:31",
"initialHeading3Structure" : "kh 6/19/2020 00:31",
"initialItalicStructure" : "kh 6/19/2020 00:28",
"initialListStructure" : "kh 6/19/2020 00:32",
"initialTextStructures" : "kh 6/19/2020 00:34",
"initialUnderlinedStructure" : "kh 6/18/2020 21:39" },
"instance" : {
"addAttribute:from:to:" : "AG 7/25/2019 13:08",
"charcount" : "frc 5/25/2020 16:02",
"charcountExcept:" : "frc 6/13/2020 11:15",
"copy:" : "MB 7/3/2019 18:58",
"createNewStructure:" : "ls 7/24/2019 15:24",
"emptyChars" : "frc 6/1/2020 13:43",
"getTextStructure:" : "kh 6/18/2020 21:18",
"hasStructure:forText:from:to:" : "AG 7/25/2019 13:20",
"initialize" : "ls 7/24/2019 15:10",
"initializeStructure:" : "ls 7/24/2019 15:13",
"initializeStructure:" : "kh 6/18/2020 22:37",
"initializeStructure:withEmphasis:" : "tok 6/8/2020 12:06",
"initializeStructures" : "ls 7/24/2019 15:12",
"isUnsavedDocument" : "OS 6/14/2020 18:19",
"name" : "ls 6/26/2019 17:28",
"name:" : "MB 7/3/2019 19:29",
"openEditor" : "lh 7/24/2019 21:27",
"openInEditor" : "ls 7/24/2019 20:14",
"removeStructure:" : "ls 7/24/2019 17:28",
"removeStructure:" : "kh 6/18/2020 22:49",
"removeTextAttribute:from:to:" : "MB 7/24/2019 20:40",
"sortRunsByPriority" : "JEH 5/20/2020 10:28",
"structuresChanged" : "ls 7/24/2019 14:46",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"classvars" : [
],
"commentStamp" : "lh 7/25/2019 11:57",
"commentStamp" : "kh 6/19/2020 00:40",
"instvars" : [
"textStructures",
"text",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ addExtendableStructures

(self currentStructures
collect: [:each | self symbolToStructure: each]
thenSelect: [:each | each isExtendable]) do: [:each | self addAttribute: each]
thenSelect: [:each | each mayBeExtended]) do: [:each | self addAttribute: each]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"yellowButtonMenuItems" : "tok 5/31/2020 20:54" },
"instance" : {
"addAttribute:" : "ls 7/24/2019 20:26",
"addExtendableStructures" : "OS 5/31/2020 23:59",
"addExtendableStructures" : "kh 6/19/2020 00:51",
"applyCurrentStructures" : "OS 6/3/2020 22:35",
"bufferDocument" : "ls 6/26/2019 17:45",
"bufferDocument:" : "ls 7/24/2019 20:57",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
constants
allAttributes

^ TextStructure allAttributeIdentifiers

konradh marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
text coloring
addColor: aColor

self currentStructure add: (TextStructure color: aColor)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
text font
addFont: aFont

self currentStructure add: (TextStructure font: aFont)


This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
text attributes
allAttributes

^ self class allAttributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildColorButtonWith: aBuilder
model: self;
frame: (0.5 @ 0.55 corner: 0.75 @ 0.65);
label: 'Color';
action: #addColor;
action: #openColorPicker;
yourself


Loading