~gpanders/ijq

ef1dc6b182f8e6ca81da0b83ec9bee4c5c3f428e — Gregory Anders 2 months ago 5080851
Do not block event loop when running jq
1 files changed, 8 insertions(+), 5 deletions(-)

M main.go
M main.go => main.go +8 -5
@@ 295,6 295,10 @@ func createApp(doc Document) *tview.Application {

	outputView := tview.NewTextView()
	outputView.SetDynamicColors(true).SetWrap(false).SetBorder(true)
	outputView.SetChangedFunc(func() {
		outputView.ScrollToBeginning()
		app.Draw()
	})

	errorView := tview.NewTextView()
	errorView.SetDynamicColors(true).SetTitle("Error").SetBorder(true)


@@ 313,10 317,9 @@ func createApp(doc Document) *tview.Application {
		SetFieldBackgroundColor(tcell.ColorDefault).
		SetFieldTextColor(tcell.ColorDefault).
		SetChangedFunc(func(text string) {
			go app.QueueUpdateDraw(func() {
				errorView.Clear()
				doc.filter = text
				outputView.ScrollToBeginning()
			errorView.Clear()
			doc.filter = text
			go func() {
				_, err := doc.WriteTo(outputView)
				if err != nil {
					filterInput.SetFieldTextColor(tcell.ColorMaroon)


@@ 330,7 333,7 @@ func createApp(doc Document) *tview.Application {

				outputLineCount = strings.Count(outputView.GetText(false), "\n")
				filterInput.SetFieldTextColor(tcell.ColorDefault)
			})
			}()
		}).
		SetDoneFunc(func(key tcell.Key) {
			switch key {