]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - terminal.c
New SSH bug flag, for 'can't handle SSH2_MSG_IGNORE'. Another user
[PuTTY.git] / terminal.c
index aaf8705a5f4eafab90020394f273dee7d9d085cd..c0c809c6c7751326b21bed9b4664885461ac7da3 100644 (file)
@@ -5136,6 +5136,31 @@ void term_scroll(Terminal *term, int rel, int where)
     term_update(term);
 }
 
+/*
+ * Scroll the scrollback to centre it on the beginning or end of the
+ * current selection, if any.
+ */
+void term_scroll_to_selection(Terminal *term, int which_end)
+{
+    pos target;
+    int y;
+    int sbtop = -sblines(term);
+
+    if (term->selstate != SELECTED)
+       return;
+    if (which_end)
+       target = term->selend;
+    else
+       target = term->selstart;
+
+    y = target.y - term->rows/2;
+    if (y < sbtop)
+       y = sbtop;
+    else if (y > 0)
+       y = 0;
+    term_scroll(term, -1, y);
+}
+
 /*
  * Helper routine for clipme(): growing buffer.
  */