Re: ex.err & Geany

new topic     » goto parent     » topic index » view thread      » older message » newer message
petelomax said...

Right, I see what I was missing now. I would comment the line that mislead me thusly:

    file_name = trim(err_lines[1]) -- nb file_name is eg "path\test.ex:85" 

or rename that var to say name_colon_error_line

Regards,
Pete

Point taken. Your comments and suggestions are appreciated.

This is my latest effort:

-- 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 
 
procedure get_err_line() 
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])  -- eg: path/test.ex:18 
	msg = trim(err_lines[2]) 
	system( sprintf("geany \"%s:%d:\"", {file_name, start_col} ) ) 
    end if 
    end if 
end procedure 
 
sequence cl = command_line() 
clear_screen() 
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, 0 ) 
    if exit_code != 0 then 
    get_err_line() 
    end if 
else 
    get_err_line() 
end if 
clear_screen() 
abort(0) 
 
 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu