<commit_before>{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-unused-do-bind #-}
module Main where

import System.Exit ( exitSuccess )
import Control.Monad ( when )
import Text.Regex.PCRE.Light
import Graphics.Vty
import Graphics.Vty.Widgets.All
import qualified Data.ByteString.Char8 as BS8

-- Visual attributes.
borderAttr = blue `on` black
editAttr = white `on` black
focusAttr = black `on` yellow
bodyAttr = white `on` black
headerAttr = bright_yellow `on` black
msgAttr = bright_white `on` black

color :: Formatter
color = highlight (compile (BS8.pack "<.*>") []) (bright_green `on` black)

main :: IO ()
main = do
  let msg = "- <TAB> switches input elements\n\n\
            \- ordinary keystrokes edit\n\n\
            \- <SPC> toggles radio buttons and checkboxes\n\n\
            \- <ESC> quits"

      columns = [ column (Fixed 25) `pad` (padAll 1) `align` AlignRight
                , column Auto `pad` (padAll 1)
                ]

  table <- newTable borderAttr columns BorderFull

  tw <- textWidget (wrap &.& color) $ prepareText msgAttr msg
  mainBox <- (return table) <--> (return tw)

  setBoxSpacing mainBox 1

  ui <- centered =<< hLimit 70 mainBox

  r1 <- newCheckbox "Cake"
  r2 <- newCheckbox "Death"
  r3 <- newCheckbox "Checkbox"
  radioHeader <- simpleText headerAttr ""
  r3Header <- simpleText headerAttr ""

  rg <- newRadioGroup
  addToRadioGroup rg r1
  addToRadioGroup rg r2

  edit1 <- editWidget
  edit2 <- editWidget

  edit1Header <- simpleText headerAttr ""
  edit2Header <- simpleText headerAttr ""

  lst <- listWidget $ mkList focusAttr (simpleText bodyAttr)

  selector <- vLimit 3 lst
  listHeader <- simpleText bodyAttr ""

  rs <- (return r1) <--> (return r2)

  addHeadingRow_ table headerAttr ["Column 1", "Column 2"]
  addRow table $ (radioHeader .|.) rs
  addRow table $ r3Header .|. r3
  addRow table $ edit1Header .|. edit1
  addRow table $ edit2Header .|. edit2<commit_msg>Demo attribute updates<commit_after>{-# OPTIONS_GHC -fno-warn-missing-signatures -fno-warn-unused-do-bind #-}
module Main where

import System.Exit ( exitSuccess )
import Control.Monad ( when )
import Text.Regex.PCRE.Light
import Graphics.Vty
import Graphics.Vty.Widgets.All
import qualified Data.ByteString.Char8 as BS8

-- Visual attributes.
bg = blue
borderAttr = white `on` bg
focusAttr = black `on` yellow
bodyAttr = white `on` bg
headerAttr = bright_yellow `on` bg
msgAttr = bright_white `on` bg

color :: Formatter
color = highlight (compile (BS8.pack "<.*>") []) (bright_green `on` bg)

main :: IO ()
main = do
  let msg = "- <TAB> switches input elements\n\n\
            \- ordinary keystrokes edit\n\n\
            \- <SPC> toggles radio buttons and checkboxes\n\n\
            \- <ESC> quits"

      columns = [ column (Fixed 25) `pad` (padAll 1) `align` AlignRight
                , column Auto `pad` (padAll 1)
                ]

  table <- newTable borderAttr columns BorderFull

  tw <- textWidget (wrap &.& color) $ prepareText msgAttr msg
  mainBox <- (return table) <--> (return tw)

  setBoxSpacing mainBox 1

  ui <- centered =<< hLimit 70 mainBox

  r1 <- newCheckbox "Cake"
  r2 <- newCheckbox "Death"
  r3 <- newCheckbox "Checkbox"
  radioHeader <- simpleText headerAttr ""
  r3Header <- simpleText headerAttr ""

  rg <- newRadioGroup
  addToRadioGroup rg r1
  addToRadioGroup rg r2

  edit1 <- editWidget
  setFocusAttribute edit1 (white `on` red)

  edit2 <- editWidget

  edit1Header <- simpleText headerAttr ""
  edit2Header <- simpleText headerAttr ""

  lst <- listWidget $ mkList focusAttr (simpleText bodyAttr)

  selector <- vLimit 3 lst
  listHeader <- simpleText bodyAttr ""

  rs <- (return r1) <--> (return r2)

  addHeadingRow_ table headerAttr ["Column 1", "Column 2"]
  addRow table $ (radioHeader .|.) rs
  addRow table $ r3Header .|. r3
  addRow table $ edit1Header .|. edit1
  addRow table $ edit2Header .|. edit2
{'fraction_non_alphanumeric': 0.11610583097867969, 'fraction_numerical': 0.01618289237092217, 'mean_word_length': 3.052029136316337, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1590964', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1243, 'n_words': 390}