Helios-Workspace.st 17 KB

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