Added support of notepad2.

This commit is contained in:
Alexander Kislitsyn 2020-05-23 18:31:44 +03:00
parent 1116c4b54c
commit 690e6bd4c3
3 changed files with 25 additions and 1 deletions

View file

@ -98,6 +98,7 @@ namespace Notepad.Extensions.Logging
case WindowKind.Notepad:
SendMessage(info.Handle, EM_REPLACESEL, (IntPtr)1, message);
break;
case WindowKind.Notepad2:
case WindowKind.NotepadPlusPlus:
WriteToNotepadPlusPlus(info.Handle, message);
break;

View file

@ -44,6 +44,12 @@ namespace Notepad.Extensions.Logging
sb.Remove(0, 1);
}
if (sb.Length > 0 && sb[0] == ' ')
{
// Notepad2 added space after asterisk
sb.Remove(0, 1);
}
if (IsKnownNotepadWindow(sb.ToString()))
{
return false;
@ -60,13 +66,28 @@ namespace Notepad.Extensions.Logging
{
if (WindowName.Equals(titleText, StringComparison.Ordinal))
{
WindowKind = titleText.EndsWith(" - Notepad++", StringComparison.Ordinal) ? WindowKind.NotepadPlusPlus : WindowKind.Notepad;
if (titleText.EndsWith(" - Notepad++", StringComparison.Ordinal))
{
WindowKind = WindowKind.NotepadPlusPlus;
}
else if (titleText.EndsWith(" - Notepad2", StringComparison.Ordinal))
{
WindowKind = WindowKind.Notepad2;
}
else
{
WindowKind = WindowKind.Notepad;
}
}
}
else if (titleText.Equals("Untitled - Notepad", StringComparison.Ordinal))
{
WindowKind = WindowKind.Notepad;
}
else if (titleText.Equals("Untitled - Notepad2", StringComparison.Ordinal))
{
WindowKind = WindowKind.Notepad2;
}
else if (notepadPlusPlusRegex.IsMatch(titleText))
{
WindowKind = WindowKind.NotepadPlusPlus;
@ -83,6 +104,7 @@ namespace Notepad.Extensions.Logging
{
case WindowKind.Notepad:
return NativeMethods.FindWindowEx(Handle, IntPtr.Zero, "EDIT", null);
case WindowKind.Notepad2:
case WindowKind.NotepadPlusPlus:
return NativeMethods.FindWindowEx(Handle, IntPtr.Zero, "Scintilla", null);
default:

View file

@ -5,5 +5,6 @@
Invalid,
Notepad,
NotepadPlusPlus,
Notepad2,
}
}