Merge pull request #2850 from BDisp/v2_opensuse-fix_415

Fixes #415 v2. Colors: OpenSUSE - The native method "COLOR_PAIRS" does not exist
This commit is contained in:
Tig
2023-09-29 11:20:34 -06:00
committed by GitHub
5 changed files with 84 additions and 4 deletions

View File

@@ -43,6 +43,7 @@
//
using System;
using System.Runtime.InteropServices;
using Terminal.Gui;
namespace Unix.Terminal {
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
@@ -83,8 +84,25 @@ namespace Unix.Terminal {
static void LoadMethods ()
{
var libs = UnmanagedLibrary.IsMacOSPlatform ? new string [] { "libncurses.dylib" } : new string [] { "libncursesw.so.6", "libncursesw.so.5" };
curses_library = new UnmanagedLibrary (libs, false);
methods = new NativeMethods (curses_library);
var attempts = 1;
while (true) {
try {
curses_library = new UnmanagedLibrary (libs, false);
methods = new NativeMethods (curses_library);
break;
} catch (Exception ex) {
if (attempts == 1) {
attempts++;
var (exitCode, result) = ClipboardProcessRunner.Bash ("cat /etc/os-release", waitForOutput: true);
if (exitCode == 0 && result.Contains ("opensuse")) {
libs [0] = "libncursesw.so.5";
}
} else {
throw ex.GetBaseException ();
}
}
}
}
static void FindNCurses ()