Exemple #1
0
    def show_types(self, types):
        if not types:
            Common.show_status_message("Can't infer type", False)
            return

        types = sorted(filter(
            lambda t: t.region(self.view).contains(self.view.sel()[0]), types),
                       key=lambda t: t.region(self.view).size())
        self.output_view = Common.output_panel(self.view.window(),
                                               '',
                                               panel_name=TYPES_PANEL_NAME,
                                               syntax='Haskell-SublimeHaskell',
                                               panel_display=False)

        regions = []
        for typ in types:
            Common.output_text(self.output_view,
                               '{0}\n'.format(typ.show(self.view)),
                               clear=False)
            regions.append(
                sublime.Region(
                    self.output_view.size() - 1 -
                    len(UnicodeOpers.use_unicode_operators(typ.typename)),
                    self.output_view.size() - 1))
        self.output_view.add_regions('types', regions, 'comment', '',
                                     sublime.DRAW_OUTLINED)
        Common.show_panel(self.view.window(), panel_name=TYPES_PANEL_NAME)
Exemple #2
0
def report_error(view, errmsg):
    window = view.window()
    output_view = Common.output_panel(window, FILTER_OUTPUT_PANEL_NAME)
    output_view.run_command('sublime_haskell_output_text', {
        'text': errmsg,
        'clear': 'yes'
    })
    Common.show_panel(window, FILTER_OUTPUT_PANEL_NAME)
    output_view.sel().clear()
    output_view.sel().add(sublime.Region(0, 0))
def goto_error(view, mark):
    line = mark.region.start.line + 1
    column = mark.region.start.column + 1

    Common.show_panel(view.window(), OUTPUT_PANEL_NAME)
    msg_panel = MARKER_MANAGER.message_panel
    # error_region = msg_panel.find('{0}: line {1}, column \\d+:(\\n\\s+.*)*'.format(re.escape(mark.filename), line), 0)
    error_region = msg_panel.find(re.escape(str(mark)), 0)
    # error_region = msg_panel.find('\\s{{2}}{0}: line {1}, column {2}:(\\n\\s+.*)*'.format(re.escape(mark.filename),
    #                                                                                        line, column), 0)
    msg_panel.add_regions("current_error", [error_region], 'string', 'dot', sublime.HIDDEN)
    msg_panel.show(error_region.a)

    view.window().open_file("{0}:{1}:{2}".format(mark.filename, line, column), sublime.ENCODED_POSITION)
    def show_types(self, types):
        if not types:
            Common.sublime_status_message("Can't infer type")
            return

        self.types = types
        self.output_view = Common.output_panel(self.view.window(), '',
                                               panel_name=TYPES_PANEL_NAME,
                                               syntax='Haskell-SublimeHaskell',
                                               panel_display=False)
        regions = []
        for typ in self.types:
            Common.output_text(self.output_view, '{0}\n'.format(typ.show(self.view)), clear=False)
            regions.append(sublime.Region(self.output_view.size() - 1 - len(UnicodeOpers.use_unicode_operators(typ.typename)),
                                          self.output_view.size() - 1))
        self.output_view.add_regions('types', regions, 'comment', '', sublime.DRAW_OUTLINED)
        Common.show_panel(self.view.window(), panel_name=TYPES_PANEL_NAME)