xmonad-contrib-0.18.0.9: Community-maintained extensions for xmonad
Copyright(c) Tom Smeets <tom.tsmeets@gmail.com>
LicenseBSD3-style (see LICENSE)
MaintainerTom Smeets <tom.tsmeets@gmail.com>
Stabilityunstable
Portabilityunportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

XMonad.Util.TreeZipper

Description

Zipper over the Data.Tree data structure. This module is based on rosezipper.

Synopsis

Data structure

data TreeZipper a Source #

A Zipper over the Data.Tree data structure.

Very crappy visualization of the TreeZipper data structure

             (tz_parents)
       ([*],       *, [*])
       ([*, *],    *, [])
       ([],        *                  [*,   *])
                   |                   |    |
  +-------+--------+-------+------+  +-*-+  *
  |       |        |       |      |  |   |
 (tz_before) (tz_current) (tz_after) *   *
  |       |                |      |
+-*-+     *                *      *
|   |
*   *

Constructors

TreeZipper 

Fields

  • tz_current :: Tree a

    the currently focused sub-tree under the cursor

  • tz_before :: Forest a

    all sub-tree's to the left of the cursor that have the same parent

  • tz_after :: Forest a

    all sub-tree's to the right of the cursor that have the same parent

  • tz_parents :: [(Forest a, a, Forest a)]

    list zippers for each parent level, the first element is the current parent

cursor :: TreeZipper a -> a Source #

Get the highlighted value

Conversion

fromForest :: Forest a -> TreeZipper a Source #

Create a TreeZipper from a list of Trees focused on the first element

toForest :: TreeZipper a -> Forest a Source #

Convert the entire zipper back to a Forest

getSubForest :: TreeZipper a -> Forest a Source #

Create a Forest from all the children of the current parent

Navigation

rootNode :: TreeZipper a -> TreeZipper a Source #

Go to the upper most node such that nothing is before nor above the cursor

parent :: TreeZipper a -> Maybe (TreeZipper a) Source #

Move to the parent node

children :: TreeZipper a -> Maybe (TreeZipper a) Source #

Move the cursor one level down to the first node

nextChild :: TreeZipper a -> Maybe (TreeZipper a) Source #

Go to the next child node

previousChild :: TreeZipper a -> Maybe (TreeZipper a) Source #

Go to the previous child node

Utils

nodeDepth :: TreeZipper a -> Int Source #

How many nodes are above this one?

nodeIndex :: TreeZipper a -> Int Source #

How many nodes are before the cursor? (on the current level)

followPath :: Eq b => (a -> b) -> [b] -> TreeZipper a -> Maybe (TreeZipper a) Source #

follow a Path specified by the list of nodes

findChild :: (a -> Bool) -> TreeZipper a -> Maybe (TreeZipper a) Source #

go to the first node next to the cursor that matches

isLeaf :: TreeZipper a -> Bool Source #

Check whenther this is a leaf node

isRoot :: TreeZipper a -> Bool Source #

Check whenther this is a leaf node

isLast :: TreeZipper a -> Bool Source #

Check whenther this the last child

isFirst :: TreeZipper a -> Bool Source #

Check whenther this the first child