kate Library API Documentation

KateAutoIndent Class Reference

Provides Auto-Indent functionality for katepart. More...

#include <kateautoindent.h>

List of all members.

Public Member Functions

 KateAutoIndent (KateDocument *doc)
virtual ~KateAutoIndent ()
void updateConfig ()
virtual void processNewline (KateDocCursor &cur, bool needContinue)
virtual void processChar (QChar)
virtual void processLine (KateDocCursor &)
virtual void processSection (KateDocCursor &, KateDocCursor &)
virtual bool canProcessLine ()
virtual uint modeNumber () const

Static Public Member Functions

KateAutoIndentcreateIndenter (KateDocument *doc, uint mode)
QStringList listModes ()
QString modeName (uint mode)
QString modeDescription (uint mode)
uint modeNumber (const QString &name)

Protected Member Functions

bool isBalanced (KateDocCursor &begin, const KateDocCursor &end, QChar open, QChar close, uint &pos) const
bool skipBlanks (KateDocCursor &cur, KateDocCursor &max, bool newline) const
uint measureIndent (KateDocCursor &cur) const
QString tabString (uint length) const

Protected Attributes

KateDocument * doc
uint tabWidth
uint indentWidth
uchar commentAttrib
uchar doxyCommentAttrib
uchar regionAttrib
uchar symbolAttrib
uchar alertAttrib
uchar tagAttrib
uchar wordAttrib
bool useSpaces
bool keepProfile


Detailed Description

Provides Auto-Indent functionality for katepart.

Definition at line 30 of file kateautoindent.h.


Constructor & Destructor Documentation

KateAutoIndent::KateAutoIndent KateDocument *  doc  ) 
 

Constructor.

Parameters:
doc parent document

Definition at line 81 of file kateautoindent.cpp.

Referenced by createIndenter().

KateAutoIndent::~KateAutoIndent  )  [virtual]
 

Virtual Destructor for the baseclass.

Definition at line 85 of file kateautoindent.cpp.


Member Function Documentation

KateAutoIndent * KateAutoIndent::createIndenter KateDocument *  doc,
uint  mode
[static]
 

Create an indenter.

Parameters:
doc document for the indenter
mode indention mode wanted
Returns:
created autoindention object

Definition at line 30 of file kateautoindent.cpp.

References KateAutoIndent().

QStringList KateAutoIndent::listModes  )  [static]
 

List all possible modes by name.

Returns:
list of modes

Definition at line 40 of file kateautoindent.cpp.

References modeDescription().

QString KateAutoIndent::modeName uint  mode  )  [static]
 

Return the mode name given the mode.

Parameters:
mode mode index
Returns:
name for this mode index

Definition at line 51 of file kateautoindent.cpp.

Referenced by modeNumber().

QString KateAutoIndent::modeDescription uint  mode  )  [static]
 

Return the mode description.

Parameters:
mode mode index
Returns:
mode index

Definition at line 61 of file kateautoindent.cpp.

Referenced by listModes().

uint KateAutoIndent::modeNumber const QString name  )  [static]
 

Maps name -> index.

Parameters:
name mode name
Returns:
mode index

Definition at line 71 of file kateautoindent.cpp.

References modeName().

void KateAutoIndent::updateConfig  ) 
 

Update indenter's configuration (indention width, attributes etc.).

Definition at line 89 of file kateautoindent.cpp.

References indentWidth, keepProfile, tabWidth, and useSpaces.

void KateAutoIndent::processNewline KateDocCursor cur,
bool  needContinue
[virtual]
 

Called every time a newline character is inserted in the document.

Parameters:
cur The position to start processing. Contains the new cursor position after the indention.
needContinue Used to determine whether to calculate a continue indent or not.

Definition at line 253 of file kateautoindent.cpp.

References KateTextCursor::col(), KateTextCursor::line(), KateTextCursor::setCol(), tabString(), and tabWidth.

virtual void KateAutoIndent::processChar QChar   )  [inline, virtual]
 

Called every time a character is inserted into the document.

Parameters:
c character inserted

Definition at line 100 of file kateautoindent.h.

virtual void KateAutoIndent::processLine KateDocCursor  )  [inline, virtual]
 

Aligns/indents the given line to the proper indent position.

Definition at line 105 of file kateautoindent.h.

virtual void KateAutoIndent::processSection KateDocCursor ,
KateDocCursor
[inline, virtual]
 

Processes a section of text, indenting each line in between.

Definition at line 110 of file kateautoindent.h.

virtual bool KateAutoIndent::canProcessLine  )  [inline, virtual]
 

Set to true if an actual implementation of 'processLine' is present.

This is used to prevent a needless Undo action from being created.

Definition at line 116 of file kateautoindent.h.

virtual uint KateAutoIndent::modeNumber  )  const [inline, virtual]
 

Mode index of this mode.

Returns:
modeNumber

Definition at line 122 of file kateautoindent.h.

bool KateAutoIndent::isBalanced KateDocCursor begin,
const KateDocCursor end,
QChar  open,
QChar  close,
uint &  pos
const [protected]
 

Determines if the characters open and close are balanced between begin and end Fills in pos with the column position of first opened character if found.

Parameters:
begin Beginning cursor position.
end Ending cursor position where the processing will stop.
open The open character.
close The closing character which should be matched against open.
pos Contains the position of the first open character in the line.
Returns:
True if open and close have an equal number of occurances between begin and end. False otherwise.

Definition at line 143 of file kateautoindent.cpp.

References KateDocCursor::currentAttrib(), KateDocCursor::currentChar(), KateTextCursor::line(), measureIndent(), and KateDocCursor::moveForward().

bool KateAutoIndent::skipBlanks KateDocCursor cur,
KateDocCursor max,
bool  newline
const [protected]
 

Skip all whitespace starting at cur and ending at max.

Spans lines if newline is set. cur is set to the current position afterwards.

Parameters:
cur The current cursor position to start from.
max The furthest cursor position that will be used for processing
newline Whether we are allowed to span multiple lines when skipping blanks
Returns:
True if cur < max after processing. False otherwise.

Definition at line 188 of file kateautoindent.cpp.

References KateDocCursor::currentAttrib(), KateDocCursor::currentChar(), KateTextCursor::line(), KateDocCursor::moveForward(), and KateTextCursor::setCol().

uint KateAutoIndent::measureIndent KateDocCursor cur  )  const [protected]
 

Measures the indention of the current textline marked by cur // Produces a string with the proper indentation characters for its length.

Parameters:
cur The cursor position to measure the indent to. QString tabString (uint length) const;
Returns:
The length of the indention in characters.

Definition at line 224 of file kateautoindent.cpp.

References KateTextCursor::col(), keepProfile, KateTextCursor::line(), tabWidth, and useSpaces.

Referenced by isBalanced().

QString KateAutoIndent::tabString uint  length  )  const [protected]
 

Produces a string with the proper indentation characters for its length.

Parameters:
length The length of the indention in characters.
Returns:
A QString representing length characters (factoring in tabs and spaces)

Definition at line 232 of file kateautoindent.cpp.

References tabWidth, and useSpaces.

Referenced by processNewline().


Member Data Documentation

uint KateAutoIndent::tabWidth [protected]
 

The number of characters simulated for a tab.

Definition at line 168 of file kateautoindent.h.

Referenced by measureIndent(), processNewline(), tabString(), and updateConfig().

uint KateAutoIndent::indentWidth [protected]
 

The number of characters used when tabs are replaced by spaces.

Definition at line 169 of file kateautoindent.h.

Referenced by updateConfig().

bool KateAutoIndent::useSpaces [protected]
 

Should we use spaces or tabs to indent.

Definition at line 180 of file kateautoindent.h.

Referenced by measureIndent(), tabString(), and updateConfig().

bool KateAutoIndent::keepProfile [protected]
 

Always try to honor the leading whitespace of lines already in the file.

Definition at line 181 of file kateautoindent.h.

Referenced by measureIndent(), and updateConfig().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kate Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Jul 22 10:18:53 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003