gcla / gowid

Compositional widgets for terminal user interfaces, written in Go, inspired by urwid.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to implement this layout

nickw8 opened this issue · comments

We are working on a small project that will let us practice vim. Your terminal ui seems like the one closest to what we want but we are having a hard time figuring it out since we are new to golang. We are trying to adjust your terminal example and would like to end up with something like the following:

Screen Shot 2021-02-17 at 3 14 30 PM

We just arent sure how to organize the widgets correctly. Any tips would be appreciated. Thanks

Hi @nickw8 - I'll get back to you later today with some suggestions :-)

Thanks, here is the repo. https://github.com/nickw8/vimkatas I think we got the panes working but now it looks like since vim captures the keystrokes, we cant sell kill commands or open a dialog box to move to the next exercise

I think we figured out the vim grabbing the keystrokes. Now we are stuck on how to get the widgets to reload once the exercise is done. Updated code is in the repo

Screen Shot 2021-02-19 at 3 24 25 PM

We got the quit button to work. The problem is we want to pull in a different file for vim, output and tips when hitting next.

our next button is set up like this:

res.view.menuWidget.nextBt.OnClick(gowid.WidgetCallback{"cb", func(app gowid.IApp, w gowid.IWidget) {
		view, _ := makeNewExerciseView()
		res.view = view
		app.Redraw()
	}})

our makeNewExcerciseView looks like this:

func makeNewExerciseView() (*exerciseView, error){

	getKata, err := handlers.SelectKata()
	kataTips := string(getKata.Tips)
	kataNum := getKata.Kata
	kataExample := string(getKata.Example)
	kataVim := getKata.VimText


	tw := text.New(" VimKatas ")
	twi := styled.New(tw, gowid.MakePaletteRef("invred"))
	twp := holder.New(tw)

	vimWidget := makeNewVimWidget(kataVim)
	outputWidget := makeNewOutputWidget(kataExample)
	tipsWidget := makeNewTipsWidget(kataTips)
	menuWidget := makeNewMenuWidget()

	outFrame := framed.New(outputWidget, framed.Options{
		Frame: framed.UnicodeFrame,
		Title: "Expected Output",
	})

	tipsFrame := framed.New(tipsWidget, framed.Options{
		Frame: framed.UnicodeFrame,
		Title: "Tips",
	})

	vimFrame := framed.New(vimWidget, framed.Options{
		Frame: framed.UnicodeFrame,
		Title: "Exercise " + kataNum,
	})

	menuFrame := framed.New(menuWidget.cols, framed.Options{
		Frame: framed.UnicodeFrame,
		Title: "Menu",
	})

	rows1 = NewResizeablePile([]gowid.IContainerWidget{
		&gowid.ContainerWidget{IWidget: vimFrame, D: gowid.RenderWithWeight{W: 3}},
		&gowid.ContainerWidget{IWidget: outFrame, D: gowid.RenderWithWeight{W: 3}},
	})

	rows2 = NewResizeablePile([]gowid.IContainerWidget{
		&gowid.ContainerWidget{IWidget: tipsFrame, D: gowid.RenderWithWeight{W: 5}},
		&gowid.ContainerWidget{IWidget: menuFrame, D: gowid.RenderWithWeight{W: 1}},
	})

	cols = NewResizeableColumns([]gowid.IContainerWidget{
		&gowid.ContainerWidget{IWidget: rows1, D: gowid.RenderWithWeight{W: 3}},
		&gowid.ContainerWidget{IWidget: rows2, D: gowid.RenderWithWeight{W: 1}},

	})

	view := framed.New(cols, framed.Options{
		Frame:       framed.UnicodeFrame,
		TitleWidget: twp,
	})


	res := &exerciseView{
		view: view,
		title: tw,
		titleInv: twi,
		holder: twp,
		vimWidget: vimWidget,
		menuWidget: menuWidget,
	}

	return res, err

can you see anything we are missing? Thanks

Hi @nickw8 - I sent you a PR with a small fix for the next button issue, and noted a couple of other details to take care of. Happy to help more - let me know!

Thanks! That helped a ton! Got it all working with your help and now looking into killing the orphaned vim stuff. Really appreciated the help