aardio给富文本编辑器richedit设置每行颜色

admin2022-01-19  5.3K+

//aardio给富文本编辑器richedit设置每行颜色
import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=759;bottom=469)
winform.add(
button={cls="button";text="Button";left=198;top=30;right=461;bottom=70;z=1};
richedit={cls="richedit";text="RichEdit";left=67;top=106;right=704;bottom=419;edge=1;multiline=1;z=2}
)
/*}}*/

var ctb = {0xFF0000;0x00FF00;0x0000FF}

winform.button.oncommand = function(id,event) {
	winform.richedit.print(string.random("红色", "绿色", "蓝色"));
	//不会实时保存颜色,只能用循环将每行颜色设置一遍
	for (i = 1; winform.richedit.lineCount; 1) {
		var str = winform.richedit.lineText(i)
		winform.richedit.lineSel(i)
		//添加并设置颜色
		select(false) {
			case !string.indexOf(str, "红色") {
				winform.richedit.setSelCharformat(textColor = ctb[3])
			}
			case !string.indexOf(str, "绿色"){
				winform.richedit.setSelCharformat(textColor=ctb[2])
			}
			case !string.indexOf(str, "蓝色") {
				winform.richedit.setSelCharformat( textColor=ctb[1])
			}
		}
	}
}



winform.show();
win.loopMessage();
转载请注明原文地址: http://aardio.net/read-297.html
最新回复(0)
aardio问答
aardio编程语言