hscurses-1.4.1.2: NCurses bindings for Haskell

Safe Haskell | None

UI.HSCurses.Widgets

Synopsis

- type Pos = (Int, Int)
- type Offset = (Int, Int)
- type Size = (Int, Int)
- getHeight :: Size -> Int
- getWidth :: Size -> Int
- getYOffset :: Offset -> Int
- getXOffset :: Offset -> Int
- getYPos :: Pos -> Int
- getXPos :: Pos -> Int
- data Direction
  - = DirLeft
  - | DirRight
  - | DirUp
  - | DirDown
- data HAlignment
  - = AlignLeft
  - | AlignCenter
  - | AlignRight
- data Cont a
  - = Cont a
  - | Done a
- class Widget a where
  - draw :: Pos -> Size -> DrawingHint -> a -> IO ()
  - minSize :: a -> Size
- class Widget a => ActiveWidget a where
  - activate :: MonadExcIO m => m () -> Pos -> Size -> a -> m (a, String)
- type KeyHandler a = Pos -> Size -> a -> IO (Cont a)
- mkKeyHandler :: (Pos -> Size -> a -> a) -> KeyHandler a
- data DrawingHint
  - = DHNormal
  - | DHFocus
  - | DHActive
- data DrawingStyle = DStyle {
  - dstyle_normal :: CursesStyle
  - dstyle_focus :: CursesStyle
  - dstyle_active :: CursesStyle
  }
- mkDrawingStyle :: CursesStyle -> DrawingStyle
- defaultDrawingStyle :: DrawingStyle
- _draw :: DrawingHint -> DrawingStyle -> IO a -> IO a
- scrollFactor :: Double
- scrollBy :: Int -> Int
- scrollForward :: Int -> Int -> Int -> Int
- scrollBackward :: t -> Int -> Int -> Int
- data EmptyWidget = EmptyWidget Size
- data OpaqueWidget = OpaqueWidget Size
- data EditWidget = EditWidget {
  - ew_content :: String
  - ew_xoffset :: Int
  - ew_xcursor :: Int
  - ew_history :: [String]
  - ew_historyIndex :: Int
  - ew_historySavedContent :: Maybe String
  - ew_options :: EditWidgetOptions
  }
- ew_contentPos :: EditWidget -> Int
- data EditWidgetOptions = EWOptions {
  - ewopt_keyHandlers :: [(Key, KeyHandler EditWidget)]
  - ewopt_minWidth :: Int
  - ewopt_style :: DrawingStyle
  }
- defaultEWOptions :: EditWidgetOptions
- newEditWidget :: EditWidgetOptions -> String -> EditWidget
- editWidgetGoLeft :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)
- editWidgetGoRight :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)
- editWidgetDeleteLeft :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)
- editWidgetDeleteUnderCursor :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)
- editWidgetDeleteToEnd :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)
- editWidgetGoHome :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)
- editWidgetGoEnd :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)
- editWidgetHistoryUp :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)
- editWidgetHistoryDown :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)
- editWidgetKeyHandlers :: [(Key, Pos -> Size -> EditWidget -> IO (Cont EditWidget))]
- editWidgetGetContent :: EditWidget -> String
- editWidgetSetContent :: EditWidget -> String -> EditWidget
- editWidgetGetOptions :: EditWidget -> EditWidgetOptions
- editWidgetSetOptions :: EditWidget -> EditWidgetOptions -> EditWidget
- drawEditWidget :: Pos -> Size -> DrawingHint -> EditWidget -> IO ()
- activateEditWidget :: MonadExcIO m => m () -> Pos -> Size -> EditWidget -> m (EditWidget, String)
- editWidgetGoLeft' :: t -> t1 -> EditWidget -> EditWidget
- editWidgetGoRight' :: t -> (t1, Int) -> EditWidget -> EditWidget
- editWidgetDeleteLeft' :: Pos -> Size -> EditWidget -> EditWidget
- editWidgetDeleteUnderCursor' :: t -> t1 -> EditWidget -> EditWidget
- editWidgetDeleteToEnd' :: t -> t1 -> EditWidget -> EditWidget
- editWidgetGoHome' :: t -> t1 -> EditWidget -> EditWidget
- editWidgetGoEnd' :: Pos -> Size -> EditWidget -> EditWidget
- editWidgetFinish :: Monad m => t -> t1 -> EditWidget -> m (Cont EditWidget)
- maxHistoryLength :: Int
- addToHistory :: EditWidget -> [Char] -> EditWidget
- editWidgetHistoryUp' :: t -> t1 -> EditWidget -> EditWidget
- editWidgetHistoryDown' :: t -> t1 -> EditWidget -> EditWidget
- editWidgetHistory :: Num t => (Int -> t -> Int) -> EditWidget -> EditWidget
- data TextWidget = TextWidget {
  - tw_text :: String
  - tw_yoffset :: Int
  - tw_xoffset :: Int
  - tw_options :: TextWidgetOptions
  }
- data TextWidgetSize
  - = TWSizeDefault
  - | TWSizeFixed Size
- data TextWidgetOptions = TWOptions {
  - twopt_size :: TextWidgetSize
  - twopt_style :: DrawingStyle
  - twopt_halign :: HAlignment
  }
- defaultTWOptions :: TextWidgetOptions
- newTextWidget :: TextWidgetOptions -> String -> TextWidget
- drawTextWidget :: Pos -> Size -> DrawingHint -> TextWidget -> IO ()
- textWidgetGetText :: TextWidget -> String
- textWidgetSetText :: TextWidget -> String -> TextWidget
- textWidgetScrollDown :: Size -> TextWidget -> TextWidget
- textWidgetScrollUp :: Size -> TextWidget -> TextWidget
- textWidgetScrollLeft :: Size -> TextWidget -> TextWidget
- textWidgetScrollRight :: Size -> TextWidget -> TextWidget
- data TableCell
  - = forall w . Widget w => TableCell w
  - | forall w . ActiveWidget w => ActiveTableCell w
- isActive :: TableCell -> Bool
- _activateTableCell :: MonadExcIO m => m () -> Pos -> Size -> TableCell -> m (TableCell, String)
- type Row = [TableCell]
- singletonRow :: TableCell -> Row
- getCellWidget :: TableWidget -> (Int, Int) -> TableCell
- setCellWidget :: TableWidget -> (Int, Int) -> TableCell -> TableWidget
- data TableWidget = TableWidget {
  - tbw_rows :: [Row]
  - tbw_colOffset :: Int
  - tbw_pos :: Maybe Pos
  - tbw_options :: TableWidgetOptions
  }
- data FillRow
  - = First
  - | Last
  - | None
- data TableWidgetOptions = TBWOptions {
  - tbwopt_fillCol :: Maybe Int
  - tbwopt_fillRow :: FillRow
  - tbwopt_activeCols :: [Int]
  - tbwopt_minSize :: Size
  }
- defaultTBWOptions :: TableWidgetOptions
- newTableWidget :: TableWidgetOptions -> [Row] -> TableWidget
- data TableWidgetDisplayInfo = TBWDisplayInfo {
  - tbwdisp_height :: Int
  - tbwdisp_width :: Int
  - tbwdisp_firstVis :: Int
  - tbwdisp_lastVis :: Int
  - tbwdisp_rows :: [Row]
  - tbwdisp_nrows :: Int
  - tbwdisp_heights :: [Int]
  - tbwdisp_widths :: [Int]
  - tbwdisp_rightMargin :: Maybe (Int, Size)
  }
- tableWidgetDisplayInfo :: Size -> TableWidget -> TableWidgetDisplayInfo
- getCellInfo :: Pos -> Size -> TableWidget -> (Int, Int) -> (Pos, Size)
- drawTableWidget :: Pos -> Size -> DrawingHint -> TableWidget -> IO ()
- tableWidgetScrollDown :: Size -> TableWidget -> TableWidget
- tableWidgetScrollUp :: Size -> TableWidget -> TableWidget
- tableWidgetActivateCurrent :: MonadExcIO m => m () -> Pos -> Size -> DrawingHint -> TableWidget -> m (TableWidget, Maybe String)
- tableWidgetGoLeft :: Size -> TableWidget -> TableWidget
- tableWidgetGoRight :: Size -> TableWidget -> TableWidget
- tableWidgetGoUp :: Size -> TableWidget -> TableWidget
- tableWidgetGoDown :: Size -> TableWidget -> TableWidget
- tableWidgetMove :: Direction -> (Int, Int) -> TableWidget -> TableWidget
- tableWidgetMakeVisible :: TableWidget -> (Int, Int) -> Int -> TableWidget
- findFirstActiveCell :: [Row] -> TableWidgetOptions -> Maybe Pos
- findNextActiveCell :: TableWidgetOptions -> Int -> Pos -> Direction -> Maybe Pos
- tableWidgetDeleteRow :: Int -> TableWidget -> TableWidget
- joinLists :: [[a]] -> [a] -> [a]
- splitList :: Eq a => [a] -> [a] -> [[a]]
- listReplace :: [a] -> a -> Int -> [a]
- alignRows :: [[[a]]] -> a -> [a] -> [[a]]
- align :: HAlignment -> Int -> a -> [a] -> [a]
- deleteAt :: Int -> [a] -> [a]

# Documentation

type Pos = (Int, Int)Source

type Offset = (Int, Int)Source

type Size = (Int, Int)Source

getHeight :: Size -> Int Source

getWidth :: Size -> Int Source

getYOffset :: Offset -> Int Source

getXOffset :: Offset -> Int Source

getYPos :: Pos -> Int Source

getXPos :: Pos -> Int Source

data Direction Source

Constructors

DirLeft |
DirRight |
DirUp |
DirDown |

Instances

Eq Direction |
Ord Direction |
Show Direction |

data HAlignment Source

Constructors

AlignLeft |
AlignCenter |
AlignRight |

Instances

Eq HAlignment |
Show HAlignment |

data Cont a Source

Constructors

Cont a |
Done a |

class Widget a where Source

Methods

draw :: Pos -> Size -> DrawingHint -> a -> IO ()Source

minSize :: a -> Size Source

Instances

Widget TableWidget |
Widget TableCell |
Widget TextWidget |
Widget EditWidget |
Widget OpaqueWidget |
Widget EmptyWidget |

class Widget a => ActiveWidget a where Source

Methods

activate :: MonadExcIO m => m () -> Pos -> Size -> a -> m (a, String)Source

Instances

ActiveWidget EditWidget |

type KeyHandler a = Pos -> Size -> a -> IO (Cont a)Source

mkKeyHandler :: (Pos -> Size -> a -> a) -> KeyHandler aSource

data DrawingHint Source

Constructors

DHNormal |
DHFocus |
DHActive |

Instances

Eq DrawingHint |
Ord DrawingHint |
Show DrawingHint |

data DrawingStyle Source

Constructors

DStyle |

Fields

dstyle_normal :: CursesStyle
dstyle_focus :: CursesStyle
dstyle_active :: CursesStyle

Instances

Eq DrawingStyle |
Show DrawingStyle |

mkDrawingStyle :: CursesStyle -> DrawingStyle Source

defaultDrawingStyle :: DrawingStyle Source

_draw :: DrawingHint -> DrawingStyle -> IO a -> IO aSource

scrollFactor :: Double Source

scrollBy :: Int -> Int Source

scrollForward :: Int -> Int -> Int -> Int Source

scrollBackward :: t -> Int -> Int -> Int Source

data EmptyWidget Source

Constructors

EmptyWidget Size |

Instances

Widget EmptyWidget |

data OpaqueWidget Source

Constructors

OpaqueWidget Size |

Instances

Widget OpaqueWidget |

data EditWidget Source

Constructors

EditWidget |

Fields

ew_content :: String
ew_xoffset :: Int
ew_xcursor :: Int
ew_history :: [String]
ew_historyIndex :: Int
ew_historySavedContent :: Maybe String
ew_options :: EditWidgetOptions

Instances

ActiveWidget EditWidget |
Widget EditWidget |

ew_contentPos :: EditWidget -> Int Source

data EditWidgetOptions Source

Constructors

EWOptions |

Fields

ewopt_keyHandlers :: [(Key, KeyHandler EditWidget)]
ewopt_minWidth :: Int
ewopt_style :: DrawingStyle

defaultEWOptions :: EditWidgetOptions Source

newEditWidget :: EditWidgetOptions -> String -> EditWidget Source

editWidgetGoLeft :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)Source

editWidgetGoRight :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)Source

editWidgetDeleteLeft :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)Source

editWidgetDeleteUnderCursor :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)Source

editWidgetDeleteToEnd :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)Source

editWidgetGoHome :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)Source

editWidgetGoEnd :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)Source

editWidgetHistoryUp :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)Source

editWidgetHistoryDown :: Pos -> Size -> EditWidget -> IO (Cont EditWidget)Source

editWidgetKeyHandlers :: [(Key, Pos -> Size -> EditWidget -> IO (Cont EditWidget))]Source

editWidgetGetContent :: EditWidget -> String Source

editWidgetSetContent :: EditWidget -> String -> EditWidget Source

editWidgetGetOptions :: EditWidget -> EditWidgetOptions Source

editWidgetSetOptions :: EditWidget -> EditWidgetOptions -> EditWidget Source

drawEditWidget :: Pos -> Size -> DrawingHint -> EditWidget -> IO ()Source

activateEditWidget :: MonadExcIO m => m () -> Pos -> Size -> EditWidget -> m (EditWidget, String)Source

editWidgetGoLeft' :: t -> t1 -> EditWidget -> EditWidget Source

editWidgetGoRight' :: t -> (t1, Int) -> EditWidget -> EditWidget Source

editWidgetDeleteLeft' :: Pos -> Size -> EditWidget -> EditWidget Source

editWidgetDeleteUnderCursor' :: t -> t1 -> EditWidget -> EditWidget Source

editWidgetDeleteToEnd' :: t -> t1 -> EditWidget -> EditWidget Source

editWidgetGoHome' :: t -> t1 -> EditWidget -> EditWidget Source

editWidgetGoEnd' :: Pos -> Size -> EditWidget -> EditWidget Source

editWidgetFinish :: Monad m => t -> t1 -> EditWidget -> m (Cont EditWidget)Source

maxHistoryLength :: Int Source

addToHistory :: EditWidget -> [Char] -> EditWidget Source

editWidgetHistoryUp' :: t -> t1 -> EditWidget -> EditWidget Source

editWidgetHistoryDown' :: t -> t1 -> EditWidget -> EditWidget Source

editWidgetHistory :: Num t => (Int -> t -> Int) -> EditWidget -> EditWidget Source

data TextWidget Source

Constructors

TextWidget |

Fields

tw_text :: String
tw_yoffset :: Int
tw_xoffset :: Int
tw_options :: TextWidgetOptions

Instances

Eq TextWidget |
Show TextWidget |
Widget TextWidget |

data TextWidgetSize Source

Constructors

TWSizeDefault |
TWSizeFixed Size |

Instances

Eq TextWidgetSize |
Show TextWidgetSize |

data TextWidgetOptions Source

Constructors

TWOptions |

Fields

twopt_size :: TextWidgetSize
twopt_style :: DrawingStyle
twopt_halign :: HAlignment

Instances

Eq TextWidgetOptions |
Show TextWidgetOptions |

defaultTWOptions :: TextWidgetOptions Source

newTextWidget :: TextWidgetOptions -> String -> TextWidget Source

drawTextWidget :: Pos -> Size -> DrawingHint -> TextWidget -> IO ()Source

textWidgetGetText :: TextWidget -> String Source

textWidgetSetText :: TextWidget -> String -> TextWidget Source

textWidgetScrollDown :: Size -> TextWidget -> TextWidget Source

textWidgetScrollUp :: Size -> TextWidget -> TextWidget Source

textWidgetScrollLeft :: Size -> TextWidget -> TextWidget Source

textWidgetScrollRight :: Size -> TextWidget -> TextWidget Source

data TableCell Source

Constructors

forall w . Widget w => TableCell w |
forall w . ActiveWidget w => ActiveTableCell w |

Instances

Widget TableCell |

isActive :: TableCell -> Bool Source

_activateTableCell :: MonadExcIO m => m () -> Pos -> Size -> TableCell -> m (TableCell, String)Source

type Row = [TableCell]Source

singletonRow :: TableCell -> Row Source

getCellWidget :: TableWidget -> (Int, Int) -> TableCell Source

setCellWidget :: TableWidget -> (Int, Int) -> TableCell -> TableWidget Source

data TableWidget Source

Constructors

TableWidget |

Fields

tbw_rows :: [Row]
tbw_colOffset :: Int
tbw_pos :: Maybe Pos
tbw_options :: TableWidgetOptions

Instances

Widget TableWidget |

data FillRow Source

Constructors

First |
Last |
None |

Instances

Eq FillRow |
Show FillRow |

data TableWidgetOptions Source

Constructors

TBWOptions |

Fields

tbwopt_fillCol :: Maybe Int
tbwopt_fillRow :: FillRow
tbwopt_activeCols :: [Int]
tbwopt_minSize :: Size

Instances

Eq TableWidgetOptions |
Show TableWidgetOptions |

defaultTBWOptions :: TableWidgetOptions Source

newTableWidget :: TableWidgetOptions -> [Row] -> TableWidget Source

data TableWidgetDisplayInfo Source

Constructors

TBWDisplayInfo |

Fields

tbwdisp_height :: Int
tbwdisp_width :: Int
tbwdisp_firstVis :: Int
tbwdisp_lastVis :: Int
tbwdisp_rows :: [Row]
tbwdisp_nrows :: Int
tbwdisp_heights :: [Int]
tbwdisp_widths :: [Int]
tbwdisp_rightMargin :: Maybe (Int, Size)

tableWidgetDisplayInfo :: Size -> TableWidget -> TableWidgetDisplayInfo Source

getCellInfo :: Pos -> Size -> TableWidget -> (Int, Int) -> (Pos, Size)Source

drawTableWidget :: Pos -> Size -> DrawingHint -> TableWidget -> IO ()Source

tableWidgetScrollDown :: Size -> TableWidget -> TableWidget Source

tableWidgetScrollUp :: Size -> TableWidget -> TableWidget Source

tableWidgetActivateCurrent :: MonadExcIO m => m () -> Pos -> Size -> DrawingHint -> TableWidget -> m (TableWidget, Maybe String)Source

tableWidgetGoLeft :: Size -> TableWidget -> TableWidget Source

tableWidgetGoRight :: Size -> TableWidget -> TableWidget Source

tableWidgetGoUp :: Size -> TableWidget -> TableWidget Source

tableWidgetGoDown :: Size -> TableWidget -> TableWidget Source

tableWidgetMove :: Direction -> (Int, Int) -> TableWidget -> TableWidget Source

tableWidgetMakeVisible :: TableWidget -> (Int, Int) -> Int -> TableWidget Source

findFirstActiveCell :: [Row] -> TableWidgetOptions -> Maybe Pos Source

findNextActiveCell :: TableWidgetOptions -> Int -> Pos -> Direction -> Maybe Pos Source

tableWidgetDeleteRow :: Int -> TableWidget -> TableWidget Source

joinLists :: [[a]] -> [a] -> [a]Source

Join a list by some delimiter

splitList :: Eq a => [a] -> [a] -> [[a]]Source

Split a list by some delimiter

listReplace :: [a] -> a -> Int -> [a]Source

alignRows :: [[[a]]] -> a -> [a] -> [[a]]Source

align :: HAlignment -> Int -> a -> [a] -> [a]Source

deleteAt :: Int -> [a] -> [a]Source