diff options
-rw-r--r-- | src/pooptmodule.c | 28 | ||||
-rw-r--r-- | src/text_buffer.py | 2 | ||||
-rw-r--r-- | src/windows.py | 3 |
3 files changed, 16 insertions, 17 deletions
diff --git a/src/pooptmodule.c b/src/pooptmodule.c index cdc0d127..289313f3 100644 --- a/src/pooptmodule.c +++ b/src/pooptmodule.c @@ -17,7 +17,6 @@ otherwise it will just use the equivalent python functions. */ #include "Python.h" PyObject *ErrorObject; -#define DEBUG(...) fprintf(stderr, __VA_ARGS__) /*** The module functions @@ -35,11 +34,11 @@ PyDoc_STRVAR(poopt_cut_text_doc, "cut_text(width, text)\n\n\nReturn the list of static PyObject *poopt_cut_text(PyObject *self, PyObject *args) { - int length; + /* int length; */ unsigned char *buffer; int width; - if (PyArg_ParseTuple(args, "es#i", NULL, &buffer, &length, &width) == 0) + if (PyArg_ParseTuple(args, "si", &buffer, &width) == 0) return NULL; int bpos = 0; /* the real position in the char* */ @@ -49,7 +48,7 @@ static PyObject *poopt_cut_text(PyObject *self, PyObject *args) PyObject* retlist = PyList_New(0); - while (bpos < length) + while (buffer[bpos]) { if (buffer[bpos] == ' ') last_space = spos; @@ -78,17 +77,20 @@ static PyObject *poopt_cut_text(PyObject *self, PyObject *args) } if (buffer[bpos] == 25) /* \x19 */ { - spos--; - bpos += 1; + spos++; + bpos += 2; } - else if (buffer[bpos] <= 127) /* ASCII char on one byte */ - bpos += 1; - else if (buffer[bpos] <= 195) - bpos += 2; - else if (buffer[bpos] <= 225) - bpos += 3; else - bpos += 4; + if (buffer[bpos] <= 127) /* ASCII char on one byte */ + bpos += 1; + else if (buffer[bpos] >= 194 && buffer[bpos] <= 223) + bpos += 2; + else if (buffer[bpos] >= 224 && buffer[bpos] <= 239) + bpos += 3; + else if (buffer[bpos] >= 240 && buffer[bpos] <= 244) + bpos += 4; + else + return NULL; spos++; } if (PyList_Append(retlist, Py_BuildValue("(i,i)", start_pos, spos)) == -1) diff --git a/src/text_buffer.py b/src/text_buffer.py index 77646aea..a6465da3 100644 --- a/src/text_buffer.py +++ b/src/text_buffer.py @@ -46,7 +46,7 @@ class TextBuffer(object): def add_message(self, txt, time=None, nickname=None, nick_color=None, history=None): time = time or datetime.now() - msg = Message(txt='%s'%(txt,), nick_color=nick_color, + msg = Message(txt='%s\x19o'%(txt,), nick_color=nick_color, time=time, str_time=time.strftime("%Y-%m-%d %H:%M:%S")\ if history else time.strftime("%H:%M:%S"),\ nickname=nickname, user=None) diff --git a/src/windows.py b/src/windows.py index 1aff61bc..59365dc8 100644 --- a/src/windows.py +++ b/src/windows.py @@ -565,8 +565,6 @@ class TextWin(Win): if nick: offset += wcwidth.wcswidth(nick) + 2 # + nick + spaces length first = True - start_pos = 0 - end_pos = 0 text_len = len(txt) offset = (3 if message.nickname else 1) + len(message.str_time)+len(message.nickname or '') lines = cut_text(txt, self.width-offset-1) @@ -576,7 +574,6 @@ class TextWin(Win): end_pos=line[1], first=first)) first = False - start_pos = next_start_pos while len(self.built_lines) > self.lines_nb_limit: self.built_lines.pop(0) return len(lines) |