1. ex.err & Geany

Forked from Re: EuGeany 1.2

SDPringle said...

Some time ago, I documented a way one could associate .err with ed.exe, in the Installation (Section 2.? ). You need to modify the registry. When done you only click the ex.err file and ed.exe opens for you. Now, if we have a way of directing an editor to go to some line in a given file at the command line, you can strip out pieces of ed.ex and call whatever editor that can do that. But often it is not the inner most frame that has the problem. It is the caller of that routine, calling it badly for example.

Shawn Pringle

Geany Manual said...

file:///usr/share/doc/geany/html/index.html#id30

Geany detects if there is an an instance of itself already running and opens files from the command-line in that instance. So, Geany can be used to view and edit files by opening them from other programs such as a file manager.

You can also pass line number and column number information, e.g.:

geany some_file.foo:55:4

This would open the file some_file.foo with the cursor on line 55, column 4.

So... If we had a little euphoria program, as you have described, which could be executed from Geany's builtin terminal interface upon a crash/error, it could pass the filename, error line, and error column to Geany. Indeed, multiple files could be opened if necessary, Yes?

Regards, Ken

new topic     » topic index » view message » categorize

2. Re: ex.err & Geany

K_D_R said...

Forked from Re: EuGeany 1.2

...snip...

So... If we had a little euphoria program, as you have described, which could be executed from Geany's builtin terminal interface upon a crash/error, it could pass the filename, error line, and error column to Geany. Indeed, multiple files could be opened if necessary, Yes?

Regards, Ken

Couldn't you just use crash_routine() for this?

include "std/error.e" 
include "std/text.e" 
 
function geany_crash( integer dummy ) 
   
    integer fn = open( "ex.err", "r" ) 
    if fn = -1 then 
        return 0 
    end if 
     
    object line = gets( fn ) 
    if sequence( line ) then 
 
        line = text:trim( line ) -- e.g. C:\path\to\file:1234 
         
        sequence command = sprintf( "geany \"%s\"", {line} ) 
        system_exec( command ) 
         
    end if 
     
    close( fn ) 
     
    return 0 and dummy 
end function 
crash_routine( routine_id("geany_crash") ) 

You could probably even wrap that in an ifdef DEBUG statement, and then add "-D DEBUG" to your run_cmd. Maybe you could even add custom "build targets" for Debug/Release.

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: ex.err & Geany

ghaberek said...
K_D_R said...

Forked from Re: EuGeany 1.2

...snip...

So... If we had a little euphoria program, as you have described, which could be executed from Geany's builtin terminal interface upon a crash/error, it could pass the filename, error line, and error column to Geany. Indeed, multiple files could be opened if necessary, Yes?

Regards, Ken

Couldn't you just use crash_routine() for this?

include "std/error.e" 
include "std/text.e" 
 
function geany_crash( integer dummy ) 
   
    integer fn = open( "ex.err", "r" ) 
    if fn = -1 then 
        return 0 
    end if 
     
    object line = gets( fn ) 
    if sequence( line ) then 
 
        line = text:trim( line ) -- e.g. C:\path\to\file:1234 
         
        sequence command = sprintf( "geany \"%s\"", {line} ) 
        system_exec( command ) 
         
    end if 
     
    close( fn ) 
     
    return 0 and dummy 
end function 
crash_routine( routine_id("geany_crash") ) 

You could probably even wrap that in an ifdef DEBUG statement, and then add "-D DEBUG" to your run_cmd. Maybe you could even add custom "build targets" for Debug/Release.

-Greg

I am clueless ... like this?

-- 
-- eugeany.ex 
-- 
-- usage: Geany run_cmd = eui eugeany.ex ./%f 
-- 
-- 
-- 
 
include "std/error.e" 
include "std/text.e" 
 
function geany_crash( integer dummy ) 
   
    integer fn = open( "ex.err", "r" ) 
    if fn = -1 then 
        return 0 
    end if 
     
    object line = gets( fn ) 
    if sequence( line ) then 
 
        line = text:trim( line ) -- e.g. C:\path\to\file:1234 
         
        sequence command = sprintf( "geany \"%s\"", {line} ) 
        system_exec( command ) 
         
    end if 
     
    close( fn ) 
     
    return 0 and dummy 
end function 
crash_routine( routine_id("geany_crash") ) 
 
ifdef DEBUG then 
 crash_routine() 
end ifdef 
 
 
-- it may be possible to simply 
-- set Geany's run_cmd = eui ./%f -D DEBUG 
-- in which case the following code may 
-- not be necessary. 
sequence file_name = "" 
sequence cl = command_line() 
if length(cl) >= 3 then 
 
   ifdef UNIX then 
 
       file_name = cl[3] 
        
       if file_exists("ex.err")  
           
            system("rm " & "ex.err", 0) 
        
       end if 
                                                           
       system("eui \"" & file_name & "\""  & "-D DEBUG", 1) 
    
 
   elsedef 
 
       file_name = lower(cl[3]) 
 
            if file_exists("ex.err") 
             
                 system("del " & "ex.err > NUL", 0)                                                             
          
            end if 
 
 
            if match(".exw", lower(file_name) & "-D DEBUG", 1) or  
                    match(".ew",  lower(file_name)) then 
 
                 system("euiw \"" & file_name & "\"" & "-D DEBUG", 1) 
 
            else 
 
                 system("eui \"" & file_name & "\"" & "-D DEBUG", 1) 
 
            end if 
 
   end ifdef 
 
end if 
    
new topic     » goto parent     » topic index » view message » categorize

4. Re: ex.err & Geany

K_D_R said...

I am clueless ... like this?

Option #1

Put the geany_crash() function into the top of your app you are editing and running from Geany. Then if your app crashes, it automatically invokes Geany to display the error line from the ex.err file. Then add -D DEBUG to the run_cmd line for Euphoria files (you technically are debugging if you're running from the editor, correct?). No extra launcher required!

Option #2

Use a dedicated launcher (eugeany.ex) to see if the app crashed, and invoke Geany to the the error line from the ex.err file as needed. In this case, use system_exec() instead of just system() so you can catch the result of abort(). If you get back a zero [0], then everything was successful. If it's anything else, your app "crashed".

-- 
-- eugeany.ex 
-- 
-- usage: Geany run_cmd = eui eugeany.ex ./%f 
-- 
 
include "std/error.e" 
include "std/filesys.e" 
include "std/text.e" 
include "std/wildcard.e" 
 
sequence file_name = "", command = "" 
sequence cl = command_line() 
integer exit_code = 0 
if length(cl) >= 3 then 
 
    file_name = cl[3] 
     
    if file_exists("ex.err")  
        delete_file("ex.err") 
    end if 
     
    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 
     
    exit_code = system_exec( command ) 
     
    if exit_code != 0 then 
         
        -- from geany_crash() 
         
        integer fn = open( "ex.err", "r" ) 
        if fn = -1 then 
            return 0 
        end if 
         
        object line = gets( fn ) 
        if sequence( line ) then 
             
            line = text:trim( line ) -- e.g. C:\path\to\file:1234 
             
            -- this assumes 'geany' is in your PATH 
            system_exec( sprintf("geany \"%s\"", {line}) ) 
             
        end if 
         
        close( fn ) 
         
    end if 
     
end if 

-Greg

new topic     » goto parent     » topic index » view message » categorize

5. Re: ex.err & Geany

Once more, with feeling...

edit: 2013-03-19 to show error message

 
-- gneui.ex 
-- 
-- 2013 2013-03-18 
-- Kenneth Rhodes <wolfmanjacques@gmail.com> 
-- 
-- 
-- gneui.ex 
-- 
-- usage: Geany run_cmd = eui gneui.ex ./%f 
-- 
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" 
 
file_number err_file 
sequence err_lines 
object temp_line 
sequence msg 
integer TRUE = 1 
 
constant STANDARD_TAB_WIDTH = 8 
 
type natural(integer x) 
    return x >= 0 
end type 
natural start_line, start_col, colon_pos 
 
type positive_int(integer x) 
    return x >= 1 
end type 
 
function tab(natural tab_width, positive_int pos) 
    -- compute new column position after a tab 
    return (floor((pos - 1) / tab_width) + 1) * tab_width + 1 
end function 
 
function expand_tabs(natural tab_width, sequence line) 
    -- replace tabs by blanks in a line of text 
    natural tab_pos, column, ntabs 
     
    column = 1 
    while TRUE do 
	tab_pos = find('\t', line[column..length(line)]) 
	if tab_pos = 0 then 
	    -- no more tabs 
	    return line 
	else 
	    tab_pos += column - 1 
	end if 
	column = tab(tab_width, tab_pos) 
	ntabs = 1 
	while line[tab_pos+ntabs] = '\t' do 
	    ntabs += 1 
	    column += tab_width 
	end while 
	-- replace consecutive tabs by blanks 
	line = line[1..tab_pos-1] &  
	repeat(' ', column - tab_pos) & 
	line[tab_pos+ntabs..length(line)]             
    end while 
end function 
 
sequence 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 
	-- from geany_crash() and ed.ex 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 length(err_lines) < 6 do 
		    temp_line = gets(err_file) 
		    if atom(temp_line) then 
			exit 
		    end if 
		    err_lines = append(err_lines, temp_line) 
	    end while 
	    close(err_file) 
	    -- look for file name, line, column and error messag 
	    if length(err_lines) > 1 and match("TASK ID ", err_lines[1]) then 
		err_lines = err_lines[2..$] 
	    end if 
	    if length(err_lines) > 0 then 
		if sequence(err_lines[1]) then 
		    colon_pos = match(".e", lower(err_lines[1])) 
		    if colon_pos then 
			if find(err_lines[1][colon_pos+2], "dxXwWuU") then 
			    colon_pos += 1 
			    if find(err_lines[1][colon_pos+2], "wxWuU") then 
				colon_pos += 1 
			    end if 
			end if 
			file_name = err_lines[1][1..colon_pos+1] 
			start_line = to_integer(err_lines[1][colon_pos+3..length(err_lines[1])]) 
			msg = trim(err_lines[2]) 
			 
			if length(err_lines) > 3 then 
			    start_col = find('^', expand_tabs(STANDARD_TAB_WIDTH,  
						err_lines[length(err_lines)-1])) 
			end if 
 
			-- show error message 
                        if length(error_message) > 0 then                                                                          
                             puts(SCREEN, error_message)                                                                                
                        end if 
                   
			file_name = file_name & ":" & start_line & ":" & start_col 
--                      open file in Geany with cursor placed at error line & column 
			system_exec( sprintf("geany \"%s\"", {file_name}) ) 
		    end if 
		end if 
	    end if 
	end if 
    end if 
end if 
 
 
new topic     » goto parent     » topic index » view message » categorize

6. Re: ex.err & Geany

Update: This version works very, very well ... with one exception - on error, it loads the file with errors and positions the cursor on the proper line, but it does not move the cursor to the column position of the error.

-- gneui.ex 
-- 
-- 2013 2013-03-19 
-- Kenneth Rhodes <wolfmanjacques@gmail.com> 
-- 
-- 
-- gneui.ex 
-- 
-- usage: Geany run_cmd = eui gneui.ex ./%f 
-- set run source code command to this as well 
-- 
--  
-- 
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" 
 
file_number err_file 
sequence err_lines, fline 
object temp_line 
sequence msg 
integer TRUE = 1 
 
constant STANDARD_TAB_WIDTH = 8 
 
type natural(integer x) 
    return x >= 0 
end type 
natural start_line, start_col, colon_pos 
start_line = 1 start_col = 1 
 
type positive_int(integer x) 
    return x >= 1 
end type 
 
function tab(natural tab_width, positive_int pos) 
    -- compute new column position after a tab 
    return (floor((pos - 1) / tab_width) + 1) * tab_width + 1 
end function 
 
function expand_tabs(natural tab_width, sequence line) 
    -- replace tabs by blanks in a line of text 
    natural tab_pos, column, ntabs 
 
    column = 1 
    while TRUE do 
    tab_pos = find('\t', line[column..length(line)]) 
    if tab_pos = 0 then 
        -- no more tabs 
        return line 
    else 
        tab_pos += column - 1 
    end if 
    column = tab(tab_width, tab_pos) 
    ntabs = 1 
    while line[tab_pos+ntabs] = '\t' do 
        ntabs += 1 
        column += tab_width 
    end while 
    -- replace consecutive tabs by blanks 
    line = line[1..tab_pos-1] & 
    repeat(' ', column - tab_pos) & 
    line[tab_pos+ntabs..length(line)] 
    end while 
end function 
 
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 
    -- from geany_crash() and ed.ex 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 length(err_lines) < 6 do 
            temp_line = gets(err_file) 
            if atom(temp_line) then 
            exit 
            end if 
            err_lines = append(err_lines, temp_line) 
        end while 
        close(err_file) 
        -- look for file name, line, column and error messag 
        if length(err_lines) > 1 and match("TASK ID ", err_lines[1]) then 
        err_lines = err_lines[2..$] 
        end if 
        if length(err_lines) > 0 then 
        if sequence(err_lines[1]) then 
            colon_pos = match(".e", lower(err_lines[1])) 
            if colon_pos then 
            if find(err_lines[1][colon_pos+2], "dxXwWuU") then 
                colon_pos += 1 
                if find(err_lines[1][colon_pos+2], "wxWuU") then 
                colon_pos += 1 
                end if 
            end if 
--            file_name = err_lines[1][1..colon_pos+1] 
            file_name = err_lines[1][1..length(err_lines[1])] 
            start_line = to_integer(err_lines[1][colon_pos+3..length(err_lines[1])]) 
            msg = trim(err_lines[2]) 
            if length(err_lines) > 3 then 
              start_col = find('^', expand_tabs(STANDARD_TAB_WIDTH, 
                      err_lines[length(err_lines)-1])) 
            end if 
 
              -- return file_name 
 
--              start_l = sprint(start_line) 
--              start_c = sprint(start_col) 
            system_exec("geany " & file_name & ":" 
                                 & sprint(start_col)) 
 
 
            end if 
        end if 
        end if 
    end if 
    end if 
end if 
 
clear_screen() 
abort(0) 
 
 
new topic     » goto parent     » topic index » view message » categorize

7. Re: ex.err & Geany

Shouldn't that geany line be something like this... ?

-- usage: geany path_to_file:line:col 
system_exec( sprintf("geany \"%s:%d:%d\"", {file_name,start_line,start_col}) ) 

-Greg

new topic     » goto parent     » topic index » view message » categorize

8. Re: ex.err & Geany

ghaberek said...

Shouldn't that geany line be something like this... ?

-- usage: geany path_to_file:line:col 
system_exec( sprintf("geany \"%s:%d:%d\"", {file_name,start_line,start_col}) ) 

-Greg

Thanks again for your suggestion

No Joy with that code either. I am ashamed to admit how man hours today I have experimented with escape sequences, sprintf and sprint - the best I could come up with is:

--                    sets cursor on line 185 column 1 using:                                                 
--                    file_name = err_lines[1][1..length(err_lines[1])]                                        
--                    system_exec("geany " & file_name & ":" & sprint(start_col))                              
--                                                                                                             
--                    sets cursor on line 185 column 1 using:                                                 
--                    file_name = err_lines[1][1..colon_pos+1]                                                 
                      system_exec( sprintf("geany \"%s:%d:%d\"",  
                                      {file_name, start_line, start_col}) )         
                                                                                                               
--                    sets cursor correctly at line 185 column 26 using                                        
--                    file_name = err_lines[1][1..colon_pos+1]                                                 
--                    system_exec("geany " & file_name & ":185:26")                                            
                                                                                                               
--                  CONCLUSION: start_col is not getting "set" beyond its default value  
 
 
-- error.ex is my test file - an early version of gneui.ex.   
-- This is the ex.err file: 
/home/ken/edx-1.0/edx-1.0/edx/EuHelp/EuGeany/EuGeany-1.2/error.ex:185                                          
<0074>:: Errors resolving the following references:                                                            
        's_line' (error.ex:140) has not been declared.                                                         
        's_col' (error.ex:140) has not been declared.                                                          
        'set_position' (error.ex:140) has not been declared.                                                   
        'set_err_pointer' (error.ex:185) has not been declared.                                                
                                                                                                               
            set_err_pointer() --<--- this is not being "read"                                                                          
                           ^                                                                                   
                                                                                                               
                                                                                                               
--- Defined Words ---                                                                                          
EU4                                                                                                            
EU4_1                                                                                                          
EU4_1_0 
----------------------------------------------------- 
-----------------------------------------------------                                                                                    
 

Your comments and suggestions are appreciated.

Regards, Ken

new topic     » goto parent     » topic index » view message » categorize

9. SUCESS! ex.err support for Geany!

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) 
new topic     » goto parent     » topic index » view message » categorize

10. Re: ex.err & Geany

ghaberek said...

Shouldn't that geany line be something like this... ?

-- usage: geany path_to_file:line:col 
system_exec( sprintf("geany \"%s:%d:%d\"", {file_name,start_line,start_col}) ) 

-Greg

Has this been tried?

-- usage: geany path_to_file:line:col 
system_exec( sprintf("geany \"%s\":%d:%d", {file_name,start_line,start_col}) ) 

EDIT: Failing that, how about:

chdir(pathname(file_name)) 
system_exec( sprintf("geany %s:%d:%d", {filename(file_name),start_line,start_col}) ) 
new topic     » goto parent     » topic index » view message » categorize

11. Re: ex.err & Geany

petelomax said...
ghaberek said...

Shouldn't that geany line be something like this... ?

-- usage: geany path_to_file:line:col 
system_exec( sprintf("geany \"%s:%d:%d\"", {file_name,start_line,start_col}) ) 

-Greg

Has this been tried?

-- usage: geany path_to_file:line:col 
system_exec( sprintf("geany \"%s\":%d:%d", {file_name,start_line,start_col}) ) 

EDIT: Failing that, how about:

chdir(pathname(file_name)) 
system_exec( sprintf("geany %s:%d:%d", {filename(file_name),start_line,start_col}) ) 
err_lines = {} 
    while length(err_lines) < 6 do 
        temp_line = gets(err_file) 
        if atom(temp_line) then 
        exit 
        end if 
        err_lines = append(err_lines, temp_line) 
    end while 
    close(err_file) 

The problem was a simple bug in the ed.ex "get_err_line" routine:

err_lines = {} 
    while length(err_lines) < 6 do  --<----------- only 6 lines are being read 
                                    -- the '^' marking the error column was found 
                                    -- on line 9 
 
        temp_line = gets(err_file) 
        if atom(temp_line) then 
        exit 
        end if 
        err_lines = append(err_lines, temp_line) 
    end while 
    close(err_file) 

I resolved the problem by continuing to read lines from the file, until the '^' is matched:

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)  
new topic     » goto parent     » topic index » view message » categorize

12. Re: ex.err & Geany

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

new topic     » goto parent     » topic index » view message » categorize

13. Re: ex.err & Geany

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 message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu