当有多个具有相同名称的文件时,在选项卡中显示文件路径

时间:2013-09-12 11:00:07

标签: filepath user-experience komodoedit tabbed name-collision

请查看截图:

enter image description here

正如您所看到的,有3个选项卡,其中打开了3个不同的“index.xml”文件。 我一直在寻找一个选项,在选项卡名称中显示类似“folder / file.extension”的内容,以便能够区分文件,但我找不到任何内容。

使用“转到文件”也不是很有用,因为所有文件的路径名都很长,以至于我看不到包含文件的文件夹。

有什么想法吗?

干杯

更新:

可以使用鼠标增加“转到文件”面板宽度,Komodo将来会记住尺寸。这有帮助!

3 个答案:

答案 0 :(得分:1)

我们专门为此添加了OpenFiles窗格,请查看View>标签&侧边栏>打开文件。

这是我的窗格看起来像几个同名的文件打开:

Open Files Pane

此外,您可以指定自己的模式,目前这是通过宏以编程方式完成的,但将来您可以通过UI完成此操作。

例如,我使用以下宏进行Komodo开发:

ko.openfiles.groupers.byPattern.patterns = [
    {
        name:       'Plat - %match% - config',
        pattern:    /\/skin\/plat\/([a-z0-9_-]*)\/_config\//i
    },
    {
        name:       'Plat - %match%',
        pattern:    /\/skin\/plat\/([a-z0-9_-]*)\//i
    },
    {
        name:       'Module - %match% - skin config',
        pattern:    /\/(?:module|modules)\/([a-z0-9_-]*)\/skin\/_config\//i
    },
    {
        name:       'Module - %match%',
        pattern:    /\/(?:module|modules)\/([a-z0-9_-]*)\//i
    },
    {
        name:       'Skin - %match% - config',
        pattern:    /\/chrome\/skins\/([a-z0-9_-]*)\/_config\//i
    },
    {
        name:       'Skin - %match%',
        pattern:    /\/chrome\/skins\/([a-z0-9_-]*)\//i
    },
    {
        name:       'Iconset - %match%',
        pattern:    /\/chrome\/iconsets\/([a-z0-9_-]*)\//i
    },
    {
        name:       'Component - %match%',
        pattern:    /\/(?:component|components)\/([a-z0-9_-]*)/i
    },
    {
        name:       'Locale',
        pattern:    /\/locale(?:\/|$)/i
    },
    {
        name:       'Skin',
        pattern:    /\/skin(?:\/|$)/i
    },
    {
        name:       'Module',
        pattern:    /\/(?:module|modules)(?:\/|$)/i
    },
    {
        name:       'Component',
        pattern:    /\/(?:component|components)(?:\/|$)/i
    },
];

ko.openfiles.reload(true);

您可以在此处阅读宏:http://docs.activestate.com/komodo/8.5/macros.html#macros_writing

使用上面的宏我需要确保选择了“按模式分组”选项,然后我只运行宏,你在上面的截图中看到的相同文件将根据我指定的模式进行分组: / p>

openfiles pane with patterns

请注意,这需要最新版本的Komodo(8.5)。

另请注意,如果您使用“打开文件”窗格,您可能会发现不再需要常规选项卡,您可以在“查看>视图编辑器选项卡”下禁用这些选项卡。

希望有所帮助,祝你好运!

答案 1 :(得分:0)

使用Komodo JavaScript API更改标签标题的默认显示:

komodo.assertMacroVersion(3);

function changeTabTitles(useLongerTitle, splitLength) {
try {
    var vm = ko.views.manager.topView;
    var box = document.getAnonymousNodes(vm)[0];

    // Get the views-tabbed elements.
    var topTabs = box.firstChild;
    var bottomTabs = box.lastChild;

    if (!useLongerTitle) {
        // Restore the original functionality.
        if (topTabs._tweakui_updateLeafName) {
            topTabs.updateLeafName = topTabs._tweakui_updateLeafName;
            topTabs._tweakui_updateLeafName = null;
        }
        if (bottomTabs._tweakui_updateLeafName) {
            bottomTabs.updateLeafName = bottomTabs._tweakui_updateLeafName;
            bottomTabs._tweakui_updateLeafName = null;
        }

    } else {
        // Save the original functionality.
        if (!topTabs._tweakui_updateLeafName)
            topTabs._tweakui_updateLeafName = topTabs.updateLeafName;
        if (!bottomTabs._tweakui_updateLeafName)
            bottomTabs._tweakui_updateLeafName = bottomTabs.updateLeafName;

        // Replace the updateLeafName implementation to use something
        // different for the tab label.
        var osSvc = Components.classes["@activestate.com/koOs;1"].
                            getService(Components.interfaces.koIOs);
        var dirsep = osSvc.sep;
        topTabs.updateLeafName =
        bottomTabs.updateLeafName = function(view) {
            view.parentNode._tab.label = view.title;
            if (view.document) {
                view.parentNode._tab.setAttribute('crop', 'start');
                var path = view.document.displayPath;
                var sep = dirsep;
                if (path.lastIndexOf(sep) == -1) {
                    // Try using the URI separator.
                    sep = "/";
                }
                var path_split = path.split(sep);
                var l = path_split.length;
                var label = path_split.slice(l-splitLength, l).join(sep);
                view.parentNode._tab.label = label;
                view.parentNode._tab.setAttribute('tooltiptext',view.document.displayPath);
                this.tabbox.firstChild.scrollBoxObject.ensureElementIsVisible(this.tabbox.firstChild.selectedItem);
            }
        }
    }

将其另存为macro并根据自己的喜好进行自定义。

答案 2 :(得分:0)

为Komodo 8.5更新的代码(view.document - > view.koDoc)

komodo.assertMacroVersion(3);

try {
var vm = ko.views.manager.topView;
var box = document.getAnonymousNodes(vm)[0];

// get the views-tabbed elements
var tabset1 = box.firstChild;
var tabset2 = box.lastChild;

// replace the updateLeafName implementation to use something different
// for the tab label

tabset1.updateLeafName =
tabset2.updateLeafName = function(view) {
    view.parentNode._tab.label = view.title;
    if (view.koDoc) {
        var language = view.koDoc.language;
        if (language == 'Python') {
            var parts = view.koDoc.displayPath.split('/');
            var len = parts.length;
            var label = '';
            if (len > 2) {
                label += parts[len-2] + '/';
            }
            label += parts[len-1];

            view.parentNode._tab.setAttribute('crop', 'start');
            view.parentNode._tab.label = label;
            view.parentNode._tab.setAttribute('tooltiptext',view.koDoc.displayPath);
            this.tabbox.firstChild.scrollBoxObject.ensureElementIsVisible(this.tabbox.firstChild.selectedItem);
        }
    }
};

// the "on startup" trigger happens after files
// are opened, so we need to call updateLeafName
// for each opened view.  Files opened after startup
// will be fine
var views = ko.views.manager.topView.getViews(true);
for (var i=0; i < views.length; i++) {
    if (views[i].koDoc) {
        views[i].updateLeafName(views[i]);
    }
}

} catch(e) {
    alert(e);
}