diff options
-rw-r--r-- | core/.buffer.luadoc | 8 | ||||
-rw-r--r-- | doc/manual.md | 4 | ||||
-rw-r--r-- | init.lua | 12 | ||||
-rw-r--r-- | src/Makefile | 2 |
4 files changed, 15 insertions, 11 deletions
diff --git a/core/.buffer.luadoc b/core/.buffer.luadoc index ff5427e3..f1b42a11 100644 --- a/core/.buffer.luadoc +++ b/core/.buffer.luadoc @@ -3122,15 +3122,13 @@ function set_lexer(buffer, lexer) end -- User themes override Textadept's default themes when they have the same name. -- If *name* contains slashes, it is assumed to be an absolute path to a theme -- instead of a theme name. --- Note: this function must be called on startup in order to be effective. Once --- set, it applies to all subsequent buffers, so additional calls are --- unnecessary. +-- @param buffer A buffer. -- @param name The name or absolute path of a theme to set. -- @param props Optional table of theme property assignments that override the -- theme's defaults. --- @usage buffer.set_theme('light', {font = 'Monospace', fontsize = 12}) +-- @usage buffer:set_theme('light', {font = 'Monospace', fontsize = 12}) -- @name set_theme -function set_theme(name, props) end +function set_theme(buffer, name, props) end -- Unused Fields. -- * annotation_style_offset diff --git a/doc/manual.md b/doc/manual.md index 2fa76425..fcd5c51a 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -1284,7 +1284,7 @@ display these standard colors (which may be completely different in the end). Override the default theme in your [*~/.textadept/init.lua*](#User.Init) using the [`buffer.set_theme()`][] function. For example: - buffer.set_theme(not CURSES and 'dark' or 'term') + buffer:set_theme(not CURSES and 'dark' or 'term') Either restart Textadept for changes to take effect or type [`reset`][] in the [command entry](#Lua.Command.Entry). @@ -1292,7 +1292,7 @@ Either restart Textadept for changes to take effect or type [`reset`][] in the `buffer.set_theme()` can also tweak theme properties like font face and font size without editing the theme file itself: - buffer.set_theme('light', {font = 'Monospace', fontsize = 12}) + buffer:set_theme('light', {font = 'Monospace', fontsize = 12}) You can even tweak themes on a per-language basis. For example, in order to color Java functions black instead of the default orange, add the following to @@ -14,14 +14,20 @@ package.cpath = table.concat({ textadept = require('textadept') -- Documentation is in core/.buffer.luadoc. -function buffer.set_theme(name, props) +local function set_theme(buffer, name, props) + --[[Temporary compatibility notice for Textadept 10 alpha 3.]]if type(buffer) == 'string' then events.connect(events.INITIALIZED, function() ui.print('Textadept 10 Compatibility Notice: buffer.set_theme() should be called as buffer:set_theme(). Please update your ~/.textadept/init.lua accordingly.') end) buffer, name, props = _G.buffer, buffer, name end name = name:find('[/\\]') and name or package.searchpath(name, _USERHOME..'/themes/?.lua;'.. _HOME..'/themes/?.lua') if not name or not lfs.attributes(name) then return end + local orig_buffer = _G.buffer -- may not be equivalent to buffer argument + _G.buffer = buffer dofile(name) + _G.buffer = orig_buffer for prop, value in pairs(props or {}) do buffer.property[prop] = value end end +events.connect(events.BUFFER_NEW, function() buffer.set_theme = set_theme end) +buffer.set_theme = set_theme -- needed for the first buffer -- On reset, _LOADED['lexer'] is removed. Force a reload in order for set_theme -- to work properly. if not arg then view:goto_buffer(buffer) end @@ -71,7 +77,7 @@ end -- Default buffer settings. local buffer = buffer -buffer.set_theme(not CURSES and 'light' or 'term') +buffer:set_theme(not CURSES and 'light' or 'term') buffer.FIND_REGEXP = buffer.FIND_REGEXP + buffer.FIND_CXX11REGEX @@ -256,7 +262,7 @@ buffer.wrap_mode = buffer.WRAP_NONE buffer.accessibility = buffer.ACCESSIBILITY_DISABLED -- Temporary compatibility notices for Textadept 10. -function ui.set_theme(...) events.connect(events.INITIALIZED, function() ui.print('Textadept 10 Compatibility Notice: ui.set_theme() is now buffer.set_theme(). Please update your ~/.textadept/init.lua accordingly.') end) buffer.set_theme(...) end +function ui.set_theme(...) events.connect(events.INITIALIZED, function() ui.print('Textadept 10 Compatibility Notice: ui.set_theme() is now buffer:set_theme(). Please update your ~/.textadept/init.lua accordingly.') end) buffer:set_theme(...) end events.connect(events.INITIALIZED, function() if lfs.attributes(_USERHOME..'/properties.lua') then ui.print('Textadept 10 Compatibility Notice: textadept/properties.lua is not read anymore. Please move its contents to ~/.textadept/init.lua.') end end) -- Load user init file, which may also define default buffer settings. diff --git a/src/Makefile b/src/Makefile index 50dc6bce..926d9a9b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -401,7 +401,7 @@ else lspawn_url = http://foicica.com/hg/lspawn/archive/tip.zip endif -scintilla_zip = 80bcec2634db.zip +scintilla_zip = 2b68221be146.zip lua_tgz = lua-5.3.4.tar.gz lpeg_tgz = lpeg-1.0.0.tar.gz lfs_zip = v_1_6_3.zip |