diff --git a/src/InteractiveNotebookPresenter/Collection.extension.st b/src/InteractiveNotebookPresenter/Collection.extension.st new file mode 100644 index 0000000..e03b159 --- /dev/null +++ b/src/InteractiveNotebookPresenter/Collection.extension.st @@ -0,0 +1,29 @@ +Extension { #name : #Collection } + +{ #category : #'*InteractiveNotebookPresenter' } +Collection >> generateMicrodownListOn: aStream using: aGenerationHelper [ + + self do: [ :el | + (el isKindOf: self class) + ifTrue: [ + aGenerationHelper listLevelIncrement. + el generateMicrodownListOn: aStream using: aGenerationHelper. + aGenerationHelper listLevelDecrement ] + ifFalse: [ + 0 to: aGenerationHelper listLevel do: [ :i | + aStream nextPut: Character tab ]. + aStream nextPutAll: '- '. + aStream nextPutAll: + (el generateMicrodownUsingHelper: aGenerationHelper). + aStream nextPut: Character cr ] ] +] + +{ #category : #'*InteractiveNotebookPresenter' } +Collection >> generateMicrodownUsingHelper: aGenerationHelper [ + + | text | + aGenerationHelper listLevel: 0. + text := String streamContents: [ :s | + self generateMicrodownListOn: s using: aGenerationHelper ]. + ^ text +] diff --git a/src/InteractiveNotebookPresenter/INAbstractReportPrinter.class.st b/src/InteractiveNotebookPresenter/INAbstractReportPrinter.class.st deleted file mode 100644 index 444af61..0000000 --- a/src/InteractiveNotebookPresenter/INAbstractReportPrinter.class.st +++ /dev/null @@ -1,35 +0,0 @@ -Class { - #name : #INAbstractReportPrinter, - #superclass : #Object, - #instVars : [ - 'micBuilder', - 'stream' - ], - #category : #InteractiveNotebookPresenter -} - -{ #category : #printing } -INAbstractReportPrinter >> initialize [ - - super initialize. - micBuilder := Microdown builder. -] - -{ #category : #printing } -INAbstractReportPrinter >> print: aCollection [ - - self shouldBeImplemented -] - -{ #category : #accessing } -INAbstractReportPrinter >> stream [ - - ^ stream -] - -{ #category : #accessing } -INAbstractReportPrinter >> stream: anObject [ - - stream := anObject. - micBuilder setStream: stream -] diff --git a/src/InteractiveNotebookPresenter/INNotebookAbstractCellModel.class.st b/src/InteractiveNotebookPresenter/INNotebookAbstractCellModel.class.st index ef2377e..79835e4 100644 --- a/src/InteractiveNotebookPresenter/INNotebookAbstractCellModel.class.st +++ b/src/InteractiveNotebookPresenter/INNotebookAbstractCellModel.class.st @@ -1,40 +1,94 @@ -Class { - #name : #INNotebookAbstractCellModel, - #superclass : #Object, - #instVars : [ - 'text', - 'model' - ], - #category : #InteractiveNotebookPresenter -} - -{ #category : #initialization } -INNotebookAbstractCellModel >> initialize [ - - super initialize. - text := String empty -] - -{ #category : #helpers } -INNotebookAbstractCellModel >> presenterClass [ - - self subclassResponsibility -] - -{ #category : #printing } -INNotebookAbstractCellModel >> printContentIn: aStream withContext: aContext [ - - self subclassResponsibility -] - -{ #category : #accessing } -INNotebookAbstractCellModel >> text [ - - ^ text -] - -{ #category : #accessing } -INNotebookAbstractCellModel >> text: anObject [ - - text := anObject -] +" +I am an abstract editor cell model. + +I have an instance variable `needToUpdate` that is set to true if a preview cell was never created for me (i.e. if I was never compiled) or if I was modified after having created a preview cell. +It is set to false otherwise, this way I don't have to be recompiled or to create a new preview cell. + +I am responsible for the compilation of the content in my presenter's text input. +" +Class { + #name : #INNotebookAbstractCellModel, + #superclass : #Object, + #instVars : [ + 'text', + 'needToUpdate', + 'previewCell' + ], + #category : #InteractiveNotebookPresenter +} + +{ #category : #ston } +INNotebookAbstractCellModel class >> stonAllInstVarNames [ + ^ super stonAllInstVarNames \ { #needToUpdate. #previewCell } +] + +{ #category : #converting } +INNotebookAbstractCellModel >> beCodeModel [ + ^ self subclassResponsibility +] + +{ #category : #converting } +INNotebookAbstractCellModel >> beTextModel [ + ^ self subclassResponsibility +] + +{ #category : #printing } +INNotebookAbstractCellModel >> getContentwithContext: aContext [ + + ^ self subclassResponsibility +] + +{ #category : #initialization } +INNotebookAbstractCellModel >> initialize [ + + super initialize. + needToUpdate := true. + text := String empty +] + +{ #category : #accessing } +INNotebookAbstractCellModel >> needToUpdate [ + ^ needToUpdate +] + +{ #category : #accessing } +INNotebookAbstractCellModel >> needToUpdate: aBoolean [ + needToUpdate := aBoolean +] + +{ #category : #helpers } +INNotebookAbstractCellModel >> presenterClass [ + + self subclassResponsibility +] + +{ #category : #accessing } +INNotebookAbstractCellModel >> previewCell [ + + ^ previewCell +] + +{ #category : #accessing } +INNotebookAbstractCellModel >> previewCell: anObject [ + + previewCell := anObject +] + +{ #category : #printing } +INNotebookAbstractCellModel >> printContentIn: aStream withContext: aContext [ + + self subclassResponsibility +] + +{ #category : #accessing } +INNotebookAbstractCellModel >> text [ + + ^ text +] + +{ #category : #accessing } +INNotebookAbstractCellModel >> text: anObject [ + + (text = anObject) ifFalse: [ self needToUpdate: true ]. + text := anObject +] diff --git a/src/InteractiveNotebookPresenter/INNotebookAbstractCellPresenter.class.st b/src/InteractiveNotebookPresenter/INNotebookAbstractCellPresenter.class.st index 5f15b21..66ddee7 100644 --- a/src/InteractiveNotebookPresenter/INNotebookAbstractCellPresenter.class.st +++ b/src/InteractiveNotebookPresenter/INNotebookAbstractCellPresenter.class.st @@ -1,306 +1,322 @@ -Class { - #name : #INNotebookAbstractCellPresenter, - #superclass : #SpPresenter, - #instVars : [ - 'cell', - 'icon', - 'notebook', - 'removeButton', - 'leftMenuCanvas', - 'rightMenuCanvas', - 'deleteButton', - 'addCellBellowButton', - 'addCellAboveButton', - 'moveCellUp', - 'moveCellDown', - 'previewCell' - ], - #category : #InteractiveNotebookPresenter -} - -{ #category : #converting } -INNotebookAbstractCellPresenter >> asModelCell [ - - self subclassResponsibility -] - -{ #category : #api } -INNotebookAbstractCellPresenter >> beCode [ - - self subclassResponsibility -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> beSelected [ - - notebook select: self. - previewCell ifNotNil: [ :c | c beSelected ] -] - -{ #category : #api } -INNotebookAbstractCellPresenter >> beText [ - - self subclassResponsibility -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> beUnselected [ - - leftMenuCanvas canvas color: self unselectedColor. - leftMenuCanvas canvas signalUpdate. - rightMenuCanvas canvas color: self unselectedColor. - rightMenuCanvas canvas signalUpdate -] - -{ #category : #accessing } -INNotebookAbstractCellPresenter >> cell [ - - ^ cell -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> createDescriptionFor: aString [ - - ^ aString asTextMorph - backgroundColor: (Color white alpha: 0.6); - borderColor: Color gray; - textColor: Color black; - borderWidth: 1; - margins: 2; - yourself -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> iconNamed: anIconName [ - - INNotebookIcons icons - at: anIconName - ifPresent: [ :found | ^ found ]. - ^ super iconNamed: anIconName -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> initializeLayout [ - - self layout: (SpBoxLayout newLeftToRight - add: leftMenuCanvas width: 30; - add: cell; - add: rightMenuCanvas width: 100; - yourself) -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> initializePresenters [ - - | buttons menu | - self whenDisplayDo: [ - self withAdapterDo: [ - self adapter children second textArea announcer - when: MorphGotFocus - do: [ self selectMe ] ]. - self updateHeight ]. - removeButton := self newButton - icon: (Smalltalk ui iconNamed: #remove); - action: [ self remove ]. - leftMenuCanvas := self newRoassal. - leftMenuCanvas canvas color: self unselectedColor. - rightMenuCanvas := self newRoassal. - rightMenuCanvas canvas color: Color transparent. - deleteButton := RSBitmap new - form: (self iconNamed: #trash); - model: 'Delete'; - size: 16; - yourself. - deleteButton when: RSMouseClick do: [ self remove ]. - - addCellBellowButton := RSBitmap new - form: (self iconNamed: #addBelow); - model: 'Add after'; - size: 16; - yourself. - addCellAboveButton := RSBitmap new - form: (self iconNamed: #addAbove); - model: 'Add before'; - size: 16; - yourself. - moveCellUp := RSBitmap new - form: (self iconNamed: #up); - model: 'Move up cell'; - size: 16; - yourself. - moveCellDown := RSBitmap new - form: (self iconNamed: #down); - model: 'Move down cell'; - size: 16; - yourself. - buttons := RSGroup withAll: { - moveCellUp. - moveCellDown. - addCellBellowButton. - addCellAboveButton. - - deleteButton }. - buttons @ (RSMorphicPopupInteraction new - morphBuilder: [ :model | self createDescriptionFor: model ]; - yourself). - RSHorizontalLineLayout new - alignMiddle; - horizontalGap: 2; - on: buttons. - menu := RSComposite new - addAll: buttons; - isFixed: true; - color: Color transparent; - translateBy: 50 @ 14; - yourself. - - rightMenuCanvas canvas add: menu. - menu adjustToChildren. - menu padding: 10. - moveCellUp when: RSMouseClick do: [ self moveUp ]. - moveCellDown when: RSMouseClick do: [ self moveDown ]. - addCellBellowButton - when: RSMouseClick - do: [ notebook addTextCellAfter: self ]. - addCellAboveButton - when: RSMouseClick - do: [ notebook addTextCellBefore: self ] -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> moveDown [ - - notebook moveDown: self -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> moveUp [ - - notebook moveUp: self -] - -{ #category : #accessing } -INNotebookAbstractCellPresenter >> notebook [ - - ^ notebook -] - -{ #category : #accessing } -INNotebookAbstractCellPresenter >> notebook: anObject [ - - notebook := anObject -] - -{ #category : #accessing } -INNotebookAbstractCellPresenter >> previewCell [ - - ^ previewCell -] - -{ #category : #accessing } -INNotebookAbstractCellPresenter >> previewCell: anObject [ - - previewCell := anObject -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> remove [ - - notebook removeCell: self -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> select [ - - self takeKeyboardFocus. - leftMenuCanvas canvas color: self selectedColor. - leftMenuCanvas canvas signalUpdate. - rightMenuCanvas canvas color: self selectedColor. - rightMenuCanvas canvas signalUpdate -] - -{ #category : #actions } -INNotebookAbstractCellPresenter >> selectAndScrollToMe [ - - notebook selectAndScrollTo: self -] - -{ #category : #actions } -INNotebookAbstractCellPresenter >> selectMe [ - - notebook select: self. - previewCell ifNotNil: [ :c | c selectAndScrollToMe ] -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> selectedColor [ - - ^ Color fromHexString: '77A8C8' -] - -{ #category : #protocol } -INNotebookAbstractCellPresenter >> takeKeyboardFocus [ - - cell takeKeyboardFocus -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> text [ - - ^ cell text -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> text: aText [ - - cell text: aText -] - -{ #category : #accessing } -INNotebookAbstractCellPresenter >> textAreaWidth [ - - self layout adapter ifNil: [ ^ -1 ]. - ^ self layout adapter children second width -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> unselect [ - - self beUnselected -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> unselectedColor [ - - ^ Color transparent -] - -{ #category : #initialization } -INNotebookAbstractCellPresenter >> updateHeight [ - - UIManager default defer: [ - notebook headerSep withAdapterDo: [ :a | - cell withAdapterDo: [ :b | - | textMorph height width | - textMorph := b widget. - textMorph - borderColor: Color gray translucent; - borderWidth: 1. - textMorph scrollPane - vHideScrollbar; - vScrollbarShowNever. - width := a widget width. - textMorph scrollPane textArea withoutSelectionBar. - height := (RubEditingArea new - font: textMorph font; - width: width - 182; - beWrapped; - updateTextWith: cell text) height. - self withAdapterDo: [ :c | c widget height: height + 2 ] ] ] ] -] - -{ #category : #enumerating } -INNotebookAbstractCellPresenter >> whenTextChangedDo: aBlock [ - - cell whenTextChangedDo: aBlock -] +" +I am an abstract editing cell presenter. + +I have a presenter providing a text input (`cellTextInput`) in which the user can type Microdown text or code, depending on the cell type. + +I give to my children buttons allowing to transform themselves from code cell to text cell and vice versa, to add a new text cell before or after the current cell, to move the cell up or down in the notebook, and one to delete the current cell. + + + + +" +Class { + #name : #INNotebookAbstractCellPresenter, + #superclass : #SpPresenterWithModel, + #instVars : [ + 'icon', + 'notebook', + 'removeButton', + 'leftMenuCanvas', + 'rightMenuCanvas', + 'deleteButton', + 'addCellBellowButton', + 'addCellAboveButton', + 'moveCellUp', + 'moveCellDown', + 'previewCell', + 'cellTextInput' + ], + #category : #InteractiveNotebookPresenter +} + +{ #category : #converting } +INNotebookAbstractCellPresenter >> asModelCell [ + + self subclassResponsibility +] + +{ #category : #api } +INNotebookAbstractCellPresenter >> beCode [ + + self subclassResponsibility +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> beSelected [ + + notebook select: self. + previewCell ifNotNil: [ :c | c beSelected ] +] + +{ #category : #api } +INNotebookAbstractCellPresenter >> beText [ + + self subclassResponsibility +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> beUnselected [ + + leftMenuCanvas canvas color: self unselectedColor. + leftMenuCanvas canvas signalUpdate. + rightMenuCanvas canvas color: self unselectedColor. + rightMenuCanvas canvas signalUpdate +] + +{ #category : #accessing } +INNotebookAbstractCellPresenter >> cellTextInput [ + + ^ cellTextInput +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> createDescriptionFor: aString [ + + ^ aString asTextMorph + backgroundColor: (Color white alpha: 0.6); + borderColor: Color gray; + textColor: Color black; + borderWidth: 1; + margins: 2; + yourself +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> iconNamed: anIconName [ + + INNotebookIcons icons + at: anIconName + ifPresent: [ :found | ^ found ]. + ^ super iconNamed: anIconName +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> initializeLayout [ + + self layout: (SpBoxLayout newLeftToRight + add: leftMenuCanvas width: 30; + add: cellTextInput; + add: rightMenuCanvas width: 100; + yourself) +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> initializePresenters [ + + | buttons menu | + self whenDisplayDo: [ + self withAdapterDo: [ + self adapter children second textArea announcer + when: MorphGotFocus + do: [ self selectMe ] ]. + self updateHeight ]. + removeButton := self newButton + icon: (Smalltalk ui iconNamed: #remove); + action: [ self remove ]. + leftMenuCanvas := self newRoassal. + leftMenuCanvas canvas color: self unselectedColor. + rightMenuCanvas := self newRoassal. + rightMenuCanvas canvas color: Color transparent. + deleteButton := RSBitmap new + form: (self iconNamed: #trash); + model: 'Delete'; + size: 16; + yourself. + deleteButton when: RSMouseClick do: [ self remove ]. + + addCellBellowButton := RSBitmap new + form: (self iconNamed: #addBelow); + model: 'Add after'; + size: 16; + yourself. + addCellAboveButton := RSBitmap new + form: (self iconNamed: #addAbove); + model: 'Add before'; + size: 16; + yourself. + moveCellUp := RSBitmap new + form: (self iconNamed: #up); + model: 'Move up cell'; + size: 16; + yourself. + moveCellDown := RSBitmap new + form: (self iconNamed: #down); + model: 'Move down cell'; + size: 16; + yourself. + buttons := RSGroup withAll: { + moveCellUp. + moveCellDown. + addCellBellowButton. + addCellAboveButton. + + deleteButton }. + buttons @ (RSMorphicPopupInteraction new + morphBuilder: [ :model | self createDescriptionFor: model ]; + yourself). + RSHorizontalLineLayout new + alignMiddle; + horizontalGap: 2; + on: buttons. + menu := RSComposite new + addAll: buttons; + isFixed: true; + color: Color transparent; + translateBy: 50 @ 14; + yourself. + + rightMenuCanvas canvas add: menu. + menu adjustToChildren. + menu padding: 10. + moveCellUp when: RSMouseClick do: [ self moveUp ]. + moveCellDown when: RSMouseClick do: [ self moveDown ]. + addCellBellowButton + when: RSMouseClick + do: [ notebook addTextCellAfter: self ]. + addCellAboveButton + when: RSMouseClick + do: [ notebook addTextCellBefore: self ] +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> moveDown [ + + notebook moveDown: self +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> moveUp [ + + notebook moveUp: self +] + +{ #category : #accessing } +INNotebookAbstractCellPresenter >> notebook [ + + ^ notebook +] + +{ #category : #accessing } +INNotebookAbstractCellPresenter >> notebook: anObject [ + + notebook := anObject +] + +{ #category : #accessing } +INNotebookAbstractCellPresenter >> previewCell [ + + ^ previewCell +] + +{ #category : #accessing } +INNotebookAbstractCellPresenter >> previewCell: anObject [ + + previewCell := anObject +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> remove [ + + notebook removeCell: self +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> select [ + + self takeKeyboardFocus. + leftMenuCanvas canvas color: self selectedColor. + leftMenuCanvas canvas signalUpdate. + rightMenuCanvas canvas color: self selectedColor. + rightMenuCanvas canvas signalUpdate +] + +{ #category : #actions } +INNotebookAbstractCellPresenter >> selectAndScrollToMe [ + + notebook selectAndScrollTo: self +] + +{ #category : #actions } +INNotebookAbstractCellPresenter >> selectMe [ + + notebook select: self. + previewCell ifNotNil: [ :c | c selectAndScrollToMe ] +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> selectedColor [ + + ^ Color fromHexString: '77A8C8' +] + +{ #category : #api } +INNotebookAbstractCellPresenter >> setModelBeforeInitialization: aModel [ + + self notebook: aModel +] + +{ #category : #protocol } +INNotebookAbstractCellPresenter >> takeKeyboardFocus [ + + cellTextInput takeKeyboardFocus +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> text [ + + ^ cellTextInput text +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> text: aText [ + + cellTextInput text: aText +] + +{ #category : #accessing } +INNotebookAbstractCellPresenter >> textAreaWidth [ + + self layout adapter ifNil: [ ^ -1 ]. + ^ self layout adapter children second width +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> unselect [ + + self beUnselected +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> unselectedColor [ + + ^ Color transparent +] + +{ #category : #initialization } +INNotebookAbstractCellPresenter >> updateHeight [ + UIManager default defer: [ + notebook headerSep withAdapterDo: [ :a | + cellTextInput withAdapterDo: [ :b | + | textMorph height width | + textMorph := b widget. + textMorph + borderColor: Color gray translucent; + borderWidth: 1. + textMorph scrollPane + vHideScrollbar; + vScrollbarShowNever. + width := a widget width. + textMorph scrollPane textArea withoutSelectionBar. + height := (RubEditingArea new + font: textMorph font; + width: width - 182; + beWrapped; + updateTextWith: cellTextInput text) height. + self withAdapterDo: [ :c | c widget height: height + 2 ] ] ] ] +] + +{ #category : #enumerating } +INNotebookAbstractCellPresenter >> whenTextChangedDo: aBlock [ + + cellTextInput whenTextChangedDo: aBlock +] diff --git a/src/InteractiveNotebookPresenter/INNotebookCellPreviewPresenter.class.st b/src/InteractiveNotebookPresenter/INNotebookCellPreviewPresenter.class.st index 7092fb5..7ec142d 100644 --- a/src/InteractiveNotebookPresenter/INNotebookCellPreviewPresenter.class.st +++ b/src/InteractiveNotebookPresenter/INNotebookCellPreviewPresenter.class.st @@ -1,122 +1,153 @@ -Class { - #name : #INNotebookCellPreviewPresenter, - #superclass : #SpPresenter, - #instVars : [ - 'textPresenter', - 'cell', - 'parent' - ], - #category : #InteractiveNotebookPresenter -} - -{ #category : #actions } -INNotebookCellPreviewPresenter >> beSelected [ - - self parent select: self. - -] - -{ #category : #accessing } -INNotebookCellPreviewPresenter >> cell [ - - ^ cell -] - -{ #category : #accessing } -INNotebookCellPreviewPresenter >> cell: anObject [ - - cell := anObject -] - -{ #category : #initialization } -INNotebookCellPreviewPresenter >> initializeLayout [ - - self layout: (SpBoxLayout newLeftToRight - add: textPresenter; - yourself) -] - -{ #category : #initialization } -INNotebookCellPreviewPresenter >> initializePresenters [ - - textPresenter := self newText - beNotEditable; - yourself. - self whenDisplayDo: [ - self updateHeight. - textPresenter withAdapterDo: [ :a | - UIManager default defer: [ - a widget backgroundColor: self unselectedColor ] ] ]. - self initializeLayout. - textPresenter eventHandler whenMouseDownDo: [ :anEvent | - self selectMe ] -] - -{ #category : #initialization } -INNotebookCellPreviewPresenter >> morphFor: aPresenter from: aMorph [ - - aMorph presenter = aPresenter ifTrue: [ ^ aMorph ]. - aMorph owner ifNil: [ ^ nil ]. - ^ self morphFor: aPresenter from: aMorph owner -] - -{ #category : #accessing } -INNotebookCellPreviewPresenter >> parent [ - - ^ parent -] - -{ #category : #accessing } -INNotebookCellPreviewPresenter >> parent: anObject [ - - parent := anObject -] - -{ #category : #actions } -INNotebookCellPreviewPresenter >> select [ - - textPresenter withAdapterDo: [ :a | - a widget backgroundColor: (Color fromHexString: '77A8C8') ] -] - -{ #category : #actions } -INNotebookCellPreviewPresenter >> selectAndScrollToMe [ - - self parent selectAndScrollTo: self -] - -{ #category : #actions } -INNotebookCellPreviewPresenter >> selectMe [ - - self parent select: self. - cell ifNotNil: [ :c | c selectAndScrollToMe ] -] - -{ #category : #accessing } -INNotebookCellPreviewPresenter >> text: aString [ - - textPresenter text: aString -] - -{ #category : #actions } -INNotebookCellPreviewPresenter >> unselected [ - - textPresenter withAdapterDo: [ :a | a widget backgroundColor: self unselectedColor ] -] - -{ #category : #initialization } -INNotebookCellPreviewPresenter >> unselectedColor [ - - ^ Smalltalk ui theme backgroundColor -] - -{ #category : #initialization } -INNotebookCellPreviewPresenter >> updateHeight [ - - UIManager default defer: [ - textPresenter withAdapterDo: [ :a | - a widget defer: [ - a widget scrollPane textArea withoutSelectionBar. - self withAdapterDo: [ :b | - b widget height: a widget scrollPane textArea height ] ] ] ] -] +" +I am a preview cell of a notebook page. +I display the compiled content of a cell, either in Microdown if I represent a text cell, or using different types of presenters for a code cell, depending on the class of the final compiled result of the cell. + +Using class extensions, the object resulting of the compilation of a cell provides me an appropriate presenter to display itself (using the extension method `createContentPreviewPresenter`). I can add this object to the created presenter (using the extension method `addContentToPreviewPresenter: anObject`). + +Those presenters also use extension methods : `selectNotebookPresenter`, `unselectedNotebookPresenter` and `updateNotebookPresenterHeight`. +" +Class { + #name : #INNotebookCellPreviewPresenter, + #superclass : #SpPresenter, + #instVars : [ + 'cell', + 'parent', + 'contentPresenter' + ], + #category : #InteractiveNotebookPresenter +} + +{ #category : #actions } +INNotebookCellPreviewPresenter class >> selectedColor [ + + ^ Color fromHexString: '77A8C8' +] + +{ #category : #initialization } +INNotebookCellPreviewPresenter class >> unselectedColor [ + + ^ Color transparent +] + +{ #category : #actions } +INNotebookCellPreviewPresenter >> beSelected [ + + self parent select: self. + +] + +{ #category : #accessing } +INNotebookCellPreviewPresenter >> cell: anObject [ + + cell := anObject +] + +{ #category : #accessing } +INNotebookCellPreviewPresenter >> cellTextInput [ + + ^ cell +] + +{ #category : #accessing } +INNotebookCellPreviewPresenter >> contentPresenter [ + ^ contentPresenter +] + +{ #category : #initialization } +INNotebookCellPreviewPresenter >> contentPresenter: aPresenter [ + + contentPresenter := aPresenter. + self whenDisplayDo: [ self updateHeight ]. + self initializeLayout +] + +{ #category : #accessing } +INNotebookCellPreviewPresenter >> getContent [ + + ^ parent mustDisplayInspectorView + ifTrue: [ + contentPresenter selectedPage activePresenter view context + inspectedObject ] + ifFalse: [ contentPresenter view context inspectedObject ] +] + +{ #category : #initialization } +INNotebookCellPreviewPresenter >> initializeLayout [ + + self layout: (SpBoxLayout newLeftToRight + add: contentPresenter; + yourself) +] + +{ #category : #initialization } +INNotebookCellPreviewPresenter >> initializePresenters [ + + self whenDisplayDo: [ + self withAdapterDo: [ :a | + a widget announcer when: MorphGotFocus do: [ self selectMe ] ] ] +] + +{ #category : #initialization } +INNotebookCellPreviewPresenter >> morphFor: aPresenter from: aMorph [ + + aMorph presenter = aPresenter ifTrue: [ ^ aMorph ]. + aMorph owner ifNil: [ ^ nil ]. + ^ self morphFor: aPresenter from: aMorph owner +] + +{ #category : #accessing } +INNotebookCellPreviewPresenter >> parent [ + + ^ parent +] + +{ #category : #accessing } +INNotebookCellPreviewPresenter >> parent: anObject [ + + parent := anObject +] + +{ #category : #actions } +INNotebookCellPreviewPresenter >> select [ + + self withAdapterDo: [ :a | a widget color: self class selectedColor ] +] + +{ #category : #actions } +INNotebookCellPreviewPresenter >> selectAndScrollToMe [ + + self parent selectAndScrollTo: self +] + +{ #category : #actions } +INNotebookCellPreviewPresenter >> selectMe [ + + self parent select: self. + cell ifNotNil: [ :c | c selectAndScrollToMe ] +] + +{ #category : #accessing } +INNotebookCellPreviewPresenter >> text: aString [ + + contentPresenter text: aString +] + +{ #category : #actions } +INNotebookCellPreviewPresenter >> unselected [ + + self withAdapterDo: [ :a | + a widget color: self class unselectedColor ] +] + +{ #category : #initialization } +INNotebookCellPreviewPresenter >> updateHeight [ + + parent mustDisplayInspectorView + ifFalse: [ contentPresenter specPresenter updatePresenterHeight ] + ifTrue: [ self updateInspectorViewHeight ] +] + +{ #category : #'as yet unclassified' } +INNotebookCellPreviewPresenter >> updateInspectorViewHeight [ + self withAdapterDo: [ :a | a widget height: 350 ]. +] diff --git a/src/InteractiveNotebookPresenter/INNotebookCodeCellModel.class.st b/src/InteractiveNotebookPresenter/INNotebookCodeCellModel.class.st index f56d412..15565aa 100644 --- a/src/InteractiveNotebookPresenter/INNotebookCodeCellModel.class.st +++ b/src/InteractiveNotebookPresenter/INNotebookCodeCellModel.class.st @@ -1,27 +1,45 @@ -Class { - #name : #INNotebookCodeCellModel, - #superclass : #INNotebookAbstractCellModel, - #category : #InteractiveNotebookPresenter -} - -{ #category : #helpers } -INNotebookCodeCellModel >> presenterClass [ - - ^ INNotebookCodeCellPresenter -] - -{ #category : #printing } -INNotebookCodeCellModel >> printContentIn: aStream withContext: aContext [ - - aContext bindings add: - (AdditionalBinding key: 'stream' value: aStream). - aContext bindings add: (AdditionalBinding - key: 'printer' - value: (INReportCollectionPrinter new - stream: aStream; - yourself)). - self class compiler - compilationContext: aContext; - source: text; - evaluate -] +Class { + #name : #INNotebookCodeCellModel, + #superclass : #INNotebookAbstractCellModel, + #category : #InteractiveNotebookPresenter +} + +{ #category : #converting } +INNotebookCodeCellModel >> beCodeModel [ + ^ self +] + +{ #category : #converting } +INNotebookCodeCellModel >> beTextModel [ + "no need to add the text of the current model in the new model, it will be compiled anyway in the next preview" + ^ INNotebookTextCellModel new +] + +{ #category : #printing } +INNotebookCodeCellModel >> getContentwithContext: aContext [ + + ^ self class compiler + compilationContext: aContext; + source: text; + evaluate +] + +{ #category : #compiling } +INNotebookCodeCellModel >> parseContent [ + + ^ RBParser parseExpression: text +] + +{ #category : #helpers } +INNotebookCodeCellModel >> presenterClass [ + + ^ INNotebookCodeCellPresenter +] + +{ #category : #printing } +INNotebookCodeCellModel >> printContentIn: aStream withContext: aContext [ + ^self class compiler + compilationContext: aContext; + source: text; + evaluate +] diff --git a/src/InteractiveNotebookPresenter/INNotebookCodeCellPresenter.class.st b/src/InteractiveNotebookPresenter/INNotebookCodeCellPresenter.class.st index ebd74e1..c39f8b4 100644 --- a/src/InteractiveNotebookPresenter/INNotebookCodeCellPresenter.class.st +++ b/src/InteractiveNotebookPresenter/INNotebookCodeCellPresenter.class.st @@ -1,69 +1,72 @@ -Class { - #name : #INNotebookCodeCellPresenter, - #superclass : #INNotebookAbstractCellPresenter, - #category : #InteractiveNotebookPresenter -} - -{ #category : #converting } -INNotebookCodeCellPresenter >> asModelCell [ - - ^ INNotebookCodeCellModel new - text: cell text; - yourself -] - -{ #category : #api } -INNotebookCodeCellPresenter >> beCode [ - - ^ self -] - -{ #category : #api } -INNotebookCodeCellPresenter >> beText [ - - notebook transformToTextCell: self -] - -{ #category : #initialization } -INNotebookCodeCellPresenter >> initializePresenters [ - - super initializePresenters. - cell := self newCode - withoutLineNumbers; - beForScripting; - placeholder: notebook codeCellPlaceholder; - yourself. - cell whenTextChangedDo: [ self updateHeight ]. - self interactionModel: notebook interactionModel. - - icon := self newButton - label: 'Code'; - action: [ notebook transformToTextCell: self ]. - - leftMenuCanvas canvas - add: (RSLabel new - text: '[ ]'; - bold; - color: Color black; - yourself); - when: RSMouseClick do: [ notebook transformToTextCell: self ]. - self initializeLayout -] - -{ #category : #api } -INNotebookCodeCellPresenter >> interactionModel: anEnvironment [ - - cell interactionModel: anEnvironment -] - -{ #category : #accessing } -INNotebookCodeCellPresenter >> notebook: aNoteBook [ - - notebook := aNoteBook. -] - -{ #category : #api } -INNotebookCodeCellPresenter >> setModelBeforeInitialization: aModel [ - - self notebook: aModel -] +Class { + #name : #INNotebookCodeCellPresenter, + #superclass : #INNotebookAbstractCellPresenter, + #category : #InteractiveNotebookPresenter +} + +{ #category : #converting } +INNotebookCodeCellPresenter >> asModelCell [ + + ^ INNotebookCodeCellModel new + text: cellTextInput text; + yourself +] + +{ #category : #api } +INNotebookCodeCellPresenter >> beCode [ + + ^ self +] + +{ #category : #api } +INNotebookCodeCellPresenter >> beText [ + + notebook transformToTextCell: self +] + +{ #category : #initialization } +INNotebookCodeCellPresenter >> initializePresenters [ + + super initializePresenters. + cellTextInput := self newCode + withoutLineNumbers; + beForScripting; + placeholder: notebook codeCellPlaceholder; + yourself. + cellTextInput whenTextChangedDo: [ self updateHeight. self updateBindings. ]. + self interactionModel: notebook interactionModel. + + icon := self newButton + label: 'Code'; + action: [ notebook transformToTextCell: self ]. + + leftMenuCanvas canvas + add: (RSLabel new + text: '[ ]'; + bold; + color: Color black; + yourself); + when: RSMouseClick do: [ notebook transformToTextCell: self ]. + self initializeLayout +] + +{ #category : #api } +INNotebookCodeCellPresenter >> interactionModel: anEnvironment [ + + cellTextInput interactionModel: anEnvironment +] + +{ #category : #accessing } +INNotebookCodeCellPresenter >> notebook: aNoteBook [ + + notebook := aNoteBook. +] + +{ #category : #updating } +INNotebookCodeCellPresenter >> updateBindings [ + + | parsedContent | + self model text: cellTextInput text. + parsedContent := [ self model parseContent ] on: Exception do: [ ^ self ]. + notebook interactionModel setBindings: parsedContent +] diff --git a/src/InteractiveNotebookPresenter/INNotebookCodeScriptingInteractionModel.class.st b/src/InteractiveNotebookPresenter/INNotebookCodeScriptingInteractionModel.class.st index e60f721..af5a680 100644 --- a/src/InteractiveNotebookPresenter/INNotebookCodeScriptingInteractionModel.class.st +++ b/src/InteractiveNotebookPresenter/INNotebookCodeScriptingInteractionModel.class.st @@ -1,26 +1,33 @@ -Class { - #name : #INNotebookCodeScriptingInteractionModel, - #superclass : #SpCodeScriptingInteractionModel, - #instVars : [ - 'receiver' - ], - #category : #InteractiveNotebookPresenter -} - -{ #category : #accessing } -INNotebookCodeScriptingInteractionModel >> doItReceiver [ - - ^ receiver -] - -{ #category : #accessing } -INNotebookCodeScriptingInteractionModel >> receiver [ - - ^ receiver -] - -{ #category : #accessing } -INNotebookCodeScriptingInteractionModel >> receiver: anObject [ - - receiver := anObject -] +Class { + #name : #INNotebookCodeScriptingInteractionModel, + #superclass : #SpCodeScriptingInteractionModel, + #instVars : [ + 'receiver' + ], + #category : #InteractiveNotebookPresenter +} + +{ #category : #accessing } +INNotebookCodeScriptingInteractionModel >> doItReceiver [ + + ^ receiver +] + +{ #category : #accessing } +INNotebookCodeScriptingInteractionModel >> receiver [ + + ^ receiver +] + +{ #category : #accessing } +INNotebookCodeScriptingInteractionModel >> receiver: anObject [ + + receiver := anObject +] + +{ #category : #initialization } +INNotebookCodeScriptingInteractionModel >> setBindings: aASTTree [ + + aASTTree allChildren do: [ :l | + l class = RBAssignmentNode ifTrue: [ self bindingOf: l variable name ] ] +] diff --git a/src/InteractiveNotebookPresenter/INNotebookEditorPresenter.class.st b/src/InteractiveNotebookPresenter/INNotebookEditorPresenter.class.st index c6b25ef..9907158 100644 --- a/src/InteractiveNotebookPresenter/INNotebookEditorPresenter.class.st +++ b/src/InteractiveNotebookPresenter/INNotebookEditorPresenter.class.st @@ -1,308 +1,289 @@ -Class { - #name : #INNotebookEditorPresenter, - #superclass : #SpPresenter, - #instVars : [ - 'menu', - 'cellList', - 'lastCellAdded', - 'selectedCell', - 'interactionModel', - 'headerSep', - 'mooseModel', - 'cellLayout', - 'browser', - 'codeCellPlaceholder' - ], - #category : #InteractiveNotebookPresenter -} - -{ #category : #adding } -INNotebookEditorPresenter >> add: aCell [ - - self layout add: aCell expand: false. - aCell announceDisplayed. - lastCellAdded takeKeyboardFocus -] - -{ #category : #adding } -INNotebookEditorPresenter >> addCodeCell [ - - lastCellAdded := self newCodeCell. - cellList addLast: lastCellAdded. - selectedCell := lastCellAdded. - self relayout -] - -{ #category : #adding } -INNotebookEditorPresenter >> addTextCell [ - - lastCellAdded := self newTextCell. - cellList addLast: lastCellAdded. - selectedCell := lastCellAdded. - self relayout -] - -{ #category : #initialization } -INNotebookEditorPresenter >> addTextCellAfter: aCell [ - - lastCellAdded := self newTextCell. - cellList add: lastCellAdded after: aCell. - selectedCell := lastCellAdded. - self relayout -] - -{ #category : #initialization } -INNotebookEditorPresenter >> addTextCellBefore: aCell [ - - lastCellAdded := self newTextCell. - cellList add: lastCellAdded before: aCell. - selectedCell := lastCellAdded. - self relayout -] - -{ #category : #accessing } -INNotebookEditorPresenter >> allModelCells [ - - ^ cellList asOrderedCollection collect: [ :cell | cell asModelCell ] -] - -{ #category : #accessing } -INNotebookEditorPresenter >> browser [ - - ^ browser -] - -{ #category : #accessing } -INNotebookEditorPresenter >> browser: anObject [ - - browser := anObject -] - -{ #category : #accessing } -INNotebookEditorPresenter >> cellList [ - - ^ cellList -] - -{ #category : #accessing } -INNotebookEditorPresenter >> codeCellPlaceholder [ - - ^ codeCellPlaceholder -] - -{ #category : #accessing } -INNotebookEditorPresenter >> codeCellPlaceholder: anObject [ - - codeCellPlaceholder := anObject -] - -{ #category : #initialization } -INNotebookEditorPresenter >> defer: aBlock times: n [ - - n traceCr. - self withAdapterDo: [ :a | - a widget defer: [ - n <= 0 - ifTrue: [ a widget defer: aBlock ] - ifFalse: [ self defer: aBlock times: n - 1 ] ] ] -] - -{ #category : #accessing } -INNotebookEditorPresenter >> headerSep [ - - ^ headerSep -] - -{ #category : #initialization } -INNotebookEditorPresenter >> initialize [ - - codeCellPlaceholder := 'Code'. - cellList := LinkedList new. - interactionModel := INNotebookCodeScriptingInteractionModel new - receiver: 1; - yourself. - super initialize -] - -{ #category : #initialization } -INNotebookEditorPresenter >> initializeLayout [ - - cellLayout := SpBoxLayout newTopToBottom - spacing: self layoutSpacing; - yourself. - self layout: (SpScrollableLayout with: (SpBoxLayout newTopToBottom - spacing: self layoutSpacing; - add: headerSep height: 1; - add: cellLayout; - yourself)) -] - -{ #category : #initialization } -INNotebookEditorPresenter >> initializePresenters [ - - (headerSep := self newRoassal) canvas color: Color transparent. - headerSep canvas when: RSExtentChangedEvent do: [ self updateHeight ]. - self whenDisplayDo: [ self updateHeight ]. - self initializeLayout -] - -{ #category : #accessing } -INNotebookEditorPresenter >> interactionModel [ - - ^ interactionModel -] - -{ #category : #initialization } -INNotebookEditorPresenter >> layoutSpacing [ - - ^ 10 -] - -{ #category : #accessing } -INNotebookEditorPresenter >> model [ - - ^ self owner model -] - -{ #category : #accessing } -INNotebookEditorPresenter >> mooseModel [ - - ^ self owner mooseModel -] - -{ #category : #removing } -INNotebookEditorPresenter >> moveDown: aCell [ - - | idx | - idx := cellList indexOf: aCell. - idx >= cellList size ifTrue: [ ^ self ]. - cellList swap: idx with: idx + 1. - selectedCell := aCell. - self relayout -] - -{ #category : #removing } -INNotebookEditorPresenter >> moveUp: aCell [ - - | idx | - idx := cellList indexOf: aCell. - idx <= 1 ifTrue: [ ^ self ]. - cellList swap: idx with: idx - 1. - selectedCell := aCell. - self relayout -] - -{ #category : #initialization } -INNotebookEditorPresenter >> newCodeCell [ - - ^ (self instantiate: INNotebookCodeCellPresenter on: self) - notebook: self; - yourself -] - -{ #category : #initialization } -INNotebookEditorPresenter >> newTextCell [ - - ^ (self instantiate: INNotebookTextCellPresenter) notebook: self -] - -{ #category : #adding } -INNotebookEditorPresenter >> relayout [ - - | newLayout | - newLayout := SpBoxLayout newTopToBottom - spacing: self layoutSpacing; - yourself. - cellList do: [ :cell | newLayout add: cell expand: false ]. - - cellLayout removeAll. - cellLayout add: (self newPresenter - layout: newLayout; - yourself). - cellList do: [ :cell | cell announceDisplayed ]. - self defer: [ - selectedCell ifNotNil: [ self selectAndScrollTo: selectedCell ] ] -] - -{ #category : #removing } -INNotebookEditorPresenter >> removeCell: aCell [ - - cellList remove: aCell. - self relayout -] - -{ #category : #adding } -INNotebookEditorPresenter >> scrollTo: aMiNoteBookCell [ - - self layout withAdapterDo: [ :a | - aMiNoteBookCell withAdapterDo: [ :b | - a widget scrollToShow: b widget bounds ] ] -] - -{ #category : #removing } -INNotebookEditorPresenter >> select: aCell [ - - selectedCell := aCell. - cellList do: [ :c | c unselect ]. - selectedCell select -] - -{ #category : #adding } -INNotebookEditorPresenter >> selectAndScrollTo: aMiNoteBookCell [ - - self select: aMiNoteBookCell. - self scrollTo: aMiNoteBookCell -] - -{ #category : #adding } -INNotebookEditorPresenter >> transformToCodeCell: aCell [ - - | width | - lastCellAdded := self newCodeCell - text: aCell text; - yourself. - width := aCell textAreaWidth. - cellList at: (cellList indexOf: aCell) put: lastCellAdded. - selectedCell := lastCellAdded. - self relayout -] - -{ #category : #adding } -INNotebookEditorPresenter >> transformToTextCell: aCell [ - - | width | - lastCellAdded := self newTextCell - text: aCell text; - yourself. - width := aCell textAreaWidth. - cellList at: (cellList indexOf: aCell) put: lastCellAdded. - selectedCell := lastCellAdded. - self relayout -] - -{ #category : #removing } -INNotebookEditorPresenter >> updateAll [ - - cellList := LinkedList new. - self model cellList do: [ :c | - cellList add: ((self instantiate: c presenterClass) - notebook: self; - text: c text; - yourself) ]. - - cellList ifEmpty: [ ^ self ]. - selectedCell := cellList last. - self relayout -] - -{ #category : #removing } -INNotebookEditorPresenter >> updateHeight [ - - cellList do: [ :c | c updateHeight ] -] - -{ #category : #initialization } -INNotebookEditorPresenter >> updatePresenter [ - - self updateAll -] +" +I am the editor panel for a notebook page. + +I allow the user to add cells before or after a cell, to transform a text cell into a code cell and vice versa, or to move up or down a cell. +" +Class { + #name : #INNotebookEditorPresenter, + #superclass : #SpPresenter, + #instVars : [ + 'cellList', + 'selectedCell', + 'interactionModel', + 'headerSep', + 'cellLayout', + 'browser', + 'codeCellPlaceholder' + ], + #category : #InteractiveNotebookPresenter +} + +{ #category : #initialization } +INNotebookEditorPresenter >> addTextCellAfter: aCell [ + + | lastCellAdded | + lastCellAdded := self newTextCell. + cellList add: lastCellAdded after: aCell. + selectedCell := lastCellAdded. + self relayout +] + +{ #category : #initialization } +INNotebookEditorPresenter >> addTextCellBefore: aCell [ + + | lastCellAdded | + lastCellAdded := self newTextCell. + cellList add: lastCellAdded before: aCell. + selectedCell := lastCellAdded. + self relayout +] + +{ #category : #accessing } +INNotebookEditorPresenter >> allModelCells [ + + ^ cellList asOrderedCollection collect: [ :cell | cell model ] +] + +{ #category : #accessing } +INNotebookEditorPresenter >> browser [ + + ^ browser +] + +{ #category : #accessing } +INNotebookEditorPresenter >> browser: anObject [ + + browser := anObject +] + +{ #category : #accessing } +INNotebookEditorPresenter >> cellList [ + + ^ cellList +] + +{ #category : #accessing } +INNotebookEditorPresenter >> codeCellPlaceholder [ + + ^ codeCellPlaceholder +] + +{ #category : #accessing } +INNotebookEditorPresenter >> codeCellPlaceholder: anObject [ + + codeCellPlaceholder := anObject +] + +{ #category : #initialization } +INNotebookEditorPresenter >> defer: aBlock times: n [ + + n traceCr. + self withAdapterDo: [ :a | + a widget defer: [ + n <= 0 + ifTrue: [ a widget defer: aBlock ] + ifFalse: [ self defer: aBlock times: n - 1 ] ] ] +] + +{ #category : #accessing } +INNotebookEditorPresenter >> headerSep [ + + ^ headerSep +] + +{ #category : #initialization } +INNotebookEditorPresenter >> initialize [ + + codeCellPlaceholder := 'Code'. + cellList := LinkedList new. + interactionModel := INNotebookCodeScriptingInteractionModel new + receiver: 1; + yourself. + super initialize +] + +{ #category : #initialization } +INNotebookEditorPresenter >> initializeLayout [ + + cellLayout := SpBoxLayout newTopToBottom + spacing: self layoutSpacing; + yourself. + self layout: (SpScrollableLayout with: (SpBoxLayout newTopToBottom + spacing: self layoutSpacing; + add: headerSep height: 1; + add: cellLayout; + yourself)) +] + +{ #category : #initialization } +INNotebookEditorPresenter >> initializePresenters [ + + (headerSep := self newRoassal) canvas color: Color transparent. + headerSep canvas when: RSExtentChangedEvent do: [ self updateHeight ]. + self whenDisplayDo: [ self updateHeight ]. + self initializeLayout +] + +{ #category : #accessing } +INNotebookEditorPresenter >> interactionModel [ + + ^ interactionModel +] + +{ #category : #initialization } +INNotebookEditorPresenter >> layoutSpacing [ + + ^ 10 +] + +{ #category : #accessing } +INNotebookEditorPresenter >> model [ + + ^ self owner model +] + +{ #category : #removing } +INNotebookEditorPresenter >> moveDown: aCell [ + + | idx | + idx := cellList indexOf: aCell. + idx >= cellList size ifTrue: [ ^ self ]. + cellList swap: idx with: idx + 1. + selectedCell := aCell. + self relayout +] + +{ #category : #removing } +INNotebookEditorPresenter >> moveUp: aCell [ + + | idx | + idx := cellList indexOf: aCell. + idx <= 1 ifTrue: [ ^ self ]. + cellList swap: idx with: idx - 1. + selectedCell := aCell. + self relayout +] + +{ #category : #initialization } +INNotebookEditorPresenter >> newCodeCell [ + + ^ (self instantiate: INNotebookCodeCellPresenter on: self) + notebook: self; + model: INNotebookCodeCellModel new; + yourself +] + +{ #category : #initialization } +INNotebookEditorPresenter >> newTextCell [ + + ^ (self instantiate: INNotebookTextCellPresenter) + notebook: self; + model: INNotebookTextCellModel new; + yourself +] + +{ #category : #adding } +INNotebookEditorPresenter >> relayout [ + + | newLayout | + newLayout := SpBoxLayout newTopToBottom + spacing: self layoutSpacing; + yourself. + cellList do: [ :cell | newLayout add: cell expand: false ]. + + cellLayout removeAll. + cellLayout add: (self newPresenter + layout: newLayout; + yourself). + cellList do: [ :cell | cell announceDisplayed ]. + self defer: [ + selectedCell ifNotNil: [ self selectAndScrollTo: selectedCell ] ] +] + +{ #category : #removing } +INNotebookEditorPresenter >> removeCell: aCell [ + + cellList remove: aCell. + self relayout +] + +{ #category : #adding } +INNotebookEditorPresenter >> scrollTo: aMiNoteBookCell [ + + self layout withAdapterDo: [ :a | + aMiNoteBookCell withAdapterDo: [ :b | + a widget scrollToShow: b widget bounds ] ] +] + +{ #category : #removing } +INNotebookEditorPresenter >> select: aCell [ + + + selectedCell := aCell. + cellList do: [ :c | c unselect ]. + selectedCell select +] + +{ #category : #adding } +INNotebookEditorPresenter >> selectAndScrollTo: aMiNoteBookCell [ + + self select: aMiNoteBookCell. + self scrollTo: aMiNoteBookCell +] + +{ #category : #adding } +INNotebookEditorPresenter >> transformToCodeCell: aCell [ + + | width lastCellAdded | + lastCellAdded := self newCodeCell + text: aCell text; + yourself. + width := aCell textAreaWidth. + cellList at: (cellList indexOf: aCell) put: lastCellAdded. + selectedCell := lastCellAdded. + self relayout +] + +{ #category : #adding } +INNotebookEditorPresenter >> transformToTextCell: aCell [ + + | width lastCellAdded | + lastCellAdded := self newTextCell + text: aCell text; + yourself. + width := aCell textAreaWidth. + cellList at: (cellList indexOf: aCell) put: lastCellAdded. + selectedCell := lastCellAdded. + self relayout +] + +{ #category : #'updating screen' } +INNotebookEditorPresenter >> updateAll [ + + cellList := self model cellList collect: [ :c | + (self instantiate: c presenterClass on: self) + model: c; + text: c text; + yourself ]. + + cellList ifEmpty: [ ^ self ]. + self select: cellList last. + self relayout +] + +{ #category : #removing } +INNotebookEditorPresenter >> updateHeight [ + + cellList do: [ :c | c updateHeight ] +] + +{ #category : #removing } +INNotebookEditorPresenter >> updateModelCells [ + cellList do: [ :cell | cell model text: cell text ] +] + +{ #category : #initialization } +INNotebookEditorPresenter >> updatePresenter [ + + self updateAll +] diff --git a/src/InteractiveNotebookPresenter/INNotebookGenerationHelper.class.st b/src/InteractiveNotebookPresenter/INNotebookGenerationHelper.class.st new file mode 100644 index 0000000..fcfaaac --- /dev/null +++ b/src/InteractiveNotebookPresenter/INNotebookGenerationHelper.class.st @@ -0,0 +1,106 @@ +" +I am a helper class used to generate the document to export. +" +Class { + #name : #INNotebookGenerationHelper, + #superclass : #Object, + #instVars : [ + 'fileReferenceParent', + 'index', + 'listLevel' + ], + #category : #InteractiveNotebookPresenter +} + +{ #category : #'instance creation' } +INNotebookGenerationHelper class >> newFor: aFileReference [ + + ^ self new + fileReferenceParent: aFileReference; + index: 0; + yourself +] + +{ #category : #'*InteractiveNotebookPresenter' } +INNotebookGenerationHelper >> checkForResourcesDirectory [ + "checks whether or not the notebook resources file is already created" + ^ (fileReferenceParent / 'notebook_resources') exists +] + +{ #category : #'*InteractiveNotebookPresenter' } +INNotebookGenerationHelper >> createResourcesDirectory [ + "create a resource directory, to store additional files necessary to the notebook export document, like images" + (fileReferenceParent / 'notebook_resources') createDirectory +] + +{ #category : #accessing } +INNotebookGenerationHelper >> fileReferenceParent [ + + ^ fileReferenceParent +] + +{ #category : #accessing } +INNotebookGenerationHelper >> fileReferenceParent: anObject [ + + fileReferenceParent := anObject +] + +{ #category : #'as yet unclassified' } +INNotebookGenerationHelper >> generateDocument: aCellList [ + + ^ String streamContents: [ :stream | + aCellList do: [ :cell | + stream nextPutAll: + (self generateObject: cell previewCell getContent). + stream nextPutAll: ' '. + stream nextPut: Character cr ] ] +] + +{ #category : #'as yet unclassified' } +INNotebookGenerationHelper >> generateObject: anObject [ + + self incrementIndex. + ^ anObject generateMicrodownUsingHelper: self +] + +{ #category : #'as yet unclassified' } +INNotebookGenerationHelper >> incrementIndex [ + + index := index + 1. +] + +{ #category : #accessing } +INNotebookGenerationHelper >> index [ + + ^ index +] + +{ #category : #accessing } +INNotebookGenerationHelper >> index: anObject [ + + index := anObject +] + +{ #category : #accessing } +INNotebookGenerationHelper >> listLevel [ + + ^ listLevel +] + +{ #category : #accessing } +INNotebookGenerationHelper >> listLevel: anObject [ + + listLevel := anObject +] + +{ #category : #accessing } +INNotebookGenerationHelper >> listLevelDecrement [ + + listLevel := listLevel - 1 +] + +{ #category : #accessing } +INNotebookGenerationHelper >> listLevelIncrement [ + + listLevel := listLevel + 1 +] diff --git a/src/InteractiveNotebookPresenter/INNotebookGenerationHelper.extension.st b/src/InteractiveNotebookPresenter/INNotebookGenerationHelper.extension.st new file mode 100644 index 0000000..f40f3d8 --- /dev/null +++ b/src/InteractiveNotebookPresenter/INNotebookGenerationHelper.extension.st @@ -0,0 +1,13 @@ +Extension { #name : #INNotebookGenerationHelper } + +{ #category : #'*InteractiveNotebookPresenter' } +INNotebookGenerationHelper >> checkForResourcesDirectory [ + "checks whether or not the notebook resources file is already created" + ^ (fileReferenceParent / 'notebook_resources') exists +] + +{ #category : #'*InteractiveNotebookPresenter' } +INNotebookGenerationHelper >> createResourcesDirectory [ + "create a resource directory, to store additional files necessary to the notebook export document, like images" + (fileReferenceParent / 'notebook_resources') createDirectory +] diff --git a/src/InteractiveNotebookPresenter/INNotebookIcons.class.st b/src/InteractiveNotebookPresenter/INNotebookIcons.class.st index ce59981..f9a76c3 100644 --- a/src/InteractiveNotebookPresenter/INNotebookIcons.class.st +++ b/src/InteractiveNotebookPresenter/INNotebookIcons.class.st @@ -1,499 +1,435 @@ -Class { - #name : #INNotebookIcons, - #superclass : #Object, - #classInstVars : [ - 'icons' - ], - #category : #InteractiveNotebookPresenter -} - -{ #category : #utilities } -INNotebookIcons class >> buildCache [ - - (Pragma allNamed: #icon in: self class) do: [ :pragma | - pragma method selector value: self ] -] - -{ #category : #'icon creation' } -INNotebookIcons class >> iconAddAbove [ - - - ^ self icons at: #addAbove ifAbsentPut: [ - Form - extent: 16 @ 16 - depth: 32 - fromArray: - #( 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16rFF404040 16rFF404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16rFF404040 16rFF404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16rFF404040 16rFF404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 ) - offset: 0 @ 0 ] -] - -{ #category : #'icon creation' } -INNotebookIcons class >> iconAddBellow [ - - - ^ self icons at: #addBelow ifAbsentPut: [ - Form - extent: 16 @ 16 - depth: 32 - fromArray: - #( 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16rFF404040 16rFF404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16rFF404040 16rFF404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 ) - offset: 0 @ 0 ] -] - -{ #category : #'icon creation' } -INNotebookIcons class >> iconAddBelow [ - - - ^ self icons at: #addBelow ifAbsentPut: [ - Form - extent: 16 @ 16 - depth: 32 - fromArray: - #( 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16rFF404040 16rFF404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16rFF404040 16rFF404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 ) - offset: 0 @ 0 ] -] - -{ #category : #utilities } -INNotebookIcons class >> iconDown [ - - - ^ self icons at: #down ifAbsentPut: [ - Form - extent: 16 @ 16 - depth: 32 - fromArray: - #( 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r40404040 16rFF404040 16r40404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r40404040 16rFF404040 16r40404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r40404040 16rFF404040 16rFF404040 - 16r40404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r40404040 16rFF404040 16rFF404040 16r40404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r40404040 - 16rFF404040 16rFF404040 16r40404040 16r00000000 16r00000000 - 16r40404040 16rFF404040 16rFF404040 16r40404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r40404040 16rFF404040 16rFF404040 16r40404040 - 16r40404040 16rFF404040 16rFF404040 16r40404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r40404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16r40404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r40404040 16rFF404040 16rFF404040 16r40404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r40404040 16r40404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 ) - offset: 0 @ 0 ] -] - -{ #category : #'icon creation' } -INNotebookIcons class >> iconRemove [ - - - ^ self icons at: #remove ifAbsentPut: [ - Form - extent: 16 @ 16 - depth: 32 - fromArray: - #( 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 2130706432 4278190080 4278190080 4278190080 - 4278190080 4278190080 4278190080 2130706432 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 2130706432 4278190080 4278190080 4278190080 4278190080 - 4278190080 4278190080 2130706432 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 16777215 - 16777215 16777215 16777215 16777215 16777215 ) - offset: 0 @ 0 ] -] - -{ #category : #'icon creation' } -INNotebookIcons class >> iconTrash [ - - - ^ self icons at: #trash ifAbsentPut: [ - Form - extent: 16 @ 16 - depth: 32 - fromArray: - #( 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16rFF404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 ) - offset: 0 @ 0 ] -] - -{ #category : #'icon creation' } -INNotebookIcons class >> iconUp [ - - - ^ self icons at: #up ifAbsentPut: [ - Form - extent: 16 @ 16 - depth: 32 - fromArray: - #( 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r40404040 16r40404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r40404040 16rFF404040 16rFF404040 16r40404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r40404040 16rFF404040 16rFF404040 16rFF404040 - 16rFF404040 16r40404040 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r40404040 16rFF404040 16rFF404040 16r40404040 - 16r40404040 16rFF404040 16rFF404040 16r40404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r40404040 16rFF404040 16rFF404040 16r40404040 - 16r00000000 16r00000000 16r40404040 16rFF404040 16rFF404040 - 16r40404040 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r40404040 16rFF404040 16rFF404040 16r40404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r40404040 - 16rFF404040 16rFF404040 16r40404040 16r00000000 16r00000000 - 16r00000000 16r00000000 16r40404040 16rFF404040 16r40404040 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r40404040 16rFF404040 16r40404040 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 16r00000000 16r00000000 16r00000000 16r00000000 - 16r00000000 ) - offset: 0 @ 0 ] -] - -{ #category : #utilities } -INNotebookIcons class >> icons [ - - ^ icons ifNil: [ - icons := Dictionary new. - self buildCache. - icons ] -] - -{ #category : #import } -INNotebookIcons class >> importIcons: iconCollection fromFolder: aString inClass: aClass category: aCategory [ - iconCollection - do: [:each | - | method form | - form := PNGReadWriter formFromFileNamed: aString, '/', each , '.png'. - method := each , Character cr asString , - ('^ self icons - at: #', each , - ' ifAbsentPut: ['), - form storeString, - ']'. - aClass compile: method classified: aCategory ] -] - -{ #category : #utilities } -INNotebookIcons class >> resetIcons [ - -