Fix package and naming

This commit is contained in:
Hamcha 2018-11-16 11:39:41 +01:00
parent 99e86cde50
commit 11c9d9498b
Signed by: hamcha
GPG Key ID: A40413D21021EAEE
1 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,4 @@
package freetype package emoji
import ( import (
"fmt" "fmt"
@ -9,12 +9,12 @@ import (
"unicode/utf8" "unicode/utf8"
) )
// Emoji is a node of an EmojiTable // Emoji is a node of a Table
type Emoji struct { type Emoji struct {
Codepoint []rune Codepoint []rune
IsEmoji bool IsEmoji bool
Path string Path string
Sub EmojiTable Sub Table
} }
func (e Emoji) String() (str string) { func (e Emoji) String() (str string) {
@ -41,11 +41,11 @@ func (e Emoji) Length() int {
return total return total
} }
// EmojiTable is a table of detected Unicode codepoints sequences for which an emoticon is available // Table is a table of detected Unicode codepoints sequences for which an emoticon is available
type EmojiTable map[rune]Emoji type Table map[rune]Emoji
// Find checks if a given strings begins with an emoji made by one or more sequential runes // Find checks if a given strings begins with an emoji made by one or more sequential runes
func (em EmojiTable) Find(str string) *Emoji { func (em Table) Find(str string) *Emoji {
for i, r := range str { for i, r := range str {
e, ok := em[r] e, ok := em[r]
if !ok { if !ok {
@ -67,12 +67,12 @@ func (em EmojiTable) Find(str string) *Emoji {
} }
// IsEmoji checks whether the given rune is an emoji // IsEmoji checks whether the given rune is an emoji
func (em EmojiTable) IsEmoji(cp rune) bool { func (em Table) IsEmoji(cp rune) bool {
_, ok := em[cp] _, ok := em[cp]
return ok return ok
} }
func (em EmojiTable) tostring(indent string, nomarker bool) (str string) { func (em Table) tostring(indent string, nomarker bool) (str string) {
counter := len(em) counter := len(em)
marker := "│ " marker := "│ "
if nomarker { if nomarker {
@ -96,7 +96,7 @@ func (em EmojiTable) tostring(indent string, nomarker bool) (str string) {
return return
} }
func (em EmojiTable) String() string { func (em Table) String() string {
return "Emoji table\n" + em.tostring("", true) return "Emoji table\n" + em.tostring("", true)
} }
@ -105,8 +105,8 @@ func (em EmojiTable) String() string {
// emoji_uXXXX_XXXX.png // emoji_uXXXX_XXXX.png
// where XXXX are Unicode codepoints // where XXXX are Unicode codepoints
// See <https://github.com/googlei18n/noto-emoji/tree/master/png/128> // See <https://github.com/googlei18n/noto-emoji/tree/master/png/128>
func ScanEmojiDirectory(emojipath string) (tab EmojiTable, err error) { func ScanEmojiDirectory(emojipath string) (tab Table, err error) {
tab = make(EmojiTable) tab = make(Table)
filepath.Walk(emojipath, func(path string, info os.FileInfo, err error) error { filepath.Walk(emojipath, func(path string, info os.FileInfo, err error) error {
// Ignore non-images // Ignore non-images
if !strings.HasSuffix(strings.ToLower(path), ".png") { if !strings.HasSuffix(strings.ToLower(path), ".png") {
@ -143,7 +143,7 @@ func ScanEmojiDirectory(emojipath string) (tab EmojiTable, err error) {
} else { } else {
// Add sub-entry if not existant // Add sub-entry if not existant
if newemo.Sub == nil { if newemo.Sub == nil {
newemo.Sub = make(EmojiTable) newemo.Sub = make(Table)
} }
} }
(*curtab)[cprune] = newemo (*curtab)[cprune] = newemo