mirror of https://github.com/adamdruppe/arsd.git
few little improvements for better Windows terminal emulator
This commit is contained in:
parent
2a0d6aeb15
commit
fed1788981
|
@ -177,6 +177,8 @@ extern(C) {
|
||||||
uint username_len);
|
uint username_len);
|
||||||
|
|
||||||
int libssh2_channel_eof(LIBSSH2_CHANNEL*);
|
int libssh2_channel_eof(LIBSSH2_CHANNEL*);
|
||||||
|
int libssh2_channel_close(LIBSSH2_CHANNEL*);
|
||||||
|
int libssh2_channel_wait_closed(LIBSSH2_CHANNEL *channel);
|
||||||
|
|
||||||
enum LIBSSH2_ERROR_EAGAIN = -37;
|
enum LIBSSH2_ERROR_EAGAIN = -37;
|
||||||
}
|
}
|
||||||
|
|
|
@ -811,7 +811,7 @@ class SimpleWindow : CapableOfHandlingNativeEvent {
|
||||||
/// The event loop automatically returns when the window is closed
|
/// The event loop automatically returns when the window is closed
|
||||||
/// pulseTimeout is given in milliseconds.
|
/// pulseTimeout is given in milliseconds.
|
||||||
final int eventLoop(T...)(
|
final int eventLoop(T...)(
|
||||||
long pulseTimeout, /// set to zero if you don't want a pulse. Note: don't set it too big, or user input may not be processed in a timely manner. I suggest something < 150.
|
long pulseTimeout, /// set to zero if you don't want a pulse.
|
||||||
T eventHandlers) /// delegate list like std.concurrency.receive
|
T eventHandlers) /// delegate list like std.concurrency.receive
|
||||||
{
|
{
|
||||||
setEventHandlers(eventHandlers);
|
setEventHandlers(eventHandlers);
|
||||||
|
@ -3640,7 +3640,7 @@ version(Windows) {
|
||||||
|
|
||||||
int eventLoop(long pulseTimeout) {
|
int eventLoop(long pulseTimeout) {
|
||||||
MSG message;
|
MSG message;
|
||||||
int ret;
|
int ret = -1;
|
||||||
|
|
||||||
Timer pulser;
|
Timer pulser;
|
||||||
scope(exit)
|
scope(exit)
|
||||||
|
@ -3650,19 +3650,39 @@ version(Windows) {
|
||||||
if(pulseTimeout)
|
if(pulseTimeout)
|
||||||
pulser = new Timer(cast(int) pulseTimeout, handlePulse);
|
pulser = new Timer(cast(int) pulseTimeout, handlePulse);
|
||||||
|
|
||||||
// if(PeekMessage(&message, null, 0, 0, PM_NOREMOVE))
|
HANDLE[] handles;
|
||||||
while((ret = GetMessage(&message, null, 0, 0)) != 0) {
|
while(ret != 0) {
|
||||||
if(ret == -1)
|
auto waitResult = MsgWaitForMultipleObjectsEx(
|
||||||
throw new Exception("GetMessage failed");
|
handles.length, handles.ptr,
|
||||||
// if(!IsDialogMessageA(message.hwnd, &message)) {
|
INFINITE, /* timeout */
|
||||||
TranslateMessage(&message);
|
0x04FF, /* QS_ALLINPUT */
|
||||||
DispatchMessage(&message);
|
0x0002 /* MWMO_ALERTABLE */ | 0x0004 /* MWMO_INPUTAVAILABLE */);
|
||||||
// }
|
|
||||||
|
|
||||||
SleepEx(0, true); // I call this to give it a chance to do stuff like async io, which never happens when you just block in GetMessage
|
enum WAIT_OBJECT_0 = 0;
|
||||||
|
if(waitResult >= WAIT_OBJECT_0 && waitResult < handles.length + WAIT_OBJECT_0) {
|
||||||
|
// process handles[waitResult - WAIT_OBJECT_0];
|
||||||
|
} else if(waitResult == handles.length + WAIT_OBJECT_0) {
|
||||||
|
// message ready
|
||||||
|
if((ret = GetMessage(&message, null, 0, 0)) != 0) {
|
||||||
|
if(ret == -1)
|
||||||
|
throw new Exception("GetMessage failed");
|
||||||
|
TranslateMessage(&message);
|
||||||
|
DispatchMessage(&message);
|
||||||
|
}
|
||||||
|
} else if(waitResult == 0x000000C0L /* WAIT_IO_COMPLETION */) {
|
||||||
|
SleepEx(0, true); // I call this to give it a chance to do stuff like async io
|
||||||
|
} else if(waitResult == 258L /* WAIT_TIMEOUT */) {
|
||||||
|
// timeout, should never happen since we aren't using it
|
||||||
|
} else if(waitResult == 0xFFFFFFFF) {
|
||||||
|
// failed
|
||||||
|
throw new Exception("MsgWaitForMultipleObjectsEx failed");
|
||||||
|
} else {
|
||||||
|
// idk....
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return message.wParam;
|
// return message.wParam;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5173,6 +5193,16 @@ nothrow:
|
||||||
enum KEYEVENTF_KEYUP = 0x2;
|
enum KEYEVENTF_KEYUP = 0x2;
|
||||||
enum KEYEVENTF_SCANCODE = 0x8;
|
enum KEYEVENTF_SCANCODE = 0x8;
|
||||||
enum KEYEVENTF_UNICODE = 0x4;
|
enum KEYEVENTF_UNICODE = 0x4;
|
||||||
|
|
||||||
|
extern(Windows)
|
||||||
|
DWORD MsgWaitForMultipleObjectsEx(
|
||||||
|
in DWORD nCount,
|
||||||
|
in HANDLE *pHandles,
|
||||||
|
in DWORD dwMilliseconds,
|
||||||
|
in DWORD dwWakeMask,
|
||||||
|
in DWORD dwFlags
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else version(X11) {
|
else version(X11) {
|
||||||
|
|
Loading…
Reference in New Issue