📄 workspace.tcl
字号:
}}proc Workspace:saveDisplays {context} { global Monitor:standaloneRun # We are actually saving monitor's stuff in the workspace code # because its far more easier to do this here than anywhere else. set tracerStatus [TkRequest $context GetInspectorStatus {System RT/Interfaces}] if {${Monitor:standaloneRun} == 0} { set inspectorStatus [TkRequest $context GetInspectorStatus] } { set inspectorStatus withdrawn } Project:setResource MonitorDisplayStatuses [list $tracerStatus $inspectorStatus]}proc Workspace:restoreDisplays {context} { global Monitor:standaloneRun set dispStat [Project:getResource MonitorDisplayStatuses] set tracerStatus [lindex $dispStat 0] set inspectorStatus [lindex $dispStat 1] if {$tracerStatus == "displayed"} { Workspace:traceSimulation $context } if {$inspectorStatus == "displayed" && ${Monitor:standaloneRun} == 0} { Workspace:inspectSimulation $context }}proc Workspace:displayAboutBox {context} { set w $context.about if {[winfo exists $w]} { wm deiconify $w raise $w return } set info [TkRequest $context GetVersionInfo] set version [lindex $info 0] set buildcf [lindex $info 1] toplevel $w wm title $w "About RTAI/sim" wm resizable $w 0 0 cascadeWindow $w bind $w <Escape> "destroy $w" frame $w.banner -relief flat -bd 0 label $w.banner.image -image [fetchImage banner] -anchor c pack $w.banner.image -pady 0 -padx 0 pack $w.banner frame $w.f -relief sunken -bd 3 pack $w.f -expand yes -fill both tixScrolledText $w.f.gpl -scrollbar y -options { text.spacing1 0 text.spacing3 0 text.height 16 text.width 60 text.wrap word } pack $w.f.gpl -expand yes -fill both set textw [$w.f.gpl subwidget text] $textw tag config aligned -lmargin1 30 -lmargin2 30 $textw insert end "\nRTAI/sim is free software; you can redistribute it and/or modify it\n" aligned $textw insert end "under the terms of the GNU General Public License as published by the\n" aligned $textw insert end "Free Software Foundation; either version 2 of the License, or (at your\n" aligned $textw insert end "option) any later version.\n\n" aligned $textw insert end "This program is distributed in the hope that it will be useful,\n" aligned $textw insert end "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" aligned $textw insert end "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" aligned $textw insert end "See the GNU General Public License for more details.\n\n" aligned $textw insert end "You are currently running the Xenoscope, a RTOS-aware debugger\n" aligned $textw insert end "for programs running on top of RTAI's Minute Virtual Machine.\n\n" aligned $textw insert end "MVM version $version.\n" aligned $textw insert end "Configured as: $buildcf.\n" aligned $textw config -state disabled tixButtonBox $w.bbox -orientation horizontal -relief flat -bd 0 $w.bbox add dismiss -text Close -command "destroy $w" pack $w.bbox -side bottom -fill x tkwait visibility $w grab $w}proc Workspace:processGlobalEvent {context name1 name2 op} { global Workspace:session Project:settings set mbar $context.mbar set tools $context.mtoolbar.tools set controls $context.mtoolbar.controls while {[popEvent eventQueue:$context e] == "true"} { switch $e { InitWorkspaceEvent { # may not open text files $mbar.file.m entryconfigure 0 -state disabled # may not edit project $mbar.project.m entryconfigure 1 -state disabled # may not edit project settings $mbar.project.m entryconfigure 5 -state disabled # may not close project $mbar.project.m entryconfigure 7 -state disabled # may not access debugger $mbar.debug configure -state disabled $tools subwidget loadDebug configure -state disabled # may not access simulation actions $mbar.simulation configure -state disabled $tools subwidget updateSettings configure -state disabled $tools subwidget startSimulation configure -state disabled wm title $context Xenoscope # no cached windows at startup $mbar.window configure -state disabled # no RecentProjects $mbar.file.m entryconfigure 2 -state disabled } OpenProjectEvent - ProjectUpdateEvent { # may edit project $mbar.project.m entryconfigure 1 -state normal # may edit project settings $mbar.project.m entryconfigure 5 -state normal # may close project $mbar.project.m entryconfigure 7 -state normal # may access debugger if executable seems valid set progfile [set Project:settings(Executable)] set progpath [TkRequest $context CanonicalizePath ${progfile}] if {$progfile != {} && \ [file isfile $progpath] == 1 && \ [file executable $progpath] == 1} { # may access debugger actions $mbar.debug configure -state normal $tools subwidget loadDebug configure -state normal # may access simulation actions $mbar.simulation configure -state normal $tools subwidget startSimulation configure -state normal } { # may not access debugger actions $mbar.debug configure -state disabled $tools subwidget loadDebug configure -state disabled # may not access simulation actions $mbar.simulation configure -state disabled $tools subwidget startSimulation configure -state disabled } # may configure the simulation $tools subwidget updateSettings configure -state normal # may not break/restart/stop debuggee $mbar.debug.m entryconfigure 3 -state disabled $mbar.debug.m entryconfigure 5 -state disabled $mbar.debug.m entryconfigure 6 -state disabled # may not hold simulation $mbar.simulation.m entryconfigure 1 -state disabled # may not release simulation $mbar.simulation.m entryconfigure 2 -state disabled # may not inspect simulation $mbar.simulation.m entryconfigure 3 -state disabled # may not trace simulation $mbar.simulation.m entryconfigure 4 -state disabled # may not access simulation timers $mbar.simulation.m entryconfigure 5 -state disabled # may not restart/kill simulation $mbar.simulation.m entryconfigure 7 -state disabled $mbar.simulation.m entryconfigure 8 -state disabled set projname [file rootname [file tail [set Workspace:session(CurrentProject)]]] wm title $context "Xenoscope: $projname" } CloseProjectEvent { # may not edit project $mbar.project.m entryconfigure 1 -state disabled # may not edit project settings $mbar.project.m entryconfigure 5 -state disabled # may not close project $mbar.project.m entryconfigure 7 -state disabled # may not access debugger $mbar.debug configure -state disabled $tools subwidget loadDebug configure -state disabled # may not access simulation actions $mbar.simulation configure -state disabled $tools subwidget updateSettings configure -state disabled $tools subwidget startSimulation configure -state disabled wm title $context Xenoscope } SimulationStartedEvent { # may not access project actions or change # current project. $mbar.project configure -state disabled $tools subwidget openProject configure -state disabled $mbar.file.m entryconfigure 2 -state disabled # may not open source files $mbar.file.m entryconfigure 0 -state disabled # may not access debug actions (but restart if !runOnce) $mbar.debug.m entryconfigure 0 -state disabled $mbar.debug.m entryconfigure 1 -state disabled $mbar.debug.m entryconfigure 6 -state disabled $tools subwidget loadDebug configure -state disabled # may not start simulation $mbar.simulation.m entryconfigure 0 -state disabled $tools subwidget startSimulation configure -state disabled # may hold simulation $mbar.simulation.m entryconfigure 1 -state normal $controls subwidget holdSimulation configure -state normal # may not release simulation $mbar.simulation.m entryconfigure 2 -state disabled $controls subwidget releaseSimulation configure -state disabled # may restart simulation, but if running in "self-exit" mode global Workspace:runOnce if {${Workspace:runOnce} == 0} { $mbar.debug.m entryconfigure 5 -state normal $mbar.simulation.m entryconfigure 7 -state normal } # may kill simulation $mbar.simulation.m entryconfigure 8 -state normal } SimulationHeldEvent { # may not hold simulation $mbar.simulation.m entryconfigure 1 -state disabled $controls subwidget holdSimulation configure -state disabled # may release simulation $mbar.simulation.m entryconfigure 2 -state normal $controls subwidget releaseSimulation configure -state normal # update status icon set icon [Monitor:getStopIcon] $context.mtoolbar.status config -image [fetchImage $icon] } SimulationReleasedEvent { # may hold simulation $mbar.simulation.m entryconfigure 1 -state normal $controls subwidget holdSimulation configure -state normal # may not release simulation $mbar.simulation.m entryconfigure 2 -state disabled $controls subwidget releaseSimulation configure -state disabled # update status icon $context.mtoolbar.status config -image [fetchImage runflip] } SimulationWarmEvent { # display status icon pack $context.mtoolbar.status -expand no \ -padx 6 -pady 4 -side right # display speed control spinbox pack $context.mtoolbar.speed -expand no -anchor e \ -padx 0 -pady 4 -side right # Warm and Finished events are shared between standalone # and debug running modes. # may access simulation controls pack $controls -expand no -padx 6 -pady 4 -side right $controls config -state normal # display simulation clock pack $context.mtoolbar.clock -expand no -anchor e \ -padx 10 -pady 4 -side left # enable speed spinbox and reset its value to the max. $context.mtoolbar.speed.control config -state normal $context.mtoolbar.speed.control config -value 10 global Monitor:standaloneRun if {${Monitor:standaloneRun} == 1} { # may not re-access inspector's window (i.e. always visible) $mbar.simulation.m entryconfigure 3 -state disabled $controls subwidget inspectSimulation config -state disabled } { # may inspect simulation through inspector's window $mbar.simulation.m entryconfigure 3 -state normal } # may trace simulation $mbar.simulation.m entryconfigure 4 -state normal # may access simulation timers $mbar.simulation.m entryconfigure 5 -state normal } SimulationReadyEvent { # restore timers TimerManager:restoreTimers $context # restore main displays Workspace:restoreDisplays $context } SimulationFinishedEvent { global Monitor:standaloneRun # may not hold simulation (using the simulation controls) $controls subwidget holdSimulation config -state disabled # may not hold simulation (using Simulation menu) $mbar.simulation.m entryconfigure 1 -state disabled # may not access simulation timers (using the simulation controls) $controls subwidget timerManager config -state disabled # may not access simulation timers (using Simulation menu) $mbar.simulation.m entryconfigure 5 -state disabled if {${Monitor:standaloneRun} != 1} { # may not break debuggee (using Debug menu) $mbar.debug.m entryconfigure 3 -state disabled } # disable speed spinbox $context.mtoolbar.speed.control config -state disabled # update status icon $context.mtoolbar.status config -image [fetchImage done] } SimulationKilledEvent { # may access project actions $mbar.project configure -state normal $tools subwidget openProject configure -state normal # may open source files $mbar.file.m entryconfigure 0 -state normal global Workspace:session if {[set Workspace:session(RecentProjects)] != {}} { $mbar.file.m entryconfigure 2 -state normal } # may access debug actions $mbar.debug.m entryconfigure 0 -state normal $mbar.debug.m entryconfigure 1 -state normal $mbar.debug.m entryconfigure 5 -state disabled $mbar.debug.m entryconfigure 6 -state disabled $tools subwidget loadDebug configure -state normal # may start simulation $mbar.simulation.m entryconfigure 0 -state normal $tools subwidget startSimulation configure -state normal # may not hold simulation $mbar.simulation.m entryconfigure 1 -state disabled # may not release simulation $mbar.simulation.m entryconfigure 2 -state disabled # may not inspect simulation $mbar.simulation.m entryconfigure 3 -state disabled # may not trace simulation $mbar.simulation.m entryconfigure 4 -state disabled # may not access simulation timers $mbar.simulation.m entryconfigure 5 -state disabled # may not restart/kill simulation $mbar.simulation.m entryconfigure 7 -state disabled $mbar.simulation.m entryconfigure 8 -state disabled } DebuggerStartedEvent { # may open text files $mbar.file.m entryconfigure 0 -state normal # may not access project actions $mbar.project configure -state disabled $tools subwidget openProject configure -state disabled $mbar.file.m entryconfigure 2 -state disabled # may only access configuration (never disabled) and # restart/kill entries $mbar.simulation.m entryconfigure 0 -state disabled $mbar.simulation.m entryconfigure 1 -state disabled $mbar.simulation.m entryconfigure 2 -state disabled $mbar.simulation.m entryconfigure 3 -state disabled $mbar.simulation.m entryconfigure 4 -state disabled $mbar.simulation.m entryconfigure 5 -state disabled # may restart simulation, but if running in "self-exit" mode global Workspace:runOnce if {${Workspace:runOnce} == 0} { $mbar.simulation.m entryconfigure 7 -state normal } $mbar.simulation.m entryconfigure 8 -state normal # cannot start simulation through toolbar $tools subwidget startSimulation configure -state disabled # may not load nor run debuggee $mbar.debug.m entryconfigure 0 -state disabled $mbar.debug.m entryconfigure 1 -state disabled $tools subwidget loadDebug configure -state disabled # may not break debuggee (until the monitor is up) $mbar.debug.m entryconfigure 3 -state disabled # may restart debuggee, but if running in "self-exit" mode if {${Workspace:runOnce} == 0} { $mbar.debug.m entryconfigure 5 -state normal } # may stop debugger $mbar.debug.m entryconfigure 6 -state normal } DebuggerAbortEvent - DebuggerStoppedEvent { # may not open text files $mbar.file.m entryconfigure 0 -state disabled # may access project actions $mbar.project configure -state normal $tools subwidget openProject configure -state normal global Workspace:session if {[set Workspace:session(RecentProjects)] != {}} { $mbar.file.m entryconfigure 2 -state normal } # reset simulation actions $mbar.simulation.m entryconfigure 0 -state normal $mbar.simulation.m entryconfigure 1 -state disabled $mbar.simulation.m entryconfigure 2 -state disabled $mbar.simulation.m entryconfigure 3 -state disabled $mbar.simulation.m entryconfigure 4 -state disabled $mbar.simulation.m entryconfigure 5 -state disabled $mbar.simulation.m entryconfigure 7 -state disabled $mbar.simulation.m entryconfigure 8 -state disabled $tools subwidget startSimulation configure -state normal # may load or run debuggee $mbar.debug.m entryconfigure 0 -state normal $mbar.debug.m entryconfigure 1 -state normal $tools subwidget loadDebug configure -state normal # may not break debuggee $mbar.debug.m entryconfigure 3 -state disabled # may not stop/restart debugger $mbar.debug.m entryconfigure 5 -state disabled $mbar.debug.m entryconfigure 6 -state disabled } DebuggeeHeldEvent { global Debugger:childState # may not break debuggee $mbar.debug.m entryconfigure 3 -state disabled # may not hold simulation (using the simulation controls) $controls subwidget holdSimulation configure -state disabled if {${Debugger:childState} == "released"} { # may release simulation (using the simulation controls) # (unless child is in a zombie state) $controls subwidget releaseSimulation configure -state normal } } DebuggeeReleasedEvent { global Monitor:channel # may break debuggee (if the monitor is up) if {${Monitor:channel} != {}} { $mbar.debug.m entryconfigure 3 -state normal # may hold simulation (using the simulation controls) $controls subwidget holdSimulation configure -state normal # may not release simulation (using the simulation controls) $controls subwidget releaseSimulation configure -state disabled } } DebuggerExceptionEvent { # may access simulation controls $controls configure -state disabled # may not hold simulation (using Simulation menu) $mbar.simulation.m entryconfigure 1 -state disabled # may not break debuggee (using Debug menu) $mbar.debug.m entryconfigure 3 -state disabled # disable speed spinbox $context.mtoolbar.speed.control config -state disabled # may not inspect simulation $mbar.simulation.m entryconfigure 3 -state disabled # may not trace simulation $mbar.simulation.m entryconfigure 4 -state disabled # may not access simulation timers $mbar.simulation.m entryconfigure 5 -state disabled # update status icon $context.mtoolbar.status config -image [fetchImage brkcrash] } MonitorConnectEvent { global Monitor:simulationState # may break debuggee (if still released) if {${Monitor:simulationState} == "released"} { $mbar.debug.m entryconfigure 3 -state normal } # may hold simulation $mbar.simulation.m entryconfigure 1 -state normal } MonitorShutdownEvent { # save timers then destroy timer manager TimerManager:saveTimers $context TimerManager:destroy $context # save display status global Monitor:initState if {${Monitor:initState} == "ok"} { Workspace:saveDisplays $context } } MonitorDisconnectEvent { # may not break debuggee $mbar.debug.m entryconfigure 3 -state disabled # may not hold simulation $mbar.simulation.m entryconfigure 1 -state disabled # may not release simulation $mbar.simulation.m entryconfigure 2 -state disabled # may not access simulation controls pack forget $controls # hide simulation clock & speed pack forget $context.mtoolbar.clock pack forget $context.mtoolbar.speed pack forget $context.mtoolbar.status } TimeUpdateEvent { global Monitor:currentTime Workspace:runIcons global Workspace:statusFlip Monitor:simulationState $context.mtoolbar.clock config -text \ [format "Time: %s" ${Monitor:currentTime}] if {${Monitor:simulationState} == "released"} { # flicker status set nth ${Workspace:statusFlip} $context.mtoolbar.status config -image [set Workspace:runIcons($nth)] set nth [expr 1 - $nth] set Workspace:statusFlip $nth } } WorkspaceQuitEvent { Session:save $context } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -