Helios-Workspace.st 17 KB

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