-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impliment i3-style marks #1145
Impliment i3-style marks #1145
Conversation
sway/commands/mark.c
Outdated
list_add(view->marks, mark); | ||
} | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Join your elses on the same line as your closing braces
sway/commands/unmark.c
Outdated
free(view->marks->items[index]); | ||
list_del(view->marks, index); | ||
|
||
if (0 == view->marks->length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No yoda conditionals please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are Yoda conditionals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant value before the variable in the comparison.
E.g: "0 equals mark's length" instead of "mark's length equals 0"
Looks good at first glance. Will review more in depth tomorrow. Nice work, thanks! |
Found an issue:
The marks do not re-appear. |
sway/border.c
Outdated
strcpy(cursor + 1, mark); | ||
*(cursor + len + 1) = ']'; | ||
cursor += len + 2; | ||
*cursor = '\0'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer snprintf to all of this manual string slinging
sway/border.c
Outdated
size += strlen((char *)view->marks->items[i]) + 2; | ||
} | ||
} | ||
marks = (size ? (char *)malloc(size + 1) : strdup("\0")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use snprintf to measure the final string here
sway/border.c
Outdated
get_text_size(cr, config->font, &width, &height, 1, false, "%s", marks); | ||
cairo_move_to(cr, MAX((int)tb->size.w + x - (width + 2), x + 2), y + 2); | ||
cairo_set_source_u32(cr, colors->text); | ||
pango_printf(cr, config->font, 1, false, "%s", marks); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better yet, how about just doing this in a loop and avoiding allocation and string slinging alltogether?
sway/commands/mark.c
Outdated
|
||
swayc_t *view = get_focused_container(&root_container); | ||
int add = false; | ||
int toggle = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool add = false
include stdbool.h too
Looks like the |
This commit adds three commands to sway: `show_marks`, `mark` and `unmark`. Marks are displayed right-aligned in the window border as i3 does. Marks may be found using criteria. Fixes #1007
Thanks! |
Right, so this change is eligible for a bounty. Please follow up via sir@cmpwn.com to claim it, or you can redonate it to another bounty if you wish. |
This commit adds three commands to sway:
show_marks
,mark
andunmark
. Marks are displayed right-aligned in the window border as i3does. Marks may be found using criteria.
Fixes #1007
I may want to add some commits that improve criteria handling before this gets merged.