Skip to content

Commit

Permalink
Merge pull request #184 from hpi-swa-teaching/refactor/minor
Browse files Browse the repository at this point in the history
Refactor/minor
  • Loading branch information
frcroth committed Aug 7, 2020
2 parents 021b18f + a7c0403 commit 463f7e7
Show file tree
Hide file tree
Showing 160 changed files with 322 additions and 325 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ Copy this command into your local workspace and execute (Ctrl + d) it:
``` Smalltalk
Metacello new
baseline: 'RichTextEditing';
repository: 'github://hpi-swa-teaching/RichTextEditing:master/packages';
repository: 'github://hpi-swa-teaching/RichTextEditing:dev/packages';
load.
```

# Developer advice
If you are new to the project and starting to develop more features visit the Wiki over at [https://github.com/hpi-swa-teaching/RichTextEditing/wiki](https://github.com/hpi-swa-teaching/RichTextEditing/wiki).

## Outlook
In the future, it may also be possible to reflect over the text. Therefore, one would be able to easily export the text into different formats (e.g. Markdown, HTML, ...).
In the future, it might be possible to integrate morphs, tables etc. into rich text. The Scripting API and exporting/importing functionality is also up for improvement. Additionally, it may be possible to integrate rich text into other tools (i.e. e-mail client).
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
text structures
utilities
hasStructure: aSymbol forText: aText from: start to: end

aText isEmpty
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
converting
asByteArray

^ self asString asByteArray
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
converting
asString

^ self text string
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ count
charcountExcept: aListOfBytecodes

| byteString |
byteString := self text string asByteArray.
byteString := self asByteArray.

^ byteString count: [:each | (aListOfBytecodes includes: each) not]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
comparing
hash

^ (((self textStructures hash) bitXor: (self text hash)) bitXor: (self name hash)) bitXor: (self timeLastSaved hash)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ removeStructure: aSymbol
self textStructures remove: (self textStructureAt: aSymbol).
self
textChanged;
structuresChanged
structuresChanged;
yourself
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
text structures
setNewTemplate: aRichTextTemplateClass

aRichTextTemplateClass applyOnDocument: self
aRichTextTemplateClass applyOn: self
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ sortRunsByPriority
structureCopy := attributes copy select: [:attribute | attribute isTextStructure].
noStructureCopy := attributes copy reject: [:attribute | attribute isTextStructure].
structureCopy := structureCopy sorted: [:a :b |
(self textStructureSymbols indexOf: a structureIdentifier) > (self textStructureSymbols indexOf: b structureIdentifier)].
(self textStructureSymbols indexOf: a structureIdentifier) >
(self textStructureSymbols indexOf: b structureIdentifier)].
attributes := noStructureCopy, structureCopy])
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ count
wordcount

| prev bool byteString|
byteString := self asString asByteArray.
byteString := self asByteArray.
prev := self emptyChars first.
^ (byteString count: [:each | bool := ((self emptyChars includes: each) not and: (self emptyChars includes: prev)). prev := each. bool ])
^ (byteString count: [:each | bool := ((self emptyChars includes: each) not and: [
self emptyChars includes: prev]). prev := each. bool ])
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
"commonStructures" : "kh 6/21/2020 17:03",
"editorClass" : "ls 6/26/2019 17:33",
"fromText:withStructures:" : "ls 6/26/2019 17:31",
"hasStructure:forText:from:to:" : "frc 8/7/2020 11:27",
"initialTextStructures" : "JEH 7/4/2020 11:19" },
"instance" : {
"=" : "frc 8/6/2020 20:01",
"addAttribute:from:to:" : "kh 6/19/2020 12:35",
"asByteArray" : "frc 8/7/2020 10:49",
"asString" : "frc 7/16/2020 13:46",
"charcount" : "frc 5/25/2020 16:02",
"charcountExcept:" : "frc 6/13/2020 11:15",
"charcountExcept:" : "frc 8/7/2020 12:41",
"copy:" : "tok 7/20/2020 14:10",
"createNewStructure:" : "ls 7/24/2019 15:24",
"dateLastSaved" : "tok 7/20/2020 14:10",
"emptyChars" : "frc 6/1/2020 13:43",
"hasStructure:forText:from:to:" : "AG 7/25/2019 13:20",
"hash" : "frc 8/7/2020 11:37",
"initialize" : "ls 7/24/2019 15:10",
"initializeStructure:" : "kh 6/21/2020 17:03",
"initializeStructures" : "ls 7/24/2019 15:12",
Expand All @@ -23,11 +25,11 @@
"name:" : "MB 7/3/2019 19:29",
"openEditor" : "lh 7/24/2019 21:27",
"openInEditor" : "kh 7/27/2020 12:26",
"removeStructure:" : "kh 6/21/2020 10:03",
"removeStructure:" : "frc 8/7/2020 11:43",
"removeTextAttribute:from:to:" : "MB 7/24/2019 20:40",
"setNewTemplate:" : "frc 7/15/2020 15:43",
"setNewTemplate:" : "frc 8/7/2020 10:21",
"setTemplateStructures" : "frc 7/15/2020 15:49",
"sortRunsByPriority" : "JEH 5/20/2020 10:28",
"sortRunsByPriority" : "frc 8/7/2020 12:04",
"structuresChanged" : "ls 7/24/2019 14:46",
"text" : "ls 6/26/2019 17:28",
"text:" : "MB 7/3/2019 19:29",
Expand All @@ -42,4 +44,4 @@
"timeLastSaved" : "frc 8/6/2020 20:07",
"timestampLastSaved" : "tok 7/20/2020 14:10",
"timestampLastSaved:" : "tok 7/20/2020 14:10",
"wordcount" : "frc 7/16/2020 13:47" } }
"wordcount" : "frc 8/7/2020 12:04" } }
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
input events
utilities
isCtrlA: aKeyboardEvent

^ aKeyboardEvent buttons = 64 and: [aKeyboardEvent keyValue = $a asciiValue]

^ aKeyboardEvent buttons = 64 and: [aKeyboardEvent keyValue = $a asciiValue]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pasting
utilities
makeTextURLFrom: aString

^ aString asText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ keyStroke: aKeyboardEvent
returnValue := super keyStroke: aKeyboardEvent.
(self isNewCharacter: aKeyboardEvent)
ifTrue: [self model applyCurrentStructures].
(self isCtrlA: aKeyboardEvent)
(self class isCtrlA: aKeyboardEvent)
ifTrue: [self selectAll].
(self isStructureShortcut: aKeyboardEvent) ifFalse:
[self model precedingStructuresChanged].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ pasting
pasteURL

self
replaceSelectionWith: (self makeTextURLFrom: self clipboardText asString);
replaceSelectionWith: (self class makeTextURLFrom: self clipboardText asString);
selectAt: self pointIndex
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"initializeShiftCmdKeyShortcuts" : "tok 8/7/2020 11:14",
"initializeShiftedYellowButtonMenu" : "AG 5/29/2019 18:39",
"initializeYellowButtonMenu" : "AG 5/29/2019 18:39",
"isCtrlA:" : "frc 8/7/2020 11:26",
"makeTextURLFrom:" : "frc 8/7/2020 11:25",
"paragraphCharacter" : "OS 8/7/2020 09:47",
"structureKeymap" : "tok 8/7/2020 11:13",
"structureKeymap:" : "frc 8/6/2020 19:39" },
Expand All @@ -13,17 +15,15 @@
"clipboardContainsURL" : "kh 6/15/2020 13:32",
"crWithIndent:" : "OS 8/7/2020 09:49",
"initialize" : "JEH 8/3/2020 15:01",
"isCtrlA:" : "lh 7/24/2019 16:59",
"isNewCharacter:" : "tok 6/13/2020 12:03",
"isSpecialCharacter:" : "OS 6/12/2020 12:03",
"isStructureShortcut:" : "tok 8/7/2020 11:14",
"isValidCharacter:" : "tok 6/13/2020 12:04",
"keyStroke:" : "OS 8/6/2020 17:11",
"makeTextURLFrom:" : "frc 8/7/2020 14:10",
"keyStroke:" : "frc 8/7/2020 11:26",
"paste" : "kh 6/15/2020 13:32",
"pasteURL" : "frc 8/7/2020 11:25",
"mouseDown:" : "OS 8/6/2020 16:26",
"openStructureTypeIn" : "tok 8/3/2020 14:33",
"paste" : "kh 6/15/2020 13:32",
"pasteURL" : "frc 7/3/2020 09:13",
"setEmphasisHere" : "OS 8/7/2020 09:38",
"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 @@ -5,4 +5,5 @@ footerFrame
leftFraction: 0;
rightFraction: 1;
topFraction: 1 offset: self footerHeight negated;
bottomFraction: 1
bottomFraction: 1;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ hasStructure: aSymbol between: start to: end

self setTextFromView.

^ self bufferDocument
^ self bufferDocument class
hasStructure: aSymbol
forText: self text
from: start
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ mainSectionFrame
topFraction: self menuBarFrame bottomFraction
offset: self menuBarFrame bottomOffset;
bottomFraction: self footerFrame topFraction
offset: self footerFrame topOffset
offset: self footerFrame topOffset;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ manageStructuresButtonFrame
leftFraction: 0;
rightFraction: 1;
topFraction: 1 offset: self buttonHeight negated;
bottomFraction: 1
bottomFraction: 1;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ menuBarFrame
leftFraction: 0;
rightFraction: 1;
topFraction: 0;
bottomFraction: 0 offset: self buttonHeight
bottomFraction: 0 offset: self buttonHeight;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ structureListFrame
leftFraction: 0;
rightFraction: 1;
topFraction: 0;
bottomFraction: 1 offset: self buttonHeight negated
bottomFraction: 1 offset: self buttonHeight negated;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ structureSectionFrame
leftFraction: 0;
rightFraction: 0.3;
topFraction: 0;
bottomFraction: 1
bottomFraction: 1;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ textFieldFrame
leftFraction: 0.3;
rightFraction: 1;
topFraction: 0;
bottomFraction: 1
bottomFraction: 1;
yourself
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"class" : {
"autocompletion" : "kh 5/5/2020 22:35",
"autocompletion:" : "kh 5/5/2020 21:54",
"autocompletion:" : "frc 8/7/2020 12:43",
"fileExporters" : "JEH 7/26/2020 18:01",
"initialLabel" : "ls 6/21/2019 17:54",
"initialize" : "ls 6/21/2019 17:54",
Expand Down Expand Up @@ -44,12 +44,12 @@
"fitParagraphs" : "lh 7/24/2019 22:44",
"footer" : "frc 5/25/2020 15:40",
"footer:" : "frc 5/25/2020 15:22",
"footerFrame" : "kh 8/3/2020 13:56",
"footerFrame" : "frc 8/7/2020 11:57",
"footerHeight" : "kh 7/11/2020 14:48",
"footerText" : "JEH 6/14/2020 11:16",
"getStructureSelectionAt:" : "OS 8/6/2020 16:24",
"hasStructure:" : "AG 7/25/2019 13:13",
"hasStructure:between:to:" : "6/1/2020 14:03:21",
"hasStructure:between:to:" : "frc 8/7/2020 11:29",
"hasUnacceptedEdits" : "ls 5/9/2019 10:34",
"help" : "frc 8/7/2020 13:51",
"importFileFrom:" : "frc 8/6/2020 20:08",
Expand All @@ -66,9 +66,9 @@
"label" : "ls 5/11/2019 12:23",
"label:" : "ls 6/26/2019 17:46",
"loadDocumentFromSaver" : "tok 7/8/2020 16:09",
"mainSectionFrame" : "kh 8/3/2020 13:56",
"manageStructuresButtonFrame" : "kh 8/3/2020 13:56",
"menuBarFrame" : "kh 8/3/2020 13:56",
"mainSectionFrame" : "frc 8/7/2020 11:57",
"manageStructuresButtonFrame" : "frc 8/7/2020 11:56",
"menuBarFrame" : "frc 8/7/2020 11:56",
"noUnacceptedEdits" : "ls 7/24/2019 21:08",
"okToChange" : "ls 6/12/2019 22:15",
"openDocumentMenu" : "kh 8/3/2020 14:34",
Expand Down Expand Up @@ -106,17 +106,17 @@
"setTextFromView" : "ls 7/24/2019 20:27",
"showInfo" : "frc 7/16/2020 12:44",
"showInfoDialog:" : "frc 7/16/2020 12:45",
"structureListFrame" : "kh 8/3/2020 13:57",
"structureSectionFrame" : "kh 7/12/2020 13:48",
"structureSelectionAt:put:" : "OS 8/7/2020 13:52",
"structureListFrame" : "frc 8/7/2020 11:56",
"structureSectionFrame" : "frc 8/7/2020 11:56",
"structureSelectionAt:put:" : "tok 8/3/2020 12:52",
"structuresChanged" : "ls 6/26/2019 23:03",
"targetDocument" : "ls 6/26/2019 18:10",
"targetDocument:" : "lh 7/24/2019 20:23",
"text" : "ls 6/26/2019 17:59",
"text:" : "ls 6/26/2019 17:59",
"textChanged" : "frc 5/25/2020 15:22",
"textEditorClass" : "lh 7/24/2019 15:09",
"textFieldFrame" : "kh 7/12/2020 13:49",
"textFieldFrame" : "frc 8/7/2020 11:56",
"textMorph" : "ls 7/24/2019 21:06",
"textStructureAt:" : "kh 6/21/2020 15:39",
"textStructureSymbols" : "ls 7/24/2019 14:25",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export
export: aRichTextDocument on: aFilePath
export: aRichTextDocument on: aStream
"Subclasses overwrite this to specify how a text is exported"

^ self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"class" : {
"availableExportStrategies" : "JEH 7/26/2020 18:52",
"export:on:" : "frc 8/4/2020 14:22",
"export:on:" : "frc 8/7/2020 12:09",
"export:to:" : "frc 8/4/2020 14:23",
"fileEnding" : "tok 7/6/2020 14:33",
"label" : "tok 7/8/2020 16:42",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
printing
utilities
event: aDocumentReadStreamEvent contains: aStopCondition

^ (aDocumentReadStreamEvent second) contains: [:each | each first = aStopCondition]
^ (aDocumentReadStreamEvent second) contains: [:each | each first = aStopCondition]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
utilities
removeLastCharFrom: aText

^ aText copyFrom: 1 to: (aText size - 1)
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ putTextForEvent: aDocumentReadStreamEvent
| text |

text := aDocumentReadStreamEvent first.
(self event: aDocumentReadStreamEvent contains: #paragraph)
ifTrue: [text := self removeLastCharFrom: text].
(self event: aDocumentReadStreamEvent contains: #lineFeed)
ifTrue: [text := self removeLastCharFrom: text].
(self class event: aDocumentReadStreamEvent contains: #paragraph)
ifTrue: [text := self class removeLastCharFrom: text].
(self class event: aDocumentReadStreamEvent contains: #lineFeed)
ifTrue: [text := self class removeLastCharFrom: text].

self put: text

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"class" : {
"boldStructureEnclosingStrings" : "JEH 8/3/2020 14:36",
"codeStructureEnclosingStrings" : "JEH 8/3/2020 14:37",
"event:contains:" : "frc 8/7/2020 11:23",
"export:on:" : "frc 8/4/2020 14:26",
"fileEnding" : "JEH 7/26/2020 16:10",
"heading1StructureEnclosingStrings" : "JEH 8/3/2020 14:37",
Expand All @@ -16,6 +17,7 @@
"listMiddleString" : "frc 8/1/2020 13:30",
"paragraphStructureEnclosingStrings" : "JEH 8/3/2020 14:38",
"quoteStructureEnclosingStrings" : "JEH 8/3/2020 14:39",
"removeLastCharFrom:" : "frc 8/7/2020 11:24",
"template" : "frc 8/1/2020 13:13",
"underlinedStructureEnclosingStrings" : "JEH 8/3/2020 14:39",
"urlStructureEnclosingStrings" : "JEH 8/3/2020 14:39" },
Expand Down Expand Up @@ -51,8 +53,7 @@
"putClosingStrings" : "JEH 7/26/2020 16:27",
"putOpeningStrings" : "JEH 7/26/2020 16:27",
"putSpecialStrings:with:" : "JEH 8/3/2020 14:53",
"putTextForEvent:" : "frc 8/1/2020 13:07",
"removeLastCharFrom:" : "frc 8/1/2020 13:07",
"putTextForEvent:" : "frc 8/7/2020 11:24",
"removeStructuresFromActive:" : "frc 8/1/2020 13:07",
"saveFile" : "JEH 7/26/2020 17:36",
"startString" : "JEH 7/26/2020 16:16" } }
Loading

0 comments on commit 463f7e7

Please sign in to comment.