Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1923 from adobe/randy/statusbar-mode
Browse files Browse the repository at this point in the history
Make mode string in statusbar more presentable
  • Loading branch information
RaymondLim committed Oct 24, 2012
2 parents 25c986b + a81b744 commit 4b066af
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/editor/EditorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
47 changes: 47 additions & 0 deletions src/widgets/StatusBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

0 comments on commit 4b066af

Please sign in to comment.