Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
242 - fix and features (#254)
Browse files Browse the repository at this point in the history
* Changed opacity and added to state

* added opacity config options for CursorLine and CursorColumn

* added some startup logic for cursorline settings
  • Loading branch information
Bret Barkley authored and extr0py committed Feb 25, 2017
1 parent e7e1435 commit b83a467
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 2 deletions.
3 changes: 3 additions & 0 deletions browser/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ const DefaultConfig: any = {
"editor.fullScreenOnStart" : false,

"editor.cursorLine": true,
"editor.cursorLineOpacity" : 0.1,

"editor.cursorColumn": false,
"editor.cursorColumnOpacity": 0.1,
}

const MacConfig: any = {
Expand Down
14 changes: 14 additions & 0 deletions browser/src/UI/ActionCreators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,17 @@ export const showCursorLine = () => ({ type: "SHOW_CURSOR_LINE" })
export const showCursorColumn = () => ({ type: "SHOW_CURSOR_COLUMN" })

export const hideCursorColumn = () => ({ type: "HIDE_CURSOR_COLUMN" })

export const setCursorLineOpacity = (opacity: number) => ({
type: "SET_CURSOR_LINE_OPACITY",
payload: {
opacity,
},
})

export const setCursorColumnOpacity = (opacity: number) => ({
type: "SET_CURSOR_COLUMN_OPACITY",
payload: {
opacity,
},
})
18 changes: 17 additions & 1 deletion browser/src/UI/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ export interface IHideCursorColumnAction {
type: "HIDE_CURSOR_COLUMN"
}

export interface ISetCursorLineOpacityAction {
type: "SET_CURSOR_LINE_OPACITY"
payload: {
opacity: number,
}
}

export interface ISetCursorColumnOpacityAction {
type: "SET_CURSOR_COLUMN_OPACITY"
payload: {
opacity: number,
}
}

export type Action = ISetCursorPositionAction |
IShowSignatureHelpAction |
IHideSignatureHelpAction |
Expand All @@ -154,4 +168,6 @@ export type Action = ISetCursorPositionAction |
IHideCurorLineAction |
IHideCursorColumnAction |
IShowCursorLineAction |
IShowCursorColumnAction
IShowCursorColumnAction |
ISetCursorColumnOpacityAction |
ISetCursorLineOpacityAction
8 changes: 8 additions & 0 deletions browser/src/UI/Reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ export const reducer = (s: State.IState, a: Actions.Action) => {
return Object.assign({}, s, {
cursorColumnVisible: true,
})
case "SET_CURSOR_LINE_OPACITY":
return Object.assign({}, s, {
cursorLineOpacity: a.payload.opacity,
})
case "SET_CURSOR_COLUMN_OPACITY":
return Object.assign({}, s, {
cursorLineOpacity: a.payload.opacity,
})
default:
return Object.assign({}, s, {
autoCompletion: autoCompletionReducer(s.autoCompletion, a), // FIXME: null
Expand Down
5 changes: 5 additions & 0 deletions browser/src/UI/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export interface IState {
popupMenu: null | IMenu
signatureHelp: null | Oni.Plugin.SignatureHelpResult
cursorLineVisible: boolean
cursorLineOpacity: number
cursorColumnVisible: boolean
cursorColumnOpacity: number

// Dimensions of active window, in pixels
activeWindowDimensions: Rectangle
Expand Down Expand Up @@ -69,5 +71,8 @@ export const createDefaultState = () => (<IState>{
height: 0,
},
cursorLineVisible: false,
cursorLineOpacity: 0,
cursorColumnVisible: false,
cursorColumnOpacity: 0,

})
4 changes: 3 additions & 1 deletion browser/src/UI/components/CursorLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ICursorLineRendererProps {
height: number
color: string
visible: boolean
opacity: number
}

export interface ICursorLineProps {
Expand All @@ -34,7 +35,7 @@ class CursorLineRenderer extends React.Component<ICursorLineRendererProps, void>

height: this.props.height.toString() + "px", // Same as cursor
backgroundColor: this.props.color,
opacity: 0.2,
opacity: this.props.opacity,
}

return <div style={cursorStyle} className="cursorLine"></div>
Expand All @@ -49,6 +50,7 @@ const mapStateToProps = (state: State.IState, props: ICursorLineProps) => {
height: props.lineType === "line" ? state.fontPixelHeight : state.activeWindowDimensions.height,
color: state.foregroundColor,
visible: props.lineType === "line" ? state.cursorLineVisible : state.cursorColumnVisible,
opacity: props.lineType === "line" ? state.cursorLineOpacity : state.cursorColumnOpacity,
}
}

Expand Down
8 changes: 8 additions & 0 deletions browser/src/UI/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@ export function hideCursorColumn(): void {
store.dispatch(ActionCreators.hideCursorColumn())
}

export function setCursorLineOpacity(opacity: number): void {
store.dispatch(ActionCreators.setCursorLineOpacity(opacity))
}

export function setCursorColumnOpacity(opacity: number): void {
store.dispatch(ActionCreators.setCursorColumnOpacity(opacity))
}

function render(_state: State.IState): void {
const element = document.getElementById("overlay-ui")
ReactDOM.render(
Expand Down
2 changes: 2 additions & 0 deletions browser/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const start = (args: string[]) => {

const cursorLine = Config.getValue<boolean>("editor.cursorLine")
const cursorColumn = Config.getValue<boolean>("editor.cursorColumn")
UI.setCursorLineOpacity(Config.getValue<number>("editor.cursorLineOpacity"))
UI.setCursorColumnOpacity(Config.getValue<number>("editor.cursorColumnOpacity"))

if (cursorLine) {
UI.showCursorLine()
Expand Down

0 comments on commit b83a467

Please sign in to comment.