Re: ex.err & Geany

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

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu