text:
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveTraversable   #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ViewPatterns        #-}

module Unison.Util.Pretty (
   Pretty,
   ColorText,
   align,
   align',
   alternations,
   background,
   backticked,
   backticked',
   boxForkLeft,
   boxLeft,
   boxLeftM,
   boxRight,
   boxRightM,
   bulleted,
   bracket,
   -- breakable
   callout,
   excerptSep,
   excerptSep',
   excerptColumn2,
   excerptColumn2Headed,
   warnCallout, blockedCallout, fatalCallout, okCallout,
   column2,
   column2sep,
   column2Header,
   column2M,
   column2UnzippedM,
   column3,
   column3M,
   column3UnzippedM,
   column3sep,
   commas,
   commented,
   oxfordCommas,
   oxfordCommasWith,
   plural,
   dashed,
   flatMap,
   group,
   hang',
   hang,
   hangUngrouped',
   hangUngrouped,
   indent,
   indentAfterNewline,
   indentN,
   indentNonEmptyN,
   indentNAfterNewline,
   invert,
   isMultiLine,
   leftPad,
   lines,
   linesNonEmpty,
   linesSpaced,
   lit,
   map,
   mayColumn2,
   nest,
   num,
   newline,
   lineSkip,
   nonEmpty,
   numbered,
   numberedColumn2,
   numberedColumn2Header,
   numberedList,
   orElse,
   orElses,
   paragraphyText,
   parenthesize,
   parenthesizeCommas,
   parenthesizeIf,
   render,
   renderUnbroken,
   rightPad,
   sep,
   sepNonEmpty,
   sepSpaced,
   shown,
   softbreak,
   spaceIfBreak,
   spaced,
   spacedMap,
   spacesIfBreak,
   string,
   surroundCommas,
   syntaxToColor,
   table,
   text,
   toANSI,
   toAnsiUnbroken,
   toHTML,
   toPlain,
   toPlainUnbroken,
   underline,
   withSyntax,
   wrap,
   wrap',
   wrapColumn2,
   wrapString,
   black, red, green, yellow, blue, purple, cyan, white, hiBlack, hiRed, hiGreen, hiYellow, hiBlue, hiPurple, hiCyan, hiWhite, bold,
   border,
   Width(..),
   -- * Exported for testing
   delta,
   Delta,
  ) where

import Unison.Prelude

import           Data.Bifunctor                 ( second )
import           Data.Char                      ( isSpace )
import           Data.List                      ( intersperse )
import           Prelude                 hiding ( lines , map )
import           Unison.Util.AnnotatedText      ( annotateMaybe )
import qualified Unison.Util.AnnotatedText     as AT
import qualified Unison.Util.ColorText         as CT
import qualified Unison.Util.SyntaxText        as ST
import           Unison.Util.Monoid             ( intercalateMap )
import qualified Data.ListLike                 as LL
import qualified Data.Sequence                 as Seq
import qualified Data.Text                     as Text
import Control.Monad.Identity (runIdentity, Identity(..))

newtype Width = Width {widthToInt :: Int}
  deriving (Eq, Ord, Show, Generic, Num, Bounded)

type ColorText = CT.ColorText

data Pretty s = Pretty { delta :: Delta, out :: F s (Pretty s) } deriving Eq

instance Functor Pretty where
  fmap f (Pretty d o) = Pretty d (mapLit f $ fmap (fmap f) o)

data F s r
  = Empty
    -- | A group adds a level of breaking. Layout tries not to break a group
    -- unless needed to fit in available width. Breaking is done "outside in".
    --
    --   (a | b) <> (c | d) will try (a <> c), then (b <> d)
    --
    --   (a | b) <> group (c | d) will try (a <> c), then (b <> c), then (b <> d)
  | Group r
  | Lit s
  | Wrap (Seq r)
  | OrElse r r
  | Append (Seq r)
  deriving (Eq, Show, Foldable, Traversable, Functor)

mapLit :: (s -> t) -> F s r -> F t r
mapLit f (Lit s) = Lit (f s)
mapLit _ Empty = Empty
mapLit _ (Group r) = Group r
mapLit _ (Wrap s) = Wrap s
mapLit _ (OrElse r s) = OrElse r s
mapLit _ (Append s) = Append s

lit :: (IsString s, LL.ListLike s Char) => s -> Pretty s
lit s = lit' (foldMap chDelta $ LL.toList s) s

lit' :: Delta -> s -> Pretty s
lit' d s = Pretty d (Lit s)

orElse :: Pretty s -> Pretty s -> Pretty s
orElse p1 p2 = Pretty (delta p1) (OrElse p1 p2)

orElses :: [Pretty s] -> Pretty s
orElses [] = mempty
orElses ps = foldr1 orElse ps

wrapImpl :: IsString s => [Pretty s] -> Pretty s
wrapImpl [] = mempty
wrapImpl (p:ps) = wrap_ . Seq.fromList $
  p : fmap (\p -> (" " <> p) `orElse` (newline <> p)) ps

wrapImplPreserveSpaces :: (LL.ListLike s Char, IsString s) => [Pretty s] -> Pretty s
wrapImplPreserveSpaces = \case
  [] -> mempty
  (p:ps) -> wrap_ . Seq.fromList $ p : fmap f ps
  where
  startsWithSpace p = case out p of
    (Lit s) -> fromMaybe False (fmap (isSpaceNotNewline . fst) $ LL.uncons s)
    _ -> False
  f p | startsWithSpace p = p `orElse` newline
  f p = p

isSpaceNotNewline :: Char -> Bool
isSpaceNotNewline c = isSpace c && not (c == '\n')

wrapString :: (LL.ListLike s Char, IsString s) => String -> Pretty s
wrapString s = wrap (lit $ fromString s)

-- Wrap text, preserving whitespace (apart from at the wrap points.)
-- Used in particular for viewing/displaying doc literals.
-- Should be understood in tandem with TermParser.docNormalize.
-- See also unison-src/transcripts/doc-formatting.md.
paragraphyText :: (LL.ListLike s Char, IsString s) => Text -> Pretty s
paragraphyText = sep "\n" . fmap (wrapPreserveSpaces . text) . Text.splitOn "\n"

wrap' :: IsString s => (s -> [Pretty s]) -> Pretty s -> Pretty s
wrap' wordify p = wrapImpl (toLeaves [p]) where
  toLeaves [] = []
  toLeaves (hd:tl) = case out hd of
    Empty -> toLeaves tl
    Lit s -> wordify s ++ toLeaves tl
    Group _ -> hd : toLeaves tl
    OrElse a _ -> toLeaves (a:tl)
    Wrap _ -> hd : toLeaves tl
    Append hds -> toLeaves (toList hds ++ tl)

wrap :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s
wrap = wrap' wordify
  where
  wordify s0 = let s = LL.dropWhile isSpace s0 in
    if LL.null s then []
    else case LL.break isSpace s of (word1, s) -> lit word1 : wordify s

-- Does not insert spaces where none were present, and does not collapse
-- sequences of spaces into one.
-- It'd be a bit painful to just replace wrap with the following version, because
-- lots of OutputMessages code depends on wrap's behaviour of sometimes adding
-- extra spaces.
wrapPreserveSpaces :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s
wrapPreserveSpaces p = wrapImplPreserveSpaces (toLeaves [p]) where
  toLeaves [] = []
  toLeaves (hd:tl) = case out hd of
    Empty -> toLeaves tl
    Lit s -> (fmap lit $ alternations isSpaceNotNewline s) ++ toLeaves tl
    Group _ -> hd : toLeaves tl
    OrElse a _ -> toLeaves (a:tl)
    Wrap _ -> hd : toLeaves tl
    Append hds -> toLeaves (toList hds ++ tl)

-- Cut a list every time a predicate changes.  Produces a list of
-- non-empty lists.
alternations :: (LL.ListLike s c) => (c -> Bool) -> s -> [s]
alternations p s = reverse $ go True s [] where
  go _ s acc | LL.null s = acc
  go w s acc = go (not w) rest acc' where
    (t, rest) = LL.span p' s
    p' = if w then p else (\x -> not (p x))
    acc' = if (LL.null t) then acc else t : acc

wrap_ :: Seq (Pretty s) -> Pretty s
wrap_ ps = Pretty (foldMap delta ps) (Wrap ps)

group :: Pretty s -> Pretty s
group p = Pretty (delta p) (Group p)

toANSI :: Width -> Pretty CT.ColorText -> String
toANSI avail p = CT.toANSI (render avail p)

toAnsiUnbroken :: Pretty ColorText -> String
toAnsiUnbroken p = CT.toANSI (renderUnbroken p)

toPlain :: Width -> Pretty CT.ColorText -> String
toPlain avail p = CT.toPlain (render avail p)

toHTML :: String -> Width -> Pretty CT.ColorText -> String
toHTML cssPrefix avail p = CT.toHTML cssPrefix (render avail p)

toPlainUnbroken :: Pretty ColorText -> String
toPlainUnbroken p = CT.toPlain (renderUnbroken p)

syntaxToColor :: Pretty ST.SyntaxText -> Pretty ColorText
syntaxToColor = fmap $ annotateMaybe . fmap CT.defaultColors

-- set the syntax, overriding any present syntax
withSyntax
  :: ST.Element r -> Pretty (ST.SyntaxText' r) -> Pretty (ST.SyntaxText' r)
withSyntax e = fmap $ ST.syntax e

renderUnbroken :: (Monoid s, IsString s) => Pretty s -> s
renderUnbroken = render maxBound

render :: (Monoid s, IsString s) => Width -> Pretty s -> s
render availableWidth p = go mempty [Right p] where
  go _   []       = mempty
  go cur (p:rest) = case p of
    Right p -> -- `p` might fit, let's try it!
      if p `fits` cur then flow p <> go (cur <> delta p) rest
      else go cur (Left p : rest) -- nope, switch to breaking mode
    Left p -> case out p of -- `p` requires breaking
      Append ps  -> go cur ((Left <$> toList ps) <> rest)
      Empty      -> go cur rest
      Group p    -> go cur (Right p : rest)
      -- Note: literals can't be broken further so they're
      -- added to output unconditionally
      Lit l      -> l <> go (cur <> delta p) rest
      OrElse _ p -> go cur (Right p : rest)
      Wrap ps    -> go cur ((Right <$> toList ps) <> rest)

  flow p = case out p of
    Append ps -> foldMap flow ps
    Empty -> mempty
    Group p -> flow p
    Lit s -> s
    OrElse p _ -> flow p
    Wrap ps -> foldMap flow ps

  fits p cur =
    maxCol (surgery cur <> delta p) < availableWidth
    where
      -- Surgically modify 'cur' to pretend it has not exceeded availableWidth.
      -- This is necessary because sometimes things cannot be split and *must*
      -- exceed availableWidth; in this case, we do not want to entirely "blame"
      -- the new proposed (cur <> delta p) for this overflow.
      --
      -- For example, when appending
      --
      --       availableWidth
      --       |
      --   xxx |
      --   yyyyyy
      --   zz  |
      --
      -- with
      --
      --   aa  |
      --   bb  |
      --
      -- we want to end up with
      --
      --   xxx |
      --   yyyyyy
      --   zzaa|
      --   bb  |
      --
      surgery = \case
        SingleLine c -> SingleLine (min c (availableWidth-1))
        MultiLine fc lc mc -> MultiLine fc lc (min mc (availableWidth-1))

newline :: IsString s => Pretty s
newline = "\n"

lineSkip :: IsString s => Pretty s
lineSkip = newline <> newline

spaceIfBreak :: IsString s => Pretty s
spaceIfBreak = "" `orElse` " "

spacesIfBreak :: IsString s => Int -> Pretty s
spacesIfBreak n = "" `orElse` fromString (replicate n ' ')

softbreak :: IsString s => Pretty s
softbreak = " " `orElse` newline

spaced :: (Foldable f, IsString s) => f (Pretty s) -> Pretty s
spaced = intercalateMap softbreak id

spacedMap :: (Foldable f, IsString s) => (a -> Pretty s) -> f a -> Pretty s
spacedMap f as = spaced . fmap f $ toList as

commas :: (Foldable f, IsString s) => f (Pretty s) -> Pretty s
commas = intercalateMap ("," <> softbreak) id

oxfordCommas :: (Foldable f, IsString s) => f (Pretty s) -> Pretty s
oxfordCommas = oxfordCommasWith ""

-- Like `oxfordCommas`, but attaches `end` at the end (without a space).
-- For example, `oxfordCommasWith "."` will attach a period.
oxfordCommasWith
  :: (Foldable f, IsString s) => Pretty s -> f (Pretty s) -> Pretty s
oxfordCommasWith end xs = case toList xs of
  []     -> ""
  [x]    -> group (x <> end)
  [x, y] -> x <> " and " <> group (y <> end)
  xs ->
    intercalateMap ("," <> softbreak) id (init xs)
      <> ","
      <> softbreak
      <> "and"
      <> softbreak
      <> group (last xs <> end)

parenthesizeCommas :: (Foldable f, IsString s) => f (Pretty s) -> Pretty s
parenthesizeCommas = surroundCommas "(" ")"

surroundCommas
  :: (Foldable f, IsString s)
  => Pretty s
  -> Pretty s
  -> f (Pretty s)
  -> Pretty s
surroundCommas start stop fs =
  group
    $  start
    <> spaceIfBreak
    <> intercalateMap ("," <> softbreak <> align) id fs
    <> stop
  where align = spacesIfBreak (widthToInt $ preferredWidth start + 1)

sepSpaced :: (Foldable f, IsString s) => Pretty s -> f (Pretty s) -> Pretty s
sepSpaced between = sep (between <> softbreak)

sep :: (Foldable f, IsString s) => Pretty s -> f (Pretty s) -> Pretty s
sep between = intercalateMap between id

sepNonEmpty :: (Foldable f, IsString s) => Pretty s -> f (Pretty s) -> Pretty s
sepNonEmpty between ps = sep between (nonEmpty ps)

-- if list is too long, adds `... 22 more` to the end
excerptSep :: IsString s => Maybe Int -> Pretty s -> [Pretty s] -> Pretty s
excerptSep maxCount =
  excerptSep' maxCount (\i -> group ("... " <> shown i <> " more"))

excerptSep'
  :: IsString s
  => Maybe Int
  -> (Int -> Pretty s)
  -> Pretty s
  -> [Pretty s]
  -> Pretty s
excerptSep' maxCount summarize s ps = case maxCount of
  Just max | length ps > max ->
    sep s (take max ps) <> summarize (length ps - max)
  _ -> sep s ps

nonEmpty :: (Foldable f, IsString s) => f (Pretty s) -> [Pretty s]
nonEmpty (toList -> l) = case l of
  (out -> Empty) : t -> nonEmpty t
  h : t -> h : nonEmpty t
  [] -> []

parenthesize :: IsString s => Pretty s -> Pretty s
parenthesize p = group $ "(" <> p <> ")"

parenthesizeIf :: IsString s => Bool -> Pretty s -> Pretty s
parenthesizeIf False s = s
parenthesizeIf True s = parenthesize s

lines :: (Foldable f, IsString s) => f (Pretty s) -> Pretty s
lines = intercalateMap (append newline) id where
  append p = Pretty (delta p) (Append $ Seq.singleton p)

linesNonEmpty :: (Foldable f, IsString s) => f (Pretty s) -> Pretty s
linesNonEmpty = lines . nonEmpty

linesSpaced :: (Foldable f, IsString s) => f (Pretty s) -> Pretty s
linesSpaced ps = lines (intersperse "" $ toList ps)

prefixed :: (Foldable f, LL.ListLike s Char, IsString s)
         => Pretty s -> Pretty s -> f (Pretty s) -> Pretty s
prefixed first rest =
  intercalateMap newline (\b -> first <> indentAfterNewline rest b)

bulleted
  :: (Foldable f, LL.ListLike s Char, IsString s) => f (Pretty s) -> Pretty s
bulleted = prefixed "* " "  "

dashed
  :: (Foldable f, LL.ListLike s Char, IsString s) => f (Pretty s) -> Pretty s
dashed = prefixed "- " "  "

commented
  :: (Foldable f, LL.ListLike s Char, IsString s) => f (Pretty s) -> Pretty s
commented = prefixed "-- " "-- "

numbered
  :: (Foldable f, LL.ListLike s Char, IsString s)
  => (Int -> Pretty s)
  -> f (Pretty s)
  -> Pretty s
numbered num ps = column2 (fmap num [1 ..] `zip` toList ps)

numberedHeader
  :: (Foldable f, LL.ListLike s Char, IsString s)
  => (Maybe Int -> Pretty s)
  -> f (Pretty s)
  -> Pretty s
numberedHeader num ps = column2 (fmap num (Nothing : fmap Just [1 ..]) `zip` toList ps)

-- Like `column2` but with the lines numbered. For instance:
--
-- 1. one thing     : this is a thing
-- 2. another thing : this is another thing
-- 3. and another   : yet one more thing
numberedColumn2
  :: (Foldable f, LL.ListLike s Char, IsString s)
  => (Int -> Pretty s)
  -> f (Pretty s, Pretty s)
  -> Pretty s
numberedColumn2 num ps = numbered num (align $ toList ps)

numberedColumn2Header
  :: (Foldable f, LL.ListLike s Char, IsString s)
  => (Int -> Pretty s)
  -> f (Pretty s, Pretty s)
  -> Pretty s
numberedColumn2Header num ps = numberedHeader (maybe mempty num) (align $ toList ps)

-- Opinionated `numbered` that uses bold numbers in front
numberedList :: Foldable f => f (Pretty ColorText) -> Pretty ColorText
numberedList = numbered (\i -> hiBlack . fromString $ show i <> ".")

leftPad, rightPad :: IsString s => Width -> Pretty s -> Pretty s
leftPad n p =
  let rem = n - preferredWidth p
  in  if rem > 0 then fromString (replicate (widthToInt rem) ' ') <> p else p
rightPad n p =
  let rem = n - preferredWidth p
  in  if rem > 0 then p <> fromString (replicate (widthToInt rem) ' ') else p

excerptColumn2Headed
  :: (LL.ListLike s Char, IsString s)
  => Maybe Int
  -> (Pretty s, Pretty s)
  -> [(Pretty s, Pretty s)]
  -> Pretty s
excerptColumn2Headed max hd cols = case max of
  Just max | len > max ->
    lines [column2 (hd : take max cols), "... " <> shown (len - max) <> " more"]
  _ -> column2 (hd : cols)
  where len = length cols

excerptColumn2
  :: (LL.ListLike s Char, IsString s)
  => Maybe Int
  -> [(Pretty s, Pretty s)]
  -> Pretty s
excerptColumn2 max cols = case max of
  Just max | len > max -> lines [column2 cols, "... " <> shown (len - max)]
  _                    -> column2 cols
  where len = length cols

table :: (IsString s, LL.ListLike s Char) => [[Pretty s]] -> Pretty s
table rows = lines (table' rows)

table' :: (IsString s, LL.ListLike s Char) => [[Pretty s]] -> [Pretty s]
table' [] = mempty
table' rows = case maximum (Prelude.length <$> rows) of
  1 -> rows >>= \case
    [] -> [mempty]
    hd : _ -> [hd]
  _ -> let
    colHd = [ h | (h:_) <- rows ]
    colTl = [ t | (_:t) <- rows ]
    in align (fmap (<> "  ") colHd `zip` (table' colTl))

column2
  :: (LL.ListLike s Char, IsString s) => [(Pretty s, Pretty s)] -> Pretty s
column2 = column2sep ""

column2Header
  :: Pretty ColorText -> Pretty ColorText -> [(Pretty ColorText, Pretty ColorText)] -> Pretty ColorText
column2Header left right = column2sep "  " . ((fmap CT.hiBlack left, fmap CT.hiBlack right):)

column2sep
  :: (LL.ListLike s Char, IsString s) => Pretty s -> [(Pretty s, Pretty s)] -> Pretty s
column2sep sep rows = lines . (group <$>) . align $ [(a, sep <> b) | (a, b) <- rows]

column2M
  :: (Applicative m, LL.ListLike s Char, IsString s)
  => [m (Pretty s, Pretty s)]
  -> m (Pretty s)
column2M = fmap column2 . sequenceA

mayColumn2
  :: (LL.ListLike s Char, IsString s)
  => [(Pretty s, Maybe (Pretty s))]
  -> Pretty s
mayColumn2 = lines . (group <$>) . ((uncurry (<>)) <$>) . align'

column3
  :: (LL.ListLike s Char, IsString s)
  => [(Pretty s, Pretty s, Pretty s)]
  -> Pretty s
column3 = column3sep ""

column3M
  :: (LL.ListLike s Char, IsString s, Monad m)
  => [m (Pretty s, Pretty s, Pretty s)]
  -> m (Pretty s)
column3M = fmap column3 . sequence

column3UnzippedM
  :: forall m s . (LL.ListLike s Char, IsString s, Monad m)
  => Pretty s
  -> [m (Pretty s)]
  -> [m (Pretty s)]
  -> [m (Pretty s)]
  -> m (Pretty s)
column3UnzippedM bottomPadding left mid right = let
  rowCount = maximum (fmap length [left, mid, right])
  pad :: [m (Pretty s)] -> [m (Pretty s)]
  pad a = a ++ replicate (rowCount - length a) (pure bottomPadding)
  (pleft, pmid, pright) = (pad left, pad mid, pad right)
  in column3M $ zipWith3 (liftA3 (,,)) pleft pmid pright

column2UnzippedM
  :: forall m s . (LL.ListLike s Char, IsString s, Monad m)
  => Pretty s
  -> [m (Pretty s)]
  -> [m (Pretty s)]
  -> m (Pretty s)
column2UnzippedM bottomPadding left right = let
  rowCount = length left `max` length right
  pad :: [m (Pretty s)] -> [m (Pretty s)]
  pad a = a ++ replicate (rowCount - length a) (pure bottomPadding)
  sep :: [m (Pretty s)] -> [m (Pretty s)]
  sep = fmap (fmap (" " <>))
  (pleft, pright) = (pad left, sep $ pad right)
  in column2M $ zipWith (liftA2 (,)) pleft pright

column3sep
  :: (LL.ListLike s Char, IsString s) => Pretty s -> [(Pretty s, Pretty s, Pretty s)] -> Pretty s
column3sep sep rows = let
  bc = align [(b,sep <> c) | (_,b,c) <- rows ]
  abc = group <$> align [(a,sep <> bc) | ((a,_,_),bc) <- rows `zip` bc ]
  in lines abc

wrapColumn2
  :: (LL.ListLike s Char, IsString s) => [(Pretty s, Pretty s)] -> Pretty s
wrapColumn2 rows = lines (align rows) where
  align rows =
    let lwidth = foldl' max 0 (preferredWidth . fst <$> rows) + 2
    in  [ group (rightPad lwidth l <> indentNAfterNewline lwidth (wrap r))
        | (l, r) <- rows
        ]

align
  :: (LL.ListLike s Char, IsString s) => [(Pretty s, Pretty s)] -> [Pretty s]
align rows = (((uncurry (<>)) <$>) . align') (second Just <$> rows)

-- [("foo", Just "bar")
-- ,("barabaz", Nothing)
-- ,("qux","quux")]
--
-- results in:
--
-- [("foo ", "bar"),
-- [("barabaz", ""),
-- [("qux ", "quuxbill")]
--
-- The first component has padding added, sufficient to align the second
-- component.  The second component has whitespace added after its
-- newlines, again sufficient to line it up in a second column.
align'
  :: (LL.ListLike s Char, IsString s)
  => [(Pretty s, Maybe (Pretty s))]
  -> [(Pretty s, Pretty s)]
align' rows = alignedRows
 where
  col0Width = foldl' max 0 [ preferredWidth col1 | (col1, Just _) <- rows ] + 1
  alignedRows =
    [ case col1 of
        Just s  -> (rightPad col0Width col0, indentNAfterNewline col0Width s)
        Nothing -> (col0, mempty)
    | (col0, col1) <- rows
    ]

text :: IsString s => Text -> Pretty s
text t = fromString (Text.unpack t)

num :: (Show n, Num n, IsString s) => n -> Pretty s
num n = fromString (show n)

string :: IsString s => String -> Pretty s
string = fromString

shown :: (Show a, IsString s) => a -> Pretty s
shown = fromString . show

hang'
  :: (LL.ListLike s Char, IsString s)
  => Pretty s
  -> Pretty s
  -> Pretty s
  -> Pretty s
hang' from by p = group $ if isMultiLine p
  then from <> "\n" <> group (indent by p)
  else (from <> " " <> group p) `orElse` (from <> "\n" <> group (indent by p))

hangUngrouped'
  :: (LL.ListLike s Char, IsString s)
  => Pretty s
  -> Pretty s
  -> Pretty s
  -> Pretty s
hangUngrouped' from by p = if isMultiLine p
  then from <> "\n" <> indent by p
  else (from <> " " <> p) `orElse` (from <> "\n" <> indent by p)

hangUngrouped
  :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s -> Pretty s
hangUngrouped from = hangUngrouped' from "  "

hang :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s -> Pretty s
hang from = hang' from "  "

nest :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s -> Pretty s
nest = hang' ""

indent :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s -> Pretty s
indent by p = by <> indentAfterNewline by p

indentN :: (LL.ListLike s Char, IsString s) => Width -> Pretty s -> Pretty s
indentN by = indent (fromString $ replicate (widthToInt by) ' ')

indentNonEmptyN
  :: (LL.ListLike s Char, IsString s) => Width -> Pretty s -> Pretty s
indentNonEmptyN _  (out -> Empty) = mempty
indentNonEmptyN by p              = indentN by p

indentNAfterNewline
  :: (LL.ListLike s Char, IsString s) => Width -> Pretty s -> Pretty s
indentNAfterNewline by =
  indentAfterNewline (fromString $ replicate (widthToInt by) ' ')

indentAfterNewline
  :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s -> Pretty s
indentAfterNewline by = flatMap f
 where
  f s0 = case LL.break (== '\n') s0 of
    (hd, s) -> if LL.null s
      then lit s0
      -- use `take` and `drop` to preserve annotations or
      -- or other extra info attached to the original `s`
      else lit (LL.take (LL.length hd) s0) <> "\n" <> by <> f (LL.drop 1 s)

instance IsString s => IsString (Pretty s) where
  fromString s = lit' (foldMap chDelta s) (fromString s)

instance Semigroup (Pretty s) where (<>) = mappend
instance Monoid (Pretty s) where
  mempty = Pretty mempty Empty
  mappend p1 p2 = Pretty (delta p1 <> delta p2) .
    Append $ case (out p1, out p2) of
      (Append ps1, Append ps2) -> ps1 <> ps2
      (Append ps1, _) -> ps1 <> pure p2
      (_, Append ps2) -> pure p1 <> ps2
      (_,_) -> pure p1 <> pure p2

data Delta =
    -- | The number of columns.
    SingleLine !Width
    -- | The number of columns in the first, last, and longest lines.
  | MultiLine !Width !Width !Width
  deriving stock (Eq, Ord, Show)

instance Semigroup Delta where
  SingleLine c <> SingleLine c2 = SingleLine (c + c2)
  SingleLine c <> MultiLine fc lc mc =
    let fc' = c + fc
    in MultiLine fc' lc (max fc' mc)
  MultiLine fc lc mc <> SingleLine c =
    let lc' = lc + c
    in MultiLine fc lc' (max lc' mc)
  MultiLine fc lc mc <> MultiLine fc2 lc2 mc2 =
    MultiLine fc lc2 (max mc (max mc2 (lc + fc2)))

instance Monoid Delta where
  mempty = SingleLine 0
  mappend = (<>)

maxCol :: Delta -> Width
maxCol = \case
  SingleLine c -> c
  MultiLine _ _ c -> c

lastCol :: Delta -> Width
lastCol = \case
  SingleLine c -> c
  MultiLine _ c _ -> c

chDelta :: Char -> Delta
chDelta '\n' = MultiLine 0 0 0
chDelta _ = SingleLine 1

preferredWidth :: Pretty s -> Width
preferredWidth p = lastCol (delta p)

isMultiLine :: Pretty s -> Bool
isMultiLine p =
  case delta p of
    SingleLine{} -> False
    MultiLine{} -> True

black, red, green, yellow, blue, purple, cyan, white, hiBlack, hiRed, hiGreen, hiYellow, hiBlue, hiPurple, hiCyan, hiWhite, bold, underline
  :: Pretty CT.ColorText -> Pretty CT.ColorText
black = map CT.black
red = map CT.red
green = map CT.green
yellow = map CT.yellow
blue = map CT.blue
purple = map CT.purple
cyan = map CT.cyan
white = map CT.white
hiBlack = map CT.hiBlack
hiRed = map CT.hiRed
hiGreen = map CT.hiGreen
hiYellow = map CT.hiYellow
hiBlue = map CT.hiBlue
hiPurple = map CT.hiPurple
hiCyan = map CT.hiCyan
hiWhite = map CT.hiWhite
bold = map CT.bold
underline = map CT.underline

-- invert the foreground and background colors
invert :: Pretty CT.ColorText -> Pretty CT.ColorText
invert = map CT.invert

-- set the background color, ex: `background hiBlue`, `background yellow`
background :: (Pretty CT.ColorText -> Pretty CT.ColorText) -> Pretty CT.ColorText -> Pretty CT.ColorText
background f p =
  -- hack: discover the color of `f` by calling it on a dummy string
  case f (Pretty mempty (Lit "-")) of
    Pretty _ (Lit (AT.AnnotatedText (toList -> [AT.Segment _ (Just c)]))) -> map (CT.background c) p
    _ -> p

plural :: Foldable f
       => f a -> Pretty ColorText -> Pretty ColorText
plural f p = case length f of
  0 -> mempty
  1 -> p
  -- todo: consider use of plural package
  _ -> p <> case reverse (toPlainUnbroken p) of
    's' : _ -> "es"
    _ -> "s"

border :: (LL.ListLike s Char, IsString s) => Width -> Pretty s -> Pretty s
border n p = "\n" <> indentN n p <> "\n"

callout :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s -> Pretty s
callout header p = header <> "\n\n" <> p

bracket :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s
bracket = indent "  "

boxForkLeft, boxLeft, boxRight ::
  forall s . (LL.ListLike s Char, IsString s) => [Pretty s] -> [Pretty s]
boxForkLeft = boxLeft' lBoxStyle1
boxLeft = boxLeft' lBoxStyle2
boxRight = boxRight' rBoxStyle2

boxLeft', boxRight' :: (LL.ListLike s Char, IsString s)
         => BoxStyle s -> [Pretty s] -> [Pretty s]
boxLeft' style = fmap runIdentity . boxLeftM' style . fmap Identity
boxRight' style = fmap runIdentity . boxRightM' style . fmap Identity

type BoxStyle s =
  ( (Pretty s, Pretty s) -- first (start, continue)
  , (Pretty s, Pretty s) -- middle
  , (Pretty s, Pretty s) -- last
  , (Pretty s, Pretty s) -- singleton
  )
lBoxStyle1, lBoxStyle2, rBoxStyle2 :: IsString s => BoxStyle s
lBoxStyle1 = (("┌ ", "│ ") -- first
             ,("├ ", "│ ") -- middle
             ,("└ ", "  ") -- last
             ,(""  , "" )) -- singleton
lBoxStyle2 = (("┌ ","  ")
             ,("│ ","  ")
             ,("└ ","  ")
             ,(""  ,""  ))
rBoxStyle2 = ((" ┐", " │")
             ,(" │", " │")
             ,(" ┘", "  ")
             ,("  ", "  "))

boxLeftM, boxRightM :: forall m s . (Monad m, LL.ListLike s Char, IsString s)
         => [m (Pretty s)] -> [m (Pretty s)]
boxLeftM = boxLeftM' lBoxStyle2
boxRightM = boxRightM' rBoxStyle2

boxLeftM' :: forall m s . (Monad m, LL.ListLike s Char, IsString s)
          => BoxStyle s -> [m (Pretty s)] -> [m (Pretty s)]
boxLeftM' (first, middle, last, singleton) ps = go (Seq.fromList ps) where
  go Seq.Empty = []
  go (p Seq.:<| Seq.Empty) = [decorate singleton <$> p]
  go (a Seq.:<| (mid Seq.:|> b)) =
    [decorate first <$> a]
      ++ toList (fmap (decorate middle) <$> mid)
      ++ [decorate last <$> b]
  decorate (first, mid) p = first <> indentAfterNewline mid p

-- this implementation doesn't work for multi-line inputs,
-- because i dunno how to inspect multi-line inputs

boxRightM' :: forall m s. (Monad m, LL.ListLike s Char, IsString s)
           => BoxStyle s -> [m (Pretty s)] -> [m (Pretty s)]
boxRightM' (first, middle, last, singleton) ps = go (Seq.fromList ps) where
  go :: Seq.Seq (m (Pretty s)) -> [m (Pretty s)]
  go Seq.Empty = []
  go (p Seq.:<| Seq.Empty) = [decorate singleton <$> p]
  go (a Seq.:<| (mid Seq.:|> b)) =
    [decorate first <$> a]
      ++ toList (fmap (decorate middle) <$> mid)
      ++ [decorate last <$> b]
  decorate (first, _mid) p = p <> first

warnCallout, blockedCallout, fatalCallout, okCallout
  :: (LL.ListLike s Char, IsString s) => Pretty s -> Pretty s
warnCallout = callout "⚠"
fatalCallout = callout "❗"
okCallout = callout "✅"
blockedCallout = callout "🚫"

backticked :: IsString s => Pretty s -> Pretty s
backticked p = group ("`" <> p <> "`")

-- |Attach some punctuation after the closing backtick.
backticked' :: IsString s => Pretty s -> Pretty s -> Pretty s
backticked' p end = group ("`" <> p <> "`" <> end)

instance Show s => Show (Pretty s) where
  show p = render 80 (metaPretty p)

metaPretty :: Show s => Pretty s -> Pretty String
metaPretty = go (0::Int) where
  go prec p = case out p of
    Lit s -> parenthesizeIf (prec > 0) $ "Lit" `hang` lit (show s)
    Empty -> "Empty"
    Group g -> parenthesizeIf (prec > 0) $ "Group" `hang` go 1 g
    Wrap s -> parenthesizeIf (prec > 0) $ "Wrap" `hang`
      surroundCommas "[" "]" (go 1 <$> s)
    OrElse a b -> parenthesizeIf (prec > 0) $
      "OrElse" `hang` spaced [go 1 a, go 1 b]
    Append s -> surroundCommas "[" "]" (go 1 <$> s)

map :: LL.ListLike s2 Char => (s -> s2) -> Pretty s -> Pretty s2
map f p = case out p of
  Append ps -> foldMap (map f) ps
  Empty -> mempty
  Group p -> group (map f p)
  Lit s -> lit' (foldMap chDelta $ LL.toList s2) s2 where s2 = f s
  OrElse p1 p2 -> orElse (map f p1) (map f p2)
  Wrap p -> wrap_ (map f <$> p)

flatMap :: (s -> Pretty s2) -> Pretty s -> Pretty s2
flatMap f p = case out p of
  Append ps -> foldMap (flatMap f) ps
  Empty -> mempty
  Group p -> group (flatMap f p)
  Lit s -> f s
  OrElse p1 p2 -> orElse (flatMap f p1) (flatMap f p2)
  Wrap p -> wrap_ (flatMap f <$> p)


text:
import iolib, datasets, tools
from tools.tools import add_constant, categorical
import regression
from .regression.linear_model import OLS, GLS, WLS, GLSAR
from .regression.quantile_regression import QuantReg
from .genmod.generalized_linear_model import GLM
from .genmod import families
import robust
from .robust.robust_linear_model import RLM
from .discrete.discrete_model import (Poisson, Logit, Probit, MNLogit,
                                      NegativeBinomial)
from .tsa import api as tsa
from .nonparametric import api as nonparametric
import distributions
from __init__ import test
from . import version
from info import __doc__
from graphics.gofplots import qqplot, qqplot_2samples, qqline, ProbPlot
from .graphics import api as graphics
from .stats import api as stats
from .emplike import api as emplike

from .formula import api as formula

from .iolib.smpickle import load_pickle as load

from .tools.print_version import show_versions

import os

chmpath = os.path.join(os.path.dirname(__file__), 'statsmodelsdoc.chm')
if os.path.exists(chmpath):
    def open_help(chmpath=chmpath):
        from subprocess import Popen
        p = Popen(chmpath, shell=True)

del os
del chmpath

redpajama_set_name: RedPajamaGithub


text:
package com.getcloudcherry.survey.helper;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class DateUtils {

    public static String getCurrentTimeStamp(long iTimeMillis) {
        Date d = new Date(iTimeMillis);
        SimpleDateFormat aTimeStampFormatter = new SimpleDateFormat(
                "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.getDefault());
        String aTimeStamp = aTimeStampFormatter.format(d);
        return aTimeStamp;
    }

}


text:
  {% if page.previous_in_category %}
    {% assign f_previous = page.previous_in_category.image.feature | split: '.' %}

      {% if page.previous_in_category.image.cover %}

      {% elsif page.previous_in_category.image.feature %}

      {% endif %}

Previously

{{ page.previous_in_category.title | markdownify | strip_html }}

  {% endif %}

  {% if page.next_in_category %}
    {% assign f_next = page.next_in_category.image.feature | split: '.' %}

      {% if page.next_in_category.image.cover %}

      {% elsif page.next_in_category.image.feature %}

      {% endif %}

Up Next

{{ page.next_in_category.title | markdownify | strip_html }}

  {% endif %}


text:
import { DataTypes } from 'sequelize';
import type { Migration } from '../umzug';

export const up: Migration = async ({ context: sequelize }) => {
	await sequelize.getQueryInterface().createTable('roles', {
		id: {
			type: DataTypes.INTEGER,
			allowNull: false,
			primaryKey: true,
		},
		name: {
			type: DataTypes.STRING,
			allowNull: false,
		},
	});

	await sequelize.getQueryInterface().createTable('user_roles', {
		user_id: {
			type: DataTypes.INTEGER,
			allowNull: false,
			primaryKey: true,
			references: {
				model: 'users',
				key: 'id',
			},
		},
		role_id: {
			type: DataTypes.INTEGER,
			allowNull: false,
			primaryKey: true,
			references: {
				model: 'roles',
				key: 'id',
			},
		},
	});
};

export const down: Migration = async ({ context: sequelize }) => {
	await sequelize.getQueryInterface().dropTable('users');
};


text:
title: Contributing to the Website
parent: Contribute
grand_parent: Develop
nav_order: 2
---
# Contributing to the Website

This page shows you how to contribute to MNE-CPP's documentation website. As with other code contributions, you will need to fork MNE-CPP's repository in github and then do a pull request.

The content in this website is actually stored inside the code repository itself, and the easiest way to make changes to the documentation and check them before you do a pull request is to follow the steps below.

## Set up gh-pages

If not present already, create a new branch called `gh-pages`. Please note that the `git rm -rf .` command will delete all files in your repository folder, which are not tracked by git:
```
git checkout --orphan gh-pages
git rm -rf .
touch README.md
git add README.md
git commit -m 'initial gh-pages commit'
git push origin gh-pages
```

Make sure that `gh-pages` is activated in your forked MNE-CPP repository settigns. You can check: mne-cpp > Settings > Options > GitHub Pages > Source: gh-pages branch.

## Make your Changes to the Documentation

Create a new branch named `docu` and do your changes locally in that branch. When ready, commit and push your changes to your remote repository forked from MNE-CPP's.

If everything was setup correctly, the push should trigger a GitHub action to build your changes to the `gh-pages` branch (the one you created in the previous step). Once the GitHub action finishes, you will be able to take a look at your changes by visiting `http://$username.github.io/mne-cpp/`. Please note that it can take some time or multiple refreshes for the changes to show.

If you decide to use a different branch name, instead of `docu`, to make changes to this website,  make sure to change the branch parameter in the `docutest.yml` file accordingly (this file is stored in `.github/workflows/docutest.yml`).

The website is maintained via markdown language in `.md` files, which can be found in `mne-cpp/doc/gh-pages`.


text:
<?php

namespace ZendTest\Config;

use \Zend\Config\Xml;

/**
 * @category   Zend
 * @package    Zend_Config
 * @subpackage UnitTests
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @group      Zend_Config
 */
class XmlTest extends \PHPUnit_Framework_TestCase
{
    protected $_xmlFileConfig;
    protected $_xmlFileAllSectionsConfig;
    protected $_xmlFileCircularConfig;
    protected $_xmlFileInvalid;

    public function setUp()
    {
        $this->_xmlFileConfig = __DIR__ . '/_files/config.xml';
        $this->_xmlFileAllSectionsConfig = __DIR__ . '/_files/allsections.xml';
        $this->_xmlFileCircularConfig = __DIR__ . '/_files/circular.xml';
        $this->_xmlFileTopLevelStringConfig = __DIR__ . '/_files/toplevelstring.xml';
        $this->_xmlFileOneTopLevelStringConfig = __DIR__ . '/_files/onetoplevelstring.xml';
        $this->_nonReadableConfig = __DIR__ . '/_files/nonreadable.xml';
        $this->_xmlFileSameNameKeysConfig = __DIR__ . '/_files/array.xml';
        $this->_xmlFileShortParamsOneConfig = __DIR__ . '/_files/shortparamsone.xml';
        $this->_xmlFileShortParamsTwoConfig = __DIR__ . '/_files/shortparamstwo.xml';
        $this->_xmlFileInvalid = __DIR__ . '/_files/invalid.xml';
    }

    public function testLoadSingleSection()
    {
        $config = new Xml($this->_xmlFileConfig, 'all');
        $this->assertEquals('all', $config->hostname);
        $this->assertEquals('live', $config->db->name);
        $this->assertEquals('multi', $config->one->two->three);
        $this->assertNull(@$config->nonexistent); // property doesn't exist
    }

    public function testSectionInclude()
    {
        $config = new Xml($this->_xmlFileConfig, 'staging');
        $this->assertEquals('false', $config->debug); // only in staging
        $this->assertEquals('thisname', $config->name); // only in all
        $this->assertEquals('username', $config->db->user); // only in all (nested version)
        $this->assertEquals('staging', $config->hostname); // inherited and overridden
        $this->assertEquals('dbstaging', $config->db->name); // inherited and overridden
    }

    public function testMultiDepthExtends()
    {
        $config = new Xml($this->_xmlFileConfig, 'other_staging');

        $this->assertEquals('otherStaging', $config->only_in); // only in other_staging
        $this->assertEquals('false', $config->debug); // 1 level down: only in staging
        $this->assertEquals('thisname', $config->name); // 2 levels down: only in all
        $this->assertEquals('username', $config->db->user); // 2 levels down: only in all (nested version)
        $this->assertEquals('staging', $config->hostname); // inherited from two to one and overridden
        $this->assertEquals('dbstaging', $config->db->name); // inherited from two to one and overridden
        $this->assertEquals('anotherpwd', $config->db->pass); // inherited from two to other_staging and overridden
    }

    public function testErrorNoInitialSection()
    {
        $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'cannot be found in');
        $config = @new Xml($this->_xmlFileConfig, 'notthere');
    }

    public function testErrorNoInitialSectionWhenArrayOfSectionsSpecified()
    {
        $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'cannot be found in');
        $config = @new Xml($this->_xmlFileConfig, array('notthere', 'all'));
    }

    public function testErrorNoExtendsSection()
    {
        $this->setExpectedException('Zend\Config\Exception\RuntimeException', 'cannot be found');
        $config = new Xml($this->_xmlFileConfig, 'extendserror');
    }

    public function testZF413_MultiSections()
    {
        $config = new Xml($this->_xmlFileAllSectionsConfig, array('staging','other_staging'));

        $this->assertEquals('otherStaging', $config->only_in);
        $this->assertEquals('staging', $config->hostname);
    }

    public function testZF413_AllSections()
    {
        $config = new Xml($this->_xmlFileAllSectionsConfig, null);
        $this->assertEquals('otherStaging', $config->other_staging->only_in);
        $this->assertEquals('staging', $config->staging->hostname);
    }

    public function testZF414()
    {
        $config = new Xml($this->_xmlFileAllSectionsConfig, null);
        $this->assertEquals(null, $config->getSectionName());
        $this->assertEquals(true, $config->areAllSectionsLoaded());

        $config = new Xml($this->_xmlFileAllSectionsConfig, 'all');
        $this->assertEquals('all', $config->getSectionName());
        $this->assertEquals(false, $config->areAllSectionsLoaded());

        $config = new Xml($this->_xmlFileAllSectionsConfig, array('staging','other_staging'));
        $this->assertEquals(array('staging','other_staging'), $config->getSectionName());
        $this->assertEquals(false, $config->areAllSectionsLoaded());
    }

    public function testZF415()
    {
        $this->setExpectedException('Zend\Config\Exception\RuntimeException', 'circular inheritance');
        $config = new Xml($this->_xmlFileCircularConfig, null);
    }

    public function testErrorNoFile()
    {
        $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'Filename is not set');
        $config = new Xml('',null);
    }

    public function testZF2162_TopLevelString()
    {
        $config = new Xml($this->_xmlFileTopLevelStringConfig, null);
        $this->assertEquals('one', $config->one);
        $this->assertEquals('three', $config->two->three);
        $this->assertEquals('five', $config->two->four->five);
        $this->assertEquals('three', $config->six->three);

        $config = new Xml($this->_xmlFileOneTopLevelStringConfig);
        $this->assertEquals('one', $config->one);
        $config = new Xml($this->_xmlFileOneTopLevelStringConfig, 'one');
        $this->assertEquals('one', $config->one);

    }

    public function testZF2285_MultipleKeysOfTheSameName()
    {
        $config = new Xml($this->_xmlFileSameNameKeysConfig, null);
        $this->assertEquals('2a', $config->one->two->{0});
        $this->assertEquals('2b', $config->one->two->{1});
        $this->assertEquals('4', $config->three->four->{1});
        $this->assertEquals('5', $config->three->four->{0}->five);
    }

    public function testZF2437_ArraysWithMultipleChildren()
    {
        $config = new Xml($this->_xmlFileSameNameKeysConfig, null);
        $this->assertEquals('1', $config->six->seven->{0}->eight);
        $this->assertEquals('2', $config->six->seven->{1}->eight);
        $this->assertEquals('3', $config->six->seven->{2}->eight);
        $this->assertEquals('1', $config->six->seven->{0}->nine);
        $this->assertEquals('2', $config->six->seven->{1}->nine);
        $this->assertEquals('3', $config->six->seven->{2}->nine);
    }

    /**
     * @group ZF-3578
     */
    public function testInvalidXmlFile()
    {
        $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'parser error');
        $config = new Xml($this->_xmlFileInvalid);
    }

    /**
     * @group ZF-3578
     */
    public function testMissingXmlFile()
    {
        $this->setExpectedException('Zend\Config\Exception\InvalidArgumentException', 'failed to load');
        $config = new Xml('I/dont/exist');
    }

    public function testShortParamsOne()
    {
        $config = new Xml($this->_xmlFileShortParamsOneConfig, 'all');
        $this->assertEquals('all', $config->hostname);
        $this->assertEquals('thisname', $config->name);
        $this->assertEquals('username', $config->db->user);
        $this->assertEquals('live', $config->db->name);
        $this->assertEquals('multi', $config->one->two->three);
    }

    public function testShortParamsTwo()
    {
        $config = new Xml($this->_xmlFileShortParamsTwoConfig, 'all');
        $this->assertEquals('all', $config->hostname);
        $this->assertEquals('thisname', $config->name);
        $this->assertEquals('username', $config->db->user);
        $this->assertEquals('live', $config->db->name);
        $this->assertEquals('multi', $config->one->two->three);
    }

    public function testConstants()
    {
        if (!defined('ZEND_CONFIG_XML_TEST_CONSTANT')) {
            define('ZEND_CONFIG_XML_TEST_CONSTANT', 'test');
        }

        $string = <<<EOT
<?xml version="1.0"?>
<config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/">
    <all>
        <foo>foo-<zf:const zf:name="ZEND_CONFIG_XML_TEST_CONSTANT"/>-bar-<zf:const zf:name="ZEND_CONFIG_XML_TEST_CONSTANT"/></foo>
        <bar><const name="ZEND_CONFIG_XML_TEST_CONSTANT"/></bar>
    </all>
</config>
EOT;

        $config = new Xml($string, 'all');

        $this->assertEquals('foo-test-bar-test', $config->foo);
        $this->assertEquals('ZEND_CONFIG_XML_TEST_CONSTANT', $config->bar->const->name);
    }

    public function testNonExistentConstant()
    {
        $string = <<<EOT
<?xml version="1.0"?>
<config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/">
    <all>
        <foo>foo-<zf:const zf:name="ZEND_CONFIG_XML_TEST_NON_EXISTENT_CONSTANT"/></foo>
    </all>
</config>
EOT;

        $this->setExpectedException('Zend\Config\Exception\RuntimeException', "Constant with name 'ZEND_CONFIG_XML_TEST_NON_EXISTENT_CONSTANT' was not defined");
        $config = new Xml($string, 'all');
    }

    public function testNamespacedExtends()
    {
        $string = <<<EOT
<?xml version="1.0"?>
<config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/">
    <all>
        <foo>bar</foo>
    </all>
    <staging zf:extends="all"/>
</config>
EOT;

        $config = new Xml($string);

        $this->assertEquals('bar', $config->staging->foo);
    }

    /*
     * @group 3702
     *
     */
    public function testLoadAnXMLString()
    {
        $string = <<<EOT
<?xml version="1.0"?>
<config>
    <all>
        <hostname>all</hostname>
        <db>
            <host>127.0.0.1</host>
            <name>live</name>
        </db>
    </all>

    <staging extends="all">
        <hostname>staging</hostname>
        <db>
            <name>dbstaging</name>
        </db>
        <debug>false</debug>
    </staging>

</config>
EOT;

        $config = new Xml($string, 'staging');
        $this->assertEquals('staging', $config->hostname);

    }

    /*
     * @group ZF-5800
     *
     */
    public function testArraysOfKeysCreatedUsingAttributesAndKeys()
    {
        $string = <<<EOT
<?xml version="1.0"?>
<config>
<rec>
        <receiver>
                <mail>user1@company.com</mail>
                <name>User Name</name>
                <html>1</html>
        </receiver>
</rec>
<dev extends="rec">
        <receiver mail="nice.guy@company.com" name="Nice Guy" />
        <receiver mail="fred@company.com" html="2" />
</dev>
</config>
EOT;

        $config = new Xml($string, 'dev');
        $this->assertEquals('nice.guy@company.com', $config->receiver->{0}->mail);
        $this->assertEquals('1', $config->receiver->{0}->html);
        $this->assertNull($config->receiver->mail);
    }
}


text:
@interface HomeTableHeaderView ()<UICollectionViewDataSource,UICollectionViewDelegate>

@property (nonatomic, copy) void(^imageClickedBlock)(NSInteger index);
@property (weak, nonatomic) IBOutlet UIView *cycleBackgroundView;
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UIView *collectionShadowBgView;

@property (nonatomic, strong) NSArray *sourceArray;
@property (nonatomic, strong) NSArray *detailArray;
@property (nonatomic, strong) NSArray *imageArray;

@end

@implementation HomeTableHeaderView

+ (instancetype)loadHeaderView {
   return [[NSBundle mainBundle]loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].firstObject;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupData];
    [self setupSubViews];
}

- (void)setupData {
    _sourceArray = @[@"消费贷款",@"购车贷款",@"购房贷款",@"企业贷款"];
    _detailArray = @[@"个人消费",@"购买汽车",@"购买房子",@"企业消费"];
    _imageArray = @[@"01-icon-Personal",@"01-icon-car",@"01-icon-house",@"01-icon-company"];
}

- (void)setupSubViews {
    [self setupCollectionView];
    [self setupCollectionShadowView];
}

- (void)setupCollectionView {
    self.collectionView.dataSource = self;
    self.collectionView.delegate = self;

    [self.collectionView registerNib:[UINib nibWithNibName:@"HomeHeaderCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"HomeHeaderCollectionCell"];

    UICollectionViewFlowLayout *flowLayout = (UICollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
    flowLayout.itemSize = CGSizeMake((kScreenW  - 24 )/ 2 - 0.005, 70 - 0.005);
    flowLayout.minimumLineSpacing = 0.01;
    flowLayout.minimumInteritemSpacing = 0.01;
}

- (void)setupCollectionShadowView {
    self.collectionShadowBgView.layer.shadowColor = [UIColor blackColor].CGColor;
    self.collectionShadowBgView.layer.shadowOffset = CGSizeMake(0, 6);
    self.collectionShadowBgView.layer.shadowOpacity = 0.08;

    //
}

- (void)clickImage:(void(^)(NSInteger index))imageAction {
    self.imageClickedBlock = imageAction;
}

#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return _sourceArray.count;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HomeHeaderCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"HomeHeaderCollectionCell" forIndexPath:indexPath];
    cell.testLabel.text = _sourceArray[indexPath.row];
    cell.imageView.image = [UIImage imageNamed:_imageArray[indexPath.row]];
    cell.detailLabel.text = _detailArray[indexPath.row];
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    if ([self.delegate respondsToSelector:@selector(itemDidSelectAtIndexPath:)]) {
        [self.delegate itemDidSelectAtIndexPath:indexPath];
    }
}

@end


text:
<?php

header('Content-type: application/json');
session_start();
include('config.php');

	$name = $_POST['name'];
  	$email = $_POST['email'];
	$address = $_POST['address'];
	$password = $_POST['password'];
	$hashed_password = sha1($password);

	if(filter_var($email,FILTER_VALIDATE_EMAIL)){

		$select = "SELECT * FROM users WHERE email='$email'";
		$query = mysql_query($select);
		$numrows = mysql_num_rows($query);

		if($numrows != 0){
			$msg = "already";
		}
		else{
			$conf_code = md5(uniqid(rand()));
			$insert = "INSERT INTO users (name,email,password,conf_code,address)
			VALUES('$name','$email','$hashed_password','$conf_code','$address')";
			$query=mysql_query($insert);

			if(!$query){
				$msg = "failed";
			}
			else{

				$to = $email;
				$sub = "Verify your email address";
				$msg4 = '

Hi '.$name.',

Thank you for signing up for Robbinbakers. Please click the "Verify" button below to verify your email id.

							Verify

Please ignore this mail if you did not sign up for Robbinbakers.</p

Thanking you,

							Robbinbakers

We design your dreams

                            Find us at Robbinbakers

';

				$headers = "From:Robbinbakers <contact@robbinbakers.com>\r\n";
				$headers .= "MIME-Version: 1.0\r\n";
				$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
				mail($to,$sub,$msg4,$headers);
				$msg = "success";
			}
		}
		mysql_close($server_connect);
	}
	else{
		$msg = "invalid_email";
	}

	print  json_encode(array('msg' => $msg));

?>


text:
using System;
using System.Threading;
using System.Threading.Tasks;

using Google.Apis.Auth.OAuth2.Flows;

namespace Google.Apis.Auth.OAuth2
{
    /// <summary>
    /// OAuth 2.0 authorization code flow for a Windows Phone 8.1 installed application that persists end-user
    /// credentials.
    /// <remarks>
    /// This installed app class uses an internal <see cref="AuthorizationCodeInstalledApp"/> with a
    /// <see cref="Google.Apis.Auth.OAuth2.AuthorizationCodeBroker"/> for retrieving the authorization code.
    /// </remarks>
    /// </summary>
    public sealed class AuthorizationCodeWPInstalledApp : IAuthorizationCodeInstalledApp
    {
        private readonly IAuthorizationCodeInstalledApp innerInstallApp;

        /// <summary>
        /// Constructs a new authorization code for Windows Store application targeting an installed application flow.
        /// </summary>
        /// <param name="authorizationCodeFlowInitializer">An authorization code flow initializer.</param>
        public AuthorizationCodeWPInstalledApp(AuthorizationCodeFlow.Initializer authorizationCodeFlowInitializer)
        {
            innerInstallApp = new AuthorizationCodeInstalledApp(
                new AuthorizationCodeFlow(authorizationCodeFlowInitializer), new AuthorizationCodeBroker());
        }

        /// <summary>
        /// Constructs a new authorization code for Windows Store application targeting an installed application flow.
        /// </summary>
        /// <param name="flow">An authorization code flow.</param>
        public AuthorizationCodeWPInstalledApp(IAuthorizationCodeFlow flow)
        {
            innerInstallApp = new AuthorizationCodeInstalledApp(flow, new AuthorizationCodeBroker());
        }

        #region IAuthorizationCodeInstalledApp Members

        public IAuthorizationCodeFlow Flow
        {
            get { return innerInstallApp.Flow; }
        }

        public ICodeReceiver CodeReceiver
        {
            get { return innerInstallApp.CodeReceiver; }
        }

        public async Task<UserCredential> AuthorizeAsync(string userId, CancellationToken taskCancellationToken)
        {
            return await innerInstallApp.AuthorizeAsync(userId, taskCancellationToken).ConfigureAwait(false);
        }

        #endregion
    }
}


text:
.class public final Landroid/support/coreui/R;
.super Ljava/lang/Object;
.source "R.java"

# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 9
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


text:
package Mod.Gui;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Icon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;

import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import Mod.Container.ContainerStorageBlock;
import Mod.TileEntity.TileEntityStorageBlock;

public class GuiStorageBlock extends ModGuiContainer{

	private final ResourceLocation Texture = new ResourceLocation("miscitems" , "textures/gui/StorageBlockGui.png");

	    String username;
	    boolean isScrolling = false;
	    boolean wasClicking;
	    float currentScroll = 0.0F;
	    int slotPos = 0;
	    int prevSlotPos = 0;

	    TileEntityStorageBlock tile;

		public GuiStorageBlock(InventoryPlayer InvPlayer, TileEntityStorageBlock tile) {
			super(new ContainerStorageBlock(InvPlayer, tile));
			this.xSize = 176;
			this.ySize = 235;

			this.tile = tile;
	        username = InvPlayer.player.username;

		}

	    @Override
	    public void drawScreen (int mouseX, int mouseY, float par3)
	    {
	        super.drawScreen(mouseX, mouseY, par3);
	        updateScrollbar(mouseX, mouseY, par3);
	    }

	    protected void updateScrollbar (int mouseX, int mouseY, float par3)
	    {
	        if (tile.getSizeInventory() > 64)
	        {
	            boolean mouseDown = Mouse.isButtonDown(0);
	            int lefto = this.guiLeft;
	            int topo = this.guiTop;
	            int xScroll = lefto + 157;
	            int yScroll = topo + 6;
	            int scrollWidth = xScroll + 14;
	            int scrollHeight = yScroll + 144;

	            if (!this.wasClicking && mouseDown && mouseX >= xScroll && mouseY >= yScroll && mouseX < scrollWidth && mouseY < scrollHeight)
	            {
	                this.isScrolling = true;
	            }

	            if (!mouseDown)
	            {
	                this.isScrolling = false;
	            }

	            if (wasClicking && !isScrolling && slotPos != prevSlotPos)
	            {
	                prevSlotPos = slotPos;
	            }

	            this.wasClicking = mouseDown;

	            if (this.isScrolling)
	            {
	                this.currentScroll = (mouseY - yScroll - 7.5F) / (scrollHeight - yScroll - 15.0F);

	                if (this.currentScroll < 0.0F)
	                {
	                    this.currentScroll = 0.0F;
	                }

	                if (this.currentScroll > 1.0F)
	                {
	                    this.currentScroll = 1.0F;
	                }

	                int s = ((ContainerStorageBlock) this.container).scrollTo(this.currentScroll);
	                if (s != -1)
	                    slotPos = s;
	            }
	        }
	    }

	    @Override
	    protected void drawGuiContainerForegroundLayer (int mouseX, int mouseY)
	    {

	        int base = 0;
	        int cornerX = (width - xSize) / 2;
	        int cornerY = (height - ySize) / 2;

	    }

	    @Override
	    protected void drawGuiContainerBackgroundLayer (float f, int mouseX, int mouseY)
	    {
	        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	        this.mc.getTextureManager().bindTexture(Texture);
	        int cornerX = (width - xSize) / 2;
	        int cornerY = (height - ySize) / 2;
	        drawTexturedModalRect(cornerX, cornerY, 0, 0, 176, ySize);

	            drawTexturedModalRect(cornerX + 157, (int) (cornerY + 6 + 127 * currentScroll), 176, 0, 12, 15);

	    }

	    protected void drawToolTip (List par1List, int par2, int par3)
	    {
	        if (!par1List.isEmpty())
	        {
	            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
	            RenderHelper.disableStandardItemLighting();
	            GL11.glDisable(GL11.GL_LIGHTING);
	            GL11.glDisable(GL11.GL_DEPTH_TEST);
	            int k = 0;
	            Iterator iterator = par1List.iterator();

	            while (iterator.hasNext())
	            {
	                String s = (String) iterator.next();
	                int l = this.fontRenderer.getStringWidth(s);

	                if (l > k)
	                {
	                    k = l;
	                }
	            }

	            int i1 = par2 + 12;
	            int j1 = par3 - 12;
	            int k1 = 8;

	            if (par1List.size() > 1)
	            {
	                k1 += 2 + (par1List.size() - 1) * 10;
	            }

	            if (i1 + k > this.width)
	            {
	                i1 -= 28 + k;
	            }

	            if (j1 + k1 + 6 > this.height)
	            {
	                j1 = this.height - k1 - 6;
	            }

	            this.zLevel = 300.0F;
	            itemRenderer.zLevel = 300.0F;
	            int l1 = -267386864;
	            this.drawGradientRect(i1 - 3, j1 - 4, i1 + k + 3, j1 - 3, l1, l1);
	            this.drawGradientRect(i1 - 3, j1 + k1 + 3, i1 + k + 3, j1 + k1 + 4, l1, l1);
	            this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 + k1 + 3, l1, l1);
	            this.drawGradientRect(i1 - 4, j1 - 3, i1 - 3, j1 + k1 + 3, l1, l1);
	            this.drawGradientRect(i1 + k + 3, j1 - 3, i1 + k + 4, j1 + k1 + 3, l1, l1);
	            int i2 = 1347420415;
	            int j2 = (i2 & 16711422) >> 1 | i2 & -16777216;
	            this.drawGradientRect(i1 - 3, j1 - 3 + 1, i1 - 3 + 1, j1 + k1 + 3 - 1, i2, j2);
	            this.drawGradientRect(i1 + k + 2, j1 - 3 + 1, i1 + k + 3, j1 + k1 + 3 - 1, i2, j2);
	            this.drawGradientRect(i1 - 3, j1 - 3, i1 + k + 3, j1 - 3 + 1, i2, i2);
	            this.drawGradientRect(i1 - 3, j1 + k1 + 2, i1 + k + 3, j1 + k1 + 3, j2, j2);

	            for (int k2 = 0; k2 < par1List.size(); ++k2)
	            {
	                String s1 = (String) par1List.get(k2);
	                this.fontRenderer.drawStringWithShadow(s1, i1, j1, -1);

	                if (k2 == 0)
	                {
	                    j1 += 2;
	                }

	                j1 += 10;
	            }

	            this.zLevel = 0.0F;
	            itemRenderer.zLevel = 0.0F;
	        }
	    }

	}


text:
<?php

namespace OpenCrest\Objects\Market;

use OpenCrest\Objects\TypesObject;
use OpenCrest\Objects\Universe\LocationsObject;

class OrdersObject extends Object
{
    protected $uri = "orders/";

    protected $relations = [
        "location" => LocationsObject::class,
        "type"     => TypesObject::class,
    ];
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ChangeListManager">
    <list default="true" id="381d7fea-db21-4134-b1e3-b8eecbc45834" name="Default" comment="" />
    <ignored path="zf2.iws" />
    <ignored path=".idea/workspace.xml" />
    <ignored path=".idea/dataSources.local.xml" />
    <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
    <option name="TRACKING_ENABLED" value="true" />
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
    <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
    <option name="LAST_RESOLUTION" value="IGNORE" />
  </component>
  <component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
  <component name="CreatePatchCommitExecutor">
    <option name="PATCH_PATH" value="" />
  </component>
  <component name="DaemonCodeAnalyzer">
    <disable_hints />
  </component>
  <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
  <component name="FavoritesManager">
    <favorites_list name="zf2" />
  </component>
  <component name="FileEditorManager">
    <leaf>
      <file leaf-file-name="Module.php" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/module/AppCore/Module.php">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="-9.153846" vertical-offset="0" max-vertical-offset="663">
              <caret line="20" column="52" selection-start-line="20" selection-start-column="52" selection-end-line="20" selection-end-column="52" />
              <folding>
                <element signature="e#350#383#0#PHP" expanded="true" />
              </folding>
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="IndexController.php" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/module/AppCore/src/AppCore/Controller/IndexController.php">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="-1.9615384" vertical-offset="0" max-vertical-offset="357">
              <caret line="9" column="17" selection-start-line="9" selection-start-column="17" selection-end-line="9" selection-end-column="17" />
              <folding>
                <element signature="e#361#410#0#PHP" expanded="true" />
              </folding>
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="module.config.php" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/module/AppCore/config/module.config.php">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="-5.230769" vertical-offset="0" max-vertical-offset="255">
              <caret line="8" column="2" selection-start-line="8" selection-start-column="2" selection-end-line="8" selection-end-column="2" />
              <folding>
                <element signature="e#6#13#0#PHP" expanded="true" />
              </folding>
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="IndexController.php" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/module/Teste/src/Teste/Controller/IndexController.php">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="-1.9615384" vertical-offset="0" max-vertical-offset="340">
              <caret line="9" column="15" selection-start-line="9" selection-start-column="15" selection-end-line="9" selection-end-column="15" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="application.config.php" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/config/application.config.php">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="-3.2692308" vertical-offset="0" max-vertical-offset="1207">
              <caret line="5" column="15" selection-start-line="5" selection-start-column="15" selection-end-line="5" selection-end-column="15" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="module.config.php" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/module/Teste/config/module.config.php">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="-53.115383" vertical-offset="13" max-vertical-offset="1768">
              <caret line="83" column="59" selection-start-line="83" selection-start-column="59" selection-end-line="83" selection-end-column="59" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="index.phtml" pinned="false" current-in-tab="true">
        <entry file="file://$PROJECT_DIR$/module/Teste/view/teste/index/index.phtml">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="0.8762136" vertical-offset="26" max-vertical-offset="850">
              <caret line="44" column="0" selection-start-line="44" selection-start-column="0" selection-end-line="44" selection-end-column="0" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="Module.php" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/module/Teste/Module.php">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="-9.807693" vertical-offset="0" max-vertical-offset="646">
              <caret line="22" column="0" selection-start-line="22" selection-start-column="0" selection-end-line="22" selection-end-column="0" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="index.php" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/public/index.php">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="-0.0" vertical-offset="0" max-vertical-offset="391">
              <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
      <file leaf-file-name="local.php.dist" pinned="false" current-in-tab="false">
        <entry file="file://$PROJECT_DIR$/config/autoload/local.php.dist">
          <provider selected="true" editor-type-id="text-editor">
            <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="357">
              <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
              <folding />
            </state>
          </provider>
        </entry>
      </file>
    </leaf>
  </component>
  <component name="IdeDocumentHistory">
    <option name="CHANGED_PATHS">
      <list>
        <option value="$PROJECT_DIR$/module/Application/Module.php" />
        <option value="$PROJECT_DIR$/module/Application/view/application/index/index.phtml" />
        <option value="$PROJECT_DIR$/module/Application/view/layout/layout.phtml" />
        <option value="$PROJECT_DIR$/module/Application/config/module.config.php" />
        <option value="$PROJECT_DIR$/public/css/style.css" />
        <option value="$PROJECT_DIR$/module/Application/language/pt_BR.po" />
        <option value="$PROJECT_DIR$/module/Core/config/module.config.php" />
        <option value="$PROJECT_DIR$/module/AppCore/Module.php" />
        <option value="$PROJECT_DIR$/module/AppCore/src/AppCore/Controller/IndexController.php" />
        <option value="$PROJECT_DIR$/module/AppCore/config/module.config.php" />
        <option value="$PROJECT_DIR$/config/application.config.php" />
        <option value="$PROJECT_DIR$/module/Teste/config/module.config.php" />
        <option value="$PROJECT_DIR$/module/Teste/Module.php" />
        <option value="$PROJECT_DIR$/module/Teste/src/Teste/Controller/IndexController.php" />
        <option value="$PROJECT_DIR$/module/Teste/view/teste/index/index.phtml" />
      </list>
    </option>
  </component>
  <component name="JsGulpfileManager">
    <detection-done>true</detection-done>
  </component>
  <component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
  <component name="ProjectFrameBounds">
    <option name="x" value="260" />
    <option name="y" value="20" />
    <option name="width" value="1400" />
    <option name="height" value="1000" />
  </component>
  <component name="ProjectLevelVcsManager" settingsEditedManually="false">
    <OptionsSetting value="true" id="Add" />
    <OptionsSetting value="true" id="Remove" />
    <OptionsSetting value="true" id="Checkout" />
    <OptionsSetting value="true" id="Update" />
    <OptionsSetting value="true" id="Status" />
    <OptionsSetting value="true" id="Edit" />
    <ConfirmationsSetting value="0" id="Add" />
    <ConfirmationsSetting value="0" id="Remove" />
  </component>
  <component name="ProjectView">
    <navigator currentView="ProjectPane" proportions="" version="1">
      <flattenPackages />
      <showMembers />
      <showModules />
      <showLibraryContents />
      <hideEmptyPackages />
      <abbreviatePackageNames />
      <autoscrollToSource />
      <autoscrollFromSource />
      <sortByType />
    </navigator>
    <panes>
      <pane id="ProjectPane">
        <subPane>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="public" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="public" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="js" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="module" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="Teste" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
          <PATH>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="zf2" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
            <PATH_ELEMENT>
              <option name="myItemId" value="module" />
              <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
            </PATH_ELEMENT>
          </PATH>
        </subPane>
      </pane>
      <pane id="Scope" />
    </panes>
  </component>
  <component name="PropertiesComponent">
    <property name="last_opened_file_path" value="$PROJECT_DIR$/../../../php" />
    <property name="options.lastSelected" value="configurable.group.language" />
    <property name="options.splitter.main.proportions" value="0.3" />
    <property name="options.splitter.details.proportions" value="0.2" />
    <property name="WebServerToolWindowFactoryState" value="false" />
    <property name="FullScreen" value="false" />
  </component>
  <component name="RecentsManager">
    <key name="CopyFile.RECENT_KEYS">
      <recent name="C:\Bitnami\wappstack-5.4.34-0\apache2\htdocs\zf2\module" />
    </key>
  </component>
  <component name="RunManager">
    <configuration default="true" type="PHPUnitRunConfigurationType" factoryName="PHPUnit">
      <TestRunner />
      <method />
    </configuration>
    <configuration default="true" type="PhpLocalRunConfigurationType" factoryName="PHP Console">
      <method />
    </configuration>
    <configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
      <method />
    </configuration>
    <configuration default="true" type="PhpBehatConfigurationType" factoryName="Behat">
      <BehatRunner />
      <method />
    </configuration>
    <configuration default="true" type="PhpUnitRemoteRunConfigurationType" factoryName="PHPUnit on Server">
      <method />
    </configuration>
    <configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
      <method />
    </configuration>
    <list size="0" />
  </component>
  <component name="ShelveChangesManager" show_recycled="false" />
  <component name="SvnConfiguration">
    <configuration />
  </component>
  <component name="TaskManager">
    <task active="true" id="Default" summary="Default task">
      <changelist id="381d7fea-db21-4134-b1e3-b8eecbc45834" name="Default" comment="" />
      <created>1429103306363</created>
      <option name="number" value="Default" />
      <updated>1429103306363</updated>
    </task>
    <servers />
  </component>
  <component name="ToolWindowManager">
    <frame x="260" y="20" width="1400" height="1000" extended-state="0" />
    <editor active="false" />
    <layout>
      <window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
      <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32996634" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Application Servers" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.2586705" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
      <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
      <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
      <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
      <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
      <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="SLIDING" type="SLIDING" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
      <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
      <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
      <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
      <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
    </layout>
  </component>
  <component name="Vcs.Log.UiProperties">
    <option name="RECENTLY_FILTERED_USER_GROUPS">
      <collection />
    </option>
    <option name="RECENTLY_FILTERED_BRANCH_GROUPS">
      <collection />
    </option>
  </component>
  <component name="VcsContentAnnotationSettings">
    <option name="myLimit" value="2678400000" />
  </component>
  <component name="VcsManagerConfiguration">
    <option name="myTodoPanelSettings">
      <TodoPanelSettings />
    </option>
  </component>
  <component name="XDebuggerManager">
    <breakpoint-manager />
    <watches-manager />
  </component>
  <component name="editorHistoryManager">
    <entry file="jar://$APPLICATION_HOME_DIR$/plugins/php/lib/php.jar!/com/jetbrains/php/lang/psi/stubs/data/date.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="1.7050971" vertical-offset="3508" max-vertical-offset="24310">
          <caret line="289" column="9" selection-start-line="289" selection-start-column="9" selection-end-line="289" selection-end-column="9" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/AppCore/view/layout/layout.phtml">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-12.076923" vertical-offset="213" max-vertical-offset="1037">
          <caret line="31" column="27" selection-start-line="31" selection-start-column="21" selection-end-line="31" selection-end-column="27" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/public/js/jquery-1.10.2.min.map">
      <provider editor-type-id="sourcemapFileViewerProvider">
        <state />
      </provider>
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="820">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/public/js/bootstrap.js">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="3672" max-vertical-offset="34204">
          <caret line="245" column="27" selection-start-line="245" selection-start-column="27" selection-end-line="245" selection-end-column="27" />
          <folding>
            <element signature="n#!!doc" expanded="true" />
          </folding>
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/AppCore/language/pt_BR.mo">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.60048723" vertical-offset="0" max-vertical-offset="821">
          <caret line="29" column="1562" selection-start-line="29" selection-start-column="1557" selection-end-line="29" selection-end-column="1562" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/AppCore/language/pt_BR.po">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.1863581" vertical-offset="765" max-vertical-offset="2703">
          <caret line="54" column="21" selection-start-line="54" selection-start-column="21" selection-end-line="54" selection-end-column="21" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/public/css/style.css">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="731">
          <caret line="22" column="20" selection-start-line="22" selection-start-column="20" selection-end-line="22" selection-end-column="20" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/config/autoload/global.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="863">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/config/autoload/local.php.dist">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="863">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/AppCore/src/AppCore/Controller/IndexController.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-1.9615384" vertical-offset="0" max-vertical-offset="340">
          <caret line="9" column="17" selection-start-line="9" selection-start-column="17" selection-end-line="9" selection-end-column="17" />
          <folding>
            <element signature="e#361#410#0#PHP" expanded="true" />
          </folding>
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/AppCore/config/module.config.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-5.230769" vertical-offset="0" max-vertical-offset="255">
          <caret line="8" column="2" selection-start-line="8" selection-start-column="2" selection-end-line="8" selection-end-column="2" />
          <folding>
            <element signature="e#6#13#0#PHP" expanded="true" />
          </folding>
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/AppCore/Module.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-9.153846" vertical-offset="0" max-vertical-offset="663">
          <caret line="20" column="52" selection-start-line="20" selection-start-column="52" selection-end-line="20" selection-end-column="52" />
          <folding>
            <element signature="e#350#383#0#PHP" expanded="true" />
          </folding>
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/public/index.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="863">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/config/application.config.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-3.2692308" vertical-offset="0" max-vertical-offset="1207">
          <caret line="5" column="15" selection-start-line="5" selection-start-column="15" selection-end-line="5" selection-end-column="15" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/Teste/Module.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-9.807693" vertical-offset="0" max-vertical-offset="646">
          <caret line="22" column="0" selection-start-line="22" selection-start-column="0" selection-end-line="22" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/Teste/src/Teste/Controller/IndexController.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-1.9615384" vertical-offset="0" max-vertical-offset="340">
          <caret line="9" column="15" selection-start-line="9" selection-start-column="15" selection-end-line="9" selection-end-column="15" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/Teste/config/module.config.php">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="-53.115383" vertical-offset="13" max-vertical-offset="1768">
          <caret line="83" column="59" selection-start-line="83" selection-start-column="59" selection-end-line="83" selection-end-column="59" />
          <folding />
        </state>
      </provider>
    </entry>
    <entry file="file://$PROJECT_DIR$/module/Teste/view/teste/index/index.phtml">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.8762136" vertical-offset="26" max-vertical-offset="850">
          <caret line="44" column="0" selection-start-line="44" selection-start-column="0" selection-end-line="44" selection-end-column="0" />
          <folding />
        </state>
      </provider>
    </entry>
  </component>
</project>


text:
UninstallView::UninstallView(int* user_selection,
                             const base::Closure& quit_closure)
    : confirm_label_(NULL),
      delete_profile_(NULL),
      change_default_browser_(NULL),
      browsers_combo_(NULL),
      user_selection_(*user_selection),
      quit_closure_(quit_closure) {
  SetButtonLabel(ui::DIALOG_BUTTON_OK,
                 l10n_util::GetStringUTF16(IDS_UNINSTALL_BUTTON_TEXT));
  SetAcceptCallback(
      base::BindOnce(&UninstallView::OnDialogAccepted, base::Unretained(this)));
  SetCancelCallback(base::BindOnce(&UninstallView::OnDialogCancelled,
                                   base::Unretained(this)));
  SetCloseCallback(base::BindOnce(&UninstallView::OnDialogCancelled,
                                  base::Unretained(this)));
  set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(
      views::TEXT, views::TEXT));
  SetupControls();
}

UninstallView::~UninstallView() {
  // Exit the message loop we were started with so that uninstall can continue.
  quit_closure_.Run();

  // Delete Combobox as it holds a reference to us.
  delete browsers_combo_;
}

void UninstallView::SetupControls() {
  using views::ColumnSet;

  views::GridLayout* layout =
      SetLayoutManager(std::make_unique<views::GridLayout>());

  // Message to confirm uninstallation.
  int column_set_id = 0;
  ColumnSet* column_set = layout->AddColumnSet(column_set_id);
  column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
                        views::GridLayout::kFixedSize,
                        views::GridLayout::ColumnSize::kUsePreferred, 0, 0);
  layout->StartRow(views::GridLayout::kFixedSize, column_set_id);
  auto confirm_label = std::make_unique<views::Label>(
      l10n_util::GetStringUTF16(IDS_UNINSTALL_VERIFY));
  confirm_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
  confirm_label_ = layout->AddView(std::move(confirm_label));

  ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();

  const int checkbox_indent = provider->GetDistanceMetric(
      DISTANCE_SUBSECTION_HORIZONTAL_INDENT);
  const int unrelated_vertical_spacing =
      provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);
  const int related_vertical_spacing = provider->GetDistanceMetric(
      views::DISTANCE_RELATED_CONTROL_VERTICAL);
  const int related_horizontal_spacing = provider->GetDistanceMetric(
      views::DISTANCE_RELATED_CONTROL_HORIZONTAL);
  const int related_vertical_small = provider->GetDistanceMetric(
      DISTANCE_RELATED_CONTROL_VERTICAL_SMALL);

  layout->AddPaddingRow(views::GridLayout::kFixedSize,
                        unrelated_vertical_spacing);

  // The "delete profile" check box.
  ++column_set_id;
  column_set = layout->AddColumnSet(column_set_id);
  column_set->AddPaddingColumn(views::GridLayout::kFixedSize, checkbox_indent);
  column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
                        views::GridLayout::kFixedSize,
                        views::GridLayout::ColumnSize::kUsePreferred, 0, 0);
  layout->StartRow(views::GridLayout::kFixedSize, column_set_id);
  delete_profile_ = layout->AddView(std::make_unique<views::Checkbox>(
      l10n_util::GetStringUTF16(IDS_UNINSTALL_DELETE_PROFILE)));

  // Set default browser combo box. If the default should not or cannot be
  // changed, widgets are not shown. We assume here that if Chrome cannot
  // be set programatically as default, neither can any other browser (for
  // instance because the OS doesn't permit that).
  if (ShellUtil::CanMakeChromeDefaultUnattended() &&
      shell_integration::GetDefaultBrowser() == shell_integration::IS_DEFAULT) {
    browsers_ = std::make_unique<BrowsersMap>();
    ShellUtil::GetRegisteredBrowsers(browsers_.get());
    if (!browsers_->empty()) {
      layout->AddPaddingRow(views::GridLayout::kFixedSize,
                            related_vertical_spacing);

      ++column_set_id;
      column_set = layout->AddColumnSet(column_set_id);
      column_set->AddPaddingColumn(views::GridLayout::kFixedSize,
                                   checkbox_indent);
      column_set->AddColumn(views::GridLayout::LEADING,
                            views::GridLayout::CENTER,
                            views::GridLayout::kFixedSize,
                            views::GridLayout::ColumnSize::kUsePreferred, 0, 0);
      column_set->AddPaddingColumn(views::GridLayout::kFixedSize,
                                   related_horizontal_spacing);
      column_set->AddColumn(views::GridLayout::LEADING,
                            views::GridLayout::CENTER,
                            views::GridLayout::kFixedSize,
                            views::GridLayout::ColumnSize::kUsePreferred, 0, 0);
      layout->StartRow(views::GridLayout::kFixedSize, column_set_id);
      change_default_browser_ =
          layout->AddView(std::make_unique<views::Checkbox>(
              l10n_util::GetStringUTF16(IDS_UNINSTALL_SET_DEFAULT_BROWSER),
              this));
      browsers_combo_ =
          layout->AddView(std::make_unique<views::Combobox>(this));
      browsers_combo_->SetEnabled(false);
    }
  }

  layout->AddPaddingRow(views::GridLayout::kFixedSize, related_vertical_small);
}

void UninstallView::OnDialogAccepted() {
  user_selection_ = service_manager::RESULT_CODE_NORMAL_EXIT;
  if (delete_profile_->GetChecked())
    user_selection_ = chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE;
  if (change_default_browser_ && change_default_browser_->GetChecked()) {
    BrowsersMap::const_iterator i = browsers_->begin();
    std::advance(i, browsers_combo_->GetSelectedIndex());
    base::LaunchOptions options;
    options.start_hidden = true;
    base::LaunchProcess(i->second, options);
  }
}

void UninstallView::OnDialogCancelled() {
  user_selection_ = chrome::RESULT_CODE_UNINSTALL_USER_CANCEL;
}

void UninstallView::ButtonPressed(views::Button* sender,
                                  const ui::Event& event) {
  if (change_default_browser_ == sender) {
    // Disable the browsers combobox if the user unchecks the checkbox.
    DCHECK(browsers_combo_);
    browsers_combo_->SetEnabled(change_default_browser_->GetChecked());
  }
}

base::string16 UninstallView::GetWindowTitle() const {
  return l10n_util::GetStringUTF16(IDS_UNINSTALL_CHROME);
}

int UninstallView::GetItemCount() const {
  DCHECK(!browsers_->empty());
  return browsers_->size();
}

base::string16 UninstallView::GetItemAt(int index) {
  DCHECK_LT(index, static_cast<int>(browsers_->size()));
  BrowsersMap::const_iterator i = browsers_->begin();
  std::advance(i, index);
  return i->first;
}

namespace chrome {

int ShowUninstallBrowserPrompt() {
  DCHECK(base::MessageLoopCurrentForUI::IsSet());
  int result = service_manager::RESULT_CODE_NORMAL_EXIT;

  base::RunLoop run_loop;
  UninstallView* view = new UninstallView(&result,
                                          run_loop.QuitClosure());
  views::DialogDelegate::CreateDialogWidget(view, NULL, NULL)->Show();
  run_loop.Run();
  return result;
}

}  // namespace chrome


text:
/*
	Runner.java

	Title:			Simple Stack Machine Runner
	Author:			atze
	Description:
*/

package nl.uu.cs.ssmui;

import javax.swing.ImageIcon;

public class Images
{
	public static ImageIcon redball ;
	public static ImageIcon white ;
	public static ImageIcon check ;

	public static ImageIcon tbStart ;
	public static ImageIcon tbStartBack ;
	public static ImageIcon tbPause ;
	public static ImageIcon tbReset ;
	public static ImageIcon tbStep1 ;
	public static ImageIcon tbStep1Back ;

	public static ImageIcon tbNew ;
	public static ImageIcon tbLoad ;
	public static ImageIcon tbReload ;
	public static ImageIcon tbSave ;

	public static ImageIcon tbNewInstr ;

	private static ImageIcon getImage( String nm )
	{
		return new ImageIcon( nm.getClass().getResource( "/Images/" + nm + ".gif" ) ) ;
	}

	static
	{
		redball 	= getImage( "redball" 	    ) ;
		white 		= getImage( "white" 	    ) ;
		check 		= getImage( "check" 	    ) ;

		tbStart 	= getImage( "tb-start" 	    ) ;
		tbStartBack	= getImage( "tb-startback" 	) ;
		tbPause 	= getImage( "tb-pause" 	    ) ;
		tbReset     = getImage( "tb-reset" 	    ) ;
		tbStep1 	= getImage( "tb-step1" 	    ) ;
		tbStep1Back	= getImage( "tb-step1back"  ) ;

		tbNew 	    = getImage( "tb-new" 	    ) ;
		tbLoad 	    = getImage( "tb-load" 	    ) ;
		tbReload    = getImage( "tb-reload"     ) ;
		tbSave 	    = getImage( "tb-save" 	    ) ;

		tbNewInstr 	= getImage( "tb-newinstr" 	) ;
	}
}