Scylla Framework
  • API Reference
Search Results for

    Show / Hide Table of Contents
    • Scylla.Console.TextMode
      • IConsoleScreen
      • TextModeDebugConsoleDisplay
      • TicTacToeCommand
      • TicTacToeScreen
    • Scylla.TextMode
      • ANSIAttributeParser
      • ANSIColor
      • ANSISGRAttributes
      • AmbientEffectBase
      • BackgroundBlendMode
      • BoxStyle
      • BoxStyleCharacters
      • BoxStyleCharacters.BoxChars
      • CRTSettings
      • Cell
      • CellAttributes
      • CellAttributesExtensions
      • CellBuffer
      • CellBufferRenderer
      • CellGrid
      • CellMask
      • CellPosition
      • CellRange
      • CellRect
      • ColorCycleEffect
      • ColorCycleEffectPreset
      • CrossFadeEffect
      • CursorStyle
      • DecodeEffect
      • DecodeEffectPreset
      • DigitalRainEffect
      • DigitalRainEffectPreset
      • EffectsSettings
      • FadeEffect
      • FadeEffectPreset
      • FlickerEffect
      • FlickerEffectPreset
      • GlitchEffect
      • GlitchEffectPreset
      • GlyphAtlasCache
      • GridSettings
      • IAutoCompleter
      • IInputHistory
      • ITextEffect
      • ITextEffectContext
      • ITextModeGridProvider
      • ITextModePointerMapper
      • ITextModeRenderSource
      • ITextModeViewHost
      • IVTParserHandler
      • InputHistory
      • MaskTransitionEffect
      • MouseEncodingMode
      • MouseTrackingMode
      • PackedGlyphData
      • PulseEffect
      • PulseEffectPreset
      • PushEffect
      • PushEffectPreset
      • SDFSettings
      • ScrollbackAttributeRun
      • ScrollbackLine
      • ScyllaTextMode
      • ScyllaTextMode.Meta
      • ScyllaTextModeConfiguration
      • SlideInEffect
      • SlideInEffectPreset
      • StaticTuneInEffect
      • StaticTuneInEffectPreset
      • TerminalCLI
      • TerminalEmulator
      • TerminalGridRenderer
      • TerminalInputEncoder
      • TerminalMouseButton
      • TerminalScrollbackBuffer
      • TerminalSettings
      • TextAlignment
      • TextEffectBase
      • TextEffectCompletedEvent
      • TextEffectDirection
      • TextEffectExtensions
      • TextEffectMaskPattern
      • TextEffectPreset
      • TextEffectPushMode
      • TextEffectSequencer
      • TextEffectStartedEvent
      • TextEffectState
      • TextEffectTimeMode
      • TextEffects
      • TextModeCellBorder
      • TextModeColorDefaults
      • TextModeColorScheme
      • TextModeColorSet
      • TextModeConfigurationChangedEvent
      • TextModeConsole
      • TextModeConstants
      • TextModeEffectPlayer
      • TextModeGridCapture
      • TextModeLayoutUtil
      • TextModeMaterials
      • TextModeMouseReporter
      • TextModeMouseReportingEvent
      • TextModeSelectionChangedEvent
      • TextModeSelectionEndedEvent
      • TextModeSelectionManager
      • TextModeSelectionStartedEvent
      • TextModeTerminal
      • TextModeTerminalColorTheme
      • TextModeTerminalHost
      • TextModeTerminalSettings
      • TextModeTerminalStartMode
      • TextModeThemeBackground
      • TextModeThemeChangedEvent
      • TextModeThemeRemapper
      • TextModeThemes
      • TextModeView
      • TextWrapMode
      • ThemeSettings
      • TransitionEffectBase
      • TransitionEffectPreset
      • TwinkleEffect
      • TwinkleEffectPreset
      • TypewriterCharacterRevealedEvent
      • TypewriterEffect
      • TypewriterEffectPreset
      • UITextModeView
      • VTParser
      • WaveEffect
      • WaveEffectPreset
    • Scylla.TextMode.CRT
      • CRTBeam
      • CRTBeamClock
      • CRTBeamScanDirection
      • CRTBeamStatus
      • CRTCalibrationPattern
      • CRTCurvatureShape
      • CRTGeometry
      • CRTHDR
      • CRTHDRDisplay
      • CRTHDRTarget
      • CRTHorizontalKernel
      • CRTImageRegion
      • CRTMaskType
      • CRTQualityTier
      • CRTScaleMode
      • CRTSignalStandard
      • CRTSignalType
      • ITextModeCRTCameraEffect
      • ITextModeCRTHDRDisplaySource
      • TextModeCRTBeam
      • TextModeCRTCalibration
      • TextModeCRTCameraEffects
      • TextModeCRTConstants
      • TextModeCRTDriver
      • TextModeCRTHDR
      • TextModeCRTImageRenderer
      • TextModeCRTMonitor
      • TextModeCRTPreset
      • TextModeCRTPresetRegistry
      • TextModeCRTScreen
      • TextModeCRTSettings
      • TextModeCRTTube
    • Scylla.TextMode.Editor
      • CellGridPreviewWidget
      • ColorPaletteWidget
      • ITextModeCRTCameraSetupProvider
      • ScyllaTextModeConfigurationEditor
      • ScyllaTextModeDependencyProvider
      • ScyllaTextModeEditor
      • ScyllaTextModeMenuItems
      • ScyllaTextModeShaderProvider
      • TextModeCRTCameraSetup
      • TextModeCRTCameraStatus
      • TextModeCRTDriverEditor
      • TextModeCRTMonitorEditor
      • TextModeCRTPresetEditor
      • TextModeCRTPresetGenerator
      • TextModeColorAssetGenerator
      • TextModeColorPaletteDefaults
      • TextModeTerminalHostEditor
      • TextModeThemeField
      • TextModeViewEditor
      • TextModeViewEditorBase
      • UITextModeViewEditor
    • Scylla.TextMode.URP
      • CRTQualityTierParameter
      • TextModeCRTInjectionPoint
      • TextModeCRTPresetParameter
      • TextModeCRTRendererFeature
      • TextModeCRTVolume

    Class ANSIAttributeParser

    Splits a line of text that carries ANSI style markup into the plain characters to display and the attribute runs that describe how to display them.

    Inheritance
    object
    ANSIAttributeParser
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Scylla.TextMode
    Assembly: ScyllaTextMode.dll
    Syntax
    public static class ANSIAttributeParser
    Remarks

    This is the lightweight counterpart to TerminalEmulator. The emulator maintains a live screen and understands the full escape repertoire; this parser handles a single finished line on its way into the scrollback, where the only thing that can vary within the line is its style. Both share one style table, in ANSISGRAttributes.

    Escape sequences are removed rather than displayed, so the returned text measures and wraps exactly as the reader sees it, and a copy of the line to the clipboard carries no control characters. Sequences that are not SGR are dropped without effect.

    Marking a word for inverse display, where ESC stands for the escape character:

    var runs = new List<ScrollbackAttributeRun>();
    var plain = ANSIAttributeParser.Parse("Status: ESC[7mACTIVEESC[27m", runs);
    /* plain is "Status: ACTIVE", runs holds one Inverse run at 8 for 6 characters. */

    Methods

    ContainsMarkup(string)

    Determines whether a string contains anything this parser would act on.

    Declaration
    public static bool ContainsMarkup(string text)
    Parameters
    Type Name Description
    string text

    The text to test; may be null.

    Returns
    Type Description
    bool

    true if the text contains an escape character, meaning Parse(string, List<ScrollbackAttributeRun>) may change it; otherwise false.

    Remarks

    Use this to skip the parser entirely for ordinary text, which is the common case.

    Parse(string, List<ScrollbackAttributeRun>)

    Removes the escape sequences from a line and reports the attribute runs they describe.

    Declaration
    public static string Parse(string text, List<ScrollbackAttributeRun> runs)
    Parameters
    Type Name Description
    string text

    The text to parse; may be null.

    List<ScrollbackAttributeRun> runs

    A list that receives one entry per styled span, in ascending order and without overlaps. The list is cleared first. Spans with no attributes are not recorded, so an unstyled line leaves the list empty. May be null to discard the runs and keep only the stripped text.

    Returns
    Type Description
    string

    The text with every escape sequence removed, or an empty string when text is null or empty. The original reference is returned unchanged when the text carries no escape character.

    Remarks

    Attributes carry across the whole line from the point they are switched on, so a line that never switches them off stays styled to its end. Each line is parsed on its own and starts unstyled.

    Slice(List<ScrollbackAttributeRun>, int, int)

    Rebases a set of attribute runs onto a substring of the text they were parsed from.

    Declaration
    public static ScrollbackAttributeRun[] Slice(List<ScrollbackAttributeRun> runs, int start, int length)
    Parameters
    Type Name Description
    List<ScrollbackAttributeRun> runs

    The runs covering the whole text.

    int start

    The index at which the substring begins.

    int length

    The length of the substring.

    Returns
    Type Description
    ScrollbackAttributeRun[]

    A new array holding the portions of runs that fall inside the substring, with positions relative to it, or null when none do.

    Remarks

    A multi-line message is stored as one scrollback line per linebreak, and each of those lines needs the runs that cover it expressed in its own coordinates.

    See Also

    ANSISGRAttributes
    ScrollbackAttributeRun
    In this article
    Back to top Scylla Framework - TextMode Module API Documentation