Skip to content

Commit ff4be60

Browse files
jun-mizutaniPratik Borhade
authored and
Pratik Borhade
committed
Is key Free: Adjust character width for East Asian languages
Because East Asian languages use wide characters, adjust the number of "-" to match the page width Pull Request: https://projects.blender.org/blender/blender-addons/pulls/104848
1 parent bf0e7c8 commit ff4be60

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

development_iskeyfree.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
bl_info = {
88
"name": "Is key Free",
99
"author": "Antonio Vazquez (antonioya)",
10-
"version": (1, 1, 2),
10+
"version": (1, 1, 3),
1111
"blender": (2, 80, 0),
1212
"location": "Text Editor > Sidebar > Dev Tab",
1313
"description": "Find free shortcuts, inform about used and print a key list",
@@ -16,6 +16,7 @@
1616
}
1717

1818
import bpy
19+
1920
from bpy.props import (
2021
BoolProperty,
2122
EnumProperty,
@@ -28,6 +29,7 @@
2829
PropertyGroup,
2930
)
3031

32+
import unicodedata
3133

3234
# ------------------------------------------------------
3335
# Class to find keymaps
@@ -498,6 +500,15 @@ def all_shortcuts_name(self, context):
498500
except:
499501
return None
500502

503+
def unicodelen(self, string):
504+
n = 0
505+
for c in string:
506+
if unicodedata.east_asian_width(c) in 'FWA':
507+
n += 2
508+
else:
509+
n += 1
510+
return n
511+
501512
def execute(self, context):
502513
wm = bpy.context.window_manager
503514
from collections import defaultdict
@@ -536,7 +547,7 @@ def execute(self, context):
536547
textblock.write("\n[%s]\nEntries: %s\n\n" % (ctx, len(mykeys[ctx])))
537548
line_k = sorted(mykeys[ctx])
538549
for keys in line_k:
539-
add_ticks = "-" * (max_line - (len(keys[0]) + len(keys[1])))
550+
add_ticks = "-" * (max_line - (self.unicodelen(keys[0]) + len(keys[1])))
540551
entries = "{ticks} {entry}".format(ticks=add_ticks, entry=keys[1])
541552
textblock.write("{name} {entry}\n".format(name=keys[0], entry=entries))
542553

0 commit comments

Comments
 (0)