SUCESS! ex.err support for Geany!
- Posted by K_D_R Mar 21, 2013
- 3503 views
Thanks to everyone for the help
This code succeeds in positioning the cursor in the offending file at the line and column of the error as reported by ex.err
For what it is worth, the get_err_line code in ed.ex needs some work. I discovered that it was not setting the cursor at the error column either.
ONE CAVEAT: I suspect that this code might not position the cursor properly on lines with leading tabs.
-- gneui.ex 1.0 -- -- 2013 2013-03-21 -- Kenneth Rhodes <wolfmanjacques@gmail.com> -- -- This file wraps the Euphoria interpreter -- together with a routine which extracts -- ex.err file data and passes the name, -- path, line and column to the Geany editor -- -- -- usage: Geany run_cmd = eui gneui.ex ./%f -- Set run source code command to this as well, -- Execute your code from Geany, upon error, -- Geany will position the cursor at the line -- and column of the error. -- -- include std/io.e include std/convert.e include std/console.e include std/error.e include std/filesys.e include std/text.e include std/wildcard.e integer err_file, wcmatch sequence err_lines object temp_line sequence msg integer TRUE = 1, FALSE = 2 integer cont = TRUE type natural(integer x) return x >= 0 end type natural start_line, start_col start_line = 1 start_col = 1 object file_name = "", command = "" integer exit_code = 0 sequence cl = command_line() if length(cl) >= 3 then file_name = cl[3] ifdef UNIX then command = sprintf( "eui -D DEBUG \"%s\"", {file_name} ) elsedef if wildcard:is_match( "*.ew", file_name ) or wildcard:is_match( "*.exw", file_name) then command = sprintf( "euiw -D DEBUG \"%s\"", {file_name} ) else command = sprintf( "eui -D DEBUG \"%s\"", {file_name} ) end if end ifdef if file_exists("ex.err") then delete_file("ex.err") end if exit_code = system_exec( command ) if exit_code != 0 then err_file = open( "ex.err", "r" ) if err_file = -1 then msg = "" else -- read the top of the ex.err error message file err_lines = {} while cont do temp_line = gets(err_file) if atom(temp_line) then exit end if err_lines = append(err_lines, temp_line) if find('^', temp_line) then start_col = match("^", temp_line)-1 cont = FALSE end if end while close(err_file) -- look for file name, line, column and error messag if length(err_lines) > 0 then file_name = trim(err_lines[1]) msg = trim(err_lines[2]) system_exec( sprintf("geany \"%s:%d:\"", {file_name, start_col}) ) end if end if end if end if clear_screen() abort(0)