Merge pull request #6 from 4lexKislitsyn/dev/notepad2

Added support of notepad2.
This commit is contained in:
Yaakov 2020-05-24 15:17:47 +10:00 committed by GitHub
commit 74b9d0bd1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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,
}
}