yi-core-0.19.4: Yi editor core library

License | GPL-2
Maintainer | yi-devel@googlegroups.com
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010
Extensions | DeriveDataTypeable

Yi.Buffer.TextUnit

Description

Working with blocks (units) of text.

Synopsis

- data TextUnit
  - = Character
  - | Line
  - | VLine
  - | Document
  - | GenUnit {
    - genEnclosingUnit :: TextUnit
    - genUnitBoundary :: Direction -> BufferM Bool
    }
- outsideUnit :: TextUnit -> TextUnit
- leftBoundaryUnit :: TextUnit -> TextUnit
- unitWord :: TextUnit
- unitViWord :: TextUnit
- unitViWORD :: TextUnit
- unitViWordAnyBnd :: TextUnit
- unitViWORDAnyBnd :: TextUnit
- unitViWordOnLine :: TextUnit
- unitViWORDOnLine :: TextUnit
- unitDelimited :: Char -> Char -> Bool -> TextUnit
- unitSentence :: TextUnit
- unitEmacsParagraph :: TextUnit
- unitParagraph :: TextUnit
- isAnySep :: Char -> Bool
- unitSep :: TextUnit
- unitSepThisLine :: TextUnit
- isWordChar :: Char -> Bool
- moveB :: TextUnit -> Direction -> BufferM ()
- maybeMoveB :: TextUnit -> Direction -> BufferM ()
- transformB :: (YiString -> YiString) -> TextUnit -> Direction -> BufferM ()
- transposeB :: TextUnit -> Direction -> BufferM ()
- regionOfB :: TextUnit -> BufferM Region
- regionOfNonEmptyB :: TextUnit -> BufferM Region
- regionOfPartB :: TextUnit -> Direction -> BufferM Region
- regionWithTwoMovesB :: BufferM a -> BufferM b -> BufferM Region
- regionOfPartNonEmptyB :: TextUnit -> Direction -> BufferM Region
- regionOfPartNonEmptyAtB :: TextUnit -> Direction -> Point -> BufferM Region
- readPrevUnitB :: TextUnit -> BufferM YiString
- readUnitB :: TextUnit -> BufferM YiString
- untilB :: BufferM Bool -> BufferM a -> BufferM [a]
- doUntilB_ :: BufferM Bool -> BufferM a -> BufferM ()
- untilB_ :: BufferM Bool -> BufferM a -> BufferM ()
- whileB :: BufferM Bool -> BufferM a -> BufferM [a]
- doIfCharB :: (Char -> Bool) -> BufferM a -> BufferM ()
- atBoundaryB :: TextUnit -> Direction -> BufferM Bool
- numberOfB :: TextUnit -> TextUnit -> BufferM Int
- deleteB :: TextUnit -> Direction -> BufferM ()
- genMaybeMoveB :: TextUnit -> (Direction, BoundarySide) -> Direction -> BufferM ()
- genMoveB :: TextUnit -> (Direction, BoundarySide) -> Direction -> BufferM ()
- data BoundarySide
  - = InsideBound
  - | OutsideBound
- genAtBoundaryB :: TextUnit -> Direction -> BoundarySide -> BufferM Bool
- checkPeekB :: Int -> [Char -> Bool] -> Direction -> BufferM Bool
- halfUnit :: Direction -> TextUnit -> TextUnit
- deleteUnitB :: TextUnit -> Direction -> BufferM ()

# Documentation

data TextUnit Source #

Designate a given "unit" of text.

Constructors

Character | a single character
Line | a line of text (between newlines)
VLine | a "vertical" line of text (area of text between two characters at the same column number)
Document | the whole document
GenUnit |

Fields

- genEnclosingUnit :: TextUnit
- genUnitBoundary :: Direction -> BufferM Bool

outsideUnit :: TextUnit -> TextUnit Source #

Turns a unit into its "negative" by inverting the boundaries. For example, `outsideUnit unitViWord` will be the unit of spaces between words. For units without boundaries (`Character`, `Document`, ...), this is the identity function.

leftBoundaryUnit :: TextUnit -> TextUnit Source #

Unit that have its left and right boundaries at the left boundary of the argument unit.

unitWord :: TextUnit Source #

a word as in use in Emacs (fundamental mode)

unitViWord :: TextUnit Source #

unitViWORD :: TextUnit Source #

unitViWordAnyBnd :: TextUnit Source #

unitViWORDAnyBnd :: TextUnit Source #

unitViWordOnLine :: TextUnit Source #

unitViWORDOnLine :: TextUnit Source #

unitDelimited :: Char -> Char -> Bool -> TextUnit Source #

delimited on the left and right by given characters, boolean argument tells if whether those are included.

unitSentence :: TextUnit Source #

unitEmacsParagraph :: TextUnit Source #

Paragraph to implement emacs-like forward-paragraph/backward-paragraph

unitParagraph :: TextUnit Source #

Paragraph that begins and ends in the paragraph, not the empty lines surrounding it.

isAnySep :: Char -> Bool Source #

Separator characters (space, tab, unicode separators). Most of the units above attempt to identify "words" with various punctuation and symbols included or excluded. This set of units is a simple inverse: it is true for "whitespace" or "separators" and false for anything that is not (letters, numbers, symbols, punctuation, whatever).

unitSep :: TextUnit Source #

unitSep is true for any kind of whitespace/separator

unitSepThisLine :: TextUnit Source #

unitSepThisLine is true for any kind of whitespace/separator on this line only

isWordChar :: Char -> Bool Source #

moveB :: TextUnit -> Direction -> BufferM () Source #

Move to the next unit boundary

maybeMoveB :: TextUnit -> Direction -> BufferM () Source #

As `moveB`, unless the point is at a unit boundary

transformB :: (YiString -> YiString) -> TextUnit -> Direction -> BufferM () Source #

Transforms the region given by `TextUnit` in the `Direction` with user-supplied function.

transposeB :: TextUnit -> Direction -> BufferM () Source #

regionOfB :: TextUnit -> BufferM Region Source #

Region of the whole textunit where the current point is.

regionOfNonEmptyB :: TextUnit -> BufferM Region Source #

Non empty region of the whole textunit where the current point is.

regionOfPartB :: TextUnit -> Direction -> BufferM Region Source #

Region between the point and the next boundary. The region is empty if the point is at the boundary.

regionWithTwoMovesB :: BufferM a -> BufferM b -> BufferM Region Source #

regionOfPartNonEmptyB :: TextUnit -> Direction -> BufferM Region Source #

Non empty region between the point and the next boundary, In fact the region can be empty if we are at the end of file.

regionOfPartNonEmptyAtB :: TextUnit -> Direction -> Point -> BufferM Region Source #

Non empty region at given point and the next boundary,

readPrevUnitB :: TextUnit -> BufferM YiString Source #

readUnitB :: TextUnit -> BufferM YiString Source #

untilB :: BufferM Bool -> BufferM a -> BufferM [a] Source #

Repeat an action until the condition is fulfilled or the cursor stops moving. The Action may be performed zero times.

doUntilB_ :: BufferM Bool -> BufferM a -> BufferM () Source #

untilB_ :: BufferM Bool -> BufferM a -> BufferM () Source #

whileB :: BufferM Bool -> BufferM a -> BufferM [a] Source #

doIfCharB :: (Char -> Bool) -> BufferM a -> BufferM () Source #

Do an action if the current buffer character passes the predicate

atBoundaryB :: TextUnit -> Direction -> BufferM Bool Source #

numberOfB :: TextUnit -> TextUnit -> BufferM Int Source #

deleteB :: TextUnit -> Direction -> BufferM () Source #

Delete between point and next unit boundary, return the deleted region.

genMaybeMoveB :: TextUnit -> (Direction, BoundarySide) -> Direction -> BufferM () Source #

Generic maybe move operation. As genMoveB, but don't move if we are at boundary already.

genMoveB :: TextUnit -> (Direction, BoundarySide) -> Direction -> BufferM () Source #

Generic move operation Warning: moving To the (OutsideBound, Backward) bound of Document is impossible (offset -1!) `genMoveB u b d`: move in direction d until encountering boundary b or unit u. See `genAtBoundaryB` for boundary explanation.

data BoundarySide Source #

Boundary side

Constructors

InsideBound |
OutsideBound |

#### Instances

Instances details

Eq BoundarySide Source # |
Instance details Defined in Yi.Buffer.TextUnit Methods (==) :: BoundarySide -> BoundarySide -> Bool Source # (/=) :: BoundarySide -> BoundarySide -> Bool Source #

genAtBoundaryB :: TextUnit -> Direction -> BoundarySide -> BufferM Bool Source #

`genAtBoundaryB u d s` returns whether the point is at a given boundary `(d,s)` . Boundary `(d,s)` , taking Word as example, means: Word ^^ ^^ 12 34 1: (Backward,OutsideBound) 2: (Backward,InsideBound) 3: (Forward,InsideBound) 4: (Forward,OutsideBound)

rules: genAtBoundaryB u Backward InsideBound = atBoundaryB u Backward genAtBoundaryB u Forward OutsideBound = atBoundaryB u Forward

checkPeekB :: Int -> [Char -> Bool] -> Direction -> BufferM Bool Source #

halfUnit :: Direction -> TextUnit -> TextUnit Source #

deleteUnitB :: TextUnit -> Direction -> BufferM () Source #