diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/textadept/bookmarks.lua | 14 | ||||
-rw-r--r-- | modules/textadept/editing.lua | 9 | ||||
-rw-r--r-- | modules/textadept/run.lua | 8 | ||||
-rw-r--r-- | modules/textadept/session.lua | 5 | ||||
-rw-r--r-- | modules/textadept/snippets.lua | 13 |
5 files changed, 24 insertions, 25 deletions
diff --git a/modules/textadept/bookmarks.lua b/modules/textadept/bookmarks.lua index 3e000f18..429b658f 100644 --- a/modules/textadept/bookmarks.lua +++ b/modules/textadept/bookmarks.lua @@ -24,8 +24,9 @@ function M.toggle(on, line) if not line then line = buffer:line_from_position(buffer.current_pos) end local f = on and buffer.marker_add or buffer.marker_delete if on == nil then -- toggle - local bit, marker_mask = 2^M.MARK_BOOKMARK, buffer:marker_get(line) - if bit32.band(marker_mask, bit) == 0 then f = buffer.marker_add end + if buffer:marker_get(line) & 1 << M.MARK_BOOKMARK == 0 then + f = buffer.marker_add + end end f(buffer, line, M.MARK_BOOKMARK) end @@ -58,12 +59,12 @@ function M.goto_mark(next) if buffer.filename then basename = basename:iconv('UTF-8', _CHARSET) end - local line = buffer:marker_next(0, 2^M.MARK_BOOKMARK) + local line = buffer:marker_next(0, 1 << M.MARK_BOOKMARK) while line >= 0 do local mark = string.format('%s:%d: %s', basename, line + 1, buffer:get_line(line):match('^[^\r\n]*')) utf8_list[#utf8_list + 1], buffers[#utf8_list + 1] = mark, buffer - line = buffer:marker_next(line + 1, 2^M.MARK_BOOKMARK) + line = buffer:marker_next(line + 1, 1 << M.MARK_BOOKMARK) end end end @@ -78,9 +79,10 @@ function M.goto_mark(next) else local f = next and buffer.marker_next or buffer.marker_previous local current_line = buffer:line_from_position(buffer.current_pos) - local line = f(buffer, current_line + (next and 1 or -1), 2^M.MARK_BOOKMARK) + local line = f(buffer, current_line + (next and 1 or -1), + 1 << M.MARK_BOOKMARK) if line == -1 then - line = f(buffer, (next and 0 or buffer.line_count), 2^M.MARK_BOOKMARK) + line = f(buffer, (next and 0 or buffer.line_count), 1 << M.MARK_BOOKMARK) end if line >= 0 then textadept.editing.goto_line(line) end end diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua index b66df48f..26f53449 100644 --- a/modules/textadept/editing.lua +++ b/modules/textadept/editing.lua @@ -147,7 +147,7 @@ end) -- Highlights matching braces. events.connect(events.UPDATE_UI, function(updated) - if updated and bit32.band(updated, 3) == 0 then return end -- ignore scrolling + if updated and updated & 3 == 0 then return end -- ignore scrolling if M.brace_matches[buffer.char_at[buffer.current_pos]] then local match = buffer:brace_match(buffer.current_pos, 0) if match ~= -1 then @@ -268,8 +268,8 @@ function M.paste() end local indentation = buffer:text_range(buffer:position_from_line(i), buffer.line_indent_position[i]) - local fold_header = i ~= line and bit32.band(buffer.fold_level[i], - buffer.FOLDLEVELHEADERFLAG) > 0 + local fold_header = i ~= line and + buffer.fold_level[i] & buffer.FOLDLEVELHEADERFLAG > 0 if fold_header then indentation = indentation..(buffer.use_tabs and '\t' or string.rep(' ', buffer.tab_width)) @@ -512,8 +512,7 @@ function M.convert_indentation() local e = buffer.line_indent_position[line] local current_indentation, new_indentation = buffer:text_range(s, e), nil if buffer.use_tabs then - -- Need integer division and LuaJIT does not have // operator. - local tabs = math.floor(indent / buffer.tab_width) + local tabs = indent // buffer.tab_width local spaces = math.fmod(indent, buffer.tab_width) new_indentation = string.rep('\t', tabs)..string.rep(' ', spaces) else diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua index 1ae75ae0..c81e3aa4 100644 --- a/modules/textadept/run.lua +++ b/modules/textadept/run.lua @@ -361,11 +361,11 @@ function M.goto_error(line, next) if not line and next ~= nil then local f = buffer['marker_'..(next and 'next' or 'previous')] line = buffer:line_from_position(buffer.current_pos) - local wline = f(buffer, line + (next and 1 or -1), 2^M.MARK_WARNING) - local eline = f(buffer, line + (next and 1 or -1), 2^M.MARK_ERROR) + local wline = f(buffer, line + (next and 1 or -1), 1 << M.MARK_WARNING) + local eline = f(buffer, line + (next and 1 or -1), 1 << M.MARK_ERROR) if wline == -1 and eline == -1 then - wline = f(buffer, next and 0 or buffer.line_count, 2^M.MARK_WARNING) - eline = f(buffer, next and 0 or buffer.line_count, 2^M.MARK_ERROR) + wline = f(buffer, next and 0 or buffer.line_count, 1 << M.MARK_WARNING) + eline = f(buffer, next and 0 or buffer.line_count, 1 << M.MARK_ERROR) elseif wline == -1 or eline == -1 then if wline == -1 then wline = eline else eline = wline end end diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua index c4bc4f3d..18ab1851 100644 --- a/modules/textadept/session.lua +++ b/modules/textadept/session.lua @@ -144,10 +144,11 @@ function M.save(filename) filename) -- Write out bookmarks. local lines = {} - local line = buffer:marker_next(0, 2^textadept.bookmarks.MARK_BOOKMARK) + local line = buffer:marker_next(0, 1 << textadept.bookmarks.MARK_BOOKMARK) while line >= 0 do lines[#lines + 1] = line - line = buffer:marker_next(line + 1, 2^textadept.bookmarks.MARK_BOOKMARK) + line = buffer:marker_next(line + 1, + 1 << textadept.bookmarks.MARK_BOOKMARK) end session[#session + 1] = 'bookmarks: '..table.concat(lines, ' ') end diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua index 3685f1a2..698afa38 100644 --- a/modules/textadept/snippets.lua +++ b/modules/textadept/snippets.lua @@ -164,8 +164,8 @@ local function new_snippet(text, trigger) -- snippet. (If so, pos will point to the correct position.) local pos = buffer:indicator_end(INDIC_CURRENTPLACEHOLDER, self.start_pos) if pos == 0 then pos = self.start_pos end - return bit32.band(buffer:indicator_all_on_for(pos), - 2^INDIC_CURRENTPLACEHOLDER) > 0 and pos + 1 or pos + return buffer:indicator_all_on_for(pos) & + 1 << INDIC_CURRENTPLACEHOLDER > 0 and pos + 1 or pos else return M._snippet_mt[k] end @@ -184,8 +184,7 @@ local function new_snippet(text, trigger) if #lines > 1 then -- Match indentation on all lines after the first. local line = buffer:line_from_position(buffer.current_pos) - -- Need integer division and LuaJIT does not have // operator. - local level = math.floor(buffer.line_indentation[line] / buffer.tab_width) + local level = buffer.line_indentation[line] // buffer.tab_width local additional_indent = indent[use_tabs]:rep(level) for i = 2, #lines do lines[i] = additional_indent..lines[i] end end @@ -543,8 +542,7 @@ M._snippet_mt = { return function() local s = buffer:indicator_end(M.INDIC_PLACEHOLDER, i) while s > 0 and s <= self.end_pos do - if bit32.band(buffer:indicator_all_on_for(i), - 2^M.INDIC_PLACEHOLDER) > 0 then + if buffer:indicator_all_on_for(i) & 1 << M.INDIC_PLACEHOLDER > 0 then -- This next indicator comes directly after the previous one; adjust -- start and end positions to compensate. s, i = buffer:indicator_start(M.INDIC_PLACEHOLDER, i), s @@ -617,8 +615,7 @@ M._snippet_mt = { -- Update snippet transforms when text is added or deleted. events.connect(events.UPDATE_UI, function(updated) - if #snippet_stack > 0 and updated and - bit32.band(updated, buffer.UPDATE_CONTENT) > 0 then + if #snippet_stack > 0 and updated and updated & buffer.UPDATE_CONTENT > 0 then snippet_stack[#snippet_stack]:update_transforms() end end) |