aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/session.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2010-06-11 18:51:16 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2010-06-11 18:51:16 -0400
commit8e66381a040f695f4203b28bc3f1d6818d0da7a2 (patch)
treee30e8115d27b423b579e60178f36a151dc795f50 /modules/textadept/session.lua
parent7a4800f05f26067a1cef77e5431256aab4c3d675 (diff)
downloadtextadept-8e66381a040f695f4203b28bc3f1d6818d0da7a2.tar.gz
textadept-8e66381a040f695f4203b28bc3f1d6818d0da7a2.zip
Removed _G.textadept.
Created new _SCINTILLA core module. Renamed textadept.constants to _SCINTILLA.constants Renamed textadept.buffer_functions to _SCINTILLA.functions Renamed textadept.buffer_properties to _SCINTILLA.properties Created new gui core module. Renamed textadept._print() to gui._print(). Renamed textadept.check_focused_buffer() to gui.check_focused_buffer(). Renamed textadept.clipboard_text to gui.clipboard_text. Renamed textadept.context_menu to gui.context_menu Renamed textadept.command_entry to gui.command_entry. Renamed textadept.dialog to gui.dialog. Renamed textadept.docstatusbar_text to gui.docstatusbar_text. Renamed textadept.find to gui.find. Renamed textadept.focused_doc_pointer to gui.focused_doc_pointer. Renamed textadept.get_split_table() to gui.get_split_table(). Renamed textadept.gtkmenu() to gui.gtkmenu(). Renamed textadept.goto_view() to gui.goto_view(). Renamed textadept.menubar to gui.menubar. Renamed textadept.print() to gui.print(). Renamed textadept.size to gui.size. Renamed textadept.statusbar_text to gui.statusbar_text. Renamed textadept.switch_buffer() to gui.switch_buffer(). Renamed textadept.title to gui.title. Renamed textadept.buffers to _G._BUFFERS. Renamed textadept.new_buffer() to _G.new_buffer(). Renamed textadept.quit() to _G.quit(). Renamed textadept.reset() to _G.reset(). Renamed textadept.views to _G._VIEWS. Renamed textadept.user_dofile() to _G.user_dofile(). Renamed textadept.iconv to string.iconv. Renamed textadept.session_file to _SESSIONFILE. Renamed appropriate C functions.
Diffstat (limited to 'modules/textadept/session.lua')
-rw-r--r--modules/textadept/session.lua33
1 files changed, 16 insertions, 17 deletions
diff --git a/modules/textadept/session.lua b/modules/textadept/session.lua
index 3535bca1..22f19c11 100644
--- a/modules/textadept/session.lua
+++ b/modules/textadept/session.lua
@@ -1,6 +1,5 @@
-- Copyright 2007-2010 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-local textadept = _G.textadept
local locale = _G.locale
---
@@ -49,7 +48,7 @@ function load(filename)
not_found[#not_found + 1] = filename
end
else
- textadept.new_buffer()
+ new_buffer()
buffer._type = filename
events.handle('file_opened', filename)
end
@@ -73,7 +72,7 @@ function load(filename)
local level, num, buf_idx = line:match('^(%s*)view(%d): (%d+)$')
local view = splits[#level][tonumber(num)] or view
buf_idx = tonumber(buf_idx)
- if buf_idx > #textadept.buffers then buf_idx = #textadept.buffers end
+ if buf_idx > #_BUFFERS then buf_idx = #_BUFFERS end
view:goto_buffer(buf_idx)
elseif line:find('^current_view:') then
local view_idx = line:match('^current_view: (%d+)')
@@ -81,18 +80,18 @@ function load(filename)
end
if line:find('^size:') then
local width, height = line:match('^size: (%d+) (%d+)$')
- if width and height then textadept.size = { width, height } end
+ if width and height then gui.size = { width, height } end
end
end
f:close()
- textadept.views[current_view]:focus()
- textadept.session_file = filename or DEFAULT_SESSION
+ _VIEWS[current_view]:focus()
+ _SESSIONFILE = filename or DEFAULT_SESSION
if #not_found > 0 then
- textadept.dialog('msgbox',
- '--title', locale.M_SESSION_FILES_NOT_FOUND_TITLE,
- '--text', locale.M_SESSION_FILES_NOT_FOUND_TEXT,
- '--informative-text',
- string.format('%s', table.concat(not_found, '\n')))
+ gui.dialog('msgbox',
+ '--title', locale.M_SESSION_FILES_NOT_FOUND_TITLE,
+ '--text', locale.M_SESSION_FILES_NOT_FOUND_TEXT,
+ '--informative-text',
+ string.format('%s', table.concat(not_found, '\n')))
end
return true
end
@@ -110,10 +109,10 @@ function save(filename)
local split_line = "%ssplit%d: %s %d" -- level, number, type, size
local view_line = "%sview%d: %d" -- level, number, doc index
-- Write out opened buffers.
- for _, buffer in ipairs(textadept.buffers) do
+ for _, buffer in ipairs(_BUFFERS) do
local filename = buffer.filename or buffer._type
if filename then
- local current = buffer.doc_pointer == textadept.focused_doc_pointer
+ local current = buffer.doc_pointer == gui.focused_doc_pointer
local anchor = current and 'anchor' or '_anchor'
local current_pos = current and 'current_pos' or '_current_pos'
local first_visible_line =
@@ -141,7 +140,7 @@ function save(filename)
session[#session + 1] = view_line:format(spaces, 2, c2)
end
end
- local splits = textadept.get_split_table()
+ local splits = gui.get_split_table()
if type(splits) == 'table' then
write_split(splits, 0, 0)
else
@@ -149,7 +148,7 @@ function save(filename)
end
-- Write out the current focused view.
local current_view = view
- for index, view in ipairs(textadept.views) do
+ for index, view in ipairs(_VIEWS) do
if view == current_view then
current_view = index
break
@@ -157,11 +156,11 @@ function save(filename)
end
session[#session + 1] = ("current_view: %d"):format(current_view)
-- Write out other things.
- local size = textadept.size
+ local size = gui.size
session[#session + 1] = ("size: %d %d"):format(size[1], size[2])
-- Write the session.
local f =
- io.open_file(filename or textadept.session_file or DEFAULT_SESSION, 'wb')
+ io.open_file(filename or _SESSIONFILE or DEFAULT_SESSION, 'wb')
if f then
f:write(table.concat(session, '\n'))
f:close()