diff --git a/CsvQuery/Main.cs b/CsvQuery/Main.cs index b5596dd..e7e64f1 100644 --- a/CsvQuery/Main.cs +++ b/CsvQuery/Main.cs @@ -155,7 +155,7 @@ private static void ParseWithManualSettings() public static void SetToolBarIcon() { - if (NotepadPPGateway.GetNppMajorVersion() < 8) + if (LegacyCheck.OldIconCode) { // Old way - for backwards compatibility to Npp before 8.0 var icons = new toolbarIcons { hToolbarBmp = Resources.cq.GetHbitmap() }; diff --git a/CsvQuery/PluginInfrastructure/GatewayDomain.cs b/CsvQuery/PluginInfrastructure/GatewayDomain.cs index ecbac0c..4371a02 100644 --- a/CsvQuery/PluginInfrastructure/GatewayDomain.cs +++ b/CsvQuery/PluginInfrastructure/GatewayDomain.cs @@ -6,6 +6,44 @@ namespace CsvQuery.PluginInfrastructure { + public static class LegacyCheck + { + private static int _version = -1; + private static int _majorVersion = -1; + private static int _minorVersion = -1; + + + private static void Init() + { + int Unused = 0; + _version = Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETNPPVERSION, Unused, Unused).ToInt32(); + _majorVersion = _version >> 16; + + // Minor version is stored really strange in Npp, e.g. 8.1 has lower bits = 1, but 8.1.9.3 has lower bits = 193 + var minorBits = _version & 0xffff; + var firstDigit = minorBits.ToString().Substring(0,1); + if (!int.TryParse(firstDigit, out _version)) _minorVersion = -1; + } + + public static bool OldIconCode + { + get + { + if(_version==-1)Init(); + return _majorVersion < 8; + } + } + + public static bool Old64BitScintilla + { + get + { + if (_version == -1) Init(); + return (_majorVersion < 8) || (_majorVersion == 8 && _minorVersion < 3); + } + } + } + /// /// Colours are set using the RGB format (Red, Green, Blue). The intensity of each colour is set in the range 0 to 255. /// If you have three such intensities, they are combined as: red | (green << 8) | (blue << 16). @@ -180,6 +218,16 @@ public struct CharacterRange public IntPtr cpMax; } + /// + /// This is used before N++ 8.3 + /// + [StructLayout(LayoutKind.Sequential)] + public struct CharacterRangeLegacy + { + public int cpMin; + public int cpMax; + } + public class Cells { public Cells(char[] charactersAndStyles)