notepad-plus-plus/scintilla/qt/ScintillaEdit/ScintillaEdit.cpp.template

60 lines
1.8 KiB
Plaintext

// ScintillaEdit.cpp
// Extended version of ScintillaEditBase with a method for each API
// Copyright (c) 2011 Archaeopteryx Software, Inc. d/b/a Wingware
#include "ScintillaEdit.h"
ScintillaEdit::ScintillaEdit(QWidget *parent) : ScintillaEditBase(parent) {
}
ScintillaEdit::~ScintillaEdit() {
}
QByteArray ScintillaEdit::TextReturner(int message, uptr_t wParam) const {
int length = send(message, wParam, 0);
QByteArray ba(length, '\0');
send(message, wParam, (sptr_t)ba.data());
// Remove extra NULs
if (ba.size() > 0 && ba.at(ba.size()-1) == 0)
ba.chop(1);
return ba;
}
QPair<int, int>ScintillaEdit::find_text(int flags, const char *text, int cpMin, int cpMax) {
struct TextToFind ft = {{0, 0}, 0, {0, 0}};
ft.chrg.cpMin = cpMin;
ft.chrg.cpMax = cpMax;
ft.chrgText.cpMin = cpMin;
ft.chrgText.cpMax = cpMax;
ft.lpstrText = const_cast<char *>(text);
int start = send(SCI_FINDTEXT, flags, (uptr_t) (&ft));
return QPair<int,int>(start, ft.chrgText.cpMax);
}
QByteArray ScintillaEdit::get_text_range(int start, int end) {
if (start > end)
start = end;
int length = end-start;
QByteArray ba(length+1, '\0');
struct TextRange tr = {{start, end}, ba.data()};
send(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
ba.chop(1); // Remove extra NUL
return ba;
}
ScintillaDocument *ScintillaEdit::get_doc() {
return new ScintillaDocument(0, (void *)send(SCI_GETDOCPOINTER, 0, 0));
}
void ScintillaEdit::set_doc(ScintillaDocument *pdoc_) {
send(SCI_SETDOCPOINTER, 0, (sptr_t)(pdoc_->pointer()));
}
/* ++Autogenerated -- start of section automatically generated from Scintilla.iface */
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */