summaryrefslogtreecommitdiffstats
path: root/kate/scripts/script-indent-c-char.js
blob: 975d77edced36c9490413d7e4d266c6e4690444b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var tabWidth = 4;
var spaceIndent = true;
var indentWidth = 4;

var line = view.cursorLine();
var col = view.cursorColumn();

var textLine = document.textLine( line );
var prevLine = document.textLine( line - 1 );

var prevIndent = prevLine.match(/^\s*/);
var addIndent = "";

function unindent()
{
//     if (
}

// unindent } and {, if not in a comment
if ( textLine.search( /^\s*\/\// ) == -1 )
{
    if ( textLine.charAt( col-1 ) == '}' || textLine.charAt( col-1 ) == '{')
    {
        if ( textLine.search(/^\s\s\s\s/) != -1)
        {
            document.removeText( line, 0, line, tabWidth );
            view.setCursorPositionReal( line, col - tabWidth );
        }
    }
}