aboutsummaryrefslogtreecommitdiff
path: root/core/file_io.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2008-06-18 14:00:03 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2008-06-18 14:00:03 -0400
commit705a8798f5941324a8448eee5c558a299a3588c1 (patch)
tree9666de2955c3b3bb6fe4b2bf7d225ad2e0c43d7f /core/file_io.lua
parent488e39d6d8f96b581a44281add43d726fa540390 (diff)
downloadtextadept-705a8798f5941324a8448eee5c558a299a3588c1.tar.gz
textadept-705a8798f5941324a8448eee5c558a299a3588c1.zip
Always load Project Manager settings from session file.
Diffstat (limited to 'core/file_io.lua')
-rw-r--r--core/file_io.lua67
1 files changed, 38 insertions, 29 deletions
diff --git a/core/file_io.lua b/core/file_io.lua
index 496afebd..36117ebf 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -166,41 +166,48 @@ end
-- project manager details.
-- @param filename The absolute path to the session file to load. Defaults to
-- $HOME/.ta_session if not specified.
+-- @param only_pm Flag indicating whether or not to load only the Project
+-- Manager session settings. Defaults to false.
+-- @return true if the session file was opened and read; false otherwise.
-- @usage textadept.io.load_session(filename)
-function load_session(filename)
+function load_session(filename, only_pm)
local textadept = textadept
local f = io.open(filename or os.getenv('HOME')..'/.ta_session')
local current_view, splits = 1, { [0] = {} }
if f then
for line in f:lines() do
- if line:match('^buffer:') then
- local anchor, current_pos, first_visible_line, filename =
- line:match('^buffer: (%d+) (%d+) (%d+) (.+)$')
- textadept.io.open(filename or '')
- -- Restore saved buffer selection and view.
- local anchor = tonumber(anchor) or 0
- local current_pos = tonumber(current_pos) or 0
- local first_visible_line = tonumber(first_visible_line) or 0
- local buffer = buffer
- buffer._anchor, buffer._current_pos = anchor, current_pos
- buffer._first_visible_line = first_visible_line
- buffer:line_scroll( 0,
- buffer:visible_from_doc_line(first_visible_line) )
- buffer:set_sel(anchor, current_pos)
- elseif line:match('^%s*split%d:') then
- local level, num, type, size =
- line:match('^(%s*)split(%d): (%S+) (%d+)')
- local view = splits[#level] and splits[#level][ tonumber(num) ] or view
- splits[#level + 1] = { view:split(type == 'true') }
- splits[#level + 1][1].size = tonumber(size) -- could be 1 or 2
- elseif line:match('^%s*view%d:') then
- local level, num, buf_idx = line:match('^(%s*)view(%d): (%d+)$')
- local view = splits[#level][ tonumber(num) ] or view
- view:goto_buffer( tonumber(buf_idx) )
- elseif line:match('^current_view:') then
- local view_idx, buf_idx = line:match('^current_view: (%d+)')
- current_view = tonumber(view_idx) or 1
- elseif line:match('^pm:') then
+ if not only_pm then
+ if line:match('^buffer:') then
+ local anchor, current_pos, first_visible_line, filename =
+ line:match('^buffer: (%d+) (%d+) (%d+) (.+)$')
+ textadept.io.open(filename or '')
+ -- Restore saved buffer selection and view.
+ local anchor = tonumber(anchor) or 0
+ local current_pos = tonumber(current_pos) or 0
+ local first_visible_line = tonumber(first_visible_line) or 0
+ local buffer = buffer
+ buffer._anchor, buffer._current_pos = anchor, current_pos
+ buffer._first_visible_line = first_visible_line
+ buffer:line_scroll( 0,
+ buffer:visible_from_doc_line(first_visible_line) )
+ buffer:set_sel(anchor, current_pos)
+ elseif line:match('^%s*split%d:') then
+ local level, num, type, size =
+ line:match('^(%s*)split(%d): (%S+) (%d+)')
+ local view =
+ splits[#level] and splits[#level][ tonumber(num) ] or view
+ splits[#level + 1] = { view:split(type == 'true') }
+ splits[#level + 1][1].size = tonumber(size) -- could be 1 or 2
+ elseif line:match('^%s*view%d:') then
+ local level, num, buf_idx = line:match('^(%s*)view(%d): (%d+)$')
+ local view = splits[#level][ tonumber(num) ] or view
+ view:goto_buffer( tonumber(buf_idx) )
+ elseif line:match('^current_view:') then
+ local view_idx, buf_idx = line:match('^current_view: (%d+)')
+ current_view = tonumber(view_idx) or 1
+ end
+ end
+ if line:match('^pm:') then
local width, text = line:match('^pm: (%d+) (.+)$')
textadept.pm.width = width or 0
textadept.pm.entry_text = text or ''
@@ -209,7 +216,9 @@ function load_session(filename)
end
f:close()
textadept.views[current_view]:focus()
+ return true
end
+ return false
end
---