2021-11-14 17:55:59 -05:00
|
|
|
#include "layouts.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define TMP_BUFFER_SIZE 128
|
|
|
|
|
2021-11-14 18:26:13 -05:00
|
|
|
void layouts_symbol_func(
|
|
|
|
LayoutsSymbolFunc func,
|
|
|
|
char *const buffer,
|
|
|
|
const size_t buffer_size,
|
|
|
|
const unsigned int clients_in_master,
|
|
|
|
const unsigned int visible_clients
|
|
|
|
) {
|
|
|
|
if (func == NULL) {
|
|
|
|
func = layouts_symbol_unknown;
|
|
|
|
}
|
|
|
|
|
|
|
|
func(
|
|
|
|
buffer,
|
|
|
|
buffer_size,
|
|
|
|
clients_in_master,
|
|
|
|
visible_clients
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-14 17:55:59 -05:00
|
|
|
void layouts_symbol_unknown(
|
|
|
|
char *const buffer,
|
|
|
|
const size_t buffer_size,
|
|
|
|
const unsigned int clients_in_master,
|
|
|
|
const unsigned int visible_clients
|
|
|
|
) {
|
|
|
|
// TODO: maybe we should assert
|
|
|
|
if (buffer == NULL) return;
|
|
|
|
|
|
|
|
char tmp[TMP_BUFFER_SIZE];
|
|
|
|
sprintf(tmp, "?%u/%u?", clients_in_master, visible_clients);
|
|
|
|
tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0';
|
|
|
|
strncpy(buffer, tmp, buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void layouts_symbol_monocle(
|
|
|
|
char *const buffer,
|
|
|
|
const size_t buffer_size,
|
|
|
|
const unsigned int clients_in_master,
|
|
|
|
const unsigned int visible_clients
|
|
|
|
) {
|
|
|
|
// TODO: maybe we should assert
|
|
|
|
if (buffer == NULL) return;
|
|
|
|
|
|
|
|
char tmp[TMP_BUFFER_SIZE];
|
2021-11-14 18:12:53 -05:00
|
|
|
sprintf(tmp, "[%u/%u]", clients_in_master, visible_clients);
|
2021-11-14 17:55:59 -05:00
|
|
|
tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0';
|
|
|
|
strncpy(buffer, tmp, buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void layouts_symbol_floating(
|
|
|
|
char *const buffer,
|
|
|
|
const size_t buffer_size,
|
|
|
|
const unsigned int clients_in_master,
|
|
|
|
const unsigned int visible_clients
|
|
|
|
) {
|
|
|
|
// TODO: maybe we should assert
|
|
|
|
if (buffer == NULL) return;
|
|
|
|
|
|
|
|
char tmp[TMP_BUFFER_SIZE];
|
2021-11-14 18:12:53 -05:00
|
|
|
sprintf(tmp, "<%u/%u>", clients_in_master, visible_clients);
|
2021-11-14 17:55:59 -05:00
|
|
|
tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0';
|
|
|
|
strncpy(buffer, tmp, buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void layouts_symbol_tile(
|
|
|
|
char *const buffer,
|
|
|
|
const size_t buffer_size,
|
|
|
|
const unsigned int clients_in_master,
|
|
|
|
const unsigned int visible_clients
|
|
|
|
) {
|
|
|
|
// TODO: maybe we should assert
|
|
|
|
if (buffer == NULL) return;
|
|
|
|
|
|
|
|
char tmp[TMP_BUFFER_SIZE];
|
2021-11-14 18:12:53 -05:00
|
|
|
sprintf(tmp, "{%u/%u}=", clients_in_master, visible_clients);
|
2021-11-14 17:55:59 -05:00
|
|
|
tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0';
|
|
|
|
strncpy(buffer, tmp, buffer_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void layouts_symbol_centeredmaster(
|
|
|
|
char *const buffer,
|
|
|
|
const size_t buffer_size,
|
|
|
|
const unsigned int clients_in_master,
|
|
|
|
const unsigned int visible_clients
|
|
|
|
) {
|
|
|
|
// TODO: maybe we should assert
|
|
|
|
if (buffer == NULL) return;
|
|
|
|
|
|
|
|
char tmp[TMP_BUFFER_SIZE];
|
2021-11-14 18:12:53 -05:00
|
|
|
sprintf(tmp, "={%u/%u}=", clients_in_master, visible_clients);
|
2021-11-14 17:55:59 -05:00
|
|
|
tmp[(buffer_size > TMP_BUFFER_SIZE ? TMP_BUFFER_SIZE : buffer_size) - 1] = '\0';
|
|
|
|
strncpy(buffer, tmp, buffer_size);
|
|
|
|
}
|