mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
🎨 cjk -> CJK
This commit is contained in:
parent
173fbba02b
commit
12376039a9
@ -75,21 +75,21 @@ describe 'text utilities', ->
|
||||
|
||||
expect(textUtils.isKoreanCharacter("O")).toBe(false)
|
||||
|
||||
describe ".isCjkCharacter(character)", ->
|
||||
describe ".isCJKCharacter(character)", ->
|
||||
it "returns true when the character is either a korean, half-width or double-width character", ->
|
||||
expect(textUtils.isCjkCharacter("我")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("私")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("B")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter(",")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("¢")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("ハ")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("ヒ")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("ᆲ")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("■")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("우")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("가")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("ㅢ")).toBe(true)
|
||||
expect(textUtils.isCjkCharacter("ㄼ")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("我")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("私")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("B")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter(",")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("¢")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("ハ")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("ヒ")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("ᆲ")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("■")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("우")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("가")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("ㅢ")).toBe(true)
|
||||
expect(textUtils.isCJKCharacter("ㄼ")).toBe(true)
|
||||
|
||||
expect(textUtils.isDoubleWidthCharacter("a")).toBe(false)
|
||||
expect(textUtils.isDoubleWidthCharacter("O")).toBe(false)
|
||||
|
@ -60,7 +60,7 @@ isPairedCharacter = (string, index=0) ->
|
||||
isJapaneseCharacter = (charCode) ->
|
||||
0x3000 <= charCode <= 0x30FF
|
||||
|
||||
isCjkUnifiedIdeograph = (charCode) ->
|
||||
isCJKUnifiedIdeograph = (charCode) ->
|
||||
0x4E00 <= charCode <= 0x9FAF
|
||||
|
||||
isFullWidthForm = (charCode) ->
|
||||
@ -71,7 +71,7 @@ isDoubleWidthCharacter = (character) ->
|
||||
charCode = character.charCodeAt(0)
|
||||
|
||||
isJapaneseCharacter(charCode) or
|
||||
isCjkUnifiedIdeograph(charCode) or
|
||||
isCJKUnifiedIdeograph(charCode) or
|
||||
isFullWidthForm(charCode)
|
||||
|
||||
isHalfWidthCharacter = (character) ->
|
||||
@ -89,7 +89,7 @@ isKoreanCharacter = (character) ->
|
||||
0xA960 <= charCode <= 0xA97F or
|
||||
0xD7B0 <= charCode <= 0xD7FF
|
||||
|
||||
isCjkCharacter = (character) ->
|
||||
isCJKCharacter = (character) ->
|
||||
isDoubleWidthCharacter(character) or
|
||||
isHalfWidthCharacter(character) or
|
||||
isKoreanCharacter(character)
|
||||
@ -107,4 +107,4 @@ hasPairedCharacter = (string) ->
|
||||
index++
|
||||
false
|
||||
|
||||
module.exports = {isPairedCharacter, hasPairedCharacter, isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter, isCjkCharacter}
|
||||
module.exports = {isPairedCharacter, hasPairedCharacter, isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter, isCJKCharacter}
|
||||
|
@ -1,5 +1,5 @@
|
||||
_ = require 'underscore-plus'
|
||||
{isPairedCharacter, isCjkCharacter} = require './text-utils'
|
||||
{isPairedCharacter, isCJKCharacter} = require './text-utils'
|
||||
Token = require './token'
|
||||
{SoftTab, HardTab, PairedCharacter, SoftWrapIndent} = require './special-token-symbols'
|
||||
|
||||
@ -327,12 +327,12 @@ class TokenizedLine
|
||||
return column if /\S/.test(@text[column])
|
||||
|
||||
return @text.length
|
||||
else if isCjkCharacter(@text[maxColumn])
|
||||
else if isCJKCharacter(@text[maxColumn])
|
||||
maxColumn
|
||||
else
|
||||
# search backward for the start of the word on the boundary
|
||||
for column in [maxColumn..@firstNonWhitespaceIndex]
|
||||
if /\s/.test(@text[column]) or isCjkCharacter(@text[column])
|
||||
if /\s/.test(@text[column]) or isCJKCharacter(@text[column])
|
||||
return column + 1
|
||||
|
||||
return maxColumn
|
||||
|
Loading…
Reference in New Issue
Block a user