Changed data source to include the whole set of chars

This commit is contained in:
Vangelis Kostalas 2019-05-09 16:38:47 +03:00
parent f62e06b988
commit f607e06d2e
8 changed files with 32856 additions and 210 deletions

32841
UnicodeData.txt Normal file

File diff suppressed because it is too large Load diff

View file

@ -25,11 +25,12 @@ def main():
return index return index
with open("unicode_list.txt", "w") as target: with open("unicode_list.txt", "w") as target:
with open("Index.txt", "r") as names: with open("UnicodeData.txt", "r") as names:
for line in names.readlines(): for line in names.readlines():
if line.startswith("#"): attributes = line.strip().split(";")
continue code = attributes[0]
name, code = line.strip().split("\t") name = attributes[1]
comment = attributes[10]
try: try:
num = int(code, 16) num = int(code, 16)
except ValueError: except ValueError:
@ -37,12 +38,12 @@ def main():
continue continue
index = locate_block(num) index = locate_block(num)
if index is not None: if index is not None:
target.write(name + "\t" + code + "\t" + blocks[index] + "\n") target.write(name + "\t" + comment + "\t" + code + "\t" + blocks[index] + "\n")
else: else:
print( print(
"Code " + str(num) + " not found in block, char: " + unichr(num) "Code " + str(num) + " not found in block, char: " + unichr(num)
) )
target.write(name + "\t" + code + "\t" + "\n") target.write(name + "\t" + comment + "\t" + code + "\t" + "\n")
if __name__ == "__main__": if __name__ == "__main__":

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 18 KiB

BIN
images/unicode.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="7.601603mm"
height="7.715291mm"
viewBox="0 0 7.601603 7.715291"
version="1.1"
id="svg8">
<g
id="layer1"
transform="translate(-66.505356,-78.373996)">
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="70.303574"
y="86.089287"
id="unicode_symbol"><tspan
id="tspan815"
x="70.303574"
y="86.089287"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:{font};stroke-width:0.26458332px">{symbol}</tspan></text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 998 B

View file

@ -1,5 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="28.73" height="29.16" viewBox="0 0 7.602 7.715">
<text style="line-height:125%;text-align:center" x="70.304" y="86.089" font-weight="400" font-size="10.583" font-family="sans-serif" letter-spacing="0" word-spacing="0" text-anchor="middle" stroke-width=".265" transform="translate(-66.505 -78.374)" textLength="100%">
<tspan x="70.304" y="86.089" font-family="{font}">{symbol}</tspan>
</text>
</svg>

Before

Width:  |  Height:  |  Size: 462 B

13
main.py
View file

@ -32,15 +32,16 @@ ICON_TEMPLATE = """
class UnicodeChar: class UnicodeChar:
""" Container class for unicode characters """ """ Container class for unicode characters """
def __init__(self, name, block, code): def __init__(self, name, comment, block, code):
self.name = name self.name = name if name != '<control>' else comment
self.comment = comment
self.block = block self.block = block
self.code = code self.code = code
self.character = unichr(int(code, 16)) self.character = unichr(int(code, 16))
def get_search_name(self): def get_search_name(self):
""" Called by `ulauncher.search.SortedList` to get the string that should be used in searches """ """ Called by `ulauncher.search.SortedList` to get the string that should be used in searches """
return self.name return ' '.join([self.code, self.name, self.comment])
class UnicodeCharExtension(Extension): class UnicodeCharExtension(Extension):
@ -54,8 +55,8 @@ class UnicodeCharExtension(Extension):
self.character_list = [] self.character_list = []
with open(join(FILE_PATH, "unicode_list.txt"), "r") as f: with open(join(FILE_PATH, "unicode_list.txt"), "r") as f:
for line in f.readlines(): for line in f.readlines():
name, code, block = line.strip().split("\t") name, comment, code, block = line.strip().split("\t")
character = UnicodeChar(name, block, code) character = UnicodeChar(name, comment, block, code)
self.character_list.append(character) self.character_list.append(character)
@ -64,7 +65,7 @@ class KeywordQueryEventListener(EventListener):
items = [] items = []
arg = event.get_argument() arg = event.get_argument()
if arg: if arg:
result_list = SortedList(arg, min_score=60, limit=10) result_list = SortedList(arg, min_score=40, limit=10)
result_list.extend(extension.character_list) result_list.extend(extension.character_list)
for char in result_list: for char in result_list:
image_path = self._get_character_icon(char) image_path = self._get_character_icon(char)

View file

@ -4,7 +4,7 @@
"name": "Unicode extension", "name": "Unicode extension",
"description": "Extension Description", "description": "Extension Description",
"developer_name": "John Doe", "developer_name": "John Doe",
"icon": "images/bookmark.svg", "icon": "images/unicode.png",
"options": { "options": {
"query_debounce": 0.5 "query_debounce": 0.5
}, },