diff options
author | patdenice <patdenice@piwigo.org> | 2011-04-12 11:40:06 +0000 |
---|---|---|
committer | patdenice <patdenice@piwigo.org> | 2011-04-12 11:40:06 +0000 |
commit | cf4e2c81f948a1a9e54258d3ced978d1ad2ef234 (patch) | |
tree | f3fbaa43b7207e1f153a079ffb9c84dcf85c6c00 /plugins/LocalFilesEditor/codemirror/mode/clike/index.html | |
parent | 28b9e115ee113b9510db949093c39a7743d8906f (diff) |
merge r10307 from trunk to branch 2.2
feature:2262
Replace editarea by Codemirror:
http://codemirror.net
git-svn-id: http://piwigo.org/svn/branches/2.2@10310 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'plugins/LocalFilesEditor/codemirror/mode/clike/index.html')
-rw-r--r-- | plugins/LocalFilesEditor/codemirror/mode/clike/index.html | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/plugins/LocalFilesEditor/codemirror/mode/clike/index.html b/plugins/LocalFilesEditor/codemirror/mode/clike/index.html new file mode 100644 index 000000000..0836535d2 --- /dev/null +++ b/plugins/LocalFilesEditor/codemirror/mode/clike/index.html @@ -0,0 +1,101 @@ +<!doctype html> +<html> + <head> + <title>CodeMirror 2: C-like mode</title> + <link rel="stylesheet" href="../../lib/codemirror.css"> + <script src="../../lib/codemirror.js"></script> + <script src="clike.js"></script> + <link rel="stylesheet" href="clike.css"> + <link rel="stylesheet" href="../../css/docs.css"> + <style>.CodeMirror {border: 2px inset #dee;}</style> + </head> + <body> + <h1>CodeMirror 2: C-like mode</h1> + +<form><textarea id="code" name="code"> +/* C demo code */ + +#include <zmq.h> +#include <pthread.h> +#include <semaphore.h> +#include <time.h> +#include <stdio.h> +#include <fcntl.h> +#include <malloc.h> + +typedef struct { + void* arg_socket; + zmq_msg_t* arg_msg; + char* arg_string; + unsigned long arg_len; + int arg_int, arg_command; + + int signal_fd; + int pad; + void* context; + sem_t sem; +} acl_zmq_context; + +#define p(X) (context->arg_##X) + +void* zmq_thread(void* context_pointer) { + acl_zmq_context* context = (acl_zmq_context*)context_pointer; + char ok = 'K', err = 'X'; + int res; + + while (1) { + while ((res = sem_wait(&context->sem)) == EINTR); + if (res) {write(context->signal_fd, &err, 1); goto cleanup;} + switch(p(command)) { + case 0: goto cleanup; + case 1: p(socket) = zmq_socket(context->context, p(int)); break; + case 2: p(int) = zmq_close(p(socket)); break; + case 3: p(int) = zmq_bind(p(socket), p(string)); break; + case 4: p(int) = zmq_connect(p(socket), p(string)); break; + case 5: p(int) = zmq_getsockopt(p(socket), p(int), (void*)p(string), &p(len)); break; + case 6: p(int) = zmq_setsockopt(p(socket), p(int), (void*)p(string), p(len)); break; + case 7: p(int) = zmq_send(p(socket), p(msg), p(int)); break; + case 8: p(int) = zmq_recv(p(socket), p(msg), p(int)); break; + case 9: p(int) = zmq_poll(p(socket), p(int), p(len)); break; + } + p(command) = errno; + write(context->signal_fd, &ok, 1); + } + cleanup: + close(context->signal_fd); + free(context_pointer); + return 0; +} + +void* zmq_thread_init(void* zmq_context, int signal_fd) { + acl_zmq_context* context = malloc(sizeof(acl_zmq_context)); + pthread_t thread; + + context->context = zmq_context; + context->signal_fd = signal_fd; + sem_init(&context->sem, 1, 0); + pthread_create(&thread, 0, &zmq_thread, context); + pthread_detach(thread); + return context; +} +</textarea></form> + + <script> + var editor = CodeMirror.fromTextArea(document.getElementById("code"), { + lineNumbers: true, + matchBrackets: true, + mode: "text/x-csrc" + }); + </script> + + <p>Simple mode that tries to handle C-like languages as well as it + can. Takes two configuration parameters: <code>keywords</code>, an + object whose property names are the keywords in the language, + and <code>useCPP</code>, which determines whether C preprocessor + directives are recognized.</p> + + <p><strong>MIME types defined:</strong> <code>text/x-csrc</code> + (C code), <code>text/x-c++src</code> (C++ + code), <code>text/x-java</code> (Java code).</p> + </body> +</html> |