From d55cc5872503567775f0d7a7731d6f489bf2299b Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 12 Nov 2017 15:03:09 +0100 Subject: yapf -ir --- poezio/poopt.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'poezio/poopt.py') 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: -- cgit v1.2.3