~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to editors/qeditor/ada_indent.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2003 Oliver Kellogg
 
3
 * okellogg@users.sourceforge.net
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 */
 
10
#include "ada_indent.h"
 
11
#include "qeditor.h"
 
12
#include <kdebug.h>
 
13
 
 
14
AdaIndent::AdaIndent( QEditor* ed )
 
15
    : QEditorIndenter( ed ),
 
16
    rxCompoundStmt("^\\s*(begin|for|declare|while|case|loop|if|else|subtype|type)\\b.*")
 
17
{
 
18
}
 
19
 
 
20
AdaIndent::~AdaIndent()
 
21
{
 
22
}
 
23
 
 
24
int AdaIndent::indentForLine( int line )
 
25
{
 
26
    if( line == 0 )
 
27
        return 0;
 
28
 
 
29
    int prevLine = QMAX( 0, previousNonBlankLine( line ) );
 
30
    int sw = 3;
 
31
 
 
32
    QString lineText = editor()->text( line );
 
33
    QString prevLineText = editor()->text( prevLine );
 
34
 
 
35
    int lineInd = indentation( lineText );
 
36
    int prevLineInd = indentation( prevLineText );
 
37
 
 
38
    kdDebug() << "lineText=" << lineText << "  prevLineText=" << prevLineText << " indent prev=" << lineInd << endl;
 
39
 
 
40
    if (rxCompoundStmt.exactMatch(prevLineText))
 
41
    {
 
42
        kdDebug() << "exact match for compound statement match" << endl;
 
43
        return prevLineInd + sw;
 
44
    }
 
45
    else
 
46
        return prevLineInd;
 
47
}
 
48