Compare commits

..
Author SHA1 Message Date
deepend 1d24941ed5 fix timestamp selection handling 2026-10-25 04:46:53 -06:00
+26 -7
View File
@@ -2119,8 +2119,19 @@ static gboolean
gtk_xtext_check_mark_stamp (GtkXText *xtext, GdkModifierType mask)
{
gboolean redraw = FALSE;
gboolean selecting_stamp = FALSE;
if ((mask & STATE_SHIFT || prefs.hex_text_autocopy_stamp)
/* A drag into the timestamp column deliberately includes the stamp.
Ordinary message selection does not. Only indented views have a
separate timestamp column; inline stamps are part of the text. */
if (xtext->button_down && xtext->buffer->time_stamp && xtext->auto_indent)
{
selecting_stamp =
(xtext->select_start_x >= 0 && xtext->select_start_x < xtext->stamp_width) ||
(xtext->select_end_x >= 0 && xtext->select_end_x < xtext->stamp_width);
}
if ((mask & STATE_SHIFT || prefs.hex_text_autocopy_stamp || selecting_stamp)
&& (!prefs.hex_stamp_text || prefs.hex_text_indent))
{
if (!xtext->mark_stamp)
@@ -2254,13 +2265,15 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event)
if (xtext->button_down)
{
redraw = gtk_xtext_check_mark_stamp (xtext, mask);
gtk_grab_add (widget);
/* Update the pointer position before deciding whether this drag
explicitly includes the timestamp column. */
xtext->select_end_x = x;
xtext->select_end_y = y;
redraw = gtk_xtext_check_mark_stamp (xtext, mask);
gtk_grab_add (widget);
gtk_xtext_selection_update (xtext, event, y, !redraw);
/* user has pressed or released SHIFT, must redraw entire selection */
/* SHIFT or timestamp inclusion changed: redraw the full selection. */
if (redraw)
{
xtext->force_stamp = TRUE;
@@ -2711,8 +2724,8 @@ gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret)
if (!first)
g_string_append_c (text, '\n');
first = FALSE;
if (ent->mark_end > ent->mark_start)
{
/* A selection entirely within the timestamp column has no
message bytes selected, but should still copy the stamp. */
if (ent->mark_start == 0 && xtext->mark_stamp && ent->stamp_len == 0)
{
char *stamp;
@@ -2720,10 +2733,10 @@ gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret)
g_string_append_len (text, stamp, len);
g_free (stamp);
}
if (ent->mark_end > ent->mark_start)
g_string_append_len (text, (char *)ent->str + ent->mark_start,
ent->mark_end - ent->mark_start);
}
}
if (ent == buf->last_ent_end)
break;
}
@@ -3974,6 +3987,12 @@ gtk_xtext_render_stamp (GtkXText * xtext, textentry * ent,
ent->mark_end = -1;
}
}
else
{
/* Message selection offsets must not select unrelated stamp bytes. */
ent->mark_start = -1;
ent->mark_end = -1;
}
y = (xtext->fontsize * line) + xtext->font->ascent - xtext->pixel_offset;
gtk_xtext_render_str (xtext, y, ent, text, len,