ratpoison-devel
[Top][All Lists]
Advanced

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

[RP] [PATCH] Add quiet variable to surpress "Current Frame".


From: Vasil Zlatanov
Subject: [RP] [PATCH] Add quiet variable to surpress "Current Frame".
Date: Fri, 14 Aug 2015 01:29:06 +0200
User-agent: Mutt/1.5.23+102 (2ca89bed6448) (2014-03-12)

---
 doc/ratpoison.mdoc.1 |  6 ++++
 doc/ratpoison.texi   |  1 +
 src/actions.c        | 15 ++++++++
 src/data.h           |  2 ++
 src/main.c           |  1 +
 src/split.c          | 99 +++++++++++++++++++++++++++-------------------------
 6 files changed, 76 insertions(+), 48 deletions(-)

diff --git a/doc/ratpoison.mdoc.1 b/doc/ratpoison.mdoc.1
index 2e3c356..dba987e 100644
--- a/doc/ratpoison.mdoc.1
+++ b/doc/ratpoison.mdoc.1
@@ -1141,6 +1141,12 @@ Decide if history expansion using ! is available.
 Default is
 .Li 0
 (off).
+.It Cm quiet Li 0 | 1
+Decide if ratpoison should indicate the current frame when changed.
+.Pp
+Default is
+.Li 0
+(off).
 .El
 .Sh FILES
 .Bl -tag -width "%%sysconfdir%%/ratpoisonrc" -compact
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index da9da16..a3db239 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -1672,6 +1672,7 @@ Here is a list of variables that can be set:
 @item historysize
 @item historycompaction
 @item historyexpansion
address@hidden quiet
 @end itemize
 
 @end deffn
diff --git a/src/actions.c b/src/actions.c
index 725b3d8..03faa86 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -81,6 +81,7 @@ static cmdret * set_topkmap (struct cmdarg **args);
 static cmdret * set_historysize (struct cmdarg **args);
 static cmdret * set_historycompaction (struct cmdarg **args);
 static cmdret * set_historyexpansion (struct cmdarg **args);
+static cmdret * set_quiet (struct cmdarg **args);
 
 LIST_HEAD(set_vars);
 
@@ -150,6 +151,7 @@ init_set_vars(void)
   add_set_var ("historysize", set_historysize, 1, "", arg_NUMBER);
   add_set_var ("historycompaction", set_historycompaction, 1, "", arg_NUMBER);
   add_set_var ("historyexpansion", set_historyexpansion, 1, "", arg_NUMBER);
+  add_set_var ("quiet", set_quiet, 1, "", arg_NUMBER);
 }
 
 /* rp_keymaps is ratpoison's list of keymaps. */
@@ -3791,6 +3793,19 @@ set_historyexpansion (struct cmdarg **args)
 }
 
 static cmdret *
+set_quiet (struct cmdarg **args)
+{
+  if (args[0] == NULL)
+    return cmdret_new (RET_SUCCESS, "%d", defaults.quiet);
+
+  if (ARG(0, number) != 0 && ARG(0, number) != 1)
+    return cmdret_new (RET_FAILURE, "set quiet: invalid argument");
+
+  defaults.quiet = ARG(0, number);
+  return cmdret_new (RET_SUCCESS, NULL);
+}
+
+static cmdret *
 set_font (struct cmdarg **args)
 {
 #ifdef USE_XFT_FONT
diff --git a/src/data.h b/src/data.h
index f4bd185..ca3b1f2 100644
--- a/src/data.h
+++ b/src/data.h
@@ -265,6 +265,8 @@ struct rp_defaults
   /* expand ! when compiled with libhistory */
   int history_expansion;
 
+  int quiet;
+
   char *frame_selectors;
 
   /* How many frame sets to remember when undoing. */
diff --git a/src/main.c b/src/main.c
index 52dbcce..fda70d7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -592,6 +592,7 @@ init_defaults (void)
   defaults.win_name = WIN_NAME_TITLE;
   defaults.startup_message = 1;
   defaults.warp = 0;
+  defaults.quiet = 0;
   defaults.window_list_style = STYLE_COLUMN;
 
   defaults.history_size = 20;
diff --git a/src/split.c b/src/split.c
index b36b99e..1872e65 100644
--- a/src/split.c
+++ b/src/split.c
@@ -945,56 +945,59 @@ show_frame_indicator (int force)
 void
 show_frame_message (char *msg)
 {
-  rp_screen *s = current_screen ();
-  int width, height;
-  rp_frame *frame;
-  rp_window *win;
-  rp_window_elem *elem = NULL;
-  struct sbuf *msgbuf;
-
-  frame = current_frame();
-  win = current_window ();
-  if (win)
+  if (!defaults.quiet)
     {
-      rp_group *g;
-
-      g = groups_find_group_by_window (win);
-      elem = group_find_window (&g->mapped_windows, win);
-    }
-
-  /* A frame doesn't always contain a window. */
-  msgbuf = sbuf_new (0);
-  if (elem)
-    format_string (msg, elem, msgbuf);
-  else
-    {
-      sbuf_concat (msgbuf, EMPTY_FRAME_MESSAGE);
+      rp_screen *s = current_screen ();
+      int width, height;
+      rp_frame *frame;
+      rp_window *win;
+      rp_window_elem *elem = NULL;
+      struct sbuf *msgbuf;
+      
+      frame = current_frame();
+      win = current_window ();
+      if (win)
+        {
+          rp_group *g;
+      
+          g = groups_find_group_by_window (win);
+          elem = group_find_window (&g->mapped_windows, win);
+        }
+      
+      /* A frame doesn't always contain a window. */
+      msgbuf = sbuf_new (0);
+      if (elem)
+        format_string (msg, elem, msgbuf);
+      else
+        {
+          sbuf_concat (msgbuf, EMPTY_FRAME_MESSAGE);
+        }
+      
+      width = defaults.bar_x_padding * 2
+        + rp_text_width (s, msgbuf->data, msgbuf->len);
+      height = (FONT_HEIGHT (s) + defaults.bar_y_padding * 2);
+      
+      /* We don't want another frame indicator to be displayed on another
+       * screen at the same time, so we hide it before bringing it back again.
+       */
+      hide_frame_indicator ();
+      
+      XMoveResizeWindow (dpy, s->frame_window,
+                         s->left + frame->x + frame->width / 2 - width / 2,
+                         s->top + frame->y + frame->height / 2 - height / 2,
+                         width, height);
+      
+      XMapRaised (dpy, s->frame_window);
+      XClearWindow (dpy, s->frame_window);
+      XSync (dpy, False);
+      
+      rp_draw_string (s, s->frame_window, STYLE_NORMAL,
+                      defaults.bar_x_padding,
+                      defaults.bar_y_padding + FONT_ASCENT(s),
+                      msgbuf->data, msgbuf->len);
+      
+      sbuf_free (msgbuf);
     }
-
-  width = defaults.bar_x_padding * 2
-    + rp_text_width (s, msgbuf->data, msgbuf->len);
-  height = (FONT_HEIGHT (s) + defaults.bar_y_padding * 2);
-
-  /* We don't want another frame indicator to be displayed on another
-   * screen at the same time, so we hide it before bringing it back again.
-   */
-  hide_frame_indicator ();
-
-  XMoveResizeWindow (dpy, s->frame_window,
-                     s->left + frame->x + frame->width / 2 - width / 2,
-                     s->top + frame->y + frame->height / 2 - height / 2,
-                     width, height);
-
-  XMapRaised (dpy, s->frame_window);
-  XClearWindow (dpy, s->frame_window);
-  XSync (dpy, False);
-
-  rp_draw_string (s, s->frame_window, STYLE_NORMAL,
-                  defaults.bar_x_padding,
-                  defaults.bar_y_padding + FONT_ASCENT(s),
-                  msgbuf->data, msgbuf->len);
-
-  sbuf_free (msgbuf);
 }
 
 rp_frame *
-- 
2.5.0




reply via email to

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