Measure half width characters

This commit is contained in:
Antonio Scandurra
2015-10-15 20:06:38 +02:00
parent c616e86a00
commit 7394cc531c
3 changed files with 9 additions and 4 deletions

View File

@@ -8,8 +8,10 @@ DummyLineNode.style.position = 'absolute'
DummyLineNode.style.visibility = 'hidden'
DummyLineNode.appendChild(document.createElement('span'))
DummyLineNode.appendChild(document.createElement('span'))
DummyLineNode.appendChild(document.createElement('span'))
DummyLineNode.children[0].textContent = 'x'
DummyLineNode.children[1].textContent = ''
DummyLineNode.children[2].textContent = ''
RangeForMeasurement = document.createRange()
@@ -85,11 +87,12 @@ class LinesComponent extends TiledComponent
lineHeightInPixels = DummyLineNode.getBoundingClientRect().height
defaultCharWidth = DummyLineNode.children[0].getBoundingClientRect().width
doubleWidthCharWidth = DummyLineNode.children[1].getBoundingClientRect().width
halfWidthCharWidth = DummyLineNode.children[2].getBoundingClientRect().width
@domNode.removeChild(DummyLineNode)
@presenter.setLineHeight(lineHeightInPixels)
@presenter.setBaseCharacterWidth(defaultCharWidth, doubleWidthCharWidth)
@presenter.setBaseCharacterWidth(defaultCharWidth, doubleWidthCharWidth, halfWidthCharWidth)
lineNodeForLineIdAndScreenRow: (lineId, screenRow) ->
tile = @presenter.tileForRow(screenRow)

View File

@@ -1122,11 +1122,12 @@ class TextEditorPresenter
@mouseWheelScreenRow = screenRow
@didStartScrolling()
setBaseCharacterWidth: (baseCharacterWidth, doubleWidthCharWidth) ->
unless @baseCharacterWidth is baseCharacterWidth and @doubleWidthCharWidth is doubleWidthCharWidth
setBaseCharacterWidth: (baseCharacterWidth, doubleWidthCharWidth, halfWidthCharWidth) ->
unless @baseCharacterWidth is baseCharacterWidth and @doubleWidthCharWidth is doubleWidthCharWidth and @halfWidthCharWidth is halfWidthCharWidth
@baseCharacterWidth = baseCharacterWidth
@doubleWidthCharWidth = doubleWidthCharWidth
@model.setDefaultCharWidth(baseCharacterWidth, doubleWidthCharWidth)
@halfWidthCharWidth = halfWidthCharWidth
@model.setDefaultCharWidth(baseCharacterWidth, doubleWidthCharWidth, halfWidthCharWidth)
@characterWidthsChanged()
characterWidthsChanged: ->