diff --git a/include/slurp.h b/include/slurp.h index 94bcf2f..d4a5cb8 100644 --- a/include/slurp.h +++ b/include/slurp.h @@ -15,6 +15,7 @@ struct slurp_box { int32_t x, y; int32_t width, height; struct wl_list link; + char *label; }; struct slurp_selection { @@ -100,7 +101,7 @@ struct slurp_seat { // keymap: struct xkb_keymap *xkb_keymap; struct xkb_state *xkb_state; - + // touch: struct wl_touch *wl_touch; int32_t touch_id; diff --git a/main.c b/main.c index d95bcf7..47b6314 100644 --- a/main.c +++ b/main.c @@ -673,6 +673,11 @@ static void print_formatted_result(const struct slurp_box *result, case 'h': printf("%d", result->height); continue; + case 'l': + if (result->label) { + printf("%s", result->label); + } + continue; default: // If no case was executed, revert i back - we don't need to // skip the next character. @@ -753,8 +758,8 @@ int main(int argc, char *argv[]) { size_t line_size = 0; while (getline(&line, &line_size, stdin) >= 0) { struct slurp_box in_box = {0}; - if (sscanf(line, "%d,%d %dx%d", &in_box.x, &in_box.y, - &in_box.width, &in_box.height) != 4) { + if (sscanf(line, "%d,%d %dx%d %m[^\n]", &in_box.x, &in_box.y, + &in_box.width, &in_box.height, &in_box.label) < 4) { fprintf(stderr, "invalid box format: %s\n", line); return EXIT_FAILURE; } diff --git a/slurp.1.scd b/slurp.1.scd index cb1743a..9a5e5f6 100644 --- a/slurp.1.scd +++ b/slurp.1.scd @@ -16,7 +16,9 @@ select, or click to cancel the selection. If the standard input is not a TTY, slurp will read a list of predefined rectangles for quick selection. Each line must be in the form -", x". +", x [label]". The label is optional and can be any string +that doesn't contain newlines. It can be accessed using the "%l" sequence in a +format string. If the _Esc_ key is pressed, selection is cancelled. If the _Space_ key is held, the selection is moved instead of being resized. @@ -64,6 +66,8 @@ Interpreted sequences are: %h The height of the selection +%l Label included with region from stdin + The default format is "%x,%y %wx%h". # AUTHORS