Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/components/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Color from 'color';
import hterm from '../hterm';
import Component from '../component';
import { getColorList } from '../utils/colors';
import notify from '../utils/notify';

export default class Term extends Component {

Expand All @@ -28,7 +29,7 @@ export default class Term extends Component {
this.term.prefs_.set('font-family', props.fontFamily);
this.term.prefs_.set('font-size', props.fontSize);
this.term.prefs_.set('font-smoothing', props.fontSmoothing);
this.term.prefs_.set('cursor-color', Color(props.cursorColor).rgbString());
this.term.prefs_.set('cursor-color', this.validateColor(props.cursorColor, 'rgba(255,255,255,0.5)'));
this.term.prefs_.set('enable-clipboard-notice', false);
this.term.prefs_.set('foreground-color', props.foregroundColor);
this.term.prefs_.set('background-color', props.backgroundColor);
Expand Down Expand Up @@ -158,6 +159,15 @@ export default class Term extends Component {
return URL.createObjectURL(blob);
}

validateColor (color, alternative = 'rgb(255,255,255)') {
try {
return Color(color).rgbString();
} catch (err) {
notify(`color "${color}" is invalid`);
}
return alternative;
}

componentWillReceiveProps (nextProps) {
if (this.props.url !== nextProps.url) {
// when the url prop changes, we make sure
Expand Down Expand Up @@ -201,7 +211,7 @@ export default class Term extends Component {
}

if (this.props.cursorColor !== nextProps.cursorColor) {
this.term.prefs_.set('cursor-color', Color(nextProps.cursorColor).rgbString());
this.term.prefs_.set('cursor-color', this.validateColor(nextProps.cursorColor, 'rgba(255,255,255,0.5)'));
}

if (this.props.cursorShape !== nextProps.cursorShape) {
Expand Down