Wrapped body done in smalltalk.
Starting refactor on nodes
This commit is contained in:
parent
8ffb0c0db7
commit
2a6f96f588
@ -203,58 +203,6 @@ GrafoscopioNode >> asStonFromRoot [
|
|||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #initialization }
|
|
||||||
GrafoscopioNode >> becomeDefaultTestTree [
|
|
||||||
| node1 node2 node3 node4 |
|
|
||||||
self
|
|
||||||
created: DateAndTime now printString;
|
|
||||||
header: 'Arbol principal'.
|
|
||||||
node1 := self class new
|
|
||||||
created: DateAndTime now printString;
|
|
||||||
header: 'Markup';
|
|
||||||
body: 'I am <b>just a node with markup</b>';
|
|
||||||
tagAs: 'text';
|
|
||||||
links: 'temp.md'.
|
|
||||||
node2 := self class new
|
|
||||||
created: DateAndTime now printString;
|
|
||||||
header: '%output Code';
|
|
||||||
tagAs: 'código';
|
|
||||||
body: '(ConfigurationOfGrafoscopio>>#version14:) sourceCode'.
|
|
||||||
node3 := self class new
|
|
||||||
created: DateAndTime now printString;
|
|
||||||
header: '%invisible';
|
|
||||||
tagAs: 'text';
|
|
||||||
body: '<i>Just testing</i>'.
|
|
||||||
node1 addNode: node3.
|
|
||||||
node4 := self class new
|
|
||||||
created: DateAndTime now printString;
|
|
||||||
header: 'Something';
|
|
||||||
tagAs: 'text';
|
|
||||||
body: '<h1>else</h1>'.
|
|
||||||
node1 addNode: node4.
|
|
||||||
node1 addNode: node2.
|
|
||||||
self
|
|
||||||
addNode: node1.
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #initialization }
|
|
||||||
GrafoscopioNode >> becomeDefaultTree [
|
|
||||||
"I create a starting tree for all Grafoscopio notebooks with just one textual node as child."
|
|
||||||
| node1 |
|
|
||||||
self class new.
|
|
||||||
self
|
|
||||||
created: DateAndTime now printString;
|
|
||||||
header: 'Arbol principal';
|
|
||||||
tagAs: 'código'.
|
|
||||||
node1 := self class new
|
|
||||||
created: DateAndTime now printString;
|
|
||||||
header: 'Node 1';
|
|
||||||
body: '';
|
|
||||||
tagAs: 'text'.
|
|
||||||
self addNode: node1.
|
|
||||||
^ self
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #accessing }
|
{ #category : #accessing }
|
||||||
GrafoscopioNode >> body [
|
GrafoscopioNode >> body [
|
||||||
"Returns the receivers body"
|
"Returns the receivers body"
|
||||||
@ -1271,15 +1219,25 @@ GrafoscopioNode >> visitedGoTo: aCollection [
|
|||||||
|
|
||||||
{ #category : #'as yet unclassified' }
|
{ #category : #'as yet unclassified' }
|
||||||
GrafoscopioNode >> wrapBodyLines [
|
GrafoscopioNode >> wrapBodyLines [
|
||||||
"I convert the node body from HTML format to Pandoc's Markdown."
|
"I convert the node body from HTML format to Pandoc's Markdown."
|
||||||
| bodyFile |
|
|
||||||
(self isTaggedAs: 'código' ) ifTrue: [ ^self ].
|
self wrapBodyLines: 80
|
||||||
bodyFile := FileLocator temp asFileReference / 'body.txt'.
|
]
|
||||||
bodyFile ensureCreateFile.
|
|
||||||
bodyFile writeStreamDo: [:out | out nextPutAll: self body ].
|
{ #category : #'as yet unclassified' }
|
||||||
Smalltalk platformName = 'unix'
|
GrafoscopioNode >> wrapBodyLines: aWidth [
|
||||||
ifTrue: [ self body: (self wrapBodyLinesFor: bodyFile) ].
|
"I convert the node body from HTML format to Pandoc's Markdown."
|
||||||
Smalltalk platformName = 'Win32'
|
|
||||||
ifTrue: [ self shouldBeImplemented ].
|
| bodyReader chunck |
|
||||||
bodyFile ensureDelete.
|
(self isTaggedAs: 'código')
|
||||||
|
ifTrue: [ ^ self ].
|
||||||
|
bodyReader := body readStream.
|
||||||
|
body := String
|
||||||
|
streamContents: [ :bodyWriter |
|
||||||
|
[ bodyReader atEnd ]
|
||||||
|
whileFalse: [
|
||||||
|
chunck := bodyReader next: aWidth - 1.
|
||||||
|
bodyWriter nextPutAll: chunck.
|
||||||
|
bodyReader atEnd
|
||||||
|
ifFalse: [ bodyWriter nextPut: Character lf ] ] ]
|
||||||
]
|
]
|
||||||
|
@ -16,10 +16,44 @@ GrafoscopioNodeTest >> dummyHtml [
|
|||||||
^ txt
|
^ txt
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #tests }
|
||||||
|
GrafoscopioNodeTest >> newTestTree [
|
||||||
|
| node0 node1 node2 node3 node4 |
|
||||||
|
node0 := GrafoscopioNode new
|
||||||
|
created: DateAndTime now printString;
|
||||||
|
header: 'Arbol principal'.
|
||||||
|
node1 := GrafoscopioNode new
|
||||||
|
created: DateAndTime now printString;
|
||||||
|
header: 'Markup';
|
||||||
|
body: 'I am <b>just a node with markup</b>';
|
||||||
|
tagAs: 'text';
|
||||||
|
links: 'temp.md'.
|
||||||
|
node2 := GrafoscopioNode new
|
||||||
|
created: DateAndTime now printString;
|
||||||
|
header: '%output Code';
|
||||||
|
tagAs: 'código';
|
||||||
|
body: '(ConfigurationOfGrafoscopio>>#version14:) sourceCode'.
|
||||||
|
node3 := GrafoscopioNode new
|
||||||
|
created: DateAndTime now printString;
|
||||||
|
header: '%invisible';
|
||||||
|
tagAs: 'text';
|
||||||
|
body: '<i>Just testing</i>'.
|
||||||
|
node1 addNode: node3.
|
||||||
|
node4 := GrafoscopioNode new
|
||||||
|
created: DateAndTime now printString;
|
||||||
|
header: 'Something';
|
||||||
|
tagAs: 'text';
|
||||||
|
body: '<h1>else</h1>'.
|
||||||
|
node1 addNode: node4.
|
||||||
|
node1 addNode: node2.
|
||||||
|
node0 addNode: node1.
|
||||||
|
^ node0
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #tests }
|
{ #category : #tests }
|
||||||
GrafoscopioNodeTest >> testAddingChildren [
|
GrafoscopioNodeTest >> testAddingChildren [
|
||||||
| tree nnode orig |
|
| tree nnode orig |
|
||||||
tree := GrafoscopioNode new becomeDefaultTestTree.
|
tree := self newTestTree.
|
||||||
nnode := GrafoscopioNode new.
|
nnode := GrafoscopioNode new.
|
||||||
orig := tree children size.
|
orig := tree children size.
|
||||||
tree addNode: nnode.
|
tree addNode: nnode.
|
||||||
@ -59,7 +93,7 @@ GrafoscopioNodeTest >> testHasMarkdownSubtreesToExport [
|
|||||||
result of this test is true.
|
result of this test is true.
|
||||||
Please see look #becomeDefaultTestTree message to see the details that makes this test true."
|
Please see look #becomeDefaultTestTree message to see the details that makes this test true."
|
||||||
| tree |
|
| tree |
|
||||||
tree := GrafoscopioNode new becomeDefaultTestTree.
|
tree := self newTestTree.
|
||||||
self assert: tree selectMarkupSubtreesToExport isNotEmpty equals: true.
|
self assert: tree selectMarkupSubtreesToExport isNotEmpty equals: true.
|
||||||
|
|
||||||
]
|
]
|
||||||
@ -72,7 +106,7 @@ GrafoscopioNodeTest >> testInitializeIsOk [
|
|||||||
{ #category : #tests }
|
{ #category : #tests }
|
||||||
GrafoscopioNodeTest >> testNodeSelection [
|
GrafoscopioNodeTest >> testNodeSelection [
|
||||||
| tree child1 |
|
| tree child1 |
|
||||||
tree := GrafoscopioNode new becomeDefaultTestTree.
|
tree := self newTestTree..
|
||||||
child1 := tree preorderTraversalRootChildren at: 1.
|
child1 := tree preorderTraversalRootChildren at: 1.
|
||||||
child1 selected: true.
|
child1 selected: true.
|
||||||
self assert: tree detectSelectionIndex equals: 1
|
self assert: tree detectSelectionIndex equals: 1
|
||||||
@ -130,7 +164,7 @@ var links = tree.links(nodes);
|
|||||||
{ #category : #tests }
|
{ #category : #tests }
|
||||||
GrafoscopioNodeTest >> testRemovingChildren [
|
GrafoscopioNodeTest >> testRemovingChildren [
|
||||||
| tree orig |
|
| tree orig |
|
||||||
tree := GrafoscopioNode new becomeDefaultTestTree.
|
tree := self newTestTree..
|
||||||
orig := tree children size.
|
orig := tree children size.
|
||||||
orig > 0 ifTrue: [ tree removeNode: (tree children at: 1) ].
|
orig > 0 ifTrue: [ tree removeNode: (tree children at: 1) ].
|
||||||
self assert: tree children size equals: orig - 1.
|
self assert: tree children size equals: orig - 1.
|
||||||
@ -152,7 +186,7 @@ GrafoscopioNodeTest >> testToggleNodeSelection [
|
|||||||
"I verify that a selected node can be unchosen once a new selection has been done."
|
"I verify that a selected node can be unchosen once a new selection has been done."
|
||||||
|
|
||||||
| tree testNode1 testNode2 |
|
| tree testNode1 testNode2 |
|
||||||
tree := GrafoscopioNode new becomeDefaultTestTree.
|
tree := self newTestTree..
|
||||||
testNode1 := (tree preorderTraversalRootChildren at: 1) selected: true.
|
testNode1 := (tree preorderTraversalRootChildren at: 1) selected: true.
|
||||||
self assert: tree detectSelectionIndex equals: testNode1 preorderTraversalIndex.
|
self assert: tree detectSelectionIndex equals: testNode1 preorderTraversalIndex.
|
||||||
testNode2 := (tree preorderTraversalRootChildren at: 2).
|
testNode2 := (tree preorderTraversalRootChildren at: 2).
|
||||||
|
@ -154,6 +154,22 @@ GrafoscopioNotebook >> copyNodeToClipboard [
|
|||||||
self notebookContent: notebook.
|
self notebookContent: notebook.
|
||||||
]
|
]
|
||||||
|
|
||||||
|
{ #category : #persistence }
|
||||||
|
GrafoscopioNotebook >> createNewExample [
|
||||||
|
| node0 node1 |
|
||||||
|
node0 := GrafoscopioNode new
|
||||||
|
created: DateAndTime now printString;
|
||||||
|
header: 'Arbol principal';
|
||||||
|
tagAs: 'código'.
|
||||||
|
node1 := GrafoscopioNode new
|
||||||
|
created: DateAndTime now printString;
|
||||||
|
header: 'Node 1';
|
||||||
|
body: '';
|
||||||
|
tagAs: 'text'.
|
||||||
|
node0 addNode: node1.
|
||||||
|
^ node0
|
||||||
|
]
|
||||||
|
|
||||||
{ #category : #operation }
|
{ #category : #operation }
|
||||||
GrafoscopioNotebook >> currentNode [
|
GrafoscopioNotebook >> currentNode [
|
||||||
| currentNode |
|
| currentNode |
|
||||||
@ -468,22 +484,12 @@ GrafoscopioNotebook >> importLinkContent [
|
|||||||
GrafoscopioNotebook >> initialize [
|
GrafoscopioNotebook >> initialize [
|
||||||
super initialize.
|
super initialize.
|
||||||
self
|
self
|
||||||
notebook: (GrafoscopioNode new becomeDefaultTree);
|
notebook: (self createNewExample );
|
||||||
title: ' New | Grafoscopio notebook'.
|
title: ' New | Grafoscopio notebook'.
|
||||||
self notebookContent: self notebook.
|
self notebookContent: self notebook.
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
{ #category : #initialization }
|
|
||||||
GrafoscopioNotebook >> initializeDefaultTest [
|
|
||||||
super initialize.
|
|
||||||
self
|
|
||||||
notebook: (GrafoscopioNode new becomeDefaultTestTree);
|
|
||||||
title: ' New test | Grafoscopio notebook'.
|
|
||||||
self notebookContent: self notebook.
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
{ #category : #initialization }
|
{ #category : #initialization }
|
||||||
GrafoscopioNotebook >> initializePresenter [
|
GrafoscopioNotebook >> initializePresenter [
|
||||||
tree whenHighlightedItemChanged: [ :item |
|
tree whenHighlightedItemChanged: [ :item |
|
||||||
|
Loading…
Reference in New Issue
Block a user