@trendr/core 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/buffer.js +15 -0
- package/src/renderer.js +5 -1
package/package.json
CHANGED
package/src/buffer.js
CHANGED
|
@@ -129,6 +129,21 @@ export function dimBuffer(buf) {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
export function dimRect(buf, x, y, w, h) {
|
|
133
|
+
const x1 = Math.max(x, 0)
|
|
134
|
+
const y1 = Math.max(y, 0)
|
|
135
|
+
const x2 = Math.min(x + w, buf.width)
|
|
136
|
+
const y2 = Math.min(y + h, buf.height)
|
|
137
|
+
for (let row = y1; row < y2; row++) {
|
|
138
|
+
const base = row * buf.width
|
|
139
|
+
for (let col = x1; col < x2; col++) {
|
|
140
|
+
const cell = buf.cells[base + col]
|
|
141
|
+
if (cell.attrs & 2) continue
|
|
142
|
+
buf.cells[base + col] = { ch: cell.ch, fg: cell.fg, bg: cell.bg, attrs: cell.attrs | 2 }
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
132
147
|
export function copyBuffer(src, dst) {
|
|
133
148
|
const len = Math.min(src.cells.length, dst.cells.length)
|
|
134
149
|
for (let i = 0; i < len; i++) dst.cells[i] = src.cells[i]
|
package/src/renderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createBuffer, clearBuffer, fillRect, writeText, dimBuffer, blitRect } from './buffer.js'
|
|
1
|
+
import { createBuffer, clearBuffer, fillRect, writeText, dimBuffer, dimRect, blitRect } from './buffer.js'
|
|
2
2
|
import { diff } from './diff.js'
|
|
3
3
|
import { bufferToLines } from './serialize.js'
|
|
4
4
|
import { computeLayout, resolveBorderEdges, intrinsicHeight } from './layout.js'
|
|
@@ -409,6 +409,10 @@ function paintTree(node, buf, clip, offset, prevBuf) {
|
|
|
409
409
|
paintTree(child, buf, childClip, childOffset, childPrevBuf)
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
+
|
|
413
|
+
// style.dim on a box dims its whole painted region after children render:
|
|
414
|
+
// the scoped sibling of the overlay backdrop's full-buffer dim
|
|
415
|
+
if (style.dim) dimRect(buf, clipped.x, clipped.y, clipped.width, clipped.height)
|
|
412
416
|
}
|
|
413
417
|
|
|
414
418
|
function extractText(node, parentCtx) {
|