diff options
author | Nivesh Rajbhandari | 2012-02-20 11:14:44 -0800 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-02-20 11:14:44 -0800 |
commit | abf78e2d7a97d295ce5a1c425fd359d47379137e (patch) | |
tree | d08c91bd2aef31e6325e0b499b2ffc390018bec6 /imports/codemirror/mode/clike/index.html | |
parent | e80a79bff57fecf3aa9b869d8ed2de5fd815287c (diff) | |
parent | e23708721a71ca4c71365f5f8e8ac7d6113926db (diff) | |
download | ninja-abf78e2d7a97d295ce5a1c425fd359d47379137e.tar.gz |
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'imports/codemirror/mode/clike/index.html')
-rwxr-xr-x | imports/codemirror/mode/clike/index.html | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/imports/codemirror/mode/clike/index.html b/imports/codemirror/mode/clike/index.html new file mode 100755 index 00000000..5e375ef4 --- /dev/null +++ b/imports/codemirror/mode/clike/index.html | |||
@@ -0,0 +1,101 @@ | |||
1 | <!doctype html> | ||
2 | <html> | ||
3 | <head> | ||
4 | <title>CodeMirror: C-like mode</title> | ||
5 | <link rel="stylesheet" href="../../lib/codemirror.css"> | ||
6 | <script src="../../lib/codemirror.js"></script> | ||
7 | <script src="clike.js"></script> | ||
8 | <link rel="stylesheet" href="../../doc/docs.css"> | ||
9 | <style>.CodeMirror {border: 2px inset #dee;}</style> | ||
10 | </head> | ||
11 | <body> | ||
12 | <h1>CodeMirror: C-like mode</h1> | ||
13 | |||
14 | <form><textarea id="code" name="code"> | ||
15 | /* C demo code */ | ||
16 | |||
17 | #include <zmq.h> | ||
18 | #include <pthread.h> | ||
19 | #include <semaphore.h> | ||
20 | #include <time.h> | ||
21 | #include <stdio.h> | ||
22 | #include <fcntl.h> | ||
23 | #include <malloc.h> | ||
24 | |||
25 | typedef struct { | ||
26 | void* arg_socket; | ||
27 | zmq_msg_t* arg_msg; | ||
28 | char* arg_string; | ||
29 | unsigned long arg_len; | ||
30 | int arg_int, arg_command; | ||
31 | |||
32 | int signal_fd; | ||
33 | int pad; | ||
34 | void* context; | ||
35 | sem_t sem; | ||
36 | } acl_zmq_context; | ||
37 | |||
38 | #define p(X) (context->arg_##X) | ||
39 | |||
40 | void* zmq_thread(void* context_pointer) { | ||
41 | acl_zmq_context* context = (acl_zmq_context*)context_pointer; | ||
42 | char ok = 'K', err = 'X'; | ||
43 | int res; | ||
44 | |||
45 | while (1) { | ||
46 | while ((res = sem_wait(&context->sem)) == EINTR); | ||
47 | if (res) {write(context->signal_fd, &err, 1); goto cleanup;} | ||
48 | switch(p(command)) { | ||
49 | case 0: goto cleanup; | ||
50 | case 1: p(socket) = zmq_socket(context->context, p(int)); break; | ||
51 | case 2: p(int) = zmq_close(p(socket)); break; | ||
52 | case 3: p(int) = zmq_bind(p(socket), p(string)); break; | ||
53 | case 4: p(int) = zmq_connect(p(socket), p(string)); break; | ||
54 | case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break; | ||
55 | case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break; | ||
56 | case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break; | ||
57 | case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break; | ||
58 | case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break; | ||
59 | } | ||
60 | p(command) = errno; | ||
61 | write(context->signal_fd, &ok, 1); | ||
62 | } | ||
63 | cleanup: | ||
64 | close(context->signal_fd); | ||
65 | free(context_pointer); | ||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | void* zmq_thread_init(void* zmq_context, int signal_fd) { | ||
70 | acl_zmq_context* context = malloc(sizeof(acl_zmq_context)); | ||
71 | pthread_t thread; | ||
72 | |||
73 | context->context = zmq_context; | ||
74 | context->signal_fd = signal_fd; | ||
75 | sem_init(&context->sem, 1, 0); | ||
76 | pthread_create(&thread, 0, &zmq_thread, context); | ||
77 | pthread_detach(thread); | ||
78 | return context; | ||
79 | } | ||
80 | </textarea></form> | ||
81 | |||
82 | <script> | ||
83 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
84 | lineNumbers: true, | ||
85 | matchBrackets: true, | ||
86 | mode: "text/x-csrc" | ||
87 | }); | ||
88 | </script> | ||
89 | |||
90 | <p>Simple mode that tries to handle C-like languages as well as it | ||
91 | can. Takes two configuration parameters: <code>keywords</code>, an | ||
92 | object whose property names are the keywords in the language, | ||
93 | and <code>useCPP</code>, which determines whether C preprocessor | ||
94 | directives are recognized.</p> | ||
95 | |||
96 | <p><strong>MIME types defined:</strong> <code>text/x-csrc</code> | ||
97 | (C code), <code>text/x-c++src</code> (C++ | ||
98 | code), <code>text/x-java</code> (Java | ||
99 | code), <code>text/x-groovy</code> (Groovy code).</p> | ||
100 | </body> | ||
101 | </html> | ||