Skip to content

Instantly share code, notes, and snippets.

@timsneath
Created September 22, 2020 03:23
Show Gist options
  • Select an option

  • Save timsneath/a9fcd1f71586a834c91fd92ac05b2d3f to your computer and use it in GitHub Desktop.

Select an option

Save timsneath/a9fcd1f71586a834c91fd92ac05b2d3f to your computer and use it in GitHub Desktop.
// C signature for Win32 API in kernel32.dll:
// BOOL WINAPI SetConsoleCursorPosition(
// _In_ HANDLE hConsoleOutput,
// _In_ COORD  dwCursorPosition
// );
typedef nativePrototype = Int32 Function(
IntPtr hConsoleOutput, Int32 dwCursorPos);
typedef dartPrototype = int Function(int hConsoleOutput, int dwCursorPos);
final kernel32 = DynamicLibrary.open('kernel32.dll');
final SetConsoleCursorPosition = kernel32
.lookupFunction<nativePrototype, dartPrototype>('SetConsoleCursorPosition');
// outputHandle is STDOUT (not shown here)
SetConsoleCursorPosition(outputHandle, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment