diff options
author | 2007-08-06 05:05:37 -0400 | |
---|---|---|
committer | 2007-08-06 05:05:37 -0400 | |
commit | 9cb58b78ef4f67201f3ff2b506307292fde8560a (patch) | |
tree | e421062cba6d7c3699097118da11520cef9dd5e6 | |
parent | 9f18f8ab9acce36399aa34c1f11c966b792f3d2f (diff) | |
download | textadept-9cb58b78ef4f67201f3ff2b506307292fde8560a.tar.gz textadept-9cb58b78ef4f67201f3ff2b506307292fde8560a.zip |
Initial import of utility scripts.
-rwxr-xr-x | gen_iface.lua | 59 | ||||
-rwxr-xr-x | modules/new | 68 |
2 files changed, 127 insertions, 0 deletions
diff --git a/gen_iface.lua b/gen_iface.lua new file mode 100755 index 00000000..c8320cb9 --- /dev/null +++ b/gen_iface.lua @@ -0,0 +1,59 @@ +#!/usr/bin/lua +-- Copyright 2007 Mitchell mitchell<att>caladbolg.net. See LICENSE. + +local f = io.open('/usr/share/scite-st/src/scite/src/IFaceTable.cxx') +local contents = f:read('*all') +f:close() + +local constants = contents:match('ifaceConstants%[%] = (%b{})') +local functions = contents:match('ifaceFunctions%[%] = (%b{})') +local properties = contents:match('ifaceProperties%[%] = (%b{})') + +local out = '' + +local types = { + void = 0, int = 1, length = 2, position = 3, colour = 4, bool = 5, + keymod = 6, string = 7, stringresult = 8, cells = 9, textrange = 10, + findtext = 11, formatrange = 12 +} + +out = out..'textadept.constants = {\n' +-- {"constant", value} +for item in constants:sub(2, -2):gmatch('%b{}') do + local name, value = item:match('^{"(.-)",(.-)}') + local line = (" %s = %s,\n"):format(name, value) + out = out..line +end +out = out..'}\n\n' + +out = out..'textadept.buffer_functions = {\n' +-- {"function", msg_id, iface_*, {iface_*, iface_*}} +for item in functions:sub(2, -2):gmatch('%b{}') do + local name, msg_id, rt_type, p1_type, p2_type = + item:match('^{"(.-)"%D+(%d+)%A+iface_(%a+)%A+iface_(%a+)%A+iface_(%a+)') + name = name:gsub('([a-z])([A-Z])', '%1_%2') + name = name:gsub('([A-Z])([A-Z][a-z])', '%1_%2') + name = name:lower() + local line = (" %s = {%d, %d, %d, %d},\n"):format( + name, msg_id, types[rt_type], types[p1_type], types[p2_type]) + out = out..line +end +out = out..'}\n\n' + +out = out..'textadept.buffer_properties = {\n' +-- {"property", get_id, set_id, rt_type, p1_type} +for item in properties:sub(2, -2):gmatch('%b{}') do + local name, get_id, set_id, rt_type, p1_type = + item:match('^{"(.-)"%D+(%d+)%D+(%d+)%A+iface_(%a+)%A+iface_(%a+)') + name = name:gsub('([a-z])([A-Z])', '%1_%2') + name = name:gsub('([A-Z])([A-Z][a-z])', '%1_%2') + name = name:lower() + local line = (" %s = {%d, %d, %d, %d},\n"):format( + name, get_id, set_id, types[rt_type], types[p1_type]) + out = out..line +end +out = out..'}\n' + +f = io.open('/usr/share/textadept/lib/iface.lua', 'w') +f:write(out) +f:close() diff --git a/modules/new b/modules/new new file mode 100755 index 00000000..18f23902 --- /dev/null +++ b/modules/new @@ -0,0 +1,68 @@ +#!/bin/sh + +# usage: +# ./new [module_name] [language_name] + +mkdir $1 + +cat > $1/init.lua <<_EOF +-- Copyright 2007 Mitchell mitchell<att>caladbolg.net. See LICENSE. + +--- +-- The $1 module. +-- It provides utilities for editing $2 code. +module('modules.$1', package.seeall) + +if type(_G.snippets) == 'table' then +--- +-- Container for $2-specific snippets. +-- @class table +-- @name snippets.$1 + _G.snippets.$1 = {} +end + +if type(_G.keys) == 'table' then +--- +-- Container for $2-specific key commands. +-- @class table +-- @name keys.$1 + _G.keys.$1 = {} +end + +require '$1.commands' +require '$2.snippets' + +function set_buffer_properties() + +end +_EOF + +cat > $1/snippets.lua <<_EOF +-- Copyright 2007 Mitchell mitchell<att>caladbolg.net. See LICENSE. + +--- +-- Snippets for the $1 module. +module('modules.$1.snippets', package.seeall) + +local snippets = _G.snippets + +if type(snippets) == 'table' then + snippets.$1 = {} +end +_EOF + +cat > $1/commands.lua <<_EOF +-- Copyright 2007 Mitchell mitchell<att>caladbolg.net. See LICENSE. + +--- +-- Commands for the $1 module. +module('modules.$1.commands', package.seeall) + +-- $2-specific key commands. +local keys = _G.keys +if type(keys) == 'table' then + keys.$1 = { + al = { textadept.io.open, _HOME..'/modules/$1/init.lua' }, + } +end +_EOF |