чување 39ca2835b2e586289806e92744832513d93243f8
родитељ 3fd3558736ca3e355ae2fe4b9e6b2f82a5bebc38
Аутор: Страхиња Радић <sr@strahinja.org>
Датум: Wed, 7 Aug 2024 21:08:29 +0200
draw.c: Reformat comments
Diffstat:
| M | draw.c | | | 49 | +++++++++++++++++++++++++++++-------------------- |
измењених датотека: 1, додавања: 29(+), брисања: 20(-)
diff --git a/draw.c b/draw.c
@@ -806,7 +806,7 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
* ds ds+c
* <.....(sc).....>
* (align == RIGHT in this case)
- * */
+ */
int d = 0; /* distance, in screen columns, from x to
* visible part of the string, followed by
@@ -816,7 +816,7 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
* d + p_l to d + mc - p_r (part of the
* displayed string containing text, between
* padding; string fits within this many columns
- * */
+ */
int sc = 0; /* current screen column; goes from 0..c-1
* only increased when actual characters are
@@ -830,8 +830,8 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
const int ts = TAB_SIZE;
- const uint32_t* ps = s; /* pointer to current character in string;
- * string index: ps-s */
+ const uint32_t* ps = s; /* pointer to current character in
+ * string; string index: ps-s */
uint16_t cfg = fg; /* current fg */
uint16_t cbg = bg; /* current bg */
@@ -862,14 +862,14 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
sc = 0;
/*
- * main idea: we go from start of the string to the end and count
- * displayed characters until we get to ds, then we also output
- * characters; tabs count as spaces up to multiple of ts, counted from
- * the start of the string
+ * main idea: we go from start of the string to the end and
+ * count displayed characters until we get to ds, then we also
+ * output characters; tabs count as spaces up to multiple of ts,
+ * counted from the start of the string
*
- * exit condition is also sc == c, when we have reached the maximum
- * number of characters to output
- * */
+ * exit condition is also sc == c, when we have reached the
+ * maximum number of characters to output
+ */
while (*ps && sc < c)
{
if ((hctl == 0) && ((ps - s) >= ssi) && ((ps - s) < sei))
@@ -893,6 +893,7 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
{
if (ssc < ds)
{
+ /* clang-format off */
/* ssc-(ssc%ts)+ts
* \t | = ssc+(ts-(ssc%ts))
* ----------|-----[ :|::: ]
@@ -900,7 +901,8 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
* | | ds
* ssc-(ssc%ts) |
* ssc
- * */
+ */
+ /* clang-format on */
if (ssc - (ssc % ts) + ts >= ds)
{
for (int j = 0;
@@ -913,6 +915,7 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
if (hctl < 0)
hctl = 0;
}
+ /* clang-format off */
/* else, just increase counter
*
* \t
@@ -922,10 +925,12 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
* | ssc-(ssc%ts)+ts
* ssc = ssc + (ts-(ssc%ts))
* */
+ /* clang-format on */
ssc += (ts - (ssc % ts));
}
else /* ssc >= ds */
{
+ /* clang-format off */
/*
* ds ssc+(ts-(ssc%ts))
* | \t |
@@ -933,7 +938,8 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
* | |
* | ds+c
* ssc
- * */
+ */
+ /* clang-format on */
if (ssc + (ts - (ssc % ts)) >= ds + c)
{
for (int j = 0; j < ds + c - ssc; j++)
@@ -947,15 +953,17 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
}
else /* ssc+(ts-(ssc%ts)) < ds+c */
{
+ /* clang-format off */
/*
* \t
* [ :::::::::::|::: ]-----
* | | | |
* | | | ds+c
- * | | ssc+(ts-(ssc%ts))
+ * | | ssc+(ts-(ssc%ts))
* | ssc
* ds
- * */
+ */
+ /* clang-format on */
for (int j = 0; j < ts - (ssc % ts); j++)
tb_set_cell(x + d + p_l + sc + j,
y, L' ', cfg, cbg);
@@ -976,14 +984,15 @@ u32_draw_string(const int x, const int y, const uint16_t fg, const uint16_t bg,
{
if (sc < c && w > 0)
{
- /*if ((w == 0) && (x + d + p_l + sc >
- 0)) tb_extend_cell(x + d + p_l + sc
+ /*if ((w == 0) && (x + d + p_l +
+ sc > 0)) tb_extend_cell(x + d +
+ p_l + sc
- 1,
y, *ps);
else*/
- /* TODO: Get the previous cell (if
- * applicable) and overwrite it if
- * it has wcwidth >1
+ /* TODO: Get the previous cell
+ * (if applicable) and overwrite
+ * it if it has wcwidth >1
*/
tb_set_cell(x + d + p_l + sc, y, *ps,
cfg, cbg);