-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (60 loc) · 1.5 KB
/
Copy pathmain.cpp
File metadata and controls
74 lines (60 loc) · 1.5 KB
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
#pragma comment(lib, "libuv.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "psapi.lib")
#pragma comment(lib, "Iphlpapi.lib")
#pragma comment(lib, "Userenv.lib") //see https://github.com/saghul/pyuv/issues/201
#include <iostream>
#include <stdio.h>
#include <string.h>
//#include <unistd.h>
#include <io.h>
#include <uv.h>
static uv_thread_t thread;
static void thread_cb(void* arg)
{
printf("hello threads!\n");
}
int main()
{
int r = uv_thread_create(&thread, thread_cb, NULL);
//assert(r == 0);
/* pause execution of this thread until the spawned thread has had
* time to finish execution. */
uv_thread_join(&thread);
return 0;
}
#if 0
uv_loop_t *loop;
uv_tty_t tty;
int main() {
loop = uv_default_loop();
uv_tty_init(loop, &tty, 1, 0);
uv_tty_set_mode(&tty, UV_TTY_MODE_NORMAL);
// Set as cyan text on blue background
if (uv_guess_handle(1) == UV_TTY) {
uv_write_t req;
uv_buf_t buf;
//buf.base = "\033[41;37m";
buf.base = "\033[44;36m";
buf.len = strlen(buf.base);
uv_write(&req, (uv_stream_t*)&tty, &buf, 1, NULL);
}
// Spit out the text
uv_write_t req;
uv_buf_t buf;
buf.base = "Hello TTY\n";
buf.len = strlen(buf.base);
uv_write(&req, (uv_stream_t*)&tty, &buf, 1, NULL);
// Reset any ANSI styles from above
if (uv_guess_handle(1) == UV_TTY) {
uv_write_t req;
uv_buf_t buf;
buf.base = "\033[0m";
buf.len = strlen(buf.base);
uv_write(&req, (uv_stream_t*)&tty, &buf, 1, NULL);
}
uv_tty_reset_mode();
return uv_run(loop, UV_RUN_DEFAULT);
return 0;
}
#endif