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

ruby-changes:67302

From: aycabta <ko1@a...>
Date: Sun, 29 Aug 2021 20:30:42 +0900 (JST)
Subject: [ruby-changes:67302] d768eeeddb (master): [ruby/reline] Support hide/show cursor on Windows

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

From d768eeeddbcc59166e7669471e6b3672eeed230c Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Sun, 22 Aug 2021 01:47:07 +0900
Subject: [ruby/reline] Support hide/show cursor on Windows

https://github.com/ruby/reline/commit/0c870813bd
---
 lib/reline/windows.rb | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/reline/windows.rb b/lib/reline/windows.rb
index ae87b38..9e542aa 100644
--- a/lib/reline/windows.rb
+++ b/lib/reline/windows.rb
@@ -133,6 +133,7 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L133
   @@GetFileType = Win32API.new('kernel32', 'GetFileType', ['L'], 'L')
   @@GetFileInformationByHandleEx = Win32API.new('kernel32', 'GetFileInformationByHandleEx', ['L', 'I', 'P', 'L'], 'I')
   @@FillConsoleOutputAttribute = Win32API.new('kernel32', 'FillConsoleOutputAttribute', ['L', 'L', 'L', 'L', 'P'], 'L')
+  @@SetConsoleCursorInfo = Win32API.new('kernel32', 'SetConsoleCursorInfo', ['L', 'P'], 'L')
 
   @@GetConsoleMode = Win32API.new('kernel32', 'GetConsoleMode', ['L', 'P'], 'L')
   @@SetConsoleMode = Win32API.new('kernel32', 'SetConsoleMode', ['L', 'L'], 'L')
@@ -344,11 +345,17 @@ class Reline::Windows https://github.com/ruby/ruby/blob/trunk/lib/reline/windows.rb#L345
   end
 
   def self.hide_cursor
-    # ignored
+    size = 100
+    visible = 0 # 0 means false
+    cursor_info = [size, visible].pack('Li')
+    @@SetConsoleCursorInfo.call(@@hConsoleHandle, cursor_info)
   end
 
   def self.show_cursor
-    # ignored
+    size = 100
+    visible = 1 # 1 means true
+    cursor_info = [size, visible].pack('Li')
+    @@SetConsoleCursorInfo.call(@@hConsoleHandle, cursor_info)
   end
 
   def self.set_winch_handler(&handler)
-- 
cgit v1.1


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

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