@@ -202,6 +202,30 @@ py::class_<BTextView, PyBTextView, BView, std::unique_ptr<BTextView,py::nodelete
202
202
BTextView::FreeRunArray (tra);
203
203
}
204
204
}, " " , py::arg (" text" ), py::arg (" runs" ))
205
+ .def (" SetText" , [](BTextView& self, const char * 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" ))
205
229
.def (" Insert" , py::overload_cast<const char *, const text_run_array *>(&BTextView::Insert), " " , py::arg (" text" ), py::arg (" runs" )=NULL )
206
230
.def (" Insert" , py::overload_cast<const char *, int32, const text_run_array *>(&BTextView::Insert), " " , py::arg (" text" ), py::arg (" length" ), py::arg (" runs" )=NULL )
207
231
.def (" Insert" , py::overload_cast<int32, const char *, int32, const text_run_array *>(&BTextView::Insert), " " , py::arg (" offset" ), py::arg (" text" ), py::arg (" length" ), py::arg (" runs" )=NULL )
0 commit comments