def do_update(self,library):

        sublime.status_message("Please wait, updating haxelib " + library);

        settings = self.window.active_view().settings()
        haxelib_path = settings.get("haxelib_path","haxelib")

        out,err = runcmd([haxelib_path , "update", library]);
        sublime.status_message(str(out))
        show_quick_panel(self.window, out.splitlines(), None)
    def on_lib_select(self, index):
        if(index < 1):
            return

        name = self.libs[index]
        self.selected = name

        menu = []
        menu.append( ["Info", "haxelib info " + name] )
        menu.append( ["Install", "haxelib install " + name] )

        show_quick_panel(self.window, menu, self.on_action_selected)
    def run(self):
        win = self.window
        view = win.active_view()

        if view is None or view.is_loading() or not is_haxe_scope(view):
            return

        self.context = get_context(view)

        if not self.context.type:
            return

        method_names = {'new': True}
        for methodCtx in self.context.type.methods:
            method_names[methodCtx.name] = True
        tmp_name = '__sublime_tmp_method__'
        method_names[tmp_name] = True

        win.run_command(
            'haxe_override_method_edit',
            {'pos': self.context.type.block.begin(), 'name': tmp_name})

        complete = HaxeComplete_inst()
        temp = complete.save_temp_file(view)
        _, _, _, _, fields = complete.run_haxe(view, dict(
            mode=None,
            filename=view.file_name(),
            offset=0,
            commas=None))
        complete.clear_temp_file(view, temp)

        win.run_command('undo')

        self.methods = []
        for field in fields:
            name = field[0]
            args = field[1]
            if args is None or name in method_names:
                continue
            self.methods.append(field)

        options = []
        for method in self.methods:
            options.append('%s()' % method[0])

        show_quick_panel(
            win, options, self.on_select, sublime.MONOSPACE_FONT, 0)
    def prompt_classes_to_import(self):
        impname = self.missing_impnames_to_prompt[-1]
        options = []

        for package in HaxeOrganizeImports.build_type_map[impname]:
            if package == '':
                self.missing_impnames_to_prompt.pop()
                if not self.missing_impnames_to_prompt:
                    self.complete_adding_unimported_classes()
                else:
                    self.prompt_classes_to_import()
                return
            options.append('import %s' % get_full_imp(package, impname))

        show_quick_panel(
            self.window, options, self.on_select_class_to_import,
            sublime.MONOSPACE_FONT, 0)
    def do_action(self, action, library):

        settings = self.window.active_view().settings()
        haxelib_path = settings.get("haxelib_path", "haxelib")

        out, err = runcmd([haxelib_path, action, self.selected])
        lines = out.splitlines()

        # the description can be rather long,
        # so we just split it up some
        if action == "install":

            show_quick_panel(self.window, lines, None)
            return

        if action == "info":
            max_length = 60

            #store the desc
            desc = lines[2]
            #remove it from the list
            del lines[2]

            #wrap it neatly
            descsplit = textwrap.wrap(desc, max_length)

            #now replace the Desc: into it's own line
            descsplit[0] = descsplit[0].replace('Desc: ', '')
            descsplit.append('')
            descsplit.reverse()

            #reinsert
            for d in descsplit:
                lines.insert(2, "\t\t" + d)

            #and the desc header
            lines.insert(2, 'Desc: ')

        for index, line in enumerate(lines):
            length = len(line)
            if (length > max_length):
                split_lines = textwrap.wrap(line, max_length)
                lines[index] = split_lines[0] + ' ...'

        show_quick_panel(self.window, lines, None)
    def do_action(self,action,library):

        settings = self.window.active_view().settings()
        haxelib_path = settings.get("haxelib_path","haxelib")

        out,err = runcmd([ haxelib_path , action, self.selected]);
        lines = out.splitlines()

        # the description can be rather long,
        # so we just split it up some
        if action == "install":

            show_quick_panel(self.window,lines,None)
            return

        if action == "info":
            max_length = 60

            #store the desc
            desc = lines[2]
            #remove it from the list
            del lines[2]

            #wrap it neatly
            descsplit = textwrap.wrap(desc,max_length)

            #now replace the Desc: into it's own line
            descsplit[0] = descsplit[0].replace('Desc: ','')
            descsplit.append('')
            descsplit.reverse()

            #reinsert
            for d in descsplit:
                lines.insert(2,"\t\t"+d)

            #and the desc header
            lines.insert(2, 'Desc: ')

        for index, line in enumerate(lines):
            length = len(line)
            if(length > max_length):
                split_lines = textwrap.wrap(line,max_length)
                lines[index] = split_lines[0] + ' ...'

        show_quick_panel(self.window,lines,None)
    def prompt_imports_to_remove(self, selected_index=0):
        if not self.imp_to_remove_map:
            if self.add:
                self.add_unimported_classes()
            else:
                self.complete_command()
            return

        options = []
        options.append('Done')
        options.append('Check All')
        options.append('Uncheck All')

        sorted_imps = sorted(self.imp_to_remove_map.keys())
        for imp in sorted_imps:
            options.append('[%s] remove %s' %
                           ('x' if self.imp_to_remove_map[imp] else ' ', imp))

        show_quick_panel(self.window, options, self.on_select_import_to_remove,
                         sublime.MONOSPACE_FONT, selected_index)
    def run(self):

        settings = self.window.active_view().settings()
        haxelib_path = settings.get("haxelib_path", "haxelib")

        out, err = runcmd([haxelib_path, "search"], " \n \n \n")
        lines = out.splitlines()

        if len(lines) > 0:
            #remove the initial prompt
            lines[0] = lines[0].replace("Search word : ", "")

        #sort alphabetically
        lines = sorted(lines, key=str.lower)

        #store for later
        self.libs = lines

        #show list
        show_quick_panel(self.window, lines, self.on_lib_select)
    def run(self):

        settings = self.window.active_view().settings()
        haxelib_path = settings.get("haxelib_path","haxelib")

        out,err = runcmd([ haxelib_path , "search"], " \n \n \n");
        lines = out.splitlines()

        if len(lines) > 0 :
            #remove the initial prompt
            lines[0] = lines[0].replace("Search word : ","")

        #sort alphabetically
        lines = sorted( lines , key = str.lower )

        #store for later
        self.libs = lines

        #show list
        show_quick_panel(self.window,lines,self.on_lib_select)
    def prompt_imports_to_remove(self, selected_index=0):
        if not self.imp_to_remove_map:
            if self.add:
                self.add_unimported_classes()
            else:
                self.complete_command()
            return

        options = []
        options.append('Done')
        options.append('Check All')
        options.append('Uncheck All')

        sorted_imps = sorted(self.imp_to_remove_map.keys())
        for imp in sorted_imps:
            options.append(
                '[%s] remove %s' %
                ('x' if self.imp_to_remove_map[imp] else ' ', imp))

        show_quick_panel(
            self.window, options, self.on_select_import_to_remove,
            sublime.MONOSPACE_FONT, selected_index)