Charator "➜" makes cursor moves only one step, but in most fonts it is 2
Opened this issue · 1 comments
Neutree commented
when use oh-my-zsh , in most mono fonts, the width of ➜
charactor is 2, but pyte only move cursor 1, for wcwidth('➜') => 1
, is there any way to resolve this problem if I don't want to change the font(cause I didnt find the font which this charactor's width is 1)
Neutree commented
haha, to get the cursor width pixel, I used a stupid but works code
cursor = screen.cursor
self.cursor_x = cursor.x
self.cursor_y = cursor.y
# get the line text where the cursor is
line = screen.display[self.cursor_y]
# to get the actual charactors befor cursor.x
x = self.cursor_x
while 1:
w = wcswidth(line[:x])
if w > self.cursor_x:
x -= 1
elif w < self.cursor_x:
x += 1
else:
break
text = line[:x]
char = line[x]
# calculate the pixel width
width_cursor_x = self.font.width(text)