aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2019-09-20 15:01:51 -0700
committerLuca Stefani <luca.stefani.ge1@gmail.com>2019-09-26 19:29:24 +0200
commita0e8dcc3dbdf2aaf60da063c7497bfca055b0722 (patch)
treeba05a9c9f4c37b9bdd678fc41e88097a3485789e
parent53e35a9ded66973a17d03da854a966f0e61192f7 (diff)
downloadbuild_soong-a0e8dcc3dbdf2aaf60da063c7497bfca055b0722.tar.gz
build_soong-a0e8dcc3dbdf2aaf60da063c7497bfca055b0722.tar.bz2
build_soong-a0e8dcc3dbdf2aaf60da063c7497bfca055b0722.zip
status table: don't write newlines in non-scrolling terminals
Multiple terminals have had issues with writing newlines into the non-scrolling region, just set the cursor to the beginning of the next line instead. Test: m nothing in JediTerm Change-Id: I2e434f4cc263ca13b82889a79d6a8bb48d084cb3
-rw-r--r--ui/terminal/smart_status.go50
1 files changed, 21 insertions, 29 deletions
diff --git a/ui/terminal/smart_status.go b/ui/terminal/smart_status.go
index aa7e50a4..efcfd435 100644
--- a/ui/terminal/smart_status.go
+++ b/ui/terminal/smart_status.go
@@ -334,48 +334,40 @@ func (s *smartStatusOutput) actionTable() {
scrollingHeight := s.termHeight - s.tableHeight
// Update the scrolling region in case the height of the terminal changed
+
fmt.Fprint(s.writer, ansi.setScrollingMargins(1, scrollingHeight))
- // Move the cursor to the first line of the non-scrolling region
- fmt.Fprint(s.writer, ansi.setCursor(scrollingHeight+1, 1))
// Write as many status lines as fit in the table
- var tableLine int
- var runningAction actionTableEntry
- for tableLine, runningAction = range s.runningActions {
+ for tableLine := 0; tableLine < s.tableHeight; tableLine++ {
if tableLine >= s.tableHeight {
break
}
+ // Move the cursor to the correct line of the non-scrolling region
+ fmt.Fprint(s.writer, ansi.setCursor(scrollingHeight+1+tableLine, 1))
- seconds := int(time.Since(runningAction.startTime).Round(time.Second).Seconds())
+ if tableLine < len(s.runningActions) {
+ runningAction := s.runningActions[tableLine]
- desc := runningAction.action.Description
- if desc == "" {
- desc = runningAction.action.Command
- }
+ seconds := int(time.Since(runningAction.startTime).Round(time.Second).Seconds())
- color := ""
- if seconds >= 60 {
- color = ansi.red() + ansi.bold()
- } else if seconds >= 30 {
- color = ansi.yellow() + ansi.bold()
- }
+ desc := runningAction.action.Description
+ if desc == "" {
+ desc = runningAction.action.Command
+ }
- durationStr := fmt.Sprintf(" %2d:%02d ", seconds/60, seconds%60)
- desc = elide(desc, s.termWidth-len(durationStr))
- durationStr = color + durationStr + ansi.regular()
+ color := ""
+ if seconds >= 60 {
+ color = ansi.red() + ansi.bold()
+ } else if seconds >= 30 {
+ color = ansi.yellow() + ansi.bold()
+ }
- fmt.Fprint(s.writer, durationStr, desc, ansi.clearToEndOfLine())
- if tableLine < s.tableHeight-1 {
- fmt.Fprint(s.writer, "\n")
+ durationStr := fmt.Sprintf(" %2d:%02d ", seconds/60, seconds%60)
+ desc = elide(desc, s.termWidth-len(durationStr))
+ durationStr = color + durationStr + ansi.regular()
+ fmt.Fprint(s.writer, durationStr, desc)
}
- }
-
- // Clear any remaining lines in the table
- for ; tableLine < s.tableHeight; tableLine++ {
fmt.Fprint(s.writer, ansi.clearToEndOfLine())
- if tableLine < s.tableHeight-1 {
- fmt.Fprint(s.writer, "\n")
- }
}
// Move the cursor back to the last line of the scrolling region