KDevelop API Documentation

ada_indent.cpp

Go to the documentation of this file.
00001 /* $Id: ada_indent.cpp,v 1.1 2003/05/02 18:43:36 okellogg Exp $
00002  * Copyright (C) 2003 Oliver Kellogg
00003  * okellogg@users.sourceforge.net
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  */
00010 #include "ada_indent.h"
00011 #include "qeditor.h"
00012 #include <kdebug.h>
00013 
00014 AdaIndent::AdaIndent( QEditor* ed )
00015     : QEditorIndenter( ed ),
00016     rxCompoundStmt("^\\s*(begin|for|declare|while|case|loop|if|else|subtype|type)\\b.*")
00017 {
00018 }
00019 
00020 AdaIndent::~AdaIndent()
00021 {
00022 }
00023 
00024 int AdaIndent::indentForLine( int line )
00025 {
00026     if( line == 0 )
00027         return 0;
00028 
00029     int prevLine = QMAX( 0, previousNonBlankLine( line ) );
00030     int sw = 3;
00031 
00032     QString lineText = editor()->text( line );
00033     QString prevLineText = editor()->text( prevLine );
00034 
00035     int lineInd = indentation( lineText );
00036     int prevLineInd = indentation( prevLineText );
00037 
00038     kdDebug() << "lineText=" << lineText << "  prevLineText=" << prevLineText << " indent prev=" << lineInd << endl;
00039 
00040     if (rxCompoundStmt.exactMatch(prevLineText))
00041     {
00042         kdDebug() << "exact match for compound statement match" << endl;
00043         return prevLineInd + sw;
00044     }
00045     else
00046         return prevLineInd;
00047 }
00048 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:41 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003