Skip to content

Commit

Permalink
Merge pull request #157 from melnikga/chore/move-console
Browse files Browse the repository at this point in the history
Chore/The console is shifted under the editor
  • Loading branch information
mazurroman authored Apr 23, 2024
2 parents 8046e5c + 569c72d commit 085875c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 94 deletions.
25 changes: 20 additions & 5 deletions components/Editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { Tracer } from 'components/Tracer'
import { AppUiContext, CodeType, LogType } from '../../context/appUiContext'
import { cn } from '../../util/styles'

import Console from './Console'

import { ArgumentsHelperModal } from './ArgumentsHelperModal'
import { registerCairoLanguageSupport } from './cairoLangConfig'
import EditorControls from './EditorControls'
Expand Down Expand Up @@ -436,7 +438,7 @@ const Editor = ({ readOnly = false }: Props) => {
onChange={handleCairoCodeChange}
language={'cairo'}
className={cn(
'code-editor whitespace-pre-wrap overflow-hidden',
'code-editor whitespace-pre-wrap overflow-hidden p-0 m-0 w-full h-full absolute top-0 left-0',
{
'with-numbers': !isBytecode,
},
Expand Down Expand Up @@ -478,10 +480,23 @@ const Editor = ({ readOnly = false }: Props) => {
</div>
)}
</div>
<div className={cn('h-[22vh] border-r border-t bg-red-300')}>
{/* <div className=" border-gray-200 dark:border-black-500 flex items-center pl-6 pr-2 h-14 flex-none md:border-r justify-between"> */}
Console
{/* </div> */}
<div
className={cn(
'h-[22vh] border-r border-t pane pane-light overflow-auto pb-4',
)}
>
<div className="px-4">
<nav className="-mb-px flex space-x-8" aria-label="Tabs">
<div
className={cn(
'text-gray-700 whitespace-nowrap border-b py-1 mt-2 mb-4 text-xs font-thin',
)}
>
Console
</div>
</nav>
</div>
<Console />
</div>
</div>

Expand Down
104 changes: 15 additions & 89 deletions components/Tracer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import {
memo,
useContext,
useEffect,
useReducer,
useRef,
useState,
} from 'react'

import { Priority, useRegisterActions } from 'kbar'
import { memo, useContext, useEffect, useReducer, useRef } from 'react'

import ReactTooltip from 'react-tooltip'
import { TableVirtuoso, TableVirtuosoHandle } from 'react-virtuoso'

Expand All @@ -18,7 +10,6 @@ import {
} from 'context/cairoVMApiContext'

import { cn } from '../../util/styles'
import Console from '../Editor/Console'

import ExecutionStatus from './ExecutionStatus'

Expand Down Expand Up @@ -61,11 +52,6 @@ export interface TracerData {
entryToSierraVarsMap: { [key: string]: SierraVariables }
}

enum IConsoleTab {
Console = 'debug-console',
DebugInfo = 'output',
}

export const Tracer = () => {
const {
executionState,
Expand All @@ -86,10 +72,6 @@ export const Tracer = () => {
: null
const currentCallstackEntry = tracerData?.callstack[executionTraceStepNumber]

const [selectedConsoleTab, setSelectedConsoleTab] = useState<IConsoleTab>(
IConsoleTab.Console,
)

const [currentFocus, setCurrentFocus] = useReducer(
(state: any, newIdx: number) => {
state = {
Expand Down Expand Up @@ -156,35 +138,6 @@ export const Tracer = () => {
}
}

const actions = [
{
id: 'debugInfo',
name: 'Debug Info',
shortcut: ['d'],
keywords: 'Debug info',
section: 'Execution',
perform: () => {
setSelectedConsoleTab(IConsoleTab.DebugInfo)
},
subtitle: 'Switch to Debug Info',
priority: Priority.HIGH,
},
{
id: 'console',
name: 'Console',
shortcut: ['e'],
keywords: 'Console',
section: 'Execution',
perform: () => {
setSelectedConsoleTab(IConsoleTab.Console)
},
subtitle: 'Switch to Console',
priority: Priority.HIGH,
},
]

useRegisterActions(actions, [setSelectedConsoleTab])

return (
<>
<div className="border-t md:border-t-0 border-b border-gray-200 dark:border-black-500 flex items-center pl-4 pr-6 h-14 flex-none">
Expand Down Expand Up @@ -220,52 +173,25 @@ export const Tracer = () => {
</div>
)}

<div className="border-gray-200 border-t dark:border-black-500 flex-none overflow-hidden h-[22vh]">
<div className="border-gray-200 border-t dark:border-black-500 flex-none pane pane-light overflow-auto pb-4 h-[22vh]">
<div className="px-4">
<nav className="-mb-px uppercase flex space-x-8" aria-label="Tabs">
<button
<nav className="-mb-px flex space-x-8" aria-label="Tabs">
<div
className={cn(
'hover:text-gray-700 whitespace-nowrap border-b py-1 mt-2 mb-4 text-xs font-thin',
{
'border-indigo-600 text-gray-700':
selectedConsoleTab === IConsoleTab.DebugInfo,
'border-transparent text-gray-500':
selectedConsoleTab !== IConsoleTab.DebugInfo,
},
'text-gray-700 whitespace-nowrap border-b py-1 mt-2 mb-4 text-xs font-thin',
)}
onClick={() => setSelectedConsoleTab(IConsoleTab.DebugInfo)}
>
Debug Info [d]
</button>
<button
onClick={() => setSelectedConsoleTab(IConsoleTab.Console)}
className={cn(
'hover:text-gray-700 whitespace-nowrap border-b py-1 mt-2 mb-4 text-xs font-thin',
{
'border-indigo-600 text-gray-700':
selectedConsoleTab === IConsoleTab.Console,
'border-transparent text-gray-500':
selectedConsoleTab !== IConsoleTab.Console,
},
)}
>
Console [e]
</button>
Debug Info
</div>
</nav>
</div>
<div className="pane pane-light overflow-auto pb-4 grow h-[calc(100%_-_38px)]">
{selectedConsoleTab === IConsoleTab.Console && <Console />}

{selectedConsoleTab === IConsoleTab.DebugInfo && (
<DebugInfoTab
trace={trace}
currentTraceEntry={currentTraceEntry}
executionTraceStepNumber={executionTraceStepNumber}
currentCallstackEntry={currentCallstackEntry}
handleRegisterPointerClick={handleRegisterPointerClick}
/>
)}
</div>
<DebugInfoTab
trace={trace}
currentTraceEntry={currentTraceEntry}
executionTraceStepNumber={executionTraceStepNumber}
currentCallstackEntry={currentCallstackEntry}
handleRegisterPointerClick={handleRegisterPointerClick}
/>
</div>
</>
)
Expand Down
1 change: 1 addition & 0 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ html {
* Code editor
*/
.code-editor {
max-height: 100% !important;
@apply font-mono text-base md:text-tiny leading-4;
}

Expand Down

0 comments on commit 085875c

Please sign in to comment.