[前][次][番号順一覧][スレッド一覧]

ruby-changes:67304

From: usa <ko1@a...>
Date: Sun, 29 Aug 2021 20:30:43 +0900 (JST)
Subject: [ruby-changes:67304] 788c047695 (master): [ruby/reline] Create windows.rb

https://git.ruby-lang.org/ruby.git/commit/?id=788c047695

From 788c0476958fff3b73c3e771d14822512d6b386a Mon Sep 17 00:00:00 2001
From: usa <usa@g...>
Date: Fri, 20 Aug 2021 23:40:42 +0900
Subject: [ruby/reline] Create windows.rb

see issue #317

https://github.com/ruby/reline/commit/aad164de93
---
 lib/reline/windows.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb
index 520ac59..8665f3b 100644
--- a/lib/reline/windows.rb
+++ b/lib/reline/windows.rb
@@ -136,6 +136,7 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L136
 
   @@GetConsoleMode = Win32API.new('kernel32', 'GetConsoleMode', ['L', 'P'], 'L')
   @@SetConsoleMode = Win32API.new('kernel32', 'SetConsoleMode', ['L', 'L'], 'L')
+  @@WaitForSingleObject = Win32API.new('kernel32', 'WaitForSingleObject', ['L', 'L'], 'L')
   ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
 
   private_class_method def self.getconsolemode
@@ -218,7 +219,7 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L219
   def self.check_input_event
     num_of_events = 0.chr * 8
     while @@output_buf.empty? #or true
-      sleep 0.01
+      next if @@WaitForSingleObject.(@@hConsoleInputHandle, 100) != 0 # max 0.1 sec
       next if @@GetNumberOfConsoleInputEvents.(@@hConsoleInputHandle, num_of_events) == 0 or num_of_events.unpack('L').first == 0
       input_record = 0.chr * 18
       read_event = 0.chr * 4
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]