2
0

Helios-Workspace.st 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. Smalltalk createPackage: 'Helios-Workspace'!
  2. Object subclass: #HLCodeModel
  3. instanceVariableNames: 'announcer environment receiver'
  4. package: 'Helios-Workspace'!
  5. !HLCodeModel methodsFor: 'accessing'!
  6. announcer
  7. ^ announcer ifNil: [ announcer := Announcer new ]
  8. !
  9. environment
  10. ^ environment ifNil: [ HLManager current environment ]
  11. !
  12. environment: anEnvironment
  13. environment := anEnvironment
  14. !
  15. receiver
  16. ^ receiver ifNil: [ receiver := self defaultReceiver ]
  17. !
  18. receiver: anObject
  19. receiver := anObject
  20. ! !
  21. !HLCodeModel methodsFor: 'actions'!
  22. browse: anObject
  23. anObject browse
  24. !
  25. doIt: aString
  26. "Evaluate aString in the receiver's `environment`.
  27. Note: Catch any error and handle it manually, bypassing
  28. boot.js behavior to avoid the browser default action on
  29. ctrl+d/ctrl+p.
  30. See https://github.com/amber-smalltalk/amber/issues/882"
  31. ^ [ self environment evaluate: aString for: self receiver ]
  32. tryCatch: [ :e |
  33. ErrorHandler handleError: e.
  34. nil ]
  35. !
  36. inspect: anObject
  37. self environment inspect: anObject
  38. ! !
  39. !HLCodeModel methodsFor: 'defaults'!
  40. defaultReceiver
  41. ^ self environment doItReceiver
  42. ! !
  43. !HLCodeModel class methodsFor: 'actions'!
  44. on: anEnvironment
  45. ^ self new
  46. environment: anEnvironment;
  47. yourself
  48. ! !
  49. HLWidget subclass: #HLCodeWidget
  50. instanceVariableNames: 'model wrapper code editor state'
  51. package: 'Helios-Workspace'!
  52. !HLCodeWidget methodsFor: 'accessing'!
  53. announcer
  54. ^ self model announcer
  55. !
  56. contents
  57. ^ editor getValue
  58. !
  59. contents: aString
  60. editor setValue: aString.
  61. state ifNotNil: [ self updateState ]
  62. !
  63. currentLine
  64. ^editor getLine: (editor getCursor line)
  65. !
  66. currentLineOrSelection
  67. ^editor somethingSelected
  68. ifFalse: [ self currentLine ]
  69. ifTrue: [ self selection ]
  70. !
  71. editorOptions
  72. ^ #{
  73. 'theme' -> ('helios.editorTheme' settingValueIfAbsent: 'default').
  74. 'mode' -> 'text/x-stsrc'.
  75. 'lineNumbers' -> true.
  76. 'enterMode' -> 'flat'.
  77. 'indentWithTabs' -> true.
  78. 'indentUnit' -> 4.
  79. 'matchBrackets' -> true.
  80. 'electricChars' -> false.
  81. 'keyMap' -> 'Amber'.
  82. 'extraKeys' -> (HashedCollection with: ('helios.completionKey' settingValueIfAbsent: 'Shift-Space') -> 'autocomplete')
  83. }
  84. !
  85. model
  86. ^ model ifNil: [ model := HLCodeModel new ]
  87. !
  88. model: aModel
  89. model := aModel
  90. !
  91. receiver
  92. ^ self model receiver
  93. !
  94. receiver: anObject
  95. self model receiver: anObject
  96. !
  97. selection
  98. ^editor getSelection
  99. !
  100. selectionEnd
  101. ^code element selectionEnd
  102. !
  103. selectionEnd: anInteger
  104. code element selectionEnd: anInteger
  105. !
  106. selectionStart
  107. ^code element selectionStart
  108. !
  109. selectionStart: anInteger
  110. code element selectionStart: anInteger
  111. ! !
  112. !HLCodeWidget methodsFor: 'actions'!
  113. browseIt
  114. | result |
  115. result := [ self doIt ] on: Error do: [ :exception |
  116. ^ ErrorHandler handleError: exception ].
  117. self model browse: result
  118. !
  119. clear
  120. self contents: ''
  121. !
  122. configureEditor
  123. self editor at: 'amberCodeWidget' put: self.
  124. self editor on: 'change' do: [ self onChange ].
  125. self wrapper asJQuery on: 'mousedown' in: '.CodeMirror pre' do: [ :event | | position node |
  126. (event at: 'ctrlKey') ifTrue: [
  127. position := self editor coordsChar: #{
  128. 'left' -> event clientX.
  129. 'top' -> event clientY
  130. }.
  131. self onCtrlClickAt: (position line @ position ch) + 1.
  132. event preventDefault ] ]
  133. !
  134. doIt
  135. | result |
  136. result := self model doIt: self currentLineOrSelection.
  137. self model announcer announce: (HLDoItExecuted on: model).
  138. ^ result
  139. !
  140. editor
  141. ^ editor
  142. !
  143. focus
  144. editor focus
  145. !
  146. inspectIt
  147. self model inspect: self doIt
  148. !
  149. navigateTo: aString
  150. Finder findString: aString
  151. !
  152. navigateToReference: aString
  153. (HLReferences openAsTab)
  154. search: aString
  155. !
  156. print: aString
  157. | start stop currentLine |
  158. currentLine := (editor getCursor: false) line.
  159. start := HashedCollection new.
  160. start at: 'line' put: currentLine.
  161. start at: 'ch' put: (editor getCursor: false) ch.
  162. (editor getSelection) ifEmpty: [
  163. "select current line if selection is empty"
  164. start at: 'ch' put: (editor getLine: currentLine) size.
  165. editor setSelection: #{'line' -> currentLine. 'ch' -> 0} end: start.
  166. ].
  167. stop := HashedCollection new.
  168. stop at: 'line' put: currentLine.
  169. stop at: 'ch' put: ((start at: 'ch') + aString size + 2).
  170. editor replaceSelection: (editor getSelection, ' ', aString, ' ').
  171. editor setCursor: (editor getCursor: true).
  172. editor setSelection: stop end: start
  173. !
  174. printIt
  175. self print: self doIt printString
  176. !
  177. saveIt
  178. "I do not do anything"
  179. !
  180. setEditorOn: aTextarea
  181. <self['@editor'] = CodeMirror.fromTextArea(aTextarea, self._editorOptions())>
  182. ! !
  183. !HLCodeWidget methodsFor: 'hints'!
  184. messageHintFor: anEditor token: aToken
  185. ^ (Smalltalk vm allSelectors asArray
  186. select: [ :each | each includesSubString: aToken string ])
  187. reject: [ :each | each = aToken string ]
  188. !
  189. variableHintFor: anEditor token: aToken
  190. | variables classNames pseudoVariables |
  191. variables := (anEditor display wrapper asJQuery find: 'span.cm-variable') get
  192. collect: [ :each | each asJQuery html ].
  193. classNames := Smalltalk classes collect: [ :each | each name ].
  194. pseudoVariables := Smalltalk pseudoVariableNames.
  195. ^ ((variables, classNames, pseudoVariables) asSet asArray sort
  196. select: [ :each | each includesSubString: aToken string ])
  197. reject: [ :each | each = aToken string ]
  198. ! !
  199. !HLCodeWidget methodsFor: 'reactions'!
  200. onChange
  201. self updateState
  202. !
  203. onCtrlClickAt: aPoint
  204. | ast node |
  205. ast := [ Smalltalk parse: self editor getValue ]
  206. on: Error
  207. do: [ :error | ^ self ].
  208. node := ast
  209. navigationNodeAt: aPoint
  210. ifAbsent: [ ^ nil ].
  211. self navigateTo: node navigationLink
  212. !
  213. onInspectIt
  214. self inspectIt
  215. !
  216. onPrintIt
  217. self printIt
  218. !
  219. onSaveIt
  220. "I do not do anything"
  221. ! !
  222. !HLCodeWidget methodsFor: 'rendering'!
  223. renderButtonsOn: html
  224. html button
  225. class: 'button';
  226. with: 'DoIt';
  227. onClick: [ self doIt ].
  228. html button
  229. class: 'button';
  230. with: 'PrintIt';
  231. onClick: [ self printIt ].
  232. html button
  233. class: 'button';
  234. with: 'InspectIt';
  235. onClick: [ self inspectIt ].
  236. html button
  237. class: 'button';
  238. with: 'BrowseIt';
  239. onClick: [ self browseIt ]
  240. !
  241. renderContentOn: html
  242. html div class: 'editor'; with: [
  243. code := html textarea ].
  244. state := html div class: 'state'.
  245. html div
  246. class: 'buttons_bar';
  247. with: [ self renderButtonsOn: html ].
  248. self
  249. setEditorOn: code element;
  250. configureEditor;
  251. updateState
  252. ! !
  253. !HLCodeWidget methodsFor: 'testing'!
  254. canHaveFocus
  255. ^ true
  256. !
  257. hasFocus
  258. ^ code asJQuery is: ':active'
  259. !
  260. hasModification
  261. ^ false
  262. ! !
  263. !HLCodeWidget methodsFor: 'updating'!
  264. updateState
  265. self hasModification
  266. ifTrue: [ state asJQuery addClass: 'modified' ]
  267. ifFalse: [ state asJQuery removeClass: 'modified' ]
  268. ! !
  269. !HLCodeWidget class methodsFor: 'accessing'!
  270. keyMap
  271. ^ HLManager current keyBinder systemIsMac
  272. ifTrue: [ self macKeyMap ]
  273. ifFalse: [ self pcKeyMap ]
  274. !
  275. macKeyMap
  276. ^ #{
  277. 'Alt-Backspace' -> 'delWordBefore'.
  278. 'Alt-Delete' -> 'delWordAfter'.
  279. 'Alt-Left' -> 'goWordLeft'.
  280. 'Alt-Right' -> 'goWordRight'.
  281. 'Cmd-A' -> 'selectAll'.
  282. 'Cmd-Alt-F' -> 'replace'.
  283. 'Cmd-D' -> 'doIt'.
  284. 'Cmd-B' -> 'browseIt'.
  285. 'Cmd-Down' -> 'goDocEnd'.
  286. 'Cmd-End' -> 'goDocEnd'.
  287. 'Cmd-F' -> 'find'.
  288. 'Cmd-G' -> 'findNext'.
  289. 'Cmd-I' -> 'inspectIt'.
  290. 'Cmd-Left' -> 'goLineStart'.
  291. 'Cmd-P' -> 'printIt'.
  292. 'Cmd-Right' -> 'goLineEnd'.
  293. 'Cmd-S' -> 'saveIt'.
  294. 'Cmd-Up' -> 'goDocStart'.
  295. 'Cmd-Y' -> 'redo'.
  296. 'Cmd-Z' -> 'undo'.
  297. 'Cmd-[' -> 'indentLess'.
  298. 'Cmd-]' -> 'indentMore'.
  299. 'Ctrl-Alt-Backspace' -> 'delWordAfter'.
  300. 'Shift-Cmd-Alt-F' -> 'replaceAll'.
  301. 'Shift-Cmd-G' -> 'findPrev'.
  302. 'Shift-Cmd-Z' -> 'redo'.
  303. 'fallthrough' -> { 'basic'. 'emacsy' }
  304. }
  305. !
  306. pcKeyMap
  307. ^ #{
  308. 'Alt-Left' -> 'goLineStart'.
  309. 'Alt-Right' -> 'goLineEnd'.
  310. 'Alt-Up' -> 'goDocStart'.
  311. 'Ctrl-A' -> 'selectAll'.
  312. 'Ctrl-Backspace' -> 'delWordBefore'.
  313. 'Ctrl-D' -> 'doIt'.
  314. 'Ctrl-B' -> 'browseIt'.
  315. 'Ctrl-Delete' -> 'delWordAfter'.
  316. 'Ctrl-Down' -> 'goDocEnd'.
  317. 'Ctrl-End' -> 'goDocEnd'.
  318. 'Ctrl-F' -> 'find'.
  319. 'Ctrl-G' -> 'findNext'.
  320. 'Ctrl-I' -> 'inspectIt'.
  321. 'Ctrl-Home' -> 'goDocStart'.
  322. 'Ctrl-Left' -> 'goWordLeft'.
  323. 'Ctrl-P' -> 'printIt'.
  324. 'Ctrl-Right' -> 'goWordRight'.
  325. 'Ctrl-S' -> 'saveIt'.
  326. 'Ctrl-Y' -> 'redo'.
  327. 'Ctrl-Z' -> 'undo'.
  328. 'Ctrl-[' -> 'indentLess'.
  329. 'Ctrl-]' -> 'indentMore'.
  330. 'Shift-Ctrl-F' -> 'replace'.
  331. 'Shift-Ctrl-G' -> 'findPrev'.
  332. 'Shift-Ctrl-R' -> 'replaceAll'.
  333. 'Shift-Ctrl-Z' -> 'redo'.
  334. 'fallthrough' -> #('basic')
  335. }
  336. ! !
  337. !HLCodeWidget class methodsFor: 'hints'!
  338. hintFor: anEditor options: options
  339. | cursor token completions |
  340. cursor := anEditor getCursor.
  341. token := anEditor getTokenAt: cursor.
  342. token at: 'state' put: ((CodeMirror basicAt: 'innerMode')
  343. value: anEditor getMode value: (token at: 'state')) state.
  344. completions := token type = 'variable'
  345. ifTrue: [ HLCodeWidget variableHintFor: anEditor token: token ]
  346. ifFalse: [ HLCodeWidget messageHintFor: anEditor token: token ].
  347. ^ #{
  348. 'list' -> completions.
  349. 'from' -> ((CodeMirror basicAt: 'Pos') value: cursor line value: token end).
  350. 'to' -> ((CodeMirror basicAt: 'Pos') value: cursor line value: token start)
  351. }
  352. !
  353. messageHintFor: anEditor token: aToken
  354. ^ (anEditor at: 'amberCodeWidget')
  355. messageHintFor: anEditor token: aToken
  356. !
  357. variableHintFor: anEditor token: aToken
  358. ^ (anEditor at: 'amberCodeWidget')
  359. variableHintFor: anEditor token: aToken
  360. ! !
  361. !HLCodeWidget class methodsFor: 'initialization'!
  362. initialize
  363. super initialize.
  364. self
  365. setupCodeMirror;
  366. setupCommands;
  367. setupKeyMaps.
  368. !
  369. setupCodeMirror
  370. <
  371. CodeMirror.keyMap.default.fallthrough = ["basic"];
  372. CodeMirror.commands.autocomplete = function(cm) {
  373. CodeMirror.showHint(cm, self._hintFor_options_);
  374. }
  375. >
  376. !
  377. setupCommands
  378. (CodeMirror basicAt: 'commands')
  379. at: 'doIt' put: [ :cm | cm amberCodeWidget doIt ];
  380. at: 'inspectIt' put: [ :cm | cm amberCodeWidget inspectIt ];
  381. at: 'printIt' put: [ :cm | cm amberCodeWidget printIt ];
  382. at: 'saveIt' put: [ :cm | cm amberCodeWidget saveIt ];
  383. at: 'browseIt' put: [ :cm | cm amberCodeWidget browseIt ]
  384. !
  385. setupKeyMaps
  386. <CodeMirror.keyMap['Amber'] = self._keyMap()>
  387. ! !
  388. HLCodeWidget subclass: #HLNavigationCodeWidget
  389. instanceVariableNames: 'methodContents'
  390. package: 'Helios-Workspace'!
  391. !HLNavigationCodeWidget methodsFor: 'accessing'!
  392. configureEditor
  393. super configureEditor.
  394. self contents: self methodContents
  395. !
  396. contents: aString
  397. self methodContents: aString.
  398. super contents: aString
  399. !
  400. methodContents
  401. ^ methodContents ifNil: [ '' ]
  402. !
  403. methodContents: aString
  404. ^ methodContents := aString
  405. !
  406. previous
  407. "for browser lists widget"
  408. !
  409. previous: aWidget
  410. "for browser lists widget"
  411. ! !
  412. !HLNavigationCodeWidget methodsFor: 'testing'!
  413. hasModification
  414. ^ (self methodContents = self contents) not
  415. ! !
  416. !HLNavigationCodeWidget class methodsFor: 'instance creation'!
  417. on: aBrowserModel
  418. ^ self new
  419. browserModel: aBrowserModel;
  420. yourself
  421. ! !
  422. !HLNavigationCodeWidget class methodsFor: 'testing'!
  423. canBeOpenAsTab
  424. ^ false
  425. ! !
  426. HLNavigationCodeWidget subclass: #HLBrowserCodeWidget
  427. instanceVariableNames: 'browserModel'
  428. package: 'Helios-Workspace'!
  429. !HLBrowserCodeWidget methodsFor: 'accessing'!
  430. browserModel
  431. ^ browserModel
  432. !
  433. browserModel: aBrowserModel
  434. browserModel := aBrowserModel.
  435. self
  436. observeSystem;
  437. observeBrowserModel
  438. ! !
  439. !HLBrowserCodeWidget methodsFor: 'actions'!
  440. observeBrowserModel
  441. self browserModel announcer
  442. on: HLSaveSourceCode
  443. send: #onSaveIt
  444. to: self;
  445. on: HLShowInstanceToggled
  446. send: #onShowInstanceToggled
  447. to: self;
  448. on: HLSourceCodeSaved
  449. send: #onSourceCodeSaved
  450. to: self;
  451. on: HLAboutToChange
  452. send: #onBrowserAboutToChange:
  453. to: self;
  454. on: HLParseErrorRaised
  455. send: #onParseError:
  456. to: self;
  457. on: HLCompileErrorRaised
  458. send: #onCompileError:
  459. to: self;
  460. on: HLUnknownVariableErrorRaised
  461. send: #onUnknownVariableError:
  462. to: self;
  463. on: HLInstVarAdded
  464. send: #onInstVarAdded
  465. to: self;
  466. on: HLMethodSelected
  467. send: #onMethodSelected:
  468. to: self;
  469. on: HLClassSelected
  470. send: #onClassSelected:
  471. to: self;
  472. on: HLPackageSelected
  473. send: #onPackageSelected:
  474. to: self;
  475. on: HLProtocolSelected
  476. send: #onProtocolSelected:
  477. to: self;
  478. on: HLSourceCodeFocusRequested
  479. send: #onSourceCodeFocusRequested
  480. to: self;
  481. on: HLShowTemplate
  482. send: #onShowTemplate:
  483. to: self
  484. !
  485. observeSystem
  486. self browserModel systemAnnouncer
  487. on: MethodModified
  488. send: #onMethodModified:
  489. to: self
  490. !
  491. refresh
  492. self hasModification ifTrue: [ ^ self ].
  493. self hasFocus ifTrue: [ ^ self ].
  494. self contents: self browserModel selectedMethod source
  495. !
  496. renderButtonsOn: html
  497. html button
  498. class: 'button';
  499. with: 'SaveIt';
  500. onClick: [ self saveIt ].
  501. super renderButtonsOn: html
  502. !
  503. saveIt
  504. self browserModel saveSourceCode
  505. !
  506. unregister
  507. super unregsiter.
  508. self browserModel announcer unsubscribe: self.
  509. self browserModel systemAnnouncer unsubscribe: self
  510. ! !
  511. !HLBrowserCodeWidget methodsFor: 'reactions'!
  512. onBrowserAboutToChange: anAnnouncement
  513. | block |
  514. block := anAnnouncement actionBlock.
  515. self hasModification
  516. ifTrue: [
  517. self
  518. confirm: 'Changes have not been saved. Do you want to discard these changes?'
  519. ifTrue: [
  520. "Don't ask twice"
  521. self methodContents: self contents.
  522. block value ].
  523. HLChangeForbidden signal ]
  524. !
  525. onClassSelected: anAnnouncement
  526. | class |
  527. class:= anAnnouncement item.
  528. class ifNil: [ ^ self contents: '' ].
  529. self contents: class definition
  530. !
  531. onCompileError: anAnnouncement
  532. self alert: anAnnouncement error messageText
  533. !
  534. onInstVarAdded
  535. self browserModel save: self contents
  536. !
  537. onMethodModified: anAnnouncement
  538. | method |
  539. method := anAnnouncement method.
  540. self browserModel selectedClass = method methodClass ifFalse: [ ^ self ].
  541. self browserModel selectedMethod ifNil: [ ^ self ].
  542. self browserModel selectedMethod selector = method selector ifFalse: [ ^ self ].
  543. self refresh
  544. !
  545. onMethodSelected: anAnnouncement
  546. | method |
  547. method := anAnnouncement item.
  548. method ifNil: [ ^ self contents: '' ].
  549. self contents: method source
  550. !
  551. onPackageSelected: anAnnouncement
  552. | package |
  553. package := anAnnouncement item.
  554. package ifNil: [ ^ self contents: '' ].
  555. self contents: package definition
  556. !
  557. onParseError: anAnnouncement
  558. | lineIndex newContents |
  559. lineIndex := 1.
  560. self contents: (String streamContents: [ :stream |
  561. self contents linesDo: [ :each |
  562. lineIndex = anAnnouncement line
  563. ifTrue: [
  564. stream
  565. nextPutAll: (each copyFrom: 1 to: anAnnouncement column);
  566. nextPutAll: '<- ';
  567. nextPutAll: anAnnouncement message;
  568. nextPutAll: ' ';
  569. nextPutAll: (each copyFrom: anAnnouncement column + 1 to: each size) ]
  570. ifFalse: [ stream nextPutAll: each ].
  571. stream nextPutAll: String cr.
  572. lineIndex := lineIndex + 1 ] ])
  573. !
  574. onProtocolSelected: anAnnouncement
  575. self browserModel selectedClass ifNil: [ ^ self contents: '' ].
  576. self contents: self browserModel selectedClass definition
  577. !
  578. onSaveIt
  579. self browserModel save: self contents
  580. !
  581. onShowInstanceToggled
  582. self browserModel selectedClass ifNil: [ ^ self contents: '' ].
  583. self contents: self browserModel selectedClass definition
  584. !
  585. onShowTemplate: anAnnouncement
  586. self contents: anAnnouncement template
  587. !
  588. onSourceCodeFocusRequested
  589. self focus
  590. !
  591. onSourceCodeSaved
  592. self methodContents: self contents.
  593. self updateState
  594. !
  595. onUnknownVariableError: anAnnouncement
  596. | error |
  597. error := anAnnouncement error.
  598. self
  599. confirm: (String streamContents: [ :stream |
  600. stream
  601. nextPutAll: error messageText;
  602. nextPutAll: String cr;
  603. nextPutAll: 'Would you like to define an instance variable?' ])
  604. ifTrue: [
  605. self browserModel addInstVarNamed: error variableName ]
  606. ! !
  607. !HLBrowserCodeWidget class methodsFor: 'instance creation'!
  608. on: aBrowserModel
  609. ^ self new
  610. browserModel: aBrowserModel;
  611. yourself
  612. ! !
  613. !HLBrowserCodeWidget class methodsFor: 'testing'!
  614. canBeOpenAsTab
  615. ^ false
  616. ! !
  617. HLWidget subclass: #HLWorkspace
  618. instanceVariableNames: 'codeWidget transcript'
  619. package: 'Helios-Workspace'!
  620. !HLWorkspace methodsFor: 'accessing'!
  621. codeWidget
  622. ^ codeWidget ifNil: [ codeWidget := HLCodeWidget new ]
  623. !
  624. transcript
  625. ^ transcript ifNil: [ transcript := HLTranscript new ]
  626. ! !
  627. !HLWorkspace methodsFor: 'actions'!
  628. focus
  629. ^ self codeWidget focus
  630. !
  631. unregister
  632. super unregister.
  633. self transcript unregister
  634. ! !
  635. !HLWorkspace methodsFor: 'rendering'!
  636. renderContentOn: html
  637. html with: (HLContainer with: (HLHorizontalSplitter
  638. with: self codeWidget
  639. with: [ :canvas | self renderTranscriptOn: canvas ]))
  640. !
  641. renderTranscriptOn: html
  642. html div
  643. class: 'transcript-container';
  644. with: [
  645. html div
  646. class: 'list-label';
  647. with: 'Transcript'.
  648. self transcript renderOn: html ]
  649. ! !
  650. !HLWorkspace methodsFor: 'testing'!
  651. canHaveFocus
  652. ^ true
  653. ! !
  654. !HLWorkspace class methodsFor: 'accessing'!
  655. tabClass
  656. ^ 'workspace'
  657. !
  658. tabLabel
  659. ^ 'Workspace'
  660. !
  661. tabPriority
  662. ^ 10
  663. ! !
  664. !HLWorkspace class methodsFor: 'testing'!
  665. canBeOpenAsTab
  666. ^ true
  667. ! !