mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Take into account half width chars as well
This commit is contained in:
@@ -189,12 +189,19 @@ class DisplayBuffer extends Model
|
||||
getLineHeightInPixels: -> @lineHeightInPixels
|
||||
setLineHeightInPixels: (@lineHeightInPixels) -> @lineHeightInPixels
|
||||
|
||||
getHalfWidthCharWidth: -> @halfWidthCharWidth
|
||||
|
||||
getDoubleWidthCharWidth: -> @doubleWidthCharWidth
|
||||
|
||||
getDefaultCharWidth: -> @defaultCharWidth
|
||||
setDefaultCharWidth: (defaultCharWidth, doubleWidthCharWidth=defaultCharWidth) ->
|
||||
|
||||
setDefaultCharWidth: (defaultCharWidth, doubleWidthCharWidth, halfWidthCharWidth) ->
|
||||
doubleWidthCharWidth ?= defaultCharWidth
|
||||
halfWidthCharWidth ?= defaultCharWidth
|
||||
if defaultCharWidth isnt @defaultCharWidth or doubleWidthCharWidth isnt @doubleWidthCharWidth
|
||||
@defaultCharWidth = defaultCharWidth
|
||||
@doubleWidthCharWidth = doubleWidthCharWidth
|
||||
@halfWidthCharWidth = halfWidthCharWidth
|
||||
@updateWrappedScreenLines() if @isSoftWrapped() and @getEditorWidthInChars()?
|
||||
defaultCharWidth
|
||||
|
||||
@@ -281,6 +288,8 @@ class DisplayBuffer extends Model
|
||||
|
||||
if iterator.hasDoubleWidthCharacterAt(textIndex)
|
||||
charWidth = @getDoubleWidthCharWidth()
|
||||
else if iterator.hasHalfWidthCharacterAt(textIndex)
|
||||
charWidth = @getHalfWidthCharWidth()
|
||||
else
|
||||
charWidth = @getDefaultCharWidth()
|
||||
|
||||
|
||||
@@ -2976,11 +2976,13 @@ class TextEditor extends Model
|
||||
getLineHeightInPixels: -> @displayBuffer.getLineHeightInPixels()
|
||||
setLineHeightInPixels: (lineHeightInPixels) -> @displayBuffer.setLineHeightInPixels(lineHeightInPixels)
|
||||
|
||||
getHalfWidthCharWidth: -> @displayBuffer.getHalfWidthCharWidth()
|
||||
|
||||
getDoubleWidthCharWidth: -> @displayBuffer.getDoubleWidthCharWidth()
|
||||
|
||||
getDefaultCharWidth: -> @displayBuffer.getDefaultCharWidth()
|
||||
setDefaultCharWidth: (defaultCharWidth, doubleWidthCharWidth=defaultCharWidth) ->
|
||||
@displayBuffer.setDefaultCharWidth(defaultCharWidth, doubleWidthCharWidth)
|
||||
setDefaultCharWidth: (defaultCharWidth, doubleWidthCharWidth, halfWidthCharWidth) ->
|
||||
@displayBuffer.setDefaultCharWidth(defaultCharWidth, doubleWidthCharWidth, halfWidthCharWidth)
|
||||
|
||||
setHeight: (height, reentrant=false) ->
|
||||
if reentrant
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{SoftTab, HardTab, PairedCharacter, SoftWrapIndent} = require './special-token-symbols'
|
||||
{isDoubleWidthCharacter} = require './text-utils'
|
||||
{isDoubleWidthCharacter, isHalfWidthCharacter} = require './text-utils'
|
||||
|
||||
module.exports =
|
||||
class TokenIterator
|
||||
@@ -86,5 +86,8 @@ class TokenIterator
|
||||
hasDoubleWidthCharacterAt: (charIndex) ->
|
||||
isDoubleWidthCharacter(@getText()[charIndex])
|
||||
|
||||
hasHalfWidthCharacterAt: (charIndex) ->
|
||||
isHalfWidthCharacter(@getText()[charIndex])
|
||||
|
||||
isAtomic: ->
|
||||
@isSoftTab() or @isHardTab() or @isSoftWrapIndentation() or @isPairedCharacter()
|
||||
|
||||
Reference in New Issue
Block a user