diff --git a/content/keywords/ar.yaml b/content/keywords/ar.yaml index d6b5909f8e4..e87efe65f46 100644 --- a/content/keywords/ar.yaml +++ b/content/keywords/ar.yaml @@ -53,4 +53,5 @@ green: اخضر orange: برتقالي pink: زهري pressed: pressed +button: button not in: not in diff --git a/content/keywords/bg.yaml b/content/keywords/bg.yaml index 021009ac0b6..adbedf8742f 100644 --- a/content/keywords/bg.yaml +++ b/content/keywords/bg.yaml @@ -53,4 +53,5 @@ red: червено white: бяло yellow: жълто pressed: pressed +button: button not in: not in diff --git a/content/keywords/bn.yaml b/content/keywords/bn.yaml index f22d1adc54e..a310aeedded 100644 --- a/content/keywords/bn.yaml +++ b/content/keywords/bn.yaml @@ -53,4 +53,5 @@ pink: pink white: white yellow: yellow pressed: pressed +button: button not in: not in diff --git a/content/keywords/cs.yaml b/content/keywords/cs.yaml index 4b996d0168f..471df9188d9 100644 --- a/content/keywords/cs.yaml +++ b/content/keywords/cs.yaml @@ -53,4 +53,5 @@ red: red white: white yellow: yellow pressed: pressed +button: button not in: not in diff --git a/content/keywords/de.yaml b/content/keywords/de.yaml index 27398325f10..7b24077c481 100644 --- a/content/keywords/de.yaml +++ b/content/keywords/de.yaml @@ -53,4 +53,5 @@ red: Rot white: Weiß yellow: Gelb pressed: gedrückt +button: button not in: nicht in diff --git a/content/keywords/el.yaml b/content/keywords/el.yaml index 64bb777b833..cd3d8dcb411 100644 --- a/content/keywords/el.yaml +++ b/content/keywords/el.yaml @@ -53,4 +53,5 @@ red: red white: white yellow: yellow pressed: pressed +button: button not in: not in diff --git a/content/keywords/en.yaml b/content/keywords/en.yaml index ffd9ca0f494..02f1b51c441 100644 --- a/content/keywords/en.yaml +++ b/content/keywords/en.yaml @@ -54,3 +54,4 @@ length: length comma: ',' quote: "'" pressed: pressed +button: button \ No newline at end of file diff --git a/content/keywords/eo.yaml b/content/keywords/eo.yaml index ccc34e9bf96..f884d56e362 100644 --- a/content/keywords/eo.yaml +++ b/content/keywords/eo.yaml @@ -53,4 +53,5 @@ length: longo comma: ',' quote: "'" pressed: pressed +button: button not in: not in diff --git a/content/keywords/es.yaml b/content/keywords/es.yaml index edf3f7e15d1..45717940889 100644 --- a/content/keywords/es.yaml +++ b/content/keywords/es.yaml @@ -53,4 +53,5 @@ purple: púrpura red: rojo white: blanco pressed: presionada +button: button not in: no en diff --git a/content/keywords/et.yaml b/content/keywords/et.yaml index 4e71db28378..9e765f6d3ca 100644 --- a/content/keywords/et.yaml +++ b/content/keywords/et.yaml @@ -53,4 +53,5 @@ elif: muidukui comma: ',' quote: "'" pressed: pressed +button: button not in: not in diff --git a/content/keywords/fa.yaml b/content/keywords/fa.yaml index 61ff5bc0e1f..71d226568f4 100644 --- a/content/keywords/fa.yaml +++ b/content/keywords/fa.yaml @@ -53,4 +53,5 @@ red: قرمز white: سفید yellow: زرد pressed: pressed +button: button not in: not in diff --git a/content/keywords/fi.yaml b/content/keywords/fi.yaml index 011732b7d73..32da7b50dae 100644 --- a/content/keywords/fi.yaml +++ b/content/keywords/fi.yaml @@ -54,3 +54,4 @@ comma: ',' quote: "'" pressed: painettu not in: not in +button: button diff --git a/content/keywords/fr.yaml b/content/keywords/fr.yaml index 59f3ddfa771..dc2a1e83c9b 100644 --- a/content/keywords/fr.yaml +++ b/content/keywords/fr.yaml @@ -53,4 +53,5 @@ red: rouge white: blanc yellow: jaune pressed: pressed +button: button not in: not in diff --git a/content/keywords/fy.yaml b/content/keywords/fy.yaml index 21badbe5e4b..7ea82437810 100644 --- a/content/keywords/fy.yaml +++ b/content/keywords/fy.yaml @@ -53,4 +53,5 @@ yellow: yellow color: color black: black pressed: pressed +button: button not in: not in diff --git a/content/keywords/he.yaml b/content/keywords/he.yaml index 4fa341475bf..832b2d65e25 100644 --- a/content/keywords/he.yaml +++ b/content/keywords/he.yaml @@ -53,4 +53,5 @@ elif: אחרתאם comma: ',' quote: "'" pressed: pressed +button: button not in: not in diff --git a/content/keywords/hi.yaml b/content/keywords/hi.yaml index 5d1b951c91a..906e5ad8539 100644 --- a/content/keywords/hi.yaml +++ b/content/keywords/hi.yaml @@ -53,4 +53,5 @@ red: red white: white yellow: yellow pressed: pressed +button: button not in: not in diff --git a/content/keywords/hu.yaml b/content/keywords/hu.yaml index bb76f58dd79..f26e72003a4 100644 --- a/content/keywords/hu.yaml +++ b/content/keywords/hu.yaml @@ -53,4 +53,5 @@ green: zöld orange: narancs yellow: sárga pressed: pressed +button: button not in: not in diff --git a/content/keywords/id.yaml b/content/keywords/id.yaml index 4a9a0d76694..9d4daacb841 100644 --- a/content/keywords/id.yaml +++ b/content/keywords/id.yaml @@ -53,4 +53,5 @@ red: red white: white yellow: yellow pressed: pressed +button: button not in: not in diff --git a/content/keywords/it.yaml b/content/keywords/it.yaml index ebba4fdfcb3..1e2a9842c97 100644 --- a/content/keywords/it.yaml +++ b/content/keywords/it.yaml @@ -53,4 +53,5 @@ red: rosso white: bianco yellow: giallo pressed: pressed +button: button not in: not in diff --git a/content/keywords/ja.yaml b/content/keywords/ja.yaml index 5848027852b..5f7424dce67 100644 --- a/content/keywords/ja.yaml +++ b/content/keywords/ja.yaml @@ -53,4 +53,5 @@ to: to 0: '0' comma: ',' pressed: pressed +button: button not in: not in diff --git a/content/keywords/ko.yaml b/content/keywords/ko.yaml index 2bfecc77da1..5c2ebc5d87f 100644 --- a/content/keywords/ko.yaml +++ b/content/keywords/ko.yaml @@ -53,4 +53,5 @@ length: length comma: ',' quote: "'" pressed: pressed +button: button not in: not in diff --git a/content/keywords/nb_NO.yaml b/content/keywords/nb_NO.yaml index 89ae17241a1..767422dcb39 100644 --- a/content/keywords/nb_NO.yaml +++ b/content/keywords/nb_NO.yaml @@ -53,4 +53,5 @@ red: red white: white yellow: yellow pressed: pressed +button: button not in: not in diff --git a/content/keywords/nl.yaml b/content/keywords/nl.yaml index 5a7d6bb36f1..d948628da70 100644 --- a/content/keywords/nl.yaml +++ b/content/keywords/nl.yaml @@ -53,4 +53,5 @@ length: lengte comma: ',' quote: "'" pressed: ingedrukt +button: knop not in: not in diff --git a/content/keywords/pa_PK.yaml b/content/keywords/pa_PK.yaml index 34d294c6113..b6306c18c4c 100644 --- a/content/keywords/pa_PK.yaml +++ b/content/keywords/pa_PK.yaml @@ -53,4 +53,5 @@ length: لمبائی comma: '،' quote: "'" pressed: pressed +button: button not in: not in diff --git a/content/keywords/pl.yaml b/content/keywords/pl.yaml index 2e38357b5e7..dc3bd4a3138 100644 --- a/content/keywords/pl.yaml +++ b/content/keywords/pl.yaml @@ -52,5 +52,6 @@ purple: fioletowy red: czerwony white: biały yellow: żółty +button: button pressed: naciśnięty not in: nie w diff --git a/content/keywords/pt_BR.yaml b/content/keywords/pt_BR.yaml index e68770fac98..a4a6a17f72e 100644 --- a/content/keywords/pt_BR.yaml +++ b/content/keywords/pt_BR.yaml @@ -53,4 +53,5 @@ pink: rosa white: branco yellow: amarelo pressed: pressed +button: button not in: not in diff --git a/content/keywords/pt_PT.yaml b/content/keywords/pt_PT.yaml index b4b03a0e66b..88fcf7d2d26 100644 --- a/content/keywords/pt_PT.yaml +++ b/content/keywords/pt_PT.yaml @@ -53,4 +53,5 @@ red: vermelho white: branco yellow: amarelo pressed: pressed +button: button not in: not in diff --git a/content/keywords/ru.yaml b/content/keywords/ru.yaml index a3636cb85b9..923f00760a2 100644 --- a/content/keywords/ru.yaml +++ b/content/keywords/ru.yaml @@ -53,4 +53,5 @@ red: красный white: белый yellow: жёлтый pressed: нажмите +button: button not in: not in diff --git a/content/keywords/sq.yaml b/content/keywords/sq.yaml index d9a03bbeec8..e38268eea3a 100644 --- a/content/keywords/sq.yaml +++ b/content/keywords/sq.yaml @@ -53,4 +53,5 @@ length: gjatësia comma: ',' quote: "'" pressed: shtypur +button: button not in: not in diff --git a/content/keywords/sv.yaml b/content/keywords/sv.yaml index 512a1e7d07c..fbb7c85917f 100644 --- a/content/keywords/sv.yaml +++ b/content/keywords/sv.yaml @@ -53,4 +53,5 @@ length: längd comma: ',' quote: "'" pressed: pressed +button: button not in: not in diff --git a/content/keywords/sw.yaml b/content/keywords/sw.yaml index 10acc161705..3229bc16ba0 100644 --- a/content/keywords/sw.yaml +++ b/content/keywords/sw.yaml @@ -53,4 +53,5 @@ orange: orange pink: pink purple: purple pressed: pressed +button: button not in: not in diff --git a/content/keywords/th.yaml b/content/keywords/th.yaml index f22b2d17edc..9917e128cec 100644 --- a/content/keywords/th.yaml +++ b/content/keywords/th.yaml @@ -53,4 +53,5 @@ length: ความยาว comma: ',' quote: "'" pressed: pressed +button: button not in: not in diff --git a/content/keywords/tl.yaml b/content/keywords/tl.yaml index 587b51edfbd..16568f54259 100644 --- a/content/keywords/tl.yaml +++ b/content/keywords/tl.yaml @@ -54,3 +54,4 @@ comma: ',' quote: "'" pressed: pressed not in: not in +button: button diff --git a/content/keywords/tn.yaml b/content/keywords/tn.yaml index 9f11b5807a1..d29f37fa119 100644 --- a/content/keywords/tn.yaml +++ b/content/keywords/tn.yaml @@ -53,4 +53,5 @@ length: length comma: ',' quote: "'" pressed: pressed +button: button not in: not in diff --git a/content/keywords/tr.yaml b/content/keywords/tr.yaml index 99d318843ac..d7fb12cdb14 100644 --- a/content/keywords/tr.yaml +++ b/content/keywords/tr.yaml @@ -53,4 +53,5 @@ red: red white: white yellow: yellow pressed: pressed +button: button not in: not in diff --git a/content/keywords/uk.yaml b/content/keywords/uk.yaml index 7fad0f06f2e..01fa8fd8bc1 100644 --- a/content/keywords/uk.yaml +++ b/content/keywords/uk.yaml @@ -53,4 +53,5 @@ is: це sleep: почекай add: додай pressed: натиснув +button: button not in: не в diff --git a/content/keywords/ur.yaml b/content/keywords/ur.yaml index b7caa84d151..499236956b8 100644 --- a/content/keywords/ur.yaml +++ b/content/keywords/ur.yaml @@ -53,4 +53,5 @@ length: length comma: ',' quote: "'" pressed: pressed +button: button not in: not in diff --git a/content/keywords/vi.yaml b/content/keywords/vi.yaml index a152055286c..03ad3132a05 100644 --- a/content/keywords/vi.yaml +++ b/content/keywords/vi.yaml @@ -54,3 +54,4 @@ comma: ',' quote: "'" pressed: pressed not in: not in +button: button diff --git a/content/keywords/zh_Hans.yaml b/content/keywords/zh_Hans.yaml index 55598ecdd71..4579dd883e5 100644 --- a/content/keywords/zh_Hans.yaml +++ b/content/keywords/zh_Hans.yaml @@ -53,4 +53,5 @@ red: 红色 white: 白色 yellow: 黄色 pressed: pressed +button: button not in: not in diff --git a/grammars/keywords-ar.lark b/grammars/keywords-ar.lark index 2749e101f59..90432cfcff1 100644 --- a/grammars/keywords-ar.lark +++ b/grammars/keywords-ar.lark @@ -42,3 +42,4 @@ _WHILE: ( "ـ"* "ب" "ـ"* "ي" "ـ"* "ن" "ـ"* "م" "ـ"* "ا" "ـ"* | "while _LENGTH: "ـ"* "ط" "ـ"* "و" "ـ"* "ل" "ـ"* | "length" _COLOR : ( "ـ"* "ل" "ـ"* "و" "ـ"* "ن" "ـ"* | "color") _SPACE? _PRESSED: ( "ـ"* "p" "ـ"* "r" "ـ"* "e" "ـ"* "s" "ـ"* "s" "ـ"* "e" "ـ"* "d" "ـ"* | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-bg.lark b/grammars/keywords-bg.lark index b20952df5d6..7d1fdd6e434 100644 --- a/grammars/keywords-bg.lark +++ b/grammars/keywords-bg.lark @@ -42,3 +42,4 @@ _WHILE: ("докато" | "while") _SPACE _LENGTH: "дължина" | "length" _COLOR : ("цвят" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-de.lark b/grammars/keywords-de.lark index 841118c6ae3..ed5ad927e5e 100644 --- a/grammars/keywords-de.lark +++ b/grammars/keywords-de.lark @@ -42,3 +42,4 @@ _WHILE: ("solange" | "while") _SPACE _LENGTH: "Länge" | "length" _COLOR : ("Farbe" | "color") _SPACE? _PRESSED: ("gedrückt" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-en.lark b/grammars/keywords-en.lark index a25612b1c55..c3777a2ceae 100644 --- a/grammars/keywords-en.lark +++ b/grammars/keywords-en.lark @@ -42,3 +42,4 @@ _WHILE: ("while" | "while") _SPACE _LENGTH: "length" | "length" _COLOR : ("color" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-eo.lark b/grammars/keywords-eo.lark index 5782da70ee0..7aa280ffd41 100644 --- a/grammars/keywords-eo.lark +++ b/grammars/keywords-eo.lark @@ -42,3 +42,4 @@ _WHILE: ("dum" | "while") _SPACE _LENGTH: "longo" | "length" _COLOR : ("koloro" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-es.lark b/grammars/keywords-es.lark index 320862beb55..6fec07dc62c 100644 --- a/grammars/keywords-es.lark +++ b/grammars/keywords-es.lark @@ -42,3 +42,4 @@ _WHILE: ("mientras" | "while") _SPACE _LENGTH: "longitud" | "length" _COLOR : ("color" | "color") _SPACE? _PRESSED: ("presionada" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-et.lark b/grammars/keywords-et.lark index 8594af4d9ef..f2a16465fc5 100644 --- a/grammars/keywords-et.lark +++ b/grammars/keywords-et.lark @@ -42,3 +42,4 @@ _WHILE: ("senikui" | "while") _SPACE _LENGTH: "pikkus" | "length" _COLOR : ("värv" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-fa.lark b/grammars/keywords-fa.lark index 2ae0c445ad9..3f26ab3398e 100644 --- a/grammars/keywords-fa.lark +++ b/grammars/keywords-fa.lark @@ -42,3 +42,4 @@ _WHILE: ("while" | "while") _SPACE _LENGTH: "length" | "length" _COLOR : ("رنگ" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-fi.lark b/grammars/keywords-fi.lark index ef2f606c030..de23f77d1ba 100644 --- a/grammars/keywords-fi.lark +++ b/grammars/keywords-fi.lark @@ -42,3 +42,4 @@ _WHILE: ("kun" | "while") _SPACE _LENGTH: "pituus" | "length" _COLOR : ("väri" | "color") _SPACE? _PRESSED: ("painettu" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-fr.lark b/grammars/keywords-fr.lark index b5ddb53837c..0cee3ba7ed8 100644 --- a/grammars/keywords-fr.lark +++ b/grammars/keywords-fr.lark @@ -42,3 +42,4 @@ _WHILE: ("tant que" | "while") _SPACE _LENGTH: "longueur" | "length" _COLOR : ("couleur" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-he.lark b/grammars/keywords-he.lark index ed1dee2df31..6b3eb6a089c 100644 --- a/grammars/keywords-he.lark +++ b/grammars/keywords-he.lark @@ -42,3 +42,4 @@ _WHILE: ("כלעוד" | "while") _SPACE _LENGTH: "אורך" | "length" _COLOR : ("צבע" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-hi.lark b/grammars/keywords-hi.lark index 2f9aa9a00b0..c7ec60b9170 100644 --- a/grammars/keywords-hi.lark +++ b/grammars/keywords-hi.lark @@ -42,3 +42,4 @@ _WHILE: ("व्हाइल" | "while") _SPACE _LENGTH: "लंबाई" | "length" _COLOR : ("color" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-hu.lark b/grammars/keywords-hu.lark index ca4cbd5c721..582f4364383 100644 --- a/grammars/keywords-hu.lark +++ b/grammars/keywords-hu.lark @@ -42,3 +42,4 @@ _WHILE: ("amíg" | "while") _SPACE _LENGTH: "hossz" | "length" _COLOR : ("szín" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-id.lark b/grammars/keywords-id.lark index 0f91593a819..ef3ca9e780e 100644 --- a/grammars/keywords-id.lark +++ b/grammars/keywords-id.lark @@ -42,3 +42,4 @@ _WHILE: ("selama" | "while") _SPACE _LENGTH: "panjang" | "length" _COLOR : ("warna" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-it.lark b/grammars/keywords-it.lark index 3c84d6bf5a1..03b186b6579 100644 --- a/grammars/keywords-it.lark +++ b/grammars/keywords-it.lark @@ -42,3 +42,4 @@ _WHILE: ("mentre" | "while") _SPACE _LENGTH: "lunghezza" | "length" _COLOR : ("colore" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-ja.lark b/grammars/keywords-ja.lark index 2c545d01a02..e25a2267da8 100644 --- a/grammars/keywords-ja.lark +++ b/grammars/keywords-ja.lark @@ -42,3 +42,4 @@ _WHILE: ("while" | "while") _SPACE _LENGTH: "length" | "length" _COLOR : ("いろ" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-nb_NO.lark b/grammars/keywords-nb_NO.lark index 5a9f499da37..66cc0c0eb7b 100644 --- a/grammars/keywords-nb_NO.lark +++ b/grammars/keywords-nb_NO.lark @@ -42,3 +42,4 @@ _WHILE: ("mens" | "while") _SPACE _LENGTH: "lengde" | "length" _COLOR : ("color" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-nl.lark b/grammars/keywords-nl.lark index 0c967321b49..edb00008af8 100644 --- a/grammars/keywords-nl.lark +++ b/grammars/keywords-nl.lark @@ -42,3 +42,4 @@ _WHILE: ("zolang" | "while") _SPACE _LENGTH: "lengte" | "length" _COLOR : ("kleur" | "color") _SPACE? _PRESSED: ("ingedrukt" | "pressed") _SPACE? +_BUTTON: ("knop" | "button") _SPACE? diff --git a/grammars/keywords-pa_PK.lark b/grammars/keywords-pa_PK.lark index 1c6d0d3698b..9b84269516e 100644 --- a/grammars/keywords-pa_PK.lark +++ b/grammars/keywords-pa_PK.lark @@ -1,4 +1,5 @@ -_PRINT: ("چپائی" | "print") _SPACE? + +_BUTTON: ("button" | "button") _SPACE?_PRINT: ("چپائی" | "print") _SPACE? _ASK: ("سوال" | "ask") _SPACE? _ECHO: ("فیر" | "echo") _SPACE? _FORWARD: ("اگے" | "forward") _SPACE? @@ -42,3 +43,4 @@ _WHILE: ("جدکہ" | "while") _SPACE _LENGTH: "لمبائی" | "length" _COLOR : ("رنگ" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-pl.lark b/grammars/keywords-pl.lark index 53a60aa2880..1cc7f093036 100644 --- a/grammars/keywords-pl.lark +++ b/grammars/keywords-pl.lark @@ -41,4 +41,5 @@ _OR: _SPACE ("lub" | "or") _SPACE _WHILE: ("dopóki" | "while") _SPACE _LENGTH: "długość" | "length" _COLOR : ("kolor" | "color") _SPACE? +_BUTTON: ("button" | "button") _SPACE? _PRESSED: ("naciśnięty" | "pressed") _SPACE? diff --git a/grammars/keywords-pt_BR.lark b/grammars/keywords-pt_BR.lark index d6389bb379f..327c5d522de 100644 --- a/grammars/keywords-pt_BR.lark +++ b/grammars/keywords-pt_BR.lark @@ -42,3 +42,4 @@ _WHILE: ("enquanto" | "while") _SPACE _LENGTH: "comprimento" | "length" _COLOR : ("cor" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-pt_PT.lark b/grammars/keywords-pt_PT.lark index accd63507b2..7ff74f9a81e 100644 --- a/grammars/keywords-pt_PT.lark +++ b/grammars/keywords-pt_PT.lark @@ -42,3 +42,4 @@ _WHILE: ("enquanto" | "while") _SPACE _LENGTH: "comprimento" | "length" _COLOR : ("cor" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-ru.lark b/grammars/keywords-ru.lark index a6b04f8d0b8..477c6709ae9 100644 --- a/grammars/keywords-ru.lark +++ b/grammars/keywords-ru.lark @@ -42,3 +42,4 @@ _WHILE: ("пока" | "while") _SPACE _LENGTH: "длина" | "length" _COLOR : ("цвет" | "color") _SPACE? _PRESSED: ("нажмите" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-sq.lark b/grammars/keywords-sq.lark index f09c2dc7823..7cedcf83613 100644 --- a/grammars/keywords-sq.lark +++ b/grammars/keywords-sq.lark @@ -1,4 +1,5 @@ -_PRINT: ("print" | "print") _SPACE? + +_BUTTON: ("button" | "button") _SPACE?_PRINT: ("print" | "print") _SPACE? _ASK: ("pyet" | "ask") _SPACE? _ECHO: ("përsërit" | "echo") _SPACE? _FORWARD: ("përpara" | "forward") _SPACE? @@ -42,3 +43,4 @@ _WHILE: ("derisa" | "while") _SPACE _LENGTH: "gjatësia" | "length" _COLOR : ("ngjyrë" | "color") _SPACE? _PRESSED: ("shtypur" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-sv.lark b/grammars/keywords-sv.lark index 3379707d68e..ed58bc0fe9b 100644 --- a/grammars/keywords-sv.lark +++ b/grammars/keywords-sv.lark @@ -42,3 +42,4 @@ _WHILE: ("medans" | "while") _SPACE _LENGTH: "längd" | "length" _COLOR : ("färg" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-template.lark b/grammars/keywords-template.lark index 619b74f1a7c..e7fc5a845d7 100644 --- a/grammars/keywords-template.lark +++ b/grammars/keywords-template.lark @@ -42,3 +42,4 @@ _WHILE: ({while} | "while") _SPACE _LENGTH: {length} | "length" _COLOR : ({color} | "color") _SPACE? _PRESSED: ({pressed} | "pressed") _SPACE? +_BUTTON: ({button} | "button") _SPACE? \ No newline at end of file diff --git a/grammars/keywords-th.lark b/grammars/keywords-th.lark index d4aba47a29e..6c7a54464a6 100644 --- a/grammars/keywords-th.lark +++ b/grammars/keywords-th.lark @@ -42,3 +42,4 @@ _WHILE: ("while" | "while") _SPACE _LENGTH: "ความยาว" | "length" _COLOR : ("สี" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-tn.lark b/grammars/keywords-tn.lark index ae95581e058..dec486d8440 100644 --- a/grammars/keywords-tn.lark +++ b/grammars/keywords-tn.lark @@ -42,3 +42,4 @@ _WHILE: ("while" | "while") _SPACE _LENGTH: "length" | "length" _COLOR : ("color" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-tr.lark b/grammars/keywords-tr.lark index 2f52d0837ea..7dbff46df0b 100644 --- a/grammars/keywords-tr.lark +++ b/grammars/keywords-tr.lark @@ -42,3 +42,4 @@ _WHILE: ("iken" | "while") _SPACE _LENGTH: "uzunluk" | "length" _COLOR : ("color" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-uk.lark b/grammars/keywords-uk.lark index 44a91d0ccad..9397e0ffa6a 100644 --- a/grammars/keywords-uk.lark +++ b/grammars/keywords-uk.lark @@ -42,3 +42,4 @@ _WHILE: ("тоді як" | "while") _SPACE _LENGTH: "довжина" | "length" _COLOR : ("колір" | "color") _SPACE? _PRESSED: ("натиснув" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/keywords-zh_Hans.lark b/grammars/keywords-zh_Hans.lark index c393ba7d822..ba6267d0e61 100644 --- a/grammars/keywords-zh_Hans.lark +++ b/grammars/keywords-zh_Hans.lark @@ -42,3 +42,4 @@ _WHILE: ("当的时候" | "while") _SPACE _LENGTH: "长度" | "length" _COLOR : ("颜色" | "color") _SPACE? _PRESSED: ("pressed" | "pressed") _SPACE? +_BUTTON: ("button" | "button") _SPACE? diff --git a/grammars/level5-Additions.lark b/grammars/level5-Additions.lark index 7195d5b3dce..5de4d1feded 100644 --- a/grammars/level5-Additions.lark +++ b/grammars/level5-Additions.lark @@ -3,21 +3,23 @@ _empty_program: (_EOL | _SPACE)* _non_empty_program: _EOL* (command | error_invalid) _SPACE* (_EOL+ command _SPACE*)* _EOL* //lines may end on spaces and might be separated by many newlines //placing assign after print means print is will print 'is' and print is Felienne will print 'is Felienne' -command:+= ifpressed_else | ifpressed | ifelse | ifs -= error_invalid | error_ask_no_quotes > assign -_if_less_command: print | ask | turtle | assign_list | add | remove | sleep | error_print_no_quotes | assign +command:+= assign_button | ifpressed_else | ifpressed | ifelse | ifs -= error_invalid | error_ask_no_quotes > assign +_if_less_command: print | ask | turtle | assign_button | assign_list | add | remove | sleep | error_print_no_quotes | assign // error_invalid is moved from to command to program, so that command rules have priority over error_invalid error_invalid: textwithoutspaces _SPACE* (quoted_text | textwithspaces)? - +//todo: list_access_var can be merged with var? would simplify rewriting a bit, some duplication now in processing +list_access_var: var _IS var _AT (INT | random) +assign_button: NAME _IS _BUTTON assign_list: var _IS textwithspaces (_COMMA textwithspaces)+ assign: var _IS (list_access | textwithspaces) error_print_no_quotes: _PRINT (textwithoutspaces | list_access | var_access) (_SPACE (textwithoutspaces | list_access | var_access))* -> error_print_nq // new commands for level 5 -ifpressed_else: _IF LETTER_OR_NUMERAL _IS _PRESSED _EOL* _if_less_command (_SPACE+ _EOL* | _SPACE* _EOL+) _ELSE (_SPACE+ _EOL* | _SPACE* _EOL+) _if_less_command -ifpressed: _IF LETTER_OR_NUMERAL _IS _PRESSED _EOL* _if_less_command +ifpressed_else: _IF (LETTER_OR_NUMERAL | var) _IS _PRESSED _EOL* _if_less_command (_SPACE+ _EOL* | _SPACE* _EOL+) _ELSE (_SPACE+ _EOL* | _SPACE* _EOL+) _if_less_command +ifpressed: _IF (LETTER_OR_NUMERAL | var) _IS _PRESSED _EOL* _if_less_command _if_clause: _IF (condition (_SPACE+ _EOL* | _SPACE* _EOL+) | condition_spaces _SPACE* _EOL+ | error_condition) _if_less_command error_condition: condition_spaces _SPACE diff --git a/grammars/level6-Additions.lark b/grammars/level6-Additions.lark index 2710e493da2..7e0c9d36e02 100644 --- a/grammars/level6-Additions.lark +++ b/grammars/level6-Additions.lark @@ -2,8 +2,8 @@ _print_argument: (_SPACE | quoted_text | list_access | expression | print_expres ?print_expression: var_access_print | error_unsupported_number | INT // redefining it entirely since it has many order-depending rules -command: print | turtle | add | remove | sleep | error_print_no_quotes | ifpressed_else | ifpressed | ifelse | ifs | ask | assign | assign_list | error_invalid_space | error_text_no_print | empty_line -_if_less_command: print | turtle | add | remove | sleep | error_print_no_quotes | ask | assign | assign_list +command: print | turtle | add | remove | sleep | error_print_no_quotes | ifpressed_else | ifpressed | ifelse | ifs | ask | assign_button | assign | assign_list | error_invalid_space | error_text_no_print | empty_line +_if_less_command: print | turtle | add | remove | sleep | error_print_no_quotes | ask | assign_button | assign | assign_list //splitting these commands into two rules, one for equals and one for is so they can be properly handled in the translator ask: var (_IS | _EQUALS) _ASK (_print_argument)? @@ -12,6 +12,8 @@ equality_check: (textwithoutspaces | INT) (_IS | _EQUALS) (textwithoutspaces | q condition:+= equality_check -= equality_check +list_access_var: var (_IS | _EQUALS) var _AT (INT | random) +assign_button: NAME (_IS | _EQUALS) _BUTTON assign_list: var (_IS | _EQUALS) textwithspaces (_COMMA textwithspaces)+ assign: var (_IS | _EQUALS) (list_access | expression | textwithoutspaces | textwithspaces) @@ -25,4 +27,3 @@ turtle: _FORWARD ((NUMBER | list_access | textwithoutspaces | expression))? -> f ?atom: INT | _MINUS INT |var_access | error_unsupported_number | textwithoutspaces error_unsupported_number: /([-+]?(\d+[\.،,,]\d+))/ -> error_unsupported_number - diff --git a/grammars/level8-Additions.lark b/grammars/level8-Additions.lark index 917860dc93e..6a2b2d94e80 100644 --- a/grammars/level8-Additions.lark +++ b/grammars/level8-Additions.lark @@ -8,8 +8,9 @@ condition: equality_check | in_list_check equality_check: (textwithoutspaces | NUMBER) (_IS | _EQUALS) (textwithoutspaces | NUMBER) (_SPACE | textwithoutspaces | NUMBER)* // from level 8 on ifpressed is implemented slightly differently -ifpressed: _IF LETTER_OR_NUMERAL _IS _PRESSED _EOL (_SPACE command) (_EOL _SPACE command)* _EOL? _END_BLOCK -ifpressed_else: _IF LETTER_OR_NUMERAL _IS _PRESSED _EOL (_SPACE command) (_EOL _SPACE command)* _EOL? _END_BLOCK (_SPACE)* _ELSE (_SPACE)* _EOL (_SPACE command) (_EOL _SPACE command)* _EOL? _END_BLOCK +ifpressed: _IF (LETTER_OR_NUMERAL | NAME) _IS _PRESSED _EOL (_SPACE command) (_EOL _SPACE command)* _EOL? _END_BLOCK +ifpressed_else: _IF (LETTER_OR_NUMERAL | NAME) _IS _PRESSED _EOL (_SPACE command) (_EOL _SPACE command)* _EOL? _END_BLOCK (_SPACE)* _ELSE (_SPACE)* _EOL (_SPACE command) (_EOL _SPACE command)* _EOL? _END_BLOCK + // from level 8 on if is implemented slightly differently elses: _EOL (_SPACE)* _ELSE (_SPACE)* _EOL (_SPACE command) (_EOL _SPACE command)* _EOL? _END_BLOCK ifpressed_elses: elses diff --git a/hedy.py b/hedy.py index 123eb2dfb1a..f2646f2ee07 100644 --- a/hedy.py +++ b/hedy.py @@ -247,20 +247,20 @@ def promote_types(types, rules): 2: ['print', 'ask', 'is', 'turn', 'forward', 'color', 'sleep'], 3: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from'], 4: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from'], - 5: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed'], - 6: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed'], - 7: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'repeat', 'times'], - 8: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'repeat', 'times'], - 9: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'repeat', 'times'], - 10: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'repeat', 'times', 'for'], - 11: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'for', 'range', 'repeat'], - 12: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'for', 'range', 'repeat'], - 13: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'for', 'range', 'repeat', 'and', 'or'], - 14: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'for', 'range', 'repeat', 'and', 'or'], - 15: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'for', 'range', 'repeat', 'and', 'or', 'while'], - 16: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'for', 'range', 'repeat', 'and', 'or', 'while'], - 17: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'for', 'range', 'repeat', 'and', 'or', 'while', 'elif'], - 18: ['is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'if', 'not in', 'else', 'for', 'pressed', 'range', 'repeat', 'and', 'or', 'while', 'elif', 'input'], + 5: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button'], + 6: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button'], + 7: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'repeat', 'times'], + 8: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'repeat', 'times'], + 9: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'repeat', 'times'], + 10: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'repeat', 'times', 'for'], + 11: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'for', 'range', 'repeat'], + 12: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'for', 'range', 'repeat'], + 13: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'for', 'range', 'repeat', 'and', 'or'], + 14: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'for', 'range', 'repeat', 'and', 'or'], + 15: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'for', 'range', 'repeat', 'and', 'or', 'while'], + 16: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'for', 'range', 'repeat', 'and', 'or', 'while'], + 17: ['ask', 'is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'not in', 'if', 'else', 'pressed', 'button', 'for', 'range', 'repeat', 'and', 'or', 'while', 'elif'], + 18: ['is', 'print', 'forward', 'turn', 'color', 'sleep', 'at', 'random', 'add', 'to', 'remove', 'from', 'in', 'if', 'not in', 'else', 'for', 'pressed', 'button', 'range', 'repeat', 'and', 'or', 'while', 'elif', 'input'], } command_turn_literals = ['right', 'left'] @@ -998,6 +998,9 @@ def ifpressed(self, args): def ifpressed_else(self, args): return True + def assign_button(self, args): + return True + class AllCommands(Transformer): def __init__(self, level): @@ -1718,38 +1721,70 @@ def not_in_list_check(self, meta, args): arg1 = self.process_variable(args[1], meta.line) return f"{arg0} not in {arg1}" - def make_ifpressed_command(self, command): - if self.ifpressed_prefix_added: - return command - else: - command = (f"""\ + def assign_button(self, meta, args): + button_name = self.process_variable(args[0], meta.line) + return f"""create_button({button_name})""" + + def make_ifpressed_command(self, command, button = False): + command_suffix = (f"""\ while not pygame_end: pygame.display.update() event = pygame.event.wait() if event.type == pygame.QUIT: pygame_end = True pygame.quit() - break + break""") + + if button: + command = f"""\ + if event.type == pygame.USEREVENT: +{ConvertToPython.indent(command, 4)}""" + else: + command = f"""\ if event.type == pygame.KEYDOWN: -{command}""") +{ConvertToPython.indent(command, 4)}""" + + if self.ifpressed_prefix_added: + return command + else: self.ifpressed_prefix_added = True + return command_suffix + "\n" + command - return command - def ifpressed(self, met, args): - return self.make_ifpressed_command(f"""\ - if event.unicode == '{args[0]}': -{ConvertToPython.indent(args[1], 6)} - break""") + def ifpressed(self, meta, args): + button_name = self.process_variable(args[0], meta.line) + if (len(args[0]) > 1): + return self.make_ifpressed_command(f"""\ +if event.key == {button_name}: +{ConvertToPython.indent(args[1])} + break""", True) + else: + return self.make_ifpressed_command(f"""\ +if event.unicode == '{args[0]}': +{ConvertToPython.indent(args[1])} + break""") + "\n" + self.make_ifpressed_command(f"""\ +if event.key == {button_name}: +{ConvertToPython.indent(args[1])} + break""", True) - def ifpressed_else(self, met, args): - return self.make_ifpressed_command(f"""\ - if event.unicode == '{args[0]}': -{ConvertToPython.indent(args[1], 6)} - break - else: -{ConvertToPython.indent(args[2], 6)} - break""") + def ifpressed_else(self, meta, args): + if (len(args[0]) > 1): + button_name = self.process_variable(args[0], meta.line) + return self.make_ifpressed_command(f"""\ +if event.key == {button_name}: +{ConvertToPython.indent(args[1])} + break +else: +{ConvertToPython.indent(args[2])} + break""", True) + else: + return self.make_ifpressed_command(f"""\ +if event.unicode == '{args[0]}': +{ConvertToPython.indent(args[1])} + break +else: +{ConvertToPython.indent(args[2])} + break""") @v_args(meta=True) @@ -1899,23 +1934,39 @@ def ifpressed(self, met, args): args = [a for a in args if a != ""] # filter out in|dedent tokens all_lines = '\n'.join([x for x in args[1:]]) - all_lines = ConvertToPython.indent(all_lines, 6) + all_lines = ConvertToPython.indent(all_lines) - return self.make_ifpressed_command(f"""\ - if event.unicode == '{args[0]}': + if (len(args[0]) > 1): + button_name = self.process_variable(args[0], met.line) + return self.make_ifpressed_command(f"""\ +if event.key == {button_name}: {all_lines} - break""") + break""", True) + else: + return self.make_ifpressed_command(f"""\ +if event.unicode == '{args[0]}': +{all_lines} + break""") def ifpressed_else(self, met, args): args = [a for a in args if a != ""] # filter out in|dedent tokens all_lines = '\n'.join([x for x in args[1:]]) - all_lines = ConvertToPython.indent(all_lines, 6) + all_lines = ConvertToPython.indent(all_lines) - return self.make_ifpressed_command(f"""\ - if event.unicode == '{args[0]}': + if (len(args[0]) > 1): + button_name = self.process_variable(args[0], met.line) + return self.make_ifpressed_command(f"""\ +if event.key == {button_name}: +{all_lines} + break + """, True) + else: + return self.make_ifpressed_command(f"""\ +if event.unicode == '{args[0]}': {all_lines} - break""") + break + """) def elses(self, meta, args): args = [a for a in args if a != ""] # filter out in|dedent tokens diff --git a/static/js/app.ts b/static/js/app.ts index f40be2e88f2..957f288d04d 100644 --- a/static/js/app.ts +++ b/static/js/app.ts @@ -26,10 +26,18 @@ t.showturtle() const pygame_prefix = `# coding=utf8 import pygame +import buttons pygame.init() canvas = pygame.display.set_mode((711,300)) canvas.fill(pygame.Color(247, 250, 252, 255)) pygame_end = False + +button_list = [] +def create_button(name): + if name not in button_list: + button_list.append(name) + buttons.add(name) + `; const pygame_suffix = @@ -360,6 +368,11 @@ function clearOutput() { outputDiv.append(variables); error.hide(); success.hide(); + + // Clear the user created buttons. + const buttonsDiv = $('#dynamic-buttons'); + buttonsDiv.empty(); + buttonsDiv.hide(); } export function runit(level: string, lang: string, disabled_prompt: string, cb: () => void) { @@ -1039,6 +1052,9 @@ export function runPythonProgram(this: any, code: string, hasTurtle: boolean, ha './version.js': { path: "/vendor/pygame_4_skulpt/version.js", }, + './buttons.js': { + path: "/js/buttons.js", + }, }; code_prefix += pygame_prefix; @@ -1053,7 +1069,7 @@ export function runPythonProgram(this: any, code: string, hasTurtle: boolean, ha if (!hasTurtle && !codeContainsInputFunctionBeforePygame) { $('#pygame-modal').show(); } - + document.onkeydown = animateKeys; window.State.pygame_running = true; } @@ -1843,16 +1859,16 @@ export function change_language(lang: string) { contentType: 'application/json', dataType: 'json' }).done(function(response: any) { - if (response.succes){ + if (response.succes){ // Check if keyword_language is set to change it to English const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); if (urlParams.get('keyword_language') !== null) { urlParams.set('keyword_language', 'en'); - window.location.search = urlParams.toString(); + window.location.search = urlParams.toString(); } else { location.reload(); - } + } } }).fail(function(xhr) { console.error(xhr); diff --git a/static/js/appbundle.js b/static/js/appbundle.js index 50afd1d989f..e435867b3dc 100644 --- a/static/js/appbundle.js +++ b/static/js/appbundle.js @@ -10,6 +10,7 @@ t.speed(3) t.showturtle() `,Fd=`# coding=utf8 import pygame +import buttons pygame.init() canvas = pygame.display.set_mode((711,300)) canvas.fill(pygame.Color(247, 250, 252, 255)) diff --git a/static/js/buttons.js b/static/js/buttons.js new file mode 100644 index 00000000000..fea36e8ae30 --- /dev/null +++ b/static/js/buttons.js @@ -0,0 +1,37 @@ +// This file defines a module that can be imported as an external module +// in Python through Skulpt. +// +// The module is defined in a variable called $builtinmodule (that is a +// function for some reason) in which a variable mod is created containing all +// the member functions and classes of that module. + +var $builtinmodule = function (name) { + var mod = {}; + + mod.add = new Sk.builtin.func(buttons_add); + + return mod; +}; + +function buttons_add(name) { + let button = document.createElement("button"); + var name_js = Sk.ffi.remapToJs(name); + button.classList.add("blue-btn"); + button.innerText = name; + button.onclick = function () { + button_click(name); + }; + document.getElementById("dynamic-buttons").appendChild(button); + + document.getElementById("dynamic-buttons").style.display = ""; +} + +var button_click = function (name) { + var name_js = Sk.ffi.remapToJs(name); + + // For this to work the first element of e needs to be a constant indicating + // this event is from a button, to make sure it is unique we use USEREVENT + // the dictionary can then be filled with whatever data we need. + var e = [PygameLib.constants.USEREVENT, { key: name }]; + PygameLib.eventQueue.unshift(e); +} diff --git a/templates/incl-editor-and-output.html b/templates/incl-editor-and-output.html index b7c789002ed..2a3498022e7 100644 --- a/templates/incl-editor-and-output.html +++ b/templates/incl-editor-and-output.html @@ -104,7 +104,7 @@ -