Skip to content

Commit

Permalink
Merge pull request #161 from hpi-swa-teaching/refactor/frcroth
Browse files Browse the repository at this point in the history
Refactor minor style changes
  • Loading branch information
frcroth committed Jul 20, 2020
2 parents dd85c89 + 55b6b28 commit f33b0e5
Show file tree
Hide file tree
Showing 52 changed files with 119 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
asString

^ self text string
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ copy: aRichTextDocument

self
name: aRichTextDocument name copy;
timeLastSaved: aRichTextDocument timeLastSaved;
timestampLastSaved: aRichTextDocument timestampLastSaved;
text: aRichTextDocument text copy;
textStructures: aRichTextDocument textStructures copy;
changed
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
dateLastSaved

^ self timestampLastSaved first
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
isUnsavedDocument

^ self timeLastSaved = nil
^ self timestampLastSaved isNil

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
timeLastSaved

^ timeLastSaved
^ self timestampLastSaved second
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
timestampLastSaved: aDateAndTime

timestampLastSaved := aDateAndTime
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
timestampLastSaved

^ timestampLastSaved
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ count
wordcount

| prev bool byteString|
byteString := self text string asByteArray.
byteString := self asString asByteArray.
prev := self emptyChars first.
^ (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 @@ -6,17 +6,19 @@
"initialTextStructures" : "JEH 7/4/2020 11:19" },
"instance" : {
"addAttribute:from:to:" : "kh 6/19/2020 12:35",
"asString" : "frc 7/16/2020 13:46",
"charcount" : "frc 5/25/2020 16:02",
"charcountExcept:" : "frc 6/13/2020 11:15",
"clearTextRuns" : "JEH 7/4/2020 11:48",
"copy:" : "MB 7/3/2019 18:58",
"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",
"initialize" : "ls 7/24/2019 15:10",
"initializeStructure:" : "kh 6/21/2020 17:03",
"initializeStructures" : "ls 7/24/2019 15:12",
"isUnsavedDocument" : "OS 6/14/2020 18:19",
"isUnsavedDocument" : "tok 7/20/2020 14:10",
"name" : "ls 6/26/2019 17:28",
"name:" : "MB 7/3/2019 19:29",
"openEditor" : "lh 7/24/2019 21:27",
Expand All @@ -36,6 +38,7 @@
"textStructures" : "ls 6/26/2019 17:28",
"textStructures:" : "MB 7/3/2019 19:29",
"textStructuresDo:" : "ls 7/24/2019 21:29",
"timeLastSaved" : "OS 6/14/2020 11:16",
"timeLastSaved:" : "OS 6/15/2020 12:22",
"wordcount" : "frc 6/1/2020 13:46" } }
"timeLastSaved" : "tok 7/20/2020 14:10",
"timestampLastSaved" : "tok 7/20/2020 14:10",
"timestampLastSaved:" : "tok 7/20/2020 14:10",
"wordcount" : "frc 7/16/2020 13:47" } }
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"textStructures",
"text",
"name",
"timeLastSaved" ],
"timestampLastSaved" ],
"name" : "RichTextDocument",
"pools" : [
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ makeTextURLFrom: aString

^ aString asText
addAttribute: (TextStructure hyperlinkTo: aString);
addAttribute: (TextEmphasis underlined)
addAttribute: (TextEmphasis underlined);
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"isStructureShortcut:" : "OS 6/12/2020 12:09",
"isValidCharacter:" : "tok 6/13/2020 12:04",
"keyStroke:" : "OS 6/12/2020 12:09",
"makeTextURLFrom:" : "frc 7/3/2020 09:13",
"makeTextURLFrom:" : "frc 7/16/2020 14:05",
"mouseDown:" : "frc 7/3/2020 19:37",
"paste" : "kh 6/15/2020 13:32",
"pasteURL" : "frc 7/3/2020 09:13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ documentTimeText

self bufferDocument isUnsavedDocument
ifTrue: [^ 'unsaved document']
ifFalse: [^ 'last saved ', (self bufferDocument timeLastSaved at: 1), ' ', (self bufferDocument timeLastSaved at: 2)].
ifFalse: [^ 'last saved ', (self bufferDocument dateLastSaved), ' ', (self bufferDocument timeLastSaved)]
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ menubar
openEditMenu

^ self openMenuWith: {
{'Undo' . #undo}.
{'Redo' . #redo}.
{'Undo (z)' . #undo}.
{'Redo (Z)' . #redo}.
{'Structures' . #openStructureEditor}.
{'Template'. #openTemplateChoser}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
saving and loading
saveText

self bufferDocument timeLastSaved: Time dateAndTimeNow.
self bufferDocument timestampLastSaved: Time dateAndTimeNow.
self targetDocument copy: self bufferDocument.
self noUnacceptedEdits
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,4 @@ showInfo
infoText := 'Word count: ', self bufferDocument wordcount.
infoText := infoText , String crlf, 'Total characters: ', (self bufferDocument charcountExcept: #()).
infoText := infoText, String crlf, 'Non-blank characters: ', self bufferDocument charcount.
^ UserDialogBoxMorph new
title: self label;
label: infoText;
exclusive: false;
createButton: 'OK' translated value: true;
openInWorld;
yourself
^ self showInfoDialog: infoText
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
user interface
showInfoDialog: aString

^ UserDialogBoxMorph new
title: self label;
label: aString;
exclusive: false;
createButton: 'OK' translated value: true;
openInWorld;
yourself
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"defaultExportNameFor:" : "tok 7/3/2020 19:32",
"displayedLines" : "JEH 6/14/2020 09:57",
"documentClass" : "ls 7/10/2019 15:53",
"documentTimeText" : "OS 6/14/2020 18:22",
"documentTimeText" : "tok 7/20/2020 14:10",
"editor" : "lh 7/24/2019 17:17",
"exportFileWithDialog" : "tok 7/3/2020 19:34",
"fitParagraphs" : "lh 7/24/2019 22:44",
Expand Down Expand Up @@ -64,7 +64,7 @@
"noUnacceptedEdits" : "ls 7/24/2019 21:08",
"okToChange" : "ls 6/12/2019 22:15",
"openDocumentMenu" : "tok 7/8/2020 16:09",
"openEditMenu" : "JEH 7/4/2020 11:31",
"openEditMenu" : "frc 7/16/2020 12:35",
"openMenuWith:" : "frc 6/16/2020 19:51",
"openNewEditor" : "JEH 5/31/2020 14:14",
"openStructureEditor" : "ls 7/24/2019 16:53",
Expand All @@ -78,7 +78,7 @@
"renameDocuments:" : "ls 6/26/2019 19:13",
"resetSaver" : "ls 6/26/2019 18:44",
"saveDocumentInSaverWithNamePrompt" : "OS 6/14/2020 11:17",
"saveText" : "OS 6/14/2020 11:11",
"saveText" : "tok 7/20/2020 14:10",
"saveText:" : "ls 6/26/2019 18:33",
"saver" : "ls 6/26/2019 21:15",
"saves" : "ls 6/26/2019 21:15",
Expand All @@ -97,7 +97,8 @@
"setLabel:" : "lh 7/24/2019 17:21",
"setText:" : "AG 5/29/2019 18:35",
"setTextFromView" : "ls 7/24/2019 20:27",
"showInfo" : "tok 6/21/2020 11:43",
"showInfo" : "frc 7/16/2020 12:44",
"showInfoDialog:" : "frc 7/16/2020 12:45",
"structureSelectionAt:put:" : "OS 6/4/2020 00:04",
"structuresChanged" : "ls 6/26/2019 23:03",
"targetDocument" : "ls 6/26/2019 18:10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export: aRichTextDocument to: aFilePath

| fileStream |
fileStream := StandardFileStream newFileNamed: aFilePath.
fileStream nextPutAll: aRichTextDocument text asString.
fileStream nextPutAll: aRichTextDocument asString.
fileStream close
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"class" : {
"export:to:" : "tok 7/9/2020 21:38",
"export:to:" : "tok 7/20/2020 14:11",
"fileEnding" : "tok 7/3/2020 19:28",
"label" : "tok 7/8/2020 16:42" },
"instance" : {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
toolbuilder
buildChildrenWith: aBuilder

^ {self buildStructureFieldWith: aBuilder.
self buildStyleFieldWith: aBuilder.
self buildTextPreviewFieldWith: aBuilder.
self buildAddStructureButtonWith: aBuilder.
self buildFontButtonWith: aBuilder.
self buildFontResetButtonWith: aBuilder.
self buildColorButtonWith: aBuilder.
self buildColorResetButtonWith: aBuilder.
self buildRemoveStructureButtonWith: aBuilder.
self buildIncreasePriorityButtonWith: aBuilder.
self buildDecreasePriorityButtonWith: aBuilder.
self buildAcceptTemplateButtonWith: aBuilder.
self buildTemplateFieldWith: aBuilder}
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
toolbuilder
buildWith: aBuilder

| windowSpec |
windowSpec := aBuilder pluggableWindowSpec new.
windowSpec
model: self;
label: 'Structure Editor';
children: {
self buildStructureFieldWith: aBuilder.
self buildStyleFieldWith: aBuilder.
self buildTextPreviewFieldWith: aBuilder.
self buildAddStructureButtonWith: aBuilder.
self buildFontButtonWith: aBuilder.
self buildFontResetButtonWith: aBuilder.
self buildColorButtonWith: aBuilder.
self buildColorResetButtonWith: aBuilder.
self buildRemoveStructureButtonWith: aBuilder.
self buildIncreasePriorityButtonWith: aBuilder.
self buildDecreasePriorityButtonWith: aBuilder.

self buildAcceptTemplateButtonWith: aBuilder.
self buildTemplateFieldWith: aBuilder}.
children: (self buildChildrenWith: aBuilder).
^ aBuilder build: windowSpec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
change
update: aParameter

(aParameter = #font or: [aParameter = #color])
(#(font color) includes: aParameter)
ifTrue: [self updateLoremIpsum. self document textChanged].

super update: aParameter
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"allStructureIdentifiers" : "kh 6/21/2020 16:17",
"buildAcceptTemplateButtonWith:" : "JEH 7/9/2020 14:10",
"buildAddStructureButtonWith:" : "JEH 7/6/2020 15:37",
"buildChildrenWith:" : "tok 7/20/2020 14:12",
"buildColorButtonWith:" : "JEH 7/6/2020 15:33",
"buildColorResetButtonWith:" : "JEH 7/6/2020 15:33",
"buildDecreasePriorityButtonWith:" : "JEH 7/6/2020 15:37",
Expand All @@ -19,7 +20,7 @@
"buildStyleFieldWith:" : "JEH 7/6/2020 15:38",
"buildTemplateFieldWith:" : "JEH 7/6/2020 15:50",
"buildTextPreviewFieldWith:" : "JEH 7/6/2020 15:38",
"buildWith:" : "JEH 7/6/2020 15:50",
"buildWith:" : "frc 7/16/2020 12:43",
"checkAcceptTemplateConfirmation" : "JEH 7/10/2020 14:56",
"chooseStructureToRemove" : "ls 7/24/2019 17:26",
"colorOfCurrentStructure:" : "kh 6/21/2020 15:46",
Expand Down Expand Up @@ -60,6 +61,6 @@
"structureIdentifierAt:" : "kh 6/21/2020 16:18",
"templateIdentifiers" : "JEH 7/6/2020 15:25",
"textStructures" : "ls 7/24/2019 16:55",
"update:" : "ls 7/24/2019 21:57",
"update:" : "frc 7/16/2020 13:52",
"updateLoremIpsum" : "kh 6/21/2020 10:04",
"updateStructures:" : "lh 7/25/2019 11:05" } }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
predefined
hyperlinkTo: url

^ self new: #hyperlink from: {TextURL new url: url}.
^ self new: #hyperlink from: {TextURL new url: url}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
instance creation
new: aSymbol from: aCollection

^ (self new: aSymbol) attributes: aCollection asSet.
^ (self new: aSymbol) attributes: aCollection asSet
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
"font" : "kh 6/18/2020 23:23",
"fromColor:" : "kh 6/25/2020 13:57",
"fromFont:" : "kh 6/25/2020 13:57",
"hyperlinkTo:" : "kh 6/21/2020 16:56",
"hyperlinkTo:" : "frc 7/16/2020 12:41",
"indented" : "kh 6/21/2020 16:58",
"indentedBy:" : "kh 6/21/2020 16:58",
"italic" : "kh 6/19/2020 12:25",
"listOnLevel:" : "kh 6/21/2020 16:58",
"new:" : "kh 6/21/2020 15:51",
"new:from:" : "kh 6/21/2020 15:51",
"new:from:" : "frc 7/16/2020 12:41",
"notExtendable" : "kh 6/19/2020 17:26",
"predefinedStructureFor:" : "kh 6/21/2020 16:11",
"struckOut" : "kh 6/19/2020 12:25",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ testUS59EndOfStructureAndBeginOfStructureIncludeStructure
self document text: self textWithAttributes.
stream := DocumentReadStream on: self document.
stopConditions := stream next second.
self assert: (((stopConditions at: 1) second) = {self boldTextStructure}).
self assert: (((stopConditions at: 3) second) = {self italicTextStructure}).
self assert: (((stopConditions first) second) = {self boldTextStructure}).
self assert: (((stopConditions third) second) = {self italicTextStructure})
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ testUS59StopConditionsAreInCorrectOrder
self document text: self textWithAttributes.
stream := DocumentReadStream on: self document.
stopConditions := stream next second.
self assert: (self isEndOfStructure: (stopConditions at: 1)).
self assert: (self isParagraph: (stopConditions at: 2)).
self assert: (self isBeginningOfStructure: (stopConditions at: 3)).
self assert: (self isEndOfStructure: (stopConditions first)).
self assert: (self isParagraph: (stopConditions second)).
self assert: (self isBeginningOfStructure: (stopConditions third))
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"isEndOfStructure:" : "frc 7/13/2020 13:29",
"isParagraph:" : "OS 7/10/2020 12:20",
"paragraphCharacter" : "OS 7/10/2020 11:34",
"testUS59EndOfStructureAndBeginOfStructureIncludeStructure" : "OS 7/10/2020 12:26",
"testUS59EndOfStructureAndBeginOfStructureIncludeStructure" : "tok 7/20/2020 14:13",
"testUS59NextReturnsNextSectionOfTextAndListOfStopConditions" : "OS 7/10/2020 12:27",
"testUS59ReadStreamExists" : "OS 7/10/2020 11:22",
"testUS59StopConditionsAreInCorrectOrder" : "OS 7/10/2020 12:22",
"testUS59StopConditionsAreInCorrectOrder" : "tok 7/20/2020 14:14",
"textWithAttributes" : "frc 7/13/2020 13:29" } }

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"saveName" : "MB 6/12/2019 18:08",
"saveTextInImageAndOpenNewEditor" : "ls 7/3/2019 21:42",
"setUp" : "JEH 5/31/2020 14:55",
"structureIsListed" : "kh 6/19/2020 16:31",
"structureSymbol" : "ls 7/3/2019 21:38",
"structureSymbolIsListed" : "ls 7/3/2019 21:42",
"targetDocument" : "ls 7/3/2019 18:43",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ testUS87ExportAsPlainTextExistsInDialog
answer := self answer: RichTextPlainTextExportStrategy
inDialog: [self editorModel selectExportStrategy].

self assert: answer ~= nil
self deny: answer isNil
Loading

0 comments on commit f33b0e5

Please sign in to comment.