aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/textadept/adeptsense.lua2
-rw-r--r--modules/textadept/file_types.lua15
-rw-r--r--modules/textadept/keys.lua2
3 files changed, 9 insertions, 10 deletions
diff --git a/modules/textadept/adeptsense.lua b/modules/textadept/adeptsense.lua
index 8f4bdacd..2898bc0c 100644
--- a/modules/textadept/adeptsense.lua
+++ b/modules/textadept/adeptsense.lua
@@ -470,7 +470,7 @@ function M.get_class(sense, symbol)
if class then
-- The type declaration should not be in a comment or string.
local pos = buffer:position_from_line(i)
- local style = buffer:get_style_name(buffer.style_at[pos + s - 1])
+ local style = buffer.style_name[buffer.style_at[pos + s - 1]]
if style ~= 'comment' and style ~= 'string' then break end
class = nil
end
diff --git a/modules/textadept/file_types.lua b/modules/textadept/file_types.lua
index d4f6df57..c34ab0e3 100644
--- a/modules/textadept/file_types.lua
+++ b/modules/textadept/file_types.lua
@@ -98,17 +98,16 @@ local function set_lexer(buffer, lang)
buffer:colourise(0, buffer:position_from_line(last_line + 1))
end
--- LuaDoc is in core/.buffer.luadoc.
-local function get_style_name(buffer, style_num)
- buffer:check_global()
- if style_num < 0 or style_num > 255 then error('0 <= style_num < 256') end
- return buffer:private_lexer_call(style_num)
-end
-
-- Gives new buffers lexer-specific functions.
local function set_lexer_functions()
buffer.get_lexer, buffer.set_lexer = get_lexer, set_lexer
- buffer.get_style_name = get_style_name
+ buffer.style_name = setmetatable({}, {
+ __index = function(t, style_num) -- LuaDoc is in core/.buffer.luadoc
+ if style_num < 0 or style_num > 255 then error('0 <= style_num < 256') end
+ return buffer:private_lexer_call(style_num)
+ end,
+ __newindex = function() error('read-only property') end
+ })
end
events.connect(events.BUFFER_NEW, set_lexer_functions, 1)
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index 27f44c86..3acb2a28 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -241,7 +241,7 @@ M.utils = {
local style = buffer.style_at[buffer.current_pos]
local text = string.format("%s %s\n%s %s (%d)", _L['Lexer'],
buffer:get_lexer(true), _L['Style'],
- buffer:get_style_name(style), style)
+ buffer.style_name[style], style)
buffer:call_tip_show(buffer.current_pos, text)
end,
set_indentation = function(i)