if (from < top.from)
{
- GLYPH_INFO (bol (from, 0), from, info);
- sel_start.ascent = -info.this.y;
- sel_start.from = info.line_from;
- sel_start.to = info.line_to;
- TEXT_EXTENTS (from, top.from, rect);
- sel_start.y0 = - rect.height;
- sel_start.y1 = sel_start.y0 + info.this.height;
+ int pos = bol (from, 0);
+
+ TEXT_EXTENTS (pos, top.from, rect);
+ sel_start.y0 = top.y0 - rect.height;
+ sel_start.ascent = - rect.y;
+ GLYPH_INFO (pos, from, info);
+ if (pos < info.line_from)
+ sel_start.y0 += - rect.y + info.y + info.this.y;
}
else
{
GLYPH_INFO (top.from, from, info);
sel_start.y0 = top.ascent + info.y + info.this.y;
- sel_start.y1 = sel_start.y0 + info.this.height;
- sel_start.ascent = -info.this.y;
- sel_start.from = info.line_from;
- sel_start.to = info.line_to;
}
+ sel_start.ascent = -info.this.y;
+ sel_start.y1 = sel_start.y0 + info.this.height;
+ sel_start.from = info.line_from;
+ sel_start.to = info.line_to;
if (to <= sel_start.to)
{
sel_end = sel_start;
- to = bol (to - 1, 1) - 1;
if (to >= sel_end.to)
{
GLYPH_INFO (sel_start.from, to, info);
}
else
{
- to = bol (to - 1, 1) - 1;
GLYPH_INFO (sel_start.from, to, info);
sel_end.y0 = sel_start.y0 + sel_start.ascent + info.y + info.this.y;
sel_end.y1 = sel_end.y0 + info.this.height;
if (cursor.from == from)
{
- /* Start position of selection changed. */
- select_region (pos, to);
- if (pos > from)
- /* Shrunken. Previous selection face must be cleared. */
- redraw (start_y0, sel_start.y1, 1, 0);
+ /* Starting position changed. */
+ if (pos <= from)
+ {
+ /* Enlarged. We can simply overdraw. */
+ select_region (pos, to);
+ redraw (sel_start.y0, start_y1, 0, 0);
+ }
+ else if (pos < to)
+ {
+ /* Shrunken. Previous selection face must be cleared. */
+ select_region (pos, to);
+ redraw (start_y0, sel_start.y1, 1, 0);
+ }
+ else if (pos == to)
+ {
+ /* Shrunken to zero. */
+ XtDisownSelection (w, XA_PRIMARY, CurrentTime);
+ mtext_detach_property (selection);
+ redraw (start_y0, end_y1, 1, 0);
+ }
else
- /* Enlarged. We can simply overdraw. */
- redraw (sel_start.y0, start_y1, 0, 0);
+ {
+ /* Full update is necessary. */
+ select_region (to, pos);
+ redraw (start_y0, sel_end.y1, 1, 0);
+ }
}
else
{
- /* End position of selection changed. */
- select_region (from, pos);
- if (pos < to)
- /* Shrunken. Previous selection face must be cleared. */
- redraw (sel_end.y0, end_y1, 1, 0);
+ /* Ending position changed. */
+ if (pos < from)
+ {
+ /* Full update is necessary. */
+ select_region (pos, from);
+ redraw (sel_start.y0, end_y1, 1, 0);
+ }
+ else if (pos == from)
+ {
+ /* Shrunken to zero. */
+ XtDisownSelection (w, XA_PRIMARY, CurrentTime);
+ mtext_detach_property (selection);
+ redraw (start_y0, end_y1, 1, 0);
+ }
+ else if (pos < to)
+ {
+ /* Shrunken. Previous selection face must be cleared. */
+ select_region (from, pos);
+ redraw (sel_end.y0, end_y1, 1, 0);
+ }
else
- /* Enlarged. We can simply overdraw. */
- redraw (end_y0, sel_end.y1, 0, 0);
+ {
+ /* Enlarged. We can simply overdraw. */
+ select_region (from, pos);
+ redraw (end_y0, sel_end.y1, 0, 0);
+ }
}
}
else