MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuCode_locate

Function PiuCode_locate

modules/piu/PC/Code/piuCode.c:1211–1226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1209}
1210
1211void PiuCode_locate(xsMachine *the)
1212{
1213 PiuCode* self = PIU(Code, xsThis);
1214 if ((*self)->application) {
1215 xsStringValue string = PiuToString((*self)->string);
1216 PiuStyle* style = (*self)->computedStyle;
1217 int32_t offset = fxUnicodeToUTF8Offset(string, xsToInteger(xsArg(0)));
1218 int32_t column, line;
1219 PiuCodeOffsetToColumnLine(self, offset, &column, &line);
1220 xsResult = xsNewObject();
1221 xsDefine(xsResult, xsID_x, xsPiuCoordinate((xsIntegerValue)c_floor((*style)->margins.left + (column * (*self)->columnWidth))), xsDefault);
1222 xsDefine(xsResult, xsID_y, xsPiuCoordinate((xsIntegerValue)c_floor((*style)->margins.top + (line * (*self)->lineHeight))), xsDefault);
1223 xsDefine(xsResult, xsID_width, xsPiuDimension((xsIntegerValue)c_ceil((*self)->columnWidth)), xsDefault);
1224 xsDefine(xsResult, xsID_height, xsPiuDimension((xsIntegerValue)c_ceil((*self)->lineHeight)), xsDefault);
1225 }
1226}
1227
1228void PiuCode_select(xsMachine *the)
1229{

Callers

nothing calls this directly

Calls 2

fxUnicodeToUTF8OffsetFunction · 0.85

Tested by

no test coverage detected