From 7bfa2ef621740710eac05415a4e476ef1b2cccc2 Mon Sep 17 00:00:00 2001 From: Jake Dexheimer Date: Fri, 29 Sep 2017 17:23:31 -0700 Subject: [PATCH] Add support for more clike languages --- components/Carbon.js | 2 +- lib/constants.js | 32 ++++++++++++++++++++++++++++++-- pages/editor.js | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/components/Carbon.js b/components/Carbon.js index 089bf49..072c9fe 100644 --- a/components/Carbon.js +++ b/components/Carbon.js @@ -61,7 +61,7 @@ class Carbon extends React.Component { LANGUAGE_MODE_HASH[detectedLanguage] || LANGUAGE_NAME_HASH[detectedLanguage] if (languageMode) { - this.setState({ language: languageMode.mime ? languageMode.mime : languageMode.mode }) + this.setState({ language: languageMode.mime || languageMode.mode }) } } else { this.setState({ language: props.config.language }) diff --git a/lib/constants.js b/lib/constants.js index 8519a41..6e7c8db 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -79,7 +79,21 @@ export const LANGUAGES = [ }, { name: 'C', - mode: 'clike' + mode: 'clike', + mime: 'text/x-csrc', + short: 'c' + }, + { + name: 'C++', + mode: 'clike', + mime: 'text/x-c++src', + short: 'cpp' + }, + { + name: 'C#', + mode: 'clike', + mime: 'text/x-csharp', + short: 'cs' }, { name: 'Clojure', @@ -157,6 +171,12 @@ export const LANGUAGES = [ name: 'HTML', mode: 'htmlmixed' }, + { + name: 'Java', + mode: 'clike', + mime: 'text/x-java', + short: 'java' + }, { name: 'JavaScript', mode: 'javascript' @@ -200,6 +220,12 @@ export const LANGUAGES = [ mode: 'nimrod', custom: true }, + { + name: 'Objective C', + mode: 'clike', + mime: 'text/x-objectivec', + short: 'objectivec' + }, { name: 'Pascal', mode: 'pascal' @@ -234,7 +260,9 @@ export const LANGUAGES = [ }, { name: 'Scala', - mode: 'clike' + mode: 'clike', + mime: 'text/x-scala', + short: 'scala' }, { name: 'Smalltalk', diff --git a/pages/editor.js b/pages/editor.js index 5e123da..3308020 100644 --- a/pages/editor.js +++ b/pages/editor.js @@ -112,7 +112,7 @@ class Editor extends React.Component { - this.setState({ language: language.mime ? language.mime : language.mode })} + this.setState({ language: language.mime || language.mode })} /> this.setState({ background: color })}