Code folding request: Arbortext Command Language
Posted: Fri Jan 21, 2011 5:44 am
Hi Jussi,
Would you please add folding support for "Arbortext Command Language" (as used by the SGML/XML editor "Arbortext Editor").
Extensions: .acl
Line Comment: #
Block Comment: [not supported]
Begin: {
End: }
Sample Code:
Thanks!
Would you please add folding support for "Arbortext Command Language" (as used by the SGML/XML editor "Arbortext Editor").
Extensions: .acl
Line Comment: #
Block Comment: [not supported]
Begin: {
End: }
Sample Code:
Code: Select all
function layout::linenum(doc = current_doc(), source = -1)
{
local line_counter = 1;
local row_line_base = 0;
local row_line_counter = 1;
local errors = 0;
local i;
local save_doc = current_doc(doc);
#walk the doc from start to end,
#modifying each startline attr1 with the value of the line counter
#and each startpage attr1 with the value of its number attribute
local oids[];
oid_find_children(oid_null(), oids, "atipl::*", 0x08);
for(i in oids) {
local name = oid_name(oids[i]);
layout::clear_attrs(oids[i]);
if( name == "atipl:startpage" ) {
if(!oid_modify_attr(oids[i], "attr1", oid_attr(oids[i], "number")) ){
_composerlog::add_record($_eventlog::SEVERITY_ERROR, 'Unable to modify startpage attr1 for oid: ' . $oids[i]);
errors++;
}
line_counter = 1;
}
#only set attr1 on startlines that contain something other than gentext
else if( ( name == "atipl:startline" ) && ( ( oid_attr(oids[$i], "typemask" ) ) & 1 ) ){
if( row_line_base == 0 || row_line_counter <= line_counter) {
if(!oid_modify_attr(oids[i], "attr1", $line_counter)){
_composerlog::add_record($_eventlog::SEVERITY_ERROR, 'Unable to modify startline attr1 for oid: ' . $oids[i]);
errors++;
}
}
line_counter++;
}
else if( name == "atipl:startrow" ) {
row_line_base = line_counter;
row_line_counter = 0;
}
else if( name == "atipl:endrow" ) {
if(line_counter < row_line_counter) {
line_counter = row_line_counter;
}
row_line_base = 0;
}
else if( name == "atipl:startentry" ) {
line_counter = row_line_base;
}
else if( name == "atipl:endentry" ) {
if (row_line_counter < line_counter) {
row_line_counter = line_counter;
}
}
}
# toggle gentext in order to force a redisplay
if(option("gentext") == "on") {
set gentext=off;
set gentext=on;
}
# reset the current doc
current_doc(save_doc);
return (errors == 0);
}