This repository has been archived by the owner on Jan 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.vala
64 lines (49 loc) · 2.04 KB
/
main.vala
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
class NeovimVala : GLib.Object {
public static int main(string[] args) {
// Handle Unicode properly
Intl.setlocale(LocaleCategory.CTYPE, "");
Gtk.init ();
MainLoop loop = new MainLoop ();
try {
string[] spawn_args = {"nvim", "--embed"};
for (int i = 1; i < args.length; ++i) {
spawn_args += args[i];
}
Pid child_pid;
int standard_input;
int standard_output;
Process.spawn_async_with_pipes (null /*cwd*/,
spawn_args,
null /*spawn_env*/,
SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD,
null,
out child_pid,
out standard_input,
out standard_output,
null);
// stdout:
IOChannel output = new IOChannel.unix_new (standard_output);
output.set_encoding (null); // handle as binary
output.set_buffered (false);
IOChannel input = new IOChannel.unix_new (standard_input);
input.set_encoding (null);
input.set_buffered (false);
ChildWatch.add (child_pid, (pid, status) => {
// Triggered when the child indicated by child_pid exits
Process.close_pid (pid);
loop.quit ();
});
MsgpackRpc rpc = new MsgpackRpc (input, output);
Renderer renderer = new Renderer (rpc);
renderer.attach_ui ();
var window = new Window (rpc, renderer);
window.present ();
loop.run ();
} catch (SpawnError e) {
print ("Error: %s\n", e.message);
} catch (IOChannelError e) {
print ("Error: %s\n", e.message);
}
return 0;
}
}