Esempio n. 1
0
	def set_connected(self, switch):
		self._connected = switch

		for child in self.children:
			child.set_connected(switch)

		urwid.emit_signal(self, "connected", switch)
Esempio n. 2
0
 def shiftDown(self, amount=1):
     if self.body.focus is not self.scroll(amount):
         self.focus_position = self.scroll()
         self.body[:] = self.body[:]
         urwid.emit_signal(self, 'shift')
     else:
         urwid.emit_signal(self, 'bottom')
Esempio n. 3
0
 def __accept(self):
     new_vals = {
         'server_uri': self.server_uri,
         'username': self.username,
         'password': self.password,
     }
     urwid.emit_signal(self, SettingsWidget.SIG_SETTINGS_ACCEPTED, new_vals)
Esempio n. 4
0
    def keypress(self, size, key):
        if key == "enter":
            if self.edit_text == "" and self.history:
                self.command = Command(self.history[-1])
            else:
                self.command = Command(self.edit_text)
                self.history.append(self.edit_text)

            self.command.executeCommand()
            self.historyIdx = -1
            self.edit_text = ""

            urwid.emit_signal(self, "executed")
        elif key == "up":
            if len(self.history) != 0:
                self.edit_text = self.history[self.historyIdx]
                self.edit_pos = len(self.edit_text)
                if self.historyIdx - 1 >= -1 * len(self.history):
                    self.historyIdx -= 1
        elif key == "down":
            if self.historyIdx == -1:
                self.edit_text = ""
            else:
                self.historyIdx += 1
                self.edit_text = self.history[self.historyIdx]
                self.edit_pos = len(self.edit_text)
        else:
            return super(CliEdit, self).keypress(size, key)
Esempio n. 5
0
  def cmd_exit_msgbox(self, *args):
    if self.logo_displayed:
      self.clear_msgbox()
      self.logo_displayed = False
      self._selectable = False

    urwid.emit_signal(self, 'exit_msgbox')
Esempio n. 6
0
 def keypress(self, size, key):
     if key == 'enter':
         urwid.emit_signal(self, 'ask_done', self.get_edit_text())
     elif key == 'esc':
         urwid.emit_signal(self, 'ask_done', None)
     elif len(key) != 1 or self.validator is None or self.validator(key):
         super().keypress(size, key)
Esempio n. 7
0
 def keypress(self, size, key):
     if key == "enter":
         self.save()
     elif key == "ctrl k":
         urwid.emit_signal(self, 'saved')
     else:
         return super(Saver, self).keypress(size, key)
Esempio n. 8
0
	def remove(self):
		""" emit remove signals """
		for child in self.children:
			child.remove()
			self.child_removed(child)
		urwid.emit_signal(self, "remove")
		self.set_parent(None)
Esempio n. 9
0
 def keypress(self, size, key):
     if key=='enter':
         line=self.edit_text.strip()
         if line:
             urwid.emit_signal(self,'line_entered', line)
             self.history.append(line)
         self._history_index=len(self.history)
         self.edit_text=u''
     if key=='up':
         
         self._history_index-=1
         if self._history_index< 0:
             self._history_index= 0
         else:
             self.edit_text=self.history[self._history_index]
             self.set_edit_pos(len(self.edit_text))
     if key=='down':
         self._history_index+=1
         if self._history_index>=len(self.history):
             self._history_index=len(self.history) 
             self.edit_text=u''
         else:
             self.edit_text=self.history[self._history_index]
             self.set_edit_pos(len(self.edit_text))
     else:
         urwid.Edit.keypress(self, size, key)
Esempio n. 10
0
    def keypress(self, size, key):
        """ 
            Handle user inputs
        """

        urwid.emit_signal(self, "keypress", size, key)

        # scroll the top panel

        if key in ("page up","page down","up","down"):
            self.body.keypress (size, key)
    
        # resize the main windows
        elif key == "window resize":
            self.size = self.ui.get_cols_rows()
#    
#        elif key in ('ctrl q'):
#            self.quit()
#            self.context.keypress (size, key)
               
        elif key == "enter":
            # Parse data or (if parse failed)
            # send it to the current world
            text = self.footer.get_edit_text()
            self.footer.set_edit_text(u" "*len(text))
            self.footer.set_edit_text(u"")
            if text.strip():
                self.print_sent_message(text)
                #self.print_received_message('Answer')
        else:
            self.context.keypress(size, key)
Esempio n. 11
0
 def keypress(self, size, key):
     if key == "enter":
         text = self.get_edit_text()
         urwid.emit_signal(self, "send_signal", text)
         self.set_edit_text("")
     else:
         return super(EditSms, self).keypress(size, key)
Esempio n. 12
0
 def edit_changed(self, x, d, *arg):
     # r = self.lck.acquire(False)
     # if r:
     if self.textField._checamudou():
         urwid.emit_signal(self, 'change', self, d)
         nisk.util.dump((self.textField.value(), self.textField._lastlastvalue, self.textField._checamudou()),
                        'change date')
Esempio n. 13
0
 def keypress(self, size, key):
     if key == 'enter':
         urwid.emit_signal(self, 'done', self.get_edit_text())
         return
     if key == 'esc':
         urwid.emit_signal(self, 'done', None)
     urwid.Edit.keypress(self, size, key)
Esempio n. 14
0
 def keypress(self, size, key):
     key = super().keypress(size, key)
     if key is not 'enter':
         return key
     else:
         message_text = self.input_field.get_edit_text()
         urwid.emit_signal(self, 'message-send', message_text)
Esempio n. 15
0
    def __cebNewAccountLogIn(self, a_arg_or_err, a_base_uri, a_auth):
        try:
            self.__logIn(a_base_uri, a_auth, a_arg_or_err)
        except Exception, e:
            urwid.emit_signal(self, SIG_RSP_NEW_ACCT, None, e)

            return
Esempio n. 16
0
    def __cebPrisoners(self, a_arg_or_err, a_auth, a_prisoners):
        if isinstance(a_arg_or_err, twisted.python.failure.Failure):
            urwid.emit_signal(self, SIG_RSP_PRISONERS, None, None, a_arg_or_err.value)

            return

        next_uri = None
        iresponse, resp_str, json_obj = a_arg_or_err
        new_items = dict(( ( i['id'], i ) for i in json_obj['items'] ))
        a_prisoners['items'].update(new_items)

        # Note, we check to see if "offset" has changed because there is a
        # bug in the server reference implementation where the "offset"
        # parameter is ignored (see "Server Issues" section in README)
        if json_obj['next'] is not None \
                and json_obj.get('offset', SENTINEL) != a_prisoners['offset']:
            next_uri = urlparse.urljoin(self.__base_uri, json_obj['next'])

        a_prisoners.update(( ( k, v ) for k, v in json_obj.items() if k != 'items' ))

        # Keep calling ourselves as long as we have somewhere to go
        if next_uri is not None:
            d = self._jsonRequest(next_uri, a_auth)
            d.addCallback(self.__cebPrisoners, a_auth, a_prisoners)
            d.addErrback(self.__cebPrisoners, a_auth, a_prisoners)

            return d

        urwid.emit_signal(self, SIG_RSP_PRISONERS, a_auth, a_prisoners['items'])
Esempio n. 17
0
 def bottom(self):
     for index in xrange(len(self.contents) - 1, -1, -1):
         widget = self.contents[index][0]
         if self.constraint(index, widget):
             self.focus_position = index
             urwid.emit_signal(self, 'shift')
             return
 def keypress(self, size, key):
     if self.single:
         urwid.emit_signal(self, 'prompt_enter', self, key)
     elif key == 'enter':
         urwid.emit_signal(self, 'prompt_enter', self, self.get_edit_text())
     else:
         return urwid.Edit.keypress(self, size, key)
Esempio n. 19
0
 def shiftUp(self, amount=1):
     if self.body.focus is not self.scroll(-amount):
         self.focus_position = self.scroll()
         self.body[:] = self.body[:]
         urwid.emit_signal(self, 'shift')
     else:
         urwid.emit_signal(self,'top')
Esempio n. 20
0
 def completion_mode(self, p_enable):
     if p_enable is True:
         urwid.emit_signal(self, 'show_completions')
     elif p_enable is False:
         self._surrounding_text = None
         if self.completion_mode:
             self.completion_box.clear()
             urwid.emit_signal(self, 'hide_completions')
Esempio n. 21
0
    def _repeat_cmd(self):
        try:
            todo = self.listbox.focus.todo
            todo_id = str(self.view.todolist.number(todo))
        except AttributeError:
            todo_id = None

        urwid.emit_signal(self, 'repeat_cmd', todo_id)
Esempio n. 22
0
 def quit(self, _exit=True):
     """ stops the ui, exits the application (if exit=True)
         After the UI is stopped, the config is written.
     """
     urwid.emit_signal(self, "quit")
     self.shall_quit = True
     if _exit:
         sys.exit(0)
Esempio n. 23
0
    def quit(self, exit=True):
        """ stops the ui, exits the application (if exit=True) """
        urwid.emit_signal(self, "quit")

        self.shall_quit = True

        if exit:
            sys.exit(0)
Esempio n. 24
0
    def keypress(self, p_size, p_key):
        if p_key == 'enter' or p_key == 'q' or p_key == 'esc':
            urwid.emit_signal(self, 'close')

        # don't return the key, 'enter', 'escape', 'q' or ':' are your only
        # escape. ':' will reenter to the cmdline.
        elif p_key == ':':
            urwid.emit_signal(self, 'close', True)
Esempio n. 25
0
	def child_removed(self, child):
		urwid.emit_signal(self, "child_removed", self, child)
		try:
			i = self.children.index(child)
		except ValueError:
			pass
		else:
			del self.children[i]
Esempio n. 26
0
 def handle_keys(self, key):
     '''Handle keyboard input'''
     hot_item = self.hot_items.get(key)
     if hot_item:
         # select a history entry based on its hotkey
         urwid.emit_signal(hot_item, 'click', hot_item)
     elif key in ('esc',):
         self.close()
Esempio n. 27
0
    def _reset_data(self, new_data):
        new_data = new_data or {}
        for k in ('profile', 'stats'):
            self._data[k] = new_data.get(k)
            urwid.emit_signal(self, k + '_update')

        for cls in TASK_CLASSES:
            self._task_lists[cls.type][:] = list(map(cls, new_data[cls.USER_ENTRY], itertools.repeat(self)))
Esempio n. 28
0
 def do_select(self, remember):
     accountitem = self.listwalker.get_focus()[0]
     if remember:
         self.manager.set_default(accountitem.num)
     else:
         self.manager.set_default(None)
     self.close()
     urwid.emit_signal(self, 'done', accountitem.account)
Esempio n. 29
0
 def keypress(self, size, key):
     if key == 'enter':
         urwid.emit_signal(self, 'done', self.get_edit_text())
         super(commandLine, self).set_edit_text('')
         return
     elif key == 'esc':
         super(commandLine, self).set_edit_text('')
         return
     urwid.Edit.keypress(self, size, key)
Esempio n. 30
0
 def keypress(self, size, key):
     #key=super(EndEdit,self).keypress(size,key)
     if key == "enter":
         urwid.emit_signal(self, "change", self, self.get_edit_text(), 1)
     elif key == "esc":
         self.set_edit_text(self.orig)
         urwid.emit_signal(self, "change", self, self.orig, 2)
     else:
         return super(EndEdit, self).keypress(size, key)
Esempio n. 31
0
    def keypress(self, size, key):
        if key == 'enter':
            urwid.emit_signal(self, 'done', self.get_edit_text())
            return
        elif key == 'esc':
            urwid.emit_signal(self, 'done', None)
            return

        urwid.Edit.keypress(self, size, key)
Esempio n. 32
0
 def expanded(self, expanded):
     in_init = not hasattr(self, 'expanded')
     self._expanded = expanded
     if in_init:
         return
     if expanded:
         urwid.emit_signal(self, 'expanded')
     else:
         urwid.emit_signal(self, 'collapsed')
Esempio n. 33
0
    def keypress(self, size, key):
        super(ModalDialog, self).keypress(size, key)
        if key == self.escape_key:
            urwid.emit_signal(self, "close")
            self.keep_open = False
            self.loop.widget = self.previous_widget

        if key == 'f12':
            self.original_mod.parent.exit_program(None)
Esempio n. 34
0
 def expanded(self, expanded):
     in_init = not hasattr(self, 'expanded')
     self._expanded = expanded
     if in_init:
         return
     if expanded:
         urwid.emit_signal(self, 'expanded')
     else:
         urwid.emit_signal(self, 'collapsed')
Esempio n. 35
0
File: ui.py Progetto: qarth/xapers
    def keypress(self, size, key):
        if key == "enter":
            urwid.emit_signal(self, "done", self.get_edit_text())
            return
        elif key == "esc":
            urwid.emit_signal(self, "done", None)
            return

        urwid.Edit.keypress(self, size, key)
Esempio n. 36
0
 def _on_snippet_selected(self, view, snippet):
     try:
         cmd = parse_command(snippet['cmd'])
     except ParsingError as err:
         # TODO: show error
         return
     if not cmd.field_names:
         urwid.emit_signal(self, 'snippet-applied', snippet['cmd'])
         return
     self.view.open_insert_snippet_dialog(snippet)
Esempio n. 37
0
    def quit(self, exit=True):
        """
            Stops the ui, exits the application (if exit=True)
        """
        urwid.emit_signal(self, "quit")
        self.shall_quit = True

        if exit:

            sys.exit(0)
Esempio n. 38
0
    def keypress(self, size, key):
        if key == 'enter':
            urwid.emit_signal(self, signals.PROMPT_DONE, self.get_edit_text(),
                              *self.metadata)
        elif key == 'esc':
            urwid.emit_signal(self, signals.PROMPT_DONE, None, *self.metadata)
        else:
            super(Prompt, self).keypress(size, key)

        return True
Esempio n. 39
0
 def keypress(self, size, key):
     keymap = Store.instance.config['keymap']
     if key == keymap['go_to_sidebar']:
         self.header.restore_topic()
         urwid.emit_signal(self, 'go_to_sidebar')
         return True
     elif key == keymap['quit_application']:
         urwid.emit_signal(self, 'quit_application')
         return True
     return super(ChatBox, self).keypress(size, key)
Esempio n. 40
0
    def keypress(self, size, key):
        if key in ('up', 'down', 'left', 'right', 'page up', 'page down',
                   'home', 'end', 'q', 'h', 'f'):
            return super(urwid.Button, self).keypress(size, key)

        if key == 'enter':
            urwid.emit_signal(self, 'click')

        if key == 'r':
            urwid.emit_signal(self, 'read')
Esempio n. 41
0
    def keypress(self, size, key):
        keymap = Store.instance.config['keymap']
        if key == keymap['open_quick_switcher']:
            urwid.emit_signal(self, 'open_quick_switcher')
            return True
        if key == keymap['set_snooze']:
            urwid.emit_signal(self, 'open_set_snooze')
            return True

        return super(ChatBox, self).keypress(size, key)
Esempio n. 42
0
    def handle_transaction_finalized(self, *args, **kwargs):
        """
        Clear the transation dialog state when we are told the transaction is finished.

        This cleans up the event notifications and closes the dialog.
        """
        self.finalize()

        # Close the dialog
        urwid.emit_signal(self, self.signals[0])
Esempio n. 43
0
 def closing_action(self):
     try:
         f = int(self.get_edit_text()) - 1
         if f < 0:
             f = 0
     except ValueError:
         pass
     else:
         urwid.emit_signal(self, 'select_frame', f)
     Popup.closing_action(self)
Esempio n. 44
0
 def cycle(self, clockwise):
     if clockwise:
         self.position += 1
         if self.position >= len(self.entries):
             self.position = 0
     else:
         self.position -= 1
         if self.position < 0:
             self.position = len(self.entries) - 1
     self.label_widget.set_text(self.carouselText(self.position))
     urwid.emit_signal(self, "click")
Esempio n. 45
0
    def keypress(self, size, key):
        if key == 'enter' and self.edit_text:
            urwid.emit_signal(self, "validated")
            return None

        if len(self.edit_text) == self._max_len:
            if self.valid_char(key):
                # No more room for printable chars.
                return None

        return super(LimitedEdit, self).keypress(size, key)
Esempio n. 46
0
 def _set_state_internal(self, state, signal=True):
     if state != self._state:
         old_state = self._state
         self._state = state
         # argument list to match Edit behaviour
         if signal:
             emit_signal(self, 'change', self, state)
         self._update_text()
         # this is similar behaviour to the edit widget
         if signal:
             emit_signal(self, 'postchange', self, old_state)
Esempio n. 47
0
 def _keypress_mode_input_filter(self, keys, raw):
     urwid.emit_signal(
         self,
         self._keypress_prompt_callback_signal,
         keys[0],
         self._keypress_prompt_callback_kwargs,
     )
     self._mode = NORMAL
     self._keypress_prompt_callback_signal = None
     self._keypress_prompt_callback_kwargs = {}
     return []
Esempio n. 48
0
    def keypress(self, size, key):
        '''Emit a signal with the key and size to be handled in the parent

        The reason for this is to get the inner size of the table
        Disable only the 'up' and 'down' keys due to interfering
        with other parent pile containers
        '''
        urwid.emit_signal(self, self.KEYPRESS, self, size, key)
        if key == 'up' or key == 'down':
            return
        return key
Esempio n. 49
0
    def keypress(self, size, key):
        key = utils.vim2emacs_translation(key)
        if key == 'esc':
            urwid.emit_signal(self, self.SIGNAL_ESCAPE, self)
            return

        if key == 'f10':
            urwid.emit_signal(self, self.SIGNAL_QUIT, self)
            return

        return super().keypress(size, key)
Esempio n. 50
0
    def __confirm(self):
        emit_signal(self, SET_HEADER_TEXT_SIGNAL, self.name)
        self.render_overlay()

        try:
            self.__submit()
            self.__quit()
        except Exception as e:
            emit_signal(self, SET_HEADER_TEXT_SIGNAL, ("error", str(e)))
        finally:
            self.render_form()
Esempio n. 51
0
    def test_connection(self, *args):
        form = self._edit_form_widget
        form_data = form.data
        validation_error = self._validate_connection_data(form_data)

        if validation_error is not None:
            form.set_status_message(validation_error, error=True)
            return

        form.clear_status_message()
        urwid.emit_signal(self, self.SIGNAL_TEST_CONNECTION, self, form_data)
Esempio n. 52
0
    def keypress(self, size, key):
        """Keypress events."""
        if key == "enter":
            command = self._edit_box.edit_text.strip()

            if command:
                # Call listeners.
                urwid.emit_signal(self, "line_entered", command)
            self._edit_box.edit_text = ""
        else:
            urwid.Edit.keypress(self._edit_box, size, key)
Esempio n. 53
0
 def mouse_event(self, size, event, button, col, row, focus):
     if event == "mouse press" and button == 1:
         now = time.time()
         delta = now - self.last_click
         self.last_click = now
         if delta < self.DOUBLE_CLICK_SPEED:
             urwid.emit_signal(self, "doubleclick")
             return True
     try:
         return super().mouse_event(size, event, button, col, row, focus)
     except AttributeError:
         return True
Esempio n. 54
0
 def keypress(self, size, key):
     keymap = Store.instance.config['keymap']
     if key == keymap['compose_in_editor']:
         self.set_edit_text(edit_text_in_editor(self.get_edit_text()))
         return True
     elif key == 'enter':
         urwid.emit_signal(self, 'submit_message', self.get_edit_text())
         return True
     elif key == 'up':
         urwid.emit_signal(self, 'go_to_last_message')
         return True
     return super(MessagePrompt, self).keypress(size, key)
Esempio n. 55
0
    def load_next_set(self):
        self._increment_page()

        urwid.emit_signal(self, self.SIGNAL_PRE_LOAD, self)
        result = self._fetch_more_rows()
        if result is None:
            self._increment_page(-1)
            data = []
            data_length = 0
        else:
            data, data_length = result
        urwid.emit_signal(self, self.SIGNAL_NEW_DATA, self, data, data_length)
Esempio n. 56
0
 async def add_info():
     with self._context.child("add_info"):
         try:
             await run_in_thread(_bg_add_info)
         except Exception:
             self.state = ErrorReportState.ERROR_GENERATING
             log.exception("adding info to problem report failed")
         else:
             self.state = ErrorReportState.DONE
         self._file.close()
         self._file = None
         urwid.emit_signal(self, "changed")
Esempio n. 57
0
    def _add_pending_action(self, p_action, p_size):
        """
        Creates action waiting for execution and forwards it to the mainloop.
        """
        def generate_callback():
            def callback(*args):
                self.resolve_action(p_action, p_size)
                self.keystate = None

            return callback

        urwid.emit_signal(self, 'add_pending_action', generate_callback())
Esempio n. 58
0
 async def upload():
     with self._context.child("upload") as context:
         try:
             oops_id = await run_in_thread(_bg_upload)
         except requests.exceptions.RequestException:
             log.exception("upload for %s failed", self.base)
         else:
             self.set_meta("oops-id", oops_id)
             context.description = oops_id
         uploader.stop()
         self.uploader = None
         urwid.emit_signal(self, 'changed')
Esempio n. 59
0
    def on_exit_button(self, button):
        '''
        invoked by pressing of exit buttons.
        '''
        self.exitcode = button.exitcode

        if  not self.is_root:
            self.dismiss()
            urwid.emit_signal(self, "exit")
        else:
            urwid.emit_signal(self, "exit")
            application.exit()
Esempio n. 60
0
        def keypress(self, size, key):
            if key in self.__keymap:
                signal = self.__keymap[key]
                logger.debug("Keypress '{}' sent signal '{}'".format(
                    key, signal))
                # Emit signal with self as the only argument
                urwid.emit_signal(self, self.__keymap[key], self)

                super(cls, self).keypress(size, None)
                return True

            return super(cls, self).keypress(size, key)