Foundry.FileSearchReplacement

g Foundry.FileSearchReplacement Foundry.FileSearchReplacement GObject.Object GObject.Object GObject.Object->Foundry.FileSearchReplacement

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (context, matches, options, replacement_text)

apply ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Foundry.FileSearchReplacement(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Foundry.FileSearchReplacementClass

Perform text replacements across search matches.

This class takes a list of [class`Foundry`.FileSearchMatch] objects and applies text replacements to each match location. It supports both literal text replacement and regex-based replacement with back references.

The replacement operation is performed asynchronously using fibers, and all edits are applied through the [class`Foundry`.TextManager] to ensure proper undo/redo support. The files are saved after applying changes.

New in version 1.1.

classmethod new(context, matches, options, replacement_text)
Parameters:
  • context (Foundry.Context) – a [class`Foundry`.Context]

  • matches (Gio.ListModel) – a [iface`Gio`.ListModel] of [class`Foundry`.FileSearchMatch]

  • options (Foundry.FileSearchOptions) – a [class`Foundry`.FileSearchOptions]

  • replacement_text (str) – the replacement text (may contain back references if regex is enabled)

Returns:

a new [class`Foundry`.FileSearchReplacement]

Return type:

Foundry.FileSearchReplacement

Creates a new [class`Foundry`.FileSearchReplacement] for performing single or bulk text replacements.

The replacement_text can contain back references (like \1, \2, etc.) if options has regex enabled via [method`Foundry`.FileSearchOptions.set_use_regex].

New in version 1.1.

apply()
Returns:

a [class`Dex`.Future] that completes when all replacements are finished

Return type:

Dex.Future

Applies the text replacements to all matched locations.

This method starts a fiber and performs replacements asynchronously. Each replacement is performed using [class`Foundry`.TextEdit] and applied using [class`Foundry`.TextManager].

New in version 1.1.