Support an action table that shows longest running actions

If SOONG_UI_TABLE_HEIGHT is set, enable a new smart terminal display
that prints the normal scrolling build history in the top region of
the screen and an action table of the longest currently running
actions in the bottom region of the screen.  This provides better
visibility into which are the longest running actions and when the
build parallelism is very low.

Test: manual
Change-Id: I677d7b6b008699febd259110d7f9e0f98d80c535
diff --git a/ui/terminal/util.go b/ui/terminal/util.go
index 3a11b79..c9377f1 100644
--- a/ui/terminal/util.go
+++ b/ui/terminal/util.go
@@ -35,7 +35,7 @@
 	return false
 }
 
-func termWidth(w io.Writer) (int, bool) {
+func termSize(w io.Writer) (width int, height int, ok bool) {
 	if f, ok := w.(*os.File); ok {
 		var winsize struct {
 			ws_row, ws_column    uint16
@@ -44,11 +44,11 @@
 		_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, f.Fd(),
 			syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&winsize)),
 			0, 0, 0)
-		return int(winsize.ws_column), err == 0
+		return int(winsize.ws_column), int(winsize.ws_row), err == 0
 	} else if f, ok := w.(*fakeSmartTerminal); ok {
-		return f.termWidth, true
+		return f.termWidth, f.termHeight, true
 	}
-	return 0, false
+	return 0, 0, false
 }
 
 // stripAnsiEscapes strips ANSI control codes from a byte array in place.
@@ -106,5 +106,5 @@
 
 type fakeSmartTerminal struct {
 	bytes.Buffer
-	termWidth int
+	termWidth, termHeight int
 }