pulumi/pkg/backend/display/sigint_unix.go

29 lines
824 B
Go
Raw Permalink Normal View History

[cli] Reimplement the interactive renderer The display pipleline looks like this: ╭──────╮ │Engine│ ╰──────╯ ⬇ engine events ╭────────────────╮ │Progress Display│ ╰────────────────╯ ⬇ display events: ticks, resource updates, system messages ╭─────────────────╮ │Progress Renderer│ ╰─────────────────╯ ⬇ text ╭────────╮ │Terminal│ ╰────────╯ The existing implementation of the interactive Progress Renderer is broken into two parts, the display renderer and the message renderer. The display renderer converts display events into progress messages, each of which generally represents a single line of text at a particular position in the output. The message renderer converts progress messages into screen updates by identifying whether or not the contents of a particular message have changed and if so, re-rendering its output line. In somewhat greater detail: ╭────────────────╮ │Display Renderer│ ╰────────────────╯ ⬇ convert resource rows into a tree table ⬇ convert the tree table and system messages into lines ⬇ convert each line into a progress message with an index ╭────────────────╮ │Message Renderer│ ╰────────────────╯ ⬇ if the line identified in a progress message has changed, ⬇ go to that line on the terminal, clear it, and update it ╭────────╮ │Terminal│ ╰────────╯ This separation of concerns is unnecessary and makes it difficult to understand where and when the terminal is updated. This approach also makes it somewhat challenging to change the way in which the display interacts with the terminal, as both the display renderer and the message renderer need to e.g. understand terminal dimensions, movement, etc. These changes reimplement the interactive Progress Renderer using a frame-oriented approach. The display is updated at 60 frame per second. If nothing has happened to invalidate the display's contents (i.e. no changes to the terminal geometry or the displayable contents have occurred), then the frame is not redrawn. Otherwise, the contents of the display are re-rendered and redrawn. An advantage of this approach is that it made it relatively simple to fix a long-standing issue with the interactive display: when the number of rows in the output exceed the height of the terminal, the new renderer clamps the output and allows the user to scroll the tree table using the up and down arrow keys.
2022-10-31 14:59:14 +00:00
// Copyright 2016-2022, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !windows
package display
import (
"syscall"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
)
func sigint() {
err := syscall.Kill(syscall.Getpid(), syscall.SIGINT)
contract.IgnoreError(err)
}