When it comes to code reformatting, it is easy to seamlessly integrate external formatters into Zeus. Here are at least two examples of how this is done:
So provided you can find a Fortran code formatter utility it should easy enough to integrate into Zeus
Zeus itself has a very limited code reformatting capability. Basically all it can do is indent/un-indent any marked area using the
Tab and
Shift+Tab keys
But one other option is to do the reformatting as the code is entered. In this case there are a few more options
Option #1 It is possible to use the
code templates feature to define your basic code constructs.
Option #2 Using a macro you can also make Zeus indent on the enter key. For example consider this Lua macro which when bound to the Enter key will indent on the
subroutine,
if and
do keywords.
NOTE: This macro is nothing more than a quick two minute effort, and will most certainly still need some improvement. It is presented here only as an example of what is possible.
Code: Select all
--
-- Name: Fortran Enter Key Macro
--
-- Language: Lua Macro
--
-- Description: Does a special Fortran processing on the enter key.
--
function key_macro()
-- check for read/write documents
local locked = is_read_only()
-- check for document windows
local document = is_document()
if (locked == 1) or (document == 0) then
-- leave this case to the default enter function
Enter()
else
-- get the current line
local current_line = get_line_text()
-- add the enter key
Enter()
local need_indent = false;
-- see if line starts with 'subroutine'
if (string.find(current_line, "subroutine") == 1) then
need_indent = true;
end
-- see if line starts with 'do' allowinf white space
if (string.find(current_line, "[%s]*do") == 1) then
need_indent = true;
end
-- see if line starts with 'do' allowinf white space
if (string.find(current_line, "[%s]*if") == 1) then
need_indent = true;
end
-- add the indent if required
if (need_indent == true) then
TabChar()
end
end
end
key_macro() -- run the macro
Cheers Jussi