edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
edbee::SelectionCommand Class Reference

The selection command is used to move the caret and anchors to make selections and move the carets around. More...

#include <selectioncommand.h>

+ Inheritance diagram for edbee::SelectionCommand:
+ Collaboration diagram for edbee::SelectionCommand:

Public Types

enum  SelectionType {
  MoveCaretByCharacter , MoveCaretsOrDeselect , MoveCaretByWord , MoveCaretByLine ,
  MoveCaretByPage , MoveCaretToWordBoundary , MoveCaretToLineBoundary , MoveCaretToDocumentBegin ,
  MoveCaretToDocumentEnd , MoveCaretToExactOffset , SelectAll , SelectWord ,
  SelectFullLine , SelectWordAt , ToggleWordSelectionAt , AddCaretAtOffset ,
  AddCaretByLine , ResetSelection
}
 

Public Member Functions

 SelectionCommand (SelectionType unit, int amount=0, bool keepSelection=false, int rangeIndex=-1)
 The constructor of the selection command.
 
virtual ~SelectionCommand ()
 The descructor of the command.
 
virtual int commandId ()
 Return the command id This is th coalesceId + the given selection item.
 
virtual void execute (TextEditorController *controller) override
 execute the given selection command
 
virtual QString toString () override
 Converts this command to a strings.
 
virtual bool readonly () override
 Tis method should return true if it's executable in readonly mode.
 
SelectionType unit ()
 
int amount ()
 
bool keepSelection ()
 
int rangeIndex ()
 
void setAnchor (int anchor)
 
int anchor ()
 
- Public Member Functions inherited from edbee::TextEditorCommand
 TextEditorCommand ()
 The default constructor.
 
virtual ~TextEditorCommand ()
 A blank virtual destructor.
 

Detailed Description

The selection command is used to move the caret and anchors to make selections and move the carets around.

Member Enumeration Documentation

◆ SelectionType

Enumerator
MoveCaretByCharacter 

Moves the caret(s) by the given amount of characters.

MoveCaretsOrDeselect 

Moves the caret(s) by the given amount of characters or deselects the current selection.

Todo
, implement subword selecting
MoveCaretByWord 

moves the caret(s) by the given amount of words

MoveCaretByLine 

moves the caret(s) by the given amount of lines

MoveCaretByPage 

moves the caret(s) by the given amount of pages

MoveCaretToWordBoundary 

moves the caret to a line-boundary (<0 begin of line, >0 end of line)

MoveCaretToLineBoundary 

moves the caret to a line-boundary (<0 begin of line, >0 end of line)

MoveCaretToDocumentBegin 

moves the caret to the document start

MoveCaretToDocumentEnd 

moves the caret to the document end

MoveCaretToExactOffset 

moves the caret to the given offset (given in amount). (This action also support the adjustment of the anchor)

SelectAll 

selects the complete document

SelectWord 

select a full word

SelectFullLine 

select a full line

SelectWordAt 

select 'toggles' a word. Double click on a word to select a word or deselect a word

ToggleWordSelectionAt 

Toggles the selection and caret at the given location.

AddCaretAtOffset 

adds a extra caret at the given offset (amount is the caret offset)

AddCaretByLine 

adds a caret at the given line amount is the amount of lines and the direction to add

ResetSelection 

Constructor & Destructor Documentation

◆ SelectionCommand()

edbee::SelectionCommand::SelectionCommand ( SelectionType unit,
int amount = 0,
bool keepSelection = false,
int rangeIndex = -1 )
explicit

The constructor of the selection command.

Parameters
unitthe unit of this command
amountthe number of steps
keepSelectionwhen true the anchor stays put (and the selection is expanded)

◆ ~SelectionCommand()

edbee::SelectionCommand::~SelectionCommand ( )
virtual

The descructor of the command.

Member Function Documentation

◆ amount()

int edbee::SelectionCommand::amount ( )
inline

◆ anchor()

int edbee::SelectionCommand::anchor ( )
inline

◆ commandId()

int edbee::SelectionCommand::commandId ( )
virtual

Return the command id This is th coalesceId + the given selection item.

◆ execute()

void edbee::SelectionCommand::execute ( TextEditorController * controller)
overridevirtual

execute the given selection command

Parameters
controllerthe controller to execute the selection for

Implements edbee::TextEditorCommand.

◆ keepSelection()

bool edbee::SelectionCommand::keepSelection ( )
inline

◆ rangeIndex()

int edbee::SelectionCommand::rangeIndex ( )
inline

◆ readonly()

bool edbee::SelectionCommand::readonly ( )
overridevirtual

Tis method should return true if it's executable in readonly mode.

Reimplemented from edbee::TextEditorCommand.

◆ setAnchor()

void edbee::SelectionCommand::setAnchor ( int anchor)
inline

◆ toString()

QString edbee::SelectionCommand::toString ( )
overridevirtual

Converts this command to a strings.

Implements edbee::TextEditorCommand.

◆ unit()

SelectionType edbee::SelectionCommand::unit ( )
inline

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