Skip to content

Commit

Permalink
feat: allow terminal search feature to be disabled
Browse files Browse the repository at this point in the history
This also restores the default terminal font size.
  • Loading branch information
starpit committed Oct 6, 2022
1 parent 50cc373 commit cc83582
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
21 changes: 11 additions & 10 deletions plugins/plugin-codeflare/src/components/RestartableTerminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { PassThrough } from "stream"
import { Loading } from "@kui-shell/plugin-client-common"
import { Arguments, Job, isResizable } from "@kui-shell/core"

import Terminal from "./Terminal"
import Terminal, { TerminalOptions } from "./Terminal"

/**
* This is our impl of the `watch` property that our Terminal
Expand All @@ -34,16 +34,17 @@ function watch(stream: PassThrough, job: Job) {
}
}

export type Props = Pick<Arguments, "tab" | "REPL"> & {
/** Execute this command line */
cmdline: string
export type Props = Pick<Arguments, "tab" | "REPL"> &
TerminalOptions & {
/** Execute this command line */
cmdline: string

/** Execute the given `cmdline` with this set of environment variables */
env: Record<string, string>
/** Execute the given `cmdline` with this set of environment variables */
env: Record<string, string>

/** Callback when the underlying PTY exits */
onExit?(code: number): void
}
/** Callback when the underlying PTY exits */
onExit?(code: number): void
}

type State = {
startCount?: number
Expand Down Expand Up @@ -134,7 +135,7 @@ export default class RestartableTerminal extends React.PureComponent<Props, Stat
className="kui--inverted-color-context flex-fill flex-layout flex-align-stretch"
style={{ backgroundColor: "var(--color-sidecar-background-02)" }}
>
<Terminal watch={watch} key={key} />
<Terminal watch={watch} key={key} searchable={this.props.searchable} />
</div>
)
}
Expand Down
11 changes: 8 additions & 3 deletions plugins/plugin-codeflare/src/components/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ type ClassName = {
className?: string
}

interface Props extends ClassName {
export type TerminalOptions = ClassName & {
/** Show search ui? [default: true] */
searchable?: boolean
}

type Props = TerminalOptions & {
/** If given, the initial terminal output to render */
initialContent?: string

Expand Down Expand Up @@ -257,7 +262,7 @@ export default class XTerm extends React.PureComponent<Props, State> {
const standIn = document.querySelector("body .repl")
if (standIn) {
const fontTheme = getComputedStyle(standIn)
xterm.options.fontSize = (parseInt(fontTheme.fontSize.replace(/px$/, ""), 10) * 16) / 14
xterm.options.fontSize = parseInt(fontTheme.fontSize.replace(/px$/, ""), 10)
// terminal.setOption('lineHeight', )//parseInt(fontTheme.lineHeight.replace(/px$/, ''), 10))

// FIXME. not tied to theme
Expand Down Expand Up @@ -342,7 +347,7 @@ export default class XTerm extends React.PureComponent<Props, State> {
<Toolbar className="codeflare--toolbar">
<ToolbarContent className="flex-fill">
<ToolbarItem variant="search-filter" className="flex-fill">
{this.searchInput()}
{this.props.searchable !== false && this.searchInput()}
</ToolbarItem>
</ToolbarContent>
</Toolbar>
Expand Down
4 changes: 2 additions & 2 deletions plugins/plugin-codeflare/src/controller/terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function shell(args: Arguments) {
}
}

export type Props = Pick<BaseProps, "tab" | "REPL" | "onExit"> & {
export type Props = Pick<BaseProps, "tab" | "REPL" | "onExit" | "searchable"> & {
/** Default guidebook (if not given, we will take the value from the client definition) */
defaultGuidebook?: string

Expand Down Expand Up @@ -96,7 +96,7 @@ export class TaskTerminal extends React.PureComponent<Props, State> {
private readonly splits = {
horizontal: [35, 65],
vertical1: [100], // no `this.props.belowTerminal`
vertical2: [50, 50], // yes
vertical2: [40, 60], // yes
}

private readonly tasks = [{ label: "Run a Job", argv: ["codeflare", "-p", "${SELECTED_PROFILE}"] }]
Expand Down

0 comments on commit cc83582

Please sign in to comment.