Skip to content

Commit

Permalink
Add Polyglot>>iconFor:
Browse files Browse the repository at this point in the history
Also, add missing languageIDs and refactor code.
  • Loading branch information
fniephaus committed Jun 20, 2019
1 parent cd029f8 commit e6f4678
Show file tree
Hide file tree
Showing 27 changed files with 75 additions and 49 deletions.
14 changes: 14 additions & 0 deletions src/GraalSqueak-Core.package/Polyglot.class/class/iconFor..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
icons
iconFor: aLanguage
"LanguageIDToIcon := nil"
^ (LanguageIDToIcon ifNil: [
LanguageIDToIcon := Dictionary newFromPairs: {
self languageIdJava. self iconJava.
self languageIdJS. self iconJS.
self languageIdLLVM. self iconLLVM.
self languageIdMarkdown. self iconMarkdown.
self languageIdPython. self iconPython.
self languageIdR. self iconR.
self languageIdRuby. self iconRuby.
self languageIdSqueakSmalltalk. self iconSqueakSmalltalk }
]) at: aLanguage ifAbsent: [ nil ]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
icons
iconJavascript
iconJS
^ Form
extent: 16@16
depth: 32
Expand Down
7 changes: 7 additions & 0 deletions src/GraalSqueak-Core.package/Polyglot.class/class/iconJava.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
icons
iconJava
^ Form
extent: 16@16
depth: 32
fromArray: #( 16777215 16777215 8355711 4144959 4144959 4144959 4144959 4144959 4144959 442191938 138888256 4144959 4144959 8158332 16777215 16777215 16777215 16777215 5329233 0 0 0 0 0 0 1431186690 420612096 0 0 5000268 16777215 16777215 16777215 16777215 5658198 0 0 0 0 0 606344708 2240041231 0 0 0 5395026 16777215 16777215 16777215 16777215 5658198 0 0 0 0 909517062 2812700179 757930757 741219333 202246402 0 5395026 16777215 16777215 16777215 16777215 5658198 0 0 0 1229466632 3031592213 1179003656 2004306190 741153797 33685760 0 5395026 16777215 16777215 16777215 16777215 5658198 0 0 286329346 3435690775 656873477 2795791379 673716229 0 0 0 5395026 16777215 16777215 16777215 16777215 5658198 0 0 286329346 2778948627 202180610 3738797337 976823047 0 0 0 5395026 16777215 16777215 16777215 16777215 5658198 0 0 0 1179069192 960111623 1936868877 3233641494 0 0 0 5263439 16777215 16777215 16777215 16777215 5658198 0 235210505 319228685 0 455283200 472060416 1667775751 0 184813063 1041243172 374955616 16777215 16777215 16777215 16777215 5460561 856298265 2923125874 1511993404 1091969579 1041375275 1310796591 1175987760 991174439 151192838 923209751 2441256624 16777215 16777215 16777215 16777215 5592405 100729347 755963934 1663186242 1024794921 923999524 856693539 940776998 386403343 33620225 1494295085 1618117776 16777215 16777215 16777215 16777215 5658198 0 302385420 1931885643 1965571661 2015903566 1999126350 1881619787 688789019 453644051 873207068 5263183 16777215 16777215 16777215 16777215 5526098 0 0 1528770619 1763981638 1461529912 1562325309 1629565759 201590280 0 0 5329233 16777215 16777215 16777215 16777215 828730996 1494558514 369626384 537596181 1663186242 2032746576 1931951435 1293560115 167970055 100795140 419629067 106190166 16777215 16777215 16777215 16777215 1500413577 2501983825 1780298047 1511467316 1259479082 1192304167 1209081640 1276322347 1461135411 1561864758 1510743337 727409512 16777215 16777215 16777215 16777215 8092280 3947323 474500433 1213621358 1482452345 1600024957 1650422399 1616867966 1532850043 1348036979 910906716 192905345 16777215 16777215)
offset: 0@0
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ importStatementFor: aLanguage named: aName
"LanguageIDToPolyglotImport := nil"
^ ((LanguageIDToPolyglotImport ifNil: [
LanguageIDToPolyglotImport := Dictionary newFromPairs: {
'js'. [:name | '{1} = Polyglot.import("bindings"); ' format: {name}].
'llvm'. [:name | '{1} = polyglot_import("bindings"); ' format: {name}].
'python'. [:name | 'import polyglot; {1} = polyglot.import_value("bindings"); ' format: {name}].
'R'. [:name | '{1} <- import("bindings"); ' format: {name}].
'ruby'. [:name | '{1} = Polyglot.import("bindings"); ' format: {name}].
'squeaksmalltalk'. [:name | '{1} := Polyglot import: ''bindings''. ' format: {name}]}
self languageIdJS. [:name | '{1} = Polyglot.import("bindings"); ' format: {name}].
self languageIdLLVM. [:name | '{1} = polyglot_import("bindings"); ' format: {name}].
self languageIdPython. [:name | 'import polyglot; {1} = polyglot.import_value("bindings"); ' format: {name}].
self languageIdR. [:name | '{1} <- import("bindings"); ' format: {name}].
self languageIdRuby. [:name | '{1} = Polyglot.import("bindings"); ' format: {name}].
self languageIdSqueakSmalltalk. [:name | '{1} := Polyglot import: ''bindings''. ' format: {name}]}
]) at: aLanguage ifAbsent: [self error: 'unsupported language: ', aLanguage]) value: aName
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
polyglot-api
languageIconOf: aLanguageID
^ self
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
constants
languageIdJava
^ 'java'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
constants
languageIdLLVM
^ 'llvm'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
constants
languageIdMarkdown
^ 'markdown'
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@
"eval:string:inInnerContext:" : "fn 6/14/2019 14:47",
"eval:string:withBindingsNamed:" : "CF 1/13/2019 18:04",
"export:value:" : "GraalSqueak 11/11/2018 21:34",
"iconFor:" : "fn 6/20/2019 17:28",
"iconJS" : "fn 6/20/2019 17:11",
"iconJava" : "fn 6/20/2019 17:27",
"iconLLVM" : "fn 6/20/2019 17:11",
"iconMarkdown" : "fn 6/20/2019 17:11",
"iconPython" : "fn 6/20/2019 17:11",
"iconR" : "fn 6/20/2019 17:20",
"iconRuby" : "fn 6/20/2019 17:11",
"iconSqueakSmalltalk" : "fn 6/20/2019 17:11",
"import:" : "GraalSqueak 11/11/2018 21:34",
"importStatementFor:named:" : "fn 3/25/2019 14:13",
"importStatementFor:named:" : "fn 6/20/2019 17:08",
"initialize" : "fn 12/3/2018 10:47",
"isPolyglotAccessAllowed" : "fn 5/2/2019 18:36",
"languageDefaultMimeTypeOf:" : "fn 11/25/2018 16:20",
"languageIconOf:" : "fn 6/20/2019 17:03",
"languageIdJS" : "fn 4/13/2019 13:50",
"languageIdJava" : "fn 6/20/2019 17:21",
"languageIdLLVM" : "fn 6/20/2019 17:08",
"languageIdMarkdown" : "fn 6/20/2019 17:13",
"languageIdPython" : "fn 4/13/2019 13:49",
"languageIdR" : "fn 4/13/2019 13:50",
"languageIdRuby" : "fn 4/13/2019 13:49",
Expand Down
3 changes: 2 additions & 1 deletion src/GraalSqueak-Core.package/Polyglot.class/properties.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"category" : "GraalSqueak-Core",
"classinstvars" : [
"LanguageIDToPolyglotImport" ],
"LanguageIDToPolyglotImport",
"LanguageIDToIcon" ],
"classvars" : [
],
"commentStamp" : "fn 11/25/2018 15:08",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
isMarkdown
^ self languageID = PolyglotNotebook markdownID
^ self languageID = Polyglot languageIdMarkdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
accessing
languageID
^ languageID ifNil: [ languageID := PolyglotNotebook markdownID ]
^ languageID ifNil: [ languageID := Polyglot languageIdMarkdown ]
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"down" : "fn 3/27/2019 11:16",
"editor" : "fn 4/13/2019 23:24",
"initialize" : "fn 3/27/2019 09:58",
"isMarkdown" : "fn 4/13/2019 23:19",
"isMarkdown" : "fn 6/20/2019 17:17",
"label" : "fn 4/13/2019 23:26",
"label:" : "fn 4/13/2019 23:26",
"languageID" : "fn 4/13/2019 23:26",
"languageID" : "fn 6/20/2019 17:17",
"languageID:" : "fn 4/13/2019 23:26",
"output" : "fn 4/13/2019 23:23",
"outputs:" : "fn 3/25/2019 18:49",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ events-processing
handleMouseDown: anEvent
| menu action |
menu := CustomMenu new.
menu add: PolyglotNotebook markdownName action: PolyglotNotebook markdownID.
menu add: PolyglotNotebook markdownName action: Polyglot languageIdMarkdown.
menu addLine.

Polyglot availableLanguages do: [:ea |
Expand All @@ -16,7 +16,7 @@ handleMouseDown: anEvent
menu addLine.
menu add: 'remove...' action: #remove.
anEvent wasHandled: true.
action := menu startUp: PolyglotNotebook markdownID.
action := menu startUp: Polyglot languageIdMarkdown.
action = #run ifTrue: [ self codeCell run. ^ self ].
action = #up ifTrue: [ self codeCell up. ^ self ].
action = #down ifTrue: [ self codeCell down. ^ self ].
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ labelFor: aLanguageID
hResizing: #shrinkWrap;
vResizing: #shrinkWrap.
result addMorph: languageName asMorph.
result addMorph: (self iconFor: aLanguageID) asMorph.
result addMorph: (Polyglot iconFor: aLanguageID) asMorph.
^ result
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
"instance" : {
"codeCell" : "fn 3/19/2019 18:19",
"codeCell:" : "fn 3/19/2019 18:19",
"handleMouseDown:" : "fn 4/13/2019 23:19",
"handleMouseDown:" : "fn 6/20/2019 17:19",
"handlesMouseOver:" : "fn 3/26/2019 18:11",
"handlesMouseOverDragging:" : "fn 3/26/2019 18:11",
"iconFor:" : "fn 4/13/2019 23:19",
"indicateKeyboardFocus" : "fn 3/19/2019 19:06",
"initialize" : "fn 3/27/2019 10:38",
"labelFor:" : "fn 4/13/2019 23:19",
"labelFor:" : "fn 6/20/2019 17:16",
"refresh" : "fn 4/13/2019 23:19" } }
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ helpers
colorFor: aLanguageID
| id |
id := aLanguageID asLowercase.
id = self markdownID ifTrue: [^ Color fromString: '#E0E0E0' ].
id = 'js' ifTrue: [^ Color fromString: '#FFEB3B'].
id = 'llvm' ifTrue: [^ Color fromString: '#CE93D8'].
id = 'python' ifTrue: [^ Color fromString: '#039BE5'].
id = 'r' ifTrue: [^ Color fromString: '#81D4FA'].
id = 'ruby' ifTrue: [^ Color fromString: '#E57373'].
id = 'squeaksmalltalk' ifTrue: [^ Color fromString: '#9CCC65'].
id = Polyglot languageIdJS ifTrue: [^ Color fromString: '#FFEB3B'].
id = Polyglot languageIdLLVM ifTrue: [^ Color fromString: '#CE93D8'].
id = Polyglot languageIdMarkdown ifTrue: [^ Color fromString: '#E0E0E0' ].
id = Polyglot languageIdPython ifTrue: [^ Color fromString: '#039BE5'].
id = Polyglot languageIdR ifTrue: [^ Color fromString: '#81D4FA'].
id = Polyglot languageIdRuby ifTrue: [^ Color fromString: '#E57373'].
id = Polyglot languageIdSqueakSmalltalk ifTrue: [^ Color fromString: '#9CCC65'].
^ Color gray

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
constants
markdownName
^ self markdownID asString capitalized
^ Polyglot languageIdMarkdown capitalized
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
{
"class" : {
"colorFor:" : "fn 3/27/2019 10:22",
"colorFor:" : "fn 6/20/2019 17:18",
"explorerMorphFor:" : "fn 3/26/2019 11:59",
"iconJavascript" : "fn 3/26/2019 18:27",
"iconLLVM" : "fn 3/26/2019 18:28",
"iconMarkdown" : "fn 3/26/2019 18:24",
"iconPython" : "fn 3/26/2019 18:23",
"iconR" : "fn 3/26/2019 18:27",
"iconRuby" : "fn 3/26/2019 18:27",
"iconSqueakSmalltalk" : "fn 3/26/2019 18:32",
"initialize" : "fn 4/14/2019 00:01",
"markdownID" : "fn 3/26/2019 11:58",
"markdownName" : "fn 3/26/2019 11:58",
"markdownName" : "fn 6/20/2019 17:19",
"open" : "fn 3/26/2019 09:18",
"registerInWorldMenu" : "fn 4/13/2019 23:58" },
"instance" : {
Expand Down

0 comments on commit e6f4678

Please sign in to comment.