diff options
author | Jack Sangdahl <[email protected]> | 2024-04-25 13:21:10 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2024-04-25 13:21:10 -0600 |
commit | 6182c1ff04f442086d7ce44538d357b863422295 (patch) | |
tree | b0fdc9c0f1287408c933f2df5ea4c5aa3e25acdc | |
parent | a9c2d5b0084857f572e08ba1413cb7916cf2409f (diff) | |
download | st-6182c1ff04f442086d7ce44538d357b863422295.tar.gz st-6182c1ff04f442086d7ce44538d357b863422295.zip |
align makefile & tidy code
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 29 | ||||
-rw-r--r-- | arg.h | 13 | ||||
-rw-r--r-- | boxdraw.c | 7 | ||||
-rw-r--r-- | boxdraw_data.h | 7 | ||||
-rw-r--r-- | config.h | 2 | ||||
-rw-r--r-- | config.mk | 31 | ||||
-rw-r--r-- | hb.c | 3 | ||||
-rw-r--r-- | hb.h | 4 | ||||
-rw-r--r-- | readme.md | 2 | ||||
-rw-r--r-- | st.c | 5 | ||||
-rw-r--r-- | st.h | 26 | ||||
-rw-r--r-- | win.h | 4 | ||||
-rw-r--r-- | x.c | 3 |
14 files changed, 58 insertions, 79 deletions
@@ -2,3 +2,4 @@ st *.o *.orig *.rej +.gdb_history @@ -1,8 +1,12 @@ -# st - simple terminal -# See LICENSE file for copyright and license details. -.POSIX: +PREFIX = /usr -include config.mk +DEPS = fontconfig harfbuzz + +CFLAGS = -I/usr/X11R6/include `pkg-config --cflags ${DEPS}` \ + -DVERSION=\"0.9\" -D_XOPEN_SOURCE=600 + +LDFLAGS = -L/usr/X11R6/lib -lm -lX11 -lXft \ + `pkg-config --libs ${DEPS}` SRC = st.c x.c boxdraw.c hb.c OBJ = $(SRC:.c=.o) @@ -10,27 +14,20 @@ OBJ = $(SRC:.c=.o) all: st .c.o: - $(CC) $(STCFLAGS) -c $< + cc $(CFLAGS) -c $< st.o: config.h st.h win.h x.o: arg.h config.h st.h win.h hb.h hb.o: st.h boxdraw.o: config.h st.h boxdraw_data.h -$(OBJ): config.h config.mk +$(OBJ): config.h st: $(OBJ) - $(CC) -o $@ $(OBJ) $(STLDFLAGS) + cc -o $@ $(OBJ) $(LDFLAGS) clean: - rm -f st *.o *.orig *.rej - -dist: clean - mkdir -p st-$(VERSION) - cp -r Makefile readme.md config.mk arg.h hb.h win.h \ - config.h boxdraw_data.h st.h $(SRC) st-$(VERSION) - tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz - rm -rf st-$(VERSION) + rm -f st $(OBJ) *.orig *.rej install: st mkdir -p $(DESTDIR)$(PREFIX)/bin @@ -39,5 +36,3 @@ install: st uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/st - -.PHONY: all clean dist install uninstall @@ -1,14 +1,9 @@ -/* - * Copy me if you can. - * by 20h - */ - -#ifndef ARG_H__ -#define ARG_H__ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X +#pragma once extern char *argv0; -/* use main(int argc, char *argv[]) */ #define ARGBEGIN \ for (argv0 = *argv, argv++, argc--; \ argv[0] && argv[0][0] == '-' && argv[0][1]; argc--, argv++) { \ @@ -44,5 +39,3 @@ extern char *argv0; ? (char *)0 \ : (brk_ = 1, (argv[0][i_ + 1] != '\0') ? (&argv[0][i_ + 1]) \ : (argc--, argv++, argv[0]))) - -#endif @@ -1,8 +1,5 @@ -/* - * Copyright 2018 Avi Halachmi (:avih) [email protected] https://github.com/avih - * MIT/X Consortium License - */ - +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X #include <X11/Xft/Xft.h> #include "st.h" #include "boxdraw_data.h" diff --git a/boxdraw_data.h b/boxdraw_data.h index 37a7e8a..bb7b00f 100644 --- a/boxdraw_data.h +++ b/boxdraw_data.h @@ -1,7 +1,6 @@ -/* - * Copyright 2018 Avi Halachmi (:avih) [email protected] https://github.com/avih - * MIT/X Consortium License - */ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X +#pragma once /* * U+25XX codepoints data @@ -1,3 +1,5 @@ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X #pragma once static char *font = diff --git a/config.mk b/config.mk deleted file mode 100644 index 810ffa4..0000000 --- a/config.mk +++ /dev/null @@ -1,31 +0,0 @@ -# st version -VERSION = 0.9 - -# paths -PREFIX = /usr/local -MANPREFIX = $(PREFIX)/share/man - -X11INC = /usr/X11R6/include -X11LIB = /usr/X11R6/lib - -PKG_CONFIG = pkg-config - -# includes and libs -INCS = -I$(X11INC) \ - `$(PKG_CONFIG) --cflags glib-2.0` \ - `$(PKG_CONFIG) --cflags fontconfig` \ - `$(PKG_CONFIG) --cflags freetype2` \ - `$(PKG_CONFIG) --cflags harfbuzz` -LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \ - `$(PKG_CONFIG) --libs glib-2.0` \ - `$(PKG_CONFIG) --libs fontconfig` \ - `$(PKG_CONFIG) --libs freetype2` \ - `$(PKG_CONFIG) --libs harfbuzz` - -# flags -STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS) -STLDFLAGS = $(LIBS) $(LDFLAGS) - -# compiler and linker -CC = gcc @@ -1,7 +1,8 @@ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X #include <X11/Xft/Xft.h> #include <hb-ft.h> #include <hb.h> -#include <math.h> #include <stdio.h> #include <stdlib.h> @@ -1,3 +1,7 @@ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X +#pragma once + #include <X11/Xft/Xft.h> #include <hb-ft.h> #include <hb.h> @@ -3,4 +3,4 @@ ![image](nord_image.png) ### dependencies -libXft, libXext, harfbuzz, glib, freetype, fontconfig, JetBrainsMono Nerd Font +harfbuzz, fontconfig, JetBrainsMono Nerd Font @@ -1,4 +1,5 @@ -/* See LICENSE for license details. */ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X #include <ctype.h> #include <errno.h> #include <fcntl.h> @@ -48,7 +49,7 @@ #define TLINE(y) \ ((y) < term.scr \ ? term.hist[((y) + term.histi - term.scr + HISTSIZE + 1) % HISTSIZE] \ - : term.line[(y)-term.scr]) + : term.line[(y) - term.scr]) #define TLINE_HIST(y) \ ((y) <= HISTSIZE - term.row + 2 ? term.hist[(y)] \ @@ -1,15 +1,29 @@ -/* See LICENSE for license details. */ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X +#pragma once #include <stdint.h> #include <sys/types.h> -// #include <gd.h> -#include <glib.h> - /* macros */ -#define LEN(a) (sizeof(a) / sizeof(a)[0]) +#define MIN(a, b) \ + ({ \ + __typeof__(a) _a = (a); \ + __typeof__(b) _b = (b); \ + _a < _b ? _a : _b; \ + }) +#define MAX(a, b) \ + ({ \ + __typeof__(a) _a = (a); \ + __typeof__(b) _b = (b); \ + _a > _b ? _a : _b; \ + }) +#define CHECK(value) \ + (!__builtin_types_compatible_p(typeof((value)), typeof(&(value)[0]))) +#define LEN(a) \ + (__builtin_choose_expr(CHECK((a)), sizeof((a)) / sizeof((a)[0]), (void)0)) #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b)) -#define DIVCEIL(n, d) (((n) + ((d)-1)) / (d)) +#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d)) #define DEFAULT(a, b) (a) = (a) ? (a) : (b) #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) #define ATTRCMP(a, b) \ @@ -1,4 +1,6 @@ -/* See LICENSE for license details. */ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X +#pragma once enum win_mode { MODE_VISIBLE = 1 << 0, @@ -1,4 +1,5 @@ -/* See LICENSE for license details. */ +// Copyright 2024 @waffle87 +// SPDX-License-Identifier: MIT/X #include <errno.h> #include <math.h> #include <limits.h> |