Eris.st 2.1 KB

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