#ifndef PQTEXTCURSOR_H
#define PQTEXTCURSOR_H

#include "classes/pqwidget.h"
#include "classes/pqtextedit.h"
#include "classes/pqplaintextedit.h"
#include <QTextCursor>

class PQTextCursor;
class PQTextCursor : public QObject, public QTextCursor {
    Q_OBJECT
    PQ_OBJECT_EX(QObject)

    Q_PROPERTY(int blockNumber READ blockNumber)
    Q_PROPERTY(int position READ position)
    Q_PROPERTY(int anchor READ anchor)
    Q_PROPERTY(int positionInBlock READ positionInBlock)
    Q_PROPERTY(bool hasSelection READ hasSelection)
    Q_PROPERTY(int selectionEnd READ selectionEnd)
    Q_PROPERTY(int selectionStart READ selectionStart)

    Q_PROPERTY(QString blockText READ blockText)
    Q_PROPERTY(QString previousBlockText READ previousBlockText)

public:
    Q_INVOKABLE explicit PQTextCursor(QWidget *textEditObject);
    explicit PQTextCursor(const QTextCursor &textCursor);

    Q_INVOKABLE int blockNumber();
    Q_INVOKABLE int position();
    Q_INVOKABLE void setPosition(int pos, int moveMode = 0);
    Q_INVOKABLE int anchor();
    Q_INVOKABLE int positionInBlock();
    Q_INVOKABLE bool hasSelection();
    Q_INVOKABLE void beginEditBlock();
    Q_INVOKABLE void endEditBlock();
    Q_INVOKABLE int selectionEnd();
    Q_INVOKABLE int selectionStart();
    Q_INVOKABLE bool movePosition(int operation, int moveMode = 0, int n = 1);
    Q_INVOKABLE void insertText(const QString &text);
    Q_INVOKABLE void deleteChar();
    Q_INVOKABLE void deletePreviousChar();
    Q_INVOKABLE QString selectedText();

    Q_INVOKABLE QString blockText();
    Q_INVOKABLE QString previousBlockText();

    PQ_ON_SIGNAL_DECL_START {
    } PQ_ON_SIGNAL_DECL_END

};


#endif // PQTEXTCURSOR_H
