Skip to content

Commit cc83582

Browse files
committedOct 6, 2022
feat: allow terminal search feature to be disabled
This also restores the default terminal font size.
1 parent 50cc373 commit cc83582

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed
 

‎plugins/plugin-codeflare/src/components/RestartableTerminal.tsx

+11-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { PassThrough } from "stream"
1919
import { Loading } from "@kui-shell/plugin-client-common"
2020
import { Arguments, Job, isResizable } from "@kui-shell/core"
2121

22-
import Terminal from "./Terminal"
22+
import Terminal, { TerminalOptions } from "./Terminal"
2323

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

37-
export type Props = Pick<Arguments, "tab" | "REPL"> & {
38-
/** Execute this command line */
39-
cmdline: string
37+
export type Props = Pick<Arguments, "tab" | "REPL"> &
38+
TerminalOptions & {
39+
/** Execute this command line */
40+
cmdline: string
4041

41-
/** Execute the given `cmdline` with this set of environment variables */
42-
env: Record<string, string>
42+
/** Execute the given `cmdline` with this set of environment variables */
43+
env: Record<string, string>
4344

44-
/** Callback when the underlying PTY exits */
45-
onExit?(code: number): void
46-
}
45+
/** Callback when the underlying PTY exits */
46+
onExit?(code: number): void
47+
}
4748

4849
type State = {
4950
startCount?: number
@@ -134,7 +135,7 @@ export default class RestartableTerminal extends React.PureComponent<Props, Stat
134135
className="kui--inverted-color-context flex-fill flex-layout flex-align-stretch"
135136
style={{ backgroundColor: "var(--color-sidecar-background-02)" }}
136137
>
137-
<Terminal watch={watch} key={key} />
138+
<Terminal watch={watch} key={key} searchable={this.props.searchable} />
138139
</div>
139140
)
140141
}

‎plugins/plugin-codeflare/src/components/Terminal.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ type ClassName = {
4949
className?: string
5050
}
5151

52-
interface Props extends ClassName {
52+
export type TerminalOptions = ClassName & {
53+
/** Show search ui? [default: true] */
54+
searchable?: boolean
55+
}
56+
57+
type Props = TerminalOptions & {
5358
/** If given, the initial terminal output to render */
5459
initialContent?: string
5560

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

263268
// FIXME. not tied to theme
@@ -342,7 +347,7 @@ export default class XTerm extends React.PureComponent<Props, State> {
342347
<Toolbar className="codeflare--toolbar">
343348
<ToolbarContent className="flex-fill">
344349
<ToolbarItem variant="search-filter" className="flex-fill">
345-
{this.searchInput()}
350+
{this.props.searchable !== false && this.searchInput()}
346351
</ToolbarItem>
347352
</ToolbarContent>
348353
</Toolbar>

‎plugins/plugin-codeflare/src/controller/terminal.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export async function shell(args: Arguments) {
5454
}
5555
}
5656

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

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.