예제 #1
0
    def render(self) -> ui.components:
        items = []  #type: List[ui.TableItem]
        for breakpoint in self.breakpoints.breakpoints:
            base, name = os.path.split(breakpoint.file)

            if breakpoint == self.breakpoints.selected_breakpoint:
                color = 'primary'
            else:
                color = 'secondary'

            on_toggle = lambda bp=breakpoint: self.on_toggle(bp)  #type: ignore
            on_click = lambda bp=breakpoint: self.onClicked(bp)  #type: ignore

            toggle_button = ui.Button(on_click=on_toggle,
                                      items=[
                                          ui.Img(breakpoint.image()),
                                      ])
            fileAndLine = ui.Button(
                on_click=on_click,
                items=[
                    # filename
                    ui.Label(name,
                             color=color,
                             padding_left=0.25,
                             width=15,
                             align=0),
                    # line number
                    ui.Box(items=[
                        ui.Label(str(breakpoint.line), color=color, width=3),
                    ]),
                ])
            items.append(ui.TableItem(items=[toggle_button, fileAndLine]))
        return [ui.Table(table_items=items)]
예제 #2
0
    def render(self) -> ui.components:
        v = self.variable

        if v.reference == 0:
            return [
                ui.Label(v.name, padding_left=0.5, padding_right=1),
                ui.Label(v.value, color='secondary'),
            ]

        if self.expanded:
            inner = []  #type: List[ui.Component]
            for variable in self.variables:
                inner.append(VariableComponent(variable))
            table = ui.Table(items=inner)
            table.add_class('inset')
            items = [
                ui.Button(self.toggle, items=[ui.Img(ui.Images.shared.down)]),
                ui.Label(v.name, padding_right=1),
                ui.Label(v.value, color='secondary'), table
            ]
            return items
        else:
            return [
                ui.Button(self.toggle, items=[ui.Img(ui.Images.shared.right)]),
                ui.Label(v.name, padding_right=1),
                ui.Label(v.value, color='secondary'),
            ]
예제 #3
0
    def render(self) -> ui.Block.Children:
        items = []  #type: List[ui.TableItem]
        for filter in self.breakpoints.filters:

            def on_click(filter=filter):
                self.breakpoints.toggle_filter(filter)  #type: ignore

            items.append(
                ui.block(
                    ui.Button(on_click=on_click,
                              items=[
                                  ui.Img((ui.Images.shared.dot,
                                          ui.Images.shared.dot_disabled
                                          )[not filter.enabled]),
                              ]),
                    ui.Label(filter.name,
                             color='secondary',
                             padding_left=0.25,
                             width=15,
                             align=0)))
        for breakpoint in self.breakpoints.breakpoints:
            base, name = os.path.split(breakpoint.file)

            if breakpoint == self.breakpoints.selected_breakpoint:
                color = 'primary'
            else:
                color = 'secondary'

            def on_toggle(bp=breakpoint):
                return self.on_toggle(bp)  #type: ignore

            def on_click(bp=breakpoint):
                return self.onClicked(bp)  #type: ignore

            toggle_button = ui.Button(on_click=on_toggle,
                                      items=[
                                          ui.Img(breakpoint.image()),
                                      ])
            fileAndLine = ui.Button(
                on_click=on_click,
                items=[
                    # line number
                    ui.Padding(ui.Box(
                        ui.Label(str(breakpoint.line), color=color, width=3)),
                               left=0.5,
                               right=0.5),
                    # filename
                    ui.Label(name,
                             color=color,
                             padding_left=0.25,
                             width=15,
                             align=0),
                ])
            items.append(
                ui.Padding(ui.block(toggle_button, fileAndLine),
                           top=0.1,
                           bottom=0.1))
        return [ui.Table(items)]
예제 #4
0
    def render(self) -> ui.components:
        if self.thread.stopped:
            items = [
                ui.Button(
                    self.toggle,
                    items=[
                        ui.Img((ui.Images.shared.right,
                                ui.Images.shared.down)[self.thread.expanded]),
                    ]),
                ui.Button(self.on_select_thread,
                          items=[
                              ui.Box(items=[
                                  ui.Label("", padding_left=0.8),
                                  ui.Img(ui.Images.shared.thread),
                                  ui.Label("", padding_left=0.8),
                              ]),
                              ui.Label(self.thread.name, padding_left=0.8),
                          ])
            ]  #type: List[ui.Component]
        else:
            items = [
                ui.Button(self.on_select_thread,
                          items=[
                              ui.Img(ui.Images.shared.thread_running),
                              ui.Box(items=[
                                  ui.Label("", padding_left=0.8),
                                  ui.Img(ui.Images.shared.thread),
                                  ui.Label("", padding_left=0.8),
                              ]),
                              ui.Label(self.thread.name,
                                       padding_left=0.8,
                                       padding_right=0.8),
                              ui.Label('running', color="secondary"),
                          ]),
            ]

        if self.thread.expanded and self.thread.stopped:
            frames = []  #type: List[ui.Component]
            selected_index = -1
            for index, frame in enumerate(self.frames):
                on_click = lambda index=index: self.onClicked(index
                                                              )  #type: ignore
                component = StackFrameComponent(self.debugger, frame, on_click)
                if self.debugger.selected_frame and frame.id == self.debugger.selected_frame.id:
                    selected_index = index

                frames.append(component)

            table = ui.Table(items=frames, selected_index=selected_index)
            items.append(table)

        return items
예제 #5
0
 def render(self) -> ui.Block.Children:
     return [
         ui.block(
             ui.Padding(ui.Button(self.callback, items=[self.image]),
                        left=0.6,
                        right=0.6))
     ]
예제 #6
0
	def render(self) -> ui.Block.Children:
		count = self.breakpoint.count or ''
		condition = self.breakpoint.condition or ''
		log = self.breakpoint.log or ''
		return [
			ui.Table([
				ui.block(
					ui.Box(ui.Label('expr', width=6)),
					ui.Input(on_done=self.on_enter_expression, hint='Breaks when expression is true', text=condition, width=50),
				),
				ui.block(
					ui.Box(ui.Label('log', width=6)),
					ui.Input(on_done=self.on_enter_log, hint='Message to log, expressions within {} are interpolated', text=log, width=50),
				),
				ui.block(
					ui.Box(ui.Label('count', width=6)),
					ui.Input(on_done=self.on_enter_count, hint='Break when hit count condition is met', text=count, width=50),
				),
				ui.block(
					ui.Box(ui.Button(self.on_remove, items=[
						ui.Label('Remove', width=6),
					])),
				),
			])
		]
예제 #7
0
파일: main.py 프로젝트: slifin/sublime_db
	def add_selected_stack_frame_component(self, view: sublime.View, line: int) -> None:
		if self.selectedFrameComponent:
			self.selectedFrameComponent.dispose()
			self.selectedFrameComponent = None

		if not self.debugAdapterClient:
			return
		if not self.debugAdapterClient.selected_frame:
			return

		pt = view.text_point(line + 1, 0)

		max = view.viewport_extent()[0]/view.em_width() - 3

		pt_current_line = view.text_point(line, 0)
		line_current = view.line(pt_current_line)
		region =  sublime.Region(pt-1, pt-1)

		layout = sublime.LAYOUT_INLINE
		if line_current.b - line_current.a > max:
			pt = view.text_point(line - 1, 0)
			region =  sublime.Region(pt, pt)
			layout = sublime.LAYOUT_BELOW

		variables = ui.Segment(items = [
			ui.Button(self.OnResume, items = [
				ui.Img(ui.Images.shared.play)
			]),
			ui.Button(self.OnStepOver, items = [
				ui.Img(ui.Images.shared.down)
			]),
			ui.Button(self.OnStepOut, items = [
				ui.Img(ui.Images.shared.left)
			]),
			ui.Button(self.OnStepIn, items = [
				ui.Img(ui.Images.shared.right)
			]),
			ui.Label(self.stopped_reason, padding_left = 1,  padding_right = 1, color = 'secondary')
		])
		self.selectedFrameComponent = ui.Phantom(variables, view, region, layout)
예제 #8
0
    def render(self) -> ui.Block.Children:
        count = int(self.layout.height() / 1.65)
        items = []

        for item in reversed(self.items):
            if len(items) >= count:
                break
            if item.kind & self.filter:
                items.append(item)
        items.reverse()
        items.append(
            ui.Button(self.on_click, items=[
                ui.Img(ui.Images.shared.right),
            ]))
        return [ui.Table(items=items)]
예제 #9
0
    def render(self) -> ui.components:
        frame = self.frame
        name = os.path.basename(frame.file)

        fileAndLine = ui.Button(
            on_click=self.on_click,
            items=[
                # line number
                ui.Box(items=[
                    ui.Label(str(frame.line), width=3),
                ]),
                # filename
                ui.Label(name, padding_left=0.8, padding_right=0.8),
                ui.Label(frame.name, color="secondary"),
            ])

        return [fileAndLine]
예제 #10
0
    def render(self) -> ui.Block.Children:
        v = self.variable
        name = v.name
        value = v.value

        if self.syntax_highlight:
            value_item = ui.CodeBlock(value)
        else:
            value_item = ui.Label(value)

        if not self.variable.expandable:
            return [
                ui.block(
                    ui.ButtonDoubleClick(self.on_edit, None, [
                        ui.Label(name, padding_left=0.5, padding_right=1),
                        value_item
                    ]))
            ]

        if self.variable.expanded:
            image = ui.Img(ui.Images.shared.down)
        else:
            image = ui.Img(ui.Images.shared.right)

        items = [
            ui.block(
                ui.Button(self.variable.toggle_expand, [image]),
                ui.ButtonDoubleClick(self.on_edit, None, [
                    ui.Label(name, padding_right=1),
                    value_item,
                ]))
        ]  #type: List[ui.Block]

        if self.variable.expanded:
            inner = []  #type: List[ui.Block]
            syntax_highlight = len(self.variable.variables) < 100
            for variable in self.variable.variables:
                inner.append(VariableComponent(variable, syntax_highlight))
            table = ui.Table(items=inner)
            table.add_class('inset')
            items.append(table)

        return items
예제 #11
0
    def render(self) -> ui.components:
        items = []  #type: List[ui.TableItem]
        for filter in self.breakpoints.filters:
            on_click = lambda filter=filter: self.onClicked(filter
                                                            )  #type: ignore

            items.append(
                ui.TableItem(items=[
                    ui.Button(on_click=on_click,
                              items=[
                                  ui.Img((ui.Images.shared.dot,
                                          ui.Images.shared.dot_disabled
                                          )[not filter.enabled]),
                              ]),
                    ui.Label(filter.name,
                             color='secondary',
                             padding_left=0.25,
                             width=15,
                             align=0)
                ]))
        return [ui.Table(table_items=items)]
예제 #12
0
    def render(self) -> ui.Block.Children:
        if self.scope.expanded:
            image = ui.Img(ui.Images.shared.down)
        else:
            image = ui.Img(ui.Images.shared.right)

        scope_item = ui.block(
            ui.Button(self.scope.toggle_expand, items=[image]),
            ui.Label(self.scope.name, padding_left=0.5, padding_right=1),
        )

        if self.scope.expanded:
            variables = []  #type: List[ui.Block]
            syntax_highlight = len(self.scope.variables) < 100
            for variable in self.scope.variables:
                variables.append(VariableComponent(variable, syntax_highlight))
            table = ui.Table(items=variables)
            table.add_class('inset')
            return [scope_item, table]

        return [scope_item]
예제 #13
0
    def render(self) -> ui.Block.Children:
        frame = self.frame
        name = os.path.basename(frame.file)
        if frame.presentation == StackFrame.subtle:
            color = "secondary"
        else:
            color = "primary"

        assert self.layout
        emWidth = self.layout.em_width()
        padding_left = 0.8
        padding_right = 0.8
        max_length = callstack_panel_width(
            self.layout) - padding_left - padding_right - 5
        name_length = len(name) * emWidth

        if name_length > max_length:
            name_length = max_length

        max_length -= name_length
        frame_length = max_length

        fileAndLine = ui.Button(on_click=self.on_click,
                                items=[
                                    ui.Box(
                                        ui.Label(str(frame.line),
                                                 width=3,
                                                 color=color), ),
                                    ui.Label(name,
                                             width=name_length,
                                             padding_left=padding_left,
                                             padding_right=padding_right,
                                             color=color,
                                             align=0),
                                    ui.Label(frame.name,
                                             width=frame_length,
                                             color="secondary",
                                             align=0),
                                ])
        return [ui.block(fileAndLine)]
예제 #14
0
    def render(self) -> ui.components:
        buttons = []  #type: List[ui.Component]
        if self.state == RUNNING:
            buttons = [
                ui.Label("Running", width=6),
                ui.Button(self.listener.OnSettings,
                          items=[ui.Img(ui.Images.shared.settings)]),
                ui.Button(self.listener.OnStop,
                          items=[ui.Img(ui.Images.shared.stop)]),
                ui.Button(self.listener.OnPause,
                          items=[ui.Img(ui.Images.shared.pause)]),
            ]
        if self.state == PAUSED:
            buttons = [
                ui.Label("Paused", width=6),
                ui.Button(self.listener.OnSettings,
                          items=[ui.Img(ui.Images.shared.settings)]),
                ui.Button(self.listener.OnStop,
                          items=[ui.Img(ui.Images.shared.stop)]),
                ui.Button(self.listener.OnResume,
                          items=[ui.Img(ui.Images.shared.play)]),
                ui.Button(self.listener.OnStepOver,
                          items=[ui.Img(ui.Images.shared.down)]),
                ui.Button(self.listener.OnStepOut,
                          items=[ui.Img(ui.Images.shared.left)]),
                ui.Button(self.listener.OnStepIn,
                          items=[ui.Img(ui.Images.shared.right)]),
            ]
        if self.state == STOPPED:
            buttons = [
                ui.Label(self.name, width=6),
                ui.Button(self.listener.OnSettings,
                          items=[ui.Img(ui.Images.shared.settings)]),
                ui.Button(self.listener.OnPlay,
                          items=[ui.Img(ui.Images.shared.play)]),
            ]
        if self.state == LOADING:
            buttons = [
                ui.Label(self.name, width=6),
                ui.Button(self.listener.OnSettings,
                          items=[ui.Img(ui.Images.shared.settings)]),
                ui.Button(self.listener.OnStop,
                          items=[ui.Img(ui.Images.shared.stop)]),
                LoadingComponent()
            ]

        return [
            ui.Panel(items=[
                ui.Segment(items=buttons),
                FiltersComponent(self.breakpoints),
                BreakpintsComponent(self.breakpoints,
                                    self.listener.OnExpandBreakpoint),
            ]),
        ]
예제 #15
0
    def render(self) -> ui.Block.Children:
        max_length = callstack_panel_width(self.layout) - 5
        if self.thread.stopped:
            item = ui.block(
                ui.Button(
                    self.toggle,
                    items=[
                        ui.Img((ui.Images.shared.right,
                                ui.Images.shared.down)[self.thread.expanded]),
                    ]),
                ui.Button(self.on_select_thread,
                          items=[
                              ui.Box(
                                  ui.Padding(ui.Img(ui.Images.shared.thread),
                                             left=0.8,
                                             right=0.8)),
                              ui.Label(self.thread.name,
                                       padding_left=0.8,
                                       width=max_length,
                                       align=0),
                          ]))
        else:
            item = ui.block(
                ui.Button(self.on_select_thread,
                          items=[
                              ui.Img(ui.Images.shared.thread_running),
                              ui.Box(
                                  ui.Label("", padding_left=0.8),
                                  ui.Img(ui.Images.shared.thread),
                                  ui.Label("", padding_left=0.8),
                              ),
                              ui.Label(self.thread.name,
                                       padding_left=0.8,
                                       width=max_length,
                                       align=0),
                          ]), )

        item = ui.Padding(item, top=0.1, bottom=0.1)
        items = [item]  #type: List[ui.Block]

        if self.thread.expanded and self.thread.stopped:
            frames = []  #type: List[ui.Block]
            selected_index = -1
            if self.panel.selected_thread == self.thread and self.panel.has_selection_frame(
            ):
                selected_index = self.panel.selected_frame_index

            for index, frame in enumerate(self.frames):

                def on_click(index=index):
                    self.onClicked(index)

                component = ui.Padding(StackFrameComponent(
                    self.debugger, frame, on_click),
                                       top=0.1,
                                       bottom=0.2)
                frames.append(component)

            table = ui.Table(items=frames, selected_index=selected_index)
            items.append(table)

        if self.panel.selected_thread == self.thread and not self.panel.has_selection_frame(
        ):
            item.add_class('selected_stack_frame')

        return items