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