Skip to content

Commit

Permalink
feat: observer for useEditorFont
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Aug 5, 2020
1 parent 45f6464 commit d117b17
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
14 changes: 11 additions & 3 deletions spec/config-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,20 @@ describe('Call to maximumFontSize', () => {
})
})

describe('Call to fontFamily()', () => {
it('return the same font of the editor', () => {
describe('fontFamily test', () => {
it('uses editor\'s font', () => {
atom.config.set('x-terminal.terminalSettings.useFontEditor', true)
expect(resetConfigDefaults().fontFamily).toBe(atom.config.get('editor.fontFamily'))
})

it('uses the font set manually', () => {
atom.config.set('x-terminal.terminalSettings.useFontEditor', false)
atom.config.set('editor.fontFamily', 'Cascadia Code PL')
expect(resetConfigDefaults().fontFamily).toBe('Cascadia Code PL')
})
it('return \'monospace\' when the editor font is not set', () => {

it('uses \'monospace\' when the editor font is not set', () => {
atom.config.set('x-terminal.terminalSettings.useFontEditor', false)
atom.config.set('editor.fontFamily', '')
expect(resetConfigDefaults().fontFamily).toBe('monospace')
})
Expand Down
1 change: 1 addition & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function resetConfigDefaults () {
// NOTE: Atom will crash if the font is set below 8.
minimumFontSize: 8,
maximumFontSize: 100,
useEditorFont: true,
fontFamily: atom.config.get('editor.fontFamily') || 'monospace',
theme: 'Custom',
colorForeground: '#ffffff',
Expand Down
7 changes: 7 additions & 0 deletions src/x-terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ class XTerminalSingleton {
'x-terminal:copy': () => this.copy(),
'x-terminal:paste': () => this.paste(),
}),

// font config observer
atom.config.observe('x-terminal.terminalSettings.useEditorFont', (useEditorFont) => {
if (useEditorFont) {
atom.config.set('x-terminal.terminalSettings.fontFamily', atom.config.get('editor.fontFamily'))
}
}),
)
}

Expand Down

0 comments on commit d117b17

Please sign in to comment.