Many refactors. pharo 9 en windows is working really bad

This commit is contained in:
sbragagnolo 2020-05-10 22:38:20 +02:00
parent ae12fe9576
commit 9cf21cb38b
80 changed files with 7652 additions and 7550 deletions

View File

@ -10,6 +10,31 @@ Class {
#category : #'Grafoscopio-UI'
}
{ #category : #'world menu' }
GfWorldMenu class >> getProjectExample [
| project unit |
project := GrafoscopioProject new.
unit := GrafoscopioUnitNode new.
unit name: 'Pillar-Example'.
unit
addChild: [ GrafoscopioPillarNode new
text: GrafoscopioPillarASText openExample;
yourself ]
ofClass: GrafoscopioPillarNode.
project document addChild: unit ofClass: GrafoscopioUnitNode.
^ project
]
{ #category : #'world menu' }
GfWorldMenu class >> getProjectFromFile [
| file |
file := UIManager default
chooseExistingFileReference: 'Choose a file'
extensions: #('ston')
path: FileLocator documents.
^ (STON fromStream: file readStream)
]
{ #category : #'world menu' }
GfWorldMenu class >> helpMenuOn: aBuilder [
<worldMenu>
@ -75,12 +100,17 @@ GfWorldMenu class >> launchMenuOn: aBuilder [
label: 'New notebook';
order: 1;
parent: #GfLaunch;
action: [ GrafoscopioNewNotebook new openDefault ].
action: [ (GrafoscopioTreeNotebook on: GrafoscopioProject new ) openWithSpec ].
(aBuilder item: #'New Notebook from example ')
label: 'Notebook from from example ';
order: 2;
parent: #GfLaunch;
action: [ (GrafoscopioTreeNotebook on: (self getProjectExample)) openWithSpec ].
(aBuilder item: #'Notebook from file...')
label: 'Notebook from file...';
order: 2;
parent: #GfLaunch;
action: [ GrafoscopioNewNotebook new openFromFileSelector ].
action: [ (GrafoscopioTreeNotebook on: (self getProjectFromFile)) openWithSpec ].
(aBuilder item: #GfLaunchOpenRecent)
label: 'Open recent...';
order: 2;
@ -89,7 +119,7 @@ GfWorldMenu class >> launchMenuOn: aBuilder [
label: 'Notebook from the Internet...';
order: 3;
parent: #GfLaunch;
action: [ GrafoscopioNewNotebook new openFromUrlUI ].
action: [ GrafoscopioTreeNotebook new openFromUrlUI ].
(aBuilder item: #recentNotebooks)
label: 'Recent notebooks...';
order: 4;
@ -119,19 +149,6 @@ GfWorldMenu class >> mainMenuItemsOn: aBuilder [
label: 'Help & Docs') target: self ]
]
{ #category : #'world menu' }
GfWorldMenu class >> openRecentMenu: aBuilder [
<worldMenu>
GrafoscopioNotebook recents
do: [ :f |
(aBuilder item: #'Open', f basename )
label: 'Open ', f basename;
order: 1;
parent: #GfLaunchOpenRecent;
action: [ GrafoscopioNotebook open: f ] ]
]
{ #category : #'world menu' }
GfWorldMenu class >> updateMenuOn: aBuilder [
<worldMenu>

View File

@ -34,6 +34,20 @@ GrafoscopioAttributeBranchVisitor >> attributesAt: aNode [
^ (attributes detect: [ :a | a first = aNode ]) second
]
{ #category : #'as yet unclassified' }
GrafoscopioAttributeBranchVisitor >> attributesAt: aNode force: aBlock [
^ attributes
detect: [ :a | a first = aNode ]
ifFound: [ :a | a at:2 put: aBlock value ]
ifNone: [ | val |
val := aBlock value.
attributes
add:
{aNode.
val}.
val ]
]
{ #category : #'as yet unclassified' }
GrafoscopioAttributeBranchVisitor >> attributesAt: aNode ifAbsentPut: aBlock [
^ attributes
@ -122,8 +136,8 @@ GrafoscopioAttributeBranchVisitor >> visitLineBreak: aPRLineBreak [
{ #category : #'as yet unclassified' }
GrafoscopioAttributeBranchVisitor >> visitListItem: aPRListItem [
self
attributesAt: aPRListItem
ifAbsentPut: [ styler attributesForListItem: aPRListItem at: index ]
attributesAt: aPRListItem
force: [ styler attributesForListItem: aPRListItem at: index ]
]
{ #category : #'as yet unclassified' }

View File

@ -1,24 +0,0 @@
"
This kind of a leafNodes holds code text.
"
Class {
#name : #GrafoscopioCodeNode,
#superclass : #GrafoscopioTextNode,
#category : #'Grafoscopio-Model'
}
{ #category : #'as yet unclassified' }
GrafoscopioCodeNode class >> icon [
^ self iconNamed:#objects
]
{ #category : #'as yet unclassified' }
GrafoscopioCodeNode class >> nameForSelection [
^ 'New Code Node'
]
{ #category : #accessing }
GrafoscopioCodeNode >> acceptVisitor: aGrafoscopioVisitor [
aGrafoscopioVisitor visitCodeNode: self.
]

View File

@ -1,151 +0,0 @@
Class {
#name : #GrafoscopioDocumentEditionPerspective,
#superclass : #GrafoscopioPerspective,
#instVars : [
'tree',
'document'
],
#category : #'Grafoscopio-New-UI'
}
{ #category : #accessing }
GrafoscopioDocumentEditionPerspective class >> defaultSpec [
^ SpBoxLayout newVertical
add: #toolbar height: self toolbarHeight;
add:
(SpBoxLayout newHorizontal
add: #tree width: 100;
add: #viewport;
yourself) yourself
]
{ #category : #accessing }
GrafoscopioDocumentEditionPerspective class >> icon [
^ self iconNamed: #merge
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addAtBeginningNewNodeOfClass: aClass [
self
addAtBeginningOf: (tree selectedItem ifNil: [ document ])
aNodeOfClass: aClass
]
{ #category : #'adding - base' }
GrafoscopioDocumentEditionPerspective >> addAtBeginningOf: aNode aNodeOfClass: aClass [
aNode
addAtBeginningChild: [ self instantiateNode: aClass ]
ofClass: aClass.
self modelChanged
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addAtLastNewNodeOfClass: aClass [
self
addAtLastOf: (tree selectedItem ifNil: [ document ])
aNodeOfClass: aClass
]
{ #category : #'adding - base' }
GrafoscopioDocumentEditionPerspective >> addAtLastOf: aNode aNodeOfClass: aClass [
aNode
addChild: [ self instantiateNode: aClass ]
ofClass: aClass.
self modelChanged
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addNewNodeAtBeginningOf: aNode [
self addAtBeginningOf: aNode aNodeOfClass: self chooseKindsOfNode
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addNewNodeAtLastOf: aNode [
self addAtLastOf: aNode aNodeOfClass: self chooseKindsOfNode
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentEditionPerspective >> addNewNodeOfClass: aClass [
^ self addAtLastNewNodeOfClass: aClass
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> createDefaultViewportVisitor [
^ GrafoscopioViewportVisitor new
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> createViewport [
^ self renderViewport: document
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> informNodeHasChanged: aNode [
| path |
path := tree selection selectedPath.
tree roots: {document}.
tree selectPath: path.
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> initializeWidgets [
super initializeWidgets.
tree := self newTreeTable.
tree
addColumn: (SpStringTableColumn evaluated: #name);
children: [ :node |
node isLeaf
ifTrue: [ {} ]
ifFalse: [ node children reject:[: a | a isLeaf ] ]].
tree activateOnDoubleClick.
tree whenSelectionChangedDo: [ : a | self renderViewport: a selectedItem ].
tree whenActivatedDo: [ : a | self tooglePresenterForEdition: a ].
]
{ #category : #'as yet unclassified' }
GrafoscopioDocumentEditionPerspective >> instantiateNode: aClass [
aClass class = GrafoscopioUnitNode species
ifTrue: [ | name |
name := UIManager default
request: 'Unit name'
initialAnswer: 'New unit'.
^ aClass new
name: name;
yourself ].
^ aClass new
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> modelChanged [
| path |
viewport := self createViewport.
path := tree selection selectedPath.
tree roots: {document}.
tree selectPath: path.
self needRebuild: false.
self buildWithSpec
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> renderViewport: aNode [
^ self createDefaultViewportVisitor createViewportFor: ( aNode ifNil: [ document ]) into: self
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> setModelBeforeInitialization: aDomainObject [
super setModelBeforeInitialization: aDomainObject.
document := aDomainObject .
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> tooglePresenterForEdition: anObect [
self halt.
]
{ #category : #initialization }
GrafoscopioDocumentEditionPerspective >> viewport [
^ viewport
]

View File

@ -0,0 +1,20 @@
Class {
#name : #GrafoscopioDocumentRichTextEditionPerspective,
#superclass : #GrafoscopioDocumentTextEditionPerspective,
#category : #'Grafoscopio-New-UI'
}
{ #category : #accessing }
GrafoscopioDocumentRichTextEditionPerspective class >> icon [
^ self iconNamed: #merge
]
{ #category : #initialization }
GrafoscopioDocumentRichTextEditionPerspective >> aboutToBeUninstalledFrom: aTreeNotebook [
]
{ #category : #initialization }
GrafoscopioDocumentRichTextEditionPerspective >> createDefaultViewportVisitor [
^ GrafoscopioViewportRichTextVisitor new
]

View File

@ -0,0 +1,189 @@
Class {
#name : #GrafoscopioDocumentTextEditionPerspective,
#superclass : #GrafoscopioPerspective,
#instVars : [
'tree',
'document',
'buildingVisitor'
],
#category : #'Grafoscopio-New-UI'
}
{ #category : #accessing }
GrafoscopioDocumentTextEditionPerspective class >> buildCommandsGroupWith: presenterInstance forRoot: rootCommandGroup [
rootCommandGroup
register: (self buildMenuBarGroupWith: presenterInstance)";
register: (self buildContextualMenuGroupWith: presenterInstance)"
]
{ #category : #accessing }
GrafoscopioDocumentTextEditionPerspective class >> buildContextualMenuGroupWith: presenterInstance [
^ (CmCommandGroup named: 'Context Menu') asSpecGroup
register: (self buildEditionGroupWith: presenterInstance);
register: (self buildAddingGroupWith: presenterInstance);
register: (self buildRemovingGroupWith: presenterInstance);
yourself
]
{ #category : #accessing }
GrafoscopioDocumentTextEditionPerspective class >> buildMenuBarGroupWith: presenterInstance [
^ (CmCommandGroup named: 'Context Menu') asSpecGroup
register:
(CmBlockCommand new
name: 'Inspect node';
block:
[ :context | context viewport selectedPage activePresenter inspectNode ];
asSpecCommand);
register:
(CmBlockCommand new
name: 'Inspect runs';
block:
[ :context | context viewport selectedPage activePresenter inspectRuns ];
asSpecCommand);
yourself
]
{ #category : #accessing }
GrafoscopioDocumentTextEditionPerspective class >> defaultSpec [
^ SpBoxLayout newVertical
add: #toolbar height: self toolbarHeight;
add:
(SpBoxLayout newHorizontal
add: #tree width: 100;
add: #viewport;
yourself) yourself
]
{ #category : #accessing }
GrafoscopioDocumentTextEditionPerspective class >> icon [
^ self iconNamed: #edit
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentTextEditionPerspective >> aboutToBeUninstalledFrom: aTreeNotebook [
aTreeNotebook removePerspective: self
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentTextEditionPerspective >> addAtLastNewNodeOfClass: aClass [
self
addAtLastOf: (tree selectedItem ifNil: [ document ])
aNodeOfClass: aClass
]
{ #category : #'adding - base' }
GrafoscopioDocumentTextEditionPerspective >> addAtLastOf: aNode aNodeOfClass: aClass [
aNode
addChild: [ self instantiateNode: aClass ]
ofClass: aClass.
self modelChanged
]
{ #category : #'adding - convenience' }
GrafoscopioDocumentTextEditionPerspective >> addNewNodeOfClass: aClass [
^ self addAtLastNewNodeOfClass: aClass
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> buildingVisitor [
^ buildingVisitor
ifNil: [ buildingVisitor := self createDefaultViewportVisitor ]
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> buildingVisitor: aVisitor [
buildingVisitor := aVisitor
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> createDefaultViewportVisitor [
^ GrafoscopioViewportTextVisitor new
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> createViewport [
^ self renderViewport: document
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> informNodeHasChanged: aNode [
| path |
path := tree selection selectedPath.
tree roots: {document}.
tree selectPath: path.
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> initializeWidgets [
super initializeWidgets.
tree := self newTreeTable.
tree
addColumn: (SpStringTableColumn evaluated: #name);
children: [ :node |
node isLeaf
ifTrue: [ {} ]
ifFalse: [ node children ] ].
tree activateOnDoubleClick.
tree
whenSelectionChangedDo: [ :a | self renderViewport: a selectedItem ].
tree whenActivatedDo: [ : a | self requestNewNameFor: a selectedItem ]
]
{ #category : #'as yet unclassified' }
GrafoscopioDocumentTextEditionPerspective >> instantiateNode: aClass [
| name |
name := UIManager default
request: 'Please, name the item'
initialAnswer: 'New item'.
^ aClass new
name: name;
yourself
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> modelChanged [
| path |
path := tree selection selectedPath.
tree roots: {document}.
tree selectPath: path.
self needRebuild: false.
self buildWithSpec
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> nameChanged [
| path |
path := tree selection selectedPath.
tree roots: {document}.
tree buildWithSpec.
tree selectPath: path
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> renderViewport: aNode [
^ self buildingVisitor createViewportFor: ( aNode ifNil: [ document ]) into: self
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> requestNewNameFor: aNode [
| name |
name := UIManager default
request: 'Please, name the node'
initialAnswer: aNode name asString.
name ifNotNil: [ aNode name: name ].
self buildingVisitor renamePageFor: aNode.
self nameChanged .
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> setModelBeforeInitialization: aDomainObject [
super setModelBeforeInitialization: aDomainObject.
document := aDomainObject .
]
{ #category : #initialization }
GrafoscopioDocumentTextEditionPerspective >> viewport [
^ viewport
]

View File

@ -6,5 +6,6 @@ Class {
{ #category : #'target resize' }
GrafoscopioFmtAnchorOnTheLeft >> beInstalledIn: aNode [
self installTextNodeAtLeftWithValue: (Character value: 1) asString in: aNode
]

View File

@ -6,5 +6,6 @@ Class {
{ #category : #'target resize' }
GrafoscopioFmtBeginningLinebreak >> beInstalledIn: aNode [
self installTextNodeAtLeftWithValue: OSPlatform current lineEnding in: aNode
" Should be using OSPlatform current lineEnding, but our text presenter does not support to have 2 character representation "
self installTextNodeAtLeftWithValue: String cr in: aNode
]

View File

@ -6,6 +6,7 @@ Class {
{ #category : #'target resize' }
GrafoscopioFmtDoubleLinebreak >> beInstalledIn: aNode [
self installTextNodeAtLeftWithValue: OSPlatform current lineEnding in: aNode.
self installTextNodeAtRightWithValue: OSPlatform current lineEnding in: aNode
" Should be using OSPlatform current lineEnding, but our text presenter does not support to have 2 character representation "
self installTextNodeAtLeftWithValue: String cr in: aNode.
self installTextNodeAtRightWithValue: String cr in: aNode
]

View File

@ -6,7 +6,8 @@ Class {
{ #category : #'target resize' }
GrafoscopioFmtEndingLinebreak >> beInstalledIn: aNode [
self installTextNodeAtRightWithValue: OSPlatform current lineEnding in: aNode
" Should be using OSPlatform current lineEnding, but our text presenter does not support to have 2 character representation "
self installTextNodeAtRightWithValue: String cr in: aNode
]
{ #category : #'target resize' }

View File

@ -1,105 +0,0 @@
Class {
#name : #GrafoscopioNewCodeModel,
#superclass : #GrafoscopioNewTextModel,
#instVars : [
'preview',
'previewButton'
],
#category : #'Grafoscopio-New-UI'
}
{ #category : #specs }
GrafoscopioNewCodeModel class >> defaultSpec [
^ SpBoxLayout newVertical
add: #body;
yourself
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> content: aGrafoscopioNodeContent [
self layout: (self createLayoutFor: aGrafoscopioNodeContent).
body text: (aGrafoscopioNodeContent ifNil: [ '' ])
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> createLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add:
(SpBoxLayout newHorizontal
add:
(SpBoxLayout newVertical
add: #up;
add: #down;
add: #delete;
yourself)
width: 30;
add:
(SpBoxLayout newHorizontal
add: #body;
add: #previewButton width: 30;
add: #preview;
yourself);
yourself)
height: (self heightFor: aGrafoscopioNodeContent)
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> editionLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add:
(SpBoxLayout newHorizontal
add:
(SpBoxLayout newVertical
add: #up;
add: #down;
add: #delete;
yourself)
width: 30;
add:
(SpBoxLayout newHorizontal
add: #body;
add: #previewButton width: 30;
add: #preview;
yourself);
yourself)
height: (self heightFor: aGrafoscopioNodeContent)
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> initializeWidgets [
super initializeWidgets.
previewButton := self newButton.
previewButton icon: (self iconNamed: #smallFind).
previewButton action: [ self previewCode ].
preview := self newLabel
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> newTextComponent [
^ self newCode
whenTextChangedDo: [ model text: body text ];
autoAccept: true;
yourself
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> normalLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add:
(SpBoxLayout newHorizontal
add:
(SpBoxLayout newHorizontal
add: #body;
add: #previewButton width: 30;
add: #preview;
yourself);
yourself)
height: (self heightFor: aGrafoscopioNodeContent)
]
{ #category : #initialization }
GrafoscopioNewCodeModel >> previewCode [
[ preview label: (self class compiler evaluate: body text) asString ]
on: Error
do: [ :e | preview label: e asString]
]

View File

@ -1,83 +0,0 @@
Class {
#name : #GrafoscopioNewTextInputModel,
#superclass : #SpDynamicPresenter,
#instVars : [
'#body',
'#model => SpObservableSlot',
'#onModifyNodeLocationDo'
],
#category : #'Grafoscopio-New-UI'
}
{ #category : #specs }
GrafoscopioNewTextInputModel class >> defaultSpec [
^ SpBoxLayout newVertical
add: #body height: 300;
yourself
]
{ #category : #API }
GrafoscopioNewTextInputModel >> content: aGrafoscopioNodeContent [
self layout: (self createLayoutFor: aGrafoscopioNodeContent).
body text: (aGrafoscopioNodeContent ifNil: [ '' ])
]
{ #category : #API }
GrafoscopioNewTextInputModel >> createLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add: #body
height: (self heightFor: aGrafoscopioNodeContent)
]
{ #category : #'as yet unclassified' }
GrafoscopioNewTextInputModel >> heightFor: aGrafoscopioNodeContent [
^ aGrafoscopioNodeContent
ifNil: [ 100 ]
ifNotNil: [ (aGrafoscopioNodeContent asString lines size * self class toolbarHeight) max: 100 ]
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> informModification [
onModifyNodeLocationDo
ifNotNil: [ onModifyNodeLocationDo cull: self ]
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> initialize [
super initialize.
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> initializePrivateAnnouncements [
super initializePrivateAnnouncements.
self property: #model whenChangedDo: [ self modelChanged ]
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> initializeWidgets [
body := self newTextComponent.
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> model: aModel [
model := aModel
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> modelChanged [
self content: model text.
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> newTextComponent [
^ self newTextInput whenTextChangedDo: [
model text: body text.
self informModification ];
yourself
]
{ #category : #initialization }
GrafoscopioNewTextInputModel >> onModifyNodeLocationDo: aBlock [
onModifyNodeLocationDo := aBlock
]

View File

@ -1,78 +1,77 @@
Class {
#name : #GrafoscopioNewTextModel,
#superclass : #GrafoscopioNewTextInputModel,
#superclass : #SpPresenterWithModel,
#instVars : [
'up',
'down',
'delete',
'editionMode',
'lastHeightUsed'
'body',
'onModifyNodeLocationDo'
],
#category : #'Grafoscopio-New-UI'
}
{ #category : #initialization }
GrafoscopioNewTextModel >> createLayoutFor: aGrafoscopioNodeContent [
lastHeightUsed := (self heightFor: aGrafoscopioNodeContent).
^ editionMode
ifTrue: [ self editionLayoutFor: aGrafoscopioNodeContent ]
ifFalse: [ self normalLayoutFor: aGrafoscopioNodeContent ]
{ #category : #specs }
GrafoscopioNewTextModel class >> defaultSpec [
^ SpBoxLayout newVertical
add: #body;
yourself
]
{ #category : #'as yet unclassified' }
GrafoscopioNewTextModel >> body [
^ body
]
{ #category : #initialization }
GrafoscopioNewTextModel >> editionLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add:
(SpBoxLayout newHorizontal
add:
(SpBoxLayout newVertical
add: #up;
add: #down;
add: #delete;
yourself)
width: 30;
add: #body;
yourself)
height: (self heightFor: aGrafoscopioNodeContent)
GrafoscopioNewTextModel >> contextMenuFromCommandsGroup: aBlock [
^ body contextMenuFromCommandsGroup: aBlock
]
{ #category : #initialization }
GrafoscopioNewTextModel >> informModification [
onModifyNodeLocationDo
ifNotNil: [ onModifyNodeLocationDo cull: self ]
]
{ #category : #initialization }
GrafoscopioNewTextModel >> initialize [
super initialize.
]
{ #category : #initialization }
GrafoscopioNewTextModel >> initializeWidgets [
super initializeWidgets .
editionMode := true.
up := self newButton icon: (self iconNamed: #up) ; color: Color transparent ; yourself .
down := self newButton icon: (self iconNamed: #down) ; color: Color transparent ; yourself .
delete := self newButton icon: (self iconNamed: #delete) ; color: Color transparent ; yourself .
up action: [ model moveUp. self informModification. ].
down action: [ model moveDown. self informModification.].
delete action: [ model remove .self informModification. ]
body := self newText.
body text: self model text.
body whenTextChangedDo: [ self informModification ]
]
{ #category : #initialization }
GrafoscopioNewTextModel >> newTextComponent [
^ self newText
whenTextChangedDo: [ self textChanged ];
autoAccept: true;
yourself
GrafoscopioNewTextModel >> inspectNRun [
body text
inspectRunAt:
(body selectionInterval
ifNil: [ body cursorPositionIndex ]
ifNotNil: [ :i | i first ])
]
{ #category : #initialization }
GrafoscopioNewTextModel >> normalLayoutFor: aGrafoscopioNodeContent [
^ SpBoxLayout newVertical
add: #body
height: (self heightFor: aGrafoscopioNodeContent)
GrafoscopioNewTextModel >> inspectNode [
body text
inspectNodeAt:
(body selectionInterval
ifNil: [ body cursorPositionIndex ]
ifNotNil: [ :i | i first ])
]
{ #category : #'as yet unclassified' }
GrafoscopioNewTextModel >> inspectRuns [
^ self inspectNRun
]
{ #category : #initialization }
GrafoscopioNewTextModel >> textChanged [
model text: body text.
(lastHeightUsed - (self heightFor: model text )) abs
> (lastHeightUsed * 0.1)
ifTrue: [ self modelChanged ]
GrafoscopioNewTextModel >> modelChanged [
body text: self model text.
]
{ #category : #initialization }
GrafoscopioNewTextModel >> toogleEditionMode [
editionMode := editionMode not.
GrafoscopioNewTextModel >> onModifyNodeLocationDo: aBlock [
onModifyNodeLocationDo := aBlock
]

View File

@ -10,7 +10,7 @@ Class {
{ #category : #'as yet unclassified' }
GrafoscopioPerspective class >> defaultPerspective [
^ GrafoscopioDocumentEditionPerspective
^ GrafoscopioDocumentTextEditionPerspective
]
{ #category : #'as yet unclassified' }
@ -31,6 +31,10 @@ GrafoscopioPerspective class >> perspectives [
^ self allSubclasses select: [ : c | c isAbstract not ]
]
{ #category : #initialization }
GrafoscopioPerspective >> aboutToBeInstalled: aTreeNotebook [
]
{ #category : #initialization }
GrafoscopioPerspective >> aboutToBeUninstalledFrom: aTreeNotebook [
]
@ -194,3 +198,10 @@ GrafoscopioPerspective >> subMenu [
{ #category : #'as yet unclassified' }
GrafoscopioPerspective >> updateModel: aModel [
]
{ #category : #initialization }
GrafoscopioPerspective >> viewport: aViewport [
viewport := aViewport.
self buildWithSpec
]

View File

@ -6,27 +6,12 @@ Class {
#superclass : #GrafoscopioAbstractText,
#instVars : [
'ast',
'stringDecorator',
'lastNode',
'runs'
],
#category : #'Grafoscopio-Pillar'
}
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText class >> now [
| pillarAst text presenter |
pillarAst := GrafoscopioPillarASText pillarExample .
text := GrafoscopioPillarASText new.
text ast: pillarAst.
presenter := SpTextPresenter new text: text ; yourself .
presenter autoAccept: true.
presenter whenTextChangedDo: [ : v | presenter violentForceRecompose ].
presenter openWithSpec.
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText class >> openExample [
^ self new
@ -41,7 +26,7 @@ GrafoscopioPillarASText class >> pillarExample [
'!!About Pillar
[[[label=script1|caption=My script that works|language=pharo-image
[[[label=script1|caption=My script that works|language=pharo
PolymorphSystemSettings pharoLogoForm
]]]
@ -103,7 +88,7 @@ Pillar is still in active development: maintainers keep improving its implementa
!!About Pillar
[[[label=script1|caption=My script that works|language=pharo-image
[[[label=script1|caption=My script that works|language=pharo
PolymorphSystemSettings pharoLogoForm
]]]
@ -165,7 +150,7 @@ Pillar is still in active development: maintainers keep improving its implementa
!!About Pillar
[[[label=script1|caption=My script that works|language=pharo-image
[[[label=script1|caption=My script that works|language=pharo
PolymorphSystemSettings pharoLogoForm
]]]
@ -227,7 +212,7 @@ Pillar is still in active development: maintainers keep improving its implementa
!!About Pillar
[[[label=script1|caption=My script that works|language=pharo-image
[[[label=script1|caption=My script that works|language=pharo
PolymorphSystemSettings pharoLogoForm
]]]
@ -288,6 +273,16 @@ Still some issues are missing. Here is a little list of features that we are wor
Pillar is still in active development: maintainers keep improving its implementation. The current version of Pillar is Pillar 70. This booklet only documents Pillar 70. This booklet will be synchronised with future enhancements.'
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> addAttribute: aTextFontChange [
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> addAttribute: att from: start to: stop [
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> ast [
^ ast
@ -295,13 +290,13 @@ GrafoscopioPillarASText >> ast [
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> ast: aPRDocument [
self resetRuns.
lastNode := nil.
ast := aPRDocument.
aPRDocument accept: GrafoscopioPillarTextAnnotator new.
ast start: aPRDocument children first start.
ast stop: aPRDocument children last stop.
stringDecorator := GrafoscopioPillarASTextStringDecorator new
text: self;
yourself
]
{ #category : #accessing }
@ -323,7 +318,7 @@ GrafoscopioPillarASText >> attributesAt: characterIndex do: aBlockClosure [
GrafoscopioPillarASText >> copyFrom: from to: to [
^ (ast textStart = from and: [ ast textStop = (to + 1) ])
ifTrue: [ self ]
ifFalse: [ GrafoscopioPillarASTextStringProjectionDecorator new
ifFalse: [ GrafoscopioPillarASTextStringProjectionAdapter new
text: self;
from: from;
@ -423,7 +418,7 @@ GrafoscopioPillarASText >> extractStringFrom: aPosition to: anOtherPosition [
^ String
streamContents: [ :str |
str nextPutAll: preffix.
(nodes copyFrom: 2 to: nodes size)
(nodes allButFirst)
inject: str
into: [ :stream :each |
stream nextPutAll: each text.
@ -443,6 +438,21 @@ GrafoscopioPillarASText >> fontAt: characterIndex withStyle: aTextStyle [
^ font
]
{ #category : #copying }
GrafoscopioPillarASText >> inspectNodeAt: anIndex [
(self detectAstNodeFor: anIndex) inspect
]
{ #category : #copying }
GrafoscopioPillarASText >> inspectRunAt: anIndex [
(self runs at: anIndex) inspect
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> pillarText [
^ PRPillarWriter write: ast
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASText >> rangeOf: aTextURL startingAt: anInteger [
^ self runs rangeOf: aTextURL startingAt: anInteger
@ -502,6 +512,8 @@ GrafoscopioPillarASText >> replaceFrom: start to: stop with: aCollection [
{ #category : #accessing }
GrafoscopioPillarASText >> resetRuns [
"^ runs := RunArray new."
^ runs := GrafoscopioPillarRuns new
ast: self;
yourself
@ -510,9 +522,8 @@ GrafoscopioPillarASText >> resetRuns [
{ #category : #accessing }
GrafoscopioPillarASText >> runs [
^ runs
ifNil: [ runs := GrafoscopioPillarRuns new
ast: self;
yourself ]
ifNil: [ self resetRuns.
runs ]
]
{ #category : #accessing }
@ -522,5 +533,7 @@ GrafoscopioPillarASText >> size [
{ #category : #accessing }
GrafoscopioPillarASText >> string [
^ stringDecorator
^ GrafoscopioPillarASTextStringAdapter new
text: self;
yourself
]

View File

@ -0,0 +1,80 @@
Class {
#name : #GrafoscopioPillarASTextNotebook,
#superclass : #SpPresenterWithModel,
#instVars : [
'sidebar',
'viewport',
'model',
'empty',
'perspectives'
],
#category : #'Grafoscopio-New-UI'
}
{ #category : #specs }
GrafoscopioPillarASTextNotebook class >> defaultSpec [
^ SpBoxLayout newHorizontal
add:
(SpBoxLayout newVertical
add: #empty height: self toolbarHeight;
add: #sidebar;
yourself)
width: 51;
add: #viewport;
yourself
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextNotebook >> basicInstallPerspective: aPerspective [
viewport ifNotNil: [ viewport aboutToBeUninstalledFrom: self ].
viewport := self perspectives
at: aPerspective
ifAbsentPut: [ self instantiate: aPerspective on: model document ].
]
{ #category : #initialization }
GrafoscopioPillarASTextNotebook >> createDefaultComponent [
^ self basicInstallPerspective: GrafoscopioPerspective defaultPerspective
]
{ #category : #initialization }
GrafoscopioPillarASTextNotebook >> initializeWidgets [
super initializeWidgets.
sidebar := self sidebar.
self createDefaultComponent.
empty := self newLabel.
]
{ #category : #initialization }
GrafoscopioPillarASTextNotebook >> installPerspective: aPerspective [
self basicInstallPerspective: aPerspective .
self modelChanged
]
{ #category : #initialization }
GrafoscopioPillarASTextNotebook >> modelChanged [
viewport modelChanged.
self needRebuild: false.
self buildWithSpec
]
{ #category : #initialization }
GrafoscopioPillarASTextNotebook >> perspectives [
^ perspectives ifNil: [ perspectives := Dictionary new ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextNotebook >> setModelBeforeInitialization: aDomainObject [
super setModelBeforeInitialization: aDomainObject.
model := aDomainObject
]
{ #category : #initialization }
GrafoscopioPillarASTextNotebook >> sidebar [
| bar |
bar := self instantiate: SpSidebar.
GrafoscopioPerspective perspectives
do:
[ :p | bar addAction: [ self installPerspective: p ] icon: p icon ].
^ bar
]

View File

@ -0,0 +1,205 @@
Class {
#name : #GrafoscopioPillarASTextStringAdapter,
#superclass : #ProtoObject,
#instVars : [
'text'
],
#category : #'Grafoscopio-Pillar'
}
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> allRangesOfSubstring: aSubstring [
^ Array streamContents: [:s | | start subSize |
start := 1.
subSize := aSubstring size.
[start isZero]
whileFalse: [ start := self findString: aSubstring startingAt: start.
start > 0
ifTrue: [s nextPut: (start to: start + subSize - 1).
start := start + subSize]]]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> asString [
^ self
]
{ #category : #accessing }
GrafoscopioPillarASTextStringAdapter >> at: aNumber [
^ text at: aNumber
]
{ #category : #accessing }
GrafoscopioPillarASTextStringAdapter >> at: aNumber put: aChar [
self halt
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> copyFrom: one to: two [
^ text copyFrom: one to: two
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> findString: key startingAt: start [
^ self findString: key startingAt: start caseSensitive: true
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> findString: key startingAt: start caseSensitive: caseSensitive [
"Answer the index in this String at which the substring key first occurs,
at or beyond start. The match can be case-sensitive or not. If no match
is found, zero will be returned."
"IMPLEMENTATION NOTE: do not use CaseSensitiveOrder because it is broken for WideString
This is a temporary work around until Wide CaseSensitiveOrder search is fixed
Code should revert to:
caseSensitive
ifTrue: [^ self findSubstring: key in: self startingAt: start matchTable: CaseSensitiveOrder]
ifFalse: [^ self findSubstring: key in: self startingAt: start matchTable: CaseInsensitiveOrder]"
^ caseSensitive
ifTrue: [ WideString new
findSubstring: key
in: self
startingAt: start
matchTable: nil ]
ifFalse: [ WideString new
findSubstring: key
in: self
startingAt: start
matchTable: String newCaseInsensitiveOrder ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> ifEmpty: aBlock [
"Evaluate the given block, answering its value if the receiver is empty, otherwise answer the receiver."
"Note that the fact that this method returns its receiver in case the receiver is not empty allows one to write expressions like the following ones: self classifyMethodAs: (myProtocol ifEmpty: ['As yet unclassified'])"
^ self isEmpty
ifTrue: [ aBlock value ]
ifFalse: [ self ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> ifEmpty: emptyBlock ifNotEmpty: notEmptyBlock [
"Evaluate emptyBlock if I'm empty, notEmptyBlock otherwise"
"If the notEmptyBlock has an argument, eval with the receiver as its argument"
^ self isEmpty
ifTrue: [ emptyBlock value ]
ifFalse: [ notEmptyBlock cull: self ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> indexOf: aCharacter startingAt: anInteger ifAbsent: aBlockClosure [
| current index |
current := text detectAstNodeFor: anInteger.
index := current text
indexOf: aCharacter
startingAt: anInteger - current textStart + 1.
current := current next.
[ current isNotNil ]
whileTrue: [ index := current text indexOf: aCharacter.
index = 0
ifTrue: [ current := current next ]
ifFalse: [ ^ current textStart + index ] ].
^ aBlockClosure value
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> isByteString [
^ false
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> isEmpty [
^ text isEmpty
]
{ #category : #accessing }
GrafoscopioPillarASTextStringAdapter >> isReadOnlyObject [
"Answer if the receiver is read-only.
If the VM supports read-only objects it will not write to read-only objects.
An attempt to write to an instance variable of a read-only object will
cause the VM to send attemptToAssign:withIndex: to the read-only object.
An attempt to modify a read-only object in a primitive will cause the
primitive to fail with a #'no modification' error code."
<primitive: 163 error: ec>
^self class isImmediateClass
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> isString [
^ true
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> isWideString [
^ true
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> lastIndexOf: anElement startingAt: lastIndex ifAbsent: exceptionBlock [
"Answer the index of the last occurence of anElement within the
receiver. If the receiver does not contain anElement, answer the
result of evaluating the argument, exceptionBlock."
lastIndex to: 1 by: -1 do: [ :index |
(self at: index) = anElement
ifTrue: [ ^ index ] ].
^ exceptionBlock value
]
{ #category : #accessing }
GrafoscopioPillarASTextStringAdapter >> notEmpty [
^ text notEmpty
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> printOn: aStream [
aStream
nextPutAll: 'StringAdaptor(';
nextPutAll: self size asString;
nextPutAll: ')'
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> printString [
^ String streamContents: [ :str | self printOn: str ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> readStream [
^ ReadStream on: self
]
{ #category : #accessing }
GrafoscopioPillarASTextStringAdapter >> size [
^ text size
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> string [
^ text extractStringFrom: 1 to: self size
]
{ #category : #accessing }
GrafoscopioPillarASTextStringAdapter >> text: aGFPText [
text := aGFPText
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> trimBoth [
^ self
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> yourself [
^ self
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringAdapter >> ~= anOther [
^ (self == anOther) not
]

View File

@ -1,74 +0,0 @@
Class {
#name : #GrafoscopioPillarASTextStringDecorator,
#superclass : #Object,
#instVars : [
'text'
],
#category : #'Grafoscopio-Pillar'
}
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> at: aNumber [
^ text at: aNumber
]
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> at: aNumber put: aChar [
self halt
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringDecorator >> copyFrom: one to: two [
^ text copyFrom: one to: two
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringDecorator >> indexOf: aCharacter startingAt: anInteger ifAbsent: aBlockClosure [
| current index |
current := text detectAstNodeFor: anInteger.
index := current text
indexOf: aCharacter
startingAt: anInteger - current textStart + 1.
current := current next.
[ current isNotNil ]
whileTrue: [ index := current text indexOf: aCharacter.
index = 0
ifTrue: [ current := current next ]
ifFalse: [ ^ current textStart + index ] ].
^ aBlockClosure value
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringDecorator >> isByteString [
^ false
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringDecorator >> isEmpty [
^ text isEmpty
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringDecorator >> isWideString [
^ true
]
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> notEmpty [
^ text notEmpty
]
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> size [
^ text size
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringDecorator >> string [
self shouldBeImplemented.
]
{ #category : #accessing }
GrafoscopioPillarASTextStringDecorator >> text: aGFPText [
text := aGFPText
]

View File

@ -0,0 +1,69 @@
Class {
#name : #GrafoscopioPillarASTextStringProjectionAdapter,
#superclass : #GrafoscopioPillarASTextStringAdapter,
#instVars : [
'from',
'to',
'cached'
],
#category : #'Grafoscopio-Pillar'
}
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionAdapter >> asText [
^ self string asText
]
{ #category : #accessing }
GrafoscopioPillarASTextStringProjectionAdapter >> at: anInteger [
^ self cached at: anInteger
]
{ #category : #accessing }
GrafoscopioPillarASTextStringProjectionAdapter >> cached [
^ cached ifNil: [ cached := text extractStringFrom: from to: to ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionAdapter >> copyFrom: one to: two [
^ self class new
text: text;
from: from + one;
to: from + two;
yourself
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionAdapter >> from: anInteger [
from := anInteger
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionAdapter >> isEmpty [
^ to <= from
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionAdapter >> printOn: aStream [
aStream
nextPutAll: 'SubStringAdapter(';
nextPutAll: from asString;
nextPutAll: ':';
nextPutAll: to asString;
nextPutAll: ')'
]
{ #category : #accessing }
GrafoscopioPillarASTextStringProjectionAdapter >> size [
^ to - from
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionAdapter >> string [
^ text extractStringFrom: from to: to
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionAdapter >> to: anInteger [
to := anInteger
]

View File

@ -1,64 +0,0 @@
Class {
#name : #GrafoscopioPillarASTextStringProjectionDecorator,
#superclass : #GrafoscopioPillarASTextStringDecorator,
#instVars : [
'from',
'to',
'cached'
],
#category : #'Grafoscopio-Pillar'
}
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> allRangesOfSubstring: aString [
^ { }
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> asText [
^ self string asText
]
{ #category : #accessing }
GrafoscopioPillarASTextStringProjectionDecorator >> at: anInteger [
^ self cached at: anInteger
]
{ #category : #accessing }
GrafoscopioPillarASTextStringProjectionDecorator >> cached [
^ cached ifNil: [ cached := text extractStringFrom: from to: to ]
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> copyFrom: one to: two [
^ self class new
text: text;
from: from + one;
to: from + two;
yourself
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> from: anInteger [
from := anInteger
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> isEmpty [
^ from <= to
]
{ #category : #accessing }
GrafoscopioPillarASTextStringProjectionDecorator >> size [
^ to - from
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> string [
^ text extractStringFrom: from to: to
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarASTextStringProjectionDecorator >> to: anInteger [
to := anInteger
]

View File

@ -0,0 +1,40 @@
Class {
#name : #GrafoscopioPillarNode,
#superclass : #GrafoscopioLeafNode,
#instVars : [
'ast',
'astText'
],
#category : #'Grafoscopio-Model'
}
{ #category : #testing }
GrafoscopioPillarNode class >> icon [
^ self iconNamed: #workspace
]
{ #category : #testing }
GrafoscopioPillarNode class >> nameForSelection [
^ 'New Pillar node'
]
{ #category : #testing }
GrafoscopioPillarNode class >> showInMenu [
^ true
]
{ #category : #accessing }
GrafoscopioPillarNode >> acceptVisitor: aGrafoscopioVisitor [
aGrafoscopioVisitor visitPillarNode: self.
]
{ #category : #accessing }
GrafoscopioPillarNode >> text [
^ astText
]
{ #category : #accessing }
GrafoscopioPillarNode >> text: anAst [
astText := anAst
]

View File

@ -23,8 +23,8 @@ GrafoscopioPillarRuns >> at: anIndex [
anIndex > ast size
ifTrue: [ ^ Array empty ].
newBranch := ast detectFullBranchFor: anIndex.
newBranch = lastBranch
ifTrue: [ ^ lastAttributes ].
"newBranch = lastBranch
ifTrue: [ ^ lastAttributes ]."
lastAttributes := self
calculateAttributesForBranch: newBranch
at: anIndex.
@ -56,12 +56,6 @@ GrafoscopioPillarRuns >> rangeOf: aTextURL startingAt: anInteger [
^ 0 to: 0
]
{ #category : #'basic api' }
GrafoscopioPillarRuns >> reset [
lastAttributes := nil.
lastBranch := nil.
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarRuns >> runLengthFor: anInteger [
| node |

View File

@ -71,7 +71,7 @@ GrafoscopioPillarStyler >> attributesForLineBreak: aPRLineBreak [
{ #category : #'as yet unclassified' }
GrafoscopioPillarStyler >> attributesForListItem: aPRListItem at: index [
^ (aPRListItem text at: index - aPRListItem textStart + 1) = Character home
ifTrue: [ {(TextIndent tabs: aPRListItem level).
ifTrue: [ {(TextIndent tabs: aPRListItem parent level).
(TextAnchor new
anchoredMorph: (self iconNamed: #menuPin);
yourself)} ] ifFalse: [ { } ]

View File

@ -0,0 +1,37 @@
Class {
#name : #GrafoscopioPillarToTextDecorator,
#superclass : #Object,
#instVars : [
'pillarNode'
],
#category : #'Grafoscopio-Pillar'
}
{ #category : #'instance creation' }
GrafoscopioPillarToTextDecorator class >> on: aGFPillarNode [
^ self new
pillarNode: aGFPillarNode;
yourself
]
{ #category : #'as yet unclassified' }
GrafoscopioPillarToTextDecorator >> name [
^ pillarNode name
]
{ #category : #accessing }
GrafoscopioPillarToTextDecorator >> pillarNode: aNode [
pillarNode := aNode
]
{ #category : #accessing }
GrafoscopioPillarToTextDecorator >> text [
^ pillarNode text pillarText
]
{ #category : #accessing }
GrafoscopioPillarToTextDecorator >> text: aText [
| parsed |
parsed := PRPillarParser parse: aText.
^ pillarNode text ast: parsed
]

View File

@ -8,6 +8,11 @@ Class {
#category : #'Grafoscopio-Model'
}
{ #category : #'as yet unclassified' }
GrafoscopioProject >> acceptVisitor: aGrafoscopioViewportTextVisitor [
aGrafoscopioViewportTextVisitor visitGrafoscopioProject: self
]
{ #category : #'as yet unclassified' }
GrafoscopioProject >> document [
^ document

View File

@ -30,6 +30,7 @@ GrafoscopioTreeNotebook >> basicInstallPerspective: aPerspective [
viewport := self perspectives
at: aPerspective
ifAbsentPut: [ self instantiate: aPerspective on: model document ].
viewport aboutToBeInstalled: self.
]
{ #category : #initialization }
@ -63,6 +64,11 @@ GrafoscopioTreeNotebook >> perspectives [
^ perspectives ifNil: [ perspectives := Dictionary new ]
]
{ #category : #'as yet unclassified' }
GrafoscopioTreeNotebook >> removePerspective: aPerspective [
perspectives removeKeyAtValue: aPerspective
]
{ #category : #'as yet unclassified' }
GrafoscopioTreeNotebook >> setModelBeforeInitialization: aDomainObject [
super setModelBeforeInitialization: aDomainObject.

View File

@ -1,97 +0,0 @@
"
URL Node downloads content for rendering.
"
Class {
#name : #GrafoscopioUrlNode,
#superclass : #GrafoscopioLeafNode,
#instVars : [
'link'
],
#category : #'Grafoscopio-Model'
}
{ #category : #'instance creation' }
GrafoscopioUrlNode class >> icon [
^ self iconNamed: #remote
]
{ #category : #'instance creation' }
GrafoscopioUrlNode class >> nameForSelection [
^ 'New URL Node'
]
{ #category : #'instance creation' }
GrafoscopioUrlNode class >> new [
^ super new
content;
yourself
]
{ #category : #'instance creation' }
GrafoscopioUrlNode class >> showInMenu [
^ true
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> acceptVisitor: aGrafoscopioVisitor [
aGrafoscopioVisitor visitUrlNode: self.
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> content [
^ (self url
ifNil: [ ' Invalid url ' ]
ifNotNil: [ :url | self fetchContent: url ])
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> fetchContent: anUrl [
^ (ZnEasy get: anUrl) entity contents
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> getUrl [
| url |
url := UIManager default
request: 'Please insert a url '
initialAnswer: 'http://'
title: 'URL Node'.
url ifNil: [ ^ nil ].
url := url asZnUrl.
(url host isEmptyOrNil
or: [ url scheme isEmptyOrNil or: [ url authority isEmptyOrNil ] ])
ifTrue: [ ^ nil ].
^ url
]
{ #category : #accessing }
GrafoscopioUrlNode >> link: aZnUrl [
link := aZnUrl
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> openIn: aNotebook [
super openIn: aNotebook.
aNotebook links text: (link ifNil: 'Invalid url') asString
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> shouldAskBeforeRemove [
^ false
]
{ #category : #content }
GrafoscopioUrlNode >> text [
^ self content
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> text: aString [
]
{ #category : #'as yet unclassified' }
GrafoscopioUrlNode >> url [
^ link ifNil: [ link := self getUrl ]
]

View File

@ -0,0 +1,18 @@
Class {
#name : #GrafoscopioViewportRichTextVisitor,
#superclass : #GrafoscopioViewportTextVisitor,
#category : #'Grafoscopio-New-UI'
}
{ #category : #'as yet unclassified' }
GrafoscopioViewportRichTextVisitor >> visitPillarNode: aNode [
self
showPageFor: aNode
ifProviderDoestExistInstall: [ | text |
text := presenter instantiate: GrafoscopioNewTextModel on: aNode.
text
contextMenuFromCommandsGroup: [ presenter rootCommandsGroup / 'Context Menu' ].
text
onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
text ]
]

View File

@ -0,0 +1,60 @@
Class {
#name : #GrafoscopioViewportTextVisitor,
#superclass : #GrafoscopioVisitor,
#instVars : [
'viewport',
'stack',
'presenter',
'pages'
],
#category : #'Grafoscopio-New-UI'
}
{ #category : #visiting }
GrafoscopioViewportTextVisitor >> createViewportFor: aDocumentNode into: aPresenter [
presenter := aPresenter.
aDocumentNode acceptVisitor: self.
^ viewport
]
{ #category : #visiting }
GrafoscopioViewportTextVisitor >> initialize [
super initialize.
pages := Dictionary new
]
{ #category : #'as yet unclassified' }
GrafoscopioViewportTextVisitor >> renamePageFor: aNode [
pages at: aNode ifPresent: [ : p | p title: aNode name ]
]
{ #category : #'as yet unclassified' }
GrafoscopioViewportTextVisitor >> showPageFor: aNode ifProviderDoestExistInstall: aBlock [
| page |
page := pages at: aNode ifAbsentPut: [ aBlock value ].
presenter viewport: page
]
{ #category : #'as yet unclassified' }
GrafoscopioViewportTextVisitor >> visitPillarNode: aGrafoscopioPillarNode [
self
showPageFor: aGrafoscopioPillarNode
ifProviderDoestExistInstall: [ | text |
text := presenter
instantiate: GrafoscopioNewTextModel
on: (GrafoscopioPillarToTextDecorator on: aGrafoscopioPillarNode).
text
onModifyNodeLocationDo: [ :model | model model text: model body text ].
text ]
]
{ #category : #visiting }
GrafoscopioViewportTextVisitor >> visitTextNode: aNode [
self
showPageFor: aNode
ifProviderDoestExistInstall: [ | text |
text := presenter instantiate: GrafoscopioNewTextModel on: aNode.
text
onModifyNodeLocationDo: [ :model | model model text: model body text ].
text ]
]

View File

@ -1,77 +0,0 @@
Class {
#name : #GrafoscopioViewportVisitor,
#superclass : #GrafoscopioVisitor,
#instVars : [
'viewport',
'stack',
'items',
'presenter'
],
#category : #'Grafoscopio-New-UI'
}
{ #category : #visiting }
GrafoscopioViewportVisitor >> createViewportFor: aDocumentNode into: aPresenter [
presenter := aPresenter.
items := OrderedCollection new.
aDocumentNode acceptVisitor: self.
viewport := aPresenter viewport
ifNil: [ aPresenter instantiate: SpComponentListPresenter ].
viewport items: items.
^ viewport
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitCodeNode: aNode [
| code |
code := presenter instantiate: GrafoscopioNewCodeModel.
code onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
code model: aNode.
items add: code.
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitRootNode: aNode [
| text |
text := presenter instantiate: GrafoscopioNewTextInputModel.
text model: aNode.
text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
items add: text.
super visitRootNode: aNode.
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitTextNode: aNode [
| text |
text := presenter instantiate: GrafoscopioNewTextModel.
text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
text model: aNode.
items add: text.
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitUnitNode: aNode [
| text |
text := presenter instantiate: GrafoscopioNewTextInputModel.
text model: aNode.
text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
items add: text.
items add: (presenter newButton
label: ' Add node on the beginning ';
action: [ presenter addNewNodeAtBeginningOf: aNode ];
yourself).
super visitUnitNode: aNode.
items add: (presenter newButton
label: ' Add node on the end ';
action: [ presenter addNewNodeAtLastOf: aNode ];
yourself)
]
{ #category : #visiting }
GrafoscopioViewportVisitor >> visitUrlNode: aNode [
| text |
text := presenter instantiate: GrafoscopioNewTextInputModel.
text onModifyNodeLocationDo: [ presenter informNodeHasChanged: aNode ].
text model: aNode.
items add: text.
]

View File

@ -10,9 +10,10 @@ GrafoscopioVisitor >> visitBranchNode: aNode [
aNode children do: [ : c | c acceptVisitor: self ].
]
{ #category : #visiting }
GrafoscopioVisitor >> visitCodeNode: aNode [
self visitNode: aNode
{ #category : #'as yet unclassified' }
GrafoscopioVisitor >> visitGrafoscopioProject: aGrafoscopioProject [
self visitNode: aGrafoscopioProject .
aGrafoscopioProject document acceptVisitor: self.
]
{ #category : #visiting }
@ -41,8 +42,3 @@ GrafoscopioVisitor >> visitUnitNode: aNode [
self visitNode: aNode.
aNode children do: [ : c | c acceptVisitor: self ].
]
{ #category : #visiting }
GrafoscopioVisitor >> visitUrlNode: aNode [
self visitNode: aNode
]

View File

@ -42,7 +42,7 @@ PRLineBreak >> text: aString [
{ #category : #'*Grafoscopio' }
PRLineBreak >> textSize [
^ self text size
^ 1
]
{ #category : #'*Grafoscopio' }