aboutsummaryrefslogtreecommitdiff
path: root/core/file_io.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2008-02-23 18:13:24 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2008-02-23 18:13:24 -0500
commit47b8c0db856c48abbcbcb5635deaa5c2cc41427e (patch)
tree2d94eab5c87463131001fc815e60acf0cc9c6f41 /core/file_io.lua
parent04a91f8ab1db479b48f26f3f808b74ba8a617e9b (diff)
downloadtextadept-47b8c0db856c48abbcbcb5635deaa5c2cc41427e.tar.gz
textadept-47b8c0db856c48abbcbcb5635deaa5c2cc41427e.zip
Eliminated Zenity dependency; replaced with my CocoaDialog clone (lua_dialog).
Diffstat (limited to 'core/file_io.lua')
-rw-r--r--core/file_io.lua36
1 files changed, 19 insertions, 17 deletions
diff --git a/core/file_io.lua b/core/file_io.lua
index 29d7d535..ed2b8c55 100644
--- a/core/file_io.lua
+++ b/core/file_io.lua
@@ -44,13 +44,13 @@ end
-- specified, the user is prompted to open files from a dialog.
-- @usage textadept.io.open(filename)
function open(filenames)
- if not filenames then
- local directory = '--filename="'..(buffer.filename or '')..'"'
- local p = io.popen('zenity --file-selection --multiple '..directory)
- filenames = p:read('*all')
- p:close()
- end
- for filename in filenames:gmatch('[^|\n]+') do open_helper(filename) end
+ filenames = filenames or cocoa_dialog( 'fileselect', {
+ title = 'Open',
+ text = 'Select a file(s) to open',
+ ['select-multiple'] = true,
+ ['with-directory'] = (buffer.filename or ''):match('.+/')
+ } )
+ for filename in filenames:gmatch('[^\n]+') do open_helper(filename) end
end
---
@@ -100,14 +100,15 @@ end
function save_as(buffer, filename)
textadept.check_focused_buffer(buffer)
if not filename then
- local directory = '--filename="'..(buffer.filename or '')..'"'
- local p = io.popen('zenity --file-selection --save '..directory..
- ' --confirm-overwrite')
- filename = p:read('*all')
- p:close()
+ filename = cocoa_dialog( 'filesave', {
+ title = 'Save',
+ ['with-directory'] = buffer.filename:match('.+/'),
+ ['with-file'] = buffer.filename:match('[^/]+$'),
+ ['no-newline'] = true
+ } )
end
if #filename > 0 then
- buffer.filename = filename:sub(1, -2) -- chomp
+ buffer.filename = filename
buffer:save()
events.handle('file_saved_as', filename)
end
@@ -136,10 +137,11 @@ end
-- @usage buffer:close()
function close(buffer)
textadept.check_focused_buffer(buffer)
- if buffer.dirty and os.execute('zenity --question --title Alert '..
- '--text "Close without saving?"') ~= 0 then
- return false
- end
+ if buffer.dirty and tonumber( cocoa_dialog( 'yesno-msgbox', {
+ title = 'Save?',
+ text = 'Save changes before closing?',
+ ['informative-text'] = 'You will have to save changes manually.'
+ } ) ) ~= 2 then return false end
buffer:delete()
return true
end