editors: GTK error reporting

new topic     » topic index » view thread      » older message » newer message

In Irv Mullins' latest EuGTK you will find a very much improved version of gneui (EuGeany). Everyone should start using Irv's version immediately.

I would like to see Irv's code adapted to work with ed.ex's ex.err/error processing routines.

Here is the code. NICE WORK, IRV! And thanks again for EuGTK!

 
-- 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.  
--  
--// Heavily modified by Irv Mullins to handle signal 11 errors from GTK 
--// will usually leave the cursor on the line where the error occurs... 
 
include std/io.e  
include std/convert.e  
include std/error.e  
include std/filesys.e  
 
object file_name, command 
integer exit_code = 0 
 
sequence cl = command_line()  
clear_screen()  
if length(cl) >= 3 then  
    file_name = cl[3]  
    -- UNIX: 
    ifdef UNIX then  
		command = sprintf( "eui -D DEBUG \"%s\"", {file_name} )  
    elsedef  
    -- WIN: 
		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  
		ParseErrorFile()  
    end if  
     
end if  
system("clear",0)  
 
-------------------------- 
procedure ParseErrorFile()  
-------------------------- 
object file_lines 
object temp_line 
object err_line 
integer err_col = 0, i = 0 
 
	file_lines = read_lines("ex.err") 
	if atom(file_lines) then  
		crash("Cannot find ex.err!\n")  
	else 
		printf(1,"Read %d lines\n",length(file_lines)) 
	end if 
 
	for n = 1 to length(file_lines) do 
		if match("^^^ call-back from external source",file_lines[n]) = 1 then 
			file_lines = file_lines[1..n-1] 
			printf(1,"Lines clipped: %d\n",length(file_lines)) 
			exit 
		end if 
	end for 
  
	-- trap & process GTK signal 11 errors; 
		for n = length(file_lines) to 2 by -1 do 
			if match("... called from /", file_lines[n]) then  
				i = find(':', file_lines[n])  
				file_name = file_lines[n][17..i-1] 
				err_line = file_lines[n][i+1..$] 
				i = find(' ',err_line) 
				err_line = err_line[1..i-1] 
				err_line = to_number(err_line) 
				printf(1,"FILE:%s - LINE:%d \n",{file_name,err_line}) 
				system( sprintf("geany \"%s:%d\"", {file_name, err_line} ))  
				abort(0) 
			end if 
		end for 
 
	-- trap & process euphoria error report; 
		for n = 1 to length(file_lines) do 
			if find('^', file_lines[n]) then 
				i = find(':',file_lines[1]) 
				err_col = match("^",file_lines[n])-1 
				file_name = file_lines[1][1..i-1] 
				err_line = to_number(file_lines[1][i+1..$]) 
				printf(1,"FILE:%s - LINE:%d COL:%d\n",{file_name,err_line,err_col}) 
				system( sprintf("geany \"%s:%d:%d\" & ", {file_name, err_line, err_col} ))  
				abort(0) 
			end if  
		end for 
 
end procedure  
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu