edbee - Qt Editor Library
Public Types | Public Member Functions | List of all members
edbee::RemoveCommand Class Reference

A delete command. This is a backspace or a delete operation. More...

#include <removecommand.h>

+ Inheritance diagram for edbee::RemoveCommand:
+ Collaboration diagram for edbee::RemoveCommand:

Public Types

enum  RemoveMode { RemoveChar, RemoveWord, RemoveLine }
 
enum  Direction { Left, Right }
 

Public Member Functions

 RemoveCommand (int removeMode, int direction)
 The remove command constructor. More...
 
int coalesceId () const
 This method returns the coalesceId to use Currently all commands in the same direction will get the same coalesceId. More...
 
int smartBackspace (TextDocument *doc, int caret)
 Performs a smart backspace by adjusting the textrange so the backspace leads to the start of a column. More...
 
void rangesForRemoveChar (TextEditorController *controller, TextRangeSet *ranges)
 Changes the ranges so one character on the left is removed This method can switch to smart-backspace mode, so backspace moves to the previous column at the start of the line. More...
 
void rangesForRemoveWord (TextEditorController *controller, TextRangeSet *ranges)
 Changes the ranges so one word at the left is removed. More...
 
void rangesForRemoveLine (TextEditorController *controller, TextRangeSet *ranges)
 Changes the ranges so one line at the left is removed. More...
 
virtual void execute (TextEditorController *controller)
 Performs the remove command. More...
 
virtual QString toString ()
 Converts the command to a string. More...
 
- Public Member Functions inherited from edbee::TextEditorCommand
 TextEditorCommand ()
 The default constructor. More...
 
virtual ~TextEditorCommand ()
 A blank virtual destructor. More...
 

Detailed Description

A delete command. This is a backspace or a delete operation.

The delete behaviour is pretty obvious, it just deletes :)

The behaviour of the RemoveCharLeft depends on several factors:

When the editor has enabled useTabChar_is enabled, backspace is very simple, it simply deletes the previous character or the selection

When spaces are used for tabs the behaviour is different. If the caret is left of the first non-space character, it will move 1 column to the left, depending on the tabsize

Member Enumeration Documentation

◆ Direction

Enumerator
Left 

Remove the item to the left.

Right 

Remove the item to ther right.

◆ RemoveMode

Enumerator
RemoveChar 

Remove a single character.

RemoveWord 

Remove a single word.

RemoveLine 

Remove a line.

Constructor & Destructor Documentation

◆ RemoveCommand()

edbee::RemoveCommand::RemoveCommand ( int  removeMode,
int  direction 
)

The remove command constructor.

Parameters
removeModethe mode for removal
directionthe direction for the removal

Member Function Documentation

◆ coalesceId()

int edbee::RemoveCommand::coalesceId ( ) const

This method returns the coalesceId to use Currently all commands in the same direction will get the same coalesceId.

Returns
the coalesceId to use

◆ execute()

void edbee::RemoveCommand::execute ( TextEditorController controller)
virtual

Performs the remove command.

Parameters
controllerthe active controller

Implements edbee::TextEditorCommand.

◆ rangesForRemoveChar()

void edbee::RemoveCommand::rangesForRemoveChar ( TextEditorController controller,
TextRangeSet ranges 
)

Changes the ranges so one character on the left is removed This method can switch to smart-backspace mode, so backspace moves to the previous column at the start of the line.

Parameters
controllerthe active controller
ranges(in/out) the ranges to modify for deletion

◆ rangesForRemoveLine()

void edbee::RemoveCommand::rangesForRemoveLine ( TextEditorController controller,
TextRangeSet ranges 
)

Changes the ranges so one line at the left is removed.

Parameters
controllerthe active controller
ranges(in/out) the ranges to modify so it spans a line

◆ rangesForRemoveWord()

void edbee::RemoveCommand::rangesForRemoveWord ( TextEditorController controller,
TextRangeSet ranges 
)

Changes the ranges so one word at the left is removed.

Parameters
controllerthe active controller
ranges(in/out) the ranges to modify so it spans a word

◆ smartBackspace()

int edbee::RemoveCommand::smartBackspace ( TextDocument doc,
int  caret 
)

Performs a smart backspace by adjusting the textrange so the backspace leads to the start of a column.

Parameters
controllerto perform the smartbackspace for
caretthe current caret position
Returns
the new caret position

◆ toString()

QString edbee::RemoveCommand::toString ( )
virtual

Converts the command to a string.

Implements edbee::TextEditorCommand.


The documentation for this class was generated from the following files: