Skip to content

Commit f607e06

Browse files
committed
Changed data source to include the whole set of chars
1 parent f62e06b commit f607e06

8 files changed

+32856
-210
lines changed

UnicodeData.txt

+32,841
Large diffs are not rendered by default.

generate_character_list.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,25 @@ def locate_block(code):
2525
return index
2626

2727
with open("unicode_list.txt", "w") as target:
28-
with open("Index.txt", "r") as names:
28+
with open("UnicodeData.txt", "r") as names:
2929
for line in names.readlines():
30-
if line.startswith("#"):
31-
continue
32-
name, code = line.strip().split("\t")
30+
attributes = line.strip().split(";")
31+
code = attributes[0]
32+
name = attributes[1]
33+
comment = attributes[10]
3334
try:
3435
num = int(code, 16)
3536
except ValueError:
3637
print("could not convert " + code)
3738
continue
3839
index = locate_block(num)
3940
if index is not None:
40-
target.write(name + "\t" + code + "\t" + blocks[index] + "\n")
41+
target.write(name + "\t" + comment + "\t" + code + "\t" + blocks[index] + "\n")
4142
else:
4243
print(
4344
"Code " + str(num) + " not found in block, char: " + unichr(num)
4445
)
45-
target.write(name + "\t" + code + "\t" + "\n")
46+
target.write(name + "\t" + comment + "\t" + code + "\t" + "\n")
4647

4748

4849
if __name__ == "__main__":

images/bookmark.svg

-168
This file was deleted.

images/unicode.png

2.9 KB
Loading

images/unicode.svg

-24
This file was deleted.

images/unicode2.svg

-5
This file was deleted.

main.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@
3232
class UnicodeChar:
3333
""" Container class for unicode characters """
3434

35-
def __init__(self, name, block, code):
36-
self.name = name
35+
def __init__(self, name, comment, block, code):
36+
self.name = name if name != '<control>' else comment
37+
self.comment = comment
3738
self.block = block
3839
self.code = code
3940
self.character = unichr(int(code, 16))
4041

4142
def get_search_name(self):
4243
""" Called by `ulauncher.search.SortedList` to get the string that should be used in searches """
43-
return self.name
44+
return ' '.join([self.code, self.name, self.comment])
4445

4546

4647
class UnicodeCharExtension(Extension):
@@ -54,8 +55,8 @@ def _load_character_table(self):
5455
self.character_list = []
5556
with open(join(FILE_PATH, "unicode_list.txt"), "r") as f:
5657
for line in f.readlines():
57-
name, code, block = line.strip().split("\t")
58-
character = UnicodeChar(name, block, code)
58+
name, comment, code, block = line.strip().split("\t")
59+
character = UnicodeChar(name, comment, block, code)
5960
self.character_list.append(character)
6061

6162

@@ -64,7 +65,7 @@ def on_event(self, event, extension):
6465
items = []
6566
arg = event.get_argument()
6667
if arg:
67-
result_list = SortedList(arg, min_score=60, limit=10)
68+
result_list = SortedList(arg, min_score=40, limit=10)
6869
result_list.extend(extension.character_list)
6970
for char in result_list:
7071
image_path = self._get_character_icon(char)

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "Unicode extension",
55
"description": "Extension Description",
66
"developer_name": "John Doe",
7-
"icon": "images/bookmark.svg",
7+
"icon": "images/unicode.png",
88
"options": {
99
"query_debounce": 0.5
1010
},

0 commit comments

Comments
 (0)