Class Terminals
- All Implemented Interfaces:
ContextProvider, PropertyChangeSource, Rebindable
This is the IntelliJ port of the NetBeans NbTerminal. Where NetBeans crawls the
dlight terminal container and reflects into a private Term.fireChars, IntelliJ
offers first-class APIs: TerminalToolWindowManager.createLocalShellWidget(String, String) to open a
shell and ShellTerminalWidget.executeCommand(String) to run a command. Opened widgets are
tracked by identity id in a transient map so subsequent calls can address them; the map is
rebuilt on session activation (terminals do not survive a restart).
- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionIdentity-keyed registry of terminals opened by this toolkit.Fields inherited from class AnahataToolkit
childrenProviders, propertyChangeSupportFields inherited from class ToolContext
toolkit -
Constructor Summary
ConstructorsConstructorDescriptionConstructs the Terminals toolkit (instantiated reflectively via its public no-arg constructor). -
Method Summary
Modifier and TypeMethodDescriptioncloseTerminal(long terminalId) Closes a tracked terminal tab.private com.intellij.openapi.project.ProjectReturns the first open project, which hosts newly created terminals.longopenLocalTerminal(String title, String workingDirectory) Opens a new local terminal tab and returns its tracking id.voidrebind()Rebinds the toolkit after deserialization.typeCommand(long terminalId, String command) Types a command into a tracked terminal and executes it.Methods inherited from class AnahataToolkit
getChildrenProviders, getDescription, getId, getName, getParentProvider, getPropertyChangeSupport, initialize, isEffectivelyProviding, postActivateMethods inherited from class ToolContext
addAttachment, addAttachment, addAttachment, error, error, getAgi, getApplicationMap, getAsiContainer, getAsiContainerMap, getCall, getExecutorService, getModelId, getModelMessage, getResourceManager, getResponse, getSessionMap, getThreadSafeLogger, getTool, getToolContext, getToolkit, getToolManager, getTurnMap, isToolExecution, log, peekResponse, runAsyncMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextProvider
getAgi, getContextPosition, getFlattenedHierarchy, getFullyQualifiedId, getHeader, getIconId, getInstructionsTokenCount, getRagTokenCount, getSystemInstructions, isProviding, populateMessage, setParentProvider, setProviding
-
Field Details
-
widgets
-
-
Constructor Details
-
Terminals
public Terminals()Constructs the Terminals toolkit (instantiated reflectively via its public no-arg constructor).
-
-
Method Details
-
rebind
public void rebind()Rebinds the toolkit after deserialization.This method is called by the framework during session activation to restore transient state, reconnect listeners, or refresh cached project instances. It ensures the
propertyChangeSupportis re-initialized.Re-initializes the transient terminal registry after deserialization.
- Specified by:
rebindin interfaceRebindable- Overrides:
rebindin classAnahataToolkit
-
openLocalTerminal
Opens a new local terminal tab and returns its tracking id.- Parameters:
title- the tab title, ornullfor the default.workingDirectory- the initial working directory, ornullfor the default.- Returns:
- the identity id used to address this terminal in later calls.
- Throws:
AgiToolException- if no project is open.
-
typeCommand
Types a command into a tracked terminal and executes it.- Parameters:
terminalId- the id returned byopenLocalTerminal(String, String).command- the command line to execute.- Returns:
- a confirmation message.
- Throws:
AgiToolException- if the terminal id is unknown or the command cannot be written.
-
closeTerminal
Closes a tracked terminal tab.- Parameters:
terminalId- the id returned byopenLocalTerminal(String, String).- Returns:
- a confirmation message.
- Throws:
AgiToolException- if the terminal id is unknown.
-
firstOpenProject
Returns the first open project, which hosts newly created terminals.- Returns:
- the first open project.
- Throws:
AgiToolException- if no project is open.
-

