summaryrefslogtreecommitdiff
path: root/poezio/poopt.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2017-11-12 15:03:09 +0100
committermathieui <mathieui@mathieui.net>2017-11-12 15:03:09 +0100
commitd55cc5872503567775f0d7a7731d6f489bf2299b (patch)
tree725f9e7b8144d36054447b3c82edfb45bda8df1d /poezio/poopt.py
parent92496db823db34f7f7fb1ab31eaef093a707c3e8 (diff)
downloadpoezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.gz
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.bz2
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.tar.xz
poezio-d55cc5872503567775f0d7a7731d6f489bf2299b.zip
yapf -ir
Diffstat (limited to 'poezio/poopt.py')
-rw-r--r--poezio/poopt.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/poezio/poopt.py b/poezio/poopt.py
index 51474222..b9243686 100644
--- a/poezio/poopt.py
+++ b/poezio/poopt.py
@@ -4,7 +4,6 @@
#
# Poezio is free software: you can redistribute it and/or modify
# it under the terms of the zlib license. See the COPYING file.
-
'''This is a template module just for instruction. And poopt.'''
from typing import List, Tuple
@@ -24,6 +23,7 @@ libc = ffi.dlopen(None)
# ctypedef Py_UCS4 wchar_t
# int wcwidth(wchar_t c)
+
# Just checking if the return value is -1. In some (all?) implementations,
# wcwidth("😆") returns -1 while it should return 1. In these cases, we
# return 1 instead because this is by far the most probable real value.
@@ -40,6 +40,7 @@ def xwcwidth(c: str) -> int:
return 1
return res
+
# cut_text: takes a string and returns a tuple of int.
#
# Each two int tuple is a line, represented by the ending position it
@@ -141,9 +142,10 @@ def cut_text(string: str, width: int) -> List[Tuple[int, int]]:
# char's columns to the line's columns
columns += cols
# We are at the end of the string, append the last line, not finished
- retlist.append((start_pos, spos+1))
+ retlist.append((start_pos, spos + 1))
return retlist
+
# wcswidth: An emulation of the POSIX wcswidth(3) function using xwcwidth.
def wcswidth(string: str) -> int:
'''wcswidth(s)
@@ -155,6 +157,7 @@ def wcswidth(string: str) -> int:
columns += xwcwidth(wc)
return columns
+
# cut_by_columns: takes a python string and a number of columns, returns a
# python string truncated to take at most that many columns
# For example cut_by_columns(n, "エメルカ") will return: