Eris.st 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. EnyoFriend subclass: #Eris
  2. instanceVariableNames: ''
  3. category: 'Eris'!
  4. !Eris methodsFor: 'actions'!
  5. doIt
  6. | result |
  7. [ result := self eval: self dollar richText getValue ]
  8. on: Error
  9. do: [:ex |
  10. ^self warn: ex messageText title: 'Error' button: 'Ooops...'].
  11. ^result
  12. !
  13. clear
  14. self dollar richText setValue: ''
  15. !
  16. eval: aString
  17. | compiler node |
  18. compiler := Compiler new.
  19. node := compiler parseExpression: aString.
  20. node isParseFailure ifTrue: [
  21. ^self warn: 'Ehrm, you are a Smalltalk n00b, right? That is not valid syntax.' title: 'Parsing Error' button: 'Okidoki...'].
  22. ^compiler loadExpression: aString.
  23. !
  24. printString
  25. ^''
  26. !
  27. warn: aString title: aTitle button: caption
  28. | block popup |
  29. block := [popup close].
  30. <props = {kind: 'ModalDialog', caption: aTitle, components: [
  31. {kind: 'Control', content: aString, className: 'enyo-text-error warning-icon'},
  32. {kind: 'Button', caption: caption, onclick: 'closePopup', style: 'margin-top:10px'}],
  33. closePopup: block}>.
  34. popup := enyo create: props.
  35. popup openAtCenter
  36. !
  37. print: aString
  38. self dollar richText setValue: (self dollar richText getValue), ' ', aString
  39. !
  40. quack
  41. "(self kind: 'Sound'; src: 'DuckQwaq.wav'; create) play"
  42. (enyo create: (Dictionary new at: 'kind' put: 'Sound'; at: 'src' put: 'DuckQwaq.wav'; yourself)) play
  43. !
  44. printIt
  45. self print: self doIt printString
  46. ! !
  47. !Eris methodsFor: 'initialization'!
  48. initialize
  49. | props doItBlock printItBlock quackBlock clearBlock |
  50. super initialize.
  51. doItBlock := [self doIt].
  52. printItBlock := [self printIt].
  53. quackBlock := [self quack].
  54. clearBlock := [self clear].
  55. <props = {kind: 'VFlexBox', components: [
  56. {kind: 'PageHeader', content: 'Eris'},
  57. {kind: 'RowGroup', caption: 'Workspace', components: [
  58. {kind: 'RichText', richContent: false,
  59. value: 'Put some funky Amber code here...',
  60. autoWordComplete: false, spellcheck: false, autocorrect: false,
  61. autoCapitalize: 'lowercase', alwaysLooksFocused: true
  62. },
  63. {kind: 'Toolbar', components: [
  64. {caption: 'Do it', onclick: 'doit'},
  65. {caption: 'Print it', onclick: 'printit'},
  66. {caption: 'Clear', onclick: 'clear'},
  67. {kind: 'Spacer'},
  68. {caption: 'Quack!!', onclick: 'quack'}]}]}],
  69. doit: doItBlock,
  70. printit: printItBlock,
  71. quack: quackBlock,
  72. clear: clearBlock}>.
  73. ui := enyo create: props.
  74. ! !