MCPcopy Create free account
hub / github.com/breck7/scroll / charWidth

Function charWidth

external/.scrollLibs.js:4310–4323  ·  view source on GitHub ↗
(display)

Source from the content-addressed store, hash-verified

4308
4309 // Compute the default character width.
4310 function charWidth(display) {
4311 if (display.cachedCharWidth != null) {
4312 return display.cachedCharWidth
4313 }
4314 var anchor = elt("span", "xxxxxxxxxx")
4315 var pre = elt("pre", [anchor])
4316 removeChildrenAndAdd(display.measure, pre)
4317 var rect = anchor.getBoundingClientRect(),
4318 width = (rect.right - rect.left) / 10
4319 if (width > 2) {
4320 display.cachedCharWidth = width
4321 }
4322 return width || 10
4323 }
4324
4325 // Do a bulk-read of the DOM positions and sizes needed to draw the
4326 // view, so that we don't interleave reading and writing to the DOM.

Callers 6

measureCharInnerFunction · 0.85
estimateCoordsFunction · 0.85
estimateHeightFunction · 0.85
posFromMouseFunction · 0.85
updateHeightsInViewportFunction · 0.85
addEditorMethodsFunction · 0.85

Calls 2

eltFunction · 0.85
removeChildrenAndAddFunction · 0.85

Tested by

no test coverage detected