diff options
author | 2007-10-06 20:51:34 -0400 | |
---|---|---|
committer | 2007-10-06 20:51:34 -0400 | |
commit | a87821f93d5a6cf08c28059c6846a6f794f29d4c (patch) | |
tree | 954f77e50caaa6ed5a065376a800c9542985568c | |
parent | ece35a566f002bb0454d3f02a87ca51a48a7c7c5 (diff) | |
download | textadept-a87821f93d5a6cf08c28059c6846a6f794f29d4c.tar.gz textadept-a87821f93d5a6cf08c28059c6846a6f794f29d4c.zip |
Added support for "double-click, goto error" in error buffer; core/events.lua
-rw-r--r-- | core/events.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/core/events.lua b/core/events.lua index 3fe609e3..13a41077 100644 --- a/core/events.lua +++ b/core/events.lua @@ -248,6 +248,42 @@ add_handler('save_point_left', 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 -- @name _braces |