0

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).

McGuireV10
  • 9,572
  • 5
  • 48
  • 64

1 Answers1

0

The Windows console-driver (which is all those binaries support) doesn't use escape sequences. By the way, you can enable tracing by setting the NCURSES_TRACE environment variable.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • An answer from The Man Himself! Does the Windows console support continuous mouse pointer position reporting? If so, what does it take to enable it? I ran my test with `TRACE_MAXIMUM` which was interesting (especially handy to see the whole buffer dumped on refreshes, man I could have put _that_ to good use for debugging in the old days), but no answers jumped out at me. – McGuireV10 Aug 28 '18 at 11:08
  • No - the console support is only looking for button events, though reading the [documentation](https://learn.microsoft.com/en-us/windows/console/mouse-event-record-str), I don't see anything that would prevent implementing motion-events. – Thomas Dickey Aug 28 '18 at 23:49