├── .editorconfig ├── .gitignore ├── AUTHORS ├── Buffer.c ├── COPYING ├── CRT.c ├── ChangeLog ├── Clipboard.c ├── DebugMemory.c ├── Display.c ├── Field.c ├── FileReader.c ├── Files.c ├── FunctionBar.c ├── Hashtable.c ├── Highlight.c ├── INSTALL ├── Line.c ├── List.c ├── Makefile.am ├── NEWS ├── Object.c ├── Panel.c ├── PatternMatcher.c ├── Pool.c ├── Prototypes.h ├── README ├── README.md ├── RichString.c ├── Script.c ├── Stack.c ├── String.c ├── StringBuffer.c ├── Structures.h ├── TODO ├── TabManager.c ├── Text.c ├── Undo.c ├── Vector.c ├── aclocal └── ax_lua.m4 ├── autogen.sh ├── bindings └── default ├── config.h.in ├── configure.ac ├── debug.h ├── dit.c ├── doc └── highlighting.md ├── docs ├── author.html ├── dit-white.jpg ├── dit.css ├── dit.jpg ├── downloads.html ├── faq.html ├── home.html ├── mailinglist.html ├── screenshot.png └── screenshots.html ├── editorconfig ├── LICENSE ├── include │ └── editorconfig │ │ ├── editorconfig.h │ │ └── editorconfig_handle.h └── src │ ├── config.h │ ├── ec_fnmatch.c │ ├── ec_fnmatch.h │ ├── editorconfig.c │ ├── editorconfig.h │ ├── editorconfig_handle.c │ ├── editorconfig_handle.h │ ├── global.h │ ├── ini.c │ ├── ini.h │ ├── misc.c │ └── misc.h ├── extras └── dit.keytab ├── highlight ├── autoconf.dithl ├── c.dithl ├── c.dithlinc ├── conf.dithl ├── css.dithl ├── css.dithlinc ├── diff.dithl ├── diff.dithlinc ├── dithl.dithl ├── etlua.dithl ├── gitcommit.dithl ├── gitconflict.dithlinc ├── go.dithl ├── haskell.dithl ├── haskell.dithlinc ├── html.dithl ├── html.dithlinc ├── java.dithl ├── javascript.dithl ├── javascript.dithlinc ├── json.dithl ├── latex.dithl ├── latex.dithlinc ├── ldoc.dithlinc ├── lex.dithl ├── lhs.dithl ├── lp.dithl ├── lpeg_re.dithlinc ├── ltp.dithl ├── lua.dithl ├── lua.dithlinc ├── make.dithl ├── markdown.dithl ├── markdown.dithlinc ├── moonscript.dithl ├── nestedm4.dithlinc ├── perl.dithl ├── php.dithl ├── python.dithl ├── ruby.dithl ├── rust.dithl ├── shell.dithl ├── shell.dithlinc ├── shellbacktick.dithlinc ├── t.dithl ├── teal.dithl ├── xml.dithl ├── yacc.dithl ├── yaml.dithl └── yats.dithl ├── lua-5.3.0 ├── Makefile ├── README └── src │ ├── Makefile │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lbitlib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lprefix.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── lua.hpp │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lutf8lib.c │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h ├── lua-compat-5.3 ├── compat-5.3.c └── compat-5.3.h ├── md5.c ├── md5.h ├── scripts ├── c.lua ├── cmd.lua ├── compat53.lua ├── compat53 │ ├── init.lua │ └── module.lua ├── cscope.lua ├── dit │ ├── code.lua │ ├── global.lua │ ├── line_commit.lua │ ├── lua │ │ └── mobdebug.lua │ └── tab_complete.lua ├── go.lua ├── haskell.lua ├── java.lua ├── json.lua ├── latex.lua ├── lua.lua ├── luacheck │ ├── analyze.lua │ ├── argparse.lua │ ├── builtin_standards.lua │ ├── cache.lua │ ├── check.lua │ ├── config.lua │ ├── core_utils.lua │ ├── detect_globals.lua │ ├── expand_rockspec.lua │ ├── filter.lua │ ├── format.lua │ ├── fs.lua │ ├── globbing.lua │ ├── init.lua │ ├── inline_options.lua │ ├── lexer.lua │ ├── linearize.lua │ ├── main.lua │ ├── multithreading.lua │ ├── options.lua │ ├── parser.lua │ ├── reachability.lua │ ├── standards.lua │ ├── stds.lua │ ├── utils.lua │ ├── version.lua │ └── whitespace.lua ├── rust.lua ├── shell.lua ├── teal.lua └── tmux.lua ├── terminals ├── konsole ├── linux ├── rxvt ├── screen ├── wsvt25 ├── xterm-1002 └── xterm-color └── tools └── GenHeaders /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | 6 | [*.c] 7 | indent_style = space 8 | indent_size = 3 9 | trim_trailing_whitespace = false 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | .dirstamp 3 | autom4te.cache 4 | aclocal.m4 5 | *~ 6 | *.o 7 | *.new 8 | Makefile 9 | Makefile.in 10 | order.txt 11 | install-sh 12 | depcomp 13 | missing 14 | stamp-h1 15 | compile 16 | config.guess 17 | config.h 18 | config.log 19 | config.status 20 | config.sub 21 | configure 22 | core 23 | lua*/src/*.a 24 | config.h.in 25 | libeditorconfig.a 26 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Hisham Muhammad 2 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | What's new in version 0.1 2 | ------------------------- 3 | 4 | * Everything! 5 | 6 | -------------------------------------------------------------------------------- /Clipboard.c: -------------------------------------------------------------------------------- 1 | 2 | #include "Prototypes.h" 3 | 4 | /*{ 5 | 6 | struct Clipboard_ { 7 | char clipFileName[128]; 8 | bool disk; 9 | char* text; 10 | int len; 11 | }; 12 | 13 | }*/ 14 | 15 | Clipboard* Clipboard_new(bool disk) { 16 | Clipboard* this = (Clipboard*) malloc(sizeof(Clipboard)); 17 | sprintf(this->clipFileName, "%s/.clipboard", getenv("HOME")); 18 | this->text = NULL; 19 | this->disk = disk; 20 | return this; 21 | } 22 | 23 | void Clipboard_delete(Clipboard* this) { 24 | if (this->text) 25 | free(this->text); 26 | free(this); 27 | } 28 | 29 | Text Clipboard_get(Clipboard* this) { 30 | if (this->disk) { 31 | FILE* fd = fopen(this->clipFileName, "r"); 32 | if (fd) { 33 | int size = 100; 34 | char* out = malloc(size); 35 | int len = 0; 36 | while (!feof(fd)) { 37 | if (size - len < 100) { 38 | size = len + 100; 39 | out = realloc(out, size+1); 40 | } 41 | char* walk = out + len; 42 | int amt = fread(walk, 1, 100, fd); 43 | len += amt; 44 | } 45 | out[len] = '\0'; 46 | fclose(fd); 47 | return Text_new(out); 48 | } 49 | this->disk = false; 50 | } 51 | if (this->text) { 52 | return Text_new(strdup(this->text)); 53 | } 54 | return Text_null(); 55 | } 56 | 57 | void Clipboard_set(Clipboard* this, char* text, int len) { 58 | this->len = len; 59 | if (this->disk) { 60 | FILE* fd = fopen(this->clipFileName, "w"); 61 | if (fd) { 62 | int pend = len; 63 | while (pend > 0) { 64 | int wrote = fwrite(text + (len - pend), 1, pend, fd); 65 | pend -= wrote; 66 | } 67 | fclose(fd); 68 | free(text); 69 | return; 70 | } 71 | this->disk = false; 72 | } 73 | this->text = text; 74 | } 75 | 76 | -------------------------------------------------------------------------------- /FileReader.c: -------------------------------------------------------------------------------- 1 | 2 | #define _GNU_SOURCE 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "Prototypes.h" 10 | 11 | /*{ 12 | 13 | struct FileReader_ { 14 | FILE* fd; 15 | char* buffer; 16 | int size; 17 | int used; 18 | char* start; 19 | bool eof; 20 | bool finalEnter; 21 | bool command; 22 | }; 23 | 24 | }*/ 25 | 26 | 27 | FileReader* FileReader_new(char* filename, bool command) { 28 | FileReader* this = malloc(sizeof(FileReader)); 29 | if (command) { 30 | this->fd = popen(filename, "r"); 31 | this->command = true; 32 | } else { 33 | this->command = false; 34 | struct stat st = {0}; 35 | stat(filename, &st); 36 | if (S_ISDIR(st.st_mode)) { 37 | free(this); 38 | return NULL; 39 | } 40 | this->fd = fopen(filename, "r"); 41 | } 42 | if (this->fd == NULL) { 43 | free(this); 44 | return NULL; 45 | } 46 | this->size = 600; 47 | this->buffer = malloc(this->size); 48 | this->start = this->buffer; 49 | this->used = fread(this->buffer, 1, this->size, this->fd); 50 | this->eof = feof(this->fd); 51 | this->finalEnter = false; 52 | return this; 53 | } 54 | 55 | void FileReader_delete(FileReader* this) { 56 | if (this->command) { 57 | pclose(this->fd); 58 | } else { 59 | fclose(this->fd); 60 | } 61 | free(this->buffer); 62 | free(this); 63 | } 64 | 65 | bool FileReader_eof(FileReader* this) { 66 | return this->eof && !this->finalEnter && this->used == 0; 67 | } 68 | 69 | char* FileReader_readAllAndDelete(FileReader* this) { 70 | if (this->start > this->buffer) { 71 | memmove(this->buffer, this->start, this->used); 72 | } 73 | while (!this->eof) { 74 | int free = this->size - this->used; 75 | if (free == 0) { 76 | this->size *= 2; 77 | this->buffer = realloc(this->buffer, this->size); 78 | } 79 | this->used += fread(this->buffer + this->used, 1, this->size - this->used, this->fd); 80 | this->eof = feof(this->fd); 81 | } 82 | if (this->command) { 83 | pclose(this->fd); 84 | } else { 85 | fclose(this->fd); 86 | } 87 | char* buf = this->buffer; 88 | free(this); 89 | return buf; 90 | } 91 | 92 | char* FileReader_readLine(FileReader* this) { 93 | int chunkSize = 0; 94 | char* newline = NULL; 95 | while (true) { 96 | assert(this->start + this->used <= this->buffer + this->size); 97 | newline = memchr(this->start, '\n', this->used); 98 | if (newline) { 99 | chunkSize = newline - this->start; 100 | break; 101 | } 102 | assert(this->used <= this->size); 103 | if (!this->eof) { 104 | if (this->used) { 105 | if (this->used < this->size) { 106 | assert(this->start > this->buffer); 107 | memmove(this->buffer, this->start, this->used); 108 | } else { 109 | assert(this->start == this->buffer); 110 | this->size *= 2; 111 | this->buffer = realloc(this->buffer, this->size); 112 | } 113 | } 114 | this->start = this->buffer; 115 | this->used += fread(this->buffer + this->used, 1, this->size - this->used, this->fd); 116 | this->eof = feof(this->fd); 117 | } else { 118 | chunkSize = this->used; 119 | break; 120 | } 121 | } 122 | if (newline || chunkSize) { 123 | assert(chunkSize <= this->used); 124 | char* result = malloc(chunkSize + 1); 125 | memcpy(result, this->start, chunkSize); 126 | result[chunkSize] = '\0'; 127 | if (newline) 128 | chunkSize++; 129 | this->start += chunkSize; 130 | this->used -= chunkSize; 131 | if (newline && this->eof && this->used == 0) 132 | this->finalEnter = true; 133 | return result; 134 | } 135 | if (this->finalEnter) { 136 | this->finalEnter = false; 137 | return strdup(""); 138 | } 139 | return NULL; 140 | } 141 | -------------------------------------------------------------------------------- /Files.c: -------------------------------------------------------------------------------- 1 | 2 | #define _GNU_SOURCE 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "Prototypes.h" 11 | 12 | /*{ 13 | 14 | typedef bool(*Method_Files_fileHandler)(void*, char*); 15 | 16 | struct ForEachData_ { 17 | Method_Files_fileHandler fn; 18 | void* data; 19 | }; 20 | 21 | }*/ 22 | 23 | typedef void*(*Method_Files_tryEachHandler)(const char*, void*); 24 | 25 | static char* makeFileName(char* fileName, const char* dir, const char* subdir, const char* picture, const char* value, int* dirEndsAt) { 26 | snprintf(fileName, 4096, "%s/%s", dir, subdir); 27 | int len = strlen(fileName); 28 | if (dirEndsAt) *dirEndsAt = len; 29 | snprintf(fileName + len, 4096 - len, picture, value); 30 | return fileName; 31 | } 32 | 33 | static void* tryEach(const char* picture, const char* value, int* dirEndsAt, void* arg, Method_Files_tryEachHandler fn) { 34 | char fileName[4097]; 35 | void* ret = fn(makeFileName(fileName, getenv("HOME"), "/.dit/", picture, value, dirEndsAt), arg); 36 | if (ret) return ret; 37 | ret = fn(makeFileName(fileName, SYSCONFDIR, "/dit/", picture, value, dirEndsAt), arg); 38 | if (ret) return ret; 39 | ret = fn(makeFileName(fileName, PKGDATADIR, "/", picture, value, dirEndsAt), arg); 40 | if (ret) return ret; 41 | return fn(makeFileName(fileName, ".", "/", picture, value, dirEndsAt), arg); 42 | } 43 | 44 | static void* handleOpen(const char* name, void* mode) { 45 | return fopen(name, (const char*) mode); 46 | } 47 | 48 | FILE* Files_open(const char* mode, const char* picture, const char* value) { 49 | return (FILE*) tryEach(picture, value, NULL, (void*) mode, handleOpen); 50 | } 51 | 52 | static void* handleFindFile(const char* name, void* _) { 53 | return access(name, R_OK) == 0 ? strdup(name) : NULL; 54 | } 55 | 56 | char* Files_findFile(const char* picture, const char* value, int* dirEndsAt) { 57 | return (char*) tryEach(picture, value, dirEndsAt, NULL, handleFindFile); 58 | } 59 | 60 | static void Files_nameHome(char* fileName, const char* picture, const char* value) { 61 | int _; 62 | makeFileName(fileName, getenv("HOME"), "/.dit/", picture, value, &_); 63 | } 64 | 65 | bool Files_existsHome(const char* picture, const char* value) { 66 | char fileName[4097]; 67 | Files_nameHome(fileName, picture, value); 68 | return (access(fileName, F_OK) == 0); 69 | } 70 | 71 | FILE* Files_openHome(const char* mode, const char* picture, const char* value) { 72 | char fileName[4097]; 73 | Files_nameHome(fileName, picture, value); 74 | return fopen(fileName, mode); 75 | } 76 | 77 | int Files_deleteHome(const char* picture, const char* value) { 78 | char fileName[4097]; 79 | Files_nameHome(fileName, picture, value); 80 | return unlink(fileName); 81 | } 82 | 83 | char* Files_encodePathAsFileName(char* fileName) { 84 | char* rpath; 85 | if (fileName[0] == '/') 86 | rpath = strdup(fileName); 87 | else 88 | rpath = realpath(fileName, NULL); 89 | for(char *c = rpath; *c; c++) 90 | if (*c == '/') 91 | *c = ':'; 92 | return rpath; 93 | } 94 | 95 | void Files_makeHome() { 96 | static const char* dirs[] = { 97 | "%s/.dit", 98 | "%s/.dit/undo", 99 | "%s/.dit/lock", 100 | NULL 101 | }; 102 | char fileName[4097]; 103 | const char* home = getenv("HOME"); 104 | for (int i = 0; dirs[i]; i++) { 105 | snprintf(fileName, 4096, dirs[i], home); 106 | fileName[4095] = '\0'; 107 | mkdir(fileName, 0700); 108 | } 109 | } 110 | 111 | static void* handleForEachInDir(const char* dirName, void* arg) { 112 | const ForEachData* fed = (ForEachData*) arg; 113 | DIR* dir = opendir(dirName); 114 | while (dir) { 115 | struct dirent* entry = readdir(dir); 116 | if (!entry) break; 117 | if (entry->d_name[0] == '.') continue; 118 | char fileName[4097]; 119 | makeFileName(fileName, dirName, "/", "%s", entry->d_name, NULL); 120 | if (fed->fn(fed->data, fileName)) { 121 | if (dir) closedir(dir); 122 | return &handleForEachInDir; // a non-nil pointer to tell tryEach to stop. 123 | } 124 | } 125 | if (dir) closedir(dir); 126 | return NULL; 127 | } 128 | 129 | void Files_forEachInDir(char* dirName, Method_Files_fileHandler fn, void* data) { 130 | ForEachData fed = { .fn = fn, .data = data }; 131 | tryEach("%s", dirName, NULL, &fed, handleForEachInDir); 132 | } 133 | -------------------------------------------------------------------------------- /FunctionBar.c: -------------------------------------------------------------------------------- 1 | 2 | #define _GNU_SOURCE 3 | #include 4 | #include 5 | #include 6 | 7 | #include "Prototypes.h" 8 | 9 | /*{ 10 | 11 | struct FunctionBar_ { 12 | int size; 13 | char** functions; 14 | char** keys; 15 | int* events; 16 | }; 17 | 18 | }*/ 19 | 20 | char* FunctionBar_FKeys[10] = {" 1", " 2", " 3", " 4", " 5", " 6", " 7", " 8", " 9", "10"}; 21 | 22 | int FunctionBar_FEvents[10] = {KEY_F(1), KEY_F(2), KEY_F(3), KEY_F(4), KEY_F(5), KEY_F(6), KEY_F(7), KEY_F(8), KEY_F(9), KEY_F(10)}; 23 | 24 | FunctionBar* FunctionBar_new(int size, char** functions, char** keys, int* events) { 25 | FunctionBar* this = malloc(sizeof(FunctionBar)); 26 | this->functions = functions; 27 | this->size = size; 28 | if (keys && events) { 29 | this->keys = keys; 30 | this->events = events; 31 | } else { 32 | this->keys = FunctionBar_FKeys; 33 | this->events = FunctionBar_FEvents; 34 | assert(this->size == 10); 35 | } 36 | return this; 37 | } 38 | 39 | void FunctionBar_delete(FunctionBar* this) { 40 | // These are always static data, RIGHT? >;) 41 | // free(this->functions); 42 | // free(this->keys); 43 | free(this); 44 | } 45 | 46 | void FunctionBar_draw(FunctionBar* this, char* buffer) { 47 | FunctionBar_drawAttr(this, buffer, CRT_colors[StatusColor]); 48 | } 49 | 50 | void FunctionBar_drawAttr(FunctionBar* this, char* buffer, int attr) { 51 | int lines, cols; 52 | Display_getScreenSize(&cols, &lines); 53 | Display_attrset(CRT_colors[StatusColor]); 54 | Display_mvhline(lines-1, 0, ' ', cols); 55 | int x = 0; 56 | for (int i = 0; i < this->size; i++) { 57 | Display_attrset(CRT_colors[KeyColor]); 58 | Display_writeAt(lines-1, x, this->keys[i]); 59 | x += strlen(this->keys[i]); 60 | Display_attrset(CRT_colors[StatusColor]); 61 | Display_writeAt(lines-1, x, this->functions[i]); 62 | x += strlen(this->functions[i]); 63 | } 64 | if (buffer != NULL) { 65 | Display_attrset(attr); 66 | Display_writeAt(lines-1, x, buffer); 67 | } 68 | } 69 | 70 | int FunctionBar_synthesizeEvent(FunctionBar* this, int pos) { 71 | int x = 0; 72 | for (int i = 0; i < this->size; i++) { 73 | x += strlen(this->keys[i]); 74 | x += strlen(this->functions[i]); 75 | if (pos < x) { 76 | return this->events[i]; 77 | } 78 | } 79 | return ERR; 80 | } 81 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | See the ChangeLog for news of the past, 2 | see the README for news of the present, 3 | and the TODO for news of the future. 4 | -------------------------------------------------------------------------------- /Object.c: -------------------------------------------------------------------------------- 1 | 2 | #include "Prototypes.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /*{ 9 | 10 | #define Msg(c,m,o,...) ((c ## Class*)(((Object*)o)->class))->m((c*) o, ## __VA_ARGS__) 11 | #define Msg0(c,m,o) ((c ## Class*)(((Object*)o)->class))->m((c*) o) 12 | #define Call(c,m,o,...) c ## _ ## m((c*) o, ## __VA_ARGS__) 13 | #define Call0(c,m,o) c ## _ ## m((c*) o) 14 | #define CallAs0(c,a,m,o) c ## _ ## m((a*) o) 15 | #define Class(c) ((c ## Class*)& c ## Type) 16 | #define ClassAs(c,a) ((a ## Class*)& c ## Type) 17 | 18 | #define Alloc(c) ((c*)calloc(sizeof(c), 1)); ((Object*)this)->class = (ObjectClass*)&(c ## Type) 19 | #define Bless(c) ((Object*)this)->class = (ObjectClass*)&(c ## Type) 20 | 21 | typedef void(*Method_Object_display)(Object*, RichString*); 22 | typedef bool(*Method_Object_equals)(const Object*, const Object*); 23 | typedef void(*Method_Object_delete)(Object*); 24 | 25 | struct ObjectClass_ { 26 | int size; 27 | Method_Object_display display; 28 | Method_Object_equals equals; 29 | Method_Object_delete delete; 30 | }; 31 | 32 | struct Object_ { 33 | ObjectClass* class; 34 | }; 35 | 36 | extern ObjectClass ObjectType; 37 | 38 | }*/ 39 | 40 | ObjectClass ObjectType = { 41 | .size = sizeof(Object), 42 | .display = Object_display, 43 | .equals = Object_equals, 44 | .delete = Object_delete 45 | }; 46 | 47 | void Object_delete(Object* this) { 48 | free(this); 49 | } 50 | 51 | void Object_display(Object* this, RichString* out) { 52 | char objAddress[50]; 53 | sprintf(objAddress, "O:%p C:%p", (void*) this, (void*) this->class); 54 | RichString_write(out, 0, objAddress); 55 | } 56 | 57 | bool Object_equals(const Object* this, const Object* o) { 58 | return (this == o); 59 | } 60 | 61 | bool Object_instanceOf(Object* this, ObjectClass* class) { 62 | return this->class == class; 63 | } 64 | -------------------------------------------------------------------------------- /Pool.c: -------------------------------------------------------------------------------- 1 | 2 | #include "Prototypes.h" 3 | 4 | /*{ 5 | 6 | #define POOL_FREELIST_RATE 100 7 | #define POOL_CHUNKLIST_RATE 10 8 | #define POOL_CHUNK_SIZE 200 9 | 10 | struct Pool_ { 11 | int objectSize; 12 | char* chunk; 13 | int used; 14 | char** freeList; 15 | int freeListSize; 16 | int freeListUsed; 17 | char** chunkList; 18 | int chunkListSize; 19 | int chunkListUsed; 20 | bool destroying; 21 | }; 22 | 23 | }*/ 24 | 25 | static inline void Pool_addChunk(Pool* this) { 26 | this->chunk = malloc(POOL_CHUNK_SIZE * this->objectSize); 27 | this->chunkList[this->chunkListUsed++] = this->chunk; 28 | this->used = 0; 29 | } 30 | 31 | Pool* Pool_new(ObjectClass* type) { 32 | Pool* this = (Pool*) malloc(sizeof(Pool)); 33 | this->objectSize = type->size; 34 | this->chunkListUsed = 0; 35 | this->freeList = malloc(sizeof(void*) * POOL_FREELIST_RATE); 36 | this->freeListSize = POOL_FREELIST_RATE; 37 | this->freeListUsed = 0; 38 | this->chunkListSize = POOL_CHUNKLIST_RATE; 39 | this->chunkList = malloc(sizeof(void*) * this->chunkListSize); 40 | this->destroying = false; 41 | Pool_addChunk(this); 42 | return this; 43 | } 44 | 45 | void Pool_initiateDestruction(Pool* this) { 46 | this->destroying = true; 47 | } 48 | 49 | static inline void* Pool_allocateInChunk(Pool* this) { 50 | void* result = this->chunk + (this->objectSize * this->used); 51 | this->used++; 52 | return result; 53 | } 54 | 55 | void* Pool_allocate(Pool* this) { 56 | if (this->freeListUsed > 0) 57 | return this->freeList[--this->freeListUsed]; 58 | if (this->used < POOL_CHUNK_SIZE) 59 | return Pool_allocateInChunk(this); 60 | else if (this->chunkListUsed < this->chunkListSize) { 61 | Pool_addChunk(this); 62 | return Pool_allocateInChunk(this); 63 | } else { 64 | this->chunkListSize += POOL_CHUNKLIST_RATE; 65 | this->chunkList = realloc(this->chunkList, sizeof(void*) * this->chunkListSize); 66 | Pool_addChunk(this); 67 | return Pool_allocateInChunk(this); 68 | } 69 | } 70 | 71 | inline void* Pool_allocateClear(Pool* this) { 72 | return memset(Pool_allocate(this), 0, this->objectSize); 73 | } 74 | 75 | void Pool_free(Pool* this, void* item) { 76 | if (this->destroying) 77 | return; 78 | assert(!(this->freeListUsed > this->freeListSize)); 79 | if (this->freeListUsed == this->freeListSize) { 80 | this->freeListSize += POOL_FREELIST_RATE; 81 | this->freeList = realloc(this->freeList, sizeof(void*) * this->freeListSize); 82 | } 83 | this->freeList[this->freeListUsed++] = item; 84 | } 85 | 86 | void Pool_delete(Pool* this) { 87 | free(this->freeList); 88 | for (int i = 0; i < this->chunkListUsed; i++) 89 | free(this->chunkList[i]); 90 | free(this->chunkList); 91 | free(this); 92 | } 93 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Dit

2 | 3 | A console text editor for Unix systems that you already know how to use. 4 | 5 | http://hisham.hm/dit 6 | 7 | Dependencies 8 | ------------ 9 | 10 | Dit is designed to be light on dependencies. It is developed on Linux, 11 | but it should also be portable to other Unix-like platforms. 12 | Everything you need should be already installed by default in a typical 13 | Linux system. 14 | 15 | * ncurses: preferrably newer versions, with Unicode and mouse support 16 | * libiconv: optional, needed for Unicode 17 | * librt: needed for `clock_gettime` on Linux 18 | * bash: used for generating header files at build-time only 19 | * Lua: it bundles Lua 5.3 for scripting so you don't have to worry about 20 | this dependency, but it can also use the system-installed Lua if 21 | you have one. 22 | 23 | Installing 24 | ---------- 25 | 26 | For stable releases, get the latest version at http://hisham.hm/dit/releases/ 27 | -- unpack the `.tar.gz` file, enter its directory then run: 28 | 29 | * `./configure` 30 | * You may want to customize your installation path using `--prefix` 31 | * `make` 32 | * `sudo make install` 33 | * If you are installing to a custom path where super-user privileges are not needed, use `sudo make install` 34 | 35 | For installing the latest work-in-progress code from the Dit repository, 36 | you need Git, Autoconf and Automake. Then you'll be able to build it 37 | like this 38 | 39 | * `git clone https://github.com/hishamhm/dit` 40 | * `cd dit` 41 | * `./autogen.sh` 42 | * `./configure` 43 | * You may want to customize your installation path using `--prefix` 44 | * `make` 45 | * `sudo make install` 46 | * If you are installing to a custom path where super-user privileges are not needed, use `make install` 47 | 48 | Quick reference 49 | --------------- 50 | 51 | * Ctrl+Q or F10 - quit 52 | * Ctrl+S - save 53 | * Ctrl+X - cut 54 | * Ctrl+C - copy 55 | * Ctrl+V - paste 56 | * Ctrl+Z or Ctrl+U - undo 57 | * Ctrl+Y - redo 58 | * Shift-arrows or Alt-arrows - select 59 | * NOTE! Some terminals "capture" shift-arrow movement for other purposes (switching tabs, etc) and Dit never gets the keys, that's why Dit also tries to support Alt-arrows. Try both and see which one works. If Shift-arrows don't work I recommend you reconfigure your terminal (you can do this in Konsole setting "Previous Tab" and "Next Tab" to alt-left and alt-right, for example). RXVT-Unicode and Terminology are some terminals that work well out-of-the-box. 60 | * Ctrl+F or F3 - find. Inside Find: 61 | * Ctrl+C - toggle case sensitive 62 | * Ctrl+W - toggle whole word 63 | * Ctrl+N - next 64 | * Ctrl+P - previous 65 | * Ctrl+R - replace 66 | * Enter - "confirm": exit Find staying where you are 67 | * Esc - "cancel": exit Find returning to where you started 68 | * This is useful for "peeking into another part of the file": just Ctrl+F, type something to look, and then Esc to go back to where you were. 69 | * Ctrl+G - go to... 70 | * ...line number - Type a number to go to a line. 71 | * ...tab - Type text to go to the open tab that matches that substring. 72 | * Ctrl+B - back (to previous location, before last find, go-to-line, tab-switch, etc.) 73 | * You can press Ctrl+B multiple times to go back various levels. 74 | * F5 - multiple cursors 75 | * if you press F5 with a selection, the next cursor will appear at the next occurrence of the selection. 76 | * F6 - find all occurrences of a selection and apply multiple cursors 77 | * Tabs of open files: 78 | * Ctrl+J - previous tab 79 | * Ctrl+K - next tab 80 | * Ctrl+W - close tab 81 | * Ctrl+N - word wrap paragraph 82 | * Ctrl+T - toggle tab mode (Tabs, 2, 3, 4 or 8 spaces - it tries to autodetect based on file contents) 83 | 84 | This documentation is incomplete... there are [more keys](https://github.com/hishamhm/dit/blob/master/bindings/default)! Try around! 85 | 86 | -------------------------------------------------------------------------------- /Stack.c: -------------------------------------------------------------------------------- 1 | 2 | #include "Prototypes.h" 3 | 4 | #include 5 | #include 6 | 7 | /*{ 8 | 9 | struct StackItem_ { 10 | void* data; 11 | StackItem* next; 12 | }; 13 | 14 | struct Stack_ { 15 | ObjectClass* type; 16 | StackItem* head; 17 | bool owner; 18 | int size; 19 | }; 20 | 21 | }*/ 22 | 23 | Stack* Stack_new(ObjectClass* type, bool owner) { 24 | Stack* this = (Stack*) malloc(sizeof(Stack)); 25 | this->type = type; 26 | this->head = NULL; 27 | this->owner = owner; 28 | this->size = 0; 29 | return this; 30 | } 31 | 32 | void Stack_empty(Stack* this) { 33 | StackItem* item = this->head; 34 | while (item) { 35 | StackItem* saved = item; 36 | if (this->owner) { 37 | if (this->type) { 38 | Object* obj = (Object*)item->data; 39 | Msg0(Object, delete, obj); 40 | } else { 41 | if (item->data) 42 | free(item->data); 43 | } 44 | } 45 | item = item->next; 46 | free(saved); 47 | } 48 | this->head = NULL; 49 | this->size = 0; 50 | } 51 | 52 | void Stack_delete(Stack* this) { 53 | Stack_empty(this); 54 | free(this); 55 | } 56 | 57 | void Stack_push(Stack* this, void* data) { 58 | assert( !this->type || Call(Object, instanceOf, data, this->type) ); 59 | assert( data ); 60 | StackItem* item = (StackItem*) malloc(sizeof(StackItem)); 61 | item->data = data; 62 | item->next = this->head; 63 | this->head = item; 64 | this->size++; 65 | } 66 | 67 | void* Stack_pop(Stack* this) { 68 | if (!this->head) 69 | return NULL; 70 | void* result = this->head->data; 71 | StackItem* headNext = this->head->next; 72 | free(this->head); 73 | this->head = headNext; 74 | assert( !this->type || Call(Object, instanceOf, result, this->type) ); 75 | this->size--; 76 | return result; 77 | } 78 | 79 | void* Stack_peek(Stack* this) { 80 | if (!this->head) { 81 | return NULL; 82 | } 83 | return this->head->data; 84 | } 85 | 86 | void* Stack_peekAt(Stack* this, int n) { 87 | StackItem* at = this->head; 88 | for (int i = 0; i < n; i++) { 89 | if (at) 90 | at = at->next; 91 | } 92 | if (!at) { 93 | return NULL; 94 | } 95 | return at->data; 96 | } 97 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * mouse support 2 | * populate README file with text from the website 3 | * autoindent in TABS mode 4 | * centralize color configuration 5 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p m4 3 | autoreconf --install --force -I aclocal 4 | -------------------------------------------------------------------------------- /bindings/default: -------------------------------------------------------------------------------- 1 | CTRL_A Buffer_beginningOfLine 2 | CTRL_B Dit_jumpBack 3 | CTRL_C Dit_copy 4 | CTRL_E Buffer_endOfLine 5 | CTRL_F Dit_find 6 | CTRL_G Dit_goto 7 | CTRL_J Dit_previousTabPage 8 | CTRL_K Dit_nextTabPage 9 | CTRL_L Dit_refresh 10 | CTRL_Q Dit_quit 11 | CTRL_S Dit_save 12 | CTRL_T Buffer_toggleTabCharacters 13 | CTRL_U Dit_undo 14 | CTRL_V Dit_paste 15 | CTRL_W Dit_closeCurrent 16 | CTRL_X Dit_cut 17 | CTRL_Y Dit_redo 18 | CTRL_Z Dit_undo 19 | CTRL_INSERT Dit_copy 20 | F3 Dit_find 21 | F12 Buffer_selectAll 22 | F5 Dit_multipleCursors 23 | SHIFT_F5 Dit_decreaseMultipleCursors 24 | F6 Dit_findAllCursors 25 | SHIFT_IC Dit_paste 26 | SHIFT_INSERT Dit_paste 27 | CTRL_SHIFT_INSERT Dit_paste 28 | SDC Dit_cut 29 | SHIFT_DELETE Dit_cut 30 | F10 Dit_quit 31 | RETURN Dit_breakLine 32 | ENTER Dit_breakLine 33 | TAB Buffer_indent 34 | BTAB Buffer_unindent 35 | CTRL_SHIFT_RIGHT Dit_selectForwardWord 36 | SHIFT_RIGHT Dit_selectForwardChar 37 | CTRL_SHIFT_LEFT Dit_selectBackwardWord 38 | SHIFT_LEFT Dit_selectBackwardChar 39 | CTRL_SHIFT_DOWN Dit_selectSlideDownLine 40 | SHIFT_DOWN Dit_selectDownLine 41 | CTRL_SHIFT_UP Dit_selectSlideUpLine 42 | SHIFT_UP Dit_selectUpLine 43 | CTRL_SHIFT_HOME Dit_selectBeginningOfFile 44 | SHIFT_HOME Dit_selectBeginningOfLine 45 | CTRL_SHIFT_END Dit_selectEndOfFile 46 | SHIFT_END Dit_selectEndOfLine 47 | CTRL_SHIFT_PPAGE Dit_selectPreviousPage 48 | SHIFT_PPAGE Dit_selectPreviousPage 49 | CTRL_SHIFT_NPAGE Dit_selectNextPage 50 | SHIFT_NPAGE Dit_selectNextPage 51 | CTRL_RIGHT Buffer_forwardWord 52 | RIGHT Buffer_forwardChar 53 | CTRL_LEFT Buffer_backwardWord 54 | LEFT Buffer_backwardChar 55 | CTRL_DOWN Buffer_slideDownLine 56 | DOWN Buffer_downLine 57 | CTRL_UP Buffer_slideUpLine 58 | UP Buffer_upLine 59 | HOME Buffer_beginningOfLine 60 | END Buffer_endOfLine 61 | CTRL_HOME Dit_beginningOfFile 62 | CTRL_END Dit_endOfFile 63 | DELETE Buffer_deleteChar 64 | BS Buffer_backwardDeleteChar 65 | BACKSPACE Buffer_backwardDeleteChar 66 | NPAGE Buffer_nextPage 67 | PPAGE Buffer_previousPage 68 | BACK_TAB Buffer_unindent 69 | F8 Dit_deleteLine 70 | ALT_J Dit_moveTabPageLeft 71 | ALT_K Dit_moveTabPageRight 72 | ALT_A Dit_selectUpLine 73 | ALT_B Dit_selectDownLine 74 | ALT_C Dit_selectForwardChar 75 | ALT_D Dit_selectBackwardChar 76 | ALT_N Dit_wordWrap 77 | WHEELUP Dit_scrollDown 78 | WHEELDOWN Dit_scrollUp 79 | ESC Dit_cancelSelection 80 | -------------------------------------------------------------------------------- /debug.h: -------------------------------------------------------------------------------- 1 | 2 | #if defined(DEBUG) 3 | 4 | /* Full debug */ 5 | #define calloc(a, b) DebugMemory_calloc(a, b, __FILE__, __LINE__) 6 | #define malloc(x) DebugMemory_malloc(x, __FILE__, __LINE__, #x) 7 | #define realloc(x,s) DebugMemory_realloc(x, s, __FILE__, __LINE__, #x) 8 | #define strdup(x) DebugMemory_strdup(x, __FILE__, __LINE__) 9 | #define free(x) DebugMemory_free(x, __FILE__, __LINE__) 10 | #define debug_done() DebugMemory_report() 11 | 12 | #elif defined(DEBUGLITE) 13 | 14 | /* Assertions and core only */ 15 | #ifdef NDEBUG 16 | #undef NDEBUG 17 | #endif 18 | #define debug_done() sleep(0) 19 | 20 | #else 21 | 22 | /* No debugging */ 23 | #define NDEBUG 24 | #define debug_done() sleep(0) 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /docs/author.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | dit editor 4 | 5 | 6 | 7 |
8 | dit editor 9 |
10 |

11 | A console text editor for Unix that you already know how to use. 12 |

13 |

14 | 15 | 16 | 22 | 40 | 46 | 47 |
23 | Hisham Muhammad. You may also 24 | want to check out my other projects: 25 |

26 |
    27 |
  • 28 | htop - an interactive process monitor for Linux systems. 29 |
  • 30 |
  • I'm also a developer of GoboLinux, 31 | the Linux distribution with an alternative directory structure. 32 |
  • 33 |
  • 34 | Finally, my 35 | personal webpage 36 | may be of marginal interest. :) 37 |
  • 38 |
39 |
48 |

49 | 50 | 51 | -------------------------------------------------------------------------------- /docs/dit-white.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamhm/dit/627710baea177b3ee161bf79f8e1a0f7d9f78337/docs/dit-white.jpg -------------------------------------------------------------------------------- /docs/dit.css: -------------------------------------------------------------------------------- 1 | * { 2 | font-family: "bitstream vera sans", "verdana", "arial", sans; 3 | } 4 | tt { 5 | font-family: "bitstream vera sans mono", "andale mono", "courier new", mono; 6 | } 7 | body { 8 | background-color: black; 9 | color: white; 10 | } 11 | a { 12 | color: #aaaabb; 13 | font-weight: bold; 14 | } 15 | a.menu { 16 | color: #aaaabb; 17 | font-weight: bold; 18 | text-decoration: none; 19 | } 20 | a.code { 21 | font-family: "bitstream vera sans mono", "andale mono", "courier new", mono; 22 | text-decoration: underline; 23 | color: white; 24 | font-weight: normal; 25 | } 26 | :hover { 27 | text-decoration: underline; 28 | } 29 | .title { 30 | text-align: center; 31 | } 32 | .intro { 33 | text-align: center; 34 | } 35 | .shot { 36 | text-align: center; 37 | } 38 | .left { 39 | text-align: right; 40 | } 41 | .right { 42 | text-align: left; 43 | } 44 | .middle { 45 | text-align: left; 46 | vertical-align: top; 47 | } 48 | td.menu { 49 | vertical-align: top; 50 | width: 20%; 51 | } 52 | ul.menu { 53 | padding: 10px; 54 | } 55 | li.menu { 56 | list-style-type: none; 57 | font-size: larger; 58 | margin-bottom: 10px; 59 | } 60 | .maintable { 61 | text-align: center; 62 | padding: 0px; 63 | } 64 | .footer { 65 | text-align: center; 66 | } 67 | hr { 68 | height: 1px; 69 | background-color: #aaaaaa; 70 | border: 0px; 71 | } 72 | .question { 73 | font-weight: bold; 74 | padding-top: 10px; 75 | } 76 | -------------------------------------------------------------------------------- /docs/dit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamhm/dit/627710baea177b3ee161bf79f8e1a0f7d9f78337/docs/dit.jpg -------------------------------------------------------------------------------- /docs/downloads.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | dit editor 4 | 5 | 6 | 7 |
8 | dit editor 9 |
10 |

11 | A console text editor for Unix that you already know how to use. 12 |

13 |

14 | 15 | 16 | 22 | 106 | 112 | 113 |
23 |

Downloads

24 | 25 |

Get dit!

26 | 27 |

28 | 29 | >>> dit-0.4.tar.gz <<< 30 | 31 |

32 | 33 |

Dit from git

34 | 35 |

36 | You can keep track of the ongoing development by checking out 37 | the current state of the Git repository. You can do so 38 | issuing the following command: 39 |

40 | 41 |

42 | git clone https://github.com/hishamhm/dit 43 |

44 | 45 |

46 | It will download the sources in the "dit" directory. Run the script "autogen.sh" 47 | to build the configure file, and then proceed with the usual "configure", 48 | "make", "make install" sequence. As usual, free software is distributed with 49 | NO WARRANTY, so use it at your own risk! 50 |

51 | 52 |

53 | You can also browse the Git repository online. 54 |

55 | 56 |

Quick reference:

57 | 58 |
    59 |
  • Ctrl+Q or F10 - quit
  • 60 |
  • Ctrl+S - save
  • 61 |
  • Ctrl+X - cut
  • 62 |
  • Ctrl+C - copy
  • 63 |
  • Ctrl+V - paste
  • 64 |
  • Shift-arrows or Alt-arrows - select 65 |
      66 |
    • NOTE! Some terminals "capture" shift-arrow movement 67 | for other purposes (switching tabs, etc) and Dit never gets the keys, 68 | that's why Dit also tries to support Alt-arrows. Try both and see which 69 | one works. If Shift-arrows don't work recommend you reconfigure them 70 | (you can do this in Konsole setting "Previous Tab" and "Next Tab" to 71 | alt-left and alt-right, for example). RXVT-Unicode and Terminology are 72 | some terminals that work well out-of-the-box.
    • 73 |
    74 |
  • Ctrl+F or F3 - find. Inside Find:
    75 |
      76 |
    • Ctrl+C - toggle case sensitive
    • 77 |
    • Ctrl+W - toggle whole word
    • 78 |
    • Ctrl+N - next
    • 79 |
    • Ctrl+P - previous
    • 80 |
    • Ctrl+R - replace
    • 81 |
    • Enter - "confirm": exit Find staying where you are
    • 82 |
    • Esc - "cancel": exit Find returning to where you started 83 |
      • This is useful for "peeking into another part of the file": just Ctrl+F, type something to look, and then Esc to go back to where you were.
      84 |
    • 85 |
    86 |
  • 87 |
  • Ctrl+G - go to...
  • 88 |
    • ...line number - Type a number to go to a line.
    89 |
    • ...tab - Type text to go to the open tab that matches that substring.
    90 |
  • Ctrl+B - back (to previous location, before last find, go-to-line, tab-switch, etc.) 91 |
    • You can press Ctrl+B multiple times to go back various levels.
    92 |
  • 93 |
  • Tabs of open files: 94 |
      95 |
    • Ctrl+J - previous tab
    • 96 |
    • Ctrl+K - next tab
    • 97 |
    • Ctrl+W - close tab
    • 98 |
    99 |
  • 100 |
  • Ctrl+N - word wrap paragraph
  • 101 |
  • Ctrl+T - toggle tab mode (Tabs, 2, 3, 4 or 8 spaces - it tries to autodetect based on file contents)
  • 102 |
103 | 104 |

This documentation is incomplete... there are more keys! Try around!

105 |
114 |

115 | 116 | 117 | -------------------------------------------------------------------------------- /docs/faq.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | dit editor 4 | 5 | 6 | 7 |
8 | dit editor 9 |
10 |

11 | A console text editor for Unix that you already know how to use. 12 |

13 |

14 | 15 | 16 | 22 | 71 | 77 | 78 |
23 |

Frequently Asked Questions

24 | 25 |

Who is the target audience? 26 |

27 |

28 | This project was created to scratch a personal itch: 29 | I use Linux but I never found a text editor in Unix I was totally 30 | comfortable with. So, I guess the target audience are other 31 | likeminded people who are not into Vim or Emacs but still have 32 | a need for a console-mode text editor. Dit behaves much like 33 | text-entry widgets of most applications, so its learning curve 34 | should be pretty small. 35 |

36 | 37 |

Where is the documentation?

38 |

There is not a lot of documentation yet. 39 | There are some hints to help you get started in the 40 | download page, and... 41 | well, that's not really documentation but the 42 | key bindings file knows all the secrets. :)

43 | 44 |

Some key combinations don't work!

45 |

It could be a lot of things: X or the console driver, the 46 | terminal, ncurses or dit itself. Writing interactive applications 47 | for the Unix console is a frustrating uphill battle. It's impossible to 48 | come up with a configuration that works everywhere, so I made terminal escapes 49 | and keybindings configurable through files loaded at runtime. Take a look at 50 | the files under terminals/ and bindings/ and edit them at your heart's content. 51 |

52 | 53 |

54 | What does the name 'dit' stand for? 55 |

56 |

57 | 58 | 'Dit' is the past participle of the verb dire, which means "to say", in 60 | French. It's a short, easy to pronounce name that I find very fitting: a text 61 | editor is a tool to "say" things, in writing. It took me an year and a half to 62 | find this name. Before that, the editor's binary was simply called 'e'. 63 | Ironically, only when I took the 'e' out of 'edit', I found a nice word that 64 | could represent the project well. 65 |

66 | 67 | So, no, 'dit' is not an acronym. Especially, it is not a recursive 68 | acronym, although something like "Dit Is a Texteditor" could be easily thought of 69 | after the fact.

70 |
79 |

80 | 81 | 82 | -------------------------------------------------------------------------------- /docs/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | dit editor 4 | 5 | 6 | 7 |
8 | dit editor 9 |
10 |

11 | A console text editor for Unix that you already know how to use. 12 |

13 |

14 | 15 | 16 | 22 | 82 | 88 | 89 |
23 |

24 | dit screenshot 25 |

26 | 27 |

Quick reference:

28 | 29 |
    30 |
  • Ctrl+Q or F10 - quit
  • 31 |
  • Ctrl+S - save
  • 32 |
  • Ctrl+X - cut
  • 33 |
  • Ctrl+C - copy
  • 34 |
  • Ctrl+V - paste
  • 35 |
  • Ctrl+Z or Ctrl+U - undo
  • 36 |
  • Ctrl+Y - redo
  • 37 |
  • Shift-arrows or Alt-arrows - select 38 |
      39 |
    • NOTE! Some terminals "capture" shift-arrow movement 40 | for other purposes (switching tabs, etc) and Dit never gets the keys, 41 | that's why Dit also tries to support Alt-arrows. Try both and see which 42 | one works. If Shift-arrows don't work recommend you reconfigure them 43 | (you can do this in Konsole setting "Previous Tab" and "Next Tab" to 44 | alt-left and alt-right, for example). RXVT-Unicode and Terminology are 45 | some terminals that work well out-of-the-box.
    • 46 |
    47 |
  • Ctrl+F or F3 - find. Inside Find:
    48 |
      49 |
    • Ctrl+C - toggle case sensitive
    • 50 |
    • Ctrl+W - toggle whole word
    • 51 |
    • Ctrl+N - next
    • 52 |
    • Ctrl+P - previous
    • 53 |
    • Ctrl+R - replace
    • 54 |
    • Enter - "confirm": exit Find staying where you are
    • 55 |
    • Esc - "cancel": exit Find returning to where you started 56 |
      • This is useful for "peeking into another part of the file": just Ctrl+F, type something to look, and then Esc to go back to where you were.
      57 |
    • 58 |
    59 |
  • 60 |
  • Ctrl+G - go to...
  • 61 |
    • ...line number - Type a number to go to a line.
    62 |
    • ...tab - Type text to go to the open tab that matches that substring.
    63 |
  • Ctrl+B - back (to previous location, before last find, go-to-line, tab-switch, etc.) 64 |
    • You can press Ctrl+B multiple times to go back various levels.
    65 |
  • 66 |
  • Tabs of open files: 67 |
      68 |
    • Ctrl+J - previous tab
    • 69 |
    • Ctrl+K - next tab
    • 70 |
    • Ctrl+W - close tab
    • 71 |
    72 |
  • 73 |
  • Ctrl+N - word wrap paragraph
  • 74 |
  • Ctrl+T - toggle tab mode (Tabs, 2, 3, 4 or 8 spaces - it tries to autodetect based on file contents)
  • 75 |
76 | 77 |

This documentation is incomplete... there are more keys! Try around!

78 | 79 | 81 |
90 |

91 | 92 | 93 | -------------------------------------------------------------------------------- /docs/mailinglist.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | dit editor 4 | 5 | 6 | 7 |
8 | dit editor 9 |
10 |

11 | A console text editor for Unix that you already know how to use. 12 |

13 |

14 | 15 | 16 | 22 | 33 | 39 | 40 |
23 |

Mailing list

24 | 25 |

I don't think a mailing list is needed at this point, 26 | but you can contact me directly by email 27 | (contact info in the author page. 28 |

29 | To report bugs, please use the 30 | bug tracker 31 | at GitHub! Thank you! 32 |

41 |

42 | 43 | 44 | -------------------------------------------------------------------------------- /docs/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hishamhm/dit/627710baea177b3ee161bf79f8e1a0f7d9f78337/docs/screenshot.png -------------------------------------------------------------------------------- /docs/screenshots.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | dit editor 4 | 5 | 6 | 7 |
8 | dit editor 9 |
10 |

11 | A console text editor for Unix that you already know how to use. 12 |

13 |

14 | 15 | 16 | 22 | 33 | 39 | 40 |
23 |

Screenshots

24 | 25 |

26 | An old version of dit editing an even older version of itself: 27 |

28 | dit screenshot 29 | 30 |

31 | More screenshots to come at a later date. 32 |

41 |

42 | 43 | 44 | -------------------------------------------------------------------------------- /editorconfig/LICENSE: -------------------------------------------------------------------------------- 1 | Unless otherwise stated, all files are distributed under the Simplified BSD 2 | license. The inih(`src/lib/ini.c` and `src/lib/ini.h`) library is distributed 3 | under the New BSD license. `src/lib/utarray.h` is distributed under the Revised 4 | BSD License. The See LICENSE file for details. Some code in src/lib/misc.c is 5 | idstributed under their own license (see the source file for details). 6 | 7 | Copyright (c) 2011-2013 EditorConfig Team, including Hong Xu and Trey Hunner 8 | Copyright (c) 2014 Hong Xu 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | 14 | 1. Redistributions of source code must retain the above copyright notice, 15 | this list of conditions and the following disclaimer. 16 | 2. Redistributions in binary form must reproduce the above copyright notice, 17 | this list of conditions and the following disclaimer in the documentation 18 | and/or other materials provided with the distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 24 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 | POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /editorconfig/src/config.h: -------------------------------------------------------------------------------- 1 | #define HAVE_STRDUP 2 | #if _WIN32 3 | #define WIN32 4 | #else 5 | #define UNIX 6 | #endif 7 | #define editorconfig_VERSION_MAJOR 0 8 | #define editorconfig_VERSION_MINOR 11 9 | #define editorconfig_VERSION_SUBMINOR 5 10 | #define editorconfig_VERSION_SUFFIX "-development" 11 | 12 | -------------------------------------------------------------------------------- /editorconfig/src/ec_fnmatch.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1992, 1993 3 | * The Regents of the University of California. All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the University nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 30 | * 31 | * From FreeBSD fnmatch.h 1.7 32 | * $Id: fnmatch.h,v 1.4 2001/10/04 02:46:21 jdp Exp $ 33 | * 34 | * Copyright(C) 2011-2012 EditorConfig Team. 35 | * Modified by EditorConfig Team for use in EditorConfig project. 36 | */ 37 | 38 | #ifndef __EC_FNMATCH_H__ 39 | #define __EC_FNMATCH_H__ 40 | 41 | #include "global.h" 42 | 43 | #define EC_FNM_NOMATCH 1 /* Match failed. */ 44 | 45 | #define EC_FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ 46 | #define EC_FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ 47 | #define EC_FNM_PERIOD 0x04 /* Period must be matched by period. */ 48 | #define EC_FNM_LEADING_DIR 0x08 /* Ignore / after Imatch. */ 49 | #define EC_FNM_CASEFOLD 0x10 /* Case insensitive search. */ 50 | #define EC_FNM_PREFIX_DIRS 0x20 /* Directory prefixes of pattern match too. */ 51 | 52 | EDITORCONFIG_LOCAL 53 | int ec_fnmatch(const char *, const char *, int); 54 | 55 | #endif /* !__EC_FNMATCH_H__ */ 56 | -------------------------------------------------------------------------------- /editorconfig/src/editorconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2012 EditorConfig Team 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef __EDITORCONFIG_H__ 28 | #define __EDITORCONFIG_H__ 29 | 30 | #include 31 | 32 | #include "editorconfig_handle.h" 33 | 34 | typedef struct editorconfig_name_value editorconfig_name_value; 35 | 36 | #endif /* !__EDITORCONFIG_H__ */ 37 | 38 | -------------------------------------------------------------------------------- /editorconfig/src/editorconfig_handle.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2012 EditorConfig Team 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef __EDITORCONFIG_HANDLE_H__ 28 | #define __EDITORCONFIG_HANDLE_H__ 29 | 30 | #include "global.h" 31 | #include 32 | 33 | /*! 34 | * @brief A structure containing a name and its corresponding value. 35 | * @author EditorConfig Team 36 | */ 37 | struct editorconfig_name_value 38 | { 39 | /*! EditorConfig config item's name. */ 40 | char* name; 41 | /*! EditorConfig config item's value. */ 42 | char* value; 43 | }; 44 | 45 | /*! 46 | * @brief A structure that descripts version number. 47 | * @author EditorConfig Team 48 | */ 49 | struct editorconfig_version 50 | { 51 | /*! major version */ 52 | int major; 53 | /*! minor version */ 54 | int minor; 55 | /*! subminor version */ 56 | int subminor; 57 | }; 58 | 59 | struct editorconfig_handle 60 | { 61 | /*! 62 | * The file name of EditorConfig conf file. If this pointer is set to NULL, 63 | * the file name is set to ".editorconfig" by default. 64 | */ 65 | const char* conf_file_name; 66 | 67 | /*! 68 | * When a parsing error occured, this will point to a file that caused the 69 | * parsing error. 70 | */ 71 | char* err_file; 72 | 73 | /*! 74 | * version number it should act as. Set this to 0.0.0 to act like the 75 | * current version. 76 | */ 77 | struct editorconfig_version ver; 78 | 79 | /*! Pointer to a list of editorconfig_name_value structures containing 80 | * names and values of the parsed result */ 81 | struct editorconfig_name_value* name_values; 82 | 83 | /*! The total count of name_values structures pointed by name_values 84 | * pointer */ 85 | int name_value_count; 86 | }; 87 | 88 | #endif /* !__EDITORCONFIG_HANDLE_H__ */ 89 | 90 | -------------------------------------------------------------------------------- /editorconfig/src/global.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2012 EditorConfig Team 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef __GLOBAL_H__ 28 | #define __GLOBAL_H__ 29 | 30 | #include "config.h" 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | /* 38 | * Microsoft Visual C++ and some other Windows C Compilers requires exported 39 | * functions in shared library to be defined with __declspec(dllexport) 40 | * declarator. Also, gcc >= 4 supports hiding symbols that do not need to be 41 | * exported. 42 | */ 43 | #ifdef editorconfig_shared_EXPORTS /* We are building shared lib if defined */ 44 | # ifdef WIN32 45 | # ifdef __GNUC__ 46 | # define EDITORCONFIG_EXPORT __attribute__ ((dllexport)) 47 | # else /* __GNUC__ */ 48 | # define EDITORCONFIG_EXPORT __declspec(dllexport) 49 | # endif /* __GNUC__ */ 50 | # else /* WIN32 */ 51 | # if defined(__GNUC__) && __GNUC__ >= 4 52 | # define EDITORCONFIG_EXPORT __attribute__ ((visibility ("default"))) 53 | # define EDITORCONFIG_LOCAL __attribute__ ((visibility ("hidden"))) 54 | # endif /* __GNUC__ && __GNUC >= 4 */ 55 | # endif /* WIN32 */ 56 | #endif /* editorconfig_shared_EXPORTS */ 57 | 58 | /* 59 | * For other cases, just define EDITORCONFIG_EXPORT and EDITORCONFIG_LOCAL, to 60 | * make compilation successful 61 | */ 62 | #ifndef EDITORCONFIG_EXPORT 63 | # define EDITORCONFIG_EXPORT 64 | #endif 65 | #ifndef EDITORCONFIG_LOCAL 66 | # define EDITORCONFIG_LOCAL 67 | #endif 68 | 69 | /* a macro to set editorconfig_version struct */ 70 | #define SET_EDITORCONFIG_VERSION(editorconfig_ver, maj, min, submin) \ 71 | do { \ 72 | (editorconfig_ver)->major = (maj); \ 73 | (editorconfig_ver)->minor = (min); \ 74 | (editorconfig_ver)->subminor = (submin); \ 75 | } while(0) 76 | 77 | #endif /* !__GLOBAL_H__ */ 78 | 79 | -------------------------------------------------------------------------------- /editorconfig/src/ini.h: -------------------------------------------------------------------------------- 1 | /* inih -- simple .INI file parser 2 | 3 | The "inih" library is distributed under the New BSD license: 4 | 5 | Copyright (c) 2009, Brush Technology 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of Brush Technology nor the names of its contributors 16 | may be used to endorse or promote products derived from this software 17 | without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY BRUSH TECHNOLOGY ''AS IS'' AND ANY 20 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL BRUSH TECHNOLOGY BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | Go to the project home page for more info: 31 | http://code.google.com/p/inih/ 32 | 33 | */ 34 | 35 | #ifndef __INI_H__ 36 | #define __INI_H__ 37 | 38 | #include "global.h" 39 | 40 | /* Make this header file easier to include in C++ code */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #include 46 | 47 | /* Parse given INI-style file. May have [section]s, name=value pairs 48 | (whitespace stripped), and comments starting with ';' (semicolon). Section 49 | is "" if name=value pair parsed before any section heading. name:value 50 | pairs are also supported as a concession to Python's ConfigParser. 51 | 52 | For each name=value pair parsed, call handler function with given user 53 | pointer as well as section, name, and value (data only valid for duration 54 | of handler call). Handler should return nonzero on success, zero on error. 55 | 56 | Returns 0 on success, line number of first error on parse error (doesn't 57 | stop on first error), or -1 on file open error. 58 | */ 59 | EDITORCONFIG_LOCAL 60 | int ini_parse(const char* filename, 61 | int (*handler)(void* user, const char* section, 62 | const char* name, const char* value), 63 | void* user); 64 | 65 | /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't 66 | close the file when it's finished -- the caller must do that. */ 67 | EDITORCONFIG_LOCAL 68 | int ini_parse_file(FILE* file, 69 | int (*handler)(void* user, const char* section, 70 | const char* name, const char* value), 71 | void* user); 72 | 73 | /* Nonzero to allow multi-line value parsing, in the style of Python's 74 | ConfigParser. If allowed, ini_parse() will call the handler with the same 75 | name for each subsequent line parsed. */ 76 | #ifndef INI_ALLOW_MULTILINE 77 | #define INI_ALLOW_MULTILINE 0 78 | #endif 79 | 80 | #define MAX_SECTION_NAME 50 81 | #define MAX_PROPERTY_NAME 50 82 | 83 | /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of 84 | the file. See http://code.google.com/p/inih/issues/detail?id=21 */ 85 | #ifndef INI_ALLOW_BOM 86 | #define INI_ALLOW_BOM 1 87 | #endif 88 | 89 | #ifdef __cplusplus 90 | } 91 | #endif 92 | 93 | #endif /* __INI_H__ */ 94 | -------------------------------------------------------------------------------- /editorconfig/src/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2012 EditorConfig Team 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #ifndef __MISC_H__ 28 | #define __MISC_H__ 29 | 30 | #include "global.h" 31 | 32 | #include 33 | 34 | #ifndef HAVE_STRCASECMP 35 | # ifdef HAVE_STRICMP 36 | # define strcasecmp stricmp 37 | # else /* HAVE_STRICMP */ 38 | EDITORCONFIG_LOCAL 39 | int ec_strcasecmp(const char *s1, const char *s2); 40 | # define strcasecmp ec_strcasecmp 41 | # endif /* HAVE_STRICMP */ 42 | #endif /* !HAVE_STRCASECMP */ 43 | #ifndef HAVE_STRDUP 44 | EDITORCONFIG_LOCAL 45 | char* ec_strdup(const char *str); 46 | # define strdup ec_strdup 47 | #endif 48 | #ifndef HAVE_STRNDUP 49 | EDITORCONFIG_LOCAL 50 | char* ec_strndup(const char* str, size_t n); 51 | # define strndup ec_strndup 52 | #endif 53 | EDITORCONFIG_LOCAL 54 | char* str_replace(char* str, char oldc, char newc); 55 | #ifndef HAVE_STRLWR 56 | EDITORCONFIG_LOCAL 57 | char* ec_strlwr(char* str); 58 | # define strlwr ec_strlwr 59 | #endif 60 | EDITORCONFIG_LOCAL 61 | _Bool is_file_path_absolute(const char* path); 62 | #endif /* __MISC_H__ */ 63 | -------------------------------------------------------------------------------- /highlight/autoconf.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix configure.ac 3 | name suffix configure.in 4 | name suffix .m4 5 | RULES 6 | 7 | include gitconflict.dithlinc 8 | 9 | context dnl `$ special 10 | /context 11 | rule define brightspecial 12 | 13 | rule `[A`-Z`]`[A`-Z0`-9_`]`+ brightspecial 14 | 15 | context ( ) brightspecial brightspecial normal 16 | rule , symbol 17 | context [ ] brightdiff brightdiff diff 18 | context [ ] brightdiff brightdiff diff 19 | context [ ] brightdiff brightdiff diff 20 | include nestedm4.dithlinc 21 | /context 22 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 23 | include nestedm4.dithlinc 24 | /context 25 | /context 26 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 27 | context [ ] brightdiff brightdiff diff 28 | include nestedm4.dithlinc 29 | /context 30 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 31 | include nestedm4.dithlinc 32 | /context 33 | /context 34 | /context 35 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 36 | context [ ] brightdiff brightdiff diff 37 | context [ ] brightdiff brightdiff diff 38 | include nestedm4.dithlinc 39 | /context 40 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 41 | include nestedm4.dithlinc 42 | /context 43 | /context 44 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 45 | context [ ] brightdiff brightdiff diff 46 | include nestedm4.dithlinc 47 | /context 48 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 49 | include nestedm4.dithlinc 50 | /context 51 | /context 52 | /context 53 | /context 54 | 55 | include shell.dithlinc 56 | -------------------------------------------------------------------------------- /highlight/c.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .c 3 | name suffix .C 4 | name suffix .cc 5 | name suffix .cpp 6 | name suffix .cxx 7 | name suffix .h 8 | name suffix .hh 9 | name suffix .hpp 10 | name suffix .h.in 11 | name suffix .c.in 12 | name suffix .xs 13 | RULES 14 | script c.lua 15 | 16 | include c.dithlinc 17 | include gitconflict.dithlinc 18 | -------------------------------------------------------------------------------- /highlight/c.dithlinc: -------------------------------------------------------------------------------- 1 | 2 | rule auto diff 3 | rule char diff 4 | rule void diff 5 | rule bool diff 6 | rule unsigned diff 7 | rule const diff 8 | rule double diff 9 | rule signed diff 10 | rule typedef diff 11 | rule union diff 12 | rule volatile diff 13 | rule enum diff 14 | rule extern diff 15 | rule float diff 16 | rule long diff 17 | rule register diff 18 | rule short diff 19 | rule int diff 20 | rule static diff 21 | rule struct diff 22 | rule class diff 23 | rule private diff 24 | rule protected diff 25 | rule public diff 26 | rule inline diff 27 | 28 | rule if bright 29 | rule else bright 30 | rule default bright 31 | rule while bright 32 | rule switch bright 33 | rule case bright 34 | rule break bright 35 | rule continue bright 36 | rule return bright 37 | rule for bright 38 | rule do bright 39 | rule goto bright 40 | rule sizeof bright 41 | 42 | rule -> symbol 43 | rule ! brightsymbol 44 | rule < brightsymbol 45 | rule > brightsymbol 46 | rule = brightsymbol 47 | rule + brightsymbol 48 | rule - brightsymbol 49 | rule * brightsymbol 50 | rule / brightsymbol 51 | rule [ symbol 52 | rule ] symbol 53 | rule { symbol 54 | rule } symbol 55 | rule ( symbol 56 | rule ) symbol 57 | rule : symbol 58 | rule , symbol 59 | rule | symbol 60 | rule & symbol 61 | rule ; brightsymbol 62 | rule TODO veryspecial 63 | rule XXX veryspecial 64 | rule FIXME veryspecial 65 | context /* */ dim 66 | rule TODO veryspecial 67 | rule XXX veryspecial 68 | rule FIXME veryspecial 69 | /context 70 | context // `$ dim 71 | rule TODO veryspecial 72 | rule XXX veryspecial 73 | rule FIXME veryspecial 74 | /context 75 | context " " alt 76 | eager_rule \\ brightalt 77 | eager_rule \" brightalt 78 | eager_rule \`[abcfnrtv`] brightalt 79 | eager_rule \`[0`-3`]`[0`-7`]`[0`-7`] brightalt 80 | /context 81 | context ' ' brightalt 82 | eager_rule \\ brightalt 83 | eager_rule \' brightalt 84 | /context 85 | context #`[`s`|`t`]`*`[a`-z`]`+ `$ brightspecial 86 | ### rule \`$ veryspecial ### need to handle these special breaks later 87 | /context 88 | context #include `$ brightspecial 89 | context " " special 90 | /context 91 | context < > special 92 | /context 93 | /context 94 | context #if`[`s`|`t`]`+0 #endif dim 95 | rule TODO veryspecial 96 | rule XXX veryspecial 97 | rule FIXME veryspecial 98 | /context 99 | 100 | -------------------------------------------------------------------------------- /highlight/conf.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name regex [^f][^o][^n][^t][^s]\.conf$ 3 | name regex ^....\.conf$ 4 | name regex ^...\.conf$ 5 | name regex ^..\.conf$ 6 | name regex ^.\.conf$ 7 | name regex ^\..*rc$ 8 | RULES 9 | 10 | script shell.lua 11 | 12 | include gitconflict.dithlinc 13 | 14 | context # `$ dim 15 | /context 16 | 17 | context `^; `$ dim 18 | /context 19 | 20 | context " " brightalt 21 | /context -------------------------------------------------------------------------------- /highlight/css.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .css 3 | RULES 4 | 5 | include gitconflict.dithlinc 6 | include css.dithlinc 7 | 8 | -------------------------------------------------------------------------------- /highlight/css.dithlinc: -------------------------------------------------------------------------------- 1 | 2 | context url( ) brightalt brightalt alt 3 | /context 4 | 5 | context " " alt 6 | /context 7 | 8 | rule background-color bright 9 | rule color bright 10 | rule background bright 11 | rule background-image bright 12 | rule background-repeat bright 13 | rule margin bright 14 | rule font-family bright 15 | rule font-size bright 16 | rule border bright 17 | rule border-top bright 18 | rule font-weight bright 19 | rule height bright 20 | rule padding bright 21 | rule vertical-align bright 22 | rule font-style bright 23 | rule font-size bright 24 | rule text-align bright 25 | rule border-style bright 26 | rule border-color bright 27 | rule border-width bright 28 | rule text-decoration bright 29 | 30 | rule white brightalt 31 | rule black brightalt 32 | rule bold brightalt 33 | rule solid brightalt 34 | rule none brightalt 35 | rule underline brightalt 36 | rule repeat-`[xy`] brightalt 37 | rule no-repeat brightalt 38 | rule top brightalt 39 | rule bottom brightalt 40 | rule italic brightalt 41 | rule right brightalt 42 | rule left brightalt 43 | rule center brightalt 44 | rule smaller brightalt 45 | rule small brightalt 46 | 47 | rule sans brightalt 48 | rule mono brightalt 49 | 50 | rule :hover brightalt 51 | 52 | rule * brightdiff 53 | rule , diff 54 | rule ; diff 55 | rule : brightdiff 56 | rule { brightalt 57 | rule } brightalt 58 | 59 | rule #`[0`-9`|a`-f`]`[0`-9`|a`-f`]`[0`-9`|a`-f`] alt 60 | rule #`[0`-9`|a`-f`]`[0`-9`|a`-f`]`[0`-9`|a`-f`]`[0`-9`|a`-f`]`[0`-9`|a`-f`]`[0`-9`|a`-f`] alt 61 | 62 | rule `[0`-9`]`+px alt 63 | 64 | context /* */ dim 65 | /context 66 | 67 | rule body brightdiff 68 | rule pre brightdiff 69 | rule img brightdiff 70 | rule h`[1`-6`] brightdiff 71 | rule a brightdiff 72 | rule table brightdiff 73 | rule td brightdiff 74 | rule tr brightdiff 75 | rule tt brightdiff 76 | rule hr brightdiff 77 | rule p brightdiff 78 | rule div brightdiff 79 | rule span brightdiff 80 | -------------------------------------------------------------------------------- /highlight/diff.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | firstline prefix diff 3 | name suffix .diff 4 | name suffix .patch 5 | name suffix .rej 6 | RULES 7 | 8 | include diff.dithlinc 9 | -------------------------------------------------------------------------------- /highlight/diff.dithlinc: -------------------------------------------------------------------------------- 1 | 2 | context `^diff `$ veryspecial 3 | /context 4 | 5 | context `^@@ @@ special 6 | /context 7 | 8 | context `^--- `$ specialdiff 9 | /context 10 | 11 | context `^+++ `$ brightdiff 12 | /context 13 | 14 | context `^- `$ specialdiff 15 | /context 16 | 17 | context `^+ `$ diff 18 | /context 19 | 20 | context `^< `$ specialdiff 21 | /context 22 | 23 | context `^> `$ diff 24 | /context 25 | 26 | -------------------------------------------------------------------------------- /highlight/dithl.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .dithl 3 | name suffix .dithlinc 4 | RULES 5 | context FILES RULES veryspecial veryspecial normal 6 | context name `$ normal 7 | rule prefix bright 8 | rule suffix bright 9 | rule regex bright 10 | /context 11 | context firstline `$ normal 12 | rule prefix bright 13 | rule suffix bright 14 | rule regex bright 15 | /context 16 | rule name bright 17 | rule firstline bright 18 | /context 19 | rule rule bright 20 | rule eager_rule bright 21 | rule context bright 22 | rule insensitive bright 23 | rule include bright 24 | rule script bright 25 | 26 | rule normal normal 27 | rule bright bright 28 | rule symbol symbol 29 | rule brightsymbol brightsymbol 30 | rule alt alt 31 | rule brightalt brightalt 32 | rule diff diff 33 | rule brightdiff brightdiff 34 | rule special special 35 | rule brightspecial brightspecial 36 | rule specialdiff specialdiff 37 | rule brightspecialdiff brightspecialdiff 38 | rule veryspecial veryspecial 39 | rule dim dim 40 | 41 | eager_rule ``^ veryspecial 42 | eager_rule ``$ veryspecial 43 | eager_rule ```[``[-]+*?|ts`] brightdiff 44 | 45 | context `^# `$ dim 46 | /context 47 | -------------------------------------------------------------------------------- /highlight/etlua.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .etlua 3 | RULES 4 | 5 | context <% %> veryspecial veryspecial normal 6 | include lua.dithlinc 7 | /context 8 | 9 | context <%= %> veryspecial veryspecial normal 10 | include lua.dithlinc 11 | /context 12 | 13 | include html.dithlinc 14 | 15 | -------------------------------------------------------------------------------- /highlight/gitcommit.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name prefix COMMIT_EDITM 3 | RULES 4 | 5 | context `^# `$ dim 6 | context On`sbranch`smaster `$ dim dim brightalt 7 | /context 8 | context On`sbranch`s `$ dim dim veryspecial 9 | /context 10 | context modified: `$ brightalt normal normal 11 | /context 12 | context new`sfile: `$ brightdiff normal normal 13 | /context 14 | context deleted: `$ veryspecial normal normal 15 | /context 16 | context " " alt 17 | /context 18 | context ' ' alt 19 | /context 20 | /context 21 | 22 | include diff.dithlinc 23 | -------------------------------------------------------------------------------- /highlight/gitconflict.dithlinc: -------------------------------------------------------------------------------- 1 | 2 | context `^<<<<<<< `$ veryspecial 3 | /context 4 | context `^======= `$ veryspecial 5 | /context 6 | context `^>>>>>>> `$ veryspecial 7 | /context 8 | 9 | -------------------------------------------------------------------------------- /highlight/go.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .go 3 | RULES 4 | 5 | script go.lua 6 | 7 | rule := brightdiff 8 | 9 | rule func diff 10 | rule package diff 11 | rule import diff 12 | 13 | rule auto diff 14 | rule char diff 15 | rule void diff 16 | rule bool diff 17 | rule unsigned diff 18 | rule const diff 19 | rule double diff 20 | rule signed diff 21 | rule typedef diff 22 | rule union diff 23 | rule volatile diff 24 | rule enum diff 25 | rule extern diff 26 | rule float diff 27 | rule long diff 28 | rule register diff 29 | rule short diff 30 | rule int diff 31 | rule static diff 32 | rule struct diff 33 | rule class diff 34 | rule private diff 35 | rule protected diff 36 | rule public diff 37 | rule inline diff 38 | 39 | rule int64 diff 40 | rule float64 diff 41 | rule uint64 diff 42 | 43 | rule defer bright 44 | 45 | rule if bright 46 | rule else bright 47 | rule default bright 48 | rule while bright 49 | rule switch bright 50 | rule case bright 51 | rule break bright 52 | rule continue bright 53 | rule return bright 54 | rule for bright 55 | rule do bright 56 | rule goto bright 57 | rule sizeof bright 58 | 59 | rule -> symbol 60 | rule ! brightsymbol 61 | rule < brightsymbol 62 | rule > brightsymbol 63 | rule = brightsymbol 64 | rule + brightsymbol 65 | rule - brightsymbol 66 | rule * brightsymbol 67 | rule / brightsymbol 68 | rule [ symbol 69 | rule ] symbol 70 | rule { symbol 71 | rule } symbol 72 | rule ( symbol 73 | rule ) symbol 74 | rule : symbol 75 | rule , symbol 76 | rule | symbol 77 | rule & symbol 78 | rule ; brightsymbol 79 | rule TODO veryspecial 80 | rule XXX veryspecial 81 | rule FIXME veryspecial 82 | context /* */ dim 83 | rule TODO veryspecial 84 | rule XXX veryspecial 85 | rule FIXME veryspecial 86 | 87 | context #cgo `$ brightalt special special 88 | /context 89 | context #include `$ brightalt 90 | context " " special 91 | /context 92 | context < > special 93 | /context 94 | /context 95 | /context 96 | context //export `$ brightdiff brightdiff alt 97 | rule TODO veryspecial 98 | rule XXX veryspecial 99 | rule FIXME veryspecial 100 | /context 101 | context // `$ dim 102 | rule TODO veryspecial 103 | rule XXX veryspecial 104 | rule FIXME veryspecial 105 | /context 106 | context " " alt 107 | eager_rule \\ brightalt 108 | eager_rule \" brightalt 109 | eager_rule \`[abcfnrtv`] brightalt 110 | eager_rule \`[0`-3`]`[0`-7`]`[0`-7`] brightalt 111 | /context 112 | context ' ' brightalt 113 | eager_rule \\ brightalt 114 | eager_rule \' brightalt 115 | /context 116 | context `` `` special 117 | /context 118 | 119 | rule make brightdiff 120 | rule delete brightdiff 121 | 122 | include gitconflict.dithlinc 123 | -------------------------------------------------------------------------------- /highlight/haskell.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .hs 3 | RULES 4 | script haskell.lua 5 | 6 | include gitconflict.dithlinc 7 | include haskell.dithlinc 8 | 9 | -------------------------------------------------------------------------------- /highlight/html.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .html 3 | name suffix .htm 4 | RULES 5 | 6 | include gitconflict.dithlinc 7 | include html.dithlinc 8 | 9 | -------------------------------------------------------------------------------- /highlight/java.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .java 3 | RULES 4 | script java.lua 5 | 6 | include gitconflict.dithlinc 7 | 8 | rule char bright 9 | rule void bright 10 | rule if bright 11 | rule else bright 12 | rule default bright 13 | rule while bright 14 | rule switch bright 15 | rule case bright 16 | rule break bright 17 | rule boolean bright 18 | rule continue bright 19 | rule return bright 20 | rule inline bright 21 | rule final bright 22 | rule for bright 23 | rule do bright 24 | rule double bright 25 | rule float bright 26 | rule int bright 27 | rule long bright 28 | rule short bright 29 | rule static bright 30 | rule synchronized bright 31 | rule class bright 32 | rule package bright 33 | rule private bright 34 | rule protected bright 35 | rule public bright 36 | rule native bright 37 | rule finally bright 38 | rule interface bright 39 | rule import bright 40 | rule instanceof bright 41 | rule true bright 42 | rule false bright 43 | rule abstract bright 44 | 45 | rule ! brightsymbol 46 | rule < brightsymbol 47 | rule > brightsymbol 48 | rule = brightsymbol 49 | rule + brightsymbol 50 | rule - brightsymbol 51 | rule * brightsymbol 52 | rule / brightsymbol 53 | rule % brightsymbol 54 | rule [ symbol 55 | rule ] symbol 56 | rule { symbol 57 | rule } symbol 58 | rule ( symbol 59 | rule ) symbol 60 | rule : symbol 61 | rule , symbol 62 | rule ; brightdiff 63 | 64 | rule try brightdiff 65 | rule catch brightdiff 66 | rule throw brightdiff 67 | rule throws brightdiff 68 | context throw ; brightdiff diff diff 69 | /context 70 | context catch } brightdiff diff diff 71 | context { } diff 72 | handover_rule } diff 73 | context { } diff 74 | context { } diff 75 | context { } diff 76 | context { } diff 77 | context { } diff 78 | context { } diff 79 | context { } diff 80 | context { } diff 81 | context { } diff 82 | /context 83 | /context 84 | /context 85 | /context 86 | /context 87 | /context 88 | /context 89 | /context 90 | /context 91 | /context 92 | /context 93 | 94 | rule /** dim 95 | rule /* dim 96 | context /** */ dim 97 | rule @author brightspecial 98 | rule @version brightspecial 99 | rule @since brightspecial 100 | rule @see brightspecial 101 | rule @param`[`s`t`]`[a`-zA`-Z0`-9_`]`* brightspecial 102 | rule @param brightspecial 103 | rule @return brightspecial 104 | rule @exception brightspecial 105 | rule @throws brightspecial 106 | rule @deprecated veryspecial 107 | rule @inheritDoc brightspecial 108 | rule @link brightspecial 109 | rule @value brightspecial 110 | rule TODO veryspecial 111 | rule XXX veryspecial 112 | rule FIXME veryspecial 113 | rule */ dim 114 | /context 115 | 116 | context /* */ dim 117 | rule TODO veryspecial 118 | rule XXX veryspecial 119 | rule FIXME veryspecial 120 | rule */ dim 121 | /context 122 | rule // dim 123 | context // `$ dim 124 | rule TODO veryspecial 125 | rule XXX veryspecial 126 | rule FIXME veryspecial 127 | /context 128 | 129 | rule @`[A`-Z`|a`-z`]`* brightdiff 130 | 131 | rule " alt 132 | context " " alt 133 | rule \\ brightalt 134 | rule \" brightalt 135 | eager_rule \`[abcfnrtv`] brightalt 136 | rule \`[0`-3`]`[0`-7`]`[0`-7`] brightalt 137 | rule " alt 138 | /context 139 | rule ' brightalt 140 | context ' ' brightalt 141 | rule \\ brightalt 142 | rule \' brightalt 143 | rule ' brightalt 144 | /context 145 | -------------------------------------------------------------------------------- /highlight/javascript.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .js 3 | RULES 4 | 5 | include gitconflict.dithlinc 6 | include javascript.dithlinc 7 | 8 | -------------------------------------------------------------------------------- /highlight/javascript.dithlinc: -------------------------------------------------------------------------------- 1 | rule var diff 2 | rule let diff 3 | rule const diff 4 | rule function brightspecial 5 | rule => brightspecial 6 | rule if bright 7 | rule else bright 8 | rule default bright 9 | rule while bright 10 | rule switch bright 11 | rule case bright 12 | rule break bright 13 | rule continue bright 14 | rule return bright 15 | rule for bright 16 | rule do bright 17 | rule null bright 18 | rule in bright 19 | rule of bright 20 | rule ! brightsymbol 21 | rule < brightsymbol 22 | rule > brightsymbol 23 | rule = brightsymbol 24 | rule + brightsymbol 25 | rule - brightsymbol 26 | rule * brightsymbol 27 | rule / brightsymbol 28 | rule [ symbol 29 | rule ] symbol 30 | rule { symbol 31 | rule } symbol 32 | rule ( symbol 33 | rule ) symbol 34 | rule : symbol 35 | rule , symbol 36 | rule | symbol 37 | rule & symbol 38 | rule ; brightsymbol 39 | context " " alt 40 | rule $`[A`-Z_a`-z`]`[A`-Z_a`-z0`-9`]`* brightalt 41 | rule \\ brightalt 42 | rule \" brightalt 43 | /context 44 | context ' ' alt 45 | rule \\ brightalt 46 | rule \' brightalt 47 | /context 48 | context /^ / alt 49 | rule \/ alt 50 | /context 51 | 52 | context /* */ dim 53 | /context 54 | context // `$ dim 55 | /context 56 | -------------------------------------------------------------------------------- /highlight/json.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .json 3 | RULES 4 | 5 | script json.lua 6 | 7 | rule "`[!#`-~`]`+": brightalt 8 | 9 | context " " diff 10 | /context 11 | 12 | 13 | rule [ bright 14 | rule ] bright 15 | rule { bright 16 | rule } bright 17 | rule , symbol 18 | 19 | -------------------------------------------------------------------------------- /highlight/latex.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .tex 3 | name suffix .cls 4 | name suffix .sty 5 | RULES 6 | script latex.lua 7 | 8 | include gitconflict.dithlinc 9 | include latex.dithlinc 10 | -------------------------------------------------------------------------------- /highlight/latex.dithlinc: -------------------------------------------------------------------------------- 1 | 2 | context % `$ dim 3 | /context 4 | 5 | rule \`[A`-Z`|a`-z`|_`]`[a`-z`|A`-Z`|0`-9`|_@*`]`* brightalt 6 | 7 | rule { brightdiff 8 | rule } brightdiff 9 | 10 | context \begin{comment} \end{comment} dim 11 | /context 12 | 13 | context \begin{lstlisting} \end{lstlisting} brightalt brightalt alt 14 | /context 15 | 16 | -------------------------------------------------------------------------------- /highlight/ldoc.dithlinc: -------------------------------------------------------------------------------- 1 | 2 | context @param `[`^`s`]`+ alt brightalt dim 3 | /context 4 | context @tparam`[`^`s`]`*`s`+ `s`+`[`^`s`]`+ alt brightalt diff 5 | /context 6 | context @treturn `[`^`s`]`+ alt diff dim 7 | /context 8 | context @type `[`^`s`]`+ alt brightalt dim 9 | /context 10 | context @module `[`^`s`]`+ alt brightalt dim 11 | /context 12 | rule @author alt 13 | rule @copyright alt 14 | rule @license alt 15 | rule @return alt 16 | rule @see alt 17 | rule @release alt 18 | rule TODO veryspecial 19 | rule FIXME veryspecial 20 | 21 | -------------------------------------------------------------------------------- /highlight/lex.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .l 3 | RULES 4 | 5 | script c.lua 6 | 7 | rule %{ veryspecial 8 | rule %} veryspecial 9 | 10 | include gitconflict.dithlinc 11 | include c.dithlinc 12 | 13 | context %% %% veryspecial veryspecial normal 14 | context " " alt 15 | eager_rule \n brightalt 16 | /context 17 | 18 | context // `$ dim 19 | /context 20 | 21 | context /* */ dim 22 | /context 23 | 24 | eager_rule ( brightdiff 25 | eager_rule | brightdiff 26 | eager_rule ) brightdiff 27 | eager_rule . brightdiff 28 | eager_rule * brightdiff 29 | eager_rule + brightdiff 30 | eager_rule ? brightdiff 31 | 32 | eager_rule \\ bright 33 | eager_rule \" bright 34 | eager_rule \* bright 35 | eager_rule \( bright 36 | eager_rule \) bright 37 | eager_rule \. bright 38 | eager_rule \* bright 39 | eager_rule \+ bright 40 | eager_rule \? bright 41 | eager_rule \[ bright 42 | eager_rule \] bright 43 | 44 | context [^ ] brightspecial brightspecial special 45 | eager_rule \] brightspecial 46 | /context 47 | 48 | context [ ] brightdiff brightdiff diff 49 | eager_rule \] brightdiff 50 | /context 51 | 52 | context { } symbol symbol normal 53 | include c.dithlinc 54 | /context 55 | /context 56 | 57 | -------------------------------------------------------------------------------- /highlight/lhs.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .lhs 3 | RULES 4 | script haskell.lua 5 | 6 | include gitconflict.dithlinc 7 | include latex.dithlinc 8 | 9 | context \begin{code} \end{code} veryspecial veryspecial alt 10 | include haskell.dithlinc 11 | /context 12 | 13 | context \begin{spec} \end{spec} veryspecial veryspecial dim 14 | include haskell.dithlinc 15 | /context 16 | -------------------------------------------------------------------------------- /highlight/lp.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .lp 3 | RULES 4 | 5 | context veryspecial veryspecial normal 6 | include lua.dithlinc 7 | /context 8 | 9 | context <%= %> veryspecial veryspecial normal 10 | include lua.dithlinc 11 | /context 12 | 13 | include html.dithlinc 14 | 15 | -------------------------------------------------------------------------------- /highlight/lpeg_re.dithlinc: -------------------------------------------------------------------------------- 1 | rule <- symbol 2 | rule ( symbol 3 | rule ) symbol 4 | rule * symbol 5 | rule ? symbol 6 | rule / symbol 7 | rule . symbol 8 | rule & symbol 9 | rule ! symbol 10 | rule + symbol 11 | 12 | rule ^ symbol 13 | rule ^+ symbol 14 | rule ^- symbol 15 | 16 | rule :} specialdiff 17 | rule =>`s`*`[a`-z`|A`-Z`|_`]`[a`-z`|A`-Z`|0`-9`|_`]`* special 18 | rule ->`s`*`[a`-z`|A`-Z`|_`]`[a`-z`|A`-Z`|0`-9`|_`]`* special 19 | rule ->`s`*'`[a`-z`|A`-Z`|_`]`[a`-z`|A`-Z`|0`-9`|_`]`*' special 20 | rule ->`s`*"`[a`-z`|A`-Z`|_`]`[a`-z`|A`-Z`|0`-9`|_`]`*" special 21 | 22 | rule =`[a`-z`|A`-Z`|_`]`[a`-z`|A`-Z`|0`-9`|_`]`* brightalt 23 | 24 | rule `[a`-z`|A`-Z`|_`]`[a`-z`|A`-Z`|0`-9`|_`]`* alt 25 | 26 | rule `[a`-z`|A`-Z`|_`]`[a`-z`|A`-Z`|0`-9`|_`]`*`s`*<- bright 27 | 28 | #rule `[0`-9`]`+ normal 29 | 30 | rule |} special 31 | rule {| special 32 | 33 | rule { special 34 | rule } special 35 | 36 | context [ ] symbol symbol diff 37 | rule ^ symbol 38 | rule - symbol 39 | /context 40 | 41 | context {: : specialdiff 42 | /context 43 | 44 | context -- `$ dim 45 | /context 46 | 47 | context ' ' diff 48 | /context 49 | 50 | context " " diff 51 | /context 52 | -------------------------------------------------------------------------------- /highlight/ltp.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .ltp 3 | RULES 4 | 5 | include html.dithlinc 6 | 7 | context # `$ veryspecial veryspecial normal 8 | include lua.dithlinc 9 | /context 10 | 11 | context $( ) brightspecial brightspecial special 12 | /context 13 | 14 | -------------------------------------------------------------------------------- /highlight/lua.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .lua 3 | name suffix .rockspec 4 | firstline suffix lua 5 | firstline regex ^#!.*lua.* 6 | firstline regex ^#!.*resty.* 7 | RULES 8 | script lua.lua 9 | 10 | include gitconflict.dithlinc 11 | 12 | include lua.dithlinc 13 | -------------------------------------------------------------------------------- /highlight/lua.dithlinc: -------------------------------------------------------------------------------- 1 | rule and bright 2 | rule break bright 3 | rule do bright 4 | rule else bright 5 | rule elseif bright 6 | rule end bright 7 | rule false bright 8 | rule for bright 9 | rule function bright 10 | rule if bright 11 | rule in bright 12 | rule local bright 13 | rule nil bright 14 | rule not bright 15 | rule or bright 16 | rule repeat bright 17 | rule return bright 18 | rule then bright 19 | rule true bright 20 | rule until bright 21 | rule while bright 22 | rule ... bright 23 | 24 | rule [ symbol 25 | rule ] symbol 26 | rule { symbol 27 | rule } symbol 28 | rule ( symbol 29 | rule ) symbol 30 | rule : symbol 31 | rule , symbol 32 | 33 | rule # brightsymbol 34 | rule .. brightsymbol 35 | rule ^ brightsymbol 36 | rule < brightsymbol 37 | rule > brightsymbol 38 | rule = brightsymbol 39 | rule + brightsymbol 40 | rule - brightsymbol 41 | rule * brightsymbol 42 | rule / brightsymbol 43 | rule %% brightsymbol 44 | rule ~= brightsymbol 45 | 46 | rule ; brightalt 47 | 48 | rule --[[ dim 49 | rule -- dim 50 | rule \" alt 51 | rule ' alt 52 | rule [[ alt 53 | 54 | context function ) bright bright brightdiff 55 | context ( ) bright bright normal 56 | handover_rule ) bright 57 | rule , bright 58 | context : `[,)`] brightspecialdiff bright brightspecialdiff 59 | handover_rule ) bright 60 | context { } brightspecialdiff 61 | context { } brightspecialdiff 62 | context { } brightspecialdiff 63 | /context 64 | /context 65 | /context 66 | context ( ) brightspecialdiff 67 | context ( ) brightspecialdiff 68 | context ( ) brightspecialdiff 69 | /context 70 | /context 71 | /context 72 | /context 73 | /context 74 | /context 75 | 76 | context --[[ ]] dim 77 | include ldoc.dithlinc 78 | /context 79 | 80 | context --[=[ ]=] dim 81 | include ldoc.dithlinc 82 | /context 83 | 84 | context --[==[ ]==] dim 85 | include ldoc.dithlinc 86 | /context 87 | 88 | context --[===[ ]===] dim 89 | include ldoc.dithlinc 90 | /context 91 | 92 | context --[====[ ]====] dim 93 | include ldoc.dithlinc 94 | /context 95 | 96 | context --[=====[ ]=====] dim 97 | include ldoc.dithlinc 98 | /context 99 | 100 | context -- `$ dim 101 | include ldoc.dithlinc 102 | /context 103 | 104 | 105 | context [[--lpeg.re ]] special special alt 106 | include lpeg_re.dithlinc 107 | /context 108 | 109 | context re.compile([[ ]] special special alt 110 | include lpeg_re.dithlinc 111 | /context 112 | 113 | context re.compile[[ ]] special special alt 114 | include lpeg_re.dithlinc 115 | /context 116 | 117 | context re.compile`s[[ ]] special special alt 118 | include lpeg_re.dithlinc 119 | /context 120 | 121 | context " " alt 122 | rule \\ brightalt 123 | rule \" brightalt 124 | eager_rule \`[abcfnrtv`] brightalt 125 | rule " alt 126 | /context 127 | 128 | context ' ' alt 129 | rule \\ brightalt 130 | rule \' brightalt 131 | eager_rule \`[abcfnrtv`] brightalt 132 | rule ' alt 133 | /context 134 | 135 | context [[ ]] alt 136 | rule \\ brightalt 137 | eager_rule \`[abcfnrtv`] brightalt 138 | rule ]] alt 139 | /context 140 | 141 | context [=[ ]=] alt 142 | rule \\ brightalt 143 | eager_rule \`[abcfnrtv`] brightalt 144 | rule ]=] alt 145 | /context 146 | 147 | context [==[ ]==] alt 148 | rule \\ brightalt 149 | eager_rule \`[abcfnrtv`] brightalt 150 | rule ]==] alt 151 | /context 152 | 153 | context [===[ ]===] alt 154 | rule \\ brightalt 155 | eager_rule \`[abcfnrtv`] brightalt 156 | rule ]===] alt 157 | /context 158 | 159 | context [====[ ]====] alt 160 | rule \\ brightalt 161 | eager_rule \`[abcfnrtv`] brightalt 162 | rule ]====] alt 163 | /context 164 | 165 | context [=====[ ]=====] alt 166 | rule \\ brightalt 167 | eager_rule \`[abcfnrtv`] brightalt 168 | rule ]=====] alt 169 | /context 170 | 171 | -------------------------------------------------------------------------------- /highlight/make.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name prefix Makefile 3 | name prefix makefile 4 | name prefix GNUmakefile 5 | RULES 6 | 7 | include gitconflict.dithlinc 8 | 9 | context # `$ dim 10 | /context 11 | 12 | context `^`[A`-Za`-z_-.0`-9/%()$`]`+: `$ brightdiff normal normal 13 | rule $(`[A`-Za`-z_0`-9`]`+) brightalt 14 | rule $@ brightdiff 15 | rule $^ brightspecial 16 | rule $< brightspecial 17 | /context 18 | 19 | context `[+?`]`?= `$ brightdiff normal alt 20 | rule $(`[A`-Za`-z_0`-9`]`+) brightalt 21 | rule ${`[A`-Za`-z_0`-9`]`+} special 22 | rule $@ brightdiff 23 | rule $^ brightspecial 24 | rule $< brightspecial 25 | /context 26 | 27 | context `t `$ veryspecial normal normal 28 | context # `$ dim 29 | /context 30 | rule \ bright 31 | rule $(`[A`-Za`-z_0`-9`]`+) brightalt 32 | rule ${`[A`-Za`-z_0`-9`]`+} special 33 | context `` `` brightspecial brightspecial special 34 | include shellbacktick.dithlinc 35 | rule ${`[A`-Za`-z_0`-9`]`+} veryspecial 36 | /context 37 | context " " diff 38 | rule $(`[A`-Za`-z_0`-9`]`+) brightdiff 39 | /context 40 | context ' ' diff 41 | rule $(`[A`-Za`-z_0`-9`]`+) brightdiff 42 | /context 43 | /context 44 | 45 | rule include bright 46 | rule @ bright -------------------------------------------------------------------------------- /highlight/markdown.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .md 3 | RULES 4 | 5 | include markdown.dithlinc 6 | 7 | -------------------------------------------------------------------------------- /highlight/markdown.dithlinc: -------------------------------------------------------------------------------- 1 | 2 | rule * brightalt 3 | 4 | rule `^=`* brightdiff 5 | rule `^-`* diff 6 | 7 | #rule `^#`s`[`s`-~`]`* brightdiff 8 | #rule `^##`+`s`[`s`-~`]`* diff 9 | 10 | context `^## `$ diff 11 | /context 12 | 13 | context `^# `$ brightdiff 14 | /context 15 | 16 | context [ ] diff diff bright 17 | /context 18 | 19 | context `^`````` `^`````` dim 20 | /context 21 | 22 | context `` `` bright 23 | /context 24 | 25 | context `^> `^`$ brightdiff brightdiff alt 26 | context `` `` bright 27 | /context 28 | rule *`[`^`s*`]`+* bright 29 | context ** ** brightspecialdiff brightspecialdiff brightspecial 30 | /context 31 | /context 32 | 33 | #context `^`$ `^`$ normal 34 | # context `^`s`s`s`s `$ dim 35 | # /context 36 | #/context 37 | 38 | context `^`t `$ dim 39 | /context 40 | 41 | context ** ** brightspecialdiff brightspecialdiff brightspecial 42 | /context 43 | 44 | rule *`[`^`s*`]`+* bright 45 | 46 | -------------------------------------------------------------------------------- /highlight/moonscript.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .moon 3 | 4 | RULES 5 | 6 | rule and bright 7 | rule break bright 8 | rule do bright 9 | rule else bright 10 | rule elseif bright 11 | rule end bright 12 | rule false bright 13 | rule for bright 14 | rule function bright 15 | rule if bright 16 | rule in bright 17 | rule local bright 18 | rule nil bright 19 | rule not bright 20 | rule or bright 21 | rule repeat bright 22 | rule return bright 23 | rule then bright 24 | rule true bright 25 | rule until bright 26 | rule while bright 27 | rule ... bright 28 | 29 | rule import bright 30 | rule from bright 31 | rule unless bright 32 | 33 | rule = symbol 34 | rule -> brightdiff 35 | 36 | rule => brightspecial 37 | rule @ brightspecial 38 | rule \ brightspecial 39 | 40 | context " " alt 41 | rule \\ brightalt 42 | rule \" brightalt 43 | eager_rule \`[abcfnrtv`] brightalt 44 | rule " alt 45 | /context 46 | 47 | context ' ' alt 48 | rule \\ brightalt 49 | rule \' brightalt 50 | eager_rule \`[abcfnrtv`] brightalt 51 | rule ' alt 52 | /context 53 | 54 | context -- `$ dim 55 | include ldoc.dithlinc 56 | /context 57 | 58 | rule [ symbol 59 | rule ] symbol 60 | rule { symbol 61 | rule } symbol 62 | rule ( symbol 63 | rule ) symbol 64 | rule : symbol 65 | rule , symbol 66 | 67 | rule # brightsymbol 68 | rule .. brightsymbol 69 | rule ^ brightsymbol 70 | rule < brightsymbol 71 | rule > brightsymbol 72 | rule = brightsymbol 73 | rule + brightsymbol 74 | rule - brightsymbol 75 | rule * brightsymbol 76 | rule / brightsymbol 77 | rule %% brightsymbol 78 | rule ~= brightsymbol 79 | 80 | rule ; brightalt 81 | -------------------------------------------------------------------------------- /highlight/nestedm4.dithlinc: -------------------------------------------------------------------------------- 1 | context [ ] brightdiff brightdiff diff 2 | context [ ] brightdiff brightdiff diff 3 | /context 4 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 5 | /context 6 | /context 7 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 8 | context [ ] brightdiff brightdiff diff 9 | /context 10 | context `[A`-Z`]`[A`-Z0`-9_`]`+( ) brightspecial brightspecial normal 11 | /context 12 | /context 13 | -------------------------------------------------------------------------------- /highlight/php.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .php 3 | name suffix .inc 4 | RULES 5 | 6 | context veryspecial veryspecial normal 7 | rule continue bright 8 | rule if bright 9 | rule else bright 10 | rule for bright 11 | rule foreach bright 12 | rule as bright 13 | rule include bright 14 | rule function bright 15 | rule global bright 16 | rule echo bright 17 | rule isset bright 18 | rule switch bright 19 | rule case bright 20 | rule = bright 21 | rule { bright 22 | rule } bright 23 | rule ( bright 24 | rule ) bright 25 | rule [ bright 26 | rule ] bright 27 | rule -> bright 28 | rule $`[A`-Z_a`-z`]`[A`-Z_a`-z0`-9`]`* brightdiff 29 | context " " alt 30 | rule $`[A`-Z_a`-z`]`[A`-Z_a`-z0`-9`]`* brightalt 31 | rule \\ brightalt 32 | rule \" brightalt 33 | /context 34 | context ' ' alt 35 | rule \\ brightalt 36 | rule \' brightalt 37 | /context 38 | context /* */ dim 39 | /context 40 | context // `$ dim 41 | /context 42 | context # `$ dim 43 | /context 44 | /context 45 | 46 | include html.dithlinc 47 | 48 | -------------------------------------------------------------------------------- /highlight/ruby.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .rb 3 | firstline regex ^#!.*ruby.* 4 | RULES 5 | 6 | include gitconflict.dithlinc 7 | 8 | context # `$ dim 9 | /context 10 | 11 | rule [ symbol 12 | rule ] symbol 13 | rule { brightdiff 14 | rule | brightdiff 15 | rule } brightdiff 16 | rule ( symbol 17 | rule ) symbol 18 | 19 | rule ** symbol 20 | rule ! symbol 21 | rule ~ symbol 22 | rule + symbol 23 | rule - symbol 24 | rule * symbol 25 | rule / symbol 26 | rule % symbol 27 | rule + symbol 28 | rule - symbol 29 | rule >> symbol 30 | rule << symbol 31 | rule & symbol 32 | rule ^ symbol 33 | rule | symbol 34 | rule <=> symbol 35 | rule == symbol 36 | rule === symbol 37 | rule != symbol 38 | rule =~ symbol 39 | rule !~ symbol 40 | rule <= symbol 41 | rule < symbol 42 | rule > symbol 43 | rule >= symbol 44 | rule && symbol 45 | rule || symbol 46 | rule .. symbol 47 | rule ... symbol 48 | rule ? symbol 49 | rule : symbol 50 | rule :: brightalt 51 | rule = symbol 52 | rule %= symbol 53 | rule /= symbol 54 | rule -= symbol 55 | rule += symbol 56 | rule |= symbol 57 | rule &= symbol 58 | rule >>= symbol 59 | rule <<= symbol 60 | rule *= symbol 61 | rule &&= symbol 62 | rule ||= symbol 63 | rule **= symbol 64 | 65 | rule and bright 66 | rule break bright 67 | rule in bright 68 | rule next bright 69 | rule not bright 70 | rule or bright 71 | rule redo bright 72 | rule rescue bright 73 | rule retry bright 74 | rule return bright 75 | rule defined? bright 76 | rule super bright 77 | rule yield bright 78 | rule true bright 79 | rule false bright 80 | rule nil brightalt 81 | rule self brightalt 82 | rule __ENCODING__ brightalt 83 | rule __dir__ brightalt 84 | rule __FILE__ brightalt 85 | rule __callee__ brightalt 86 | rule __method__ brightalt 87 | rule BEGIN bright 88 | rule END bright 89 | rule case bright 90 | rule begin bright 91 | rule do bright 92 | rule for bright 93 | rule if bright 94 | rule unless bright 95 | rule while bright 96 | rule until bright 97 | rule else bright 98 | rule elsif bright 99 | rule ensure bright 100 | rule then bright 101 | rule when bright 102 | rule end bright 103 | rule alias bright 104 | rule undef bright 105 | 106 | rule :`[_`|A`-Z`|a`-z`]`[A`-Z`|a`-z`|0`-9`|_`]`* brightalt 107 | rule @@`[_`|A`-Z`|a`-z`]`[A`-Z`|a`-z`|0`-9`|_`]`* brightdiff 108 | rule @`[_`|A`-Z`|a`-z`]`[A`-Z`|a`-z`|0`-9`|_`]`* diff 109 | rule $`[_`|A`-Z`|a`-z`]`[A`-Z`|a`-z`|0`-9`|_`]`* brightdiff 110 | 111 | context def `$ bright bright brightdiff 112 | context ( ) bright bright normal 113 | rule = bright 114 | rule , bright 115 | /context 116 | /context 117 | 118 | context class `$ bright bright brightdiff 119 | /context 120 | 121 | context module `$ bright bright brightdiff 122 | /context 123 | 124 | # Homebrew patches 125 | context __END__ bright bright normal 126 | include diff.dithlinc 127 | /context 128 | 129 | context " " alt 130 | rule \\ brightalt 131 | rule \" brightalt 132 | eager_rule \`[abcfnrtv`] brightalt 133 | rule " alt 134 | /context 135 | 136 | context %w[ ] alt 137 | /context 138 | 139 | context ' ' alt 140 | rule \\ brightalt 141 | rule \' brightalt 142 | eager_rule \`[abcfnrtv`] brightalt 143 | rule ' alt 144 | /context 145 | 146 | 147 | context =begin =end dim 148 | /context 149 | 150 | -------------------------------------------------------------------------------- /highlight/rust.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .rs 3 | RULES 4 | 5 | script rust.lua 6 | 7 | include gitconflict.dithlinc 8 | 9 | rule as diff 10 | rule break diff 11 | rule const diff 12 | rule continue diff 13 | rule crate diff 14 | rule else diff 15 | rule enum diff 16 | rule extern diff 17 | rule false diff 18 | rule fn diff 19 | rule for diff 20 | rule if diff 21 | rule impl diff 22 | rule in diff 23 | rule let diff 24 | rule loop diff 25 | rule match diff 26 | rule mod diff 27 | rule move diff 28 | rule mut diff 29 | rule pub diff 30 | rule ref diff 31 | rule return diff 32 | rule self diff 33 | rule Self diff 34 | rule static diff 35 | rule struct diff 36 | rule super diff 37 | rule trait diff 38 | rule true diff 39 | rule type diff 40 | rule unsafe diff 41 | rule use diff 42 | rule where diff 43 | rule while diff 44 | rule async diff 45 | rule await diff 46 | rule dyn diff 47 | 48 | rule abstract diff 49 | rule become diff 50 | rule box diff 51 | rule do diff 52 | rule final diff 53 | rule macro diff 54 | rule override diff 55 | rule priv diff 56 | rule typeof diff 57 | rule unsized diff 58 | rule virtual diff 59 | rule yield diff 60 | rule try diff 61 | rule union diff 62 | rule 'static diff 63 | 64 | rule self brightalt 65 | 66 | rule ! brightsymbol 67 | rule < brightsymbol 68 | rule > brightsymbol 69 | rule = brightsymbol 70 | rule + brightsymbol 71 | rule - brightsymbol 72 | rule * brightsymbol 73 | rule / brightsymbol 74 | rule [ symbol 75 | rule ] symbol 76 | rule { symbol 77 | rule } symbol 78 | rule ( symbol 79 | rule ) symbol 80 | rule : symbol 81 | rule , symbol 82 | rule | symbol 83 | rule & symbol 84 | rule ; brightsymbol 85 | rule TODO veryspecial 86 | rule XXX veryspecial 87 | rule FIXME veryspecial 88 | 89 | context <' > special 90 | rule 'static diff 91 | 92 | context < > special 93 | rule 'static diff 94 | 95 | context < > special 96 | rule 'static diff 97 | /context 98 | /context 99 | /context 100 | 101 | context <`[A`-Za`-z&(`]`+ > special 102 | rule 'static diff 103 | 104 | context < > special 105 | rule 'static diff 106 | 107 | context < > special 108 | rule 'static diff 109 | /context 110 | /context 111 | /context 112 | 113 | context ::< > special 114 | rule 'static diff 115 | 116 | context < > special 117 | rule 'static diff 118 | 119 | context < > special 120 | rule 'static diff 121 | /context 122 | /context 123 | /context 124 | 125 | context /* */ dim 126 | rule TODO veryspecial 127 | rule XXX veryspecial 128 | rule FIXME veryspecial 129 | /context 130 | context // `$ dim 131 | rule TODO veryspecial 132 | rule XXX veryspecial 133 | rule FIXME veryspecial 134 | /context 135 | context " " alt 136 | eager_rule \\ brightalt 137 | eager_rule \" brightalt 138 | eager_rule \`[abcfnrtv`] brightalt 139 | eager_rule \`[0`-3`]`[0`-7`]`[0`-7`] brightalt 140 | /context 141 | context r#" "# alt 142 | /context 143 | 144 | rule '`[`s`-~`]' brightalt 145 | rule '\`[`s`-~`]' brightalt 146 | 147 | context # `$ brightspecial 148 | ### rule \`$ veryspecial ### need to handle these special breaks later 149 | /context 150 | -------------------------------------------------------------------------------- /highlight/shell.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .sh 3 | name prefix Recipe 4 | firstline regex ^#!.*[a-z]*sh($|[[:blank:]].*) 5 | RULES 6 | script shell.lua 7 | include shell.dithlinc 8 | -------------------------------------------------------------------------------- /highlight/shellbacktick.dithlinc: -------------------------------------------------------------------------------- 1 | rule $`[A`-Z`|a`-z`|_`]`[a`-z`|A`-Z`|0`-9`|_`]`* brightspecial 2 | rule ${`[a`-z`|A`-Z`|0`-9`|_[]%!@#-$*?_`s`]`+} brightspecial 3 | rule ${`[!@#$*?_`]} brightspecial 4 | rule $`[!@#$*?_`] brightspecial 5 | rule \' special 6 | rule \" special 7 | context " " specialdiff 8 | rule $`[A`-Z`|a`-z`|_`]`[a`-z`|A`-Z`|0`-9`|_`]`* brightspecialdiff 9 | rule ${`[a`-z`|A`-Z`|0`-9`|_[]%!@#-$*?_`s`]`+} brightspecialdiff 10 | rule ${`[!@#$*?_`]} brightspecialdiff 11 | rule $`[!@#$*?_`] brightspecialdiff 12 | rule \" special 13 | /context 14 | context ' ' specialdiff 15 | /context 16 | -------------------------------------------------------------------------------- /highlight/teal.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .tl 3 | firstline regex ^#!.*tl.run.* 4 | RULES 5 | script teal.lua 6 | 7 | include gitconflict.dithlinc 8 | 9 | include lua.dithlinc 10 | 11 | rule local`s`+type bright 12 | rule global`s`+type bright 13 | 14 | context function ) bright bright brightdiff 15 | context ( ) bright bright normal 16 | handover_rule ) bright 17 | rule , bright 18 | context : `[,)`] brightdiff bright diff 19 | handover_rule ) bright 20 | context < > diff diff alt 21 | rule , diff 22 | /context 23 | context ( ) diff 24 | context ( ) diff 25 | context ( ) diff 26 | /context 27 | /context 28 | /context 29 | context { } diff 30 | context { } diff 31 | context { } diff 32 | /context 33 | /context 34 | /context 35 | /context 36 | /context 37 | /context 38 | 39 | context record `$ bright bright brightdiff 40 | /context 41 | 42 | context enum `$ bright bright brightdiff 43 | /context 44 | 45 | rule as bright 46 | rule is bright 47 | rule where bright 48 | -------------------------------------------------------------------------------- /highlight/xml.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | firstline prefix brightalt 11 | context " " diff 12 | /context 13 | context ' ' diff 14 | /context 15 | rule = symbol 16 | /context 17 | 18 | context veryspecial veryspecial dim 19 | context " " brightdiff 20 | /context 21 | context ' ' brightdiff 22 | /context 23 | rule = symbol 24 | /context 25 | 26 | context alt 27 | context " " brightdiff 28 | /context 29 | context ' ' brightdiff 30 | /context 31 | rule = symbol 32 | /context 33 | 34 | context dim dim dim 35 | /context 36 | -------------------------------------------------------------------------------- /highlight/yacc.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .y 3 | RULES 4 | 5 | script c.lua 6 | 7 | include gitconflict.dithlinc 8 | 9 | rule %{ veryspecial 10 | rule %} veryspecial 11 | 12 | context %token `$ brightspecial brightspecial brightalt 13 | /context 14 | 15 | context %left `$ brightspecial brightspecial brightalt 16 | /context 17 | 18 | context %right `$ brightspecial brightspecial brightalt 19 | /context 20 | 21 | include c.dithlinc 22 | 23 | context %% %% veryspecial veryspecial normal 24 | context " " alt 25 | eager_rule \n brightalt 26 | /context 27 | 28 | context // `$ dim 29 | /context 30 | 31 | context /* */ dim 32 | /context 33 | 34 | rule %prec brightspecial 35 | 36 | eager_rule : brightdiff 37 | eager_rule | brightdiff 38 | eager_rule ; brightdiff 39 | 40 | context ' ' brightalt 41 | eager_rule \\ brightalt 42 | eager_rule \' brightalt 43 | /context 44 | 45 | rule `[a`-z_`]`[a`-z_0`-9`]`* alt 46 | rule `[A`-Z_`]`[A`-Z_0`-9`]`* brightalt 47 | 48 | context { } symbol symbol normal 49 | include c.dithlinc 50 | /context 51 | /context 52 | 53 | -------------------------------------------------------------------------------- /highlight/yaml.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .yml 3 | name suffix .yaml 4 | RULES 5 | script shell.lua 6 | 7 | context # `$ dim 8 | /context 9 | 10 | context " " alt 11 | /context 12 | 13 | rule - brightdiff 14 | rule : brightdiff 15 | rule [ bright 16 | rule ] bright 17 | 18 | -------------------------------------------------------------------------------- /highlight/yats.dithl: -------------------------------------------------------------------------------- 1 | FILES 2 | name suffix .yats 3 | RULES 4 | 5 | include gitconflict.dithlinc 6 | include html.dithlinc 7 | 8 | context << >> veryspecial veryspecial special 9 | /context 10 | -------------------------------------------------------------------------------- /lua-5.3.0/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for installing Lua 2 | # See doc/readme.html for installation and customization instructions. 3 | 4 | # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= 5 | 6 | # Your platform. See PLATS for possible values. 7 | PLAT= none 8 | 9 | # Where to install. The installation starts in the src and doc directories, 10 | # so take care if INSTALL_TOP is not an absolute path. See the local target. 11 | # You may want to make INSTALL_LMOD and INSTALL_CMOD consistent with 12 | # LUA_ROOT, LUA_LDIR, and LUA_CDIR in luaconf.h. 13 | INSTALL_TOP= /usr/local 14 | INSTALL_BIN= $(INSTALL_TOP)/bin 15 | INSTALL_INC= $(INSTALL_TOP)/include 16 | INSTALL_LIB= $(INSTALL_TOP)/lib 17 | INSTALL_MAN= $(INSTALL_TOP)/man/man1 18 | INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V 19 | INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V 20 | 21 | # How to install. If your install program does not support "-p", then 22 | # you may have to run ranlib on the installed liblua.a. 23 | INSTALL= install -p 24 | INSTALL_EXEC= $(INSTALL) -m 0755 25 | INSTALL_DATA= $(INSTALL) -m 0644 26 | # 27 | # If you don't have "install" you can use "cp" instead. 28 | # INSTALL= cp -p 29 | # INSTALL_EXEC= $(INSTALL) 30 | # INSTALL_DATA= $(INSTALL) 31 | 32 | # Other utilities. 33 | MKDIR= mkdir -p 34 | RM= rm -f 35 | 36 | # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= 37 | 38 | # Convenience platforms targets. 39 | PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris 40 | 41 | # What to install. 42 | TO_BIN= lua luac 43 | TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp 44 | TO_LIB= liblua.a 45 | TO_MAN= lua.1 luac.1 46 | 47 | # Lua version and release. 48 | V= 5.3 49 | R= $V.0 50 | 51 | # Targets start here. 52 | all: $(PLAT) 53 | 54 | $(PLATS) clean: 55 | cd src && $(MAKE) $@ 56 | 57 | test: dummy 58 | src/lua -v 59 | 60 | install: dummy 61 | cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD) 62 | cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN) 63 | cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC) 64 | cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB) 65 | cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN) 66 | 67 | uninstall: 68 | cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN) 69 | cd src && cd $(INSTALL_INC) && $(RM) $(TO_INC) 70 | cd src && cd $(INSTALL_LIB) && $(RM) $(TO_LIB) 71 | cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN) 72 | 73 | local: 74 | $(MAKE) install INSTALL_TOP=../install 75 | 76 | none: 77 | @echo "Please do 'make PLATFORM' where PLATFORM is one of these:" 78 | @echo " $(PLATS)" 79 | @echo "See doc/readme.html for complete instructions." 80 | 81 | # make may get confused with test/ and install/ 82 | dummy: 83 | 84 | # echo config parameters 85 | echo: 86 | @cd src && $(MAKE) -s echo 87 | @echo "PLAT= $(PLAT)" 88 | @echo "V= $V" 89 | @echo "R= $R" 90 | @echo "TO_BIN= $(TO_BIN)" 91 | @echo "TO_INC= $(TO_INC)" 92 | @echo "TO_LIB= $(TO_LIB)" 93 | @echo "TO_MAN= $(TO_MAN)" 94 | @echo "INSTALL_TOP= $(INSTALL_TOP)" 95 | @echo "INSTALL_BIN= $(INSTALL_BIN)" 96 | @echo "INSTALL_INC= $(INSTALL_INC)" 97 | @echo "INSTALL_LIB= $(INSTALL_LIB)" 98 | @echo "INSTALL_MAN= $(INSTALL_MAN)" 99 | @echo "INSTALL_LMOD= $(INSTALL_LMOD)" 100 | @echo "INSTALL_CMOD= $(INSTALL_CMOD)" 101 | @echo "INSTALL_EXEC= $(INSTALL_EXEC)" 102 | @echo "INSTALL_DATA= $(INSTALL_DATA)" 103 | 104 | # echo pkg-config data 105 | pc: 106 | @echo "version=$R" 107 | @echo "prefix=$(INSTALL_TOP)" 108 | @echo "libdir=$(INSTALL_LIB)" 109 | @echo "includedir=$(INSTALL_INC)" 110 | 111 | # list targets that do not create files (but not all makes understand .PHONY) 112 | .PHONY: all $(PLATS) clean test install local none dummy echo pecho lecho 113 | 114 | # (end of Makefile) 115 | -------------------------------------------------------------------------------- /lua-5.3.0/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.3.0, released on 06 Jan 2015. 3 | 4 | Copyright © 1994–2015 Lua.org, PUC-Rio. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.8 2014/07/15 21:26:50 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check((n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.63 2013/12/30 20:47:58 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW, 28 | OPR_DIV, 29 | OPR_IDIV, 30 | OPR_BAND, OPR_BOR, OPR_BXOR, 31 | OPR_SHL, OPR_SHR, 32 | OPR_CONCAT, 33 | OPR_EQ, OPR_LT, OPR_LE, 34 | OPR_NE, OPR_GT, OPR_GE, 35 | OPR_AND, OPR_OR, 36 | OPR_NOBINOPR 37 | } BinOpr; 38 | 39 | 40 | typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 41 | 42 | 43 | #define getcode(fs,e) ((fs)->f->code[(e)->u.info]) 44 | 45 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 46 | 47 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 48 | 49 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) 50 | 51 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 52 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 53 | LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); 54 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 55 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 56 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 57 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 58 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 59 | LUAI_FUNC int luaK_intK (FuncState *fs, lua_Integer n); 60 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 61 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 62 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); 63 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 64 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 65 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 66 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 67 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 68 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 69 | LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); 70 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 71 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 72 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 73 | LUAI_FUNC int luaK_jump (FuncState *fs); 74 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 75 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 76 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 77 | LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); 78 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 79 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 80 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); 81 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 82 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, 83 | expdesc *v2, int line); 84 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 85 | 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 20 | 0x00, /* EOZ */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | }; 54 | 55 | #endif /* } */ 56 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /lua-5.3.0/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.12 2014/11/10 14:46:05 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | /* Active Lua function (given call info) */ 21 | #define ci_func(ci) (clLvalue((ci)->func)) 22 | 23 | 24 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 25 | const char *opname); 26 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 27 | const TValue *p2); 28 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 29 | const TValue *p2, 30 | const char *msg); 31 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 32 | const TValue *p2); 33 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 34 | const TValue *p2); 35 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 36 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 37 | LUAI_FUNC void luaG_traceexec (lua_State *L); 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /lua-5.3.0/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.21 2014/10/25 11:50:46 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | #define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ 17 | luaD_growstack(L, n); else condmovestack(L); 18 | 19 | 20 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);} 21 | 22 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 23 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 24 | 25 | 26 | /* type of protected functions, to be ran by 'runprotected' */ 27 | typedef void (*Pfunc) (lua_State *L, void *ud); 28 | 29 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 30 | const char *mode); 31 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 32 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 33 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, 34 | int allowyield); 35 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 36 | ptrdiff_t oldtop, ptrdiff_t ef); 37 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); 38 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 39 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 40 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 41 | 42 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 43 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lfunc.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.c,v 2.45 2014/11/02 19:19:04 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lfunc_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "lfunc.h" 18 | #include "lgc.h" 19 | #include "lmem.h" 20 | #include "lobject.h" 21 | #include "lstate.h" 22 | 23 | 24 | 25 | CClosure *luaF_newCclosure (lua_State *L, int n) { 26 | GCObject *o = luaC_newobj(L, LUA_TCCL, sizeCclosure(n)); 27 | CClosure *c = gco2ccl(o); 28 | c->nupvalues = cast_byte(n); 29 | return c; 30 | } 31 | 32 | 33 | LClosure *luaF_newLclosure (lua_State *L, int n) { 34 | GCObject *o = luaC_newobj(L, LUA_TLCL, sizeLclosure(n)); 35 | LClosure *c = gco2lcl(o); 36 | c->p = NULL; 37 | c->nupvalues = cast_byte(n); 38 | while (n--) c->upvals[n] = NULL; 39 | return c; 40 | } 41 | 42 | /* 43 | ** fill a closure with new closed upvalues 44 | */ 45 | void luaF_initupvals (lua_State *L, LClosure *cl) { 46 | int i; 47 | for (i = 0; i < cl->nupvalues; i++) { 48 | UpVal *uv = luaM_new(L, UpVal); 49 | uv->refcount = 1; 50 | uv->v = &uv->u.value; /* make it closed */ 51 | setnilvalue(uv->v); 52 | cl->upvals[i] = uv; 53 | } 54 | } 55 | 56 | 57 | UpVal *luaF_findupval (lua_State *L, StkId level) { 58 | UpVal **pp = &L->openupval; 59 | UpVal *p; 60 | UpVal *uv; 61 | lua_assert(isintwups(L) || L->openupval == NULL); 62 | while (*pp != NULL && (p = *pp)->v >= level) { 63 | lua_assert(upisopen(p)); 64 | if (p->v == level) /* found a corresponding upvalue? */ 65 | return p; /* return it */ 66 | pp = &p->u.open.next; 67 | } 68 | /* not found: create a new upvalue */ 69 | uv = luaM_new(L, UpVal); 70 | uv->refcount = 0; 71 | uv->u.open.next = *pp; /* link it to list of open upvalues */ 72 | uv->u.open.touched = 1; 73 | *pp = uv; 74 | uv->v = level; /* current value lives in the stack */ 75 | if (!isintwups(L)) { /* thread not in list of threads with upvalues? */ 76 | L->twups = G(L)->twups; /* link it to the list */ 77 | G(L)->twups = L; 78 | } 79 | return uv; 80 | } 81 | 82 | 83 | void luaF_close (lua_State *L, StkId level) { 84 | UpVal *uv; 85 | while (L->openupval != NULL && (uv = L->openupval)->v >= level) { 86 | lua_assert(upisopen(uv)); 87 | L->openupval = uv->u.open.next; /* remove from 'open' list */ 88 | if (uv->refcount == 0) /* no references? */ 89 | luaM_free(L, uv); /* free upvalue */ 90 | else { 91 | setobj(L, &uv->u.value, uv->v); /* move value to upvalue slot */ 92 | uv->v = &uv->u.value; /* now current value lives here */ 93 | luaC_upvalbarrier(L, uv); 94 | } 95 | } 96 | } 97 | 98 | 99 | Proto *luaF_newproto (lua_State *L) { 100 | GCObject *o = luaC_newobj(L, LUA_TPROTO, sizeof(Proto)); 101 | Proto *f = gco2p(o); 102 | f->k = NULL; 103 | f->sizek = 0; 104 | f->p = NULL; 105 | f->sizep = 0; 106 | f->code = NULL; 107 | f->cache = NULL; 108 | f->sizecode = 0; 109 | f->lineinfo = NULL; 110 | f->sizelineinfo = 0; 111 | f->upvalues = NULL; 112 | f->sizeupvalues = 0; 113 | f->numparams = 0; 114 | f->is_vararg = 0; 115 | f->maxstacksize = 0; 116 | f->locvars = NULL; 117 | f->sizelocvars = 0; 118 | f->linedefined = 0; 119 | f->lastlinedefined = 0; 120 | f->source = NULL; 121 | return f; 122 | } 123 | 124 | 125 | void luaF_freeproto (lua_State *L, Proto *f) { 126 | luaM_freearray(L, f->code, f->sizecode); 127 | luaM_freearray(L, f->p, f->sizep); 128 | luaM_freearray(L, f->k, f->sizek); 129 | luaM_freearray(L, f->lineinfo, f->sizelineinfo); 130 | luaM_freearray(L, f->locvars, f->sizelocvars); 131 | luaM_freearray(L, f->upvalues, f->sizeupvalues); 132 | luaM_free(L, f); 133 | } 134 | 135 | 136 | /* 137 | ** Look for n-th local variable at line 'line' in function 'func'. 138 | ** Returns NULL if not found. 139 | */ 140 | const char *luaF_getlocalname (const Proto *f, int local_number, int pc) { 141 | int i; 142 | for (i = 0; isizelocvars && f->locvars[i].startpc <= pc; i++) { 143 | if (pc < f->locvars[i].endpc) { /* is variable active? */ 144 | local_number--; 145 | if (local_number == 0) 146 | return getstr(f->locvars[i].varname); 147 | } 148 | } 149 | return NULL; /* not found */ 150 | } 151 | 152 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.14 2014/06/19 18:27:20 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** Upvalues for Lua closures 27 | */ 28 | struct UpVal { 29 | TValue *v; /* points to stack or to its own value */ 30 | lu_mem refcount; /* reference counter */ 31 | union { 32 | struct { /* (when open) */ 33 | UpVal *next; /* linked list */ 34 | int touched; /* mark to avoid cycles with dead threads */ 35 | } open; 36 | TValue value; /* the value (when closed) */ 37 | } u; 38 | }; 39 | 40 | #define upisopen(up) ((up)->v != &(up)->u.value) 41 | 42 | 43 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 44 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 45 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 46 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 47 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 48 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 49 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 50 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 51 | int pc); 52 | 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /lua-5.3.0/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove _PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {"_G", luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | #if defined(LUA_COMPAT_BITLIB) 54 | {LUA_BITLIBNAME, luaopen_bit32}, 55 | #endif 56 | {NULL, NULL} 57 | }; 58 | 59 | 60 | LUALIB_API void luaL_openlibs (lua_State *L) { 61 | const luaL_Reg *lib; 62 | /* "require" functions from 'loadedlibs' and set results to global table */ 63 | for (lib = loadedlibs; lib->func; lib++) { 64 | luaL_requiref(L, lib->name, lib->func, 1); 65 | lua_pop(L, 1); /* remove lib */ 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /lua-5.3.0/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.78 2014/10/29 15:38:24 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | #if !defined(LUA_ENV) 18 | #define LUA_ENV "_ENV" 19 | #endif 20 | 21 | 22 | /* 23 | * WARNING: if you change the order of this enumeration, 24 | * grep "ORDER RESERVED" 25 | */ 26 | enum RESERVED { 27 | /* terminal symbols denoted by reserved words */ 28 | TK_AND = FIRST_RESERVED, TK_BREAK, 29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 32 | /* other terminal symbols */ 33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 34 | TK_SHL, TK_SHR, 35 | TK_DBCOLON, TK_EOS, 36 | TK_FLT, TK_INT, TK_NAME, TK_STRING 37 | }; 38 | 39 | /* number of reserved words */ 40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | lua_Integer i; 46 | TString *ts; 47 | } SemInfo; /* semantics information */ 48 | 49 | 50 | typedef struct Token { 51 | int token; 52 | SemInfo seminfo; 53 | } Token; 54 | 55 | 56 | /* state of the lexer plus state of the parser when shared by all 57 | functions */ 58 | typedef struct LexState { 59 | int current; /* current character (charint) */ 60 | int linenumber; /* input line counter */ 61 | int lastline; /* line of last token 'consumed' */ 62 | Token t; /* current token */ 63 | Token lookahead; /* look ahead token */ 64 | struct FuncState *fs; /* current function (parser) */ 65 | struct lua_State *L; 66 | ZIO *z; /* input stream */ 67 | Mbuffer *buff; /* buffer for tokens */ 68 | Table *h; /* to avoid collection/reuse strings */ 69 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 70 | TString *source; /* current source name */ 71 | TString *envn; /* environment variable name */ 72 | char decpoint; /* locale decimal point */ 73 | } LexState; 74 | 75 | 76 | LUAI_FUNC void luaX_init (lua_State *L); 77 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 78 | TString *source, int firstchar); 79 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 80 | LUAI_FUNC void luaX_next (LexState *ls); 81 | LUAI_FUNC int luaX_lookahead (LexState *ls); 82 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 83 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 84 | 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.89 2014/11/02 19:33:33 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lmem_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "ldebug.h" 18 | #include "ldo.h" 19 | #include "lgc.h" 20 | #include "lmem.h" 21 | #include "lobject.h" 22 | #include "lstate.h" 23 | 24 | 25 | 26 | /* 27 | ** About the realloc function: 28 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 29 | ** ('osize' is the old size, 'nsize' is the new size) 30 | ** 31 | ** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no 32 | ** matter 'x'). 33 | ** 34 | ** * frealloc(ud, p, x, 0) frees the block 'p' 35 | ** (in this specific case, frealloc must return NULL); 36 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 37 | ** (which is equivalent to free(NULL) in ISO C) 38 | ** 39 | ** frealloc returns NULL if it cannot create or reallocate the area 40 | ** (any reallocation to an equal or smaller size cannot fail!) 41 | */ 42 | 43 | 44 | 45 | #define MINSIZEARRAY 4 46 | 47 | 48 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 49 | int limit, const char *what) { 50 | void *newblock; 51 | int newsize; 52 | if (*size >= limit/2) { /* cannot double it? */ 53 | if (*size >= limit) /* cannot grow even a little? */ 54 | luaG_runerror(L, "too many %s (limit is %d)", what, limit); 55 | newsize = limit; /* still have at least one free place */ 56 | } 57 | else { 58 | newsize = (*size)*2; 59 | if (newsize < MINSIZEARRAY) 60 | newsize = MINSIZEARRAY; /* minimum size */ 61 | } 62 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 63 | *size = newsize; /* update only when everything else is OK */ 64 | return newblock; 65 | } 66 | 67 | 68 | l_noret luaM_toobig (lua_State *L) { 69 | luaG_runerror(L, "memory allocation error: block too big"); 70 | } 71 | 72 | 73 | 74 | /* 75 | ** generic allocation routine. 76 | */ 77 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 78 | void *newblock; 79 | global_State *g = G(L); 80 | size_t realosize = (block) ? osize : 0; 81 | lua_assert((realosize == 0) == (block == NULL)); 82 | #if defined(HARDMEMTESTS) 83 | if (nsize > realosize && g->gcrunning) 84 | luaC_fullgc(L, 1); /* force a GC whenever possible */ 85 | #endif 86 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); 87 | if (newblock == NULL && nsize > 0) { 88 | api_check( nsize > realosize, 89 | "realloc cannot fail when shrinking a block"); 90 | luaC_fullgc(L, 1); /* try to free some memory... */ 91 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 92 | if (newblock == NULL) 93 | luaD_throw(L, LUA_ERRMEM); 94 | } 95 | lua_assert((nsize == 0) == (newblock == NULL)); 96 | g->GCdebt = (g->GCdebt + nsize) - realosize; 97 | return newblock; 98 | } 99 | 100 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | /* 18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where 19 | ** each element has size 'e'. In case of arithmetic overflow of the 20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because 21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). 22 | ** 23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 24 | ** comparison avoids a runtime comparison when overflow cannot occur. 25 | ** The compiler should be able to optimize the real test by itself, but 26 | ** when it does it, it may give a warning about "comparison is always 27 | ** false due to limited range of data type"; the +1 tricks the compiler, 28 | ** avoiding this warning but also this optimization.) 29 | */ 30 | #define luaM_reallocv(L,b,on,n,e) \ 31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ 32 | ? luaM_toobig(L) : cast_void(0)) , \ 33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 34 | 35 | /* 36 | ** Arrays of chars do not need any test 37 | */ 38 | #define luaM_reallocvchar(L,b,on,n) \ 39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 40 | 41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 44 | 45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 47 | #define luaM_newvector(L,n,t) \ 48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 49 | 50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 51 | 52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 53 | if ((nelems)+1 > (size)) \ 54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 55 | 56 | #define luaM_reallocvector(L, v,oldn,n,t) \ 57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 58 | 59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 60 | 61 | /* not to be called directly */ 62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 63 | size_t size); 64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 65 | size_t size_elem, int limit, 66 | const char *what); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lopcodes.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lopcodes.c,v 1.55 2015/01/05 13:48:33 roberto Exp $ 3 | ** Opcodes for Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lopcodes_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lopcodes.h" 16 | 17 | 18 | /* ORDER OP */ 19 | 20 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { 21 | "MOVE", 22 | "LOADK", 23 | "LOADKX", 24 | "LOADBOOL", 25 | "LOADNIL", 26 | "GETUPVAL", 27 | "GETTABUP", 28 | "GETTABLE", 29 | "SETTABUP", 30 | "SETUPVAL", 31 | "SETTABLE", 32 | "NEWTABLE", 33 | "SELF", 34 | "ADD", 35 | "SUB", 36 | "MUL", 37 | "MOD", 38 | "POW", 39 | "DIV", 40 | "IDIV", 41 | "BAND", 42 | "BOR", 43 | "BXOR", 44 | "SHL", 45 | "SHR", 46 | "UNM", 47 | "BNOT", 48 | "NOT", 49 | "LEN", 50 | "CONCAT", 51 | "JMP", 52 | "EQ", 53 | "LT", 54 | "LE", 55 | "TEST", 56 | "TESTSET", 57 | "CALL", 58 | "TAILCALL", 59 | "RETURN", 60 | "FORLOOP", 61 | "FORPREP", 62 | "TFORCALL", 63 | "TFORLOOP", 64 | "SETLIST", 65 | "CLOSURE", 66 | "VARARG", 67 | "EXTRAARG", 68 | NULL 69 | }; 70 | 71 | 72 | #define opmode(t,a,b,c,m) (((t)<<7) | ((a)<<6) | ((b)<<4) | ((c)<<2) | (m)) 73 | 74 | LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { 75 | /* T A B C mode opcode */ 76 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ 77 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ 78 | ,opmode(0, 1, OpArgN, OpArgN, iABx) /* OP_LOADKX */ 79 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ 80 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_LOADNIL */ 81 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ 82 | ,opmode(0, 1, OpArgU, OpArgK, iABC) /* OP_GETTABUP */ 83 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_GETTABLE */ 84 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABUP */ 85 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_SETUPVAL */ 86 | ,opmode(0, 0, OpArgK, OpArgK, iABC) /* OP_SETTABLE */ 87 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_NEWTABLE */ 88 | ,opmode(0, 1, OpArgR, OpArgK, iABC) /* OP_SELF */ 89 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_ADD */ 90 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SUB */ 91 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MUL */ 92 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */ 93 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */ 94 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */ 95 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_IDIV */ 96 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */ 97 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */ 98 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */ 99 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHL */ 100 | ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_SHR */ 101 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */ 102 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */ 103 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */ 104 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */ 105 | ,opmode(0, 1, OpArgR, OpArgR, iABC) /* OP_CONCAT */ 106 | ,opmode(0, 0, OpArgR, OpArgN, iAsBx) /* OP_JMP */ 107 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_EQ */ 108 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LT */ 109 | ,opmode(1, 0, OpArgK, OpArgK, iABC) /* OP_LE */ 110 | ,opmode(1, 0, OpArgN, OpArgU, iABC) /* OP_TEST */ 111 | ,opmode(1, 1, OpArgR, OpArgU, iABC) /* OP_TESTSET */ 112 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_CALL */ 113 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_TAILCALL */ 114 | ,opmode(0, 0, OpArgU, OpArgN, iABC) /* OP_RETURN */ 115 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORLOOP */ 116 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_FORPREP */ 117 | ,opmode(0, 0, OpArgN, OpArgU, iABC) /* OP_TFORCALL */ 118 | ,opmode(0, 1, OpArgR, OpArgN, iAsBx) /* OP_TFORLOOP */ 119 | ,opmode(0, 0, OpArgU, OpArgU, iABC) /* OP_SETLIST */ 120 | ,opmode(0, 1, OpArgU, OpArgN, iABx) /* OP_CLOSURE */ 121 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_VARARG */ 122 | ,opmode(0, 0, OpArgU, OpArgU, iAx) /* OP_EXTRAARG */ 123 | }; 124 | 125 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lparser.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lparser.h,v 1.74 2014/10/25 11:50:46 roberto Exp $ 3 | ** Lua Parser 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lparser_h 8 | #define lparser_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* 16 | ** Expression descriptor 17 | */ 18 | 19 | typedef enum { 20 | VVOID, /* no value */ 21 | VNIL, 22 | VTRUE, 23 | VFALSE, 24 | VK, /* info = index of constant in 'k' */ 25 | VKFLT, /* nval = numerical float value */ 26 | VKINT, /* nval = numerical integer value */ 27 | VNONRELOC, /* info = result register */ 28 | VLOCAL, /* info = local register */ 29 | VUPVAL, /* info = index of upvalue in 'upvalues' */ 30 | VINDEXED, /* t = table register/upvalue; idx = index R/K */ 31 | VJMP, /* info = instruction pc */ 32 | VRELOCABLE, /* info = instruction pc */ 33 | VCALL, /* info = instruction pc */ 34 | VVARARG /* info = instruction pc */ 35 | } expkind; 36 | 37 | 38 | #define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED) 39 | #define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL) 40 | 41 | typedef struct expdesc { 42 | expkind k; 43 | union { 44 | struct { /* for indexed variables (VINDEXED) */ 45 | short idx; /* index (R/K) */ 46 | lu_byte t; /* table (register or upvalue) */ 47 | lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ 48 | } ind; 49 | int info; /* for generic use */ 50 | lua_Number nval; /* for VKFLT */ 51 | lua_Integer ival; /* for VKINT */ 52 | } u; 53 | int t; /* patch list of 'exit when true' */ 54 | int f; /* patch list of 'exit when false' */ 55 | } expdesc; 56 | 57 | 58 | /* description of active local variable */ 59 | typedef struct Vardesc { 60 | short idx; /* variable index in stack */ 61 | } Vardesc; 62 | 63 | 64 | /* description of pending goto statements and label statements */ 65 | typedef struct Labeldesc { 66 | TString *name; /* label identifier */ 67 | int pc; /* position in code */ 68 | int line; /* line where it appeared */ 69 | lu_byte nactvar; /* local level where it appears in current block */ 70 | } Labeldesc; 71 | 72 | 73 | /* list of labels or gotos */ 74 | typedef struct Labellist { 75 | Labeldesc *arr; /* array */ 76 | int n; /* number of entries in use */ 77 | int size; /* array size */ 78 | } Labellist; 79 | 80 | 81 | /* dynamic structures used by the parser */ 82 | typedef struct Dyndata { 83 | struct { /* list of active local variables */ 84 | Vardesc *arr; 85 | int n; 86 | int size; 87 | } actvar; 88 | Labellist gt; /* list of pending gotos */ 89 | Labellist label; /* list of active labels */ 90 | } Dyndata; 91 | 92 | 93 | /* control of blocks */ 94 | struct BlockCnt; /* defined in lparser.c */ 95 | 96 | 97 | /* state needed to generate code for a given function */ 98 | typedef struct FuncState { 99 | Proto *f; /* current function header */ 100 | struct FuncState *prev; /* enclosing function */ 101 | struct LexState *ls; /* lexical state */ 102 | struct BlockCnt *bl; /* chain of current blocks */ 103 | int pc; /* next position to code (equivalent to 'ncode') */ 104 | int lasttarget; /* 'label' of last 'jump label' */ 105 | int jpc; /* list of pending jumps to 'pc' */ 106 | int nk; /* number of elements in 'k' */ 107 | int np; /* number of elements in 'p' */ 108 | int firstlocal; /* index of first local var (in Dyndata array) */ 109 | short nlocvars; /* number of elements in 'f->locvars' */ 110 | lu_byte nactvar; /* number of active local variables */ 111 | lu_byte nups; /* number of upvalues */ 112 | lu_byte freereg; /* first free register */ 113 | } FuncState; 114 | 115 | 116 | LUAI_FUNC LClosure *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, 117 | Dyndata *dyd, const char *name, int firstchar); 118 | 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.56 2014/07/18 14:46:47 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | #define sizestring(s) sizelstring((s)->len) 17 | 18 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 19 | #define sizeudata(u) sizeludata((u)->len) 20 | 21 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 22 | (sizeof(s)/sizeof(char))-1)) 23 | 24 | 25 | /* 26 | ** test whether a string is a reserved word 27 | */ 28 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 29 | 30 | 31 | /* 32 | ** equality for short strings, which are always internalized 33 | */ 34 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 35 | 36 | 37 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 41 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 42 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 43 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /lua-5.3.0/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.20 2014/09/04 18:15:29 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->i_key.nk.next) 16 | 17 | 18 | /* 'const' to avoid wrong writings that can mess up field 'next' */ 19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) 20 | 21 | #define wgkey(n) (&(n)->i_key.nk) 22 | 23 | #define invalidateTMcache(t) ((t)->flags = 0) 24 | 25 | 26 | /* returns the key, given the value of a table entry */ 27 | #define keyfromval(v) \ 28 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 29 | 30 | 31 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 32 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 33 | TValue *value); 34 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 35 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 36 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 37 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 38 | LUAI_FUNC Table *luaH_new (lua_State *L); 39 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 40 | unsigned int nhsize); 41 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 42 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 43 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 44 | LUAI_FUNC int luaH_getn (Table *t); 45 | 46 | 47 | #if defined(LUA_DEBUG) 48 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 49 | LUAI_FUNC int luaH_isdummy (Node *n); 50 | #endif 51 | 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /lua-5.3.0/src/ltm.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.c,v 2.33 2014/11/21 12:15:57 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define ltm_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "ldebug.h" 18 | #include "ldo.h" 19 | #include "lobject.h" 20 | #include "lstate.h" 21 | #include "lstring.h" 22 | #include "ltable.h" 23 | #include "ltm.h" 24 | #include "lvm.h" 25 | 26 | 27 | static const char udatatypename[] = "userdata"; 28 | 29 | LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = { 30 | "no value", 31 | "nil", "boolean", udatatypename, "number", 32 | "string", "table", "function", udatatypename, "thread", 33 | "proto" /* this last case is used for tests only */ 34 | }; 35 | 36 | 37 | void luaT_init (lua_State *L) { 38 | static const char *const luaT_eventname[] = { /* ORDER TM */ 39 | "__index", "__newindex", 40 | "__gc", "__mode", "__len", "__eq", 41 | "__add", "__sub", "__mul", "__mod", "__pow", 42 | "__div", "__idiv", 43 | "__band", "__bor", "__bxor", "__shl", "__shr", 44 | "__unm", "__bnot", "__lt", "__le", 45 | "__concat", "__call" 46 | }; 47 | int i; 48 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); 50 | luaC_fix(L, obj2gco(G(L)->tmname[i])); /* never collect these names */ 51 | } 52 | } 53 | 54 | 55 | /* 56 | ** function to be used with macro "fasttm": optimized for absence of 57 | ** tag methods 58 | */ 59 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 60 | const TValue *tm = luaH_getstr(events, ename); 61 | lua_assert(event <= TM_EQ); 62 | if (ttisnil(tm)) { /* no tag method? */ 63 | events->flags |= cast_byte(1u<metatable; 75 | break; 76 | case LUA_TUSERDATA: 77 | mt = uvalue(o)->metatable; 78 | break; 79 | default: 80 | mt = G(L)->mt[ttnov(o)]; 81 | } 82 | return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); 83 | } 84 | 85 | 86 | void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 87 | const TValue *p2, TValue *p3, int hasres) { 88 | ptrdiff_t result = savestack(L, p3); 89 | setobj2s(L, L->top++, f); /* push function (assume EXTRA_STACK) */ 90 | setobj2s(L, L->top++, p1); /* 1st argument */ 91 | setobj2s(L, L->top++, p2); /* 2nd argument */ 92 | if (!hasres) /* no result? 'p3' is third argument */ 93 | setobj2s(L, L->top++, p3); /* 3rd argument */ 94 | /* metamethod may yield only when called from Lua code */ 95 | luaD_call(L, L->top - (4 - hasres), hasres, isLua(L->ci)); 96 | if (hasres) { /* if has result, move it to its place */ 97 | p3 = restorestack(L, result); 98 | setobjs2s(L, p3, --L->top); 99 | } 100 | } 101 | 102 | 103 | int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 104 | StkId res, TMS event) { 105 | const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ 106 | if (ttisnil(tm)) 107 | tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ 108 | if (ttisnil(tm)) return 0; 109 | luaT_callTM(L, tm, p1, p2, res, 1); 110 | return 1; 111 | } 112 | 113 | 114 | void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 115 | StkId res, TMS event) { 116 | if (!luaT_callbinTM(L, p1, p2, res, event)) { 117 | switch (event) { 118 | case TM_CONCAT: 119 | luaG_concaterror(L, p1, p2); 120 | case TM_BAND: case TM_BOR: case TM_BXOR: 121 | case TM_SHL: case TM_SHR: case TM_BNOT: { 122 | lua_Number dummy; 123 | if (tonumber(p1, &dummy) && tonumber(p2, &dummy)) 124 | luaG_tointerror(L, p1, p2); 125 | else 126 | luaG_opinterror(L, p1, p2, "perform bitwise operation on"); 127 | /* else go through */ 128 | } 129 | default: 130 | luaG_opinterror(L, p1, p2, "perform arithmetic on"); 131 | } 132 | } 133 | } 134 | 135 | 136 | int luaT_callorderTM (lua_State *L, const TValue *p1, const TValue *p2, 137 | TMS event) { 138 | if (!luaT_callbinTM(L, p1, p2, L->top, event)) 139 | return -1; /* no metamethod */ 140 | else 141 | return !l_isfalse(L->top); 142 | } 143 | 144 | -------------------------------------------------------------------------------- /lua-5.3.0/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.21 2014/10/25 11:50:46 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_N /* number of elements in the enum */ 44 | } TMS; 45 | 46 | 47 | 48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 50 | 51 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 52 | 53 | #define ttypename(x) luaT_typenames_[(x) + 1] 54 | #define objtypename(x) ttypename(ttnov(x)) 55 | 56 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 57 | 58 | 59 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 60 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 61 | TMS event); 62 | LUAI_FUNC void luaT_init (lua_State *L); 63 | 64 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 65 | const TValue *p2, TValue *p3, int hasres); 66 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 67 | StkId res, TMS event); 68 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 69 | StkId res, TMS event); 70 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 71 | const TValue *p2, TMS event); 72 | 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.44 2014/02/06 17:32:33 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_UTF8LIBNAME "utf8" 33 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 34 | 35 | #define LUA_BITLIBNAME "bit32" 36 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 37 | 38 | #define LUA_MATHLIBNAME "math" 39 | LUAMOD_API int (luaopen_math) (lua_State *L); 40 | 41 | #define LUA_DBLIBNAME "debug" 42 | LUAMOD_API int (luaopen_debug) (lua_State *L); 43 | 44 | #define LUA_LOADLIBNAME "package" 45 | LUAMOD_API int (luaopen_package) (lua_State *L); 46 | 47 | 48 | /* open all previous libraries */ 49 | LUALIB_API void (luaL_openlibs) (lua_State *L); 50 | 51 | 52 | 53 | #if !defined(lua_assert) 54 | #define lua_assert(x) ((void)0) 55 | #endif 56 | 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.44 2014/06/19 18:27:20 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, 27 | const char* name); 28 | 29 | /* dump one chunk; from ldump.c */ 30 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 31 | void* data, int strip); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.34 2014/08/01 17:24:02 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #if !defined(LUA_NOCVTN2S) 17 | #define cvt2str(o) ttisnumber(o) 18 | #else 19 | #define cvt2str(o) 0 /* no conversion from numbers to strings */ 20 | #endif 21 | 22 | 23 | #if !defined(LUA_NOCVTS2N) 24 | #define cvt2num(o) ttisstring(o) 25 | #else 26 | #define cvt2num(o) 0 /* no conversion from strings to numbers */ 27 | #endif 28 | 29 | 30 | #define tonumber(o,n) \ 31 | (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : luaV_tonumber_(o,n)) 32 | 33 | #define tointeger(o,i) \ 34 | (ttisinteger(o) ? (*(i) = ivalue(o), 1) : luaV_tointeger_(o,i)) 35 | 36 | #define intop(op,v1,v2) l_castU2S(l_castS2U(v1) op l_castS2U(v2)) 37 | 38 | #define luaV_rawequalobj(t1,t2) luaV_equalobj(NULL,t1,t2) 39 | 40 | 41 | LUAI_FUNC int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2); 42 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 43 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 44 | LUAI_FUNC int luaV_tonumber_ (const TValue *obj, lua_Number *n); 45 | LUAI_FUNC int luaV_tointeger_ (const TValue *obj, lua_Integer *p); 46 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 47 | StkId val); 48 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 49 | StkId val); 50 | LUAI_FUNC void luaV_finishOp (lua_State *L); 51 | LUAI_FUNC void luaV_execute (lua_State *L); 52 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 53 | LUAI_FUNC lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y); 54 | LUAI_FUNC lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y); 55 | LUAI_FUNC lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y); 56 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.36 2014/11/02 19:19:04 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | /* ------------------------------------------------------------------------ */ 70 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 71 | if (n > buff->buffsize) { 72 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 73 | luaZ_resizebuffer(L, buff, n); 74 | } 75 | return buff->buffer; 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /lua-5.3.0/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.30 2014/12/19 17:26:14 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 48 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 49 | void *data); 50 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 51 | 52 | 53 | 54 | /* --------- Private Part ------------------ */ 55 | 56 | struct Zio { 57 | size_t n; /* bytes still unread */ 58 | const char *p; /* current position in buffer */ 59 | lua_Reader reader; /* reader function */ 60 | void *data; /* additional data */ 61 | lua_State *L; /* Lua state (for reader) */ 62 | }; 63 | 64 | 65 | LUAI_FUNC int luaZ_fill (ZIO *z); 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /scripts/c.lua: -------------------------------------------------------------------------------- 1 | require("compat53") 2 | 3 | local cscope = require("cscope") 4 | local tmux = require("tmux") 5 | local code = require("dit.code") 6 | local tab_complete = require("dit.tab_complete") 7 | local line_commit = require("dit.line_commit") 8 | 9 | local current_file = nil 10 | local errors = nil 11 | 12 | local function open_header() 13 | local name = buffer:filename() 14 | if name:match("%.c$") then 15 | name = name:gsub("%.c$", ".h") 16 | elseif name:match("%.h$") then 17 | name = name:gsub("%.h$", ".c") 18 | else 19 | return 20 | end 21 | local page = tabs:open(name) 22 | tabs:mark_jump() 23 | tabs:set_page(page) 24 | end 25 | 26 | local function popup_error() 27 | local x, y = buffer:xy() 28 | if errors and errors[y] then 29 | for ex, err in pairs(errors[y]) do 30 | if x >= ex then 31 | buffer:draw_popup({err}) 32 | return 33 | end 34 | end 35 | end 36 | end 37 | 38 | function on_ctrl(key) 39 | if key == "D" then 40 | cscope.go_to_definition() 41 | elseif key == "R" then 42 | popup_error() 43 | elseif key == "O" then 44 | line_commit.line_commit() 45 | elseif key == "_" then 46 | code.comment_block("//") 47 | elseif key == "P" then 48 | tmux.man() 49 | end 50 | end 51 | 52 | function on_alt(key) 53 | if key == "H" then 54 | open_header() 55 | end 56 | end 57 | 58 | function on_fkey(key) 59 | if key == "F7" then 60 | code.expand_selection() 61 | end 62 | end 63 | 64 | function highlight_file(filename) 65 | current_file = filename 66 | end 67 | 68 | function highlight_line(line, y) 69 | if errors and errors[y] then 70 | local out = {} 71 | for i = 1, #line do out[i] = " " end 72 | for x, err in pairs(errors[y]) do 73 | local k = "*" -- err:match("^warning") and "S" or "*" 74 | if x <= #line then 75 | out[x] = k 76 | local xs = x 77 | while line[xs]:match("[%w_%->]") do 78 | out[xs] = k 79 | xs = xs + 1 80 | end 81 | end 82 | end 83 | return table.concat(out) 84 | else 85 | return "" 86 | end 87 | end 88 | 89 | function on_change() 90 | errors = nil 91 | return true 92 | end 93 | 94 | function on_save() 95 | if not current_file then 96 | return true 97 | end 98 | local cmd = io.popen("LANG=C gcc -I. -Ieditorconfig/include -c "..current_file.." -o /dev/null --std=c99 2>&1") 99 | local cmdout = cmd:read("*a") 100 | cmd:close() 101 | errors = {} 102 | for ey, ex, err in cmdout:gmatch("[^\n]*:([0-9]+):([0-9]+): error: ([^\n]*)") do 103 | ey = tonumber(ey) 104 | ex = tonumber(ex) 105 | if not errors[ey] then errors[ey] = {} end 106 | errors[ey][ex] = err 107 | end 108 | for ey, ex, err in cmdout:gmatch("[^\n]*:([0-9]+):([0-9]+): warning: ([^\n]*)") do 109 | ey = tonumber(ey) 110 | ex = tonumber(ex) 111 | if not errors[ey] then errors[ey] = {} end 112 | errors[ey][ex] = "warning: " .. err 113 | end 114 | return true 115 | end 116 | 117 | function on_key(code) 118 | return tab_complete.on_key(code) 119 | end 120 | -------------------------------------------------------------------------------- /scripts/cmd.lua: -------------------------------------------------------------------------------- 1 | 2 | local cmd = {} 3 | 4 | function cmd.run(cmd, ...) 5 | local pd = io.popen(cmd:format(...)) 6 | local out = pd:read("*a") 7 | pd:close() 8 | return out 9 | end 10 | 11 | return cmd 12 | -------------------------------------------------------------------------------- /scripts/compat53.lua: -------------------------------------------------------------------------------- 1 | compat53/init.lua -------------------------------------------------------------------------------- /scripts/cscope.lua: -------------------------------------------------------------------------------- 1 | 2 | local cscope = {} 3 | 4 | local cmd = require("cmd") 5 | 6 | local cscope_files_cache = {} 7 | 8 | local function get_cscope_files(dir, pattern) 9 | if cscope_files_cache[dir] then 10 | return cscope_files_cache[dir] 11 | end 12 | local cscope_files = "/tmp/cscope_"..dir:gsub("/", "_")..".files" 13 | if os.execute("test -e "..cscope_files) ~= 0 then 14 | cmd.run("find '%s' -name '%s' > '%s'", dir, pattern, cscope_files) 15 | end 16 | cscope_files_cache[dir] = cscope_files 17 | return cscope_files 18 | end 19 | 20 | local function get_context() 21 | local token, x, y, len = buffer:token() 22 | if not token then return end 23 | local dir = buffer:dir() 24 | local cscope_db = "/tmp/cscope_"..dir:gsub("/", "_") 25 | return token, dir, cscope_db 26 | end 27 | 28 | local function go_to_result(decl, word) 29 | local file, _, line = decl:match("([^%s]+) ([^%s]+) ([^%s]+)") 30 | line = tonumber(line) 31 | if file then 32 | local page = tabs:open(file) 33 | tabs:mark_jump() 34 | tabs:set_page(page) 35 | local buf = tabs:get_buffer(page) 36 | buf:go_to(1, line) 37 | local text = buf:line() 38 | if word then 39 | local x = text:find(word) 40 | if x then buf:go_to(x, line) end 41 | return file, line 42 | end 43 | end 44 | end 45 | 46 | function cscope.go_to_definition() 47 | local token, dir, cscope_db = get_context() 48 | if not token then return end 49 | local decl = cmd.run("cscope -s '%s' -f '%s' -L -1 '%s'", dir, cscope_db, token) 50 | local thisfile = buffer:basename() 51 | local thisx, thisy = buffer:xy() 52 | local file, y = go_to_result(decl, token) 53 | if file then 54 | file = file:match("^.*/([^/]+)$") 55 | if file == thisfile and y == thisy then 56 | local all = cmd.run("cscope -s '%s' -f '%s' -L -0 '%s'", dir, cscope_db, token) 57 | for line in all:gmatch("[^\n]+") do 58 | if line:match("^([^%s]+%.h) ") then 59 | go_to_result(line, token) 60 | end 61 | end 62 | end 63 | end 64 | end 65 | 66 | function cscope.go_to_definition_in_files(pattern) 67 | local token, dir, cscope_db = get_context() 68 | if not token then return end 69 | local cscope_files = get_cscope_files(dir, pattern) 70 | local decl = cmd.run("cscope -i '%s' -f '%s' -L -1 '%s'", cscope_files, cscope_db, token) 71 | local file, word, line = decl:match("([^%s]+) ([^%s]+) ([^%s]+)") 72 | go_to_result(decl) 73 | end 74 | 75 | return cscope 76 | -------------------------------------------------------------------------------- /scripts/dit/global.lua: -------------------------------------------------------------------------------- 1 | 2 | local align_by_char 3 | do 4 | local function which_char_at_buffer(x, y) 5 | local line = buffer[y] 6 | local ch = line[x] 7 | local i = 1 8 | local nth = 0 9 | for c in line:gmatch(".") do 10 | if c == ch then 11 | nth = nth + 1 12 | if i == x then 13 | break 14 | end 15 | end 16 | i = i + 1 17 | end 18 | return ch, nth 19 | end 20 | 21 | local function find_nth(line, ch, nth) 22 | local pos = 0 23 | for i = 1, nth do 24 | pos = pos + 1 25 | pos = line:find(ch, pos, true) 26 | if not pos then return nil end 27 | end 28 | return pos 29 | end 30 | 31 | align_by_char = function() 32 | local x, y = buffer:xy() 33 | local ch, nth = which_char_at_buffer(x, y) 34 | local at = y - 1 35 | local maxx = x 36 | local positions = {} 37 | positions[y] = x 38 | local start = y 39 | while at > 1 do 40 | local pos = find_nth(buffer[at], ch, nth) 41 | if not pos then 42 | break 43 | end 44 | positions[at] = pos 45 | maxx = math.max(pos, maxx) 46 | start = at 47 | at = at - 1 48 | end 49 | local stop = y 50 | at = y + 1 51 | while at < #buffer do 52 | local pos = find_nth(buffer[at], ch, nth) 53 | if not pos then 54 | break 55 | end 56 | positions[at] = pos 57 | maxx = math.max(pos, maxx) 58 | stop = at 59 | at = at + 1 60 | end 61 | 62 | buffer:begin_undo() 63 | for i = start, stop do 64 | local pos = positions[i] 65 | if pos < maxx then 66 | buffer[i] = buffer[i]:sub(1, pos-1) .. (" "):rep(maxx - pos) .. buffer[i]:sub(pos) 67 | elseif pos > maxx then 68 | buffer[i] = buffer[i]:sub(1, pos) .. (" "):rep(pos - maxx) .. buffer[i]:sub(pos + 1) 69 | end 70 | end 71 | buffer:end_undo() 72 | return 73 | end 74 | end 75 | 76 | local flip_quotes 77 | do 78 | local function flip_quote(line, x, q, p) 79 | local a, b = line:sub(1, x-1):match("^(.*)"..q.."([^"..q.."]*)$") 80 | local c, d = line:sub(x):match("^([^"..q.."]*)"..q.."(.*)$") 81 | if not (a and c) then 82 | return nil 83 | end 84 | return a..p..b..c..p..d 85 | end 86 | 87 | flip_quotes = function() 88 | local x, y = buffer:xy() 89 | local line = buffer[y] 90 | local flip = flip_quote(line, x, '"', "'") 91 | or flip_quote(line, x, "'", '"') 92 | if flip then 93 | buffer[y] = flip 94 | end 95 | end 96 | end 97 | 98 | local ctrl_p_latch = false 99 | 100 | local old_on_ctrl = on_ctrl 101 | 102 | function on_ctrl(key) 103 | if ctrl_p_latch then 104 | ctrl_p_latch = false 105 | if key == "Q" then 106 | flip_quotes() 107 | return true 108 | elseif key == "A" then 109 | align_by_char() 110 | return true 111 | end 112 | return 113 | end 114 | ctrl_p_latch = false 115 | if key == "P" then 116 | ctrl_p_latch = true 117 | return 118 | end 119 | if old_on_ctrl then 120 | return old_on_ctrl(key) 121 | end 122 | end 123 | 124 | local old_on_key = on_key 125 | 126 | if old_on_key then 127 | function on_key(k) 128 | if k ~= 16 then ctrl_p_latch = false end 129 | return old_on_key(k) 130 | end 131 | end 132 | 133 | -------------------------------------------------------------------------------- /scripts/dit/line_commit.lua: -------------------------------------------------------------------------------- 1 | 2 | local line_commit = {} 3 | 4 | function line_commit.line_commit() 5 | local x, y = buffer:xy() 6 | local pd = io.popen("git blame "..buffer:filename().." -L "..y, "r") 7 | local info = {} 8 | if pd then 9 | local blame = pd:read("*l") 10 | pd:close() 11 | local commit = blame:match("([^ ]+) ") 12 | pd = io.popen("git show "..commit.." -s") 13 | if pd then 14 | for line in pd:lines() do 15 | table.insert(info, line) 16 | end 17 | pd:close() 18 | end 19 | end 20 | if #info == 0 then 21 | info[1] = "not found" 22 | end 23 | buffer:draw_popup(info) 24 | end 25 | 26 | return line_commit 27 | -------------------------------------------------------------------------------- /scripts/dit/lua/mobdebug.lua: -------------------------------------------------------------------------------- 1 | local dit_lua_mobdebug = {} 2 | 3 | local mobdebug_ok, mobdebug = pcall(require, "mobdebug") 4 | 5 | local server 6 | local client 7 | 8 | dit_lua_mobdebug.breakpoints = {} 9 | dit_lua_mobdebug.where = {} 10 | dit_lua_mobdebug.file = nil 11 | dit_lua_mobdebug.line = nil 12 | 13 | local function at(file, line) 14 | dit_lua_mobdebug.where[file] = line 15 | dit_lua_mobdebug.file = file 16 | dit_lua_mobdebug.line = line 17 | end 18 | 19 | function dit_lua_mobdebug.is_breakpoint(file, line) 20 | dit_lua_mobdebug.breakpoints[file] = dit_lua_mobdebug.breakpoints[file] or {} 21 | local f = dit_lua_mobdebug.breakpoints[file] 22 | return f[line] == true 23 | end 24 | 25 | function dit_lua_mobdebug.set_breakpoint(file, line, val) 26 | dit_lua_mobdebug.breakpoints[file] = dit_lua_mobdebug.breakpoints[file] or {} 27 | dit_lua_mobdebug.breakpoints[file][line] = val 28 | end 29 | 30 | function dit_lua_mobdebug.is_debugging() 31 | return client ~= nil 32 | end 33 | 34 | function dit_lua_mobdebug.listen() 35 | if not mobdebug_ok then 36 | return nil, "mobdebug not installed" 37 | end 38 | 39 | local host = "*" 40 | local port = mobdebug.port 41 | 42 | local socket = require "socket" 43 | 44 | server = socket.bind(host, port) 45 | if not server then 46 | return nil, "failed to start debugging socket" 47 | end 48 | client = server:accept() 49 | 50 | client:send("STEP\n") 51 | client:receive() 52 | 53 | local breakpoint = client:receive() 54 | local _, _, file, line = string.find(breakpoint, "^202 Paused%s+(.-)%s+(%d+)%s*$") 55 | if file and line then 56 | at(file, line) 57 | else 58 | local _, _, size = string.find(breakpoint, "^401 Error in Execution (%d+)%s*$") 59 | if size then 60 | return nil, client:receive(size) 61 | end 62 | end 63 | return true 64 | end 65 | 66 | function dit_lua_mobdebug.command(command) 67 | if not mobdebug_ok then 68 | return nil, "mobdebug not installed" 69 | end 70 | 71 | if not client then 72 | return nil, "not in a debugging session" 73 | end 74 | 75 | local out = {} 76 | local r1, r2, err = mobdebug.handle(command, client, { 77 | verbose = function(...) 78 | table.insert(out, table.concat({...})) 79 | end 80 | }) 81 | if not r1 and err == false then 82 | client:close() 83 | server:close() 84 | client = nil 85 | server = nil 86 | dit_lua_mobdebug.where = {} 87 | dit_lua_mobdebug.file = nil 88 | dit_lua_mobdebug.line = nil 89 | end 90 | 91 | if err then 92 | return nil, err 93 | end 94 | 95 | if command == "step" or command == "over" or command == "run" then 96 | local y = tonumber(r2) 97 | if r1 ~= buffer:filename() then 98 | -- TODO support multiple files in a single script 99 | -- local page = tabs:open(r1) 100 | -- tabs:mark_jump() 101 | -- tabs:set_page(page) 102 | -- tabs:get_buffer(page):go_to(1, y) 103 | else 104 | buffer:go_to(1, y) 105 | end 106 | at(r1, y) 107 | end 108 | return out 109 | end 110 | 111 | return dit_lua_mobdebug 112 | -------------------------------------------------------------------------------- /scripts/go.lua: -------------------------------------------------------------------------------- 1 | require("compat53") 2 | 3 | local cscope = require("cscope") 4 | local tmux = require("tmux") 5 | local code = require("dit.code") 6 | local tab_complete = require("dit.tab_complete") 7 | local line_commit = require("dit.line_commit") 8 | 9 | local current_file = nil 10 | local errors = nil 11 | 12 | local function popup_error() 13 | local _, x, y = buffer:token() 14 | if errors and errors[y] then 15 | for ex, err in pairs(errors[y]) do 16 | if x == ex then 17 | buffer:draw_popup({err}) 18 | return 19 | end 20 | end 21 | end 22 | end 23 | 24 | function on_ctrl(key) 25 | if key == "D" then 26 | cscope.go_to_definition() 27 | elseif key == "R" then 28 | popup_error() 29 | elseif key == "O" then 30 | line_commit.line_commit() 31 | elseif key == "_" then 32 | code.comment_block("//") 33 | elseif key == "P" then 34 | tmux.man() 35 | end 36 | end 37 | 38 | function on_fkey(key) 39 | if key == "F7" then 40 | code.expand_selection() 41 | end 42 | end 43 | 44 | function highlight_file(filename) 45 | current_file = filename 46 | end 47 | 48 | function highlight_line(line, y) 49 | if errors and errors[y] then 50 | local out = {} 51 | for i = 1, #line do out[i] = " " end 52 | for x, _ in pairs(errors[y]) do 53 | if x <= #line then 54 | out[x] = "*" 55 | local xs = x 56 | while line[xs]:match("[%w_%->]") do 57 | out[xs] = "*" 58 | xs = xs + 1 59 | end 60 | end 61 | end 62 | return table.concat(out) 63 | else 64 | return "" 65 | end 66 | end 67 | 68 | function on_change() 69 | errors = nil 70 | return true 71 | end 72 | 73 | function on_save() 74 | if not current_file then 75 | return true 76 | end 77 | local cmd = io.popen("go build -o /dev/null "..current_file.." 2>&1") 78 | local cmdout = cmd:read("*a") 79 | cmd:close() 80 | errors = {} 81 | for ey, ex, err in cmdout:gmatch("[^\n]*:([0-9]+):([0-9]+): ([^\n]*)") do 82 | ey = tonumber(ey) 83 | ex = tonumber(ex) 84 | if not errors[ey] then errors[ey] = {} end 85 | errors[ey][ex] = err 86 | end 87 | return true 88 | end 89 | 90 | function on_key(code) 91 | return tab_complete.on_key(code) 92 | end 93 | -------------------------------------------------------------------------------- /scripts/java.lua: -------------------------------------------------------------------------------- 1 | 2 | local cscope = require("cscope") 3 | local tab_complete = require("dit.tab_complete") 4 | 5 | function on_ctrl(key) 6 | if key == "D" then 7 | cscope.go_to_definition_in_files("*.java") 8 | end 9 | end 10 | 11 | function on_key(code) 12 | return tab_complete.on_key(code) 13 | end 14 | -------------------------------------------------------------------------------- /scripts/json.lua: -------------------------------------------------------------------------------- 1 | local jok, json = pcall(require, "cjson") 2 | 3 | if not jok then 4 | return 5 | end 6 | 7 | local lines = {} 8 | 9 | function highlight_file() 10 | lines = {} 11 | local src = table.concat(buffer, "\n") 12 | local pok, err = pcall(json.decode, src) 13 | if pok then 14 | return 15 | end 16 | local chr = err:match("character (%d+)") 17 | chr = tonumber(chr) 18 | 19 | local c = 0 20 | for i = 1, #buffer do 21 | local l = #(buffer[i]) 22 | local n = c + l + 1 23 | if chr <= n then 24 | lines[i] = chr - c 25 | end 26 | c = n 27 | end 28 | end 29 | 30 | function highlight_line(line, y) 31 | if not lines then 32 | return 33 | end 34 | local ret = {} 35 | local ex = lines[y] 36 | if ex then 37 | for i = 1, #line do ret[i] = " " end 38 | ret[ex] = "*" 39 | return table.concat(ret) 40 | end 41 | end 42 | 43 | function on_change() 44 | lines = nil 45 | end 46 | 47 | function on_save(filename) 48 | highlight_file() 49 | end 50 | -------------------------------------------------------------------------------- /scripts/latex.lua: -------------------------------------------------------------------------------- 1 | 2 | local code = require("dit.code") 3 | 4 | function on_ctrl(key) 5 | if key == "_" then 6 | code.comment_block("%", "%%") 7 | end 8 | end 9 | 10 | function on_fkey(key) 11 | if key == "F7" then 12 | code.expand_selection() 13 | end 14 | end 15 | 16 | -------------------------------------------------------------------------------- /scripts/luacheck/core_utils.lua: -------------------------------------------------------------------------------- 1 | local core_utils = {} 2 | 3 | -- Calls callback with line, stack_set, index, item, ... for each item reachable from starting item. 4 | -- `stack_set` is a set of indices of items in current propogation path from root, excluding current item. 5 | -- Callback can return true to stop walking from current item. 6 | function core_utils.walk_line(line, index, callback, ...) 7 | local stack = {} 8 | local stack_set = {} 9 | local backlog = {} 10 | local level = 0 11 | 12 | while index do 13 | local item = line.items[index] 14 | 15 | if not callback(line, stack_set, index, item, ...) and item then 16 | level = level + 1 17 | stack[level] = index 18 | stack_set[index] = true 19 | 20 | if item.tag == "Jump" then 21 | index = item.to 22 | elseif item.tag == "Cjump" then 23 | backlog[level] = index + 1 24 | index = item.to 25 | else 26 | index = index + 1 27 | end 28 | else 29 | while level > 0 and not backlog[level] do 30 | stack_set[stack[level]] = nil 31 | level = level - 1 32 | end 33 | 34 | index = backlog[level] 35 | backlog[level] = nil 36 | end 37 | end 38 | end 39 | 40 | local function once_per_item_callback_adapter(line, _, index, item, visited, callback, ...) 41 | if visited[index] then 42 | return true 43 | end 44 | 45 | visited[index] = true 46 | return callback(line, index, item, ...) 47 | end 48 | 49 | -- Calls callback with line, index, item, ... for each item reachable from starting item once. 50 | -- `visited` is a set of already visited indexes. 51 | -- Callback can return true to stop walking from current item. 52 | function core_utils.walk_line_once(line, visited, index, callback, ...) 53 | return core_utils.walk_line(line, index, once_per_item_callback_adapter, visited, callback, ...) 54 | end 55 | 56 | -- Given a "global set" warning, return whether it is an implicit definition. 57 | function core_utils.is_definition(opts, warning) 58 | return opts.allow_defined or (opts.allow_defined_top and warning.top) 59 | end 60 | 61 | local function event_priority(event) 62 | -- Inline option boundaries have priority over inline option declarations 63 | -- so that `-- luacheck: push ignore foo` is interpreted correctly (push first). 64 | if event.push or event.pop then 65 | return -2 66 | elseif event.options then 67 | return -1 68 | else 69 | return tonumber(event.code) 70 | end 71 | end 72 | 73 | local function event_comparator(event1, event2) 74 | if event1.line ~= event2.line then 75 | return event1.line < event2.line 76 | elseif event1.column ~= event2.column then 77 | return event1.column < event2.column 78 | else 79 | return event_priority(event1) < event_priority(event2) 80 | end 81 | end 82 | 83 | -- Sorts an array of warnings, inline options (tables with `options` field) 84 | -- or inline option boundaries (tables with `push` or `pop` field) by location 85 | -- information as provided in `line` and `column` fields. 86 | function core_utils.sort_by_location(array) 87 | table.sort(array, event_comparator) 88 | end 89 | 90 | return core_utils 91 | -------------------------------------------------------------------------------- /scripts/luacheck/expand_rockspec.lua: -------------------------------------------------------------------------------- 1 | local utils = require "luacheck.utils" 2 | 3 | local function extract_lua_files(rockspec) 4 | if type(rockspec) ~= "table" then 5 | return nil, "rockspec is not a table" 6 | end 7 | 8 | local build = rockspec.build 9 | 10 | if type(build) ~= "table" then 11 | return nil, "rockspec.build is not a table" 12 | end 13 | 14 | local res = {} 15 | 16 | local function scan(t) 17 | if type(t) == "table" then 18 | for _, file in pairs(t) do 19 | if type(file) == "string" and file:sub(-#".lua") == ".lua" then 20 | table.insert(res, file) 21 | end 22 | end 23 | end 24 | end 25 | 26 | if build.type == "builtin" then 27 | scan(build.modules) 28 | end 29 | 30 | if type(build.install) == "table" then 31 | scan(build.install.lua) 32 | scan(build.install.bin) 33 | end 34 | 35 | table.sort(res) 36 | return res 37 | end 38 | 39 | -- Receives a name of a rockspec, returns list of related .lua files or nil and "syntax" or "error" and error message. 40 | local function expand_rockspec(file) 41 | local rockspec, err, msg = utils.load_config(file) 42 | 43 | if not rockspec then 44 | return nil, err, msg 45 | end 46 | 47 | local files, format_err = extract_lua_files(rockspec) 48 | 49 | if not files then 50 | return nil, "syntax", format_err 51 | end 52 | 53 | return files 54 | end 55 | 56 | return expand_rockspec 57 | -------------------------------------------------------------------------------- /scripts/luacheck/multithreading.lua: -------------------------------------------------------------------------------- 1 | local utils = require "luacheck.utils" 2 | 3 | local multithreading = {} 4 | 5 | local ok, lanes = pcall(require, "lanes") 6 | ok = ok and pcall(lanes.configure) 7 | multithreading.has_lanes = ok 8 | multithreading.lanes = lanes 9 | multithreading.default_jobs = 1 10 | 11 | if not ok then 12 | return multithreading 13 | end 14 | 15 | local cpu_number_detection_commands = {} 16 | 17 | if utils.is_windows then 18 | cpu_number_detection_commands[1] = "echo %NUMBER_OF_PROCESSORS%" 19 | else 20 | cpu_number_detection_commands[1] = "getconf _NPROCESSORS_ONLN 2>&1" 21 | cpu_number_detection_commands[2] = "sysctl -n hw.ncpu 2>&1" 22 | cpu_number_detection_commands[3] = "psrinfo -p 2>&1" 23 | end 24 | 25 | for _, command in ipairs(cpu_number_detection_commands) do 26 | local handler = io.popen(command) 27 | 28 | if handler then 29 | local output = handler:read("*a") 30 | handler:close() 31 | 32 | if output then 33 | local cpu_number = tonumber(utils.strip(output)) 34 | 35 | if cpu_number then 36 | multithreading.default_jobs = math.floor(math.max(cpu_number, 1)) 37 | break 38 | end 39 | end 40 | end 41 | end 42 | 43 | -- Worker thread reads pairs {outkey, arg} from inkey channel of linda, 44 | -- applies func to arg and sends result to outkey channel of linda 45 | -- until arg is nil. 46 | local function worker_task(linda, inkey, func) 47 | while true do 48 | local _, pair = linda:receive(nil, inkey) 49 | local outkey, arg = pair[1], pair[2] 50 | 51 | if arg == nil then 52 | return true 53 | end 54 | 55 | linda:send(nil, outkey, func(arg)) 56 | end 57 | end 58 | 59 | local worker_gen = lanes.gen("*", worker_task) 60 | 61 | -- Maps func over array, performing at most jobs calls in parallel. 62 | function multithreading.pmap(func, array, jobs) 63 | jobs = math.min(jobs, #array) 64 | 65 | if jobs < 2 then 66 | return utils.map(func, array) 67 | end 68 | 69 | local workers = {} 70 | local linda = lanes.linda() 71 | 72 | for i = 1, jobs do 73 | workers[i] = worker_gen(linda, 0, func) 74 | end 75 | 76 | for i, item in ipairs(array) do 77 | linda:send(nil, 0, {i, item}) 78 | end 79 | 80 | for _ = 1, jobs do 81 | linda:send(nil, 0, {}) 82 | end 83 | 84 | local results = {} 85 | 86 | for i in ipairs(array) do 87 | local _, result = linda:receive(nil, i) 88 | results[i] = result 89 | end 90 | 91 | for _, worker in ipairs(workers) do 92 | assert(worker:join()) 93 | end 94 | 95 | return results 96 | end 97 | 98 | return multithreading 99 | -------------------------------------------------------------------------------- /scripts/luacheck/reachability.lua: -------------------------------------------------------------------------------- 1 | local core_utils = require "luacheck.core_utils" 2 | 3 | local reachability 4 | 5 | local function noop_callback() end 6 | 7 | local function reachability_callback(_, _, item, chstate, nested) 8 | if not item then 9 | return true 10 | end 11 | 12 | if not nested and item.lines then 13 | for _, subline in ipairs(item.lines) do 14 | reachability(chstate, subline, true) 15 | end 16 | end 17 | 18 | for _, action_key in ipairs({"accesses", "mutations"}) do 19 | local item_var_map = item[action_key] 20 | 21 | if item_var_map then 22 | for var, accessing_nodes in pairs(item_var_map) do 23 | if not var.empty then 24 | local all_possible_values_empty = true 25 | 26 | for _, possible_value in ipairs(item.used_values[var]) do 27 | if not possible_value.empty then 28 | all_possible_values_empty = false 29 | break 30 | end 31 | end 32 | 33 | if all_possible_values_empty then 34 | for _, accessing_node in ipairs(accessing_nodes) do 35 | chstate:warn_uninit(accessing_node, action_key == "mutations") 36 | end 37 | end 38 | end 39 | end 40 | end 41 | end 42 | end 43 | 44 | -- Emits warnings: unreachable code, uninitialized access. 45 | function reachability(chstate, line, nested) 46 | local reachable_indexes = {} 47 | core_utils.walk_line_once(line, reachable_indexes, 1, reachability_callback, chstate, nested) 48 | 49 | for i, item in ipairs(line.items) do 50 | if not reachable_indexes[i] then 51 | if item.location then 52 | chstate:warn_unreachable(item.location, item.loop_end, item.token) 53 | core_utils.walk_line_once(line, reachable_indexes, i, noop_callback) 54 | end 55 | end 56 | end 57 | end 58 | 59 | return reachability 60 | -------------------------------------------------------------------------------- /scripts/luacheck/version.lua: -------------------------------------------------------------------------------- 1 | local luacheck = require "luacheck" 2 | local fs = require "luacheck.fs" 3 | local multithreading = require "luacheck.multithreading" 4 | 5 | local version = {} 6 | 7 | version.luacheck = luacheck._VERSION 8 | 9 | if rawget(_G, "jit") then 10 | version.lua = rawget(_G, "jit").version 11 | else 12 | version.lua = _VERSION 13 | end 14 | 15 | if fs.has_lfs then 16 | version.lfs = fs.lfs._VERSION 17 | else 18 | version.lfs = "Not found" 19 | end 20 | 21 | if multithreading.has_lanes then 22 | version.lanes = multithreading.lanes.ABOUT.version 23 | else 24 | version.lanes = "Not found" 25 | end 26 | 27 | version.string = ([[ 28 | Luacheck: %s 29 | Lua: %s 30 | LuaFileSystem: %s 31 | LuaLanes: %s]]):format(version.luacheck, version.lua, version.lfs, version.lanes) 32 | 33 | return version 34 | -------------------------------------------------------------------------------- /scripts/luacheck/whitespace.lua: -------------------------------------------------------------------------------- 1 | local function check_whitespace(chstate, lines, line_endings) 2 | for line_number, line in ipairs(lines) do 3 | if line ~= "" then 4 | local from, to = line:find("%s+$") 5 | 6 | if from then 7 | local code 8 | 9 | if from == 1 then 10 | -- Line contains only whitespace (thus never considered "code"). 11 | code = "611" 12 | elseif not line_endings[line_number] then 13 | -- Trailing whitespace on code line or after long comment. 14 | code = "612" 15 | elseif line_endings[line_number] == "string" then 16 | -- Trailing whitespace embedded in a string literal. 17 | code = "613" 18 | elseif line_endings[line_number] == "comment" then 19 | -- Trailing whitespace at the end of a line comment or inside long comment. 20 | code = "614" 21 | end 22 | 23 | chstate:warn({code = code, line = line_number, column = from, end_column = to}) 24 | end 25 | 26 | from, to = line:find("^%s+") 27 | 28 | if from and to ~= #line and line:sub(1, to):find(" \t") then 29 | -- Inconsistent leading whitespace (SPACE followed by TAB). 30 | chstate:warn({code = "621", line = line_number, column = from, end_column = to}) 31 | end 32 | end 33 | end 34 | end 35 | 36 | return check_whitespace 37 | -------------------------------------------------------------------------------- /scripts/rust.lua: -------------------------------------------------------------------------------- 1 | require("compat53") 2 | 3 | local line_commit = require("dit.line_commit") 4 | local tab_complete = require("dit.tab_complete") 5 | local code = require("dit.code") 6 | 7 | function on_ctrl(key) 8 | if key == "O" then 9 | line_commit.line_commit() 10 | elseif key == "_" then 11 | code.comment_block("//") 12 | end 13 | end 14 | 15 | function on_key(key) 16 | return tab_complete.on_key(key) 17 | end 18 | 19 | -------------------------------------------------------------------------------- /scripts/shell.lua: -------------------------------------------------------------------------------- 1 | 2 | local code = require("dit.code") 3 | 4 | function on_ctrl(key) 5 | if key == "_" then 6 | code.comment_block("#", "#") 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /scripts/tmux.lua: -------------------------------------------------------------------------------- 1 | local tmux = {} 2 | 3 | local cmd = require("cmd") 4 | 5 | local function get_context() 6 | local token, x, y, len = buffer:token() 7 | if not token then return end 8 | return token 9 | end 10 | 11 | function tmux.man() 12 | local token = get_context() 13 | if not token then return end 14 | cmd.run("tmux splitw man '%s'", token) 15 | end 16 | 17 | return tmux 18 | -------------------------------------------------------------------------------- /terminals/konsole: -------------------------------------------------------------------------------- 1 | \033OH HOME 2 | \033OF END 3 | \033OP F1 4 | \033OQ F2 5 | \033OR F3 6 | \033OS F4 7 | \033[a SHIFT_UP 8 | \033[b SHIFT_DOWN 9 | \033[c SHIFT_RIGHT 10 | \033[d SHIFT_LEFT 11 | \033[A SHIFT_UP 12 | \033[B SHIFT_DOWN 13 | \033[C SHIFT_RIGHT 14 | \033[D SHIFT_LEFT 15 | \033[7$ SHIFT_HOME 16 | \033[8$ SHIFT_END 17 | \033[2^ CTRL_INSERT 18 | \033[2$ SHIFT_INSERT 19 | \033[2@ CTRL_SHIFT_INSERT 20 | \033[3^ CTRL_DELETE 21 | \033[3$ SHIFT_DELETE 22 | \033[7^ CTRL_HOME 23 | \033[8^ CTRL_END 24 | \033[5~ PPAGE 25 | \033[6~ NPAGE 26 | \033[5^ CTRL_PPAGE 27 | \033[6^ CTRL_NPAGE 28 | \033[5@ CTRL_SHIFT_PPAGE 29 | \033[6@ CTRL_SHIFT_NPAGE 30 | \033[7~ HOME 31 | \033[8~ END 32 | \033[Z BACK_TAB 33 | \033[1;5A CTRL_UP 34 | \033[1;5B CTRL_DOWN 35 | \033[1;5C CTRL_RIGHT 36 | \033[1;5D CTRL_LEFT 37 | \033[1;5H CTRL_HOME 38 | \033[1;5F CTRL_END 39 | \033[2;5~ CTRL_INSERT 40 | \033[3;5~ CTRL_DELETE 41 | \033[1;2A SHIFT_UP 42 | \033[1;2B SHIFT_DOWN 43 | \033[1;2C SHIFT_RIGHT 44 | \033[1;2D SHIFT_LEFT 45 | \033[1;2H SHIFT_HOME 46 | \033[1;2F SHIFT_END 47 | \033[2;2~ SHIFT_INSERT 48 | \033[3;2~ SHIFT_DELETE 49 | \033[5;2~ SHIFT_PPAGE 50 | \033[6;2~ SHIFT_NPAGE 51 | \033[5;5~ CTRL_PPAGE 52 | \033[6;5~ CTRL_NPAGE 53 | \033[H HOME 54 | \033[F END 55 | \033O2A SHIFT_UP 56 | \033O2B SHIFT_DOWN 57 | \033O2C SHIFT_RIGHT 58 | \033O2D SHIFT_LEFT 59 | \033O2H SHIFT_HOME 60 | \033O2F SHIFT_END 61 | \033[2~ CTRL_INSERT 62 | \033[1;6A CTRL_SHIFT_UP 63 | \033[1;6B CTRL_SHIFT_DOWN 64 | \033[1;6C CTRL_SHIFT_RIGHT 65 | \033[1;6D CTRL_SHIFT_LEFT 66 | \033[1;6H CTRL_SHIFT_HOME 67 | \033[1;6F CTRL_SHIFT_END 68 | \033[2;6~ CTRL_SHIFT_INSERT 69 | \033[3;6~ CTRL_SHIFT_DELETE 70 | \033[3~ DELETE 71 | \177 BACKSPACE 72 | \033[7;2~ SHIFT_HOME 73 | \033[8;2~ SHIFT_END 74 | \033[7;5~ CTRL_HOME 75 | \033[8;5~ CTRL_END 76 | -------------------------------------------------------------------------------- /terminals/linux: -------------------------------------------------------------------------------- 1 | \033OH HOME 2 | \033OF END 3 | \033OP F1 4 | \033OQ F2 5 | \033OR F3 6 | \033OS F4 7 | \033[a SHIFT_UP 8 | \033[b SHIFT_DOWN 9 | \033[c SHIFT_RIGHT 10 | \033[d SHIFT_LEFT 11 | \033Oa CTRL_UP 12 | \033Ob CTRL_DOWN 13 | \033Oc CTRL_RIGHT 14 | \033Od CTRL_LEFT 15 | \033[7$ SHIFT_HOME 16 | \033[8$ SHIFT_END 17 | \033[2^ CTRL_INSERT 18 | \033[2$ SHIFT_INSERT 19 | \033[2@ CTRL_SHIFT_INSERT 20 | \033[3^ CTRL_DELETE 21 | \033[3$ SHIFT_DELETE 22 | \033[7^ CTRL_HOME 23 | \033[8^ CTRL_END 24 | \033[5~ PPAGE 25 | \033[6~ NPAGE 26 | \033[7~ HOME 27 | \033[8~ END 28 | \033[Z BACK_TAB 29 | \033[1;5A CTRL_UP 30 | \033[1;5B CTRL_DOWN 31 | \033[1;5C CTRL_RIGHT 32 | \033[1;5D CTRL_LEFT 33 | \033[1;5H CTRL_HOME 34 | \033[1;5F CTRL_END 35 | \033[2;5~ CTRL_INSERT 36 | \033[3;5~ CTRL_DELETE 37 | \033[1;2A SHIFT_UP 38 | \033[1;2B SHIFT_DOWN 39 | \033[1;2C SHIFT_RIGHT 40 | \033[1;2D SHIFT_LEFT 41 | \033[1;2H SHIFT_HOME 42 | \033[1;2F SHIFT_END 43 | \033[2;2~ SHIFT_INSERT 44 | \033[3;2~ SHIFT_DELETE 45 | \033[5;2 SHIFT_PPAGE 46 | \033[6;2 SHIFT_NPAGE 47 | \033[H SHIFT_HOME 48 | \033[F SHIFT_END 49 | \033O2H SHIFT_HOME 50 | \033O2F SHIFT_END 51 | \033[1;6A CTRL_SHIFT_UP 52 | \033[1;6B CTRL_SHIFT_DOWN 53 | \033[1;6C CTRL_SHIFT_RIGHT 54 | \033[1;6D CTRL_SHIFT_LEFT 55 | \033[1;6H CTRL_SHIFT_HOME 56 | \033[1;6F CTRL_SHIFT_END 57 | \033[2;6~ CTRL_SHIFT_INSERT 58 | \033[3;6~ CTRL_SHIFT_DELETE 59 | \177 BACKSPACE 60 | -------------------------------------------------------------------------------- /terminals/rxvt: -------------------------------------------------------------------------------- 1 | \033OH HOME 2 | \033OF END 3 | \033OP F1 4 | \033OQ F2 5 | \033OR F3 6 | \033OS F4 7 | \033[a SHIFT_UP 8 | \033[b SHIFT_DOWN 9 | \033[c SHIFT_RIGHT 10 | \033[d SHIFT_LEFT 11 | \033OA UP 12 | \033OB DOWN 13 | \033OC RIGHT 14 | \033OD LEFT 15 | \033[A UP 16 | \033[B DOWN 17 | \033[C RIGHT 18 | \033[D LEFT 19 | \033[7$ SHIFT_HOME 20 | \033[7@ CTRL_SHIFT_HOME 21 | \033[8$ SHIFT_END 22 | \033[8@ CTRL_SHIFT_END 23 | \033[2^ CTRL_INSERT 24 | \033[2$ SHIFT_INSERT 25 | \033[2@ CTRL_SHIFT_INSERT 26 | \033[3^ CTRL_DELETE 27 | \033[3$ SHIFT_DELETE 28 | \033[7^ CTRL_HOME 29 | \033[8^ CTRL_END 30 | \033[5~ PPAGE 31 | \033[6~ NPAGE 32 | \033[5^ CTRL_PPAGE 33 | \033[6^ CTRL_NPAGE 34 | \033[5@ CTRL_SHIFT_PPAGE 35 | \033[6@ CTRL_SHIFT_NPAGE 36 | \033[7~ HOME 37 | \033[8~ END 38 | \033[Z BACK_TAB 39 | \033[1;5A CTRL_UP 40 | \033[1;5B CTRL_DOWN 41 | \033[1;5C CTRL_RIGHT 42 | \033[1;5D CTRL_LEFT 43 | \033[1;5H CTRL_HOME 44 | \033[1;5F CTRL_END 45 | \033[2;5~ CTRL_INSERT 46 | \033[3;5~ CTRL_DELETE 47 | \033[1;2A SHIFT_UP 48 | \033[1;2B SHIFT_DOWN 49 | \033[1;2C SHIFT_RIGHT 50 | \033[1;2D SHIFT_LEFT 51 | \033[1;2H SHIFT_HOME 52 | \033[1;2F SHIFT_END 53 | \033[2;2~ SHIFT_INSERT 54 | \033[3;2~ SHIFT_DELETE 55 | \033[5;2~ SHIFT_PPAGE 56 | \033[6;2~ SHIFT_NPAGE 57 | \033[H HOME 58 | \033[F END 59 | \033O2A SHIFT_UP 60 | \033O2B SHIFT_DOWN 61 | \033O2C SHIFT_RIGHT 62 | \033O2D SHIFT_LEFT 63 | \033O2H SHIFT_HOME 64 | \033O2F SHIFT_END 65 | \033[2~ CTRL_INSERT 66 | \033[1;6A CTRL_SHIFT_UP 67 | \033[1;6B CTRL_SHIFT_DOWN 68 | \033[1;6C CTRL_SHIFT_RIGHT 69 | \033[1;6D CTRL_SHIFT_LEFT 70 | \033[1;6H CTRL_SHIFT_HOME 71 | \033[1;6F CTRL_SHIFT_END 72 | \033[2;6~ CTRL_SHIFT_INSERT 73 | \033[3;6~ CTRL_SHIFT_DELETE 74 | \033[3~ DELETE 75 | \177 BACKSPACE 76 | \033[7;2~ SHIFT_HOME 77 | \033[8;2~ SHIFT_END 78 | \033[5;5~ CTRL_PPAGE 79 | \033[6;5~ CTRL_NPAGE 80 | \033[7;5~ CTRL_HOME 81 | \033[8;5~ CTRL_END 82 | \033Oa CTRL_UP 83 | \033Ob CTRL_DOWN 84 | \033Od CTRL_LEFT 85 | \033Oc CTRL_RIGHT 86 | \033a ALT_A 87 | \033b ALT_B 88 | \033c ALT_C 89 | \033d ALT_D 90 | \033e ALT_E 91 | \033f ALT_F 92 | \033g ALT_G 93 | \033h ALT_H 94 | \033i ALT_I 95 | \033j ALT_J 96 | \033k ALT_K 97 | \033l ALT_L 98 | \033m ALT_M 99 | \033n ALT_N 100 | \033o ALT_O 101 | \033p ALT_P 102 | \033q ALT_Q 103 | \033r ALT_R 104 | \033s ALT_S 105 | \033t ALT_T 106 | \033u ALT_U 107 | \033v ALT_V 108 | \033w ALT_W 109 | \033x ALT_X 110 | \033y ALT_Y 111 | \033z ALT_Z 112 | -------------------------------------------------------------------------------- /terminals/screen: -------------------------------------------------------------------------------- 1 | \033[H HOME 2 | \033[F END 3 | \033[A UP 4 | \033[B DOWN 5 | \033[C RIGHT 6 | \033[D LEFT 7 | \033[5~ PPAGE 8 | \033[6~ NPAGE 9 | \033OP F1 10 | \033OQ F2 11 | \033OR F3 12 | \033OS F4 13 | \033[3~ DELETE 14 | \033[3$ SHIFT_DELETE 15 | \033[a SHIFT_UP 16 | \033[b SHIFT_DOWN 17 | \033[c SHIFT_RIGHT 18 | \033[d SHIFT_LEFT 19 | \033[1;5H CTRL_HOME 20 | \033[1;5F CTRL_END 21 | \033[1;5A CTRL_UP 22 | \033[1;5B CTRL_DOWN 23 | \033[1;5C CTRL_RIGHT 24 | \033[1;5D CTRL_LEFT 25 | \033[2^ CTRL_INSERT 26 | \033[2@ CTRL_SHIFT_INSERT 27 | \033[5@ CTRL_SHIFT_PPAGE 28 | \033[6@ CTRL_SHIFT_NPAGE 29 | \033[5^ CTRL_PPAGE 30 | \033[6^ CTRL_NPAGE 31 | \033[Z BACK_TAB 32 | \033a ALT_A 33 | \033b ALT_B 34 | \033c ALT_C 35 | \033d ALT_D 36 | \033e ALT_E 37 | \033f ALT_F 38 | \033g ALT_G 39 | \033h ALT_H 40 | \033i ALT_I 41 | \033j ALT_J 42 | \033k ALT_K 43 | \033l ALT_L 44 | \033m ALT_M 45 | \033n ALT_N 46 | \033o ALT_O 47 | \033p ALT_P 48 | \033q ALT_Q 49 | \033r ALT_R 50 | \033s ALT_S 51 | \033t ALT_T 52 | \033u ALT_U 53 | \033v ALT_V 54 | \033w ALT_W 55 | \033x ALT_X 56 | \033y ALT_Y 57 | \033z ALT_Z 58 | -------------------------------------------------------------------------------- /terminals/wsvt25: -------------------------------------------------------------------------------- 1 | \033OH HOME 2 | \033OF END 3 | \033OP F1 4 | \033OQ F2 5 | \033OR F3 6 | \033OS F4 7 | \033[a SHIFT_UP 8 | \033[b SHIFT_DOWN 9 | \033[c SHIFT_RIGHT 10 | \033[d SHIFT_LEFT 11 | \033[A UP 12 | \033[B DOWN 13 | \033[C RIGHT 14 | \033[D LEFT 15 | \033[7$ SHIFT_HOME 16 | \033[7@ CTRL_SHIFT_HOME 17 | \033[8$ SHIFT_END 18 | \033[8@ CTRL_SHIFT_END 19 | \033[2^ CTRL_INSERT 20 | \033[2$ SHIFT_INSERT 21 | \033[2@ CTRL_SHIFT_INSERT 22 | \033[3^ CTRL_DELETE 23 | \033[3$ SHIFT_DELETE 24 | \033[7^ CTRL_HOME 25 | \033[8^ CTRL_END 26 | \033[5~ PPAGE 27 | \033[6~ NPAGE 28 | \033[5^ CTRL_PPAGE 29 | \033[6^ CTRL_NPAGE 30 | \033[5@ CTRL_SHIFT_PPAGE 31 | \033[6@ CTRL_SHIFT_NPAGE 32 | \033[7~ HOME 33 | \033[8~ END 34 | \033[1~ HOME 35 | \033[4~ END 36 | \033[Z BACK_TAB 37 | \033[1;3A SHIFT_UP 38 | \033[1;3B SHIFT_DOWN 39 | \033[1;3C SHIFT_RIGHT 40 | \033[1;3D SHIFT_LEFT 41 | \033[1;5A CTRL_UP 42 | \033[1;5B CTRL_DOWN 43 | \033[1;5C CTRL_RIGHT 44 | \033[1;5D CTRL_LEFT 45 | \033[1;5H CTRL_HOME 46 | \033[1;5F CTRL_END 47 | \033[2;5~ CTRL_INSERT 48 | \033[3;5~ CTRL_DELETE 49 | \033[1;2A SHIFT_UP 50 | \033[1;2B SHIFT_DOWN 51 | \033[1;2C SHIFT_RIGHT 52 | \033[1;2D SHIFT_LEFT 53 | \033[1;2H SHIFT_HOME 54 | \033[1;2F SHIFT_END 55 | \033[2;2~ SHIFT_INSERT 56 | \033[3;2~ SHIFT_DELETE 57 | \033[5;2~ SHIFT_PPAGE 58 | \033[6;2~ SHIFT_NPAGE 59 | \033[H HOME 60 | \033[F END 61 | \033O2A SHIFT_UP 62 | \033O2B SHIFT_DOWN 63 | \033O2C SHIFT_RIGHT 64 | \033O2D SHIFT_LEFT 65 | \033O2H SHIFT_HOME 66 | \033O2F SHIFT_END 67 | \033[2~ CTRL_INSERT 68 | \033[1;6A CTRL_SHIFT_UP 69 | \033[1;6B CTRL_SHIFT_DOWN 70 | \033[1;6C CTRL_SHIFT_RIGHT 71 | \033[1;6D CTRL_SHIFT_LEFT 72 | \033[1;6H CTRL_SHIFT_HOME 73 | \033[1;6F CTRL_SHIFT_END 74 | \033[2;6~ CTRL_SHIFT_INSERT 75 | \033[3;6~ CTRL_SHIFT_DELETE 76 | \033[3~ DELETE 77 | \177 BACKSPACE 78 | \033[7;2~ SHIFT_HOME 79 | \033[8;2~ SHIFT_END 80 | \033[5;5~ CTRL_PPAGE 81 | \033[6;5~ CTRL_NPAGE 82 | \033[7;5~ CTRL_HOME 83 | \033[8;5~ CTRL_END 84 | \033Oa CTRL_UP 85 | \033Ob CTRL_DOWN 86 | \033Od CTRL_LEFT 87 | \033Oc CTRL_RIGHT 88 | 89 | \033a ALT_A 90 | \033b ALT_B 91 | \033c ALT_C 92 | \033d ALT_D 93 | \033e ALT_E 94 | \033f ALT_F 95 | \033g ALT_G 96 | \033h ALT_H 97 | \033i ALT_I 98 | \033j ALT_J 99 | \033k ALT_K 100 | \033l ALT_L 101 | \033m ALT_M 102 | \033n ALT_N 103 | \033o ALT_O 104 | \033p ALT_P 105 | \033q ALT_Q 106 | \033r ALT_R 107 | \033s ALT_S 108 | \033t ALT_T 109 | \033u ALT_U 110 | \033v ALT_V 111 | \033w ALT_W 112 | \033x ALT_X 113 | \033y ALT_Y 114 | \033z ALT_Z 115 | -------------------------------------------------------------------------------- /terminals/xterm-1002: -------------------------------------------------------------------------------- 1 | xterm-color -------------------------------------------------------------------------------- /terminals/xterm-color: -------------------------------------------------------------------------------- 1 | # NumLock off behaves as NumLock on 2 | \033Oo KEY('/') 3 | \033Oj KEY('*') 4 | \033Om KEY('-') 5 | \033Ow KEY('7') 6 | \033Ox KEY('8') 7 | \033Oy KEY('9') 8 | \033Ok KEY('+') 9 | \033Ot KEY('4') 10 | \033Ou KEY('5') 11 | \033Ov KEY('6') 12 | \033Oq KEY('1') 13 | \033Or KEY('2') 14 | \033Os KEY('3') 15 | \033OM ENTER 16 | \033Op KEY('0') 17 | \033On KEY('.') 18 | 19 | # Original NumLock behavior if you like it 20 | #\033Oo KEY('/') 21 | #\033Oj KEY('*') 22 | #\033Om KEY('-') 23 | #\033Ow HOME 24 | #\033Ox UP 25 | #\033Oy PPAGE 26 | #\033Ok KEY('+') 27 | #\033Ot LEFT 28 | #\033Ou KEY('5') 29 | #\033Ov RIGHT 30 | #\033Oq END 31 | #\033Or DOWN 32 | #\033Os NPAGE 33 | #\033OM ENTER 34 | #\033Op INSERT 35 | #\033On DELETE 36 | 37 | # set '5 with NumLock off' in xterm to a harmless key 38 | \033OE SELECT 39 | 40 | \033OH HOME 41 | \033OF END 42 | \033OP F1 43 | \033OQ F2 44 | \033OR F3 45 | \033OS F4 46 | \033[11~ F1 47 | \033[12~ F2 48 | \033[13~ F3 49 | \033[14~ F4 50 | \033[a SHIFT_UP 51 | \033[b SHIFT_DOWN 52 | \033[c SHIFT_RIGHT 53 | \033[d SHIFT_LEFT 54 | \033[A SHIFT_UP 55 | \033[B SHIFT_DOWN 56 | \033[C SHIFT_RIGHT 57 | \033[D SHIFT_LEFT 58 | \033[7$ SHIFT_HOME 59 | \033[7@ CTRL_SHIFT_HOME 60 | \033[8$ SHIFT_END 61 | \033[8@ CTRL_SHIFT_END 62 | \033[2^ CTRL_INSERT 63 | \033[2$ SHIFT_INSERT 64 | \033[2@ CTRL_SHIFT_INSERT 65 | \033[3^ CTRL_DELETE 66 | \033[3$ SHIFT_DELETE 67 | \033[7^ CTRL_HOME 68 | \033[8^ CTRL_END 69 | \033[5~ PPAGE 70 | \033[6~ NPAGE 71 | \033[5^ CTRL_PPAGE 72 | \033[6^ CTRL_NPAGE 73 | \033[5@ CTRL_SHIFT_PPAGE 74 | \033[6@ CTRL_SHIFT_NPAGE 75 | \033[7~ HOME 76 | \033[8~ END 77 | \033[1~ HOME 78 | \033[4~ END 79 | \033[Z BACK_TAB 80 | \033[1;3A SHIFT_UP 81 | \033[1;3B SHIFT_DOWN 82 | \033[1;3C SHIFT_RIGHT 83 | \033[1;3D SHIFT_LEFT 84 | \033[1;5A CTRL_UP 85 | \033[1;5B CTRL_DOWN 86 | \033[1;5C CTRL_RIGHT 87 | \033[1;5D CTRL_LEFT 88 | \033[1;5H CTRL_HOME 89 | \033[1;5F CTRL_END 90 | \033[2;5~ CTRL_INSERT 91 | \033[3;5~ CTRL_DELETE 92 | \033[1;2A SHIFT_UP 93 | \033[1;2B SHIFT_DOWN 94 | \033[1;2C SHIFT_RIGHT 95 | \033[1;2D SHIFT_LEFT 96 | \033[1;2H SHIFT_HOME 97 | \033[1;2F SHIFT_END 98 | \033[2;2~ SHIFT_INSERT 99 | \033[3;2~ SHIFT_DELETE 100 | \033[5;2~ SHIFT_PPAGE 101 | \033[6;2~ SHIFT_NPAGE 102 | \033[H HOME 103 | \033[F END 104 | \033O2A SHIFT_UP 105 | \033O2B SHIFT_DOWN 106 | \033O2C SHIFT_RIGHT 107 | \033O2D SHIFT_LEFT 108 | \033O2H SHIFT_HOME 109 | \033O2F SHIFT_END 110 | \033[2~ CTRL_INSERT 111 | \033[1;6A CTRL_SHIFT_UP 112 | \033[1;6B CTRL_SHIFT_DOWN 113 | \033[1;6C CTRL_SHIFT_RIGHT 114 | \033[1;6D CTRL_SHIFT_LEFT 115 | \033[1;6H CTRL_SHIFT_HOME 116 | \033[1;6F CTRL_SHIFT_END 117 | \033[2;6~ CTRL_SHIFT_INSERT 118 | \033[3;6~ CTRL_SHIFT_DELETE 119 | \033[3~ DELETE 120 | \177 BACKSPACE 121 | \033[7;2~ SHIFT_HOME 122 | \033[8;2~ SHIFT_END 123 | \033[5;5~ CTRL_PPAGE 124 | \033[6;5~ CTRL_NPAGE 125 | \033[7;5~ CTRL_HOME 126 | \033[8;5~ CTRL_END 127 | \033Oa CTRL_UP 128 | \033Ob CTRL_DOWN 129 | \033Od CTRL_LEFT 130 | \033Oc CTRL_RIGHT 131 | 132 | \033a ALT_A 133 | \033b ALT_B 134 | \033c ALT_C 135 | \033d ALT_D 136 | \033e ALT_E 137 | \033f ALT_F 138 | \033g ALT_G 139 | \033h ALT_H 140 | \033i ALT_I 141 | \033j ALT_J 142 | \033k ALT_K 143 | \033l ALT_L 144 | \033m ALT_M 145 | \033n ALT_N 146 | \033o ALT_O 147 | \033p ALT_P 148 | \033q ALT_Q 149 | \033r ALT_R 150 | \033s ALT_S 151 | \033t ALT_T 152 | \033u ALT_U 153 | \033v ALT_V 154 | \033w ALT_W 155 | \033x ALT_X 156 | \033y ALT_Y 157 | \033z ALT_Z 158 | -------------------------------------------------------------------------------- /tools/GenHeaders: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if echo "hello" | grep --text "hello" &>/dev/null 4 | then 5 | GREP="grep --text" 6 | else 7 | GREP="grep" 8 | fi 9 | 10 | which tac &> /dev/null || tac() { 11 | local a=() 12 | local i=0 13 | while read line 14 | do 15 | a[i]="$line" 16 | i=$[i+1] 17 | done < "$1" 18 | for ((j = i - 1; j >= 0; j--)) 19 | do 20 | echo "${a[$j]}" 21 | done 22 | } 23 | 24 | process() { 25 | grep -q "^$1$" order.txt &> /dev/null && return 26 | for need in `cat "$1" | $GREP '//#needs ' | sed 's,//#needs ,,'` 27 | do process $need.c "$2" 28 | done 29 | "$2" "$1" 30 | processed=("${processed[@]}" "$1") 31 | echo "$1" >> order.txt 32 | } 33 | 34 | do_all() { 35 | if [ -e order.txt ] 36 | then 37 | for i in `cat order.txt` 38 | do "$1" "$i" 39 | done 40 | else 41 | processed=( ) 42 | for i in *.c 43 | do process "$i" "$1" 44 | done 45 | fi 46 | } 47 | 48 | if [ "$1" = "Prototypes.h" ] 49 | then 50 | 51 | new="Prototypes.h.new" 52 | old="Prototypes.h" 53 | 54 | ################################ 55 | echo -n "Function prototypes..." 56 | ################################ 57 | 58 | echo "#ifndef Prototypes_HEADER" > "$new" 59 | echo "#define Prototypes_HEADER" >> "$new" 60 | echo >> "$new" 61 | echo '#define _GNU_SOURCE' >> "$new" 62 | echo '#include ' >> "$new" 63 | echo '#include ' >> "$new" 64 | echo '#include ' >> "$new" 65 | echo '#include ' >> "$new" 66 | echo >> "$new" 67 | echo '#include "Structures.h"' >> "$new" 68 | echo >> "$new" 69 | 70 | includes() { 71 | cat "$1" | $GREP "^#include" 72 | } 73 | 74 | defines() { 75 | cat "$1" | $GREP "^#define Display_.*" 76 | } 77 | 78 | proto() { 79 | cat "$1" | grep -v "#include" | cpp 2> /dev/null |\ 80 | $GREP -i -v "^static" | grep '^[^ ].*) {$' |\ 81 | sed 's,) {$,);,;s,inline,,' >> "$new" 82 | } 83 | 84 | { 85 | if [ `ls *.c | wc -l` != `cat order.txt | wc -l` ] 86 | then rm -f order.txt 87 | fi 88 | } &> /dev/null 89 | 90 | do_all includes | sort -u | tac >> "$new" 91 | do_all proto 92 | echo "#if HAVE_CURSES" >> "$new" 93 | do_all defines >> "$new" 94 | echo "#endif" >> "$new" 95 | 96 | echo >> "$new" 97 | echo '#include ' >> "$new" 98 | echo '#include "debug.h"' >> "$new" 99 | echo '#include ' >> "$new" 100 | echo >> "$new" 101 | echo "#endif" >> "$new" 102 | 103 | else 104 | 105 | new="Structures.h.new" 106 | old="Structures.h" 107 | 108 | ####################### 109 | echo -n "Structures..." 110 | ####################### 111 | 112 | echo "#ifndef Structures_HEADER" > "$new" 113 | echo "#define Structures_HEADER" >> "$new" 114 | echo "#include \"config.h\"" >> "$new" 115 | echo >> "$new" 116 | 117 | cat *.c | gawk ' 118 | BEGIN { 119 | reading=0 120 | } 121 | /\/*{/ { 122 | reading=1 123 | } 124 | /}*\// { 125 | reading=0 126 | } 127 | /^struct .* {$/ { 128 | if (reading) 129 | print "typedef struct " $2 " " substr($2, 1, length($2)-1) ";" 130 | } 131 | ' >> "$new" 132 | 133 | struct() { 134 | cat "$1" | gawk ' 135 | BEGIN { 136 | writing=0 137 | } 138 | /\/\*{/ { 139 | writing=1 140 | } 141 | /}\*\// { 142 | writing=0 143 | } 144 | { 145 | if (writing==1) 146 | writing=2 147 | else if (writing == 2) 148 | print 149 | } 150 | ' >> "$new" 151 | } 152 | 153 | do_all struct 154 | 155 | echo "#endif" >> "$new" 156 | 157 | fi 158 | 159 | #### 160 | echo 161 | #### 162 | 163 | if [ -e "$old" ] 164 | then 165 | if ! diff -q "$new" "$old" 166 | then mv -f "$new" "$old" 167 | fi 168 | else 169 | mv -f "$new" "$old" 170 | fi 171 | --------------------------------------------------------------------------------