Default to the status table output
For smart terminals, default to using the status table, using 1/4 of the terminal height (with a min of 1 and a max of 10). This behavior can still be overriden to a specific height with SOONG_UI_TABLE_HEIGHT, and turned off by setting SOONG_UI_TABLE_HEIGHT to 0. Test: m <adjust terminal height, see it shrink when it gets too short> Test: SOONG_UI_TABLE_HEIGHT=20 m Test: SOONG_UI_TABLE_HEIGHT=0 m Change-Id: I224348a29a6e07f168c92cf5514a94bd27e32618
This commit is contained in:
@@ -59,21 +59,24 @@ type smartStatusOutput struct {
|
|||||||
// current build status similarly to Ninja's built-in terminal
|
// current build status similarly to Ninja's built-in terminal
|
||||||
// output.
|
// output.
|
||||||
func NewSmartStatusOutput(w io.Writer, formatter formatter) status.StatusOutput {
|
func NewSmartStatusOutput(w io.Writer, formatter formatter) status.StatusOutput {
|
||||||
tableHeight, _ := strconv.Atoi(os.Getenv(tableHeightEnVar))
|
|
||||||
|
|
||||||
s := &smartStatusOutput{
|
s := &smartStatusOutput{
|
||||||
writer: w,
|
writer: w,
|
||||||
formatter: formatter,
|
formatter: formatter,
|
||||||
|
|
||||||
haveBlankLine: true,
|
haveBlankLine: true,
|
||||||
|
|
||||||
tableMode: tableHeight > 0,
|
tableMode: true,
|
||||||
requestedTableHeight: tableHeight,
|
|
||||||
|
|
||||||
done: make(chan bool),
|
done: make(chan bool),
|
||||||
sigwinch: make(chan os.Signal),
|
sigwinch: make(chan os.Signal),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if env, ok := os.LookupEnv(tableHeightEnVar); ok {
|
||||||
|
h, _ := strconv.Atoi(env)
|
||||||
|
s.tableMode = h > 0
|
||||||
|
s.requestedTableHeight = h
|
||||||
|
}
|
||||||
|
|
||||||
s.updateTermSize()
|
s.updateTermSize()
|
||||||
|
|
||||||
if s.tableMode {
|
if s.tableMode {
|
||||||
@@ -297,6 +300,14 @@ func (s *smartStatusOutput) updateTermSize() {
|
|||||||
|
|
||||||
if s.tableMode {
|
if s.tableMode {
|
||||||
tableHeight := s.requestedTableHeight
|
tableHeight := s.requestedTableHeight
|
||||||
|
if tableHeight == 0 {
|
||||||
|
tableHeight = s.termHeight / 4
|
||||||
|
if tableHeight < 1 {
|
||||||
|
tableHeight = 1
|
||||||
|
} else if tableHeight > 10 {
|
||||||
|
tableHeight = 10
|
||||||
|
}
|
||||||
|
}
|
||||||
if tableHeight > s.termHeight-1 {
|
if tableHeight > s.termHeight-1 {
|
||||||
tableHeight = s.termHeight - 1
|
tableHeight = s.termHeight - 1
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user