summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-11-08 01:52:39 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-11-08 01:52:39 +0100
commit1ccfd09552a3ee6fa1feb4181bccf862ca21417e (patch)
tree32b8ffae506ae40e795f576fb182844461e6e9fa
parent9c5cab09d40d45a115a233ba17cec4387c63c893 (diff)
downloadpoezio-1ccfd09552a3ee6fa1feb4181bccf862ca21417e.tar.gz
poezio-1ccfd09552a3ee6fa1feb4181bccf862ca21417e.tar.bz2
poezio-1ccfd09552a3ee6fa1feb4181bccf862ca21417e.tar.xz
poezio-1ccfd09552a3ee6fa1feb4181bccf862ca21417e.zip
poopt now handles correctly the size of the chars by jumping
the color attributes properly and ignoring their length.
-rw-r--r--src/pooptmodule.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/pooptmodule.c b/src/pooptmodule.c
index b696fe4e..8a021379 100644
--- a/src/pooptmodule.c
+++ b/src/pooptmodule.c
@@ -44,6 +44,8 @@ static PyObject *poopt_cut_text(PyObject *self, PyObject *args)
int last_space = -1;
int start_pos = 0;
+ int w = width; /* this is a width that increases to make the length of char
+ of colors attribute be ignored */
PyObject* retlist = PyList_New(0);
while (buffer[bpos])
@@ -57,7 +59,7 @@ static PyObject *poopt_cut_text(PyObject *self, PyObject *args)
start_pos = spos + 1;
last_space = -1;
}
- else if ((spos - start_pos) >= width)
+ else if ((spos - start_pos) >= w)
{
if (last_space == -1)
{
@@ -72,11 +74,24 @@ static PyObject *poopt_cut_text(PyObject *self, PyObject *args)
start_pos = last_space + 1;
last_space = -1;
}
+ w = width;
}
if (buffer[bpos] == 25) /* \x19 */
{
- spos++;
- bpos += 2;
+ while (buffer[bpos] &&
+ buffer[bpos] != 'u' &&
+ buffer[bpos] != 'b' &&
+ buffer[bpos] != 'o' &&
+ buffer[bpos] != '}')
+ {
+ bpos++;
+ spos++;
+ w++;
+ }
+ bpos++;
+ spos++;
+ w++;
+ spos--;
}
else
if (buffer[bpos] <= 127) /* ASCII char on one byte */