mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 14:24:27 +01:00
fix d1d172b96c, that constant was wrong.
This commit is contained in:
@@ -104,6 +104,8 @@ var (
|
|||||||
emojiBuffer = harfbuzz.NewBuffer()
|
emojiBuffer = harfbuzz.NewBuffer()
|
||||||
fontCache = make(map[font.Face]*harfbuzz.Font)
|
fontCache = make(map[font.Face]*harfbuzz.Font)
|
||||||
emojiFont *harfbuzz.Font
|
emojiFont *harfbuzz.Font
|
||||||
|
|
||||||
|
lettersAndNumbers = &unicode.RangeTable{}
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScriptRange struct {
|
type ScriptRange struct {
|
||||||
@@ -171,6 +173,15 @@ func initializeImageDrawingStuff() error {
|
|||||||
// shaper stuff
|
// shaper stuff
|
||||||
emojiFont = harfbuzz.NewFont(emojiFace)
|
emojiFont = harfbuzz.NewFont(emojiFace)
|
||||||
|
|
||||||
|
// highlighting stuff
|
||||||
|
lettersAndNumbers.LatinOffset = unicode.Latin.LatinOffset + unicode.Number.LatinOffset
|
||||||
|
lettersAndNumbers.R16 = make([]unicode.Range16, len(unicode.Latin.R16)+len(unicode.Number.R16))
|
||||||
|
copy(lettersAndNumbers.R16, unicode.Latin.R16)
|
||||||
|
copy(lettersAndNumbers.R16[len(unicode.Latin.R16):], unicode.Number.R16)
|
||||||
|
lettersAndNumbers.R32 = make([]unicode.Range32, len(unicode.Latin.R32)+len(unicode.Number.R32))
|
||||||
|
copy(lettersAndNumbers.R32, unicode.Latin.R32)
|
||||||
|
copy(lettersAndNumbers.R32[len(unicode.Latin.R32):], unicode.Number.R32)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +504,7 @@ func shapeText(rawText []rune, fontSize int) (shaping.Output, []bool, []hlstate)
|
|||||||
case hlNormal:
|
case hlNormal:
|
||||||
if glyph.Codepoint == '#' &&
|
if glyph.Codepoint == '#' &&
|
||||||
len(buf.Info) > i+1 &&
|
len(buf.Info) > i+1 &&
|
||||||
unicode.In(buf.Info[i+1].Codepoint, unicode.Nl) {
|
unicode.In(buf.Info[i+1].Codepoint, lettersAndNumbers) {
|
||||||
hlState = hlHashtag
|
hlState = hlHashtag
|
||||||
} else if glyph.Codepoint == 'h' &&
|
} else if glyph.Codepoint == 'h' &&
|
||||||
len(buf.Info) > i+1 &&
|
len(buf.Info) > i+1 &&
|
||||||
@@ -515,8 +526,7 @@ func shapeText(rawText []rune, fontSize int) (shaping.Output, []bool, []hlstate)
|
|||||||
}
|
}
|
||||||
} else if glyph.Codepoint == '@' &&
|
} else if glyph.Codepoint == '@' &&
|
||||||
len(buf.Info) > i+1 &&
|
len(buf.Info) > i+1 &&
|
||||||
unicode.In(buf.Info[i+1].Codepoint,
|
unicode.In(buf.Info[i+1].Codepoint, lettersAndNumbers) {
|
||||||
unicode.Nl, unicode.Number) {
|
|
||||||
hlState = hlMention
|
hlState = hlMention
|
||||||
}
|
}
|
||||||
case hlLink:
|
case hlLink:
|
||||||
@@ -525,11 +535,11 @@ func shapeText(rawText []rune, fontSize int) (shaping.Output, []bool, []hlstate)
|
|||||||
hlState = hlNormal
|
hlState = hlNormal
|
||||||
}
|
}
|
||||||
case hlMention:
|
case hlMention:
|
||||||
if !unicode.In(glyph.Codepoint, unicode.Nl) {
|
if !unicode.In(glyph.Codepoint, lettersAndNumbers) {
|
||||||
hlState = hlNormal
|
hlState = hlNormal
|
||||||
}
|
}
|
||||||
case hlHashtag:
|
case hlHashtag:
|
||||||
if !unicode.In(glyph.Codepoint, unicode.Nl) {
|
if !unicode.In(glyph.Codepoint, lettersAndNumbers) {
|
||||||
hlState = hlNormal
|
hlState = hlNormal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user