]> git.eshelyaron.com Git - emacs.git/commitdiff
* dispnew.c (set_window_cursor_after_update): Use clip_to_bounds.
authorDmitry Antipov <dmantipov@yandex.ru>
Wed, 12 Dec 2012 15:33:30 +0000 (19:33 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Wed, 12 Dec 2012 15:33:30 +0000 (19:33 +0400)
* gtkutil.c (xg_set_toolkit_scroll_bar_thumb):
* window.c (Frecenter):
* xdisp.c (resize_mini_window, hscroll_window_tree, draw_glyphs):
* xterm.c (x_set_toolkit_scroll_bar_thumb): Likewise.

src/ChangeLog
src/dispnew.c
src/gtkutil.c
src/window.c
src/xdisp.c
src/xterm.c

index d19b7be739554d386e4a791b952360a462ed2e88..3070fcb6e9d72b8a0872e50fded6c9ff5ed4d2c8 100644 (file)
@@ -1,3 +1,11 @@
+2012-12-12  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * dispnew.c (set_window_cursor_after_update): Use clip_to_bounds.
+       * gtkutil.c (xg_set_toolkit_scroll_bar_thumb):
+       * window.c (Frecenter):
+       * xdisp.c (resize_mini_window, hscroll_window_tree, draw_glyphs):
+       * xterm.c (x_set_toolkit_scroll_bar_thumb): Likewise.
+
 2012-12-12  Daniel Colascione  <dancol@dancol.org>
 
        * unexcw.c (fixup_executable): use posix_fallocate to ensure that
index 675c06c22e920a46eda98e705f8bbd1ce83d0685..11ae112f8371058548c753e66004f956d29c98c5 100644 (file)
@@ -4016,11 +4016,10 @@ set_window_cursor_after_update (struct window *w)
       vpos = w->cursor.vpos;
     }
 
-  /* Window cursor can be out of sync for horizontally split windows.  */
-  hpos = max (-1, hpos); /* -1 is for when cursor is on the left fringe */
-  hpos = min (w->current_matrix->matrix_w - 1, hpos);
-  vpos = max (0, vpos);
-  vpos = min (w->current_matrix->nrows - 1, vpos);
+  /* Window cursor can be out of sync for horizontally split windows.
+     Horisontal position is -1 when cursor is on the left fringe.   */
+  hpos = clip_to_bounds (-1, hpos, w->current_matrix->matrix_w - 1);
+  vpos = clip_to_bounds (0, vpos, w->current_matrix->nrows - 1);
   rif->cursor_to (vpos, hpos, cy, cx);
 }
 
index 52a6c37b0d5dc00fb60393e82eaa7310b9518d47..9f2b652525ffa4b0cc79b0d54de3fd8e880dad1f 100644 (file)
@@ -3796,13 +3796,8 @@ xg_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar,
           shown = (gdouble) portion / whole;
         }
 
-      size = shown * XG_SB_RANGE;
-      size = min (size, XG_SB_RANGE);
-      size = max (size, 1);
-
-      value = top * XG_SB_RANGE;
-      value = min (value, XG_SB_MAX - size);
-      value = max (value, XG_SB_MIN);
+      size = clip_to_bounds (1, shown * XG_SB_RANGE, XG_SB_RANGE);
+      value = clip_to_bounds (XG_SB_MIN, top * XG_SB_RANGE, XG_SB_MAX - size);
 
       /* Assume all lines are of equal size.  */
       new_step = size / max (1, FRAME_LINES (f));
index f696e3c2a1b83df7ebac6f6abe9784bb6c07b7eb..28c3bf93553f02c46bfa2b8ea34a8d4452b6b3b4 100644 (file)
@@ -5347,8 +5347,8 @@ and redisplay normally--don't erase and redraw the frame.  */)
        iarg += ht;
 
       /* Don't let it get into the margin at either top or bottom.  */
-      iarg = max (iarg, this_scroll_margin);
-      iarg = min (iarg, ht - this_scroll_margin - 1);
+      iarg = clip_to_bounds (this_scroll_margin, iarg,
+                            ht - this_scroll_margin - 1);
 
       pos = *vmotion (PT, - iarg, w);
       charpos = pos.bufpos;
index ad600f3c83d38742715d92f8079db4de34fbe66a..aead10a7b9bd595da07283426acb9f6d1a05febc 100644 (file)
@@ -10393,8 +10393,7 @@ resize_mini_window (struct window *w, int exact_p)
        max_height = total_height / 4;
 
       /* Correct that max. height if it's bogus.  */
-      max_height = max (1, max_height);
-      max_height = min (total_height, max_height);
+      max_height = clip_to_bounds (1, max_height, total_height);
 
       /* Find out the height of the text in the window.  */
       if (it.line_wrap == TRUNCATE)
@@ -12496,11 +12495,7 @@ hscroll_window_tree (Lisp_Object window)
              if (w == XWINDOW (selected_window))
                pt = PT;
              else
-               {
-                 pt = marker_position (w->pointm);
-                 pt = max (BEGV, pt);
-                 pt = min (ZV, pt);
-               }
+               pt = clip_to_bounds (BEGV, marker_position (w->pointm), ZV);
 
              /* Move iterator to pt starting at cursor_row->start in
                 a line with infinite width.  */
@@ -23485,8 +23480,7 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
 
   /* Let's rather be paranoid than getting a SEGV.  */
   end = min (end, row->used[area]);
-  start = max (0, start);
-  start = min (end, start);
+  start = clip_to_bounds (0, start, end);
 
   /* Translate X to frame coordinates.  Set last_x to the right
      end of the drawing area.  */
index e9e9957466351c3521eaa5017821b88e32da4f6b..374b62874587b765edf10024f64966a7c2babcef 100644 (file)
@@ -4834,9 +4834,7 @@ x_set_toolkit_scroll_bar_thumb (struct scroll_bar *bar, int portion, int positio
       /* Slider size.  Must be in the range [1 .. MAX - MIN] where MAX
          is the scroll bar's maximum and MIN is the scroll bar's minimum
         value.  */
-      size = shown * XM_SB_MAX;
-      size = min (size, XM_SB_MAX);
-      size = max (size, 1);
+      size = clip_to_bounds (1, shown * XM_SB_MAX, XM_SB_MAX);
 
       /* Position.  Must be in the range [MIN .. MAX - SLIDER_SIZE].  */
       value = top * XM_SB_MAX;