aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--modules/cpp/api135
-rw-r--r--modules/cpp/commands.lua28
-rw-r--r--modules/cpp/init.lua31
-rw-r--r--modules/cpp/snippets.lua76
4 files changed, 270 insertions, 0 deletions
diff --git a/modules/cpp/api b/modules/cpp/api
new file mode 100644
index 00000000..e5a54201
--- /dev/null
+++ b/modules/cpp/api
@@ -0,0 +1,135 @@
+abort()
+abs(int n)
+acos(double x)
+asctime(const struct tm* tp)
+asin(double x)
+assert(int expression)
+atan(double x)
+atan2(double y, double x)
+atexit(void (*fcm)(void))
+atof(const char* s)
+atoi(const char* s)
+atol(const char* s)
+bsearch(const void* key, const void* base, size_t n, size_t size, int (*cmp)(const void* keyval, const void* datum))
+calloc(size_t nobj, size_t size)
+ceil(double x)
+clearerr(FILE* stream)
+clock(void)
+cos(double x)
+cosh(double x)
+ctime(const time_t* tp)
+difftime(time_t time2, time_t time1)
+div(int num, int denom)
+exit(int status)
+exp(double x)
+fabs(double x)
+fclose(FILE* stream)
+feof(FILE* stream)
+ferror(FILE* stream)
+fflush(FILE* stream)
+fgetc(FILE* stream)
+fgetpos(FILE* stream, fpos_t* ptr)
+fgets(char* s, int n, FILE* stream)
+floor(double x)
+fmod(double x, double y)
+fopen(const char* filename, const char* mode)
+fprintf(FILE* stream, const char* format, ...)
+fputc(int c, FILE* stream)
+fputs(const char* s, FILE* stream)
+fread(void* ptr, size_t size, size_t nobj, FILE* stream)
+free(void* p)
+freopen(const char* filename, const char* mode, FILE* stream)
+frexp(double x, int* exp)
+fscanf(FILE* stream, const char* format, ...)
+fseek(FILE* stream, long offset, int origin)
+fsetpos(FILE* stream, const fpos_t* ptr)
+ftell(FILE* stream)
+fwrite(const void* ptr, size_t size, size_t nobj, FILE* stream)
+getc(FILE* stream)
+getchar(void)
+getenv(const char* name)
+gets(char* s)
+gmtime(const time_t* tp)
+isalnum(int c)
+isalpha(int c)
+iscntrl(int c)
+isdigit(int c)
+isgraph(int c)
+islower(int c)
+isprint(int c)
+ispunct(int c)
+isspace(int c)
+isupper(int c)
+isxdigit(int c)
+labs(long n)
+ldexp(double x, int n)
+ldiv(long num, long denom)
+localtime(const time_t* tp)
+log(double x)
+log10(double x)
+malloc(size_t size)
+memchr(const void* cs, int c, size_t n)
+memcmp(const void* cs, const void* ct, size_t n)
+memcpy(void* s, const void* ct, size_t n)
+memmove(void* s, const void* ct, size_t n)
+memset(void* s, int c, size_t n)
+mktime(struct tm* tp)
+modf(double x, double* ip)
+perror(const char* s)
+pow(double x, double y)
+printf(const char* format, ...)
+putc(int c, FILE* stream)
+putchar(int c)
+puts(const char* s)
+qsort(void* base, size_t n, size_t size, int (*cmp)(const void*, const void*))
+raise(int sig)
+rand(void)
+realloc(void* p, size_t size)
+remove(const char* filename)
+rename(const char* oldname, const char* newname)
+rewind(FILE* stream)
+scanf(const char* format, ...)
+setbuf(FILE* stream, char* buf)
+setvbuf(FILE* stream, char* buf, int mode, size_t size)
+sin(double x)
+sinh(double x)
+sprintf(char* s, const char* format, ...)
+sqrt(double x)
+srand(unsigned int seed)
+sscanf(char* s, const char* format, ...)
+strcat(char* s, const char* ct)
+strchr(const char* cs, int c)
+strcspn(const char* cs, const char* ct)
+strcmp(const char* cs, const char* ct)
+strcoll(const char* cs, const char* ct)
+strcpy(char* s, const char* ct)
+strerror(int n)
+strftime(char* s, size_t smax, const char* fmt, const struct tm* tp)
+strlen(const char* cs)
+strncat(char* s, const char* ct, size_t n)
+strncmp(const char* cs, const char* ct, size_t n)
+strncpy(char* s, const char* ct, size_t n)
+strpbrk(const char* cs, const char* ct)
+strrchr(const char* cs, int c)
+strspn(const char* cs, const char* ct)
+strstr(const char* cs, const char* ct)
+strtod(const char* s, char** endp)
+strtok(char* s, const char* t)
+strtol(const char* s, char** endp, int base)
+strtoul(const char* s, char** endp, int base)
+strxfrm(char* s, const char* ct, size_t n)
+system(const char* s)
+tan(double x)
+tanh(double x)
+time(time_t* tp)
+tmpfile()
+tmpname(char s[L_tmpnam])
+tolower(int c)
+toupper(int c)
+ungetc(int c, FILE* stream)
+va_arg(va_list ap, type)
+va_end(va_list ap)
+va_start(va_list ap, lastarg)
+vfprintf(FILE* stream, const char* format, va_list arg)
+vprintf(const char* format, va_list arg)
+vsprintf(char* s, const char* format, va_list arg)
diff --git a/modules/cpp/commands.lua b/modules/cpp/commands.lua
new file mode 100644
index 00000000..25fa3584
--- /dev/null
+++ b/modules/cpp/commands.lua
@@ -0,0 +1,28 @@
+-- Copyright 2007 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+
+---
+-- Commands for the cpp module.
+module('modules.cpp.commands', package.seeall)
+
+-- C++-specific key commands.
+local keys = _G.keys
+if type(keys) == 'table' then
+ local m_editing = modules.textadept.editing
+ local m_handlers = textadept.handlers
+ keys.cpp = {
+ al = { textadept.io.open, _HOME..'/modules/cpp/init.lua' },
+ ['s\n'] = { function()
+ buffer:line_end()
+ buffer:add_text(';')
+ buffer:new_line()
+ end },
+ cq = { m_editing.block_comment, '//~' },
+ ['('] = { function()
+--~ buffer.word_chars =
+--~ '_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ m_editing.show_call_tip(modules.cpp.api, true)
+--~ buffer:set_chars_default()
+ return false
+ end },
+ }
+end
diff --git a/modules/cpp/init.lua b/modules/cpp/init.lua
new file mode 100644
index 00000000..22ccf21d
--- /dev/null
+++ b/modules/cpp/init.lua
@@ -0,0 +1,31 @@
+-- Copyright 2007 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+
+---
+-- The cpp module.
+-- It provides utilities for editing C/C++ code.
+module('modules.cpp', package.seeall)
+
+if type(_G.snippets) == 'table' then
+---
+-- Container for C/C++-specific snippets.
+-- @class table
+-- @name snippets.cpp
+ _G.snippets.cpp = {}
+end
+
+if type(_G.keys) == 'table' then
+---
+-- Container for C/C++-specific key commands.
+-- @class table
+-- @name keys.cpp
+ _G.keys.cpp = {}
+end
+
+require 'cpp.commands'
+require 'cpp.snippets'
+
+function set_buffer_properties()
+
+end
+
+api = textadept.io.read_api_file(_HOME..'/modules/cpp/api', '%w_')
diff --git a/modules/cpp/snippets.lua b/modules/cpp/snippets.lua
new file mode 100644
index 00000000..ac4a7955
--- /dev/null
+++ b/modules/cpp/snippets.lua
@@ -0,0 +1,76 @@
+-- Copyright 2007 Mitchell mitchell<att>caladbolg.net. See LICENSE.
+
+---
+-- Snippets for the cpp module.
+module('modules.cpp.snippets', package.seeall)
+
+local snippets = _G.snippets
+
+if type(snippets) == 'table' then
+ snippets.cpp = {
+ rc = 'reinterpret_cast<${1:}>(${2:$(selected_text)})',
+ sc = 'static_cast<${1:}>(${2:$(selected_text)})',
+ cc = 'const_cast<${1:}>(${2:$(selected_text)})',
+
+ -- Lua snippets
+ lf = 'static int ${1:function}(lua_State *${2:lua}) {\n ${0}\n return 0;\n}',
+ lff = 'LF ${1:function}(lua_State *${2:lua}) {\n ${0}\n return 0;\n}',
+ ls = 'lua_State',
+ lgf = 'lua_getfield(${1:lua}, ${2:-1}, ${3:field});',
+ lgg = 'lua_getglobal(${1:lua}, ${2:global});',
+ lgt = 'lua_gettable(${1:lua}, ${2:-2});',
+ ltop = 'lua_gettop(${1:lua});',
+ lib = 'lua_isboolean(${1:lua}, ${2:-1});',
+ licf = 'lua_iscfunction(${1:lua}, ${2:-1});',
+ lif = 'lua_isfunctionu(${1:lua}, ${2:-1});',
+ linil = 'lua_isnil(${1:lua}, ${2:-1});',
+ linone = 'lua_isnone(${1:lua}, ${2:-1});',
+ linonen = 'lua_isnoneornil(${1:lua}, ${2:-1});',
+ lin = 'lua_isnumber(${1:lua}, ${2:-1});',
+ lis = 'lua_isstring(${1:lua}, ${2:-1});',
+ lit = 'lua_istable(${1:lua}, ${2:-1});',
+ lith = 'lua_isthread(${1:lua}, ${2:-1});',
+ liu = 'lua_isuserdata(${1:lua}, ${2:-1});',
+ llen = 'lua_objlen(${1:lua}, ${2:-1});',
+ lpop = 'lua_pop(${1:lua}, ${2:1});',
+ lpb = 'lua_pushboolean(${1:lua}, ${2:boolean});',
+ lpcc = 'lua_pushcclosure(${1:lua}, ${2:closure_func}, ${3:num_values});',
+ lpcf = 'lua_pushcfunction(${1:lua}, ${2:cfunction});',
+ lpi = 'lua_pushinteger(${1:lua}, ${2:integer});',
+ lplu = 'lua_pushlightuserdata(${1:lua}, ${2:userdata});',
+ lpnil = 'lua_pushnil(${1:lua});',
+ lpn = 'lua_pushnumber(${1:lua}, ${2:number});',
+ lps = 'lua_pushstring(${1:lua}, ${2:string});',
+ lpth = 'lua_pushthread(${1:lua});',
+ lpv = 'lua_pushvalue(${1:lua}, ${2:-1});',
+ lrg = 'lua_rawget(${1:lua}, ${2:-2});',
+ lrgi = 'lua_rawgeti(${1:lua}, ${2:-2}, ${3:1});',
+ lrs = 'lua_rawset(${1:lua}, ${2:-3});',
+ lrsi = 'lua_rawseti(${1:lua}, ${2:-2}, ${3:1});',
+ lr = 'lua_register(${1:lua}, ${2:fname}, ${3:cfunction});',
+ lsf = 'lua_setfield(${1:lua}, ${2:-2}, ${3:field});',
+ lsg = 'lua_setglobal(${1:lua}, ${2:-2}, ${3:global});',
+ lst = 'lua_settable(${1:lua}, ${2:-3});',
+ ltb = 'lua_toboolean(${1:lua}, ${2:-1});',
+ ltcf = 'lua_tocfunction(${1:lua}, ${2:-1});',
+ lti = 'lua_tointeger(${1:lua}, ${2:-1});',
+ ltn = 'lua_tonumber(${1:lua}, ${2:-1});',
+ ltp = 'lua_topointer(${1:lua}, ${2:-1});',
+ lts = 'lua_tostring(${1:lua}, ${2:-1});',
+ ltth = 'lua_tothread(${1:lua}, ${2:-1});',
+ ltu = 'lua_touserdata(${1:lua}, ${2:-1});',
+ lt = 'lua_type(${1:lua}, ${2:-1});',
+ llcint = 'luaL_checkint(${1:lua}, ${2:-1});',
+ llci = 'luaL_checkinteger(${1:lua}, ${2:-1});',
+ llcl = 'luaL_checklong(${1:lua}, ${2:-1});',
+ llcn = 'luaL_checknumber(${1:lua}, ${2:-1});',
+ llcs = 'luaL_checkstring(${1:lua}, ${2:-1});',
+ llcu = 'luaL_checkudata(${1:lua}, ${2:-1}, ${3:mt_name});',
+ llerr = 'luaL_error(${1:lua}, ${2:errorstring}${3:, ${4:arg}});',
+ lloint = 'luaL_optint(${1:lua}, ${2:-1}, ${3:default});',
+ lloi = 'luaL_optinteger(${1:lua}, ${2:-1}, ${3:default});',
+ llol = 'luaL_optlong(${1:lua}, ${2:-1}, ${3:default});',
+ llon = 'luaL_optnumber(${1:lua}, ${2:-1}, ${3:default});',
+ llos = 'luaL_optstring(${1:lua}, ${2:-1}, ${3:default});',
+ }
+end