aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept
diff options
context:
space:
mode:
Diffstat (limited to 'modules/textadept')
-rw-r--r--modules/textadept/find.lua27
-rw-r--r--modules/textadept/keys.lua12
-rw-r--r--modules/textadept/menu.lua12
-rw-r--r--modules/textadept/mime_types.lua6
-rw-r--r--modules/textadept/session.lua25
5 files changed, 39 insertions, 43 deletions
diff --git a/modules/textadept/find.lua b/modules/textadept/find.lua
index a0f6e299..409ffe4c 100644
--- a/modules/textadept/find.lua
+++ b/modules/textadept/find.lua
@@ -18,7 +18,7 @@ find.in_files_label_text = L('In files')
local MARK_FIND = _SCINTILLA.next_marker_number()
local MARK_FIND_COLOR = 0x4D9999
-local previous_view
+local prev_view
-- Text escape sequences with their associated characters.
-- @class table
@@ -76,7 +76,9 @@ function find.find_in_files(utf8_dir)
search_dir(dir)
if #matches == 1 then matches[2] = L('No results found') end
matches[#matches + 1] = ''
- if buffer._type ~= L('[Files Found Buffer]') then previous_view = view end
+ if buffer._type ~= L('[Files Found Buffer]') then
+ prev_view = _VIEWS[view]
+ end
gui._print(L('[Files Found Buffer]'), table.concat(matches, '\n'))
end
end
@@ -313,17 +315,18 @@ local function goto_file(pos, line_num)
buffer:marker_add(line_num, MARK_FIND)
buffer:goto_pos(buffer.current_pos)
if #_VIEWS == 1 then
- _, previous_view = view:split(false) -- horizontal
+ view:split()
+ prev_view = 2 -- second view
else
local clicked_view = view
- if previous_view then previous_view:focus() end
+ if prev_view then gui.goto_view(prev_view) end
if buffer._type == L('[Files Found Buffer]') then
-- There are at least two find in files views; find one of those views
-- that the file was not selected from and focus it.
- for _, v in ipairs(_VIEWS) do
+ for i, v in ipairs(_VIEWS) do
if v ~= clicked_view then
- previous_view = v
- v:focus()
+ prev_view = i
+ gui.goto_view(i)
break
end
end
@@ -339,12 +342,12 @@ events.connect(events.DOUBLE_CLICK, goto_file)
-- LuaDoc is in core/.find.luadoc.
function find.goto_file_in_list(next)
- local orig_view = view
+ local orig_view = _VIEWS[view]
for _, buffer in ipairs(_BUFFERS) do
if buffer._type == L('[Files Found Buffer]') then
- for _, view in ipairs(_VIEWS) do
- if view.doc_pointer == buffer.doc_pointer then
- view:focus()
+ for j, view in ipairs(_VIEWS) do
+ if view.buffer == buffer then
+ gui.goto_view(j)
local orig_line = buffer:line_from_position(buffer.current_pos)
local line = orig_line
while true do
@@ -352,7 +355,7 @@ function find.goto_file_in_list(next)
if line > buffer.line_count - 1 then line = 0 end
if line < 0 then line = buffer.line_count - 1 end
if line == orig_line then -- prevent infinite loops
- orig_view:focus()
+ gui.goto_view(orig_view)
return
end
if buffer:get_line(line):match('^(.+):(%d+):.+$') then
diff --git a/modules/textadept/keys.lua b/modules/textadept/keys.lua
index 517502ec..5672933a 100644
--- a/modules/textadept/keys.lua
+++ b/modules/textadept/keys.lua
@@ -234,8 +234,8 @@ keys[not OSX and 'caO' or 'cmO'] = utils.snapopen_filedir
keys[not OSX and 'ci' or 'mi'] = utils.show_style
-- Buffer.
-keys['c\t'] = { _view.goto_buffer, _view, 1, false }
-keys['cs\t'] = { _view.goto_buffer, _view, -1, false }
+keys['c\t'] = { _view.goto_buffer, _view, 1, true }
+keys['cs\t'] = { _view.goto_buffer, _view, -1, true }
keys[not OSX and 'cb' or 'mb'] = gui.switch_buffer
-- Indentation.
-- TODO: { utils.set_indentation, 2 }
@@ -258,11 +258,11 @@ keys[not OSX and 'cL' or 'mL'] = m_textadept.mime_types.select_lexer
keys.f5 = { _buffer.colourise, _buffer, 0, -1 }
-- View.
-keys[not OSX and 'can' or 'ca\t'] = { gui.goto_view, 1, false }
-keys[not OSX and 'cap' or 'cas\t'] = { gui.goto_view, -1, false }
-keys[not OSX and 'cas' or 'cs'] = { _view.split, _view, false }
+keys[not OSX and 'can' or 'ca\t'] = { gui.goto_view, 1, true }
+keys[not OSX and 'cap' or 'cas\t'] = { gui.goto_view, -1, true }
+keys[not OSX and 'cas' or 'cs'] = { _view.split, _view }
if not OSX then keys.cah = keys.cas end
-keys[not OSX and 'cav' or 'cv'] = { _view.split, _view }
+keys[not OSX and 'cav' or 'cv'] = { _view.split, _view, true }
keys[not OSX and 'caw' or 'cw'] = { _view.unsplit, _view }
keys[not OSX and 'caW' or 'cW'] = utils.unsplit_all
keys[not OSX and 'ca+' or 'c+'] = { utils.grow, 10 }
diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua
index 82c72cfa..e26a2ec4 100644
--- a/modules/textadept/menu.lua
+++ b/modules/textadept/menu.lua
@@ -149,8 +149,8 @@ menubar = {
{ L('Show Style'), utils.show_style },
},
{ title = L('Buffer'),
- { L('Next Buffer'), { _view.goto_buffer, _view, 1, false } },
- { L('Previous Buffer'), { _view.goto_buffer, _view, -1, false } },
+ { L('Next Buffer'), { _view.goto_buffer, _view, 1, true } },
+ { L('Previous Buffer'), { _view.goto_buffer, _view, -1, true } },
{ L('Switch to Buffer...'), gui.switch_buffer },
SEPARATOR,
{ title = L('Indentation'),
@@ -179,11 +179,11 @@ menubar = {
{ L('Refresh Syntax Highlighting'), { _buffer.colourise, _buffer, 0, -1 } },
},
{ title = L('View'),
- { L('Next View'), { gui.goto_view, 1, false } },
- { L('Previous View'), { gui.goto_view, -1, false } },
+ { L('Next View'), { gui.goto_view, 1, true } },
+ { L('Previous View'), { gui.goto_view, -1, true } },
SEPARATOR,
- { L('Split View Horizontal'), { _view.split, _view, false } },
- { L('Split View Vertical'), { _view.split, _view } },
+ { L('Split View Horizontal'), { _view.split, _view } },
+ { L('Split View Vertical'), { _view.split, _view, true } },
{ L('Unsplit View'), { _view.unsplit, _view } },
{ L('Unsplit All Views'), utils.unsplit_all },
{ L('Grow View'), { utils.grow, 10 } },
diff --git a/modules/textadept/mime_types.lua b/modules/textadept/mime_types.lua
index a7a4f4e1..3d461db4 100644
--- a/modules/textadept/mime_types.lua
+++ b/modules/textadept/mime_types.lua
@@ -106,7 +106,7 @@ table.sort(lexers)
-- @param style_num A style number in the range 0 <= style_num < 256.
-- @see buffer.style_at
local function get_style_name(buffer, style_num)
- gui.check_focused_buffer(buffer)
+ 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
@@ -130,7 +130,7 @@ local SETLEXERLANGUAGE = _SCINTILLA.functions.set_lexer_language[1]
-- @param lang The string language to set.
-- @usage buffer:set_lexer('language_name')
local function set_lexer(buffer, lang)
- gui.check_focused_buffer(buffer)
+ buffer:check_global()
buffer._lexer = lang
buffer:private_lexer_call(SETDIRECTPOINTER, buffer.direct_pointer)
buffer:private_lexer_call(SETLEXERLANGUAGE, lang)
@@ -161,7 +161,7 @@ local GETLEXERLANGUAGE = _SCINTILLA.functions.get_lexer_language[1]
-- lexer can be different from the lexer passed to buffer:set_lexer().
-- Defaults to false.
local function get_lexer(buffer, current)
- gui.check_focused_buffer(buffer)
+ buffer:check_global()
local lexer = buffer:private_lexer_call(GETLEXERLANGUAGE)
if not current then return lexer end
local i, ws, style_at = buffer.current_pos, ws_styles[lexer], buffer.style_at
diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua
index e69f2488..1178380f 100644
--- a/modules/textadept/session.lua
+++ b/modules/textadept/session.lua
@@ -92,7 +92,7 @@ function load(filename)
end
end
f:close()
- _VIEWS[current_view]:focus()
+ gui.goto_view(current_view)
if #not_found > 0 then
gui.dialog('msgbox',
'--title', L('Session Files Not Found'),
@@ -121,7 +121,7 @@ function save(filename)
for _, buffer in ipairs(_BUFFERS) do
local filename = buffer.filename or buffer._type
if filename then
- local current = buffer.doc_pointer == gui.focused_doc_pointer
+ local current = buffer == view.buffer
local anchor = current and 'anchor' or '_anchor'
local current_pos = current and 'current_pos' or '_current_pos'
local top_line = current and 'first_visible_line' or '_first_visible_line'
@@ -138,32 +138,25 @@ function save(filename)
local spaces = (' '):rep(level)
session[#session + 1] = split_line:format(spaces, number, vertical, size)
spaces = (' '):rep(level + 1)
- if type(c1) == 'table' then
+ if c1[1] and c1[2] then
write_split(c1, level + 1, 1)
else
- session[#session + 1] = view_line:format(spaces, 1, c1)
+ session[#session + 1] = view_line:format(spaces, 1, _BUFFERS[c1.buffer])
end
- if type(c2) == 'table' then
+ if c2[1] and c2[2] then
write_split(c2, level + 1, 2)
else
- session[#session + 1] = view_line:format(spaces, 2, c2)
+ session[#session + 1] = view_line:format(spaces, 2, _BUFFERS[c2.buffer])
end
end
local splits = gui.get_split_table()
- if type(splits) == 'table' then
+ if splits[1] and splits[2] then
write_split(splits, 0, 0)
else
- session[#session + 1] = view_line:format('', 1, splits)
+ session[#session + 1] = view_line:format('', 1, _BUFFERS[splits.buffer])
end
-- Write out the current focused view.
- local current_view = view
- for i = 1, #_VIEWS do
- if _VIEWS[i] == current_view then
- current_view = i
- break
- end
- end
- session[#session + 1] = ("current_view: %d"):format(current_view)
+ session[#session + 1] = ("current_view: %d"):format(_VIEWS[view])
-- Write out other things.
local size = gui.size
session[#session + 1] = ("size: %d %d"):format(size[1], size[2])