Add notbook runtime settings shortcut (#176)

This commit is contained in:
TED 2021-04-14 17:20:51 +07:00 committed by GitHub
parent fd65ebfaa5
commit 623c5b3290
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 1 deletions

View file

@ -155,6 +155,8 @@ function handleDocumentKeyDown(hook, event) {
toggleSectionsPanel(hook); toggleSectionsPanel(hook);
} else if (keyBuffer.tryMatch(["s", "n"])) { } else if (keyBuffer.tryMatch(["s", "n"])) {
showNotebookSettings(hook); showNotebookSettings(hook);
} else if (keyBuffer.tryMatch(["s", "r"])) {
showNotebookRuntimeSettings(hook);
} else if (keyBuffer.tryMatch(["e", "x"])) { } else if (keyBuffer.tryMatch(["e", "x"])) {
cancelFocusedCellEvaluation(hook); cancelFocusedCellEvaluation(hook);
} else if (keyBuffer.tryMatch(["?"])) { } else if (keyBuffer.tryMatch(["?"])) {
@ -303,6 +305,10 @@ function showNotebookSettings(hook) {
hook.pushEvent("show_notebook_settings", {}); hook.pushEvent("show_notebook_settings", {});
} }
function showNotebookRuntimeSettings(hook) {
hook.pushEvent("show_notebook_runtime_settings", {});
}
function deleteFocusedCell(hook) { function deleteFocusedCell(hook) {
if (hook.state.focusedCellId) { if (hook.state.focusedCellId) {
hook.pushEvent("delete_cell", { cell_id: hook.state.focusedCellId }); hook.pushEvent("delete_cell", { cell_id: hook.state.focusedCellId });

View file

@ -361,6 +361,13 @@ defmodule LivebookWeb.SessionLive do
)} )}
end end
def handle_event("show_notebook_runtime_settings", %{}, socket) do
{:noreply,
push_patch(socket,
to: Routes.session_path(socket, :settings, socket.assigns.session_id, "runtime")
)}
end
@impl true @impl true
def handle_info({:operation, operation}, socket) do def handle_info({:operation, operation}, socket) do
case Session.Data.apply_operation(socket.private.data, operation) do case Session.Data.apply_operation(socket.private.data, operation) do

View file

@ -25,7 +25,8 @@ defmodule LivebookWeb.SessionLive.ShortcutsComponent do
%{seq: ["ej"], desc: "Evaluate cells below"}, %{seq: ["ej"], desc: "Evaluate cells below"},
%{seq: ["ex"], desc: "Cancel cell evaluation"}, %{seq: ["ex"], desc: "Cancel cell evaluation"},
%{seq: ["ss"], desc: "Toggle sections panel"}, %{seq: ["ss"], desc: "Toggle sections panel"},
%{seq: ["sn"], desc: "Show notebook settings"} %{seq: ["sn"], desc: "Show notebook settings"},
%{seq: ["sr"], desc: "Show notebook runtime settings"}
] ]
} }