BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lvgl
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
lvgl
Commits
9cefda4f
Commit
9cefda4f
authored
Sep 03, 2017
by
Gabor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lv_label: lv_label_append_text() renamed and upgraded to lv_label_ins_text()
parent
99dbf359
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
12 deletions
+33
-12
lv_label.c
lv_objx/lv_label.c
+22
-7
lv_label.h
lv_objx/lv_label.h
+11
-5
No files found.
lv_objx/lv_label.c
View file @
9cefda4f
...
...
@@ -238,11 +238,16 @@ void lv_label_set_text_static(lv_obj_t * label, const char * text)
}
/**
*
Append
a text to the label. The label current label text can not be static.
*
Insert
a text to the label. The label current label text can not be static.
* @param label pointer to label object
* @param text pointe rto the new text
* @param pos character index to insert
* 0: before first char.
* LV_LABEL_POS_LAST: after last char.
* < 0: count from the end
* -1: before the last char.
* @param txt pointer to the text to insert
*/
void
lv_label_
append_text
(
lv_obj_t
*
label
,
const
char
*
te
xt
)
void
lv_label_
ins_text
(
lv_obj_t
*
label
,
int32_t
pos
,
const
char
*
t
xt
)
{
lv_label_ext_t
*
ext
=
lv_obj_get_ext
(
label
);
...
...
@@ -253,11 +258,21 @@ void lv_label_append_text(lv_obj_t * label, const char * text)
/*Allocate space for the new text*/
uint32_t
old_len
=
strlen
(
ext
->
txt
);
uint32_t
app_len
=
strlen
(
te
xt
);
uint32_t
new_len
=
app
_len
+
old_len
;
uint32_t
ins_len
=
strlen
(
t
xt
);
uint32_t
new_len
=
ins
_len
+
old_len
;
ext
->
txt
=
dm_realloc
(
ext
->
txt
,
new_len
+
1
);
memcpy
(
ext
->
txt
+
old_len
,
text
,
app_len
);
ext
->
txt
[
new_len
]
=
'\0'
;
if
(
pos
==
LV_LABEL_POS_LAST
)
pos
=
old_len
;
else
if
(
pos
<
0
)
pos
=
old_len
+
pos
;
/*Copy the second part into the end to make place to text to insert*/
int32_t
i
;
for
(
i
=
new_len
;
i
>=
pos
+
ins_len
;
i
--
){
ext
->
txt
[
i
]
=
ext
->
txt
[
i
-
ins_len
];
}
/* Copy the text into the new space*/
memcpy
(
ext
->
txt
+
pos
,
txt
,
ins_len
);
lv_label_refr_text
(
label
);
}
...
...
lv_objx/lv_label.h
View file @
9cefda4f
...
...
@@ -19,12 +19,13 @@ extern "C" {
#include "../lv_obj/lv_obj.h"
#include "misc/gfx/font.h"
#include "misc/gfx/text.h"
#include "misc/gfx/fonts/symbol_def.h"
/*********************
* DEFINES
*********************/
#define LV_LABEL_DOT_NUM 3
#define LV_LABEL_POS_LAST 0xFFFF
/**********************
* TYPEDEFS
**********************/
...
...
@@ -100,11 +101,16 @@ void lv_label_set_text_array(lv_obj_t * label, const char * array, uint16_t size
void
lv_label_set_text_static
(
lv_obj_t
*
label
,
const
char
*
text
);
/**
*
Append
a text to the label. The label current label text can not be static.
*
Insert
a text to the label. The label current label text can not be static.
* @param label pointer to label object
* @param text pointe rto the new text
*/
void
lv_label_append_text
(
lv_obj_t
*
label
,
const
char
*
text
);
* @param pos character index to insert
* 0: before first char.
* LV_LABEL_POS_LAST: after last char.
* < 0: count from the end
* -1: before the last char.
* @param txt pointer to the text to insert
*/
void
lv_label_ins_text
(
lv_obj_t
*
label
,
int32_t
pos
,
const
char
*
txt
);
/**
* Set the behavior of the label with longer text then the object size
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment