add keyboard tip for apis

This commit is contained in:
end-4
2024-01-23 12:03:58 +07:00
parent 1c5fae8096
commit 2e1f0509df
+21 -17
View File
@@ -1,7 +1,7 @@
import App from 'resource:///com/github/Aylur/ags/app.js'; import App from 'resource:///com/github/Aylur/ags/app.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js'; import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'; import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
const { Box, Button, Entry, EventBox, Icon, Label, Revealer, Scrollable, Stack } = Widget; const { Box, Button, CenterBox, Entry, EventBox, Icon, Label, Revealer, Scrollable, Stack } = Widget;
const { execAsync, exec } = Utils; const { execAsync, exec } = Utils;
import { setupCursorHover, setupCursorHoverInfo } from "../../lib/cursorhover.js"; import { setupCursorHover, setupCursorHoverInfo } from "../../lib/cursorhover.js";
// APIs // APIs
@@ -86,22 +86,26 @@ function switchToTab(id) {
chatEntry.placeholderText = APIS[id].placeholderText, chatEntry.placeholderText = APIS[id].placeholderText,
currentApiId = id; currentApiId = id;
} }
const apiSwitcher = Box({ const apiSwitcher = CenterBox({
homogeneous: true, centerWidget: Box({
children: [ className: 'sidebar-chat-apiswitcher spacing-h-5',
Box({ hpack: 'center',
className: 'sidebar-chat-apiswitcher spacing-h-5', children: APIS.map((api, id) => Button({
hpack: 'center', child: api.tabIcon,
children: APIS.map((api, id) => Button({ tooltipText: api.name,
child: api.tabIcon, setup: setupCursorHover,
tooltipText: api.name, onClicked: () => {
setup: setupCursorHover, switchToTab(id);
onClicked: () => { }
switchToTab(id); })),
} }),
})), endWidget: Button({
}), hpack: 'end',
] className: 'txt-subtext txt-norm icon-material',
label: 'lightbulb',
tooltipText: 'Use PageUp/PageDown to switch between API pages',
setup: setupCursorHoverInfo,
}),
}) })
export default Widget.Box({ export default Widget.Box({