【发布时间】:2017-01-05 03:15:52
【问题描述】:
您好,我正在使用 c# 做一个 notepad++ 插件
我需要的是,以某种颜色显示给定行号之间的活动窗口。假设我有第 2 行和第 8 行,那么它必须以绿色突出显示第 2 行和第 8 行之间的记事本++ 屏幕。
从活动窗口读取
int length = (int)Win32.SendMessage(GetCurrentScintilla(), SciMsg.SCI_GETLENGTH, 0, 0);
IntPtr ptrToText = Marshal.AllocHGlobal(length + 10);
Win32.SendMessage(GetCurrentScintilla(), SciMsg.SCI_GETTEXT, length+10, ptrToText);
String InputFromActiveWindow = Marshal.PtrToStringAnsi(ptrToText);
聚焦选定行的代码
Win32.SendMessage(curScintilla, SciMsg.SCI_ENSUREVISIBLE, lineNumber, 0);
Win32.SendMessage(curScintilla, SciMsg.SCI_GOTOLINE, lineNumber, 0);
Win32.SendMessage(curScintilla, SciMsg.SCI_GRABFOCUS, 0, 0);
Win32.SendMessage(curScintilla, SciMsg.SCI_GRABFOCUS, 0, 0);
//答案是
win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERDEFINE, 1, (int)SciMsg.SC_MARK_BACKGROUND);
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERSETBACK, 1, 0x99FF00);
for (int linetobeHighlighted = StartLine; linetobeHighlighted <= EndLine; linetobeHighlighted++)
{
Win32.SendMessage(PluginBase.nppData._scintillaMainHandle, SciMsg.SCI_MARKERADD, linetobeHighlighted, 1);
}
【问题讨论】:
-
请分享您的尝试?
-
我实际上不知道该尝试什么。到目前为止我尝试的是从活动窗口读取。并在给出行号时转到特定行。用于从活动窗口读取的代码
-
@Richa Garg 我已将代码附加到问题中
标签: c# notepad++ programmers-notepad