mirror of
https://github.com/atom/atom.git
synced 2026-02-07 21:25:05 -05:00
Implement isWrapBoundary for DisplayLayer
So that we can correctly soft wrap CJK characters.
This commit is contained in:
@@ -7,7 +7,7 @@ Model = require './model'
|
||||
Token = require './token'
|
||||
Decoration = require './decoration'
|
||||
LayerDecoration = require './layer-decoration'
|
||||
{isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter} = require './text-utils'
|
||||
{isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter, isWrapBoundary} = require './text-utils'
|
||||
|
||||
class BufferToScreenConversionError extends Error
|
||||
constructor: (@message, @metadata) ->
|
||||
@@ -122,6 +122,7 @@ class DisplayBuffer extends Model
|
||||
showIndentGuides: @config.get('editor.showIndentGuide', scope: scopeDescriptor)
|
||||
tabLength: @config.get('editor.tabLength', scope: scopeDescriptor),
|
||||
ratioForCharacter: @ratioForCharacter.bind(this)
|
||||
isWrapBoundary: isWrapBoundary
|
||||
})
|
||||
|
||||
updateAllScreenLines: ->
|
||||
|
||||
@@ -94,6 +94,13 @@ isCJKCharacter = (character) ->
|
||||
isHalfWidthCharacter(character) or
|
||||
isKoreanCharacter(character)
|
||||
|
||||
isWordStart = (previousCharacter, character) ->
|
||||
(previousCharacter is ' ' or previousCharacter is '\t') and
|
||||
(character isnt ' ' and character isnt '\t')
|
||||
|
||||
isWrapBoundary = (previousCharacter, character) ->
|
||||
isWordStart(previousCharacter, character) or isCJKCharacter(character)
|
||||
|
||||
# Does the given string contain at least surrogate pair, variation sequence,
|
||||
# or combined character?
|
||||
#
|
||||
@@ -107,4 +114,8 @@ hasPairedCharacter = (string) ->
|
||||
index++
|
||||
false
|
||||
|
||||
module.exports = {isPairedCharacter, hasPairedCharacter, isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter, isCJKCharacter}
|
||||
module.exports = {
|
||||
isPairedCharacter, hasPairedCharacter,
|
||||
isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter,
|
||||
isWrapBoundary
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user