示例#1
0
    def __init__(self, block_proxy):
        self.block = block_proxy.get()
        self.ellipsis = make_label(style.ellipsis, '...', True)

        self.statement_box = VBox(CacheMap(StatementWidgetMaker.make, self.block.statements),
                                  relay_focus=True)
        self.proxy_widget = ProxyWidget(ValueContainer(self.statement_box))

        VBox.__init__(self, List([
            make_label(style.braces, '{'),
            indented(self.proxy_widget),
            make_label(style.braces, '}'),
        ]))
        self.info_shower = InfoShower(self.ellipsis.focus_keymap.obs_activation)
        self.info_shower.info_widget = self.statement_box

        self.keymap.register_key(
            self.insert_statement_key,
            Keymap.keydown_noarg(self._insert_statement)
        )
        self.keymap.register_key(
            self.append_statement_key,
            Keymap.keydown_noarg(self._append_statement)
        )

        self.block.statements.obs_list.add_observer(self, '_statement_list_')
        self._update_delete_registration()
        self._update_fold_state()
    def __init__(self, array_deref_proxy):
        self.array_deref = array_deref_proxy.get()

        HBox.__init__(self, List([
            NormalWidgetMaker.make(self.array_deref.expr),
            make_label(style.bracket, "["),
            NormalWidgetMaker.make(self.array_deref.index),
            make_label(style.bracket, "]"),
        ]))
 def __init__(self, _type_proxy, variable_proxy):
     self.type = _type_proxy.get()
     HBox.__init__(self, List([
         make_label(style.paren, '('),
         make_label(style.type_, '*'),
         PostTypeWidgetMaker.make(self.type.pointed_type, variable_proxy),
         make_label(style.paren, ')'),
     ]))
     self.is_centered = True
示例#4
0
    def __init__(self, define_proxy):
        self.define = define_proxy.get()

        HBox.__init__(self, List([
            make_label(style.define, '#define'),
            make_label(style.space, ' '),
            TextEdit(style.define_value, partial(loop.namer.get_name, self.define)),
            make_label(style.space, ' '),
            NormalWidgetMaker.make(self.define.expr),
        ]), relay_focus=True)
示例#5
0
    def __init__(self, call_proxy):
        self.call = call_proxy.get()

        comma = make_label(style.comma, ', ')
        args_box = HBox(CacheMap(NormalWidgetMaker.make, self.call.args), relay_focus=True)
        args_box.padding_widget = comma
        HBox.__init__(self, List([
            NormalWidgetMaker.make(self.call.func),
            make_label(style.paren, "("),
            args_box,
            make_label(style.paren, ")"),
        ]))
示例#6
0
    def __init__(self, return_proxy):
        self.return_ = return_proxy.get()

        HBox.__init__(
            self,
            List(
                [
                    make_label(style.return_, "return "),
                    NormalWidgetMaker.make(self.return_.expr),
                    make_label(style.semicolon, ";"),
                ]
            ),
        )
    def __init__(self, function_type_proxy, variable_proxy):
        self.function_type = function_type_proxy.get()

        comma = make_label(style.comma, ', ')
        
        self.parameters_widget = HBox(CacheMap(DeclarationWidgetMaker.make,
                                               self.function_type.parameters))
        self.parameters_widget.padding_widget = comma
        self.parameters_widget.is_centered = True

        HBox.__init__(self, List([
            PostTypeWidgetMaker.make(self.function_type.return_type, variable_proxy),
            make_label(style.paren, '('),
            self.parameters_widget,
            make_label(style.paren, ')'),
        ]))
示例#8
0
 def _make(cls, proxy, value):
     if value is None:
         return cls._spacer
     return VBox(List([
         make_label(style.else_, 'else'),
         NormalWidgetMaker._make(proxy, value),
     ]), relay_focus=True)
示例#9
0
 def _make(cls, proxy, value):
     widget = NormalWidgetMaker._make(proxy, value)
     if ccode.is_expr(value):
         return HBox(List([
             widget,
             make_label(style.semicolon, ';')
         ]), relay_focus=True)
     return widget
示例#10
0
    def __init__(self, node_proxy):
        self.node = node_proxy.get()

        left, right = self.operand_attrs
        HBox.__init__(self, List([
            NormalWidgetMaker.make(getattr(self.node, left)),
            make_label(style.operator, ' ' + self.op_string + ' '),
            NormalWidgetMaker.make(getattr(self.node, right)),
        ]))
        self.is_centered = True
示例#11
0
    def _make(cls, type_proxy, variable_proxy, type_, variable):
        basetype_widget = IdentifierWidget(ccode.find_basetype(type_proxy), style.base_type)

        type_widget = HBox(List([
            basetype_widget,
            make_label(style.space, ' '),
            PostTypeWidgetMaker.make(type_proxy, variable_proxy),
        ]))
        type_widget.is_centered = True
        return type_widget
示例#12
0
    def __init__(self, node_proxy):
        self.node_proxy = node_proxy
        self.node = node_proxy.get()

        cond_part = HBox(List([
            make_label(style.while_, 'while'),
            make_label(style.paren, '('),
            NormalWidgetMaker.make(self.node.expr),
            make_label(style.paren, ')'),
        ]), relay_focus=True)
        cond_part.is_centered = True

        VBox.__init__(self, List([
            cond_part,
            NormalWidgetMaker.make(self.node.block),
        ]))

        self.focus_keymap.register_key(
            self.convert_to_if_key,
            Keymap.keydown_noarg(self._convert_to_if)
        )
示例#13
0
 def _value_widget(self, value_proxy, with_comma, emphasize_value):
     value = value_proxy.get()
     s = style.enum_value
     if value is emphasize_value:
         s = style.emphasize(s)
     l = [
         TextEdit(s, partial(loop.namer.get_name, value)),
         make_label(style.operator, ' = '),
         NormalWidgetMaker.make(value.value),
     ]
     if with_comma:
         l.append(self._comma)
     return HBox(List(l))
示例#14
0
    def __init__(self, module_proxy):
        self.module = module_proxy.get()
        self.func_box = VBox(CacheMap(NormalWidgetMaker.make, self.module.declarations),
                             relay_focus=True)
        VBox.__init__(self, List([
            make_label(style.module_name, loop.namer.get_name(self.module)),
            self.func_box,
        ]))

        self.keymap.register_key(
            self.add_func_key,
            Keymap.keydown_noarg(self._add_func)
        )
示例#15
0
    def __init__(self, enum_proxy, emphasize_value=None):
        self.enum = enum_proxy.get()

        self._comma = make_label(style.comma, ',')
        values_box = VBox(List([
            self._value_widget(value_proxy, index!=len(self.enum.values)-1,
                               emphasize_value)
            for index, value_proxy in enumerate(self.enum.values)
        ]))

        VBox.__init__(self, List([
            HBox(List([
                make_label(style.enum, 'enum'),
                make_label(style.space, ' '),
                make_label(style.type_, loop.namer.get_name(self.enum)),
            ]), relay_focus=True),
            make_label(style.braces, '{'),
            indented(values_box),
            HBox(List([
                make_label(style.braces, '}'),
                make_label(style.semicolon, ';'),
            ]), relay_focus=True)
        ]))