Use fira code in editor (#695)

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2020-12-14 23:58:46 +01:00 committed by GitHub
parent b3288a6666
commit 8ce344512c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 311 additions and 113 deletions

View file

@ -11,6 +11,7 @@ import {
EditorConfig,
EditorConfigActionType,
SetEditorConfigAction,
SetEditorLigaturesAction,
SetEditorPreferencesAction,
SetEditorSyncScrollAction
} from './types'
@ -52,12 +53,18 @@ export const setEditorSyncScroll = (syncScroll: boolean): void => {
store.dispatch(action)
}
export const setEditorPreferences = (preferences: EditorConfiguration): void => {
export const setEditorLigatures = (ligatures: boolean): void => {
const action: SetEditorLigaturesAction = {
type: EditorConfigActionType.SET_LIGATURES,
ligatures: ligatures
}
store.dispatch(action);
}
export const mergeEditorPreferences = (preferences: EditorConfiguration): void => {
const action: SetEditorPreferencesAction = {
type: EditorConfigActionType.SET_EDITOR_PREFERENCES,
preferences: {
...preferences
}
type: EditorConfigActionType.MERGE_EDITOR_PREFERENCES,
preferences: preferences
}
store.dispatch(action)
}

View file

@ -12,12 +12,14 @@ import {
EditorConfigActions,
EditorConfigActionType,
SetEditorConfigAction,
SetEditorLigaturesAction,
SetEditorPreferencesAction,
SetEditorSyncScrollAction
} from './types'
const initialState: EditorConfig = {
editorMode: EditorMode.BOTH,
ligatures: true,
syncScroll: true,
preferences: {
theme: 'one-dark',
@ -28,7 +30,7 @@ const initialState: EditorConfig = {
}
const getInitialState = (): EditorConfig => {
return loadFromLocalStorage() ?? initialState
return { ...initialState, ...loadFromLocalStorage() }
}
export const EditorConfigReducer: Reducer<EditorConfig, EditorConfigActions> = (state: EditorConfig = getInitialState(), action: EditorConfigActions) => {
@ -48,10 +50,19 @@ export const EditorConfigReducer: Reducer<EditorConfig, EditorConfigActions> = (
}
saveToLocalStorage(newState)
return newState
case EditorConfigActionType.SET_EDITOR_PREFERENCES:
case EditorConfigActionType.SET_LIGATURES:
newState = {
...state,
preferences: (action as SetEditorPreferencesAction).preferences
ligatures: (action as SetEditorLigaturesAction).ligatures
}
saveToLocalStorage(newState)
return newState
case EditorConfigActionType.MERGE_EDITOR_PREFERENCES:
newState = {
...state,
preferences: {
...state.preferences, ...(action as SetEditorPreferencesAction).preferences
}
}
saveToLocalStorage(newState)
return newState

View file

@ -11,12 +11,14 @@ import { EditorMode } from '../../components/editor/app-bar/editor-view-mode'
export enum EditorConfigActionType {
SET_EDITOR_VIEW_MODE = 'editor/mode/set',
SET_SYNC_SCROLL = 'editor/syncScroll/set',
SET_EDITOR_PREFERENCES = 'editor/preferences/set'
MERGE_EDITOR_PREFERENCES = 'editor/preferences/merge',
SET_LIGATURES = 'editor/preferences/setLigatures'
}
export interface EditorConfig {
editorMode: EditorMode;
syncScroll: boolean;
ligatures: boolean
preferences: EditorConfiguration
}
@ -28,6 +30,10 @@ export interface SetEditorSyncScrollAction extends EditorConfigActions {
syncScroll: boolean
}
export interface SetEditorLigaturesAction extends EditorConfigActions {
ligatures: boolean
}
export interface SetEditorConfigAction extends EditorConfigActions {
mode: EditorMode
}