嗨,我正在使用 c# 做一个记事本 ++ 插件
我需要的是,以某种颜色显示给定行号之间的活动窗口。假设我有第 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);
}