Example #1
0
    def _on_command(self, instance: AdvancedTextInput) -> bool:
        """"Privated function fired when self.commandText.on_text_validate is
        called, in other words, when users hit the 'enter' key. This property
        is established by res/sira.kv.

        [ensures]:  instance.last_row > 0
                    instance.protected_len <= len(instance._lines[instance.last_row])
                    instance.password_mode = False
                    instance.history_stack.traversal =
                        instance.history_stack.traversal_dummy
        [calls]:    instance.history_stack.reset_traversal
                    self.controller.processInput
                    instance.on_cursor
        """
        string = instance.text[instance.last_row_start +
                               instance.protected_len:]
        if instance.password_mode:
            string = instance.password_cache
            instance.password_mode = False
        elif instance.command_mode and string != "":
            instance.history_stack.push(string)
        instance.history_stack.reset_traversal()
        self.controller.processInput(string)
        instance.on_cursor(instance, instance.cursor)
        return True
Example #2
0
    def _stop_interaction(self, instance: AdvancedTextInput) -> None:
        """Private function to interrupt interactive mode. This function will
        be fired when the user hit control-C.

        [ensures]:  instance.password_mode = False
                    instance.command_mode = True
        [calls]:    self.controller.closeinteractive
        """
        if not instance.command_mode:
            if instance.completion_mode:
                if "_stop_completion" not in dir(self):
                    self._stop_completion = lambda x: x
                self._stop_completion(instance)
            self.controller.closeinteractive()
            instance.password_mode = False
            instance.command_mode = True