Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit40cf710

Browse files
committed
add all SetText funcs to use python lists for text_run_array
1 parentec60680 commit40cf710

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎bindings/interface/TextView.cpp‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,30 @@ py::class_<BTextView, PyBTextView, BView, std::unique_ptr<BTextView,py::nodelete
202202
BTextView::FreeRunArray(tra);
203203
}
204204
},"",py::arg("text"),py::arg("runs"))
205+
.def("SetText", [](BTextView& self,constchar* text, int32 length,const py::list& runs){//&SetTextWrapper, "", py::arg("text"), py::arg("runs")=NULL)
206+
if (!runs.is_none()) {
207+
auto len = runs.size();
208+
text_run_array* tra =BTextView::AllocRunArray(len);
209+
int i =0;for (auto item : runs) {
210+
if (i >= len)break;// Evita overflow
211+
tra->runs[i] = item.cast<text_run>(); ++i;
212+
}
213+
self.SetText(text, length, tra);
214+
BTextView::FreeRunArray(tra);
215+
}
216+
},"",py::arg("text"),py::arg("length"),py::arg("runs"))
217+
.def("SetText", [](BTextView& self, BFile* file, int32 offset, int32 length,const py::list& runs){//&SetTextWrapper, "", py::arg("text"), py::arg("runs")=NULL)
218+
if (!runs.is_none()) {
219+
auto len = runs.size();
220+
text_run_array* tra =BTextView::AllocRunArray(len);
221+
int i =0;for (auto item : runs) {
222+
if (i >= len)break;// Evita overflow
223+
tra->runs[i] = item.cast<text_run>(); ++i;
224+
}
225+
self.SetText(file, offset, length, tra);
226+
BTextView::FreeRunArray(tra);
227+
}
228+
},"",py::arg("file"),py::arg("offset"),py::arg("length"),py::arg("runs"))
205229
.def("Insert", py::overload_cast<constchar *,const text_run_array *>(&BTextView::Insert),"",py::arg("text"),py::arg("runs")=NULL)
206230
.def("Insert", py::overload_cast<constchar *, int32,const text_run_array *>(&BTextView::Insert),"",py::arg("text"),py::arg("length"),py::arg("runs")=NULL)
207231
.def("Insert", py::overload_cast<int32,constchar *, int32,const text_run_array *>(&BTextView::Insert),"",py::arg("offset"),py::arg("text"),py::arg("length"),py::arg("runs")=NULL)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp