vte r2298 - in trunk: . src



Author: behdad
Date: Tue Dec  2 13:21:31 2008
New Revision: 2298
URL: http://svn.gnome.org/viewvc/vte?rev=2298&view=rev

Log:
2008-12-02  Behdad Esfahbod  <behdad gnome org>

        * src/vte-private.h:
        * src/vte.c (vte_terminal_start_selection),
        (vte_terminal_extend_selection):
        Cleanup selection code a bit more.



Modified:
   trunk/ChangeLog
   trunk/src/vte-private.h
   trunk/src/vte.c

Modified: trunk/src/vte-private.h
==============================================================================
--- trunk/src/vte-private.h	(original)
+++ trunk/src/vte-private.h	Tue Dec  2 13:21:31 2008
@@ -296,7 +296,7 @@
 	} selection_origin, selection_last;
 	struct selection_cell_coords {
 		long row, col;
-	} selection_start, selection_end, last_selection_start, last_selection_end;
+	} selection_start, selection_end;
 
 	/* Miscellaneous options. */
 	VteTerminalEraseBinding backspace_binding, delete_binding;

Modified: trunk/src/vte.c
==============================================================================
--- trunk/src/vte.c	(original)
+++ trunk/src/vte.c	Tue Dec  2 13:21:31 2008
@@ -6199,12 +6199,6 @@
 	terminal->pvt->selection_last.y = event->y - VTE_PAD_WIDTH +
 					  (terminal->char_height * delta);
 
-	/* Clear cached coords */
-	terminal->pvt->last_selection_start.row = -1;
-	terminal->pvt->last_selection_start.col = -1;
-	terminal->pvt->last_selection_end.row = -1;
-	terminal->pvt->last_selection_end.col = -1;
-
 	/* Decide whether or not to restart on the next drag. */
 	switch (selection_type) {
 	case selection_type_char:
@@ -6353,8 +6347,15 @@
 	sc = &terminal->pvt->selection_start;
 	ec = &terminal->pvt->selection_end;
 
-	/* Rows are easy.  But we try to be a bit lenient by discounting
-	 * one fourth of the height on each side as wiggle room */
+	/* We want to be more lenient on the user with their selection.
+	 * We round to closest logical position (positions are located between
+	 * cells).  But we don't want to fully round.  So we divide the cell
+	 * width/height into three parts.  The side parts round to their nearest
+	 * position.  The middle part is always inclusive in the selection.
+	 *
+	 * We use different partitions for height and width.
+	 */
+
 	residual = (height + 1) / 4;
 	sc->row = MAX (0, ((long)start->y + residual) / height);
 	ec->row = MAX (0, ((long)end->y - residual) / height);
@@ -6367,36 +6368,17 @@
 		end = tmp;
 	}
 
-	/* Columns are trickier.  We want to be more I-beam-like, so we round
-	 * to closest logical position (positions are located between cells).
-	 * But we don't want to fully round.  So we divide the char width into
-	 * three parts.  The side parts round to their nearest position.  The
-	 * middle part is always inclusive in the selection. XXXXXXX */
+	/* math_div and no MAX, to allow selecting no cells in the line,
+	 * ie. ec->col = -1, which is essentially equal to copying the
+	 * newline from previous line but no chars from current line. */
 	residual = (width + 1) / 3;
 	sc->col = math_div ((long)start->x + residual, width);
 	ec->col = math_div ((long)end->x - residual, width);
 
-#if 0
-	THIS CURRENTLY DOESN'T WORK AS WE HAVE INVALIDATED ALREADY.  GOT TO MOVE
-	INVALIDATION AFTER THIS CHECK AND ENABLE IT.
-
-	/* If the endpoint cells have not changed, then we need do nothing. */
-	if (force == FALSE &&
-	    sc->row == terminal->pvt->last_selection_start.row &&
-	    sc->col == terminal->pvt->last_selection_start.col &&
-	    ec->row == terminal->pvt->last_selection_end.row &&
-	    ec->col == terminal->pvt->last_selection_end.col) {
-		return;
-	}
-	terminal->pvt->last_selection_start = *sc;
-	terminal->pvt->last_selection_end   = *ec;
-#endif
-
 	/* Extend them to full multi-col characters. */
 	sc->col = find_start_column (terminal, sc->col, sc->row);
 	ec->col = find_end_column (terminal, ec->col, ec->row);
 
-
 	/* Extend the selection to handle end-of-line cases, word, and line
 	 * selection.  We do this here because calculating it once is cheaper
 	 * than recalculating for each cell as we render it. */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]