Having trouble with continuously reading the mouse position from a a simple c# wrapper around Thomas Dickey's Windows build of ncurses here, I can call most of the API without any issues.
However, I can't read the mouse position except when there is a corresponding click event. My code is highly implementation-specific but the main loop of my quick-and-dirty test app looks like this (obviously NC
is my wrapper with many static methods):
var eventMask =
NCMouse.BUTTON1_CLICKED |
NCMouse.BUTTON2_CLICKED |
NCMouse.REPORT_MOUSE_POSITION;
NC.MouseMask(eventMask, out uint old);
while(true)
{
int c = NC.GetChar();
if(c == NCKey.MOUSE)
{
NC.GetMouse(out MouseEvent mouse);
NC.MoveAddString(3, 0, $"{mouse.x}. {mouse.y}");
}
else
if (c != -1)
{
break;
}
NC.Move(NC.Lines - 1, NC.Columns - 1);
NC.Refresh();
}
From reading about *nix solutions, I suspect I may need some sort of environment variable, although I've also seen comments from C devs saying they had to printf("\0cc[?1003h\n")
to enable mouse position reporting, then disable it before exit with a similar sequence. I suppose I'd have to pinvoke to an msvcrt DLL to try that (I didn't expect .NET's Console.Write
to work, and it didn't).