From a87821f93d5a6cf08c28059c6846a6f794f29d4c Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sat, 6 Oct 2007 20:51:34 -0400 Subject: Added support for "double-click, goto error" in error buffer; core/events.lua --- core/events.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'core') diff --git a/core/events.lua b/core/events.lua index 3fe609e3..13a41077 100644 --- a/core/events.lua +++ b/core/events.lua @@ -247,6 +247,42 @@ add_handler('save_point_left', set_title(buffer) end) +--- +-- [Local table] A table of error string details. +-- Each entry is a table with the following fields: +-- pattern: the Lua pattern that matches a specific error string. +-- filename: the index of the Lua capture that contains the filename the error +-- occured in. +-- line: the index of the Lua capture that contains the line number the error +-- occured on. +-- message: [Optional] the index of the Lua capture that contains the error's +-- message. A call tip will be displayed if a message was captured. +-- When an error message is double-clicked, the user is taken to the point of +-- error. +-- @class table +-- @name _error_details +local _error_details = { + lua = { pattern = '^lua: ([^:]+):(%d+): (.+)$', + filename = 1, line = 2, message = 3 } +} + +add_handler('double_click', + function(pos, line_num) -- goes to the file and line specified by line's text + if buffer.shows_errors then + line = buffer:get_line(line_num) + for _, error_detail in pairs(_error_details) do + local captures = { line:match(error_detail.pattern) } + if #captures > 0 then + textadept.io.open( captures[error_detail.filename] ) + _m.textadept.editing.goto_line( captures[error_detail.line] ) + local msg = captures[error_detail.message] + if msg then buffer:call_tip_show(buffer.current_pos, msg) end + break + end + end + end + end) + --- -- [Local table] A table of (integer) brace characters with their matches. -- @class table -- cgit v1.2.3