forked from MLstate/opalang
-
Notifications
You must be signed in to change notification settings - Fork 1
/
plugin_ACE.js
64 lines (55 loc) · 1.19 KB
/
plugin_ACE.js
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
/**
* For documentation please see [ace.opa]
*/
##extern-type Ace.t
##register edit : string -> Ace.t
##args(id)
{
var r = ace.edit(id);
return r;
}
##register set_mode : Ace.t, string -> bool
##args(editor, mode)
{
var M = require("ace/mode/"+mode);
if(M == undefined) return false;
M = M.Mode;
if(M == undefined) return false;
editor.getSession().setMode(new M());
return true;
}
##register get_content : Ace.t -> string
##args(editor)
{
return editor.getSession().getValue();
}
##register set_content : Ace.t, string -> void
##args(editor, content)
{
editor.getSession().setValue(content);
}
##register add_event_listener : Ace.t, string, ( -> 'void) -> void
##args(editor, kind, handler)
{
editor.getSession().addEventListener(kind, handler);
}
##register redo : Ace.t -> void
##args(editor)
{
editor.getSession().getUndoManager().redo();
}
##register undo : Ace.t -> void
##args(editor)
{
editor.getSession().getUndoManager().undo();
}
##register read_only : Ace.t, bool -> void
##args(editor, b)
{
editor.setReadOnly(b);
}
##register move_cursor : Ace.t, int, int -> void
##args(editor, col, line)
{
editor.getSelection().moveCursorToScreen(col, line);
}