emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r116257: Improve window dividers code.


From: Martin Rudalics
Subject: [Emacs-diffs] trunk r116257: Improve window dividers code.
Date: Tue, 04 Feb 2014 07:38:02 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116257
revision-id: address@hidden
parent: address@hidden
committer: martin rudalics <address@hidden>
branch nick: trunk
timestamp: Tue 2014-02-04 08:36:58 +0100
message:
  Improve window dividers code.
  
  * faces.el (window-divider): New default value.  Rewrite
  doc-string.
  (window-divider-first-pixel, window-divider-last-pixel): New
  faces.
  * dispextern.h (face_id): Add WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID
  and WINDOW_DIVIDER_LAST_PIXEL_FACE_ID.
  * w32term.c (w32_draw_window_divider): Handle first and last
  pixels specially.
  * w32term.h (w32_fill_area_abs): New function.
  * xdisp.c (x_draw_right_divider): Don't draw over bottom
  divider.
  * xfaces.c (realize_basic_faces): Handle new face ids.
  * xfns.c (Fx_create_frame): Call x_default_parameter for right
  and bottom divider width.
  * xterm.c (x_draw_window_divider): Handle first and last pixels
  specially.
modified:
  etc/NEWS                       news-20100311060928-aoit31wvzf25yr1z-1
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/faces.el                  faces.el-20091113204419-o5vbwnq5f7feedwu-562
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/dispextern.h               
dispextern.h-20091113204419-o5vbwnq5f7feedwu-218
  src/w32term.c                  w32term.c-20091113204419-o5vbwnq5f7feedwu-950
  src/w32term.h                  w32term.h-20091113204419-o5vbwnq5f7feedwu-954
  src/xdisp.c                    xdisp.c-20091113204419-o5vbwnq5f7feedwu-240
  src/xfaces.c                   xfaces.c-20091113204419-o5vbwnq5f7feedwu-560
  src/xfns.c                     xfns.c-20091113204419-o5vbwnq5f7feedwu-274
  src/xterm.c                    xterm.c-20091113204419-o5vbwnq5f7feedwu-244
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2014-02-03 07:35:44 +0000
+++ b/etc/NEWS  2014-02-04 07:36:58 +0000
@@ -197,6 +197,18 @@
 These are normal hooks run when an Emacs frame gains or loses input focus.
 
 ---
+*** Emacs can now draw dividers between adjacent windows.  To put
+dividers between side-by-side windows customize the frame parameter
+right-divider-width to some positive integer.  To put dividers between
+vertically stacked windows set the frame parameter bottom-divider-width
+to some positive integer.  Dividers can be dragged with the mouse and
+show a corresponding cursor when the mouse hovers over them.  The
+appearance of dividers can be changed by customizing the basic faces
+window-divider, window-divider-first-pixel and window-divider-last-pixel
+where the latter two are useful to provide a 3D effect or to better set
+dividers apart from surrounding display objects.
+
+---
 *** `split-window' is now a non-interactive function, not a command.
 As a command, it was a special case of `C-x 2' (`split-window-below'),
 and as such superfluous.  After being reimplemented in Lisp, its

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-02-03 15:59:39 +0000
+++ b/lisp/ChangeLog    2014-02-04 07:36:58 +0000
@@ -1,3 +1,10 @@
+2014-02-03  Martin Rudalics  <address@hidden>
+
+       * faces.el (window-divider): New default value.  Rewrite
+       doc-string.
+       (window-divider-first-pixel, window-divider-last-pixel): New
+       faces.
+
 2014-02-03  Dmitry Gutov  <address@hidden>
 
        * progmodes/ruby-mode.el (ruby-font-lock-keywords): `private',

=== modified file 'lisp/faces.el'
--- a/lisp/faces.el     2014-01-01 07:43:34 +0000
+++ b/lisp/faces.el     2014-02-04 07:36:58 +0000
@@ -2425,6 +2425,39 @@
   :version "22.1"
   :group 'basic-faces)
 
+(defface window-divider '((t :foreground "gray60"))
+  "Basic face for window dividers.
+When a divider is less than 3 pixels wide, it is drawn solidly
+with the foreground of this face.  For larger dividers this face
+is used for the inner part while the first pixel line/column is
+drawn with the `window-divider-first-pixel' face and the last
+pixel line/column with the `window-divider-last-pixel' face."
+  :version "24.4"
+  :group 'frames
+  :group 'basic-faces)
+
+(defface window-divider-first-pixel
+  '((t :foreground "gray80"))
+  "Basic face for first pixel line/column of window dividers.
+When a divider is at least 3 pixels wide, its first pixel
+line/column is drawn with the foreground of this face.  If you do
+not want to accentuate the first pixel line/column, set this to
+the same as `window-divider' face."
+  :version "24.4"
+  :group 'frames
+  :group 'basic-faces)
+
+(defface window-divider-last-pixel
+  '((t :foreground "gray40"))
+  "Basic face for last pixel line/column of window dividers.
+When a divider is at least 3 pixels wide, its last pixel
+line/column is drawn with the foreground of this face.  If you do
+not want to accentuate the last pixel line/column, set this to
+the same as `window-divider' face."
+  :version "24.4"
+  :group 'frames
+  :group 'basic-faces)
+
 (defface minibuffer-prompt
   '((((background dark)) :foreground "cyan")
     ;; Don't use blue because many users of the MS-DOS port customize

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-02-03 09:37:43 +0000
+++ b/src/ChangeLog     2014-02-04 07:36:58 +0000
@@ -1,3 +1,18 @@
+2014-02-03  Martin Rudalics  <address@hidden>
+
+       * dispextern.h (face_id): Add WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID
+       and WINDOW_DIVIDER_LAST_PIXEL_FACE_ID.
+       * w32term.c (w32_draw_window_divider): Handle first and last
+       pixels specially.
+       * w32term.h (w32_fill_area_abs): New function.
+       * xdisp.c (x_draw_right_divider): Don't draw over bottom
+       divider.
+       * xfaces.c (realize_basic_faces): Handle new face ids.
+       * xfns.c (Fx_create_frame): Call x_default_parameter for right
+       and bottom divider width.
+       * xterm.c (x_draw_window_divider): Handle first and last pixels
+       specially.
+
 2014-02-03  Dmitry Antipov  <address@hidden>
 
        * print.c (Fexternal_debugging_output): Add cast to pacify

=== modified file 'src/dispextern.h'
--- a/src/dispextern.h  2014-01-01 07:43:34 +0000
+++ b/src/dispextern.h  2014-02-04 07:36:58 +0000
@@ -1765,6 +1765,8 @@
   MENU_FACE_ID,
   VERTICAL_BORDER_FACE_ID,
   WINDOW_DIVIDER_FACE_ID,
+  WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID,
+  WINDOW_DIVIDER_LAST_PIXEL_FACE_ID,
   BASIC_FACE_ID_SENTINEL
 };
 

=== modified file 'src/w32term.c'
--- a/src/w32term.c     2014-01-25 13:04:48 +0000
+++ b/src/w32term.c     2014-02-04 07:36:58 +0000
@@ -628,26 +628,38 @@
 w32_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
-  RECT r;
-  HDC hdc;
-  struct face *face;
-
-  r.left = x0;
-  r.right = x1;
-  r.top = y0;
-  r.bottom = y1;
-
-  hdc = get_frame_dc (f);
-  face = FACE_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
-  if (face)
-    w32_fill_rect (f, hdc, face->foreground, &r);
+  HDC hdc = get_frame_dc (f);
+  struct face *face = FACE_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
+  struct face *face_first = FACE_FROM_ID (f, 
WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
+  struct face *face_last = FACE_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
+  unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f);
+  unsigned long color_first = (face_first
+                              ? face_first->foreground
+                              : FRAME_FOREGROUND_PIXEL (f));
+  unsigned long color_last = (face_last
+                             ? face_last->foreground
+                             : FRAME_FOREGROUND_PIXEL (f));
+
+  if (y1 - y0 > x1 - x0 && x1 - x0 > 2)
+    /* Vertical.  */
+    {
+      w32_fill_area_abs (f, hdc, color_first, x0, y0, x0 + 1, y1);
+      w32_fill_area_abs (f, hdc, color, x0 + 1, y0, x1 - 1, y1);
+      w32_fill_area_abs (f, hdc, color_last, x1 - 1, y0, x1, y1);
+    }
+  else if (x1 - x0 > y1 - y0 && y1 - y0 > 3)
+    /* Horizontal.  */
+    {
+      w32_fill_area_abs (f, hdc, color_first, x0, y0, x1, y0 + 1);
+      w32_fill_area_abs (f, hdc, color, x0, y0 + 1, x1, y1 - 1);
+      w32_fill_area_abs (f, hdc, color_last, x0, y1 - 1, x1, y1);
+    }
   else
-    w32_fill_rect (f, hdc, FRAME_FOREGROUND_PIXEL (f), &r);
+    w32_fill_area_abs (f, hdc, color, x0, y0, x1, y1);
 
   release_frame_dc (f, hdc);
 }
 
-
 /* End update of window W.
 
    Draw vertical borders between horizontally adjacent windows, and

=== modified file 'src/w32term.h'
--- a/src/w32term.h     2014-01-01 07:43:34 +0000
+++ b/src/w32term.h     2014-02-04 07:36:58 +0000
@@ -537,6 +537,16 @@
     w32_fill_rect (f,hdc,pix,&rect); \
 } while (0)
 
+#define w32_fill_area_abs(f,hdc,pix,x0,y0,x1,y1) \
+do { \
+    RECT rect; \
+    rect.left = x0; \
+    rect.top = y0; \
+    rect.right = x1; \
+    rect.bottom = y1; \
+    w32_fill_rect (f,hdc,pix,&rect); \
+} while (0)
+
 #define w32_clear_rect(f,hdc,lprect) \
   w32_fill_rect (f, hdc, FRAME_BACKGROUND_PIXEL (f), lprect)
 

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2014-01-28 09:45:37 +0000
+++ b/src/xdisp.c       2014-02-04 07:36:58 +0000
@@ -29277,7 +29277,8 @@
       int x0 = WINDOW_RIGHT_EDGE_X (w) - WINDOW_RIGHT_DIVIDER_WIDTH (w);
       int x1 = WINDOW_RIGHT_EDGE_X (w);
       int y0 = WINDOW_TOP_EDGE_Y (w);
-      int y1 = WINDOW_BOTTOM_EDGE_Y (w);
+      /* The bottom divider prevails.  */
+      int y1 = WINDOW_BOTTOM_EDGE_Y (w) - WINDOW_BOTTOM_DIVIDER_WIDTH (w);
 
       FRAME_RIF (f)->draw_window_divider (w, x0, x1, y0, y1);
     }

=== modified file 'src/xfaces.c'
--- a/src/xfaces.c      2014-01-28 07:43:24 +0000
+++ b/src/xfaces.c      2014-02-04 07:36:58 +0000
@@ -324,6 +324,8 @@
 Lisp_Object Qmode_line_inactive;
 static Lisp_Object Qvertical_border;
 static Lisp_Object Qwindow_divider;
+static Lisp_Object Qwindow_divider_first_pixel;
+static Lisp_Object Qwindow_divider_last_pixel;
 
 /* The symbol `face-alias'.  A symbols having that property is an
    alias for another face.  Value of the property is the name of
@@ -5249,6 +5251,10 @@
       realize_named_face (f, Qmenu, MENU_FACE_ID);
       realize_named_face (f, Qvertical_border, VERTICAL_BORDER_FACE_ID);
       realize_named_face (f, Qwindow_divider, WINDOW_DIVIDER_FACE_ID);
+      realize_named_face (f, Qwindow_divider_first_pixel,
+                         WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
+      realize_named_face (f, Qwindow_divider_last_pixel,
+                         WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
 
       /* Reflect changes in the `menu' face in menu bars.  */
       if (FRAME_FACE_CACHE (f)->menu_face_changed_p)
@@ -6452,6 +6458,8 @@
   DEFSYM (Qmode_line_inactive, "mode-line-inactive");
   DEFSYM (Qvertical_border, "vertical-border");
   DEFSYM (Qwindow_divider, "window-divider");
+  DEFSYM (Qwindow_divider_first_pixel, "window-divider-first-pixel");
+  DEFSYM (Qwindow_divider_last_pixel, "window-divider-last-pixel");
   DEFSYM (Qtty_color_desc, "tty-color-desc");
   DEFSYM (Qtty_color_standard_values, "tty-color-standard-values");
   DEFSYM (Qtty_color_by_index, "tty-color-by-index");

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2014-01-11 09:31:09 +0000
+++ b/src/xfns.c        2014-02-04 07:36:58 +0000
@@ -3033,6 +3033,10 @@
 #endif
                       "internalBorderWidth", "internalBorderWidth",
                       RES_TYPE_NUMBER);
+  x_default_parameter (f, parms, Qright_divider_width, make_number (0),
+                      NULL, NULL, RES_TYPE_NUMBER);
+  x_default_parameter (f, parms, Qbottom_divider_width, make_number (0),
+                      NULL, NULL, RES_TYPE_NUMBER);
   x_default_parameter (f, parms, Qvertical_scroll_bars,
 #if defined (USE_GTK) && defined (USE_TOOLKIT_SCROLL_BARS)
                       Qright,

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2014-01-26 12:17:55 +0000
+++ b/src/xterm.c       2014-02-04 07:36:58 +0000
@@ -510,15 +510,51 @@
 x_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
 {
   struct frame *f = XFRAME (WINDOW_FRAME (w));
-  struct face *face;
-
-  face = FACE_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
-  if (face)
-    XSetForeground (FRAME_X_DISPLAY (f), f->output_data.x->normal_gc,
-                   face->foreground);
-
-  XFillRectangle (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
-                 f->output_data.x->normal_gc, x0, y0, x1 - x0, y1 - y0);
+  struct face *face = FACE_FROM_ID (f, WINDOW_DIVIDER_FACE_ID);
+  struct face *face_first = FACE_FROM_ID (f, 
WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
+  struct face *face_last = FACE_FROM_ID (f, WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
+  unsigned long color = face ? face->foreground : FRAME_FOREGROUND_PIXEL (f);
+  unsigned long color_first = (face_first
+                              ? face_first->foreground
+                              : FRAME_FOREGROUND_PIXEL (f));
+  unsigned long color_last = (face_last
+                             ? face_last->foreground
+                             : FRAME_FOREGROUND_PIXEL (f));
+  Display *display = FRAME_X_DISPLAY (f);
+  Window window = FRAME_X_WINDOW (f);
+
+  if (y1 - y0 > x1 - x0 && x1 - x0 > 2)
+    /* Vertical.  */
+    {
+      XSetForeground (display, f->output_data.x->normal_gc, color_first);
+      XFillRectangle (display, window, f->output_data.x->normal_gc,
+                     x0, y0, 1, y1 - y0);
+      XSetForeground (display, f->output_data.x->normal_gc, color);
+      XFillRectangle (display, window, f->output_data.x->normal_gc,
+                     x0 + 1, y0, x1 - x0 - 2, y1 - y0);
+      XSetForeground (display, f->output_data.x->normal_gc, color_last);
+      XFillRectangle (display, window, f->output_data.x->normal_gc,
+                     x1 - 1, y0, 1, y1 - y0);
+    }
+  else if (x1 - x0 > y1 - y0 && y1 - y0 > 3)
+    /* Horizontal.  */
+    {
+      XSetForeground (display, f->output_data.x->normal_gc, color_first);
+      XFillRectangle (display, window, f->output_data.x->normal_gc,
+                     x0, y0, x1 - x0, 1);
+      XSetForeground (display, f->output_data.x->normal_gc, color);
+      XFillRectangle (display, window, f->output_data.x->normal_gc,
+                     x0, y0 + 1, x1 - x0, y1 - y0 - 2);
+      XSetForeground (display, f->output_data.x->normal_gc, color_last);
+      XFillRectangle (display, window, f->output_data.x->normal_gc,
+                     x0, y1 - 1, x1 - x0, 1);
+    }
+  else
+    {
+      XSetForeground (display, f->output_data.x->normal_gc, color);
+      XFillRectangle (display, window, f->output_data.x->normal_gc,
+                     x0, y0, x1 - x0, y1 - y0);
+    }
 }
 
 /* End update of window W.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]