aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2013-09-01 23:20:30 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2013-09-01 23:20:30 -0400
commit38788d01b42165d916467f8aec84121d5c1f6fe0 (patch)
tree8e4557272ace380e372833d364859c4a7b9e6a00
parentd633a4c74e824113f5d242cb18573fed3015bc27 (diff)
downloadtextadept-38788d01b42165d916467f8aec84121d5c1f6fe0.tar.gz
textadept-38788d01b42165d916467f8aec84121d5c1f6fe0.zip
Renamed `buffer:get_style_name(n)` to `buffer.style_name[n]`.
-rw-r--r--core/.buffer.luadoc19
-rw-r--r--doc/14_Appendix.md3
-rw-r--r--modules/textadept/adeptsense.lua2
-rw-r--r--modules/textadept/file_types.lua15
-rw-r--r--modules/textadept/keys.lua2
5 files changed, 19 insertions, 22 deletions
diff --git a/core/.buffer.luadoc b/core/.buffer.luadoc
index 676f9c26..488422a9 100644
--- a/core/.buffer.luadoc
+++ b/core/.buffer.luadoc
@@ -774,6 +774,8 @@
-- Table of flags indicating whether or not text within styles has an italic
-- font face for style numbers from `0` to `255`.
-- The default values are `false`.
+-- @field style_name (table, Read-only)
+-- Table of style names for style numbers from `0` to `255`.
-- @field style_size (table)
-- Table of font sizes of text within styles for style numbers from `0` to
-- `255`.
@@ -2489,12 +2491,12 @@ function undo(buffer) end
function upper_case(buffer) end
---
--- Displays a list constructed from string *item_list*, whose items are
--- delimited by `buffer.auto_c_separator` characters, using the list identifier
--- number *list_type* which is greater than zero and sent in a
--- `USER_LIST_SELECTION` event after the user selects an item.
+-- Displays a list identified by list identifier number *list_item* and
+-- constructed from string *item_list*, whose items are delimited by
+-- `buffer.auto_c_separator` characters.
-- The sorted order of *item_list*, `buffer.auto_c_order`, must have already
--- been defined.
+-- been defined. When the user selects an item, *list_type* is sent in a
+-- `USER_LIST_SELECTION` event along with the selection.
-- @param buffer The global buffer.
-- @param list_type The list identifier number greater than zero to use.
-- @param item_list The sorted string of words to show, separated by
@@ -2773,13 +2775,6 @@ function get_lexer(buffer, current) end
-- @usage buffer.set_lexer(buffer, 'language_name')
function set_lexer(buffer, lang) end
----
--- Returns the name of style number *style_num*, in the range of `0` to `255`.
--- @param buffer The global buffer.
--- @param style_num The style number from `0` to `255` to get the name of.
--- @see buffer.style_at
-function get_style_name(buffer, style_num) end
-
-- Unused Fields.
-- * annotation_styles
-- * automatic_fold
diff --git a/doc/14_Appendix.md b/doc/14_Appendix.md
index 663be78d..682582fb 100644
--- a/doc/14_Appendix.md
+++ b/doc/14_Appendix.md
@@ -176,6 +176,8 @@ contextmenu |Removed |N/A
MARK\_ERROR\_BACK |Renamed |[ERROR\_COLOR][]
**_M.textadept.snapopen** |Removed |N/A
open |Changed |\_G.[io.snapopen()][]<sup>†</sup>
+**buffer** | |
+get\_style\_name(buffer, n) |Renamed |[style\_name][]\[n\]
**events** | |
N/A |New |[INITIALIZED][]<sup>‡</sup>
handlers |Removed |N/A
@@ -207,6 +209,7 @@ not all buffer functions are available at the `require()` stage. See
[select\_enclosed()]: api/textadept.editing.html#select_enclosed
[ERROR\_COLOR]: api/textadept.run.html#ERROR_COLOR
[io.snapopen()]: api/io.html#snapopen
+[style\_name]: api/buffer.html#style_name
[INITIALIZED]: api/events.html#INITIALIZED
[ui]: api/ui.html
[maximized]: api/ui.html#maximized
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)