on pressing ENTER we send user some info, the calling program
 would bind :PRESS
--
 FIXME we can create this once and reuse
++
197591
def fire_action_event
      return if @list.nil? || @list.size == 0
      require 'canis/core/include/ractionevent'
      aev = TextActionEvent.new self, :PRESS, current_value().to_s, @current_index, @curpos
      fire_handler :PRESS, aev
    end
900040
def handle_input(self, ncode, wparam, lparam):
        """"""
        x_pos = lparam.contents.x_pos
        y_pos = lparam.contents.y_pos
        data = lparam.contents.mousedata

        # This is how we can distinguish mouse 1 from mouse 2
        # extrainfo = lparam.contents.extrainfo
        # The way windows seems to do it is there is primary mouse
        # and all other mouses report as mouse 2

        # Also useful later will be to support the flags field
        # flags = lparam.contents.flags
        # This shows if the event was from a real device or whether it
        # was injected somehow via software

        self.emulate_mouse(wparam, x_pos, y_pos, data)

        # Give back control to Windows to wait for and process the
        # next event
        return ctypes.windll.user32.CallNextHookEx(
            self.hooked, ncode, wparam, lparam)
818795
def onKeyPressInCanvas(self, event):
        ''''''
        char_map = { 'w':'move 1', 'a':'strafe -1', 's':'move -1', 'd':'strafe 1', ' ':'jump 1' }
        keysym_map = { 'continuous': { 'Left':'turn -1', 'Right':'turn 1', 'Up':'pitch -1', 'Down':'pitch 1', 'Shift_L':'crouch 1',
                                       'Shift_R':'crouch 1', 
                                       '1':'hotbar.1 1', '2':'hotbar.2 1', '3':'hotbar.3 1', '4':'hotbar.4 1', '5':'hotbar.5 1',
                                       '6':'hotbar.6 1', '7':'hotbar.7 1', '8':'hotbar.8 1', '9':'hotbar.9 1' },
                       'discrete':   { 'Left':'turn -1', 'Right':'turn 1', 'Up':'move 1', 'Down':'move -1', 
                                       '1':'hotbar.1 1', '2':'hotbar.2 1', '3':'hotbar.3 1', '4':'hotbar.4 1', '5':'hotbar.5 1',
                                       '6':'hotbar.6 1', '7':'hotbar.7 1', '8':'hotbar.8 1', '9':'hotbar.9 1' } }
        if event.char == '/':
            self.command_entry.focus_set() # interlude to allow user to type command
        elif event.char.lower() in char_map:
            self.agent_host.sendCommand( char_map[ event.char.lower() ] )
        elif event.keysym in keysym_map[self.action_space]:
            self.agent_host.sendCommand( keysym_map[self.action_space][ event.keysym ] )
1181524
def call(severity, time, progname, msg)
      sprintf("%s: %s\n", time.strftime("%H:%M:%S"), hide_inputs(msg2str(msg)))
    end
773809
def handle_symbol_info(self, call_id, payload):
        """"""
        with catch(KeyError, lambda e: self.editor.message("unknown_symbol")):
            decl_pos = payload["declPos"]
            f = decl_pos.get("file")
            call_options = self.call_options[call_id]
            self.log.debug('handle_symbol_info: call_options %s', call_options)
            display = call_options.get("display")
            if display and f:
                self.editor.raw_message(f)

            open_definition = call_options.get("open_definition")
            if open_definition and f:
                self.editor.clean_errors()
                self.editor.doautocmd('BufLeave')
                if call_options.get("split"):
                    vert = call_options.get("vert")
                    self.editor.split_window(f, vertical=vert)
                else:
                    self.editor.edit(f)
                self.editor.doautocmd('BufReadPre', 'BufRead', 'BufEnter')
                self.set_position(decl_pos)
                del self.call_options[call_id]
1210002
def input(self, prompt, default=None, show_default=True):
        """"""
        return click.prompt(prompt, default=default, show_default=show_default)
380320
def _enter_handler(self, event):
        """"""
        iid = self.current_iid
        if iid is None or iid == self.active:
            return
        self.update_state(iid, "hover")
953419
def _call_handler(self, key, insert_text):
        
        if isinstance(key, tuple):
            for k in key:
                self._call_handler(k, insert_text)
        else:
            if key == Keys.BracketedPaste:
                self._in_bracketed_paste = True
                self._paste_buffer = ''
            else:
                self.feed_key_callback(KeyPress(key, insert_text))
760640
function onRead (key) {
  if (key !== null) {
    if (cli.debug) console.log('Key:', key)
    // Exits on CTRL-C
    if (key === '\u0003') process.exit()
    // If enter is pressed and the program is waiting for the user to press enter
    // so that the emulator can step forward, then call the appropriate callback
    if (key.charCodeAt(0) === 13 && readingFn() && onReadCb) onReadCb(key.charCodeAt(0))
    else if (cpu) {
      // Since the CPU is initialized and the program is not waiting for the user
      // to press enter, pass the pressed key to the LC-2 CPU Console.
      cpu.console.input(key)
    }
    readingFn(false)
  }
}
566419
def _on_key_pressed(self, event):
        
        if not event.isAccepted():
            if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
                cursor = self.editor.textCursor()
                pre, post = self._get_indent(cursor)
                cursor.beginEditBlock()
                cursor.insertText("%s\n%s" % (pre, post))

                # eats possible whitespaces
                cursor.movePosition(cursor.WordRight, cursor.KeepAnchor)
                txt = cursor.selectedText()
                if txt.startswith(' '):
                    new_txt = txt.replace(" ", '')
                    if len(txt) > len(new_txt):
                        cursor.insertText(new_txt)
                cursor.endEditBlock()
                event.accept()
102601
def key_press(self, key, x, y):
        ""
        if ord(key) == 27:
            # print "Escape!"
            if bool(glutLeaveMainLoop):
                glutLeaveMainLoop()
            else:
                raise Exception("Application quit")
781176
function _keyboard_interactive_process()
    {
        $responses = func_get_args();

        $response = $this->_get_binary_packet();
        if ($response === false) {
            user_error('Connection closed by server', E_USER_NOTICE);
            return false;
        }

        extract(unpack('Ctype', $this->_string_shift($response, 1)));

        switch ($type) {
            case NET_SSH2_MSG_USERAUTH_INFO_REQUEST:
                // see http://tools.ietf.org/html/rfc4256#section-3.2
                if (defined('NET_SSH2_LOGGING')) {
                    $this->message_number_log[count($this->message_number_log) - 1] = str_replace(
                        'UNKNOWN',
                        'NET_SSH2_MSG_USERAUTH_INFO_REQUEST',
                        $this->message_number_log[count($this->message_number_log) - 1]
                    );
                }

                extract(unpack('Nlength', $this->_string_shift($response, 4)));
                $this->_string_shift($response, $length); // name; may be empty
                extract(unpack('Nlength', $this->_string_shift($response, 4)));
                $this->_string_shift($response, $length); // instruction; may be empty
                extract(unpack('Nlength', $this->_string_shift($response, 4)));
                $this->_string_shift($response, $length); // language tag; may be empty
                extract(unpack('Nnum_prompts', $this->_string_shift($response, 4)));
                /*
                for ($i = 0; $i < $num_prompts; $i++) {
                    extract(unpack('Nlength', $this->_string_shift($response, 4)));
                    // prompt - ie. "Password: "; must not be empty
                    $this->_string_shift($response, $length);
                    $echo = $this->_string_shift($response) != chr(0);
                }
                */

                /*
                   After obtaining the requested information from the user, the client
                   MUST respond with an SSH_MSG_USERAUTH_INFO_RESPONSE message.
                */
                // see http://tools.ietf.org/html/rfc4256#section-3.4
                $packet = $logged = pack('CN', NET_SSH2_MSG_USERAUTH_INFO_RESPONSE, count($responses));
                for ($i = 0; $i < count($responses); $i++) {
                    $packet.= pack('Na*', strlen($responses[$i]), $responses[$i]);
                    $logged.= pack('Na*', strlen('dummy-answer'), 'dummy-answer');
                }

                if (!$this->_send_binary_packet($packet)) {
                    return false;
                }

                if (defined('NET_SSH2_LOGGING')) {
                    $this->message_number_log[count($this->message_number_log) - 1] = str_replace(
                        'UNKNOWN',
                        'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE',
                        $this->message_number_log[count($this->message_number_log) - 1]
                    );
                    $this->message_log[count($this->message_log) - 1] = $logged;
                }

                /*
                   After receiving the response, the server MUST send either an
                   SSH_MSG_USERAUTH_SUCCESS, SSH_MSG_USERAUTH_FAILURE, or another
                   SSH_MSG_USERAUTH_INFO_REQUEST message.
                */
                // maybe phpseclib should force close the connection after x request / responses?  unless something like that is done
                // there could be an infinite loop of request / responses.
                return $this->_keyboard_interactive_process();
            case NET_SSH2_MSG_USERAUTH_SUCCESS:
                return true;
            case NET_SSH2_MSG_USERAUTH_FAILURE:
                return false;
        }

        return false;
    }
476346
def on_feed_key(self, key_press):
        """"""
        if key_press.key in {Keys.Escape, Keys.ControlC}:
            echo(carriage_return=True)
            raise Abort()
        if key_press.key == Keys.Backspace:
            if self.current_command_pos > 0:
                self.current_command_pos -= 1
            return key_press
        ret = None
        if key_press.key != Keys.CPRResponse:
            if self.current_command_pos < len(self.current_command):
                current_key = self.current_command_key
                ret = KeyPress(current_key)
                increment = min(
                    [self.speed, len(self.current_command) - self.current_command_pos]
                )
                self.current_command_pos += increment
            else:
                # Command is finished, wait for Enter
                if key_press.key != Keys.Enter:
                    return None
                self.current_command_index += 1
                self.current_command_pos = 0
                ret = key_press
        return ret
61807
def handle_input(self, ncode, wparam, lparam):
        """"""
        value = WIN_KEYBOARD_CODES[wparam]
        scan_code = lparam.contents.scan_code
        vk_code = lparam.contents.vk_code
        self.update_timeval()

        events = []
        # Add key event
        scan_key, key_event = self.emulate_press(
            vk_code, scan_code, value, self.timeval)
        events.append(scan_key)
        events.append(key_event)

        # End with a sync marker
        events.append(self.sync_marker(self.timeval))

        # We are done
        self.write_to_pipe(events)

        return ctypes.windll.user32.CallNextHookEx(
            self.hooked, ncode, wparam, lparam)
146782
def enter(self):
        """"""
        self._communication.send(StartRequest,
                                 self._communication.left_end_needle,
                                 self._communication.right_end_needle)
471718
def key_press_handler(event, canvas, toolbar=None):
    
    if event.key is None: return

    key = event.key.encode('ascii', 'ignore')

    if key in ['1']:
        toolbar.create_gate_widget(kind='poly')
    elif key in ['2', '3', '4']:
        kind = {'2': 'quad', '3': 'horizontal threshold', '4': 'vertical threshold'}[key]
        toolbar.create_gate_widget(kind=kind)
    elif key in ['9']:
        toolbar.remove_active_gate()
    elif key in ['0']:
        toolbar.load_fcs()
    elif key in ['a']:
        toolbar.set_axes(('d1', 'd2'), pl.gca())
    elif key in ['b']:
        toolbar.set_axes(('d2', 'd1'), pl.gca())
    elif key in ['c']:
        toolbar.set_axes(('d1', 'd3'), pl.gca())
    elif key in ['8']:
        print(toolbar.get_generation_code())
654231
def interact(title, description, prompt, binary, options):
    """"""
    args = [binary]
    p = subprocess.Popen(args=args,
                         stdin=subprocess.PIPE,
                         stdout=subprocess.PIPE,
                         env=os.environ)
    p.args = args  # TODO: remove after Python 2 deprecation.
    expect(p, [b'OK'])

    title = util.assuan_serialize(title.encode('ascii'))
    write(p, b'SETTITLE ' + title + b'\n')
    expect(p, [b'OK'])

    if description:
        description = util.assuan_serialize(description.encode('ascii'))
        write(p, b'SETDESC ' + description + b'\n')
        expect(p, [b'OK'])

    if prompt:
        prompt = util.assuan_serialize(prompt.encode('ascii'))
        write(p, b'SETPROMPT ' + prompt + b'\n')
        expect(p, [b'OK'])

    log.debug('setting %d options', len(options))
    for opt in options:
        write(p, b'OPTION ' + opt + b'\n')
        expect(p, [b'OK', b'ERR'])

    write(p, b'GETPIN\n')
    pin = expect(p, [b'OK', b'D '], confidential=True)

    p.communicate()  # close stdin and wait for the process to exit
    exit_code = p.wait()
    if exit_code:
        raise subprocess.CalledProcessError(exit_code, binary)

    return pin.decode('ascii').strip()