diff --git a/commands.js b/commands.js index b5914e0..e9063e3 100644 --- a/commands.js +++ b/commands.js @@ -29,6 +29,9 @@ export default { "disconnect": (app, args) => { app.disconnect(); }, + "help": (app, args) => { + app.openHelp(); + }, "join": (app, args) => { var channel = args[0]; if (!channel) { diff --git a/components/app.js b/components/app.js index ff61830..d3856fe 100644 --- a/components/app.js +++ b/components/app.js @@ -6,6 +6,7 @@ import BufferHeader from "./buffer-header.js"; import MemberList from "./member-list.js"; import Connect from "./connect.js"; import Join from "./join.js"; +import Help from "./help.js"; import Composer from "./composer.js"; import ScrollManager from "./scroll-manager.js"; import Dialog from "./dialog.js"; @@ -879,6 +880,10 @@ export default class App extends Component { return fromList(buf.members.keys(), prefix); } + openHelp() { + this.setState({ dialog: "help" }); + } + handleBufferScrollTop() { var buf = this.state.buffers.get(this.state.activeBuffer); if (!buf || buf.type == BufferType.SERVER) { @@ -959,6 +964,13 @@ export default class App extends Component { var dialog = null; switch (this.state.dialog) { + case "help": + dialog = html` + <${Dialog} title="Help" onDismiss=${this.handleDialogDismiss}> + <${Help}/> + > + `; + break; case "join": dialog = html` <${Dialog} title="Join channel" onDismiss=${this.handleDialogDismiss}> diff --git a/components/help.js b/components/help.js new file mode 100644 index 0000000..4820547 --- /dev/null +++ b/components/help.js @@ -0,0 +1,36 @@ +import { html, Component } from "../lib/index.js"; +import { keybindings } from "../keybindings.js"; + +function KeyBindingsHelp() { + var l = keybindings.map((binding) => { + var keys = []; + if (binding.ctrlKey) { + keys.psuh("Ctrl"); + } + if (binding.altKey) { + keys.push("Alt"); + } + keys.push(binding.key); + + keys = keys.map((name, i) => { + return html` + ${i > 0 ? "+" : null} + ${name} + `; + }); + + return html` +