format code index to tab no space

This commit is contained in:
DreamMaoMao
2025-06-07 13:53:12 +08:00
parent 0af8799a2d
commit 5aaf8d7625
11 changed files with 8896 additions and 8749 deletions
+4
View File
@@ -0,0 +1,4 @@
BasedOnStyle: LLVM
UseTab: Always
TabWidth: 4
IndentWidth: 4
+264 -256
View File
File diff suppressed because it is too large Load Diff
+21 -21
View File
@@ -7,34 +7,34 @@
#include <string.h> #include <string.h>
static void die_if_null(void *ptr) { static void die_if_null(void *ptr) {
if (!ptr) { if (!ptr) {
perror("Failed to allocate memory"); perror("Failed to allocate memory");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
void *xzalloc(size_t size) { void *xzalloc(size_t size) {
if (!size) { if (!size) {
return NULL; return NULL;
} }
void *ptr = calloc(1, size); void *ptr = calloc(1, size);
die_if_null(ptr); die_if_null(ptr);
return ptr; return ptr;
} }
void *xrealloc(void *ptr, size_t size) { void *xrealloc(void *ptr, size_t size) {
if (!size) { if (!size) {
free(ptr); free(ptr);
return NULL; return NULL;
} }
ptr = realloc(ptr, size); ptr = realloc(ptr, size);
die_if_null(ptr); die_if_null(ptr);
return ptr; return ptr;
} }
char *xstrdup(const char *str) { char *xstrdup(const char *str) {
assert(str); assert(str);
char *copy = strdup(str); char *copy = strdup(str);
die_if_null(copy); die_if_null(copy);
return copy; return copy;
} }
+8 -9
View File
@@ -47,18 +47,17 @@ char *xstrdup(const char *str);
* <ptr> before assigning the result. * <ptr> before assigning the result.
*/ */
#define xstrdup_replace(ptr, str) \ #define xstrdup_replace(ptr, str) \
do { \ do { \
free(ptr); \ free(ptr); \
(ptr) = xstrdup(str); \ (ptr) = xstrdup(str); \
} while (0) } while (0)
/* /*
* Frees memory pointed to by <ptr> and sets <ptr> to NULL. * Frees memory pointed to by <ptr> and sets <ptr> to NULL.
* Does nothing if <ptr> is already NULL. * Does nothing if <ptr> is already NULL.
*/ */
#define zfree(ptr) \ #define zfree(ptr) \
do { \ do { \
free(ptr); \ free(ptr); \
(ptr) = NULL; \ (ptr) = NULL; \
} while (0) } while (0)
+43 -51
View File
@@ -11,71 +11,63 @@
#include <pcre2.h> #include <pcre2.h>
void die(const char *fmt, ...) { void die(const char *fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vfprintf(stderr, fmt, ap); vfprintf(stderr, fmt, ap);
va_end(ap); va_end(ap);
if (fmt[0] && fmt[strlen(fmt) - 1] == ':') { if (fmt[0] && fmt[strlen(fmt) - 1] == ':') {
fputc(' ', stderr); fputc(' ', stderr);
perror(NULL); perror(NULL);
} else { } else {
fputc('\n', stderr); fputc('\n', stderr);
} }
exit(1); exit(1);
} }
void *ecalloc(size_t nmemb, size_t size) { void *ecalloc(size_t nmemb, size_t size) {
void *p; void *p;
if (!(p = calloc(nmemb, size))) if (!(p = calloc(nmemb, size)))
die("calloc:"); die("calloc:");
return p; return p;
} }
int fd_set_nonblock(int fd) { int fd_set_nonblock(int fd) {
int flags = fcntl(fd, F_GETFL); int flags = fcntl(fd, F_GETFL);
if (flags < 0) { if (flags < 0) {
perror("fcntl(F_GETFL):"); perror("fcntl(F_GETFL):");
return -1; return -1;
} }
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) { if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
perror("fcntl(F_SETFL):"); perror("fcntl(F_SETFL):");
return -1; return -1;
} }
return 0; return 0;
} }
int regex_match(const char *pattern, const char *str) { int regex_match(const char *pattern, const char *str) {
int errnum; int errnum;
PCRE2_SIZE erroffset; PCRE2_SIZE erroffset;
pcre2_code *re = pcre2_compile( pcre2_code *re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED,
(PCRE2_SPTR)pattern, PCRE2_UTF, // 启用 UTF-8 支持
PCRE2_ZERO_TERMINATED, &errnum, &erroffset, NULL);
PCRE2_UTF, // 启用 UTF-8 支持 if (!re) {
&errnum, &erroffset, NULL PCRE2_UCHAR errbuf[256];
); pcre2_get_error_message(errnum, errbuf, sizeof(errbuf));
if (!re) { fprintf(stderr, "PCRE2 error: %s at offset %zu\n", errbuf, erroffset);
PCRE2_UCHAR errbuf[256]; return 0;
pcre2_get_error_message(errnum, errbuf, sizeof(errbuf)); }
fprintf(stderr, "PCRE2 error: %s at offset %zu\n", errbuf, erroffset);
return 0;
}
pcre2_match_data *match_data = pcre2_match_data_create_from_pattern(re, NULL); pcre2_match_data *match_data =
int ret = pcre2_match( pcre2_match_data_create_from_pattern(re, NULL);
re, int ret =
(PCRE2_SPTR)str, pcre2_match(re, (PCRE2_SPTR)str, strlen(str), 0, 0, match_data, NULL);
strlen(str),
0, 0,
match_data,
NULL
);
pcre2_match_data_free(match_data); pcre2_match_data_free(match_data);
pcre2_code_free(re); pcre2_code_free(re);
return ret >= 0; return ret >= 0;
} }
-1
View File
@@ -1,6 +1,5 @@
/* See LICENSE.dwm file for copyright and license details. */ /* See LICENSE.dwm file for copyright and license details. */
void die(const char *fmt, ...); void die(const char *fmt, ...);
void *ecalloc(size_t nmemb, size_t size); void *ecalloc(size_t nmemb, size_t size);
int fd_set_nonblock(int fd); int fd_set_nonblock(int fd);
+1882 -1854
View File
File diff suppressed because it is too large Load Diff
+39 -39
View File
@@ -4,22 +4,22 @@
/* speedie's maomao config */ /* speedie's maomao config */
#define COLOR(hex) \ #define COLOR(hex) \
{((hex >> 24) & 0xFF) / 255.0f, ((hex >> 16) & 0xFF) / 255.0f, \ {((hex >> 24) & 0xFF) / 255.0f, ((hex >> 16) & 0xFF) / 255.0f, \
((hex >> 8) & 0xFF) / 255.0f, (hex & 0xFF) / 255.0f} ((hex >> 8) & 0xFF) / 255.0f, (hex & 0xFF) / 255.0f}
/* animaion */ /* animaion */
char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom char *animation_type_open = "slide"; // 是否启用动画 //slide,zoom
char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom char *animation_type_close = "slide"; // 是否启用动画 //slide,zoom
int animations = 1; // 是否启用动画 int animations = 1; // 是否启用动画
int tag_animation_direction = HORIZONTAL; // 标签动画方向 int tag_animation_direction = HORIZONTAL; // 标签动画方向
int animation_fade_in = 1; // Enable animation fade in int animation_fade_in = 1; // Enable animation fade in
int animation_fade_out = 1; // Enable animation fade out int animation_fade_out = 1; // Enable animation fade out
float zoom_initial_ratio = 0.5; // 动画起始窗口比例 float zoom_initial_ratio = 0.5; // 动画起始窗口比例
float fadein_begin_opacity = 0.5; // Begin opac window ratio for animations float fadein_begin_opacity = 0.5; // Begin opac window ratio for animations
float fadeout_begin_opacity = 0.5; // Begin opac window ratio for animations float fadeout_begin_opacity = 0.5; // Begin opac window ratio for animations
uint32_t animation_duration_move = 500; // Animation move speed uint32_t animation_duration_move = 500; // Animation move speed
uint32_t animation_duration_open = 400; // Animation open speed uint32_t animation_duration_open = 400; // Animation open speed
uint32_t animation_duration_tag = 300; // Animation tag speed uint32_t animation_duration_tag = 300; // Animation tag speed
uint32_t animation_duration_close = 300; // Animation close speed uint32_t animation_duration_close = 300; // Animation close speed
double animation_curve_move[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线 double animation_curve_move[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
double animation_curve_open[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线 double animation_curve_open[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
@@ -28,20 +28,20 @@ double animation_curve_close[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
/* appearance */ /* appearance */
unsigned int axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔 unsigned int axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔
unsigned int focus_on_activate = 1; // 收到窗口激活请求是否自动跳转聚焦 unsigned int focus_on_activate = 1; // 收到窗口激活请求是否自动跳转聚焦
unsigned int new_is_master = 1; // 新窗口是否插在头部 unsigned int new_is_master = 1; // 新窗口是否插在头部
double default_mfact = 0.55f; // master 窗口比例 double default_mfact = 0.55f; // master 窗口比例
double default_smfact = 0.5f; // 第一个stack窗口比例 double default_smfact = 0.5f; // 第一个stack窗口比例
unsigned int default_nmaster = 1; // 默认master数量 unsigned int default_nmaster = 1; // 默认master数量
/* logging */ /* logging */
int log_level = WLR_ERROR; int log_level = WLR_ERROR;
unsigned int numlockon = 1; // 是否打开右边小键盘 unsigned int numlockon = 1; // 是否打开右边小键盘
unsigned int capslock = 0; // 是否启用快捷键 unsigned int capslock = 0; // 是否启用快捷键
unsigned int ov_tab_mode = 0; // alt tab切换模式 unsigned int ov_tab_mode = 0; // alt tab切换模式
unsigned int hotarea_size = 10; // 热区大小,10x10 unsigned int hotarea_size = 10; // 热区大小,10x10
unsigned int enable_hotarea = 1; // 是否启用鼠标热区 unsigned int enable_hotarea = 1; // 是否启用鼠标热区
int smartgaps = 0; /* 1 means no outer gap when there is only one window */ int smartgaps = 0; /* 1 means no outer gap when there is only one window */
int sloppyfocus = 1; /* focus follows mouse */ int sloppyfocus = 1; /* focus follows mouse */
unsigned int gappih = 5; /* horiz inner gap between windows */ unsigned int gappih = 5; /* horiz inner gap between windows */
unsigned int gappiv = 5; /* vert inner gap between windows */ unsigned int gappiv = 5; /* vert inner gap between windows */
@@ -65,8 +65,8 @@ unsigned int cursor_hide_timeout = 0;
unsigned int swipe_min_threshold = 20; unsigned int swipe_min_threshold = 20;
int bypass_surface_visibility = int bypass_surface_visibility =
0; /* 1 means idle inhibitors will disable idle tracking even if it's 0; /* 1 means idle inhibitors will disable idle tracking even if it's
surface isn't visible */ surface isn't visible */
unsigned int borderpx = 4; /* border pixel of windows */ unsigned int borderpx = 4; /* border pixel of windows */
float rootcolor[] = COLOR(0x323232ff); float rootcolor[] = COLOR(0x323232ff);
float bordercolor[] = COLOR(0x444444ff); float bordercolor[] = COLOR(0x444444ff);
@@ -78,36 +78,36 @@ float globalcolor[] = COLOR(0xb153a7ff);
float overlaycolor[] = COLOR(0x14a57cff); float overlaycolor[] = COLOR(0x14a57cff);
// char *cursor_theme = "Bibata-Modern-Ice"; // char *cursor_theme = "Bibata-Modern-Ice";
int overviewgappi = 5; /* overview时 窗口与边缘 缝隙大小 */ int overviewgappi = 5; /* overview时 窗口与边缘 缝隙大小 */
int overviewgappo = 30; /* overview时 窗口与窗口 缝隙大小 */ int overviewgappo = 30; /* overview时 窗口与窗口 缝隙大小 */
/* To conform the xdg-protocol, set the alpha to zero to restore the old /* To conform the xdg-protocol, set the alpha to zero to restore the old
* behavior */ * behavior */
float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
int warpcursor = 1; /* Warp cursor to focused client */ int warpcursor = 1; /* Warp cursor to focused client */
int xwayland_persistence = 1; /* xwayland persistence */ int xwayland_persistence = 1; /* xwayland persistence */
/* layout(s) */ /* layout(s) */
Layout overviewlayout = {"󰃇", overview, "overview"}; Layout overviewlayout = {"󰃇", overview, "overview"};
Layout layouts[] = { Layout layouts[] = {
// 最少两个,不能删除少于两个 // 最少两个,不能删除少于两个
/* symbol arrange function name */ /* symbol arrange function name */
{"S", scroller, "scroller"}, // 滚动布局 {"S", scroller, "scroller"}, // 滚动布局
{"T", tile, "tile"}, // 堆栈布局 {"T", tile, "tile"}, // 堆栈布局
{"G", grid, "grid"}, {"M", monocle, "monocle"}, {"G", grid, "grid"}, {"M", monocle, "monocle"},
{"D", dwindle, "dwindle"}, {"P", spiral, "spiral"}, {"D", dwindle, "dwindle"}, {"P", spiral, "spiral"},
{"K", deck, "deck"}, {"K", deck, "deck"},
}; };
/* keyboard */ /* keyboard */
struct xkb_rule_names xkb_rules = { struct xkb_rule_names xkb_rules = {
/* can specify fields: rules, model, layout, variant, options */ /* can specify fields: rules, model, layout, variant, options */
/* example: /* example:
.options = "ctrl:nocaps", .options = "ctrl:nocaps",
*/ */
.options = NULL, .options = NULL,
}; };
int repeat_rate = 25; int repeat_rate = 25;
@@ -138,7 +138,7 @@ LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER
*/ */
enum libinput_config_click_method click_method = enum libinput_config_click_method click_method =
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
/* You can choose between: /* You can choose between:
LIBINPUT_CONFIG_SEND_EVENTS_ENABLED LIBINPUT_CONFIG_SEND_EVENTS_ENABLED
@@ -152,7 +152,7 @@ LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
*/ */
enum libinput_config_accel_profile accel_profile = enum libinput_config_accel_profile accel_profile =
LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
double accel_speed = 0.0; double accel_speed = 0.0;
/* You can choose between: /* You can choose between:
LIBINPUT_CONFIG_TAP_MAP_LRM -- 1/2/3 finger tap maps to left/right/middle LIBINPUT_CONFIG_TAP_MAP_LRM -- 1/2/3 finger tap maps to left/right/middle
@@ -164,5 +164,5 @@ enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
#define MODKEY WLR_MODIFIER_ALT #define MODKEY WLR_MODIFIER_ALT
static const char *tags[] = { static const char *tags[] = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "1", "2", "3", "4", "5", "6", "7", "8", "9",
}; };
+427 -417
View File
File diff suppressed because it is too large Load Diff
+5716 -5620
View File
File diff suppressed because it is too large Load Diff
+492 -481
View File
File diff suppressed because it is too large Load Diff