-1

こんにちは、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);
            }
4

1 に答える 1

1

選択したテキストを強調表示するには、使用します

Win32.SendMessage(PluginBase.GetCurrentScintilla(),
              SciMsg.SCI_SETSELBACK, 1, 0xFFFF00);

詳細については、Notepad++ プラグイン - テキストの検索と強調表示を参照してください。

于 2016-08-29T08:46:33.697 に答える