aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2015-03-11 16:53:07 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2015-03-11 16:53:07 -0400
commit85450b9983ec16b27981572c258298e6fbf2f59d (patch)
tree3a9557314cad78bde44d9d2030110339b73669f4 /modules/textadept
parent920c230f140c38ec072da27e522053aed2a9af75 (diff)
downloadtextadept-85450b9983ec16b27981572c258298e6fbf2f59d.tar.gz
textadept-85450b9983ec16b27981572c258298e6fbf2f59d.zip
Updated to Lua 5.3, LPeg 0.12.2, and lfs 1.6.3.
LuaJIT uses Lua 5.3's new utf8 library. Restored documentation for Lua 5.1 symbols and added deprecation notes.
Diffstat (limited to 'modules/textadept')
-rw-r--r--modules/textadept/editing.lua3
-rw-r--r--modules/textadept/keys.lua30
-rw-r--r--modules/textadept/menu.lua3
-rw-r--r--modules/textadept/snippets.lua4
4 files changed, 8 insertions, 32 deletions
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index 93e34aec..ced101b2 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -450,7 +450,8 @@ function M.convert_indentation()
local indent, e = line_indentation[line], line_indent_position[line]
current_indentation = buffer:text_range(s, e)
if buffer.use_tabs then
- new_indentation = ('\t'):rep(indent / buffer.tab_width)
+ -- Need integer division and LuaJIT does not have // operator.
+ new_indentation = ('\t'):rep(math.floor(indent / buffer.tab_width))
else
new_indentation = (' '):rep(indent)
end
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index ca515d9a..09f9bab8 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -219,14 +219,6 @@ local M = {}
-- ‡: Ctrl+Enter in Win32 curses.
module('textadept.keys')]]
--- UTF-8 handling tables.
-local utf8_lengths = { -- {max code point, UTF-8 length}
- {0x80, 1}, {0x800, 2}, {0x10000, 3}, {0x200000, 4}, {0x4000000, 5}
-}
-local lead_bytes = { -- [UTF-8 length] = {UTF-8 lead bits, remaining mask}
- {0, 0x7F}, {0xC0, 0x1F}, {0xE0, 0x0F}, {0xF0, 0x7}, {0xF8, 0x3}, {0xFC, 0x1}
-}
-
-- Utility functions.
M.utils = {
delete_word = function()
@@ -253,11 +245,7 @@ M.utils = {
show_style = function()
local pos = buffer.current_pos
local char = buffer:text_range(pos, buffer:position_after(pos))
- if char == '' then char = '\0' end
- local code = bit32.band(char:byte(), lead_bytes[#char][2])
- for i = 2, #char do
- code = bit32.bor(bit32.lshift(code, 6), bit32.band(char:byte(i), 0x3F))
- end
+ local code = utf8.codepoint(char)
local bytes = string.rep(' 0x%X', #char):format(char:byte(1, #char))
local style = buffer.style_at[pos]
local text = string.format("'%s' (U+%04X:%s)\n%s %s\n%s %s (%d)", char,
@@ -660,21 +648,7 @@ end
if OSX or CURSES then
-- UTF-8 input.
keys.utf8_input = {['\n'] = {ui.command_entry.finish_mode, function(code)
- local c = tonumber(code, 16)
- -- Determine the number of bytes in UTF-8 character to insert.
- local buf, len = {}, 6
- for i = 1, #utf8_lengths do
- if c < utf8_lengths[i][1] then len = utf8_lengths[i][2] break end
- end
- -- Produce UTF-8 bytes.
- for i = len, 2, -1 do
- buf[i], c = bit32.bor(0x80, bit32.band(c, 0x3F)), bit32.rshift(c, 6)
- end
- -- Construct the lead UTF-8 byte.
- buf[1] = bit32.bor(lead_bytes[len][1], bit32.band(c, lead_bytes[len][2]))
- -- Transform bytes into strings and perform the insertion.
- for i = 1, #buf do buf[i] = string.char(buf[i]) end
- _G.buffer:add_text(table.concat(buf))
+ _G.buffer:add_text(utf8.char(tonumber(code, 16)))
end}}
keys[OSX and 'mU' or 'mu'] = {ui.command_entry.enter_mode, 'utf8_input'}
end
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index 19d0687d..97e6ce2d 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -7,8 +7,7 @@ local M = {}
---
-- Defines the menus used by Textadept.
-- Menus are simply tables and may be edited in place. Submenus have `title`
--- keys with string text. Use the '#' operator (instead of `ipairs()`) for
--- iteration.
+-- keys with string text.
-- If applicable, load this module last in your *~/.textadept/init.lua*, after
-- [`textadept.keys`]() since it looks up defined key commands to show them in
-- menus.
diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua
index 0e31e6bb..81a4247f 100644
--- a/modules/textadept/snippets.lua
+++ b/modules/textadept/snippets.lua
@@ -102,7 +102,9 @@ local function new_snippet(text, trigger)
if #lines > 1 then
-- Match indentation on all lines after the first.
local indent_size = #buffer:get_cur_line():match('^%s*')
- if not use_tabs then indent_size = indent_size / buffer.tab_width end
+ if not use_tabs then
+ indent_size = math.floor(indent_size / buffer.tab_width) -- for Lua 5.3
+ end
local additional_indent = indent[use_tabs]:rep(indent_size)
for i = 2, #lines do lines[i] = additional_indent..lines[i] end
end