Skip to content

Commit

Permalink
Merge pull request #1 from trypear/main
Browse files Browse the repository at this point in the history
Merge Main
  • Loading branch information
charlwillia6 authored Oct 24, 2024
2 parents 00c1410 + 660167c commit 8466ac3
Show file tree
Hide file tree
Showing 11 changed files with 475 additions and 10 deletions.
2 changes: 1 addition & 1 deletion product.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"nameShort": "PearAI",
"nameLong": "PearAI",
"pearAIVersion": "1.3.0",
"pearAIVersion": "1.4.1",
"applicationName": "PearAI",
"dataFolderName": ".pearai",
"win32MutexName": "pearai",
Expand Down
5 changes: 4 additions & 1 deletion src/vs/workbench/browser/actions/layoutActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
import { ToggleAuxiliaryBarAction } from 'vs/workbench/browser/parts/auxiliarybar/auxiliaryBarActions';
import { TogglePanelAction } from 'vs/workbench/browser/parts/panel/panelActions';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { AuxiliaryBarVisibleContext, PanelAlignmentContext, PanelVisibleContext, SideBarVisibleContext, FocusedViewContext, InEditorZenModeContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, IsMainWindowFullscreenContext, PanelPositionContext, IsAuxiliaryWindowFocusedContext, TitleBarStyleContext } from 'vs/workbench/common/contextkeys';
import { AuxiliaryBarVisibleContext, PanelAlignmentContext, PanelVisibleContext, SideBarVisibleContext, FocusedViewContext, InEditorZenModeContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, IsMainWindowFullscreenContext, PanelPositionContext, IsAuxiliaryWindowFocusedContext, TitleBarStyleContext, PearAIVisibleContext } from 'vs/workbench/common/contextkeys';
import { Codicon } from 'vs/base/common/codicons';
import { ThemeIcon } from 'vs/base/common/themables';
import { DisposableStore } from 'vs/base/common/lifecycle';
Expand All @@ -31,6 +31,7 @@ import { ICommandActionTitle } from 'vs/platform/action/common/action';
import { mainWindow } from 'vs/base/browser/window';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { TitlebarStyle } from 'vs/platform/window/common/window';
import { TogglePearOverlayAction } from 'vs/workbench/browser/parts/overlay/pearOverlayActions';

// Register Icons
const menubarIcon = registerIcon('menuBar', Codicon.layoutMenubar, localize('menuBarIcon', "Represents the menu bar"));
Expand All @@ -42,6 +43,7 @@ const panelRightIcon = registerIcon('panel-right', Codicon.layoutSidebarRight, l
const panelRightOffIcon = registerIcon('panel-right-off', Codicon.layoutSidebarRightOff, localize('panelRightOff', "Represents side bar in the right position toggled off"));
const panelIcon = registerIcon('panel-bottom', Codicon.layoutPanel, localize('panelBottom', "Represents the bottom panel"));
const statusBarIcon = registerIcon('statusBar', Codicon.layoutStatusbar, localize('statusBarIcon', "Represents the status bar"));
const pearaiIcon = registerIcon('pearai', Codicon.archive, localize('pearaiIcon', "Represents the PearAI overlay"));

const panelAlignmentLeftIcon = registerIcon('panel-align-left', Codicon.layoutPanelLeft, localize('panelBottomLeft', "Represents the bottom panel alignment set to the left"));
const panelAlignmentRightIcon = registerIcon('panel-align-right', Codicon.layoutPanelRight, localize('panelBottomRight', "Represents the bottom panel alignment set to the right"));
Expand Down Expand Up @@ -1341,6 +1343,7 @@ ToggleVisibilityActions.push(...[
CreateToggleLayoutItem(ToggleAuxiliaryBarAction.ID, AuxiliaryBarVisibleContext, localize('secondarySideBar', "Secondary Side Bar"), { whenA: ContextKeyExpr.equals('config.workbench.sideBar.location', 'left'), iconA: panelRightIcon, iconB: panelLeftIcon }),
CreateToggleLayoutItem(TogglePanelAction.ID, PanelVisibleContext, localize('panel', "Panel"), panelIcon),
CreateToggleLayoutItem(ToggleStatusbarVisibilityAction.ID, ContextKeyExpr.equals('config.workbench.statusBar.visible', true), localize('statusBar', "Status Bar"), statusBarIcon),
CreateToggleLayoutItem(TogglePearOverlayAction.ID, PearAIVisibleContext, 'PearAI', pearaiIcon)
]);

const MoveSideBarActions: CustomizeLayoutItem[] = [
Expand Down
22 changes: 21 additions & 1 deletion src/vs/workbench/browser/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
private auxiliaryBarPartView!: ISerializableView;
private editorPartView!: ISerializableView;
private statusBarPartView!: ISerializableView;
private pearOverlayPartView!: ISerializableView;

private environmentService!: IBrowserWorkbenchEnvironmentService;
private extensionService!: IExtensionService;
Expand Down Expand Up @@ -1483,6 +1484,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
const auxiliaryBarPart = this.getPart(Parts.AUXILIARYBAR_PART);
const sideBar = this.getPart(Parts.SIDEBAR_PART);
const statusBar = this.getPart(Parts.STATUSBAR_PART);
const pearOverlayPart = this.getPart(Parts.PEAROVERLAY_PART);

// View references for all parts
this.titleBarPartView = titleBar;
Expand All @@ -1493,6 +1495,22 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
this.panelPartView = panelPart;
this.auxiliaryBarPartView = auxiliaryBarPart;
this.statusBarPartView = statusBar;
this.pearOverlayPartView = pearOverlayPart;

// Create a new container for PearOverlayPart
const pearOverlayPartContainer = document.createElement("div");
pearOverlayPartContainer.style.position = "absolute";
pearOverlayPartContainer.style.top = "0";
pearOverlayPartContainer.style.left = "0";
pearOverlayPartContainer.style.right = "0";
pearOverlayPartContainer.style.bottom = "0";
pearOverlayPartContainer.style.zIndex = "-10";
pearOverlayPartContainer.style.display = "absolute";
pearOverlayPartContainer.classList.add("pearoverlay-part-container");
pearOverlayPartContainer.style.backgroundColor = 'var(--vscode-editor-background)';

this.mainContainer.appendChild(pearOverlayPartContainer);
pearOverlayPart.create(pearOverlayPartContainer);

const viewMap = {
[Parts.ACTIVITYBAR_PART]: this.activityBarPartView,
Expand All @@ -1502,7 +1520,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
[Parts.PANEL_PART]: this.panelPartView,
[Parts.SIDEBAR_PART]: this.sideBarPartView,
[Parts.STATUSBAR_PART]: this.statusBarPartView,
[Parts.AUXILIARYBAR_PART]: this.auxiliaryBarPartView
[Parts.AUXILIARYBAR_PART]: this.auxiliaryBarPartView,
[Parts.PEAROVERLAY_PART]: this.pearOverlayPartView,
};

const fromJSON = ({ type }: { type: Parts }) => viewMap[type];
Expand Down Expand Up @@ -1571,6 +1590,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi

// Layout the grid widget
this.workbenchGrid.layout(this._mainContainerDimension.width, this._mainContainerDimension.height);
this.pearOverlayPartView.layout(this._mainContainerDimension.width, this._mainContainerDimension.height, 0, 0);
this.initialized = true;

// Emit as event
Expand Down
49 changes: 49 additions & 0 deletions src/vs/workbench/browser/parts/overlay/pearOverlayActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { registerAction2, Action2 } from "vs/platform/actions/common/actions";
import { ServicesAccessor } from "vs/platform/instantiation/common/instantiation";
import { IPearOverlayService } from "./pearOverlayService";
import { KeyCode, KeyMod } from "vs/base/common/keyCodes";

export class ClosePearOverlayAction extends Action2 {
static readonly ID = "workbench.action.closePearAI";

constructor() {
super({
id: ClosePearOverlayAction.ID,
title: { value: "Close PearAI Popup", original: "Close PearAI Popup" },
f1: true,
keybinding: {
weight: 200,
primary: KeyCode.Escape,
},
});
}

run(accessor: ServicesAccessor): void {
const pearaiOverlayService = accessor.get(IPearOverlayService);
pearaiOverlayService.hide();
}
}

export class TogglePearOverlayAction extends Action2 {
static readonly ID = "workbench.action.togglePearAI";

constructor() {
super({
id: TogglePearOverlayAction.ID,
title: { value: "Toggle PearAI Popup", original: "Toggle PearAI Popup" },
f1: true,
keybinding: {
weight: 200,
primary: KeyMod.CtrlCmd | KeyCode.KeyE,
},
});
}

run(accessor: ServicesAccessor): void {
const pearaiOverlayService = accessor.get(IPearOverlayService);
pearaiOverlayService.toggle();
}
}

registerAction2(TogglePearOverlayAction);
registerAction2(ClosePearOverlayAction);
Loading

0 comments on commit 8466ac3

Please sign in to comment.