aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2007-11-16 19:17:44 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2007-11-16 19:17:44 -0500
commitcf070ac8b3e4d89058f0a6e6fc313a0fc494a12f (patch)
treeaa3064fe1d5c16d180b45aba983620363d82d840
parente41d14b9f3b74018278f63bf7ca71316a1b36838 (diff)
downloadtextadept-cf070ac8b3e4d89058f0a6e6fc313a0fc494a12f.tar.gz
textadept-cf070ac8b3e4d89058f0a6e6fc313a0fc494a12f.zip
Added Mac OSX patch file for CocoaDialog.
-rw-r--r--osx.patch233
1 files changed, 233 insertions, 0 deletions
diff --git a/osx.patch b/osx.patch
new file mode 100644
index 00000000..5d1018c6
--- /dev/null
+++ b/osx.patch
@@ -0,0 +1,233 @@
+diff -r 48f2f7ef285f core/events.lua
+--- a/core/events.lua Thu Nov 08 15:01:36 2007 -0500
++++ b/core/events.lua Thu Nov 08 16:23:06 2007 -0500
+@@ -372,11 +372,11 @@ add_handler('quit',
+ end
+ end
+ if any then
+- list = list..'\nQuit without saving?'
+- if os.execute('zenity --question --title Alert '..
+- '--text "'..list..'"') ~= 0 then
+- return false
+- end
++ if tonumber( cocoa_dialog( 'yesno-msgbox', {
++ title = 'Save?',
++ text = 'Save changes before quitting?',
++ ['informative-text'] = 'You will have to save changes manually.'
++ } ) ) ~= 2 then return false end
+ end
+ textadept.io.save_session()
+ return true
+diff -r 48f2f7ef285f core/ext/find.lua
+--- a/core/ext/find.lua Thu Nov 08 15:01:36 2007 -0500
++++ b/core/ext/find.lua Thu Nov 08 16:23:06 2007 -0500
+@@ -96,7 +96,11 @@ function find.replace(rtext)
+ function(code)
+ local ret, val = pcall( loadstring('return '..code) )
+ if not ret then
+- os.execute('zenity --error --text "'..val:gsub('"', '\\"')..'"')
++ cocoa_dialog( 'msgbox', {
++ title = 'Error',
++ text = 'An error ocurred:',
++ ['informative-text'] = val:gsub('"', '\\"')
++ } )
+ error()
+ end
+ return val
+diff -r 48f2f7ef285f core/file_io.lua
+--- a/core/file_io.lua Thu Nov 08 15:01:36 2007 -0500
++++ b/core/file_io.lua Thu Nov 08 16:23:06 2007 -0500
+@@ -44,11 +44,12 @@ 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 '')..'"'
+- filenames = io.popen('zenity --file-selection --multiple '..
+- directory):read('*all')
+- 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,8 +101,9 @@ function save_as(buffer, filename)
+ textadept.check_focused_buffer(buffer)
+ if not filename then
+ local directory = '--filename="'..(buffer.filename or '')..'"'
+- filename = io.popen('zenity --file-selection --save '..
+- directory..' --confirm-overwrite'):read('*all')
++ filename = cocoa_dialog( 'filesave', {
++ title = 'Save'
++ } )
+ end
+ if #filename > 0 then
+ buffer.filename = filename:sub(1, -2) -- chomp
+@@ -133,10 +135,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
+diff -r 48f2f7ef285f core/init.lua
+--- a/core/init.lua Thu Nov 08 15:01:36 2007 -0500
++++ b/core/init.lua Thu Nov 08 16:23:06 2007 -0500
+@@ -14,6 +14,23 @@ function textadept.check_focused_buffer(
+ end
+ end
+
++---
++-- Displays a CocoaDialog of a specified type with given arguments returning
++-- the result.
++-- @param kind The CocoaDialog type.
++-- @param ... A table of key, value arguments. Each key is a --key switch with
++-- a "value" value. If value is nil, it is omitted and just the switch is
++-- used.
++-- @return string CocoaDialog result.
++function cocoa_dialog(kind, opts)
++ local args = ''
++ for k, v in pairs(opts) do
++ args = args..' --'..k
++ if type(v) == 'string' then args = args..' "'..v..'"' end
++ end
++ return io.popen('CocoaDialog '..kind..args):read('*all')
++end
++
+ package.path = package.path..';'.._HOME..'/core/?.lua'
+
+ require 'iface'
+diff -r 48f2f7ef285f modules/textadept/editing.lua
+--- a/modules/textadept/editing.lua Thu Nov 08 15:01:36 2007 -0500
++++ b/modules/textadept/editing.lua Thu Nov 08 16:23:06 2007 -0500
+@@ -219,9 +219,12 @@ function goto_line(line)
+ function goto_line(line)
+ local buffer = buffer
+ if not line then
+- line = io.popen('zenity --entry --title "Go To" '..
+- '--text "Line Number:"'):read('*all')
+- if line == '' then return end
++ line = cocoa_dialog( 'standard-inputbox', {
++ title = 'Go To',
++ text = 'Line Number:',
++ ['no-newline'] = true
++ } ):match('%d+$')
++ if not line then return end
+ line = tonumber(line)
+ end
+ buffer:ensure_visible_enforce_policy(line - 1)
+diff -r 48f2f7ef285f modules/textadept/macros.lua
+--- a/modules/textadept/macros.lua Thu Nov 08 15:01:36 2007 -0500
++++ b/modules/textadept/macros.lua Thu Nov 08 16:23:06 2007 -0500
+@@ -66,9 +66,12 @@ function stop_recording()
+ recording = false
+ local textadept = textadept
+ local bf, bp = textadept.buffer_functions, textadept.buffer_properties
+- local macro_name =
+- io.popen('zenity --entry --text "Macro name:"'):read('*all'):sub(1, -2)
+- if #macro_name > 0 then
++ local macro_name = cocoa_dialog( 'standard-inputbox', {
++ title = 'Save Macro',
++ text = 'Macro name:',
++ ['no-newline'] = true
++ } )
++ if macro_name:match('^%d') ~= '2' then
+ for _, command in ipairs(current) do
+ command.type = 'function'
+ local msg = command[1]
+@@ -82,7 +85,7 @@ function stop_recording()
+ end
+ end
+ end
+- list[macro_name] = current
++ list[ macro_name:match('[^\n]+$') ] = current
+ save()
+ textadept.statusbar_text = 'Macro saved'
+ textadept.events.handle('macro_saved')
+@@ -104,9 +107,13 @@ function play(macro_name)
+ function play(macro_name)
+ if not macro_name then
+ local macro_list = ''
+- for name in pairs(list) do macro_list = macro_list..name..' ' end
+- macro_name = io.popen('zenity --list --text "Select a Macro" '..
+- '--column Name '..macro_list):read('*all'):sub(1, -2)
++ for name in pairs(list) do macro_list = macro_list..'"'..name..'" ' end
++ macro_name = cocoa_dialog( 'standard-dropdown', {
++ title = 'Select a Macro',
++ text = 'Macro name:',
++ items = macro_list,
++ ['no-newline'] = true
++ } )
+ end
+ local macro = list[macro_name]
+ if not macro then return end
+diff -r 48f2f7ef285f src/Makefile
+--- a/src/Makefile Thu Nov 08 15:01:36 2007 -0500
++++ b/src/Makefile Thu Nov 08 16:23:06 2007 -0500
+@@ -2,7 +2,7 @@
+
+ .SUFFIXES: .c .o .h .a
+
+-INCLUDEDIRS=-Iscintilla-st/include
++INCLUDEDIRS=-Iscintilla-st/include -I/opt/local/include
+ ifdef DEBUG
+ CXXFLAGS=-DDEBUG -g -DGTK -DSCI_LEXER -W -Wall
+ else
+@@ -14,7 +14,7 @@ all: textadept
+
+ .c.o:
+ g++ `pkg-config --cflags gtk+-2.0` $(INCLUDEDIRS) $(CXXFLAGS) -c $< -o $@
+-textadept: textadept.o lua_interface.o pm.o find_replace.o $(LEXEROBJS) scintilla-st/bin/scintilla.a -llua
+- g++ `pkg-config --libs gtk+-2.0 gthread-2.0` -lstdc++ -DGTK $^ -o $@
++textadept: textadept.o lua_interface.o pm.o find_replace.o $(LEXEROBJS) scintilla-st/bin/scintilla.a
++ g++ `pkg-config --libs gtk+-2.0 gthread-2.0` -lstdc++ -DGTK -L/opt/local/lib -llua $^ -o $@
+ clean:
+ rm -rf textadept *.o
+diff -r 48f2f7ef285f src/properties.h
+--- a/src/properties.h Thu Nov 08 15:01:36 2007 -0500
++++ b/src/properties.h Thu Nov 08 16:23:06 2007 -0500
+@@ -32,7 +32,7 @@ void set_default_editor_properties(Scint
+ SS(sci, SCI_SETFOLDFLAGS, 16);
+ SS(sci, SCI_SETMODEVENTMASK, SC_MOD_CHANGEFOLD);
+
+- SS(sci, SCI_SETMARGINWIDTHN, 0, 4 + 2 * // line number margin
++ SS(sci, SCI_SETMARGINWIDTHN, 0, 4 + 3 * // line number margin
+ SS(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, reinterpret_cast<long>("9")));
+
+ SS(sci, SCI_SETMARGINWIDTHN, 1, 0); // marker margin invisible
+diff -r 48f2f7ef285f src/textadept.c
+--- a/src/textadept.c Thu Nov 08 15:01:36 2007 -0500
++++ b/src/textadept.c Thu Nov 08 16:23:06 2007 -0500
+@@ -29,7 +29,7 @@ int main(int argc, char **argv) {
+
+ void create_ui() {
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+- gtk_window_set_default_size(GTK_WINDOW(window), 500, 400);
++ gtk_window_set_default_size(GTK_WINDOW(window), 700, 1000);
+ signal(window, "delete_event", w_exit);
+ signal(window, "focus-in-event", w_focus);
+ signal(window, "key_press_event", w_keypress);
+@@ -105,8 +105,8 @@ void new_scintilla_buffer(ScintillaObjec
+ }
+ // Setup default styling and properties.
+ SS(sci, SCI_STYLESETFONT, 32,
+- reinterpret_cast<long>("!Bitstream Vera Sans Mono"));
+- SS(sci, SCI_STYLESETSIZE, 32, 8);
++ reinterpret_cast<long>("!Monaco"));
++ SS(sci, SCI_STYLESETSIZE, 32, 11);
+ SS(sci, SCI_STYLESETFORE, 32, 0xAA | (0xAA << 8) | (0xAA << 16));
+ SS(sci, SCI_STYLESETBACK, 32, 0x33 | (0x33 << 8) | (0x33 << 16));
+ set_default_buffer_properties(sci);