diff options
-rw-r--r-- | core/.textadept.lua | 4 | ||||
-rw-r--r-- | core/events.lua | 4 | ||||
-rw-r--r-- | core/ext/find.lua | 5 | ||||
-rw-r--r-- | core/ext/pm/buffer_browser.lua | 4 | ||||
-rw-r--r-- | core/file_io.lua | 1 | ||||
-rw-r--r-- | core/init.lua | 12 | ||||
-rw-r--r-- | core/locale.lua | 6 | ||||
-rw-r--r-- | modules/textadept/run.lua | 3 |
8 files changed, 26 insertions, 13 deletions
diff --git a/core/.textadept.lua b/core/.textadept.lua index 9e0375a7..d16d61ef 100644 --- a/core/.textadept.lua +++ b/core/.textadept.lua @@ -108,8 +108,8 @@ function check_focused_buffer(buffer) end -- buffer, and prints to it. -- @param buffer_type String type of message buffer. -- @param ... Message strings. --- @usage textadept._print('shows_errors', error_message) --- @usage textadept._print('shows_messages', message) +-- @usage textadept._print(textadept.locale.ERROR_BUFFER, error_message) +-- @usage textadept._print(textadept.locale.MESSAGE_BUFFER, message) function _print(buffer_type, ...) --- diff --git a/core/events.lua b/core/events.lua index 946d0874..52093fc3 100644 --- a/core/events.lua +++ b/core/events.lua @@ -359,7 +359,7 @@ local title_text = '%s %s Textadept (%s)' -- @param buffer The currently focused buffer. local function set_title(buffer) local buffer = buffer - local filename = buffer.filename or textadept.locale.UNTITLED + local filename = buffer.filename or buffer._type or textadept.locale.UNTITLED local d = buffer.dirty and '*' or '-' textadept.title = string.format(title_text, filename:match('[^/\\]+$'), d, filename) @@ -475,4 +475,4 @@ end -- Default error handler. -- Prints the errors to an error buffer. -- @param ... Error strings. -function error(...) textadept._print('shows_errors', ...) end +function error(...) textadept._print(textadept.locale.ERROR_BUFFER, ...) end diff --git a/core/ext/find.lua b/core/ext/find.lua index cc7763d6..566ff0d9 100644 --- a/core/ext/find.lua +++ b/core/ext/find.lua @@ -124,7 +124,8 @@ function find.find(text, next, flags, nowrap, wrapped) if #matches == 1 then matches[2] = locale.FIND_NO_RESULTS end matches[#matches + 1] = '' previous_view = view - textadept._print('shows_files_found', table.concat(matches, '\n')) + textadept._print(locale.FIND_FILES_FOUND_BUFFER, + table.concat(matches, '\n')) end return end @@ -255,7 +256,7 @@ end -- @param pos The position of the caret. -- @param line_num The line double-clicked. function goto_file(pos, line_num) - if buffer.shows_files_found then + if buffer._type == textadept.locale.FIND_FILES_FOUND_BUFFER then line = buffer:get_line(line_num) local file, line_num = line:match('^(.+):(%d+):.+$') if file and line_num then diff --git a/core/ext/pm/buffer_browser.lua b/core/ext/pm/buffer_browser.lua index b92d2768..0bac4818 100644 --- a/core/ext/pm/buffer_browser.lua +++ b/core/ext/pm/buffer_browser.lua @@ -16,10 +16,12 @@ end function get_contents_for() local contents = {} for index, buffer in ipairs(textadept.buffers) do + local filename = + buffer.filename or buffer._type or textadept.locale.UNTITLED index = string.format("%02i", index) contents[index] = { pixbuf = buffer.dirty and 'gtk-edit' or 'gtk-file', - text = (buffer.filename or textadept.locale.UNTITLED):match('[^/\\]+$') + text = filename:match('[^/\\]+$') } end return contents diff --git a/core/file_io.lua b/core/file_io.lua index d296aa03..4dce2721 100644 --- a/core/file_io.lua +++ b/core/file_io.lua @@ -100,6 +100,7 @@ function save(buffer) else textadept.events.error(err) end + if buffer._type then buffer._type = nil end end --- diff --git a/core/init.lua b/core/init.lua index f6563c8b..e792a515 100644 --- a/core/init.lua +++ b/core/init.lua @@ -53,15 +53,15 @@ end -- buffer, and prints to it. -- @param buffer_type String type of message buffer. -- @param ... Message strings. --- @usage textadept._print('shows_errors', error_message) --- @usage textadept._print('shows_messages', message) +-- @usage textadept._print(textadept.locale.ERROR_BUFFER, error_message) +-- @usage textadept._print(textadept.locale.MESSAGE_BUFFER, message) function textadept._print(buffer_type, ...) local function safe_print(...) local message = table.concat({...}, '\t') local message_buffer, message_buffer_index local message_view, message_view_index for index, buffer in ipairs(textadept.buffers) do - if buffer[buffer_type] then + if buffer._type == buffer_type then message_buffer, message_buffer_index = buffer, index for jndex, view in ipairs(textadept.views) do if view.doc_pointer == message_buffer.doc_pointer then @@ -76,7 +76,7 @@ function textadept._print(buffer_type, ...) local _, message_view = view:split(false) -- horizontal split if not message_buffer then message_buffer = textadept.new_buffer() - message_buffer[buffer_type] = true + message_buffer._type = buffer_type else message_view:goto_buffer(message_buffer_index, true) end @@ -93,7 +93,9 @@ end -- Prints messages to the Textadept message buffer. -- Opens a new buffer (if one hasn't already been opened) for printing messages. -- @param ... Message strings. -function textadept.print(...) textadept._print('shows_messages', ...) end +function textadept.print(...) + textadept._print(textadept.locale.MESSAGE_BUFFER, ...) +end --- -- Displays a CocoaDialog of a specified type with given arguments returning diff --git a/core/locale.lua b/core/locale.lua index 6cfb8f85..26a7f1fe 100644 --- a/core/locale.lua +++ b/core/locale.lua @@ -15,6 +15,8 @@ module('textadept.locale', package.seeall) -- Untitled UNTITLED = 'Untitled' +-- [Message Buffer] +MESSAGE_BUFFER = '[Message Buffer]' -- OVR STATUS_OVR = 'OVR' -- INS @@ -47,6 +49,8 @@ The following buffers are unsaved: You will have to save changes manually. ]] +-- [Error Buffer] +ERROR_BUFFER = '[Error Buffer]' -- core/file_io.lua @@ -90,6 +94,8 @@ FIND_REPLACEMENTS_MADE = '%d replacement(s) made' FIND_IN_FILES_TITLE = 'Find in Files' -- Select Directory to Search FIND_IN_FILES_TEXT = 'Select Directory to Search' +-- [Files Found Buffer] +FIND_FILES_FOUND_BUFFER = '[Files Found Buffer]' -- core/ext/keys.lua diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua index f60bf2b5..147c8055 100644 --- a/modules/textadept/run.lua +++ b/modules/textadept/run.lua @@ -179,7 +179,8 @@ local error_details = { -- @param line_num The line double-clicked. -- @see error_details function goto_error(pos, line_num) - if buffer.shows_messages or buffer.shows_errors then + local locale = textadept.locale + if buffer._type == locale.MESSAGE_BUFFER or buffer._type == 'error_buffer' then line = buffer:get_line(line_num) for _, error_detail in pairs(error_details) do local captures = { line:match(error_detail.pattern) } |