From 340303d57cfade4278b2a9459677e43b710b1e70 Mon Sep 17 00:00:00 2001 From: LukaszMMazur Date: Fri, 8 Mar 2024 16:22:41 +0100 Subject: [PATCH 1/3] Implemented keyboard shortcuts --- components/Editor/EditorControls.tsx | 19 +++++++++++-- components/Editor/index.tsx | 41 +++++++++++++++++++++++++++ components/Tracer/ExecutionStatus.tsx | 6 ++-- components/Tracer/index.tsx | 34 ++++++++++++++++++++-- 4 files changed, 92 insertions(+), 8 deletions(-) diff --git a/components/Editor/EditorControls.tsx b/components/Editor/EditorControls.tsx index ca1d599..713004b 100644 --- a/components/Editor/EditorControls.tsx +++ b/components/Editor/EditorControls.tsx @@ -2,9 +2,9 @@ import { useRef } from 'react' import { RiLinksLine, RiQuestionLine } from '@remixicon/react' import cn from 'classnames' +import { Priority, useRegisterActions } from 'kbar' import { Button, Input } from 'components/ui' -import { Priority, useRegisterActions } from 'kbar' type EditorControlsProps = { isCompileDisabled: boolean @@ -37,11 +37,24 @@ const EditorControls = ({ perform: () => { onCompileRun() }, + subtitle: 'Run execution', + priority: Priority.HIGH, + }, + { + id: 'permalink', + name: 'Share permalink', + shortcut: ['p'], + keywords: 'share permalink', + section: 'Excetution', + perform: () => { + onCopyPermalink() + }, + subtitle: 'Copy permalink', priority: Priority.HIGH, }, ] - useRegisterActions(actions, [onCompileRun]) + useRegisterActions(actions, [onCompileRun, onCopyPermalink]) return (
@@ -50,7 +63,7 @@ const EditorControls = ({ onClick={onCopyPermalink} transparent padded={false} - tooltip="Share permalink" + tooltip="Share permalink [p]" tooltipId="share-permalink" > diff --git a/components/Editor/index.tsx b/components/Editor/index.tsx index 8dacfca..ef652a3 100644 --- a/components/Editor/index.tsx +++ b/components/Editor/index.tsx @@ -11,6 +11,7 @@ import React, { import { decode, encode } from '@kunigi/string-compression' import cn from 'classnames' import copy from 'copy-to-clipboard' +import { Priority, useRegisterActions } from 'kbar' import { useRouter } from 'next/router' import SCEditor from 'react-simple-code-editor' @@ -197,6 +198,46 @@ const Editor = ({ readOnly = false }: Props) => { const isBytecode = false + const actions = [ + { + id: 'cairo', + name: 'Cairo', + shortcut: ['x'], + keywords: 'Switch to cairo', + section: 'Excetution', + perform: () => { + setCodeType(CodeType.Cairo) + }, + subtitle: 'Switch to Cairo', + priority: Priority.HIGH, + }, + { + id: 'sierra', + name: 'Sierra', + shortcut: ['s'], + keywords: 'Switch to sierra', + section: 'Excetution', + perform: () => { + setCodeType(CodeType.Sierra) + }, + subtitle: 'Switch to Sierra', + priority: Priority.HIGH, + }, + { + id: 'casm', + name: 'Casm', + shortcut: ['w'], + keywords: 'Switch to casm', + section: 'Excetution', + perform: () => { + setCodeType(CodeType.CASM) + }, + subtitle: 'Switch to Casm', + priority: Priority.HIGH, + }, + ] + useRegisterActions(actions, [highlightCode]) + return ( <>
diff --git a/components/Tracer/ExecutionStatus.tsx b/components/Tracer/ExecutionStatus.tsx index ffa7d20..f03f5c2 100644 --- a/components/Tracer/ExecutionStatus.tsx +++ b/components/Tracer/ExecutionStatus.tsx @@ -70,7 +70,7 @@ const ExecutionStatus = ({ transparent onClick={onStepOut} padded={false} - tooltip="Step back" + tooltip="Step back [b]" tooltipId="step1" > @@ -79,7 +79,7 @@ const ExecutionStatus = ({ transparent onClick={onStepIn} padded={false} - tooltip="Step next" + tooltip="Step next [n]" tooltipId="step2" > @@ -88,7 +88,7 @@ const ExecutionStatus = ({ transparent onClick={onContinueExecution} padded={false} - tooltip="Continue execution" + tooltip="Continue execution [c]" tooltipId="continue-execution" > diff --git a/components/Tracer/index.tsx b/components/Tracer/index.tsx index 07fa31f..ebf9167 100644 --- a/components/Tracer/index.tsx +++ b/components/Tracer/index.tsx @@ -1,6 +1,7 @@ import { useContext, useEffect, useState, useRef, useReducer } from 'react' import cn from 'classnames' +import { Priority, useRegisterActions } from 'kbar' import { CairoVMApiContext, BreakPoints } from 'context/cairoVMApiContext' @@ -130,6 +131,35 @@ export const Tracer = ({ mainHeight }: TracerProps) => { } } + const actions = [ + { + id: 'debugInfo', + name: 'Debug Info', + shortcut: ['d'], + keywords: 'switch to debug info', + section: 'Excetution', + perform: () => { + setSelectedConsoleTab(IConsoleTab.DebugInfo) + }, + subtitle: 'Switch to Debug Info', + priority: Priority.HIGH, + }, + { + id: 'console', + name: 'Console', + shortcut: ['e'], + keywords: 'switch to console', + section: 'Excetution', + perform: () => { + setSelectedConsoleTab(IConsoleTab.Console) + }, + subtitle: 'Switch to Console', + priority: Priority.HIGH, + }, + ] + + useRegisterActions(actions, [setSelectedConsoleTab]) + return ( <>
@@ -173,7 +203,7 @@ export const Tracer = ({ mainHeight }: TracerProps) => { )}`} onClick={() => setSelectedConsoleTab(IConsoleTab.DebugInfo)} > - Debug Info + Debug Info [d]
From 5e9f3b185fba400f94d7d40ce25ea3338ab0c54c Mon Sep 17 00:00:00 2001 From: LukaszMMazur Date: Fri, 8 Mar 2024 22:10:39 +0100 Subject: [PATCH 2/3] corrected typos --- components/Editor/index.tsx | 12 ++++++------ components/Tracer/index.tsx | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/Editor/index.tsx b/components/Editor/index.tsx index ef652a3..802e403 100644 --- a/components/Editor/index.tsx +++ b/components/Editor/index.tsx @@ -203,8 +203,8 @@ const Editor = ({ readOnly = false }: Props) => { id: 'cairo', name: 'Cairo', shortcut: ['x'], - keywords: 'Switch to cairo', - section: 'Excetution', + keywords: 'Cairo', + section: 'Execution', perform: () => { setCodeType(CodeType.Cairo) }, @@ -215,8 +215,8 @@ const Editor = ({ readOnly = false }: Props) => { id: 'sierra', name: 'Sierra', shortcut: ['s'], - keywords: 'Switch to sierra', - section: 'Excetution', + keywords: 'Sierra', + section: 'Execution', perform: () => { setCodeType(CodeType.Sierra) }, @@ -227,8 +227,8 @@ const Editor = ({ readOnly = false }: Props) => { id: 'casm', name: 'Casm', shortcut: ['w'], - keywords: 'Switch to casm', - section: 'Excetution', + keywords: 'Casm', + section: 'Execution', perform: () => { setCodeType(CodeType.CASM) }, diff --git a/components/Tracer/index.tsx b/components/Tracer/index.tsx index ebf9167..31cf2db 100644 --- a/components/Tracer/index.tsx +++ b/components/Tracer/index.tsx @@ -136,8 +136,8 @@ export const Tracer = ({ mainHeight }: TracerProps) => { id: 'debugInfo', name: 'Debug Info', shortcut: ['d'], - keywords: 'switch to debug info', - section: 'Excetution', + keywords: 'Debug info', + section: 'Excecution', perform: () => { setSelectedConsoleTab(IConsoleTab.DebugInfo) }, @@ -148,8 +148,8 @@ export const Tracer = ({ mainHeight }: TracerProps) => { id: 'console', name: 'Console', shortcut: ['e'], - keywords: 'switch to console', - section: 'Excetution', + keywords: 'Console', + section: 'Excecution', perform: () => { setSelectedConsoleTab(IConsoleTab.Console) }, From fbaa79dfe158234d7b074f8a6e751f4328cf2cda Mon Sep 17 00:00:00 2001 From: LukaszMMazur Date: Sat, 9 Mar 2024 08:49:57 +0100 Subject: [PATCH 3/3] typos corrected (2) --- components/Editor/EditorControls.tsx | 4 ++-- components/Tracer/ExecutionStatus.tsx | 2 +- components/Tracer/index.tsx | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/Editor/EditorControls.tsx b/components/Editor/EditorControls.tsx index 713004b..8f6af05 100644 --- a/components/Editor/EditorControls.tsx +++ b/components/Editor/EditorControls.tsx @@ -44,8 +44,8 @@ const EditorControls = ({ id: 'permalink', name: 'Share permalink', shortcut: ['p'], - keywords: 'share permalink', - section: 'Excetution', + keywords: 'Share permalink', + section: 'Execution', perform: () => { onCopyPermalink() }, diff --git a/components/Tracer/ExecutionStatus.tsx b/components/Tracer/ExecutionStatus.tsx index f03f5c2..ac32820 100644 --- a/components/Tracer/ExecutionStatus.tsx +++ b/components/Tracer/ExecutionStatus.tsx @@ -45,7 +45,7 @@ const ExecutionStatus = ({ id: 'continue', name: 'Continue', shortcut: ['c'], - keywords: 'execution continue', + keywords: 'Execution continue', section: 'Execution', perform: () => { onContinueExecution() diff --git a/components/Tracer/index.tsx b/components/Tracer/index.tsx index 31cf2db..d9e50a9 100644 --- a/components/Tracer/index.tsx +++ b/components/Tracer/index.tsx @@ -137,7 +137,7 @@ export const Tracer = ({ mainHeight }: TracerProps) => { name: 'Debug Info', shortcut: ['d'], keywords: 'Debug info', - section: 'Excecution', + section: 'Execution', perform: () => { setSelectedConsoleTab(IConsoleTab.DebugInfo) }, @@ -149,7 +149,7 @@ export const Tracer = ({ mainHeight }: TracerProps) => { name: 'Console', shortcut: ['e'], keywords: 'Console', - section: 'Excecution', + section: 'Execution', perform: () => { setSelectedConsoleTab(IConsoleTab.Console) },