aboutsummaryrefslogtreecommitdiff
path: root/src/console
diff options
context:
space:
mode:
Diffstat (limited to 'src/console')
-rw-r--r--src/console/Completions.ts6
-rw-r--r--src/console/completion/hooks.ts50
-rw-r--r--src/console/components/console/Completion.tsx8
-rw-r--r--src/console/components/console/CompletionItem.tsx14
4 files changed, 39 insertions, 39 deletions
diff --git a/src/console/Completions.ts b/src/console/Completions.ts
index a18f160..b04e480 100644
--- a/src/console/Completions.ts
+++ b/src/console/Completions.ts
@@ -1,9 +1,9 @@
type Completions = {
readonly name: string;
readonly items: {
- readonly caption?: string;
- readonly content?: string;
- readonly url?: string;
+ readonly primary?: string;
+ readonly secondary?: string;
+ readonly value?: string;
readonly icon?: string;
}[];
}[];
diff --git a/src/console/completion/hooks.ts b/src/console/completion/hooks.ts
index 4402b70..ad315e6 100644
--- a/src/console/completion/hooks.ts
+++ b/src/console/completion/hooks.ts
@@ -74,9 +74,9 @@ const getCommandCompletions = async (query: string): Promise<Completions> => {
const items = Object.entries(commandDocs)
.filter(([name]) => name.startsWith(query))
.map(([name, doc]) => ({
- caption: name,
- content: name,
- url: doc,
+ primary: name,
+ secondary: doc,
+ value: name,
}));
return [
{
@@ -102,8 +102,8 @@ const getOpenCompletions = async (
completions.push({
name: "Search Engines",
items: items.map((key) => ({
- caption: key.title,
- content: command + " " + key.title,
+ primary: key.title,
+ value: command + " " + key.title,
})),
});
break;
@@ -116,9 +116,9 @@ const getOpenCompletions = async (
completions.push({
name: "History",
items: items.map((item) => ({
- caption: item.title,
- content: command + " " + item.url,
- url: item.url,
+ primary: item.title,
+ secondary: item.url,
+ value: command + " " + item.url,
})),
});
break;
@@ -131,9 +131,9 @@ const getOpenCompletions = async (
completions.push({
name: "Bookmarks",
items: items.map((item) => ({
- caption: item.title,
- content: command + " " + item.url,
- url: item.url,
+ primary: item.title,
+ secondary: item.url,
+ value: command + " " + item.url,
})),
});
break;
@@ -157,11 +157,11 @@ export const getTabCompletions = async (
{
name: "Buffers",
items: items.map((item) => ({
- content: command + " " + item.url,
- caption: `${item.index}: ${
+ primary: `${item.index}: ${
item.flag != TabFlag.None ? item.flag : " "
} ${item.title}`,
- url: item.url,
+ secondary: item.url,
+ value: command + " " + item.url,
icon: item.faviconUrl,
})),
},
@@ -179,28 +179,28 @@ export const getPropertyCompletions = async (
if (item.type === "boolean") {
return [
{
- caption: item.name,
- content: command + " " + item.name,
- url: "Enable " + desc,
+ primary: item.name,
+ secondary: "Enable " + desc,
+ value: command + " " + item.name,
},
{
- caption: "no" + item.name,
- content: command + " no" + item.name,
- url: "Disable " + desc,
+ primary: "no" + item.name,
+ secondary: "Disable " + desc,
+ value: command + " no" + item.name,
},
];
} else {
return [
{
- caption: item.name,
- content: command + " " + item.name,
- url: "Set " + desc,
+ primary: item.name,
+ secondary: "Set " + desc,
+ value: command + " " + item.name,
},
];
}
})
.reduce((acc, val) => acc.concat(val), [])
- .filter((item) => item.caption.startsWith(query));
+ .filter((item) => item.primary.startsWith(query));
return [{ name: "Properties", items }];
};
@@ -308,7 +308,7 @@ export const useSelectCompletion = () => {
return state.completionSource;
}
const items = state.completions.map((g) => g.items).flat();
- return items[state.select]?.content || "";
+ return items[state.select]?.value || "";
}, [state.completionSource, state.select]);
return {
diff --git a/src/console/components/console/Completion.tsx b/src/console/components/console/Completion.tsx
index ed271aa..6a58a40 100644
--- a/src/console/components/console/Completion.tsx
+++ b/src/console/components/console/Completion.tsx
@@ -4,8 +4,8 @@ import CompletionTitle from "./CompletionTitle";
interface Item {
icon?: string;
- caption?: string;
- url?: string;
+ primary?: string;
+ secondary?: string;
}
interface Group {
@@ -75,8 +75,8 @@ const Completion: React.FC<Props> = ({ select, size, completions }) => {
shown={viewOffset <= viewIndex && viewIndex < viewOffset + size}
key={`item-${itemIndex}`}
icon={item.icon}
- caption={item.caption}
- url={item.url}
+ primary={item.primary}
+ secondary={item.secondary}
highlight={itemIndex === select}
aria-selected={itemIndex === select}
role="menuitem"
diff --git a/src/console/components/console/CompletionItem.tsx b/src/console/components/console/CompletionItem.tsx
index 2de1375..394af04 100644
--- a/src/console/components/console/CompletionItem.tsx
+++ b/src/console/components/console/CompletionItem.tsx
@@ -23,14 +23,14 @@ const Container = styled.li<{
white-space: pre;
`;
-const Caption = styled.span`
+const Primary = styled.span`
display: inline-block;
width: 40%;
text-overflow: ellipsis;
overflow: hidden;
`;
-const Description = styled.span`
+const Secondary = styled.span`
display: inline-block;
color: ${({ theme }) => theme.completionItemDescriptionForeground};
width: 60%;
@@ -41,19 +41,19 @@ const Description = styled.span`
interface Props extends React.HTMLAttributes<HTMLElement> {
shown: boolean;
highlight: boolean;
- caption?: string;
- url?: string;
+ primary?: string;
+ secondary?: string;
icon?: string;
}
const CompletionItem: React.FC<Props> = (props) => (
<Container
icon={props.icon || ""}
- aria-labelledby={`completion-item-${props.caption}`}
+ aria-labelledby={`completion-item-${props.primary}`}
{...props}
>
- <Caption id={`completion-item-${props.caption}`}>{props.caption}</Caption>
- <Description>{props.url}</Description>
+ <Primary id={`completion-item-${props.primary}`}>{props.primary}</Primary>
+ <Secondary>{props.secondary}</Secondary>
</Container>
);