您正在使用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);
}
答案 0 :(得分:1)
要突出显示所选文字,请使用
Win32.SendMessage(PluginBase.GetCurrentScintilla(),
SciMsg.SCI_SETSELBACK, 1, 0xFFFF00);