-
Notifications
You must be signed in to change notification settings - Fork 11
/
CodeMirrorDemo.ns
80 lines (79 loc) · 1.88 KB
/
CodeMirrorDemo.ns
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Newspeak3
'Samples'
class CodeMirrorDemo packageUsing: manifest = (
(*An experiment integrating CodeMirror into the Newspeak UI.*)
|
JSObject <Alien>
private hopscotchRuntime = manifest HopscotchForHTML5Runtime packageUsing: manifest.
|
) (
class Demo usingPlatform: p = (
(* Describe the class in this comment. *)
|
Subject = p hopscotch core Subject.
Presenter = p hopscotch core Presenter.
TextEditorFragment = p hopscotch fragments TextEditorFragment.
CodeMirror = p js global at: 'CodeMirror'.
|
) (
class DemoPresenter onSubject: s = Presenter onSubject: s (
(* A test class for using CodeMirror in HopscotchForHTML. *)
|
editor <CodeMirrorFragment>
|
) (
public definition ^ <Fragment> = (
editor:: codeMirror:
'forEach: i <Integer> do: b <[String]> = (
1 to: i do: [:j | b value].
)'.
^column: {
textString: 'Below is a CodeMirror text editor:'.
editor.
}
)
public setupEditor = (
editor refresh
)
public style = (
| bloo = JSObject new. bold = JSObject new. |
bold at: 'css' put: 'font-weight:bold'.
bloo at: 'css' put: 'color:#0000FF; font-weight:bold'.
editor style: bold from: 0 to: 7.
editor style: bloo from: 11 to: 20.
editor style: bold from: 21 to: 24.
editor style: bloo from: 27 to: 38.
editor refresh.
)
) : (
)
public class DemoSubject new = Subject onModel: nil (
(* Describe the class in this comment. *)
|
|
) (
public createPresenter = (
^DemoPresenter onSubject: self
)
public setupEditor = (
presenter setupEditor
)
public style = (
presenter style
)
) : (
)
) : (
)
public main: platform args: args = (
|
hopscotchPlatform = hopscotchRuntime using: platform.
demo <Demo> = Demo usingPlatform: hopscotchPlatform.
demoSubject = demo DemoSubject new.
|
JSObject:: hopscotchPlatform js global at: 'Object'.
hopscotchPlatform hopscotch core HopscotchWindow openSubject: demoSubject.
demoSubject setupEditor; style.
)
) : (
)