Package ghidra.app.services

# Interface CodeViewerService

All Known Subinterfaces:
  `DebuggerListingService`

public interface CodeViewerService
Service provided by a plugin that shows the listing from a Program, i.e., a Code Viewer. The service allows other plugins to add components and actions local to the Code Viewer.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addButtonPressedListener(ButtonPressedListener listener)`
  Add a listener that is notified when a mouse button is pressed.
  `void`
  `addListingDisplayListener(AddressSetDisplayListener listener)`
  Adds a listener to be notified when the set of visible addresses change.
  `void`
  `addLocalAction(DockingAction action)`
  Add an action that is local to the Code Viewer.
  `void`
  `addMarginProvider(MarginProvider marginProvider)`
  Add a provider that shows markers in a program for the portion that is visible.
  `void`
  `addOverviewProvider(OverviewProvider overviewProvider)`
  Add a provider that shows an overview of the program.
  `void`
  `addProgramDropProvider(ProgramDropProvider provider)`
  Add a provider that will be notified for drag and drop actions.
  `AddressIndexMap`
  `getAddressIndexMap()`
  Returns the current address-index-map
  `Field`
  `getCurrentField()`
  Returns the current field under the cursor.
  `String`
  `getCurrentFieldTextSelection()`
  Returns a String representing the current character-based selection of the currently selected field.
  `ProgramLocation`
  `getCurrentLocation()`
  Returns the current cursor location.
  `ProgramSelection`
  `getCurrentSelection()`
  Returns the current program selection (which crosses multiple fields).
  `FieldPanel`
  `getFieldPanel()`
  Return the fieldPanel.
  `FormatManager`
  `getFormatManager()`
  `ListingModel`
  `getListingModel()`
  Gets the current ListingLayoutModel;
  `ListingPanel`
  `getListingPanel()`
  Get the main Listing panel for the code viewer service.
  `Navigatable`
  `getNavigatable()`
  Gets the navigatable for the code viewer service.
  `AddressSetView`
  `getView()`
  Get Current view that the CodeViewer is showing.
  `boolean`
  `goTo(ProgramLocation loc, boolean centerOnScreen)`
  Commands the code viewer to position the cursor at the given location.
  `void`
  `removeButtonPressedListener(ButtonPressedListener listener)`
  Remove the button pressed listener.
  `void`
  `removeHighlightProvider(ListingHighlightProvider provider, Program program)`
  Remove the highlight provider.
  `void`
  `removeListingDisplayListener(AddressSetDisplayListener listener)`
  Removes listener from being notified when the set of visible addresses change.
  `void`
  `removeListingPanel(ListingPanel listingPanel)`
  Remove the given listing panel from the code viewer.
  `void`
  `removeLocalAction(DockingAction action)`
  Remove the local action from the Code Viewer.
  `void`
  `removeMarginProvider(MarginProvider marginProvider)`
  Remove a provider that shows markers in a program for the portion that is visible.
  `void`
  `removeOverviewProvider(OverviewProvider overviewProvider)`
  Remove a provider that shows an overview of the program.
  `void`
  `requestFocus()`
  Request that the main connected Listing view gets focus
  `void`
  `setCoordinatedListingPanelListener(CoordinatedListingPanelListener listener)`
  Set the `CoordinatedListingPanelListener` for this listing.
  `void`
  `setHighlightProvider(ListingHighlightProvider provider, Program program)`
  Set the highlight provider.
  `void`
  `setListingPanel(ListingPanel listingPanel)`
  Set a listing panel on the code viewer.
  `void`
  `setNorthComponent(JComponent comp)`
  Place a component in the North area of the CodeViewer.
  `void`
  `updateDisplay()`
  tells the browser to rebuild the display.

- ## Method Details

  - ### addOverviewProvider

    void addOverviewProvider(OverviewProvider overviewProvider)
    Add a provider that shows an overview of the program.
    Parameters:
      `overviewProvider` - provider to add

  - ### removeOverviewProvider

    void removeOverviewProvider(OverviewProvider overviewProvider)
    Remove a provider that shows an overview of the program.
    Parameters:
      `overviewProvider` - provider to remove

  - ### addMarginProvider

    void addMarginProvider(MarginProvider marginProvider)
    Add a provider that shows markers in a program for the portion that is visible.
    Parameters:
      `marginProvider` - provider to add

  - ### removeMarginProvider

    void removeMarginProvider(MarginProvider marginProvider)
    Remove a provider that shows markers in a program for the portion that is visible.
    Parameters:
      `marginProvider` - provider to remove

  - ### addLocalAction

    void addLocalAction(DockingAction action)
    Add an action that is local to the Code Viewer.
    Parameters:
      `action` - local action to add

  - ### removeLocalAction

    void removeLocalAction(DockingAction action)
    Remove the local action from the Code Viewer.
    Parameters:
      `action` - local action to remove

  - ### addProgramDropProvider

    void addProgramDropProvider(ProgramDropProvider provider)
    Add a provider that will be notified for drag and drop actions.
    Parameters:
      `provider` - for drag and drop

  - ### addButtonPressedListener

    void addButtonPressedListener(ButtonPressedListener listener)
    Add a listener that is notified when a mouse button is pressed.
    Parameters:
      `listener` -

  - ### removeButtonPressedListener

    void removeButtonPressedListener(ButtonPressedListener listener)
    Remove the button pressed listener.
    Parameters:
      `listener` -

  - ### setHighlightProvider

    void setHighlightProvider(ListingHighlightProvider provider, Program program)
    Set the highlight provider. The existing provider is replaced with the given provider.
    Parameters:
      `provider` - The provider to set.
      `program` - The program with which to associate the given provider.

  - ### removeHighlightProvider

    void removeHighlightProvider(ListingHighlightProvider provider, Program program)
    Remove the highlight provider.
    Parameters:
      `provider` - the provider to remove.
      `program` - the program associated with the given provider.

  - ### setListingPanel

    void setListingPanel(ListingPanel listingPanel)
    Set a listing panel on the code viewer.
    Parameters:
      `listingPanel` - the panel to add.

  - ### setCoordinatedListingPanelListener

    void setCoordinatedListingPanelListener(CoordinatedListingPanelListener listener)
    Set the `CoordinatedListingPanelListener` for this listing.
    Parameters:
      `listener` - the listener to add.

  - ### removeListingPanel

    void removeListingPanel(ListingPanel listingPanel)
    Remove the given listing panel from the code viewer.

  - ### getView

    AddressSetView getView()
    Get Current view that the CodeViewer is showing.

  - ### goTo

    boolean goTo(ProgramLocation loc, boolean centerOnScreen)
    Commands the code viewer to position the cursor at the given location.
    Parameters:
      `loc` - the location at which to position the cursor.
      `centerOnScreen` - if true, the location will be placed in the center of the display window
    Returns:
      true if the location exists.

  - ### getFieldPanel

    FieldPanel getFieldPanel()
    Return the fieldPanel.

  - ### getAddressIndexMap

    AddressIndexMap getAddressIndexMap()
    Returns the current address-index-map

  - ### getFormatManager

    FormatManager getFormatManager()

  - ### setNorthComponent

    void setNorthComponent(JComponent comp)
    Place a component in the North area of the CodeViewer.
    Parameters:
      `comp` - component to place in the North area of the CodeViewer

  - ### updateDisplay

    void updateDisplay()
    tells the browser to rebuild the display.

  - ### getListingModel

    ListingModel getListingModel()
    Gets the current ListingLayoutModel;
    Returns:
      the current ListingLayoutModel;

  - ### getNavigatable

    Navigatable getNavigatable()
    Gets the navigatable for the code viewer service.
    Returns:
      the navigatable for the code viewer service.

  - ### getListingPanel

    ListingPanel getListingPanel()
    Get the main Listing panel for the code viewer service.
    Returns:
      the listing panel.

  - ### getCurrentFieldTextSelection

    String getCurrentFieldTextSelection()
    Returns a String representing the current character-based selection of the currently selected field. If there is no selection, or if there is a `ProgramSelection` (which spans multiple fields), then this method will return null.

    To know which field contains the selection,

    Returns:
      the currently selected text within a given field

  - ### getCurrentField

    Field getCurrentField()
    Returns the current field under the cursor.
    Returns:
      the current field under the cursor.

  - ### getCurrentLocation

    ProgramLocation getCurrentLocation()
    Returns the current cursor location.
    Returns:
      the current cursor location.

  - ### getCurrentSelection

    ProgramSelection getCurrentSelection()
    Returns the current program selection (which crosses multiple fields).
    Returns:
      the current program selection.

  - ### addListingDisplayListener

    void addListingDisplayListener(AddressSetDisplayListener listener)
    Adds a listener to be notified when the set of visible addresses change.
    Parameters:
      `listener` - the listener to be notified;

  - ### removeListingDisplayListener

    void removeListingDisplayListener(AddressSetDisplayListener listener)
    Removes listener from being notified when the set of visible addresses change.
    Parameters:
      `listener` - the listener to be notified;

  - ### requestFocus

    void requestFocus()
    Request that the main connected Listing view gets focus