<commit_before>-- Test file for the ListView widget.
module Main(Main.main) where

import Mogul

main = do
  Mogul.init Nothing
  win <- newWindow
  win `onDestroy` Mogul.mainQuit

  -- create a new TextView Widget
  (store, r, w, attrs) <- createStore
  tv <- newTreeViewWithModel store
  tv `treeViewSetHeadersVisible` True
  win `containerAdd` tv

  -- add a single column
  tvc <- newTreeViewColumn
  treeViewAppendColumn tv tvc

  -- create a single text renderer within this column
  tRen <- treeViewColumnNewText tvc True True
  tvc `treeViewColumnSetTitle` "My Title"
  treeViewColumnAssociate tRen attrs

  -- fill the list with some entries
  mapM_ (\txt -> do
    iter <- listStoreAppend store
    w iter txt "red" "white") 
    ["Hello", "how", "are", "you"]

  -- show the widget and run the main loop
  widgetShow tv
  widgetShow win
  Mogul.main


createStore = do
  -- Start by creating a description of how the database (the store) looks
  -- like. We call this descripton the skeleton of the store.
  skel <- emptyListSkel
  (tAttr, tRead, tWrite) <- listSkelAddAttribute skel
    (cellText:: Attribute TextRenderer String)
  (fAttr, fRead, fWrite) <- listSkelAddAttribute skel
    (cellForeground:: Attribute TextRenderer String)
  (bAttr, bRead, bWrite) <- listSkelAddAttribute skel
    (cellBackground:: Attribute TextRenderer String)
  
  -- Now create the real store from this skeleton. The skeleton is of no use
  -- after this function call.
  store <- newListStore skel

  -- Return this store and read and write functions that read and write a
  -- whole line in the store.

  let writeStore :: TreeIter -> String -> String -> String -> IO ()
      writeStore iter txt fore back = do
        tWrite iter txt
	fWrite iter fore
	bWrite iter back
  let readStore :: TreeIter -> IO (String, String, String)<commit_msg>[project @ 2002-07-08 16:49:58 by as49] Changed some types so that user code runs without type annotations.<commit_after>-- Test file for the ListView widget.
module Main(Main.main) where

import Mogul

main = do
  Mogul.init Nothing
  win <- newWindow
  win `onDestroy` Mogul.mainQuit

  -- create a new TextView Widget
  (store, r, w, attrs) <- createStore
  tv <- newTreeViewWithModel store
  tv `treeViewSetHeadersVisible` True
  win `containerAdd` tv

  -- add a single column
  tvc <- newTreeViewColumn
  treeViewAppendColumn tv tvc

  -- create a single text renderer within this column
  tRen <- treeViewColumnNewText tvc True True
  tvc `treeViewColumnSetTitle` "My Title"
  treeViewColumnAssociate tRen attrs

  -- fill the list with some entries
  mapM_ (\txt -> do
    iter <- listStoreAppend store
    w iter txt "red" "") 
    ["Hello", "how", "are", "you"]

  -- show the widget and run the main loop
  widgetShow tv
  widgetShow win
  Mogul.main


createStore = do
  -- Start by creating a description of how the database (the store) looks
  -- like. We call this descripton the skeleton of the store.
  skel <- emptyListSkel
  (tAttr, tRead, tWrite) <- listSkelAddAttribute skel cellText
  (fAttr, fRead, fWrite) <- listSkelAddAttribute skel cellForeground
  (bAttr, bRead, bWrite) <- listSkelAddAttribute skel cellBackground
  
  -- Now create the real store from this skeleton. The skeleton is of no use
  -- after this function call.
  store <- newListStore skel

  -- Return this store and read and write functions that read and write a
  -- whole line in the store.

  let writeStore :: TreeIter -> String -> String -> String -> IO ()
      writeStore iter txt fore back = do
        tWrite iter txt
	--fWrite iter fore
	--bWrite iter back
  let readStore :: TreeIter -> IO (String, String, String)
{'fraction_non_alphanumeric': 0.08030592734225621, 'fraction_numerical': 0.004370390603660202, 'mean_word_length': 3.223760092272203, 'pattern_counts': {'":': 0, '<': 25, '<?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': '5416522', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1081, 'n_words': 452}