edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
textchange.h
Go to the documentation of this file.
1// edbee - Copyright (c) 2012-2025 by Rick Blommers and contributors
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "edbee/exports.h"
7
8#include <QString>
9
11
12namespace edbee {
13
19{
20public:
21 TextChange(int offset, int length, const QString& text );
22 virtual ~TextChange();
23
24 virtual void execute(TextDocument* document);
25 virtual void revert(TextDocument* document);
26
27protected:
28 virtual void mergeStoredData( AbstractRangedChange* change );
29
30public:
31 virtual bool giveAndMerge(TextDocument *document, Change* textChange );
32
33 virtual QString toString();
34
35 int offset() const;
36 void setOffset( int offset );
37 virtual int docLength() const;
38 virtual int storedLength() const;
39
40 void setDocLength( int len );
41
42 QString storedText() const;
43 void setStoredText( const QString& text );
44 void appendStoredText( const QString& text );
45 const QString docText( TextDocument* doc ) const;
46
47 QString testString();
48
49protected:
50 void replaceText( TextDocument* document );
51
52private:
53 int offset_;
54 int length_;
55 QString text_;
56};
57
58} // edbee
This is an abstract class for ranged changes This are changes (text changes and line changes) that sp...
Definition abstractrangedchange.h:16
A basic change.
Definition change.h:18
virtual void mergeStoredData(AbstractRangedChange *change)
This method merges the old data with the new data @apram change the data to merge with.
Definition textchange.cpp:51
void replaceText(TextDocument *document)
replaces the text and stores the 'old' content
Definition textchange.cpp:182
virtual int docLength() const
This is the length in the document.
Definition textchange.cpp:124
const QString docText(TextDocument *doc) const
This method returns the text currently in the document.
Definition textchange.cpp:167
int offset() const
Return the offset.
Definition textchange.cpp:109
virtual bool giveAndMerge(TextDocument *document, Change *textChange)
This method gives the given change to this textchange. The changes will be merged if possible....
Definition textchange.cpp:88
void setDocLength(int len)
Set the length of the change.
Definition textchange.cpp:139
void setOffset(int offset)
set the new offset
Definition textchange.cpp:117
virtual void execute(TextDocument *document)
executes the given textchange
Definition textchange.cpp:35
QString storedText() const
The text currently stored in this textchange.
Definition textchange.cpp:145
TextChange(int offset, int length, const QString &text)
Constructs a single textchange.
Definition textchange.cpp:19
virtual int storedLength() const
The content length is the length that's currently stored in memory.
Definition textchange.cpp:131
virtual QString toString()
converts the change to a string
Definition textchange.cpp:100
void setStoredText(const QString &text)
Sets the text of this change.
Definition textchange.cpp:153
QString testString()
This method returns a string used for testing.
Definition textchange.cpp:174
void appendStoredText(const QString &text)
Appends the text to this change.
Definition textchange.cpp:160
virtual void revert(TextDocument *document)
Reverts the single textchange.
Definition textchange.cpp:43
This is the base and abstract class of a text document A TextDocument is the model part of the editor...
Definition textdocument.h:42
#define EDBEE_EXPORT
Definition exports.h:15
QT Acessibility has an issue with reporting blank lines between elements lines. defining 'WINDOWS_EMP...
Definition commentcommand.cpp:20