KSyntaxMultiLineEdit Class

# KSyntaxMultiLineEdit Class Reference

[Action.h Index] [Action.h Hierarchy]

KSyntaxMultiLineEdit is a widget that is able to show a text file with colored sections More...

`#include <KColorMLE.h>`

Inherits: QMultiLineEdit

## Public Members

- KSyntaxMultiLineEdit (const QString& mode, QWidget *parent=0, const char *name=0)
- virtual ~KSyntaxMultiLineEdit ()
- int numVisibleLines ()
- void setMark (int startx, int starty, int endx, int endy)
- void setCursorPosition (int row, int col, bool mark = false)
- virtual void insertAt (const char* s, int line, int col)
- EditorSettings& settings ()
- void setSettings (const EditorSettings& es)
- void setNewMode (const QString& mode)
- void updateFromSettings ()
- inline bool dirty ()
- bool loadFile (const QString& filename, int mode = EDITOR_OPEN_REPLACE)
- bool saveTo (const QString& filename)
- void debugOutUL ()
- Colorizer* getColorizer ()

## Public Slots

- void Search ()
- void GotoLine ()
- void Replace ()
- void clear ()
- void setText (const char*)
- void UFStartOfText ()
- void UFEndOfText ()
- void UFStartOfLine ()
- void UFEndOfLine ()
- void UFWordLeft ()
- void UFWordRight ()
- void UFCursorLeft ()
- void UFCursorRight ()
- void UFCursorUp ()
- void UFCursorDown ()
- void UFPageDown ()
- void UFPageUp ()
- void UFStartOfTextM ()
- void UFEndOfTextM ()
- void UFStartOfLineM ()
- void UFEndOfLineM ()
- void UFWordLeftM ()
- void UFWordRightM ()
- void UFCursorLeftM ()
- void UFCursorRightM ()
- void UFCursorUpM ()
- void UFCursorDownM ()
- void UFPageDownM ()
- void UFPageUpM ()
- void UFNewLine ()
- void UFKillLine ()
- void UFPaste ()
- void UFCopy ()
- void UFCut ()
- void UFDelete ()
- void UFBackspace ()
- void UFUndo ()
- void UFRedo ()
- void UFInsertToggle ()

## Protected Members

- virtual void paintCell (QPainter*, int row, int col)
- virtual void keyPressEvent (QKeyEvent*)
- virtual void mouseDoubleClickEvent (QMouseEvent*)
- virtual void mousePressEvent (QMouseEvent*)
- virtual void mouseMoveEvent (QMouseEvent*)
- virtual void mouseReleaseEvent (QMouseEvent*)
- virtual void timerEvent (QTimerEvent *)
- virtual void wordLeft (bool mark, bool wrap = true)
- virtual void wordRight (bool mark, bool wrap = true)
- virtual void pageUp (bool mark)
- virtual void pageDown (bool mark)
- inline int tabStopDist (const QFontMetrics &fm)
- int textWidthWithTabs (const QFontMetrics &fm,const char *s,int nChars)
- int xPosToCursorPos (const char *s, const QFontMetrics &fm, int xPos, int width)
- int doSearch (QString s_pattern, bool case_sensitive, bool wildcard, bool forward, int line, int col)
- int repeatSearch ()
- int doReplace (QString s_pattern, bool case_sensitive, bool wildcard, bool forward, int line, int col, bool replace_all)
- inline void setDirty (bool d = true)
- void makeCursorVisibleImmediatly ()
- void smle_markWord (int posx, int posy)
- void handleReadOnlyKey (QKeyEvent* e)
- int lineLength (int row)
- void drawText (QPainter* p, int x, int y, int w, int h, int tf, const char* str, int len = -1)
- void setFontInfo (QPainter& p, int state)
- void updateAllVisibleRowsFrom (int row)
- void updateAllNewStateVisibleRowsFrom (int from, int to)
- void inputChar (char c)
- void inputTab ()
- void initColorHandler (const char* rule_file)
- void initStateCache ()
- void deleteStateCache ()
- virtual void cursorLeft (bool mark, bool wrap = true)
- virtual void cursorRight (bool mark, bool wrap = true)
- virtual void cursorUp (bool mark)
- virtual void cursorDown (bool mark)
- void extendMark (int posy, int posx, bool c = false)
- bool getMarkedRegion (int* ay, int* ax, int* dy, int* dx)
- void updateMarkedLines (int oldMarkedLine, int newMarkedLine)
- bool hasMarkedText ()
- QString markedText ()
- virtual void newLine (bool doAutoIndent = true)
- virtual void killLine ()
- virtual void insertChar (char c)
- virtual void backspace ()
- virtual void del ()
- void _UFStartOfText (bool mark)
- void _UFEndOfText (bool mark)
- void _UFStartOfLine (bool mark)
- void _UFEndOfLine (bool mark)
- void _UFWordLeft (bool mark)
- void _UFWordRight (bool mark)
- void _UFCursorLeft (bool mark)
- void _UFCursorRight (bool mark)
- void _UFCursorUp (bool mark)
- void _UFCursorDown (bool mark)
- void _UFPageDown (bool mark)
- void _UFPageUp (bool mark)
- UndoList UndoRedoList
- EditorSettings edSettings
- Colorizer* colorizer
- StateCache* stateCache
- Marker mark
- QString Mode
- bool Dirty

## Protected Slots

- void cut ()
- void copyText ()
- void paste ()
- void textChangedSlot ()
- void searchSlot ()
- void searchDoneSlot ()
- void replaceSlot ()
- void replaceAllSlot ()
- void replaceDoneSlot ()
- void replaceSearchSlot ()

## Signals

- void cursorPosChanged ()
- void textChanged ()
- void insModeChanged ()
- void dirtyChanged ()

## Detailed Description

KSyntaxMultiLineEdit is a widget that is able to show a text file with colored sections. It has the following features: simple to use as a replacement for the QMultiLineEdit configurable syntax highlighting multiple undo and redo function

Be aware that the only functions that produce entries in the undo list are (besides the internal input functions) the UFXXX() methods; use these in order to perform an undoable action (e.g. use UFPaste() instead of paste()!

## KSyntaxMultiLineEdit(const QString& mode, QWidget *parent=0, const char *name=0)

This creates a new KSyntaxMultiLineEdit.

Parameters:

  name | is passed on to the constructor of QMultiLineEdit and specifies thename of the newly created widget.
  parent | is passed on to the constructor of QMultiLineEdit and specifies the parent widget of the newly created one.
  mode: | mode is a string that contains the name of the mode (rule) file to be loaded and used to do the syntax coloring. this name includes the path and extension of the rule file.

## virtual ~KSyntaxMultiLineEdit()

Destructor for KSyntaxMultiLineEdit.

## int numVisibleLines()

Returns the number of lines visible (even partially) in the actual window.

## void setMark(int startx, int starty, int endx, int endy)

Sets a new region of marked text.

Parameters:

  endy | is the ending row of the new marked region
  startx | is the starting col of the new marked region
  endx | is the ending col of the new marked region
  starty | is the starting row of the new marked region

## EditorSettings& settings()

Returns a reference to the current settings of the editor widget. For more information on the settings see section EditorSettings

## void setSettings(const EditorSettings& es)

Changes the settings of the KSyntaxMultiLineEdit to es. Does not call updateFromSettings() to make changes visible. For more information on the settings see section EditorSettings

Parameters:

  es | settings to apply to the editor widget.

## void setNewMode(const QString& mode)

Sets the syntax coloring mode to mode. updateFromSettings() is called to show current text using the new mode.

Parameters:

  mode | mode file string; same format as mode parameter for constructor.

## void updateFromSettings()

Must be called in order to make any changes in the settings of the editor widget become visible. Also needs to be called after changing the current syntax coloring mode.

## inline bool dirty()

Returns the current state of the editor's dirty flag:

## inline void setDirty(bool d = true)

sets or clears the dirty flag; also emits the dirtyChanged() signal to make it possible for external objects to update any visual representation of this flag.

## virtual void newLine(bool doAutoIndent = true)

This function creates a new line of text; when the actual cursor position is at the end of a line, a new line is inserted after the current line; when the cursor is in the middle of a line of text, this line is splitted and the part to the right of the cursor is moved to the new line. The flag doAutoIndent indicates, wether auto indentation shoud be performed (when activated via EditorSettings or not.

## virtual void killLine()

Deletes the contents of the actual line from the actual cursor position to the end of the line.

## virtual void insertChar(char c)

Inserts character c into the text at the current cursor position and moves the cursor one character to the right.

## virtual void backspace()

Deletes the char left to the cursor and moves cursor on char to the left.

## virtual void del()

Deletes the char rightmost to the cursor; the cursor position remains unchanged.

## void textChangedSlot()

Connected to the textChanged() signal to set the dirty flag according to any changes made in the text

| Kdoc