rem: if(!done) { chunk = chunk->next; start = w = 0; } else { tPtr->tpos = w; tPtr->currentChunk = chunk; break; } }	} else { short vS = (tPtr->hasVscroller)?32:12; if(para->align == WARight) { tPtr->clicked.x = tPtr->view->size.width-vS; } else if (para->align == WACenter) { tPtr->clicked.x = -(vS/2)+(tPtr->view->size.width-vS)/2; } else { tPtr->clicked.x = 2; } }
add: if (0 && chunk->next) { if (chunk->next->type == ctImage) { if (x + 10 < line_width + chunk->next->pixmap->width) { printf("true\n"); done = True; } } } } else { _width = chunk->pixmap->width; line_width += _width; if (line_width + tPtr->clicked.x >= x) { line_width -= _width; tPtr->tpos = 0; done = True; } }
context: cursorToTextPosition(Text *tPtr, int x, int y){    Paragraph *para = NULL;    Chunk *chunk = NULL;    WMFont *font;    short line_width=0;    short orig_x, orig_y;    if(x<(tPtr->hasVscroller?21:1)) {        y -= tPtr->clheight;        x = tPtr->view->size.width; //tPtr->visibleW;    } else if(x>tPtr->clwidth && x<tPtr->clicked.x) {        //x = (tPtr->hasVscroller)?21:1;        //y += tPtr->clheight;    }    if(x<0) x=0;    orig_x = x;    if(y<0 || y>tPtr->view->size.height-3) return;    orig_y = y;    tPtr->clicked.x = orig_x;    tPtr->clicked.y = y;    tPtr->clicked.y += tPtr->vpos;    tPtr->clicked.y -= tPtr->rulerShown?40:0;    para = tPtr->paragraphs;    if(!para) return;    while(para->next) {        if( tPtr->clicked.y>= para->top-4 &&            tPtr->clicked.y < para->bottom+4) break;        para = para->next;    } if(!(tPtr->currentPara = para)) return;    tPtr->clicked.y -= para->top;    if(tPtr->clicked.y<0) tPtr->clicked.y=0;    if(tPtr->hasVscroller) x -= 21;    if(x<0) x=0;    tPtr->findingClickPoint = True;    tPtr->foundClickPoint = False;    /* also affects tPtr->currentChunk, tPtr->clicked.x and y,     tPtr->clheight and ->width */    putParagraphOnPixmap(tPtr, para, False);    tPtr->findingClickPoint = False;    tPtr->clicked.y += para->top;    if(tPtr->currentChunk) {        short _width=0, start=tPtr->tpos, done=False, w=0;        chunk = tPtr->currentChunk;        while(!done && chunk && line_width<tPtr->clwidth) {            if(chunk->type == ctText) {                font = (tPtr->monoFont)?tPtr->dFont:chunk->font;                for (w=start; w<chunk->chars; w++) {                    _width = WMWidthOfString(font, &chunk->text[w], 1);                    line_width += _width;                    if(line_width+tPtr->clicked.x >= x) {                        line_width -= _width;                        done = True;                        printf("break\n");                        break;                    } }                if(0&&chunk->next) {                    if(chunk->next->type == ctImage) {                        if(x+10 < line_width+chunk->next->pixmap->width) {                            printf("true\n");                            done = True;                        } } }            } else  {                _width  = chunk->pixmap->width;                line_width += _width;                if(line_width+tPtr->clicked.x >= x) {                    line_width -= _width;                    tPtr->tpos = 0;                    done = True;                } }            if(!done) {                chunk = chunk->next;                start = w = 0;            } else {                tPtr->tpos = w;                tPtr->currentChunk = chunk;                break;            } }	} else {        short vS = (tPtr->hasVscroller)?32:12;        if(para->align == WARight) {            tPtr->clicked.x = tPtr->view->size.width-vS;        } else if (para->align == WACenter) {            tPtr->clicked.x = -(vS/2)+(tPtr->view->size.width-vS)/2;        } else {            tPtr->clicked.x = 2;        } }    tPtr->cursor.x = tPtr->clicked.x+2+line_width;    tPtr->cursor.y = tPtr->clicked.y;    tPtr->clicked.y = orig_y;    tPtr->clicked.x = orig_x;    putParagraphOnPixmap(tPtr, para, True);    paintText(tPtr);}