Changeset 96c6a00 in mainline for uspace/lib/ui/src/paint.c
- Timestamp:
- 2022-03-10T13:44:10Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c88d7f99
- Parents:
- ca2680d
- git-author:
- Jiri Svoboda <jiri@…> (2022-03-09 18:44:00)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-03-10 13:44:10)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ui/src/paint.c
rca2680d r96c6a00 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2022 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 39 39 #include <gfx/render.h> 40 40 #include <gfx/text.h> 41 #include <ui/accel.h> 41 42 #include <ui/paint.h> 42 43 #include <stdlib.h> … … 566 567 } 567 568 568 /** Process text with '~' markup.569 *570 * Parse text with tilde markup into a list of strings. @a *rbuf is set571 * to point to a newly allocated buffer containing consecutive null-terminated572 * strings.573 *574 * Each part between two '~' becomes one string. '~~' is translated into575 * a literal '~' character. @a *endptr is set to point to the first character576 * beyond the end of the list.577 *578 * @param str String with tilde markup579 * @param rbuf Place to store pointer to newly allocated buffer.580 * @param endptr Place to store end pointer (just after last character)581 * @return EOK on success or an error code582 */583 static int ui_text_process(const char *str, char **rbuf, char **endptr)584 {585 const char *sp;586 char *dp;587 char *buf;588 589 buf = malloc(str_size(str) + 1);590 if (buf == NULL)591 return ENOMEM;592 593 /* Break down string into list of (non)highlighted parts */594 sp = str;595 dp = buf;596 while (*sp != '\0') {597 if (*sp == '~') {598 if (sp[1] == '~') {599 sp += 2;600 *dp++ = '~';601 } else {602 ++sp;603 *dp++ = '\0';604 }605 } else {606 *dp++ = *sp++;607 }608 }609 610 *dp++ = '\0';611 *rbuf = buf;612 *endptr = dp;613 614 return EOK;615 }616 617 569 /** Compute UI text width. 618 570 * … … 664 616 665 617 /* Break down string into list of (non)highlighted parts */ 666 rc = ui_ text_process(str, &buf, &endptr);618 rc = ui_accel_process(str, &buf, &endptr); 667 619 if (rc != EOK) 668 620 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.