예제 #1
0
    def run(self):
        global g_is_there_new_changes

        view = self.view
        window = view.window()

        current_time = time.time()
        elapsed_time = 0.1
        default_time = 1.0

        while True:
            log(4, "current_time: %s, elapsed_time: %s", current_time,
                elapsed_time)

            # Wait a little to not generate the diagram/image while the user is typing
            while g_is_there_new_changes:
                g_is_there_new_changes = False
                self.sleepEvent.wait(1.0)

            # Run until it closes
            if view not in window.views():
                log(1, "Exiting continuous thread...")
                del all_views_active[view.id()]
                return

            elif self.change_count != view.change_count() \
                    and window == sublime.active_window() \
                    and view == window.active_view():

                current_time = time.time()
                self.change_count = view.change_count()

                open_image = self.open_image
                # active_sheet = window.active_sheet()
                # group, view_index = window.get_view_index(view)

                try:
                    process(view, self)

                except plantuml_connection.PlantUMLSyntaxError as error:
                    log(
                        1, "Syntax error on diagram: %s",
                        re.findall(
                            r'X-PlantUML-Diagram-Description:((?:.|\n)*?)X-Powered-By',
                            str(error)))

                # Allowed the image view to be focused on the first time it is opened
                if not open_image:
                    window.focus_view(view)
                    # window.focus_group( group )
                    # window.focus_sheet( active_sheet )

                elapsed_time = time.time() - current_time

            self.sleepEvent.wait(default_time)
예제 #2
0
    def run(self, edit):
        #print("Processing diagrams in %r..." % self.view)
        self.selCurDiagram()

        # Save file name, and use for automatic preview on save
        previewed_files[self.view.file_name()] = True

        if not process(self.view, True):
            error_message("No diagrams overlap selections.\n\n" \
                "Nothing to process.")
예제 #3
0
def process_diagram_image(view):
    all_views_active[view.id()] = view

    try:
        if not process(view):
            sublime.error_message("No diagrams found, nothing to process.")
    except plantuml_connection.PlantUMLSyntaxError as error:
        # TODO show syntax error use mdpop
        sublime.error_message(
            "Syntax error on diagram: %s",
            re.findall(
                r'X-PlantUML-Diagram-Description:((?:.|\n)*?)X-Powered-By',
                str(error)))
예제 #4
0
 def run(self):
     active_view = self.window.active_view()
     if active_view.is_dirty():
         # Save the file so that source and target file on the drive don't differ
         active_view.run_command("save")
         if active_view.is_dirty():
             return error_message("Build Diagrams:\n"
                                  "The file could not be saved correctly. "
                                  "The build was aborted")
     file_path = active_view.file_name()
     if not file_path:
         return error_message("Build Diagrams: \n" "File does not exist!")
     scope = active_view.scope_name(
         active_view.sel()[0].begin()).split(' ')[0]
     if scope != 'source.wsd':
         return error_message("Build Diagrams: \n" "Not a diagram file!")
     if not process(active_view, False):
         return error_message("No diagrams overlap selections.\n\n" \
             "Nothing to process.")
 def run(self):
     active_view = self.window.active_view()
     if active_view.is_dirty():
         # Save the file so that source and target file on the drive don't differ
         active_view.run_command("save")
         if active_view.is_dirty():
             return error_message("Build Diagrams:\n"
                                  "The file could not be saved correctly. "
                                  "The build was aborted")
     file_path = active_view.file_name()
     if not file_path:
         return error_message("Build Diagrams: \n"
                              "File does not exist!")
     scope=active_view.scope_name(active_view.sel()[0].begin()).split(' ')[0]
     if scope != 'source.wsd':
         return error_message("Build Diagrams: \n"
                              "Not a diagram file!")
     if not process(active_view, False):
         return error_message("No diagrams overlap selections.\n\n" \
             "Nothing to process.")
예제 #6
0
 def run(self, edit):
     print "Processing diagrams in %r..." % self.view
     if not process(self.view):
         error_message("No diagrams overlap selections.\n\n" \
             "Nothing to process.")
예제 #7
0
 def run(self, edit):
     print("Processing diagrams in %r..." % self.view)
     if not process(self.view):
         error_message("No diagrams overlap selections.\n\n" \
             "Nothing to process.")
예제 #8
0
 def run(self, edit):
     if not process(self.view):
         error_message("No diagrams overlap selections.\n\n" \
             "Nothing to process.")
예제 #9
0
    def on_post_save(self, view):

        if view.file_name() in previewed_files:
            if not process(view, True, True):
                error_message("No diagrams overlap selections.\n\n" \
                    "Nothing to process.")
예제 #10
0
def process_diagram_image(view):
    log(1, "Processing diagrams in %s...", view.file_name())

    if not process(view):
        error_message("No diagrams overlap selections.\n\n" \
            "Nothing to process.")
 def run(self, edit, output):
     g_output.g_output = output
     print("Processing diagrams in %r..." % self.view)
     if not process(self.view):
         error_message("No diagrams overlap selections.\n\n" \
             "Nothing to process.")