Skip to content

Commit

Permalink
Added USE_IOCTL definition for toggle.
Browse files Browse the repository at this point in the history
  • Loading branch information
BDisp committed Nov 2, 2023
1 parent bfa76a2 commit 2411b8a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Terminal.Gui/ConsoleDrivers/CursesDriver/binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,26 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

//#define USE_IOCTL

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

public partial class Curses {
#if USE_IOCTL

[StructLayout (LayoutKind.Sequential)]
public struct winsize {
public ushort ws_row;
public ushort ws_col;
public ushort ws_xpixel; /* unused */
public ushort ws_ypixel; /* unused */
};

#endif
[StructLayout (LayoutKind.Sequential)]
public struct MouseEvent {
public short ID;
Expand All @@ -77,10 +81,11 @@ public struct MouseEvent {

[DllImport ("libc")]
public extern static int setlocale (int cate, [MarshalAs (UnmanagedType.LPStr)] string locale);
#if USE_IOCTL

[DllImport ("libc")]
public extern static int ioctl (int fd, int cmd, out winsize argp);

#endif
static void LoadMethods ()
{
var libs = UnmanagedLibrary.IsMacOSPlatform ? new string [] { "libncurses.dylib" } : new string [] { "libncursesw.so.6", "libncursesw.so.5" };
Expand Down Expand Up @@ -227,6 +232,8 @@ internal static IntPtr console_sharp_get_curscr ()

internal static void console_sharp_get_dims (out int lines, out int cols)
{
#if USE_IOCTL

if (UnmanagedLibrary.IsMacOSPlatform) {
int cmd = TIOCGWINSZ_MAC;

Expand All @@ -247,7 +254,10 @@ internal static void console_sharp_get_dims (out int lines, out int cols)
lines = Marshal.ReadInt32 (lines_ptr);
cols = Marshal.ReadInt32 (cols_ptr);
}

#else
lines = Marshal.ReadInt32 (lines_ptr);
cols = Marshal.ReadInt32 (cols_ptr);
#endif
//int cmd;
//if (UnmanagedLibrary.IsMacOSPlatform) {
// cmd = TIOCGWINSZ_MAC;
Expand Down

0 comments on commit 2411b8a

Please sign in to comment.