For languages like c/c++ where there are large source files and lots of include files this feature works well.
But for languages like Java, where there are no include files and each public class must be in a source file of it's own, then this function does not work so well

Fortunately it is possible to improve on the functionality using a macro script. The macro script shown below will take the word under the current cursor or any marked area and try to load it as a file.
Save the following code to the openinclude.lua in the Zeus zScript directory:
Code: Select all
function file_exists(file_name)
  -- use the Lua file functions to check if the file exists
  local file_handle = io.open(file_name, "r")
  -- check for success
  if file_handle ~= nil then
      -- close the Lua file handle
      file_handle:close()
      -- the file exists
      return 1
  end
  -- the file doe snot exist
  return 0
end
function key_macro()
  -- This macro will only work for document windows.
  local document = is_document ()
  if (document == 0) then
     message("This macro only works for document files!")
     beep()
     return 1
  end
  -- get the word under the cursor or the current marked area
  local current_word = macro_tag("$WEX")
  local current_len = string.len(current_word)
  if (current_len > 0) then
    -- get the extension of the current file
    local file_path      = macro_tag("$FDD")
    local file_extension = macro_tag("$E")
    -- build up a file name
    local file_name = file_path .. current_word .. file_extension
    -- check if the file exists
    if (file_exists(file_name) == 1) then
        -- open the file in Zeus
        file_open(file_name)
        -- all done
        return 1;
    end
  end
  -- no luck with the current word so try the built-in function
  FileOpenInLine()
end
key_macro() -- run the macro
Code: Select all
public class MyObject extends SomeBaseObject
{
}
Using this macro it is posisble to load the SomeBaseObject.java file by placing the cursor on the word SomeBaseObject and simply running the macro.
For more information on running Zeus macros see the Binding a Macro to the Keyboard example.
For more information on Lua goto this link: http://www.lua.org/manual/5.0/manual.html
