diff options
author | 2011-09-25 22:37:24 -0400 | |
---|---|---|
committer | 2011-09-25 22:37:24 -0400 | |
commit | f10a48801dd09bb6cb058b4f783f879720d22bf0 (patch) | |
tree | 8b22a252a4b6f60cc7cb8acf862d5c770be8a28a /modules/textadept/session.lua | |
parent | 8461d29251895160755695b74ca6356a9cd8e6f3 (diff) | |
download | textadept-f10a48801dd09bb6cb058b4f783f879720d22bf0.tar.gz textadept-f10a48801dd09bb6cb058b4f783f879720d22bf0.zip |
Refactored textadept.c and changed Lua interface a bit.
'_BUFFERS' and '_VIEWS' now also have buffer and view keys with index values;
'buffer.doc_pointer', 'view.doc_pointer', and 'gui.focused_doc_pointer' are no
longer used; 'buffer:check_global()' replaces 'gui.check_focused_buffer()';
Added 'view.buffer' field; 'view:goto_buffer()' and 'gui.goto_view()' arguments
changed to make more sense.
Diffstat (limited to 'modules/textadept/session.lua')
-rw-r--r-- | modules/textadept/session.lua | 25 |
1 files changed, 9 insertions, 16 deletions
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]) |