Raxol.Terminal.ScreenBuffer.FileWatcher (Raxol v0.5.0)

View Source

Handles file system event monitoring for the terminal screen buffer. This module provides functions for processing file system events and managing debounced event handling.

Summary

Functions

Cleans up the file watcher state. Returns a new file watcher state with all watched paths and pending events cleared.

Handles debounced file system events. Returns a new file watcher state with the events processed after the timeout.

Handles a file system event. Returns a new file watcher state with the event processed.

Initializes a new file watcher struct with default values.

Types

debounce_timeout()

@type debounce_timeout() :: non_neg_integer()

event()

@type event() :: {:created, Path.t()} | {:modified, Path.t()} | {:deleted, Path.t()}

events()

@type events() :: [event()]

t()

@type t() :: %Raxol.Terminal.ScreenBuffer.FileWatcher{
  last_event_time: non_neg_integer(),
  pending_events: events(),
  watched_paths: MapSet.new(Path.t())
}

Functions

cleanup(state)

@spec cleanup(t()) :: t()

Cleans up the file watcher state. Returns a new file watcher state with all watched paths and pending events cleared.

handle_debounced(state, events, timeout)

@spec handle_debounced(t(), events(), debounce_timeout()) :: t()

Handles debounced file system events. Returns a new file watcher state with the events processed after the timeout.

handle_event(state, event)

@spec handle_event(t(), event()) :: t()

Handles a file system event. Returns a new file watcher state with the event processed.

init()

Initializes a new file watcher struct with default values.