mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
Add transforms and shortcodes to emoji
Signed-off-by: BulbyVR <26726264+TheDrawingCoder-Gamer@users.noreply.github.com>
This commit is contained in:
parent
cbe2d784f6
commit
7d3a98af67
4 changed files with 3674 additions and 12908 deletions
6
resources/shortcodes.txt
Normal file
6
resources/shortcodes.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
loudly crying face:sob
|
||||||
|
face screaming in fear:scream
|
||||||
|
downcast face with sweat:sweat
|
||||||
|
grinning face with sweat:sweat_smile
|
||||||
|
grinning face with smiling eyes:smile
|
||||||
|
rolling on the floor laughing:rofl
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
from unidecode import unidecode
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,11 +26,12 @@ const QVector<Emoji> emoji::Provider::emoji = {
|
||||||
print(tmpl.render(d))
|
print(tmpl.render(d))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 3:
|
||||||
print('usage: emoji_codegen.py /path/to/emoji-test.txt')
|
print('usage: emoji_codegen.py /path/to/emoji-test.txt /path/to/shortcodes.txt')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
filename = sys.argv[1]
|
filename = sys.argv[1]
|
||||||
|
shortcodefilename = sys.argv[2]
|
||||||
|
|
||||||
people = []
|
people = []
|
||||||
nature = []
|
nature = []
|
||||||
|
@ -52,7 +53,11 @@ if __name__ == '__main__':
|
||||||
'Symbols': symbols,
|
'Symbols': symbols,
|
||||||
'Flags': flags
|
'Flags': flags
|
||||||
}
|
}
|
||||||
|
shortcodeDict = {}
|
||||||
|
# for my sanity - this strips newlines
|
||||||
|
for line in open(shortcodefilename, 'r', encoding="utf8"):
|
||||||
|
longname, shortname = line.strip().split(':')
|
||||||
|
shortcodeDict[longname] = shortname
|
||||||
current_category = ''
|
current_category = ''
|
||||||
for line in open(filename, 'r', encoding="utf8"):
|
for line in open(filename, 'r', encoding="utf8"):
|
||||||
if line.startswith('# group:'):
|
if line.startswith('# group:'):
|
||||||
|
@ -68,16 +73,34 @@ if __name__ == '__main__':
|
||||||
code, qualification, charAndName = segments
|
code, qualification, charAndName = segments
|
||||||
|
|
||||||
# skip unqualified versions of same unicode
|
# skip unqualified versions of same unicode
|
||||||
if qualification == 'unqualified':
|
if qualification != 'fully-qualified':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if qualification == 'component':
|
|
||||||
continue
|
|
||||||
|
|
||||||
char, name = re.match(r'^(\S+) E\d+\.\d+ (.*)$', charAndName).groups()
|
char, name = re.match(r'^(\S+) E\d+\.\d+ (.*)$', charAndName).groups()
|
||||||
|
# drop "face" part
|
||||||
|
|
||||||
|
if name in shortcodeDict:
|
||||||
|
name = shortcodeDict[name]
|
||||||
|
else:
|
||||||
|
if name.endswith(' face'):
|
||||||
|
name = name[:-5]
|
||||||
|
elif name.endswith(' button'):
|
||||||
|
name = name[:-7]
|
||||||
|
else:
|
||||||
|
matchobj = re.match(r'^flag: (.*)$', name)
|
||||||
|
if matchobj:
|
||||||
|
country, = matchobj.groups()
|
||||||
|
name = country + " flag"
|
||||||
|
name = name.replace(" ", "_")
|
||||||
|
name = name.replace("“", "")
|
||||||
|
name = name.replace("”", "")
|
||||||
|
name = name.replace(":", "")
|
||||||
|
name = name.lower()
|
||||||
|
name = unidecode(name)
|
||||||
categories[current_category].append(Emoji(code, name))
|
categories[current_category].append(Emoji(code, name))
|
||||||
|
|
||||||
# Use xclip to pipe the output to clipboard.
|
# Use xclip to pipe the output to clipboard.
|
||||||
# e.g ./codegen.py emoji.json | xclip -sel clip
|
# e.g ./codegen.py emoji.json | xclip -sel clip
|
||||||
|
# alternatively - delete the var from src/emoji/Provider.cpp, and do ./codegen.py emojis shortcodes >> src/emoji/Provider.cpp
|
||||||
generate_qml_list(people=people, nature=nature, food=food, activity=activity, travel=travel, objects=objects, symbols=symbols, flags=flags)
|
generate_qml_list(people=people, nature=nature, food=food, activity=activity, travel=travel, objects=objects, symbols=symbols, flags=flags)
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
1. Get the latest emoji-test.txt from here: https://unicode.org/Public/emoji/
|
1. Get the latest emoji-test.txt from here: https://unicode.org/Public/emoji/
|
||||||
2. Overwrite the existing resources/emoji-test.txt with the new one
|
2. Overwrite the existing resources/emoji-test.txt with the new one
|
||||||
3. Run `./scripts/emoji_codegen.py resources/emoji-test.txt` and replace the current tail of src/emoji/Provider.cpp with the new output
|
3. Run `./scripts/emoji_codegen.py resources/emoji-test.txt resources/shortcodes.txt` and replace the current tail of src/emoji/Provider.cpp with the new output
|
||||||
4. `make lint`
|
4. `make lint`
|
||||||
5. Compile and test
|
5. Compile and test
|
||||||
|
|
||||||
|
|
||||||
|
|
15827
src/emoji/Provider.cpp
15827
src/emoji/Provider.cpp
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue