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