2013-08-28 00:44:27 +00:00
|
|
|
//
|
|
|
|
// Copyright (c) 1990-2011, Scientific Toolworks, Inc.
|
|
|
|
//
|
|
|
|
// The License.txt file describes the conditions under which this software may be distributed.
|
|
|
|
//
|
|
|
|
// Author: Jason Haslam
|
|
|
|
//
|
|
|
|
// Additions Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware
|
|
|
|
// ScintillaQt.h - Qt specific subclass of ScintillaBase
|
|
|
|
|
|
|
|
#ifndef SCINTILLAQT_H
|
|
|
|
#define SCINTILLAQT_H
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstring>
|
|
|
|
#include <cctype>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <ctime>
|
2015-06-07 21:19:26 +00:00
|
|
|
#include <cmath>
|
|
|
|
#include <stdexcept>
|
2013-08-28 00:44:27 +00:00
|
|
|
#include <string>
|
2019-05-04 18:14:48 +00:00
|
|
|
#include <string_view>
|
2013-08-28 00:44:27 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <algorithm>
|
2019-05-04 18:14:48 +00:00
|
|
|
#include <memory>
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
#include "Scintilla.h"
|
|
|
|
#include "Platform.h"
|
2019-05-04 18:14:48 +00:00
|
|
|
#include "ILoader.h"
|
2013-08-28 00:44:27 +00:00
|
|
|
#include "ILexer.h"
|
2019-07-21 13:26:02 +00:00
|
|
|
#include "CharacterCategory.h"
|
2019-05-04 18:14:48 +00:00
|
|
|
#include "Position.h"
|
|
|
|
#include "UniqueString.h"
|
2013-08-28 00:44:27 +00:00
|
|
|
#include "SplitVector.h"
|
|
|
|
#include "Partitioning.h"
|
|
|
|
#include "RunStyles.h"
|
|
|
|
#include "ContractionState.h"
|
|
|
|
#include "CellBuffer.h"
|
|
|
|
#include "CallTip.h"
|
|
|
|
#include "KeyMap.h"
|
|
|
|
#include "Indicator.h"
|
|
|
|
#include "LineMarker.h"
|
|
|
|
#include "Style.h"
|
|
|
|
#include "AutoComplete.h"
|
|
|
|
#include "ViewStyle.h"
|
|
|
|
#include "CharClassify.h"
|
|
|
|
#include "Decoration.h"
|
|
|
|
#include "CaseFolder.h"
|
|
|
|
#include "Document.h"
|
|
|
|
#include "Selection.h"
|
|
|
|
#include "PositionCache.h"
|
2015-06-07 21:19:26 +00:00
|
|
|
#include "EditModel.h"
|
|
|
|
#include "MarginView.h"
|
|
|
|
#include "EditView.h"
|
2013-08-28 00:44:27 +00:00
|
|
|
#include "Editor.h"
|
|
|
|
#include "ScintillaBase.h"
|
|
|
|
#include "CaseConvert.h"
|
|
|
|
|
|
|
|
#ifdef SCI_LEXER
|
|
|
|
#include "SciLexer.h"
|
|
|
|
#include "PropSetSimple.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QAbstractScrollArea>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QClipboard>
|
|
|
|
#include <QPaintEvent>
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
class ScintillaEditBase;
|
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
namespace Scintilla {
|
|
|
|
|
|
|
|
class ScintillaQt : public QObject, public ScintillaBase {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-06-07 21:19:26 +00:00
|
|
|
explicit ScintillaQt(QAbstractScrollArea *parent);
|
2013-08-28 00:44:27 +00:00
|
|
|
virtual ~ScintillaQt();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void horizontalScrolled(int value);
|
|
|
|
void verticalScrolled(int value);
|
|
|
|
void horizontalRangeChanged(int max, int page);
|
|
|
|
void verticalRangeChanged(int max, int page);
|
|
|
|
|
|
|
|
void notifyParent(SCNotification scn);
|
|
|
|
void notifyChange();
|
|
|
|
|
|
|
|
// Clients can use this hook to add additional
|
|
|
|
// formats (e.g. rich text) to the MIME data.
|
|
|
|
void aboutToCopy(QMimeData *data);
|
|
|
|
|
|
|
|
void command(uptr_t wParam, sptr_t lParam);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onIdle();
|
|
|
|
void execCommand(QAction *action);
|
|
|
|
void SelectionChanged();
|
|
|
|
|
|
|
|
private:
|
2019-05-04 18:14:48 +00:00
|
|
|
void Init();
|
|
|
|
void Finalise() override;
|
|
|
|
bool DragThreshold(Point ptStart, Point ptNow) override;
|
|
|
|
bool ValidCodePage(int codePage) const override;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
|
|
|
private:
|
2019-05-04 18:14:48 +00:00
|
|
|
void ScrollText(Sci::Line linesToMove) override;
|
|
|
|
void SetVerticalScrollPos() override;
|
|
|
|
void SetHorizontalScrollPos() override;
|
|
|
|
bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) override;
|
|
|
|
void ReconfigureScrollBars() override;
|
2013-08-28 00:44:27 +00:00
|
|
|
void CopyToModeClipboard(const SelectionText &selectedText, QClipboard::Mode clipboardMode_);
|
2019-05-04 18:14:48 +00:00
|
|
|
void Copy() override;
|
|
|
|
void CopyToClipboard(const SelectionText &selectedText) override;
|
2013-08-28 00:44:27 +00:00
|
|
|
void PasteFromMode(QClipboard::Mode clipboardMode_);
|
2019-05-04 18:14:48 +00:00
|
|
|
void Paste() override;
|
|
|
|
void ClaimSelection() override;
|
|
|
|
void NotifyChange() override;
|
|
|
|
void NotifyFocus(bool focus) override;
|
|
|
|
void NotifyParent(SCNotification scn) override;
|
|
|
|
void NotifyURIDropped(const char *uri);
|
2015-06-07 21:19:26 +00:00
|
|
|
int timers[tickDwell+1];
|
2019-05-04 18:14:48 +00:00
|
|
|
bool FineTickerRunning(TickReason reason) override;
|
|
|
|
void FineTickerStart(TickReason reason, int millis, int tolerance) override;
|
|
|
|
void FineTickerCancel(TickReason reason) override;
|
|
|
|
bool SetIdle(bool on) override;
|
|
|
|
void SetMouseCapture(bool on) override;
|
|
|
|
bool HaveMouseCapture() override;
|
|
|
|
void StartDrag() override;
|
2013-08-28 00:44:27 +00:00
|
|
|
int CharacterSetOfDocument() const;
|
|
|
|
const char *CharacterSetIDOfDocument() const;
|
|
|
|
QString StringFromDocument(const char *s) const;
|
|
|
|
QByteArray BytesForDocument(const QString &text) const;
|
2019-05-04 18:14:48 +00:00
|
|
|
CaseFolder *CaseFolderForEncoding() override;
|
|
|
|
std::string CaseMapString(const std::string &s, int caseMapping) override;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
void CreateCallTipWindow(PRectangle rc) override;
|
|
|
|
void AddToPopUp(const char *label, int cmd = 0, bool enabled = true) override;
|
|
|
|
sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
|
|
|
|
sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2015-06-07 21:19:26 +00:00
|
|
|
static sptr_t DirectFunction(sptr_t ptr,
|
2013-08-28 00:44:27 +00:00
|
|
|
unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
void PartialPaint(const PRectangle &rect);
|
|
|
|
|
|
|
|
void DragEnter(const Point &point);
|
|
|
|
void DragMove(const Point &point);
|
|
|
|
void DragLeave();
|
|
|
|
void Drop(const Point &point, const QMimeData *data, bool move);
|
2019-05-04 18:14:48 +00:00
|
|
|
void DropUrls(const QMimeData *data);
|
2013-08-28 00:44:27 +00:00
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
void timerEvent(QTimerEvent *event) override;
|
2015-06-07 21:19:26 +00:00
|
|
|
|
2013-08-28 00:44:27 +00:00
|
|
|
private:
|
|
|
|
QAbstractScrollArea *scrollArea;
|
|
|
|
|
|
|
|
int vMax, hMax; // Scroll bar maximums.
|
|
|
|
int vPage, hPage; // Scroll bar page sizes.
|
|
|
|
|
|
|
|
bool haveMouseCapture;
|
|
|
|
bool dragWasDropped;
|
|
|
|
int rectangularSelectionModifier;
|
|
|
|
|
2019-05-04 18:14:48 +00:00
|
|
|
friend class ::ScintillaEditBase;
|
2013-08-28 00:44:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SCINTILLAQT_H
|