Commit graph

37 commits

Author SHA1 Message Date
Daniel Eklöf
060586dbbe
tag: remove the :b formatter
Superseded by /N. Removing since a) it's no longer needed, and b) its
name is not consistent with the other kb/mb/gb formatters.
2024-09-05 08:23:47 +02:00
Zhong Jianxin
311c481bfe
tag: add '/N' formatter 2024-09-05 08:19:28 +02:00
Zhong Jianxin
9498d7e445
tag: combine FMT_*BYTE into one FMT_DIVIDE 2024-09-05 08:19:28 +02:00
Daniel Eklöf
700bf5b28c
tag: add 'b' formatter
Divides the tag's decimal value by 8.

Closes #392
2024-08-20 14:34:45 +02:00
Delgan
b85ba99980 Apply "clang-format" preferences globally 2024-04-07 10:05:10 +02:00
Daniel Eklöf
e1fc3a0e29
tag: explicitly initialize ‘fmt’
Fixes the following compiler warning/error:

  In file included from /usr/include/stdio.h:906,
                   from ../tag.c:6:
  In function ‘snprintf’,
      inlined from ‘tags_expand_template’ at ../tag.c:708:13:
  /usr/include/bits/stdio2.h:54:10: error: ‘fmt’ may be used uninitialized [-Werror=maybe-uninitialized]
     54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     55 |                                    __glibc_objsize (__s), __fmt,
        |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     56 |                                    __va_arg_pack ());
        |                                    ~~~~~~~~~~~~~~~~~
  ../tag.c: In function ‘tags_expand_template’:
  ../tag.c:677:25: note: ‘fmt’ was declared here
    677 |             const char *fmt;
        |                         ^~~
  cc1: all warnings being treated as errors

Closes #311
2023-07-14 12:52:19 +02:00
Daniel Eklöf
0f3894bf63
tag: handle width formatter on ints when no other formatting options are used
For example: in {cpu:3}, the ‘3’ were ignored, assuming ‘cpu’ was an
int tag.
2023-01-02 12:19:17 +01:00
Leonardo Gibrowski Faé
146759bd96
implement field width tag format option
This implements the possibility of specifying padding for numeric tags.
Both space and zero padding is supported.
2023-01-01 16:22:44 -03:00
Leonardo Gibrowski Faé
87854fa101
float tag: let user specify number of decimals
Closes #200
2022-12-09 15:24:59 +01:00
Daniel Eklöf
a8994b9268
tag: for now, always use 2 decimals for floats
In the future, we’ll want to add a way to specify the number of
decimals, as part of the formatter.
2022-06-03 19:43:28 +02:00
Daniel Eklöf
de4814d16e
tag: use as_float() when kb/mb/gb formatting a float tag value 2022-06-02 21:33:04 +02:00
Leonardo Gibrowski Faé
2b103b7acd Implement conditions on tag
A condition is formed by:
    <tag> <op> <value>

<tag> is the normal yambar tag. <op> is one of '==', '!=', '<', '<=', '>', or
'>='. <value> is what you wish to compare it to.

'boolean' tags must be used directly. They falsehood is matched with '~':

    <tag>
    ~<tag>

Finally, to match an empty string, one must use ' "" ':
    <tag> <op> ""
2022-04-23 17:13:24 -03:00
Daniel Eklöf
52e0b5f3d1
tag: fix inverted logic for KiB vs KB logic 2022-02-01 19:01:04 +01:00
Daniel Eklöf
eff890ab9d
tag: add kib/mib/gib formatters 2021-09-01 19:12:29 +02:00
Daniel Eklöf
a6194c63e6
tag: add kb/mb/gb formatters 2021-09-01 19:12:27 +02:00
Daniel Eklöf
e201cc3d30
tag: add a ‘%’ formatter
Range tags can now be rendered as a percentage value, by using a ‘%’
formatter:

  {tag_name:%}
2021-09-01 19:12:16 +02:00
Daniel Eklöf
c79ffbe057
Add support binding on-click handlers to other buttons than LEFT
One can now bind the left/middle/right mouse buttons to on-click. In
fact, you can have all three buttons bound to different handlers for
the same particle. The new syntax is

    on-click:
        left: <command>
        middle: <command>
        right: <command>

Leaving one out is the same thing as not mapping it at
all. Furthermore,

    on-click: <command>

is still valid, and is a shorthand for

    on-click:
        left: <commsnd>
2021-07-01 17:15:53 +02:00
Daniel Eklöf
5c4ae642f2
tag: fix crash on empty tag specifier, “{}”
For strings with empty tag specifiers, “{}”, we ended up calling
tag_for_name() with a NULL pointer for name. This caused us to crash.

Closes #48
2021-05-25 18:08:54 +02:00
Daniel Eklöf
9cf00f8200
codespell: spelling fixes 2020-12-25 12:31:20 +01:00
Daniel Eklöf
3f6030df68 tag: add support for "hex" and "oct" format modifiers 2019-01-21 21:05:38 +01:00
Daniel Eklöf
a0ecc1ff03 tag: add support for "min", "max" and "unit" tag arguments 2019-01-21 20:15:04 +01:00
Daniel Eklöf
7936e197af tag: add support for an optional tag argument in a tag format string
E..g {volume:max}
2019-01-21 20:14:25 +01:00
Daniel Eklöf
09fcedc33f tag: pull in logging 2019-01-21 20:14:09 +01:00
Daniel Eklöf
400a92fa04 tag: rename and rewrite sbuf_strcat()
In particular, don't use strncat() with a length derived from the
source.
2019-01-07 18:26:48 +01:00
Daniel Eklöf
32b4e9986d tag: tags_expand_template(): return NULL if template is NULL 2018-12-29 17:10:54 +01:00
Daniel Eklöf
ab67d036ae tags: break out string formatting from particle/string 2018-12-29 17:03:41 +01:00
Daniel Eklöf
b0f0a1e942 tag: add realtime unit MSECS (milliseconds) 2018-12-28 14:05:02 +01:00
Daniel Eklöf
13cc11e200 tag: refresh_in() *must* use the realtime unit 2018-12-28 14:04:35 +01:00
Daniel Eklöf
20b3299afd tag: add a refresh_in() interface function
E.g. particles may use this to force a refresh after a certain amount
of time.

Note that it can only be used with 'realtime' tags.
2018-12-28 12:43:02 +01:00
Daniel Eklöf
904f9ff8e1 tag: all tag constructors must now be passed a module 'owner' 2018-12-28 12:40:41 +01:00
Daniel Eklöf
025c6991a3 tag: add a new variant of int tags, with a realtime unit property
The idea is, consumers of a tag, can check the realtime property, and
if set to something other than TAG_REALTIME_NONE, schedule a realtime
update.

For example, it could be used to track song progress.
2018-12-27 11:43:27 +01:00
Daniel Eklöf
3bc4bd56a9 tag: tag_new_string(): allow NULL values (treat as empty string) 2018-12-19 21:01:36 +01:00
Daniel Eklöf
2218bd1583 tag: allow integer tags to have a minimum and maximum value 2018-12-16 15:58:40 +01:00
Daniel Eklöf
1712362da9 tag: add as_int(), as_bool() and as_float() 2018-11-18 11:11:50 +01:00
Daniel Eklöf
44a2dbb201 tag: rename tag.value() -> tag.as_string() 2018-11-18 11:02:21 +01:00
Daniel Eklöf
12e9304612 tag: add a boolean tag 2018-11-18 11:00:01 +01:00
Daniel Eklöf
8bf8a398b9 initial commit: wip 2018-11-17 11:30:33 +01:00