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

Feature/add search icon commandline #1230

Merged
merged 36 commits into from
Jan 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6666f80
Rework styling to match quickopen menu
akinsho Dec 23, 2017
8e5624b
Render wild menu into the stack layer
akinsho Dec 23, 2017
5279e25
Reduce padding
akinsho Dec 23, 2017
ebea06d
Compose wild menu with commandline
akinsho Dec 23, 2017
686f823
Configure wild menu and commandline
akinsho Dec 23, 2017
a20d048
Render components separately inside of common
akinsho Dec 23, 2017
132e7f4
Attempt to manually place external menus not working
akinsho Dec 23, 2017
343ad5b
add space to constructor
akinsho Dec 23, 2017
8f00c2a
Add timeout to prevent flickering of cmdline
akinsho Dec 23, 2017
d22090f
revert changes to neovim surface
akinsho Dec 24, 2017
24f6491
Merge branch 'master' of github.com:onivim/oni into restyle-wild-menu
akinsho Dec 24, 2017
21c3c0a
wire up setcursor actions
akinsho Dec 24, 2017
8f59329
Add a cursor to commandline
akinsho Dec 24, 2017
627bae0
Remove excess space
akinsho Dec 24, 2017
4c7b902
Remove refs from commandline components
akinsho Dec 24, 2017
909c72b
re-add focus as this is essential for functionality
akinsho Dec 24, 2017
02533be
important: fix html trimming whitespace bug
akinsho Dec 24, 2017
38a4f39
add in the prompt segment
akinsho Dec 25, 2017
207e3eb
fix overflow styling
akinsho Dec 25, 2017
1de13c0
add pointer events but not selection
akinsho Dec 25, 2017
66deb2f
Add overflow handling for command line
akinsho Dec 25, 2017
07889c7
minor change to comment position
akinsho Dec 25, 2017
252a087
adjust cursor position
akinsho Dec 26, 2017
e8d1a1d
re-add missing max width
akinsho Dec 26, 2017
d2104c4
re-arrange css to rerun tests
akinsho Dec 26, 2017
9530640
re-arrange css again..
akinsho Dec 26, 2017
ae0a496
Merge branch 'master' of github.com:onivim/oni into restyle-wild-menu
akinsho Jan 3, 2018
059ec25
reduce timeout to 80ms
akinsho Jan 3, 2018
189ee2b
Add spurious CR to rerun test
akinsho Jan 3, 2018
9346cf9
Merge branch 'master' into restyle-wild-menu
akinsho Jan 4, 2018
fa48142
merge upstream fix neovimeditor reducer conflicts
akinsho Jan 4, 2018
ec1ba62
merge upstream branch
akinsho Jan 4, 2018
01ac2c3
Merge branch 'master' into restyle-wild-menu
akinsho Jan 4, 2018
9555200
Add icons to replace the first character
akinsho Jan 4, 2018
0cec01a
Add configuration to show and hide icons
akinsho Jan 4, 2018
813c262
Merge branch 'master' of github.com:onivim/oni into feature/add-searc…
akinsho Jan 4, 2018
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
1 change: 1 addition & 0 deletions browser/src/Services/Configuration/DefaultConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const BaseConfiguration: IConfigurationValues = {

"experimental.editor.textMateHighlighting.enabled": false,
"experimental.commandline.mode": false,
"experimental.commandline.icons": false,
"experimental.wildmenu.mode": false,

"experimental.neovim.transport": "stdio",
Expand Down
2 changes: 2 additions & 0 deletions browser/src/Services/Configuration/IConfigurationValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export interface IConfigurationValues {
// The transport to use for Neovim
// Valid values are "stdio" and "pipe"
"experimental.neovim.transport": string
"experimental.commandline.mode": boolean,
"experimental.commandline.icons": boolean,

"autoClosingPairs.enabled": boolean
"autoClosingPairs.default": any
Expand Down
79 changes: 67 additions & 12 deletions browser/src/UI/components/CommandLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from "react"
import { connect } from "react-redux"
import styled from "styled-components"

import { Icon } from "./../../UI/Icon"
import { fadeInAndDown } from "./animations"
import { boxShadow } from "./common"

Expand Down Expand Up @@ -41,7 +42,17 @@ const Cursor = styled.span`
height: 1.3em;
`

const IconContainer = styled.span`
margin-right: 0.5em;
`

const ArrowContainer = styled.span`
font-size: 0.7em;
margin-right: 0.6em;
`

export interface ICommandLineRendererProps {
showIcons: boolean
visible: boolean
content: string
position: number
Expand All @@ -55,6 +66,18 @@ interface State {
waiting: boolean
}

const CommandLineIcon = (props: { iconName: string; arrow?: boolean }) => (
<span>
{!props.arrow ? (
<Icon name={props.iconName} />
) : (
<ArrowContainer>
<Icon name={props.iconName} />
</ArrowContainer>
)}
</span>
)

class CommandLine extends React.PureComponent<ICommandLineRendererProps, State> {
public state = {
focused: false,
Expand All @@ -76,12 +99,42 @@ class CommandLine extends React.PureComponent<ICommandLineRendererProps, State>
}
}

public renderIconOrChar(character: string) {
if (!this.props.showIcons) {
return character
}
switch (character) {
case "/":
return [
<CommandLineIcon iconName="search" key={`${character}-search`} />,
<CommandLineIcon
arrow
iconName="arrow-right"
key={`${character}-arrow-right`}
/>,
]
case ":":
return (
<IconContainer>
<CommandLineIcon iconName="file-code-o" />
</IconContainer>
)
case "?":
return [
<CommandLineIcon iconName="search" key={`${character}-search`} />,
<CommandLineIcon key={`${character}-arrow-left`} arrow iconName="arrow-left" />,
]
default:
return character
}
}

public componentWillUnmount() {
clearTimeout(this.timer)
}

public render(): null | JSX.Element {
const { visible, content, position } = this.props
const { visible, content, position, firstchar } = this.props
const { focused, waiting } = this.state
if (!focused && visible && this._inputElement) {
this._inputElement.focus()
Expand All @@ -96,7 +149,7 @@ class CommandLine extends React.PureComponent<ICommandLineRendererProps, State>
visible && (
<CommandLineBox>
<CommandLineOutput innerRef={e => (this._inputElement = e)}>
{this.props.firstchar}
{this.renderIconOrChar(firstchar)}
{this.props.prompt}
{beginning}
<Cursor />
Expand All @@ -108,15 +161,17 @@ class CommandLine extends React.PureComponent<ICommandLineRendererProps, State>
}
}

const mapStateToProps = ({
commandLine: { visible, position, content, firstchar, level, prompt },
}: State.IState) => ({
visible,
content,
firstchar,
position,
level,
prompt,
})
const mapStateToProps = ({ commandLine, configuration }: State.IState) => {
const { visible, position, content, firstchar, level, prompt } = commandLine
return {
showIcons: configuration["experimental.commandline.icons"],
visible,
content,
firstchar,
position,
level,
prompt,
}
}

export default connect<ICommandLineRendererProps>(mapStateToProps)(CommandLine)