irc: simplify isHighlight
git-svn-id: file:///srv/svn/repo/suika/trunk@786 f0ae65fe-ee39-954e-97ec-027ff2717ef4
This commit is contained in:
parent
cdb3bfe2a4
commit
d09f594aac
14
irc.go
14
irc.go
@ -681,10 +681,8 @@ func (cm *monitorCasemapMap) Value(name string) (online bool) {
|
||||
|
||||
func isWordBoundary(r rune) bool {
|
||||
switch r {
|
||||
case '-', '_', '|':
|
||||
case '-', '_', '|': // inspired from weechat.look.highlight_regex
|
||||
return false
|
||||
case '\u00A0':
|
||||
return true
|
||||
default:
|
||||
return !unicode.IsLetter(r) && !unicode.IsNumber(r)
|
||||
}
|
||||
@ -697,14 +695,8 @@ func isHighlight(text, nick string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Detect word boundaries
|
||||
var left, right rune
|
||||
if i > 0 {
|
||||
left, _ = utf8.DecodeLastRuneInString(text[:i])
|
||||
}
|
||||
if i < len(text) {
|
||||
right, _ = utf8.DecodeRuneInString(text[i+len(nick):])
|
||||
}
|
||||
left, _ := utf8.DecodeLastRuneInString(text[:i])
|
||||
right, _ := utf8.DecodeRuneInString(text[i+len(nick):])
|
||||
if isWordBoundary(left) && isWordBoundary(right) {
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user