<commit_before># Include the gem library
require 'net/vnc'

# Monkey patch the vnc
require 'net/vnc/vnc.rb'

module Veewee
  module Provider
    module Core
      module BoxCommand

      def vnc_type(sequence,host,display=20)
        counter=0
        env.logger.info "Opening VNC #{host} on display #{display}"
        vnc=Net::VNC.open("#{host}:#{display}",{:wait => 0.001})
        sequence.each { |s|
          counter=counter+1

          env.ui.info "Typing:[#{counter}]: "+s

          keycodes=string_to_vnccode(s)

            keycodes.each do |keycode|
              if keycode==:wait
                sleep 1
              else
                send_vnc_keycode(vnc,keycode)
              end
            end
        }
        vnc.close
        env.ui.info "Done typing."
        env.ui.info ""

      end

      def send_vnc_keycode(vnc,keycode)

        if keycode.is_a?(Symbol)
          vnc.key_press keycode
          sleep 0.1
        else
            vnc.type_string keycode,{:wait => 0.001}
        end

      end


      def string_to_vnccode(thestring)

        # http://code.google.com/p/ruby-vnc/source/browse/trunk/data/keys.yaml<commit_msg>increased wait times for vnc again, otherwise some chars send got lost<commit_after># Include the gem library
require 'net/vnc'

# Monkey patch the vnc
require 'net/vnc/vnc.rb'

module Veewee
  module Provider
    module Core
      module BoxCommand

      def vnc_type(sequence,host,display=20)
        counter=0
        env.logger.info "Opening VNC #{host} on display #{display}"
        vnc=Net::VNC.open("#{host}:#{display}",{:wait => 0.001})
        sequence.each { |s|
          counter=counter+1

          env.ui.info "Typing:[#{counter}]: "+s

          keycodes=string_to_vnccode(s)

            keycodes.each do |keycode|
              if keycode==:wait
                sleep 1
              else
                send_vnc_keycode(vnc,keycode)
              end
            end
        }
        vnc.close
        env.ui.info "Done typing."
        env.ui.info ""

      end

      def send_vnc_keycode(vnc,keycode)

        if keycode.is_a?(Symbol)
          vnc.key_press keycode
          sleep 1
        else
            vnc.type_string keycode,{:wait => 0.1}
        end

      end


      def string_to_vnccode(thestring)

        # http://code.google.com/p/ruby-vnc/source/browse/trunk/data/keys.yaml
{'fraction_non_alphanumeric': 0.10583788324233516, 'fraction_numerical': 0.01133977320453591, 'mean_word_length': 1.753757225433526, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6120241', 'n_tokens_mistral': 821, 'n_tokens_neox': 766, 'n_words': 158}