| 212 | } |
| 213 | |
| 214 | void PiuCodeDraw(void* it, PiuView* view, PiuRectangle area) |
| 215 | { |
| 216 | PiuCode* self = it; |
| 217 | xsMachine* the = (*self)->the; |
| 218 | PiuSkin* skin = (*self)->skin; |
| 219 | PiuStyle* style = (*self)->computedStyle; |
| 220 | PiuTextBuffer* results = (*self)->results; |
| 221 | if (skin) { |
| 222 | PiuCodeResult result = (PiuCodeResult)((char*)(*results) + sizeof(PiuTextBufferRecord)); |
| 223 | if (result->count > 0) { |
| 224 | PiuViewPushColor(view, &((*skin)->data.color.fill[0])); |
| 225 | while (result->count > 0) { |
| 226 | PiuCodeHilite(self, view, result->fromColumn, result->fromLine, result->toColumn, result->toLine); |
| 227 | result = (PiuCodeResult)(((char*)result) + (*self)->resultsSize); |
| 228 | } |
| 229 | PiuViewPopColor(view); |
| 230 | } |
| 231 | PiuViewPushColor(view, &((*skin)->data.color.fill[3])); |
| 232 | PiuCodeHilite(self, view, (*self)->fromColumn, (*self)->fromLine, (*self)->toColumn, (*self)->toLine); |
| 233 | PiuViewPopColor(view); |
| 234 | } |
| 235 | { |
| 236 | int32_t selectionFrom = (*self)->from; |
| 237 | int32_t selectionTo = (*self)->to; |
| 238 | double clipLeft = area->x; |
| 239 | double clipRight = clipLeft + area->width; |
| 240 | double clipTop = area->y; |
| 241 | double clipBottom = clipTop + area->height; |
| 242 | xsBooleanValue flag = (clipTop <= ((*style)->margins.top + (*self)->lineHeight)) ? 1 : 0; |
| 243 | double x = (*style)->margins.left; |
| 244 | double y = (*style)->margins.top; |
| 245 | double columnWidth = (*self)->columnWidth; |
| 246 | double lineHeight = (*self)->lineHeight; |
| 247 | xsStringValue string = PiuToString((*self)->string); |
| 248 | PiuTextBuffer* runs = (*self)->runs; |
| 249 | PiuCodeRun run = (PiuCodeRun)((uint8_t*)(*runs) + sizeof(PiuTextBufferRecord)); |
| 250 | xsIntegerValue offset = 0; |
| 251 | while (*(string + offset)) { |
| 252 | switch(run->kind) { |
| 253 | case piuCodeLineKind: |
| 254 | x = (*style)->margins.left; |
| 255 | y += lineHeight; |
| 256 | if (clipBottom <= y) |
| 257 | return; |
| 258 | if (clipTop <= (y + lineHeight)) |
| 259 | flag = 1; |
| 260 | break; |
| 261 | case piuCodeTabKind: |
| 262 | if (flag) |
| 263 | x += run->color * columnWidth; |
| 264 | break; |
| 265 | default: |
| 266 | if (flag && run->count) { |
| 267 | double right = x + (fxUTF8ToUnicodeOffset(string + offset, run->count) * columnWidth); |
| 268 | if ((clipLeft < right) && (x < clipRight)) { |
| 269 | PiuColorRecord runColor = (*style)->color[run->color]; |
| 270 | PiuColorRecord black = { 0, 0, 0, 255 }; |
| 271 | if ((*self)->variant == 1) { |
nothing calls this directly
no test coverage detected