hs-highlight-1.0.4: A tool to highlight terminal strings
Copyright(c) Lorenzobattistela 2024
LicenseMIT
Maintainerlorenzobattistela@gmail.com
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

Highlight

Description

This module provides functions to highlight and format text in terminal output, particularly useful for displaying code snippets with error highlighting.

Synopsis

Documentation

highlightError :: (Int, Int) -> (Int, Int) -> String -> String Source #

Highlight errors with red color and underline.

This function highlights text in the specified range with red color and underline.

  • sLine, sCol: Starting line and column position.
  • eLine, eCol: Ending line and column position.
  • file: The text content to process.

Returns the highlighted text.

highlight :: (Int, Int) -> (Int, Int) -> String -> (String -> String) -> String -> String Source #

Highlight text in the given range.

This function highlights text within the specified range with the provided color and formatting function.

  • sPos: Starting position as a tuple (line, column).
  • ePos: Ending position as a tuple (line, column).
  • color: The color code to apply for highlighting.
  • format: A function to format the highlighted text.
  • file: The text content to process.

Returns the highlighted text.

underline Source #

Arguments

:: String

Text to underline

-> String

Underlined text

Applies underline formatting to text using ANSI escape codes.

bold Source #

Arguments

:: String

Text to make bold

-> String

Bold text

Applies bold formatting to text using ANSI escape codes.

italic Source #

Arguments

:: String

Text to italicize

-> String

Italicized text

Applies italic formatting to text using ANSI escape codes.

parenthesize Source #

Arguments

:: String

Text to parenthesize

-> String

Parenthesized text

Wraps text in parentheses.

strikethrough Source #

Arguments

:: String

Text to strikethrough

-> String

Strikethrough text

Applies strikethrough formatting to text using ANSI escape codes.

inverse Source #

Arguments

:: String

Text to inverse

-> String

Inversed text

Applies inverse (reverse video) formatting to text using ANSI escape codes.

getColor Source #

Arguments

:: String

Color name

-> String

ANSI color code

Gets the ANSI color code for a given color name.