diff options
author | 2007-09-27 23:05:20 -0400 | |
---|---|---|
committer | 2007-09-27 23:05:20 -0400 | |
commit | ece35a566f002bb0454d3f02a87ca51a48a7c7c5 (patch) | |
tree | 47976d27bce1b458aa4d27d82853e76d76426b6f /core/file_io.lua | |
parent | 0c947b9f153824d092437c8f06aee28602814d00 (diff) | |
download | textadept-ece35a566f002bb0454d3f02a87ca51a48a7c7c5.tar.gz textadept-ece35a566f002bb0454d3f02a87ca51a48a7c7c5.zip |
Added buffer:reload() function.
Diffstat (limited to 'core/file_io.lua')
-rw-r--r-- | core/file_io.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/file_io.lua b/core/file_io.lua index c7433479..e4d36db0 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -53,6 +53,24 @@ function open(filenames) end --- +-- Reloads the file in a given buffer. +-- @param buffer The buffer to reload. This must be the currently focused +-- buffer. +-- @usage buffer:reload() +function reload(buffer) + textadept.check_focused_buffer(buffer) + if not buffer.filename then return end + local f, err = io.open(buffer.filename) + if f then + local pos = buffer.current_pos + buffer:set_text( f:read('*all') ) + buffer.current_pos = pos + buffer:set_save_point() + f:close() + end +end + +--- -- Saves the current buffer to a file. -- @param buffer The buffer to save. Its 'filename' property is used as the -- path of the file to save to. This must be the currently focused buffer. |