diff --git a/src/editor/EditorManager.js b/src/editor/EditorManager.js index cad78b89af6..d4ed9d02639 100644 --- a/src/editor/EditorManager.js +++ b/src/editor/EditorManager.js @@ -614,7 +614,7 @@ define(function (require, exports, module) { } function _updateModeInfo(editor) { - $modeInfo.text(editor.getModeForSelection()); + $modeInfo.text(StatusBar.getModeDisplayString(editor.getModeForSelection())); } function _updateFileInfo(editor) { diff --git a/src/widgets/StatusBar.js b/src/widgets/StatusBar.js index 3281c25d548..3c4f594cd63 100644 --- a/src/widgets/StatusBar.js +++ b/src/widgets/StatusBar.js @@ -180,12 +180,59 @@ define(function (require, exports, module) { // hide on init hide(); } + + function getModeDisplayString(mode) { + // mode is either a string or an object with a name property string + var s = (typeof mode === "string") ? mode : mode.name, + slash, + result; + + s = s.toLowerCase(); + + // Handle special cases + if (s === "javascript") { + return "JavaScript"; + } else if (s === "html") { + return "HTML"; + } else if (s === "css") { + return "CSS"; + } else if (s === "less") { + return "LESS"; + } else if (s === "text/plain") { + return "Text"; + } else if (s === "php") { + return "PHP"; + } else if (s === "xml") { + return "XML"; + } + + // Generic case + + // Strip "text/" or "application/" from beginning + s = s.replace(/^(text\/|application\/)/, ""); + + // Strip "x-" from beginning + s = s.replace(/^x-/, ""); + + // Strip any remaining "/" sections from end + slash = s.indexOf("/"); + if (slash !== -1) { + s = s.substr(0, slash); + } + + // Uppercase first char and rest is (already) lowercase + result = s[0].toUpperCase(); + result += s.substr(1); + + return result; + } exports.init = init; exports.showBusyIndicator = showBusyIndicator; exports.hideBusyIndicator = hideBusyIndicator; exports.addIndicator = addIndicator; exports.updateIndicator = updateIndicator; + exports.getModeDisplayString = getModeDisplayString; exports.hide = hide; exports.show = show; }); \ No newline at end of file