aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-05-01 09:46:24 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-05-01 09:46:24 +0000
commit69c3e744983e37662fa7b4f61482fb1d142e257c (patch)
treec32f324f64bd0a581a14853b6bf638fe9d2125c0
parentterm: don't enable ptmx FDM callback until Wayland window has been configured (diff)
util.h: new header file defining commonly used macros
-rw-r--r--commands.c4
-rw-r--r--config.c4
-rw-r--r--csi.c3
-rw-r--r--grid.c3
-rw-r--r--input.c3
-rw-r--r--quirks.c3
-rw-r--r--render.c5
-rw-r--r--search.c3
-rw-r--r--selection.c4
-rw-r--r--sixel.c6
-rw-r--r--terminal.c5
-rw-r--r--util.h5
-rw-r--r--vt.c4
-rw-r--r--wayland.c5
14 files changed, 18 insertions, 39 deletions
diff --git a/commands.c b/commands.c
index 53d0dfb3..ffe03f3b 100644
--- a/commands.c
+++ b/commands.c
@@ -6,9 +6,7 @@
#include "terminal.h"
#include "render.h"
#include "grid.h"
-
-#define max(x, y) ((x) > (y) ? (x) : (y))
-#define min(x, y) ((x) < (y) ? (x) : (y))
+#include "util.h"
void
cmd_scrollback_up(struct terminal *term, int rows)
diff --git a/config.c b/config.c
index 3634a701..0d0b8cca 100644
--- a/config.c
+++ b/config.c
@@ -19,11 +19,9 @@
#define LOG_ENABLE_DBG 0
#include "log.h"
#include "input.h"
+#include "util.h"
#include "wayland.h"
-#define ALEN(v) (sizeof(v) / sizeof(v[0]))
-#define min(x, y) ((x) < (y) ? (x) : (y))
-
static const uint32_t default_foreground = 0xdcdccc;
static const uint32_t default_background = 0x111111;
diff --git a/csi.c b/csi.c
index c684def9..d437f5a6 100644
--- a/csi.c
+++ b/csi.c
@@ -16,8 +16,7 @@
#include "vt.h"
#include "selection.h"
#include "sixel.h"
-
-#define min(x, y) ((x) < (y) ? (x) : (y))
+#include "util.h"
#define UNHANDLED() LOG_DBG("unhandled: %s", csi_as_string(term, final, -1))
#define UNHANDLED_SGR(idx) LOG_DBG("unhandled: %s", csi_as_string(term, 'm', idx))
diff --git a/grid.c b/grid.c
index 3c183703..51d76191 100644
--- a/grid.c
+++ b/grid.c
@@ -7,8 +7,7 @@
#define LOG_ENABLE_DBG 0
#include "log.h"
#include "sixel.h"
-
-#define max(x, y) ((x) > (y) ? (x) : (y))
+#include "util.h"
void
grid_swap_row(struct grid *grid, int row_a, int row_b, bool initialize)
diff --git a/input.c b/input.c
index a6415b31..f7d14f0f 100644
--- a/input.c
+++ b/input.c
@@ -29,10 +29,9 @@
#include "search.h"
#include "selection.h"
#include "terminal.h"
+#include "util.h"
#include "vt.h"
-#define ALEN(v) (sizeof(v) / sizeof(v[0]))
-
static void
execute_binding(struct terminal *term, enum bind_action_normal action,
uint32_t serial)
diff --git a/quirks.c b/quirks.c
index 6685d614..f77b111d 100644
--- a/quirks.c
+++ b/quirks.c
@@ -7,8 +7,7 @@
#define LOG_MODULE "quirks"
#define LOG_ENABLE_DBG 0
#include "log.h"
-
-#define ALEN(v) (sizeof(v) / sizeof(v[0]))
+#include "util.h"
static bool
is_weston(void)
diff --git a/render.c b/render.c
index 36d93be6..ccca05f1 100644
--- a/render.c
+++ b/render.c
@@ -21,14 +21,11 @@
#include "quirks.h"
#include "selection.h"
#include "shm.h"
+#include "util.h"
#define TIME_FRAME_RENDERING 0
#define TIME_SCROLL_DAMAGE 0
-#define ALEN(v) (sizeof(v) / sizeof((v)[0]))
-#define min(x, y) ((x) < (y) ? (x) : (y))
-#define max(x, y) ((x) > (y) ? (x) : (y))
-
struct renderer {
struct fdm *fdm;
struct wayland *wayl;
diff --git a/search.c b/search.c
index 547ac643..eef7b032 100644
--- a/search.c
+++ b/search.c
@@ -16,8 +16,7 @@
#include "render.h"
#include "selection.h"
#include "shm.h"
-
-#define max(x, y) ((x) > (y) ? (x) : (y))
+#include "util.h"
static bool
search_ensure_size(struct terminal *term, size_t wanted_size)
diff --git a/selection.c b/selection.c
index 534a0888..4ed24dca 100644
--- a/selection.c
+++ b/selection.c
@@ -17,11 +17,9 @@
#include "grid.h"
#include "misc.h"
#include "render.h"
+#include "util.h"
#include "vt.h"
-#define min(x, y) ((x) < (y) ? (x) : (y))
-#define max(x, y) ((x) > (y) ? (x) : (y))
-
bool
selection_enabled(const struct terminal *term)
{
diff --git a/sixel.c b/sixel.c
index f335fdff..2d33cf99 100644
--- a/sixel.c
+++ b/sixel.c
@@ -7,11 +7,7 @@
#include "log.h"
#include "render.h"
#include "sixel-hls.h"
-
-#define ALEN(v) (sizeof(v) / sizeof(v[0]))
-#define max(x, y) ((x) > (y) ? (x) : (y))
-#define min(x, y) ((x) < (y) ? (x) : (y))
-
+#include "util.h"
static size_t count;
diff --git a/terminal.c b/terminal.c
index 633503d3..1f1ef782 100644
--- a/terminal.c
+++ b/terminal.c
@@ -27,12 +27,9 @@
#include "selection.h"
#include "sixel.h"
#include "slave.h"
+#include "util.h"
#include "vt.h"
-#define ALEN(v) (sizeof(v) / sizeof(v[0]))
-#define min(x, y) ((x) < (y) ? (x) : (y))
-#define max(x, y) ((x) > (y) ? (x) : (y))
-
#define PTMX_TIMING 0
static const char *const XCURSOR_LEFT_PTR = "left_ptr";
diff --git a/util.h b/util.h
new file mode 100644
index 00000000..c4496bd1
--- /dev/null
+++ b/util.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#define ALEN(v) (sizeof(v) / sizeof((v)[0]))
+#define min(x, y) ((x) < (y) ? (x) : (y))
+#define max(x, y) ((x) > (y) ? (x) : (y))
diff --git a/vt.c b/vt.c
index 743580a1..bd2b7f7a 100644
--- a/vt.c
+++ b/vt.c
@@ -16,9 +16,7 @@
#include "dcs.h"
#include "grid.h"
#include "osc.h"
-
-#define min(x, y) ((x) < (y) ? (x) : (y))
-#define max(x, y) ((x) > (y) ? (x) : (y))
+#include "util.h"
#define UNHANDLED() LOG_DBG("unhandled: %s", esc_as_string(term, final))
diff --git a/wayland.c b/wayland.c
index 5619c7e6..23ccbb8e 100644
--- a/wayland.c
+++ b/wayland.c
@@ -28,10 +28,7 @@
#include "input.h"
#include "render.h"
#include "selection.h"
-
-#define ALEN(v) (sizeof(v) / sizeof(v[0]))
-#define min(x, y) ((x) < (y) ? (x) : (y))
-#define max(x, y) ((x) > (y) ? (x) : (y))
+#include "util.h"
static bool wayl_reload_cursor_theme(
struct wayland *wayl, struct terminal *term);