You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: termdashdemo.go
    path of file: ./repos/termdash/termdashdemo
    
    the code of the file until where you have to start completion: // Copyright 2019 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Binary termdashdemo demonstrates the functionality of termdash and its various widgets.
// Exits when 'q' is pressed.
package main

import (
	"context"
	"flag"
	"fmt"
	"image"
	"log"
	"math"
	"math/rand"
	"sync"
	"time"

	"github.com/mum4k/termdash"
	"github.com/mum4k/termdash/align"
	"github.com/mum4k/termdash/cell"
	"github.com/mum4k/termdash/container"
	"github.com/mum4k/termdash/container/grid"
	"github.com/mum4k/termdash/keyboard"
	"github.com/mum4k/termdash/linestyle"
	"github.com/mum4k/termdash/terminal/tcell"
	"github.com/mum4k/termdash/terminal/termbox"
	"github.com/mum4k/termdash/terminal/terminalapi"
	"github.com/mum4k/termdash/widgets/barchart"
	"github.com/mum4k/termdash/widgets/button"
	"github.com/mum4k/termdash/widgets/donut"
	"github.com/mum4k/termdash/widgets/gauge"
	"github.com/mum4k/termdash/widgets/linechart"
	"github.com/mum4k/termdash/widgets/segmentdisplay"
	"github.com/mum4k/termdash/widgets/sparkline"
	"github.com/mum4k/termdash/widgets/text"
	"github.com/mum4k/termdash/widgets/textinput"
)

// redrawInterval is how often termdash redraws the screen.
const redrawInterval = 250 * time.Millisecond

// widgets holds the widgets used by this demo.
type widgets struct {
	segDist  *segmentdisplay.SegmentDisplay
	input    *textinput.TextInput
	rollT    *text.Text
	spGreen  *sparkline.SparkLine
	spRed    *sparkline.SparkLine
	gauge    *gauge.Gauge
	heartLC  *linechart.LineChart
	barChart *barchart.BarChart
	donut    *donut.Donut
	leftB    *button.Button
	rightB   *button.Button
	sineLC   *linechart.LineChart

	buttons *layoutButtons
}

// newWidgets creates all widgets used by this demo.
func newWidgets(ctx context.Context, t terminalapi.Terminal, c *container.Container) (*widgets, error) {
	updateText := make(chan string)
	sd, err := newSegmentDisplay(ctx, t, updateText)
	if err != nil {
		return nil, err
	}

	input, err := newTextInput(updateText)
	if err != nil {
		return nil, err
	}

	rollT, err := newRollText(ctx)
	if err != nil {
		return nil, err
	}
	spGreen, spRed, err := newSpark
    
func contLayout(w *widgets) ([]container.Option, error) {
	buttonRow := []container.Option{
		container.SplitVertical(
			container.Left(
				container.SplitVertical(
					container.Left(
						container.PlaceWidget(w.buttons.allB),
					),
					container.Right(
						container.PlaceWidget(w.buttons.textB),
					),
				),
			),
			container.Right(
				container.SplitVertical(
					container.Left(
						container.PlaceWidget(w.buttons.spB),
					),
					container.Right(
						container.PlaceWidget(w.buttons.lcB),
					),
				),
			),
		),
	}

	textAndSparks := []container.Option{
		container.SplitVertical(
			container.Left(
				container.Border(linestyle.Light),
				container.BorderTitle("A rolling text"),
				container.PlaceWidget(w.rollT),
			),
			container.Right(
				container.SplitHorizontal(
					container.Top(
						container.Border(linestyle.Light),
						container.BorderTitle("Green SparkLine"),
						container.PlaceWidget(w.spGreen),
					),
					container.Bottom(
						container.Border(linestyle.Light),
						container.BorderTitle("Red SparkLine"),
						container.PlaceWidget(w.spRed),
					),
				),
			),
		),
	}

	segmentTextInputSparks := []container.Option{
		container.SplitHorizontal(
			container.Top(
				container.Border(linestyle.Light),
				container.BorderTitle("Press Esc to quit"),
				container.PlaceWidget(w.segDist),
			),
			container.Bottom(
				container.SplitHorizontal(
					container.Top(
						container.SplitHorizontal(
							container.Top(
								container.PlaceWidget(w.input),
							),
							container.Bottom(buttonRow...),
						),
					),
					container.Bottom(textAndSparks...),
					container.SplitPercent(40),
				),
			),
			container.SplitPercent(50),
		),
	}

	gaugeAndHeartbeat := []container.Option{
		container.SplitHorizontal(
			container.Top(
				container.Border(linestyle.Light),
				container.BorderTitle("A Gauge"),
				container.BorderColor(cell.ColorNumber(39)),
				container.PlaceWidget(w.gauge),
			),
			container.Bottom(
				container.Border(linestyle.Light),
				container.BorderTitle("A LineChart"),
				container.PlaceWidget(w.heartLC),
			),
			container.SplitPercent(20),
		),
	}

	leftSide := []container.Option{
		container.SplitHorizontal(
			container.Top(segmentTextInputSparks...),
			container.Bottom(gaugeAndHeartbeat...),
			container.SplitPercent(50),
		),
	}

	lcAndButtons := []container.Option{
		container.SplitHorizontal(
			container.Top(
				container.Border(linestyle.Light),
				container.BorderTitle("Multiple series"),
				container.BorderTitleAlignRight(),
				container.PlaceWidget(w.sineLC),
			),
			container.Bottom(
				container.SplitVertical(
					container.Left(
						container.PlaceWidget(w.leftB),
						container.AlignHorizontal(align.HorizontalRight),
						container.PaddingRight(1),
					),
					container.Right(
						container.PlaceWidget(w.rightB),
						container.AlignHorizontal(align.HorizontalLeft),
						container.PaddingLeft(1),
					),
				),
			),
			container.SplitPercent(80),
		),
	}

	rightSide := []container.Option{
		container.SplitHorizontal(
			container.Top(
				container.Border(linestyle.Light),
				container.BorderTitle("BarChart"),
				container.PlaceWidget(w.barChart),
				container.BorderTitleAlignRight(),
			),
			container.Bottom(
				container.SplitHorizontal(
					container.Top(
						container.Border(linestyle.Light),
						container.BorderTitle("A Donut"),
						container.BorderTitleAlignRight(),
						container.PlaceWidget(w.donut),
					),
					container.Bottom(lcAndButtons...),
					container.SplitPercent(30),
				),
			),
			container.SplitPercent(30),
		),
	}

	return []container.Option{
		container.SplitVertical(
			container.Left(leftSide...),
			container.Right(rightSide...),
			container.SplitPercent(70),
		),
	}, nil
}