aboutsummaryrefslogtreecommitdiff
path: root/core/gui.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2011-09-28 17:04:18 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2011-09-28 17:04:18 -0400
commit851ebfe28a7c2c157cdf17d4623cb954dc3802ea (patch)
treec911d2bdcc146210e31f9833e53e6295b6de03a5 /core/gui.lua
parent132e362f44e00cd93e04967efbfc138c53a47ee4 (diff)
downloadtextadept-851ebfe28a7c2c157cdf17d4623cb954dc3802ea.tar.gz
textadept-851ebfe28a7c2c157cdf17d4623cb954dc3802ea.zip
Added gui.goto_file() for the 'find' and 'run' modules.
Diffstat (limited to 'core/gui.lua')
-rw-r--r--core/gui.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/gui.lua b/core/gui.lua
index 6c6e60ef..0beb1a11 100644
--- a/core/gui.lua
+++ b/core/gui.lua
@@ -63,6 +63,21 @@ function gui.switch_buffer()
if i then view:goto_buffer(i + 1) end
end
+-- LuaDoc is in core/.gui.luadoc.
+function gui.goto_file(filename, split, preferred_view)
+ if #_VIEWS == 1 and view.buffer.filename ~= filename and split then
+ view:split()
+ else
+ local other_view = _VIEWS[preferred_view]
+ for i, v in ipairs(_VIEWS) do
+ if v.buffer.filename == filename then gui.goto_view(i) return end
+ if not other_view and v ~= view then other_view = i end
+ end
+ if other_view then gui.goto_view(other_view) end
+ end
+ io.open_file(filename)
+end
+
local connect = events.connect
-- Sets default properties for a Scintilla window.