Set platform based on server (#32)
* Set platform based on server Had to refactor a bit to ensure our values get set before VS Code tries to use them. * Pave the way for mnemonics on all platforms * Fix context menus on Mac * Fix a bunch of things on Mac including menu bar * Set keybindings based on client's OS
This commit is contained in:
@ -5,6 +5,7 @@ import { upload } from "./upload";
|
||||
import { client } from "./fill/client";
|
||||
import { clipboard } from "./fill/clipboard";
|
||||
import { INotificationService, IProgressService } from "./fill/notification";
|
||||
import "./fill/os"; // Ensure it fills before anything else waiting on initData.
|
||||
|
||||
/**
|
||||
* A general abstraction of an IDE client.
|
||||
|
@ -78,7 +78,7 @@ export class Dialog {
|
||||
this.buttons = this.options.buttons.map((buttonText, buttonIndex) => {
|
||||
const button = document.createElement("button");
|
||||
// TODO: support mnemonics.
|
||||
button.innerText = buttonText.replace("_", "");
|
||||
button.innerText = buttonText.replace("&&", "");
|
||||
button.addEventListener("click", () => {
|
||||
this.actionEmitter.emit({
|
||||
buttonIndex,
|
||||
|
@ -145,6 +145,14 @@ class Clipboard {
|
||||
return false;
|
||||
}
|
||||
|
||||
public readFindText(): string {
|
||||
return "";
|
||||
}
|
||||
|
||||
public writeFindText(_text: string): void {
|
||||
// Nothing.
|
||||
}
|
||||
|
||||
public writeText(value: string): Promise<void> {
|
||||
return clipboard.writeText(value);
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
import { InitData } from "@coder/protocol";
|
||||
import { OperatingSystem, InitData } from "@coder/protocol";
|
||||
import { client } from "./client";
|
||||
|
||||
class OS {
|
||||
private _homedir: string | undefined;
|
||||
private _tmpdir: string | undefined;
|
||||
private _platform: NodeJS.Platform | undefined;
|
||||
|
||||
public constructor() {
|
||||
client.initData.then((data) => {
|
||||
this.initialize(data);
|
||||
});
|
||||
client.initData.then((d) => this.initialize(d));
|
||||
}
|
||||
|
||||
public homedir(): string {
|
||||
@ -30,6 +29,11 @@ class OS {
|
||||
public initialize(data: InitData): void {
|
||||
this._homedir = data.homeDirectory;
|
||||
this._tmpdir = data.tmpDirectory;
|
||||
switch (data.os) {
|
||||
case OperatingSystem.Windows: this._platform = "win32"; break;
|
||||
case OperatingSystem.Mac: this._platform = "darwin"; break;
|
||||
default: this._platform = "linux"; break;
|
||||
}
|
||||
}
|
||||
|
||||
public release(): string {
|
||||
@ -37,14 +41,11 @@ class OS {
|
||||
}
|
||||
|
||||
public platform(): NodeJS.Platform {
|
||||
if (navigator.appVersion.indexOf("Win") != -1) {
|
||||
return "win32";
|
||||
}
|
||||
if (navigator.appVersion.indexOf("Mac") != -1) {
|
||||
return "darwin";
|
||||
if (typeof this._platform === "undefined") {
|
||||
throw new Error("trying to access platform before it has been set");
|
||||
}
|
||||
|
||||
return "linux";
|
||||
return this._platform;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user