2797 qt terminal on windows における標準入力 |
現在の qt terminal on windows は,標準入力を読めない ようです。こちらでは,いつまでも入力を待って, サーバ gnuplot_qt.exe が実行されません。 以下のように,qt_term.cpp における関数 int qt_waitforinput(int options) を wxt_gui.cpp におけるもので置き換えると, qt terminal on windows でも パイプを使うことが でき, gnuplot <test.plt がちゃんと動作します。 しかし,他の場面で困ることが生じますので,これは 採用しないでください。バグがどこにあるかがわかる だけです。つまり, int qt_waitforinput(int options) における windows に関する部分を書き換える必要が あります。この関数は複雑なので,識者に訂正して もらいたいと思います。 ---------------------------- このパッチは採用しないこと ---------------------------- --- qt_term.cpp.origWed Jun 11 07:28:20 2014 +++ qt_term.cppFri Jun 13 14:55:20 2014 @@ -1020,158 +1020,26 @@ } while (paused_for_mouse || !FD_ISSET(stdin_fd, &read_fds)); return getchar(); #else // Windows console and wgnuplot -#ifdef WGP_CONSOLE -int fd = fileno(stdin); -#endif -HANDLE h[2];// list of handles to wait for -DWORD idx = 0;// count of handles to wait for and current index -DWORD idx_stdin = -1;// return value MsgWaitForMultipleObjects for stdin -DWORD idx_socket = -1;// return value MsgWaitForMultipleObjects for the Qt socket -DWORD idx_msg = -1;// return value MsgWaitForMultipleObjects for message queue events -int c = NUL; -bool waitOK = true; -bool quitLoop = false; -#if 0 // Maybe not necessary after all? -static int nrConcurrentCalls = 0; -ScopeCounter scopeCounter(nrConcurrentCalls); - -// avoid recursion when check_for_mouse_events() is called as a result of a -// keypress sent from Qt -if ((nrConcurrentCalls > 1) && (options == TERM_ONLY_CHECK_MOUSING)) +if (options == TERM_ONLY_CHECK_MOUSING) { +WinMessageLoop(); return NUL; -#endif -#ifndef WGP_CONSOLE -if (options != TERM_ONLY_CHECK_MOUSING) -TextStartEditing(&textwin); -#endif - -// stdin or console -if (options != TERM_ONLY_CHECK_MOUSING) { // NOTE: change this if used also for the caca terminal -#ifdef WGP_CONSOLE -if (!isatty(fd)) -h[0] = CreateThread(NULL, 0, stdin_pipe_reader, NULL, 0, NULL); -else -#endif -h[0] = GetStdHandle(STD_INPUT_HANDLE); -if (h[0] != NULL) -idx_stdin = WAIT_OBJECT_0 + idx++; -} - -// Named pipe of QLocalSocket -if (qt != NULL) { -h[idx] = (HANDLE) qt->socket.socketDescriptor(); -DWORD flags; -if (GetHandleInformation(h[idx], &flags) == 0) -fprintf(stderr, "Error: QtLocalSocket handle is invalid\n"); -else -idx_socket = WAIT_OBJECT_0 + idx++; -} - -// Windows Messages -idx_msg = WAIT_OBJECT_0 + idx; // do not increment count - -// Process any pending message queue events -WinMessageLoop(); - -do { -DWORD waitResult = -1; - -#ifndef WGP_CONSOLE -// Process pending key events of the text console -if (kbhit() && (options != TERM_ONLY_CHECK_MOUSING)) -waitResult = idx_msg; -#endif - -// Process pending qt events -if ((idx_socket != -1) && // (qt != NULL)) && -(qt->socket.waitForReadyRead(0)) && (qt->socket.bytesAvailable() >= (int)sizeof(gp_event_t))) -waitResult = idx_socket; // data already available - -// Wait for a new event -if ((waitResult == -1) && (options != TERM_ONLY_CHECK_MOUSING)) -waitResult = MsgWaitForMultipleObjects(idx, h, FALSE, INFINITE, QS_ALLINPUT); // wait for new data - -if ((waitResult == idx_stdin) && (idx_stdin != -1)) { // console windows or caca terminal (TBD) -#ifdef WGP_CONSOLE -if (!isatty(fd)) { -DWORD dw; -GetExitCodeThread(h, &dw); -CloseHandle(h); -c = dw; -quitLoop = true; -} else -#endif -{ -c = ConsoleReadCh(); -if (c != NUL) -quitLoop = true; -// Otherwise, this wasn't a key down event and we cycle again -} - -} else if ((waitResult == idx_socket) && (idx_socket != -1)) { // qt terminal -qt->socket.waitForReadyRead(0); -// Temporary event for mouse move events. If several consecutive move events -// are received, only transmit the last one. -gp_event_t tempEvent; -tempEvent.type = -1; -while (qt->socket.bytesAvailable() >= (int)sizeof(gp_event_t)) { -struct gp_event_t event; -qt->socket.read((char*) &event, sizeof(gp_event_t)); -// Delay move events -if (event.type == GE_motion) -tempEvent = event; -// Other events. Replay the last move event if present -else { -if (tempEvent.type == GE_motion) { -qt_processTermEvent(&tempEvent); -tempEvent.type = -1; -} -if (qt_processTermEvent(&event)) { -c = NUL; // exit from paused_for_mouse -quitLoop = true; -} -} -} -// Replay move event -if (tempEvent.type == GE_motion) -qt_processTermEvent(&tempEvent); - -} else if (waitResult == idx_msg) {// Text window, windows and wxt terminals -// process windows message queue events -WinMessageLoop(); -if (options == TERM_ONLY_CHECK_MOUSING) { -quitLoop = true; -} else { -#ifdef WGP_CONSOLE -if (ctrlc_flag) { -c = '\r'; -quitLoop = true; -} -#else -// get key from text window if available -if (kbhit()) { -c = getchar(); -quitLoop = true; -} -#endif -} - -} else { // Time-out or Error -waitOK = false; -quitLoop = true; +} else if (paused_for_mouse) { +MSG msg; +BOOL ret; + +/* wait for next event */ +while ((ret = GetMessage(&msg, NULL, 0, 0)) != 0) { +if (ret == -1) +break; +TranslateMessage(&msg); +DispatchMessage(&msg); +if (!paused_for_mouse) +break; } -} while (!quitLoop); - +return NUL; +} else +return getch(); -#ifndef WGP_CONSOLE -if (options != TERM_ONLY_CHECK_MOUSING) -TextStopEditing(&textwin); - -// This happens if neither the qt queue is alive, nor there is a console window. -if ((options != TERM_ONLY_CHECK_MOUSING) && !waitOK) -return getchar(); -#endif -return c; #endif // WIN32 #else return getchar();
〔ツリー構成〕
【2797】 qt terminal on windows における標準入力 2014/6/13(金)15:26 kakuto (5549) |
┣【2798】 re(1):qt terminal on windows における標準入力 2014/6/13(金)17:51 松岡 (368) |
┣【2799】 re(2):qt terminal on windows における標準入力 2014/6/14(土)07:25 kakuto (568) |
┣【2800】 re(3):qt terminal on windows における標準入力 2014/6/14(土)09:14 kakuto (107) |
┣【2801】 re(4):qt terminal on windows における標準入力 2014/6/14(土)10:57 松岡 (305) |
※ 『クリックポイント』とは一覧上から読み始めた地点を指し、ツリー上の記事を巡回しても、その位置に戻ることができます.