類別 Reline::Windows::KeyEventRecord
屬性
char_code[R]
control_key_state[R]
control_keys[R]
virtual_key_code[R]
公開類別方法
new(virtual_key_code, char_code, control_key_state) 按一下以切換來源
# File lib/reline/windows.rb, line 467 def initialize(virtual_key_code, char_code, control_key_state) @virtual_key_code = virtual_key_code @char_code = char_code @control_key_state = control_key_state @enhanced = control_key_state & ENHANCED_KEY != 0 (@control_keys = []).tap do |control_keys| # symbols must be sorted to make comparison is easier later on control_keys << :ALT if control_key_state & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED) != 0 control_keys << :CTRL if control_key_state & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) != 0 control_keys << :SHIFT if control_key_state & SHIFT_PRESSED != 0 end.freeze end
公開執行個體方法
char() 按一下以切換來源
# File lib/reline/windows.rb, line 481 def char @char_code.chr(Encoding::UTF_8) end
enhanced?() 按一下以切換來源
# File lib/reline/windows.rb, line 485 def enhanced? @enhanced end
matches?(control_keys: nil, virtual_key_code: nil, char_code: nil) 按一下以切換來源
驗證引數是否與此鍵盤事件相符。忽略為 nil 的引數,但至少必須傳遞一個非 nil 引數。若要驗證未按下任何控制鍵,請傳遞一個空陣列:‘control_keys: []`。
# File lib/reline/windows.rb, line 492 def matches?(control_keys: nil, virtual_key_code: nil, char_code: nil) raise ArgumentError, 'No argument was passed to match key event' if control_keys.nil? && virtual_key_code.nil? && char_code.nil? (control_keys.nil? || [*control_keys].sort == @control_keys) && (virtual_key_code.nil? || @virtual_key_code == virtual_key_code) && (char_code.nil? || char_code == @char_code) end