(text, styles) { let styledText = text; // RGB颜色 if (styles.color) { styledText = `\x1b[38;2;${styles.color[0]};${styles.color[1]};${styles.color[2]}m${styledText}\x1b[0m (styles.bold) { styledText = `\x1b[1m${styledText}\x1b[0m`; } // 斜体 if (styles.italic) { styledText = `\x1b[3m${styledText}\x1b[0m`; } // 下划线 if (styles.underline) { styledText = `\x1b[4m${styledText}\x1b[0m`; } // 返回带样式的文本
textBackgroundStyle({ color: this.linkBackgroundColor }) }}高性能知识点本示例使用了LazyForEach进行数据懒加载工程结构&模块类型 styledtext TextModel.ets // 数据类型定义 |---/src/main/ets/pages | |---StyledText.ets
document); sqlEditor.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); StyledText org.eclipse.jface.text.source.VerticalRuler; 30 import org.eclipse.swt.SWT; 31 import org.eclipse.swt.custom.StyledText 70 sqlEditor.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); 71 72 StyledText
( bulletSpan, 0, 4, Spanned.SPAN_INCLUSIVE_INCLUSIVE) styledText.setText bulletSpan.color = Color.GRAY // color won’t be changed until invalidate is called styledText.invalidate
( bulletSpan, 0, 4, Spanned.SPAN_INCLUSIVE_INCLUSIVE) styledText.setText bulletSpan.color = Color.GRAY // color won’t be changed until invalidate is called styledText.invalidate
String text = String.format(res.getString(R.string.welcome_messages), username, mailCount); CharSequence styledText
当 textFormat 设置为 AutoText 时,自动转换为 StyledText 而不是 RichText, TextEdit – textFormat 属性的默认值为 PlainText 而不是