【发布时间】:2010-04-25 12:43:22
【问题描述】:
我知道很多人问其中一些是如何完成的,但我不明白使用答案的上下文,所以...
我正在为 Python 语言的颠覆构建一个代码编辑器,我发现了一种非常体面的方法来突出显示 RichTextBox 中的关键字:
bluwords.Add(KEYWORDS GO HERE)
If scriptt.Text.Length > 0 Then
Dim selectStart2 As Integer = scriptt.SelectionStart
scriptt.Select(0, scriptt.Text.Length)
scriptt.SelectionColor = Color.Black
scriptt.DeselectAll()
For Each oneWord As String In bluwords
Dim pos As Integer = 0
Do While scriptt.Text.ToUpper.IndexOf(oneWord.ToUpper, pos) >= 0
pos = scriptt.Text.ToUpper.IndexOf(oneWord.ToUpper, pos)
scriptt.Select(pos, oneWord.Length)
scriptt.SelectionColor = Color.Blue
pos += 1
Loop
Next
scriptt.SelectionStart = selectStart2
End If
(脚本是富文本框) 但是,当键入(或通过 OpenFileDialog 加载)任何相当数量的代码时,代码块会丢失,语法选择就会崩溃,它只会破坏它。 我正在寻找一种更有效的方法,也许更像是视觉工作室本身......因为不需要突出显示所有文本,将其设置为黑色,然后重做所有语法,文本开始结束- 如果您返回在文本之间插入字符,则正确。 此外,在此版本的 Python 中,哈希 (#) 用于仅注释行上的 cmets,双哈希 (##) 用于同一行上的 cmets。 现在我看到有人问过这个确切的事情,选择到行尾的工作答案是这样的:^\'[^\r\n]+$|''[^\r\n] +$ 我似乎无法付诸实践。 我还想选择引号之间的文本并将其变为青绿色,例如在第一个引号和第二个引号之间,文本是青绿色,而在第三和第四个之间也是如此……
感谢任何帮助!
【问题讨论】:
标签: vb.net syntax-highlighting