mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-11-14 06:59:50 -05:00
fix: parse circle arg next and prev
This commit is contained in:
parent
5d6e9bd4e6
commit
2dd0589a10
1 changed files with 19 additions and 1 deletions
|
|
@ -136,6 +136,24 @@ typedef struct {
|
||||||
typedef void (*FuncType)(const Arg *);
|
typedef void (*FuncType)(const Arg *);
|
||||||
Config config;
|
Config config;
|
||||||
|
|
||||||
|
int parse_circle_direction(const char *str) {
|
||||||
|
// 将输入字符串转换为小写
|
||||||
|
char lowerStr[10];
|
||||||
|
int i = 0;
|
||||||
|
while (str[i] && i < 9) {
|
||||||
|
lowerStr[i] = tolower(str[i]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
lowerStr[i] = '\0';
|
||||||
|
|
||||||
|
// 根据转换后的小写字符串返回对应的枚举值
|
||||||
|
if (strcmp(lowerStr, "next") == 0) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int parse_direction(const char *str) {
|
int parse_direction(const char *str) {
|
||||||
// 将输入字符串转换为小写
|
// 将输入字符串转换为小写
|
||||||
char lowerStr[10];
|
char lowerStr[10];
|
||||||
|
|
@ -311,7 +329,7 @@ FuncType parse_func_name(char *func_name, Arg *arg, char *arg_value) {
|
||||||
|
|
||||||
if (strcmp(func_name, "focusstack") == 0) {
|
if (strcmp(func_name, "focusstack") == 0) {
|
||||||
func = focusstack;
|
func = focusstack;
|
||||||
(*arg).i = atoi(arg_value);
|
(*arg).i = parse_circle_direction(arg_value);
|
||||||
} else if (strcmp(func_name, "focusdir") == 0) {
|
} else if (strcmp(func_name, "focusdir") == 0) {
|
||||||
func = focusdir;
|
func = focusdir;
|
||||||
(*arg).i = parse_direction(arg_value);
|
(*arg).i = parse_direction(arg_value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue