# Java language templates

eventmap JAVA {
    # these work well for default indentation settings
    # changes may be necessary if you use different indentation
    
    # typical usage would be typing ifx and <space>.
    # useful command here is <A+Enter> which adds 
    # a new line after the current one, and indents it properly.
    # in cmode defined as LineAdd; LineIndent;
    abbrev 'ifx' {
        KillWordPrev;
%if(BSD_BRACE)
        InsertString 'if ()'; MoveLeft; SavePos; MoveRight; LineIndent; LineNew;
        InsertString '{'; LineIndent; LineNew;
%endif
%if(1TBS_BRACE)
        InsertString 'if () {'; 3:MoveLeft; SavePos; 3:MoveRight; LineIndent; LineNew; 
%endif
        InsertString '}'; LineIndent; 
        MoveSavedPos; Fail; # do not insert typed character
    }
    abbrev 'whx' { 
        KillWordPrev;
%if(BSD_BRACE)
        InsertString 'while ()'; MoveLeft; SavePos; MoveRight; LineIndent; LineNew;
        InsertString '{'; LineIndent; LineNew;
%endif
%if(1TBS_BRACE)
        InsertString 'while () {'; 3:MoveLeft; SavePos; 3:MoveRight; LineIndent; LineNew; 
%endif
        InsertString '}'; LineIndent; 
        MoveSavedPos; Fail;
    }
    abbrev 'swx' { 
        KillWordPrev;
%if(BSD_BRACE)
        InsertString 'switch ()'; MoveLeft; SavePos; MoveRight; LineIndent; LineNew;
        InsertString '{'; LineIndent; LineNew;
%endif
%if(1TBS_BRACE)
        InsertString 'switch () {'; 3:MoveLeft; SavePos; 3:MoveRight; LineIndent; LineNew; 
%endif
        InsertString '}'; LineIndent; 
        MoveSavedPos; Fail;
    }
    abbrev 'cax' {
        KillWordPrev; InsertString 'case :'; LineIndent; LineNew;
        InsertString 'break;'; LineIndent;
        MoveUp; MoveLineEnd; MovePrev;
        Fail;
    }
    abbrev 'dex' {
        KillWordPrev; InsertString 'default:'; LineIndent; 2:LineNew;
        InsertString 'break;'; LineIndent;
        MoveUp; LineIndent;
        Fail;
    }
}

